Skip to content

Commit

Permalink
Облагороженная версия проекта ESP8266 ILI9341
Browse files Browse the repository at this point in the history
  • Loading branch information
Sermus committed Mar 11, 2015
1 parent 9da4b17 commit 36f163a
Show file tree
Hide file tree
Showing 26 changed files with 49 additions and 169 deletions.
6 changes: 3 additions & 3 deletions .cproject
Expand Up @@ -5,19 +5,19 @@
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.mingw.base.1135534147" moduleId="org.eclipse.cdt.core.settings" name="Default">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration buildProperties="" description="" id="cdt.managedbuild.toolchain.gnu.mingw.base.1135534147" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
<configuration artifactName="${ProjName}" buildProperties="" description="" id="cdt.managedbuild.toolchain.gnu.mingw.base.1135534147" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
<folderInfo id="cdt.managedbuild.toolchain.gnu.mingw.base.1135534147.86962463" name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.base.18106306" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.base">
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.PE" id="cdt.managedbuild.target.gnu.platform.mingw.base.1721398479" name="Debug Platform" osList="win32" superClass="cdt.managedbuild.target.gnu.platform.mingw.base"/>
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.GNU_ELF" id="cdt.managedbuild.target.gnu.platform.mingw.base.1721398479" name="Debug Platform" osList="win32" superClass="cdt.managedbuild.target.gnu.platform.mingw.base"/>
<builder arguments="-f ${ProjDirPath}/Makefile" command="mingw32-make.exe" id="cdt.managedbuild.builder.gnu.cross.1876460142" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.builder.gnu.cross"/>
<tool id="cdt.managedbuild.tool.gnu.assembler.mingw.base.1056286588" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.base">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1833681201" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Expand Up @@ -132,14 +132,14 @@ endif
TARGET = app

# which modules (subdirectories) of the project to include in compiling
MODULES = driver user
EXTRA_INCDIR = include $(SDK_BASE)/../include
MODULES = driver math user
EXTRA_INCDIR = include include\driver include\math $(SDK_BASE)/../include

# libraries used in this project, mainly provided by the SDK
LIBS = c gcc hal phy pp net80211 lwip wpa main

# compiler flags using during compilation of source files
CFLAGS = -Os -g -O2 -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH
CFLAGS = -O2 -Wpointer-arith -Wundef -Werror -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH
CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions

# linker flags used to generate the main object file
Expand Down
53 changes: 1 addition & 52 deletions user/Adafruit_GFX_AS.cpp → driver/Adafruit_GFX_AS.cpp
Expand Up @@ -54,7 +54,7 @@ extern "C" {
#endif

#define abs(x) ((x)<0 ? -(x) : (x))
extern "C" int ets_uart_printf(const char *fmt, ...);
#define swap(x, y) do { typeof(x) temp##x##y = x; x = y; y = temp##x##y; } while (0)

ICACHE_FLASH_ATTR Adafruit_GFX_AS::Adafruit_GFX_AS(int16_t w, int16_t h):
WIDTH(w), HEIGHT(h)
Expand All @@ -64,7 +64,6 @@ ICACHE_FLASH_ATTR Adafruit_GFX_AS::Adafruit_GFX_AS(int16_t w, int16_t h):
rotation = 0;
textcolor = textbgcolor = 0xFFFF;
wrap = true;
ets_uart_printf("Adafruit_GFX_AS::Adafruit_GFX_AS()");
}

// Draw a circle outline
Expand Down Expand Up @@ -247,11 +246,8 @@ void Adafruit_GFX_AS::fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
}
}

extern "C" int ets_uart_printf(const char *fmt, ...);

void Adafruit_GFX_AS::fillScreen(uint16_t color) {
fillRect(0, 0, _width, _height, color);
ets_uart_printf("%d x %d", _width, _height);
}

// Draw a rounded rectangle
Expand Down Expand Up @@ -422,14 +418,6 @@ void Adafruit_GFX_AS::invertDisplay(bool i) {
// Do nothing, must be subclassed if supported
}

ICACHE_FLASH_ATTR void Adafruit_GFX_AS::drawQuad(int16_t x, int16_t y, uint16_t color)
{
drawPixel(x, y, color);
drawPixel(x + 1, y, color);
drawPixel(x, y + 1, color);
drawPixel(x + 1, y + 1, color);
}

/***************************************************************************************
** Function name: drawUnicode
** Descriptions: draw a unicode
Expand Down Expand Up @@ -487,12 +475,6 @@ ICACHE_FLASH_ATTR int Adafruit_GFX_AS::drawUnicode(uint16_t uniCode, uint16_t x,
height = chr_hgt_f7s;
gap = 2;
}
if (size == 8) {
flash_address = chrtbl_f7s[uniCode];
width = *(widtbl_f7s+uniCode);
height = chr_hgt_f7s;
gap = 4;
}
#endif

uint16_t w = (width+ 7) / 8;
Expand All @@ -501,8 +483,6 @@ ICACHE_FLASH_ATTR int Adafruit_GFX_AS::drawUnicode(uint16_t uniCode, uint16_t x,
uint16_t color = 0;
uint8_t line = 0;

if (size < 8)
{
for(int i=0; i<height; i++)
{
if (textcolor != textbgcolor) drawFastHLine(x, pY, width+gap, textbgcolor);
Expand All @@ -523,35 +503,6 @@ ICACHE_FLASH_ATTR int Adafruit_GFX_AS::drawUnicode(uint16_t uniCode, uint16_t x,
}
pY++;
}
}
else if (size == 8)
{
for(int i=0; i<height; i++)
{
if (textcolor != textbgcolor)
{
drawFastHLine(x, pY, width * 2+gap, textbgcolor);
drawFastHLine(x, pY + 1, width * 2+gap, textbgcolor);
}
for (int k = 0;k < w; k++)
{
line = *(flash_address+w*i+k);
if(line) {
pX = x + k*16;
if(line & 0x80) drawQuad(pX, pY, textcolor);
if(line & 0x40) drawQuad(pX+2, pY, textcolor);
if(line & 0x20) drawQuad(pX+4, pY, textcolor);
if(line & 0x10) drawQuad(pX+6, pY, textcolor);
if(line & 0x8) drawQuad(pX+8, pY, textcolor);
if(line & 0x4) drawQuad(pX+10, pY, textcolor);
if(line & 0x2) drawQuad(pX+12, pY, textcolor);
if(line & 0x1) drawQuad(pX+14, pY, textcolor);
}
}
pY += 2;
}
width *= 2;
}
return width+gap; // x +
}

Expand All @@ -565,7 +516,6 @@ ICACHE_FLASH_ATTR int Adafruit_GFX_AS::drawNumber(long long_num,uint16_t poX, ui
if (long_num < 0) snprintf(tmp, sizeof(tmp), "%d", long_num);
else snprintf(tmp, sizeof(tmp), "%u", long_num);
return drawString(tmp, poX, poY, size);

}

/***************************************************************************************
Expand Down Expand Up @@ -630,7 +580,6 @@ ICACHE_FLASH_ATTR int Adafruit_GFX_AS::drawCentreString(const char *string, uint
#endif
#ifdef LOAD_FONT7
if (size==7) len += *(widtbl_f7s+ascii-32)+2;
if (size==8) len += (*(widtbl_f7s+ascii-32)+2) * 2;
*pointer++;
#endif
}
Expand Down
@@ -1,18 +1,3 @@
/***************************************************
This is our library for the Adafruit ILI9341 Breakout and Shield
----> http://www.adafruit.com/products/1651
Check out the links above for our tutorials and wiring diagrams
These displays use SPI to communicate, 4 or 5 pins are required to
interface (RST is optional)
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
MIT license, all text above must be included in any redistribution
****************************************************/

#include "Adafruit_ILI9341_fast_as.h"
#include "Adafruit_GFX_AS.h"

Expand All @@ -24,11 +9,8 @@ extern "C"{
#include "espmissingincludes.h"
}

extern "C" int ets_uart_printf(const char *fmt, ...);

ICACHE_FLASH_ATTR Adafruit_ILI9341::Adafruit_ILI9341() : Adafruit_GFX_AS(ILI9341_TFTWIDTH, ILI9341_TFTHEIGHT) {
tabcolor = 0;
ets_uart_printf("Adafruit_ILI9341::Adafruit_ILI9341()");
}

void Adafruit_ILI9341::transmitCmdData(uint8_t cmd, const uint8_t *data, uint8_t numDataByte)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions user/hspi.c → driver/hspi.c
Expand Up @@ -40,7 +40,7 @@ void hspi_init(void)
WRITE_PERI_REG(SPI_FLASH_USER(HSPI), regvalue);
}

void hspi_send_uint16_r(uint16_t data, uint32_t repeats)
void hspi_send_uint16_r(uint16_t data, int32_t repeats)
{
uint32_t i;
uint32_t word = data << 16 | data;
Expand All @@ -49,11 +49,11 @@ void hspi_send_uint16_r(uint16_t data, uint32_t repeats)
{
uint8_t words_to_transfer = __min((repeats + 1) / 2, SPIFIFOSIZE);
hspi_wait_ready();
hspi_prepare_tx(__min(repeats * 2, SPIFIFOSIZE * 4));
hspi_prepare_tx(__min(repeats * sizeof(uint16_t), SPIFIFOSIZE * sizeof(uint32_t)));
for(i = 0; i < words_to_transfer;i++)
spi_fifo[i] = word;
hspi_start_tx();
repeats -= words_to_transfer * 2;
repeats -= words_to_transfer * sizeof(uint32_t);
}
}

Expand Down
File renamed without changes.
13 changes: 5 additions & 8 deletions include/cpp_routines/routines.h
@@ -1,18 +1,15 @@
/*
* routines.h
*
* Created on: 18 ÿíâ. 2015 ã.
* Author: Alex
*/

#pragma once
#ifndef INCLUDE_ROUTINES_H_
#define INCLUDE_ROUTINES_H_

#define os_malloc pvPortMalloc
#define os_free vPortFree
#define os_zalloc pvPortZalloc

void do_global_ctors(void);

#endif /* INCLUDE_ROUTINES_H_ */





15 changes: 11 additions & 4 deletions include/cube.h
@@ -1,13 +1,20 @@
#ifndef INCLUDE_CUBE_H_
#define INCLUDE_CUBE_H_

#define AMOUNT_NODE 8
#define VERTEX_COUNT 8

#ifdef __cplusplus
extern "C" {
#endif

#include <math.h>
#include <osapi.h>

void cube_calculate(int16_t _pix[AMOUNT_NODE][3], double degreeX, double degreeY, double degreeZ, double scale, int16_t shiftX, int16_t shiftY, int16_t shiftZ);
void cube_draw(int16_t _pix[AMOUNT_NODE][3], uint16_t color);
void cube_draw_init();
void cube_calculate(int16_t _pix[VERTEX_COUNT][3], double degreeX, double degreeY, double degreeZ, double scale, int16_t shiftX, int16_t shiftY, int16_t shiftZ);
void cube_draw(int16_t _pix[VERTEX_COUNT][3], uint16_t color);

#ifdef __cplusplus
};
#endif

#endif /* INCLUDE_CUBE_H_ */
Expand Up @@ -2,19 +2,15 @@
#define _ADAFRUIT_GFX_AS_H

#include "Load_fonts.h"
#include <ets_sys.h>
#include <c_types.h>

#define swap(a, b) { int16_t t = a; a = b; b = t; }

class Adafruit_GFX_AS {

public:

Adafruit_GFX_AS(int16_t w, int16_t h); // Constructor

// This MUST be defined by the subclass:
virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0;
void drawQuad(int16_t x, int16_t y, uint16_t color);

// These MAY be overridden by the subclass to provide device-specific
// optimized code. Otherwise 'generic' versions are used.
Expand Down
@@ -1,27 +1,15 @@
/***************************************************
This is our library for the Adafruit ILI9341 Breakout and Shield
----> http://www.adafruit.com/products/1651
Check out the links above for our tutorials and wiring diagrams
These displays use SPI to communicate, 4 or 5 pins are required to
interface (RST is optional)
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
MIT license, all text above must be included in any redistribution
****************************************************/

#ifndef _ADAFRUIT_ILI9341H_
#define _ADAFRUIT_ILI9341H_

#include "Adafruit_GFX_AS.h"

extern "C"
{
#include <osapi.h>
#include <gpio.h>
#include "hspi.h"
}

#define ILI9341_TFTWIDTH 240
#define ILI9341_TFTHEIGHT 320

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 1 addition & 4 deletions include/hspi.h → include/driver/hspi.h
Expand Up @@ -15,17 +15,14 @@ extern uint32_t *spi_fifo;

extern void hspi_init(void);
extern void hspi_send_data(const uint8_t * data, uint8_t datasize);
extern void hspi_send_uint16_r(const uint16_t data, uint32_t repeats);
extern void hspi_send_uint16_r(const uint16_t data, int32_t repeats);
inline void hspi_wait_ready(void){while (READ_PERI_REG(SPI_FLASH_CMD(HSPI))&SPI_FLASH_USR);}

inline void hspi_prepare_tx(uint32_t bytecount)
{
uint32_t bitcount = bytecount * 8 - 1;

WRITE_PERI_REG(SPI_FLASH_USER1(HSPI), (bitcount & SPI_USR_OUT_BITLEN) << SPI_USR_OUT_BITLEN_S);
// WRITE_PERI_REG(SPI_FLASH_USER1(HSPI),
// ( (bitcount & SPI_USR_OUT_BITLEN) << SPI_USR_OUT_BITLEN_S ) |
// ( (bitcount & SPI_USR_DIN_BITLEN) << SPI_USR_DIN_BITLEN_S ) );
}


Expand Down
File renamed without changes.
8 changes: 8 additions & 0 deletions include/cordic.h → include/math/cordic.h
Expand Up @@ -8,6 +8,10 @@
// 1.0 = 1073741824
// 1/k = 0.6072529350088812561694

#ifdef __cplusplus
extern "C" {
#endif

//Constants
#define M_PI 3.14159265358979323846
#define cordic_1K 0x26DD3B6A
Expand All @@ -16,5 +20,9 @@
#define CORDIC_NTAB 32

void cordic(double degree, double *s, double *c);

#ifdef __cplusplus
};
#endif

#endif /* INCLUDE_CORDIC_H_ */
7 changes: 0 additions & 7 deletions user/cordic.cpp → math/cordic.c
@@ -1,10 +1,3 @@
/*
* cordic.c
*
* Created on: 28 ÿíâ. 2015 ã.
* Author: Sem
*/

#include "cordic.h"

static int cordic_ctab [CORDIC_NTAB] = { 0x3243F6A8, 0x1DAC6705, 0x0FADBAFC, 0x07F56EA6, 0x03FEAB76, 0x01FFD55B,
Expand Down

0 comments on commit 36f163a

Please sign in to comment.