Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/tft_library/lcd_com.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ typedef struct {
uint16_t _height;
uint16_t _offsetx;
uint16_t _offsety;
uint16_t _font_direction;
font_direction_t _font_direction;
uint16_t _font_fill;
uint16_t _font_fill_color;
uint16_t _font_underline;
Expand Down
26 changes: 13 additions & 13 deletions components/tft_library/lcd_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ int lcdDrawChar(TFT_t * dev, FontxFile *fxs, uint16_t x, uint16_t y, uint8_t asc
int16_t y0 = 0;
int16_t y1 = 0;

if (dev->_font_direction == 0) {
if (dev->_font_direction == DIRECTION0) {
xd1 = +1;
yd1 = +1; //-1;
xd2 = 0;
Expand All @@ -480,7 +480,7 @@ int lcdDrawChar(TFT_t * dev, FontxFile *fxs, uint16_t x, uint16_t y, uint8_t asc
y0 = y - (ph-1);
x1 = x + (pw-1);
y1 = y;
} else if (dev->_font_direction == 2) {
} else if (dev->_font_direction == DIRECTION180) {
xd1 = -1;
yd1 = -1; //+1;
xd2 = 0;
Expand All @@ -495,7 +495,7 @@ int lcdDrawChar(TFT_t * dev, FontxFile *fxs, uint16_t x, uint16_t y, uint8_t asc
y0 = y;
x1 = x;
y1 = y + (ph-1);
} else if (dev->_font_direction == 1) {
} else if (dev->_font_direction == DIRECTION90) {
xd1 = 0;
yd1 = 0;
xd2 = -1;
Expand All @@ -510,7 +510,7 @@ int lcdDrawChar(TFT_t * dev, FontxFile *fxs, uint16_t x, uint16_t y, uint8_t asc
y0 = y;
x1 = x + (ph-1);
y1 = y + (pw-1);
} else if (dev->_font_direction == 3) {
} else if (dev->_font_direction == DIRECTION270) {
xd1 = 0;
yd1 = 0;
xd2 = +1;
Expand Down Expand Up @@ -575,19 +575,19 @@ int lcdDrawString(TFT_t * dev, FontxFile *fx, uint16_t x, uint16_t y, uint8_t *
if(_DEBUG_)printf("lcdDrawString length=%d\n",length);
for(int i=0;i<length;i++) {
if(_DEBUG_)printf("ascii[%d]=%x x=%d y=%d\n",i,ascii[i],x,y);
if (dev->_font_direction == 0)
if (dev->_font_direction == DIRECTION0)
x = lcdDrawChar(dev, fx, x, y, ascii[i], color);
if (dev->_font_direction == 1)
if (dev->_font_direction == DIRECTION90)
y = lcdDrawChar(dev, fx, x, y, ascii[i], color);
if (dev->_font_direction == 2)
if (dev->_font_direction == DIRECTION180)
x = lcdDrawChar(dev, fx, x, y, ascii[i], color);
if (dev->_font_direction == 3)
if (dev->_font_direction == DIRECTION270)
y = lcdDrawChar(dev, fx, x, y, ascii[i], color);
}
if (dev->_font_direction == 0) return x;
if (dev->_font_direction == 2) return x;
if (dev->_font_direction == 1) return y;
if (dev->_font_direction == 3) return y;
if (dev->_font_direction == DIRECTION0) return x;
if (dev->_font_direction == DIRECTION90) return x;
if (dev->_font_direction == DIRECTION180) return y;
if (dev->_font_direction == DIRECTION270) return y;
return 0;
}

Expand Down Expand Up @@ -746,7 +746,7 @@ int lcdDrawUTF8String(TFT_t * dev, FontxFile *fx, uint16_t x, uint16_t y, unsign

// Set font direction
// dir:Direction
void lcdSetFontDirection(TFT_t * dev, uint16_t dir) {
void lcdSetFontDirection(TFT_t * dev, font_direction_t dir) {
dev->_font_direction = dir;
}

Expand Down
13 changes: 7 additions & 6 deletions components/tft_library/lcd_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
#define CYAN 0x07FF
#define PURPLE 0xF81F


#define DIRECTION0 0
#define DIRECTION90 1
#define DIRECTION180 2
#define DIRECTION270 3
typedef enum {
DIRECTION0,
DIRECTION90,
DIRECTION180,
DIRECTION270
} font_direction_t

/*
The version of GCC has changed.
Expand Down Expand Up @@ -78,7 +79,7 @@ int lcdDrawString(TFT_t * dev, FontxFile *fx, uint16_t x, uint16_t y, uint8_t *
//int lcdDrawSJISChar(TFT_t * dev, FontxFile *fx, uint16_t x, uint16_t y, uint16_t sjis, uint16_t color);
//int lcdDrawUTF8Char(TFT_t * dev, FontxFile *fx, uint16_t x, uint16_t y, uint8_t *utf8, uint16_t color);
//int lcdDrawUTF8String(TFT_t * dev, FontxFile *fx, uint16_t x, uint16_t y, unsigned char *utfs, uint16_t color);
void lcdSetFontDirection(TFT_t * dev, uint16_t);
void lcdSetFontDirection(TFT_t * dev, font_direction_t);
void lcdSetFontFill(TFT_t * dev, uint16_t color);
void lcdUnsetFontFill(TFT_t * dev);
void lcdSetFontUnderLine(TFT_t * dev, uint16_t color);
Expand Down
32 changes: 16 additions & 16 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,22 +310,22 @@ TickType_t DirectionTest(TFT_t * dev, FontxFile *fx, int width, int height) {

color = RED;
strcpy((char *)ascii, "Direction=0");
lcdSetFontDirection(dev, 0);
lcdSetFontDirection(dev, DIRECTION0);
lcdDrawString(dev, fx, 0, fontHeight-1, ascii, color);

color = BLUE;
strcpy((char *)ascii, "Direction=2");
lcdSetFontDirection(dev, 2);
lcdSetFontDirection(dev, DIRECTION180);
lcdDrawString(dev, fx, (width-1), (height-1)-(fontHeight*1), ascii, color);

color = CYAN;
strcpy((char *)ascii, "Direction=1");
lcdSetFontDirection(dev, 1);
lcdSetFontDirection(dev, DIRECTION90);
lcdDrawString(dev, fx, (width-1)-fontHeight, 0, ascii, color);

color = GREEN;
strcpy((char *)ascii, "Direction=3");
lcdSetFontDirection(dev, 3);
lcdSetFontDirection(dev, DIRECTION270);
lcdDrawString(dev, fx, (fontHeight-1), height-1, ascii, color);

endTick = xTaskGetTickCount();
Expand All @@ -351,7 +351,7 @@ TickType_t HorizontalTest(TFT_t * dev, FontxFile *fx, int width, int height) {

color = RED;
strcpy((char *)ascii, "Direction=0");
lcdSetFontDirection(dev, 0);
lcdSetFontDirection(dev, DIRECTION0);
lcdDrawString(dev, fx, 0, fontHeight*1-1, ascii, color);
lcdSetFontUnderLine(dev, RED);
lcdDrawString(dev, fx, 0, fontHeight*2-1, ascii, color);
Expand All @@ -366,7 +366,7 @@ TickType_t HorizontalTest(TFT_t * dev, FontxFile *fx, int width, int height) {

color = BLUE;
strcpy((char *)ascii, "Direction=2");
lcdSetFontDirection(dev, 2);
lcdSetFontDirection(dev, DIRECTION180);
lcdDrawString(dev, fx, width-1, height-(fontHeight*1)-1, ascii, color);
lcdSetFontUnderLine(dev, BLUE);
lcdDrawString(dev, fx, width-1, height-(fontHeight*2)-1, ascii, color);
Expand Down Expand Up @@ -402,7 +402,7 @@ TickType_t VerticalTest(TFT_t * dev, FontxFile *fx, int width, int height) {

color = RED;
strcpy((char *)ascii, "Direction=1");
lcdSetFontDirection(dev, 1);
lcdSetFontDirection(dev, DIRECTION90);
lcdDrawString(dev, fx, width-(fontHeight*1), 0, ascii, color);
lcdSetFontUnderLine(dev, RED);
lcdDrawString(dev, fx, width-(fontHeight*2), 0, ascii, color);
Expand All @@ -417,7 +417,7 @@ TickType_t VerticalTest(TFT_t * dev, FontxFile *fx, int width, int height) {

color = BLUE;
strcpy((char *)ascii, "Direction=3");
lcdSetFontDirection(dev, 3);
lcdSetFontDirection(dev, DIRECTION270);
lcdDrawString(dev, fx, (fontHeight*1)-1, height-1, ascii, color);
lcdSetFontUnderLine(dev, BLUE);
lcdDrawString(dev, fx, (fontHeight*2)-1, height-1, ascii, color);
Expand Down Expand Up @@ -638,7 +638,7 @@ TickType_t ScrollTest(TFT_t * dev, FontxFile *fx, int width, int height) {
int ymax = (lines+1) * fontHeight;
ESP_LOGD(__FUNCTION__, "ymax=%d",ymax);

lcdSetFontDirection(dev, 0);
lcdSetFontDirection(dev, DIRECTION0);
lcdFillScreen(dev, BLACK);

strcpy((char *)ascii, "Vertical Smooth Scroll");
Expand Down Expand Up @@ -686,7 +686,7 @@ TickType_t BMPTest(TFT_t * dev, char * file, int width, int height) {
TickType_t startTick, endTick, diffTick;
startTick = xTaskGetTickCount();

lcdSetFontDirection(dev, 0);
lcdSetFontDirection(dev, DIRECTION0);
lcdFillScreen(dev, BLACK);

// open BMP file
Expand Down Expand Up @@ -845,7 +845,7 @@ TickType_t JPEGTest(TFT_t * dev, char * file, int width, int height) {
TickType_t startTick, endTick, diffTick;
startTick = xTaskGetTickCount();

lcdSetFontDirection(dev, 0);
lcdSetFontDirection(dev, DIRECTION0);
lcdFillScreen(dev, BLACK);

int _width = width;
Expand Down Expand Up @@ -921,7 +921,7 @@ TickType_t PNGTest(TFT_t * dev, char * file, int width, int height) {
TickType_t startTick, endTick, diffTick;
startTick = xTaskGetTickCount();

lcdSetFontDirection(dev, 0);
lcdSetFontDirection(dev, DIRECTION0);
lcdFillScreen(dev, BLACK);

int _width = width;
Expand Down Expand Up @@ -1294,7 +1294,7 @@ typedef struct {
} AREA_t;

void ShowAllPngImage(TFT_t * dev, char * path, int max, FontxFile *fx, int width, int height, AREA_t *area) {
lcdSetFontDirection(dev, 0);
lcdSetFontDirection(dev, DIRECTION0);
lcdFillScreen(dev, WHITE);

char file[64];
Expand Down Expand Up @@ -1614,13 +1614,13 @@ void TFT(void *pvParameters)
uint16_t margin = 10;
lcdFillScreen(&dev, BLACK);
color = WHITE;
lcdSetFontDirection(&dev, 0);
lcdSetFontDirection(&dev, DIRECTION0);
uint16_t xpos = 0;
uint16_t ypos = 15;
int xd = 0;
int yd = 1;
if(CONFIG_WIDTH < CONFIG_HEIGHT) {
lcdSetFontDirection(&dev, 1);
lcdSetFontDirection(&dev, DIRECTION90);
xpos = (CONFIG_WIDTH-1)-16;
ypos = 0;
xd = 1;
Expand Down Expand Up @@ -1659,7 +1659,7 @@ void TFT(void *pvParameters)
strcpy((char *)ascii, "32Dot Mincyo Font");
lcdDrawString(&dev, fx32M, xpos, ypos, ascii, color);
}
lcdSetFontDirection(&dev, 0);
lcdSetFontDirection(&dev, DIRECTION0);
WAIT;
} // end while
}
Expand Down