|
@@ -239,17 +239,26 @@ static void ST7735_WriteChar(uint16_t x, uint16_t y, char ch, FontDef font, uint
|
|
|
|
|
|
ST7735_SetAddressWindow(x, y, x+font.width-1, y+font.height-1);
|
|
ST7735_SetAddressWindow(x, y, x+font.width-1, y+font.height-1);
|
|
|
|
|
|
|
|
+ LCD_DC_DATA;
|
|
|
|
+ SPI1->CR1 |= SPI_CR1_DFF;
|
|
|
|
+
|
|
|
|
+ uint16_t ih = (ch - 32) * font.height;
|
|
for(i = 0; i < font.height; i++) {
|
|
for(i = 0; i < font.height; i++) {
|
|
- b = font.data[(ch - 32) * font.height + i];
|
|
|
|
|
|
+ b = font.data[ih + i];
|
|
for(j = 0; j < font.width; j++) {
|
|
for(j = 0; j < font.width; j++) {
|
|
if (b & 0x8000) {
|
|
if (b & 0x8000) {
|
|
- ST7735_WriteData16(color);
|
|
|
|
|
|
+ while (!(SPI1->SR & SPI_SR_TXE));
|
|
|
|
+ SPI1->DR = color;
|
|
} else {
|
|
} else {
|
|
- ST7735_WriteData16(bgcolor);
|
|
|
|
|
|
+ while (!(SPI1->SR & SPI_SR_TXE));
|
|
|
|
+ SPI1->DR = bgcolor;
|
|
}
|
|
}
|
|
b <<= 1;
|
|
b <<= 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ while (!(SPI1->SR & SPI_SR_TXE));
|
|
|
|
+ while ((SPI1->SR & SPI_SR_BSY));
|
|
|
|
+ SPI1->CR1 &= ~(SPI_CR1_DFF);
|
|
}
|
|
}
|
|
|
|
|
|
void ST7735_WriteString(uint16_t x, uint16_t y, const char* str, FontDef font, uint16_t color, uint16_t bgcolor) {
|
|
void ST7735_WriteString(uint16_t x, uint16_t y, const char* str, FontDef font, uint16_t color, uint16_t bgcolor) {
|
|
@@ -289,7 +298,7 @@ void ST7735_WriteString(uint16_t x, uint16_t y, const char* str, FontDef font, u
|
|
* @param bgcolor background color
|
|
* @param bgcolor background color
|
|
*/
|
|
*/
|
|
static void ST7735_WriteCharV(uint16_t x, uint16_t y, char ch, FontDefV font, uint16_t color, uint16_t bgcolor) {
|
|
static void ST7735_WriteCharV(uint16_t x, uint16_t y, char ch, FontDefV font, uint16_t color, uint16_t bgcolor) {
|
|
- uint32_t i, b, j;
|
|
|
|
|
|
+ uint16_t i, b, j;
|
|
uint8_t c, w, h;
|
|
uint8_t c, w, h;
|
|
|
|
|
|
c = ch - 32;
|
|
c = ch - 32;
|
|
@@ -301,8 +310,9 @@ static void ST7735_WriteCharV(uint16_t x, uint16_t y, char ch, FontDefV font, ui
|
|
LCD_DC_DATA;
|
|
LCD_DC_DATA;
|
|
SPI1->CR1 |= SPI_CR1_DFF;
|
|
SPI1->CR1 |= SPI_CR1_DFF;
|
|
|
|
|
|
|
|
+ uint16_t ih = c * h;
|
|
for(i = 0; i < h; i++) {
|
|
for(i = 0; i < h; i++) {
|
|
- b = font.data[c * h + i]; // ??? замінити на масив позицій
|
|
|
|
|
|
+ b = font.data[ih+i]; // ??? замінити на масив позицій
|
|
for(j = 0; j < w; j++) {
|
|
for(j = 0; j < w; j++) {
|
|
if (b & 0x8000) {
|
|
if (b & 0x8000) {
|
|
while (!(SPI1->SR & SPI_SR_TXE));
|
|
while (!(SPI1->SR & SPI_SR_TXE));
|
|
@@ -314,7 +324,6 @@ static void ST7735_WriteCharV(uint16_t x, uint16_t y, char ch, FontDefV font, ui
|
|
b <<= 1;
|
|
b <<= 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
while (!(SPI1->SR & SPI_SR_TXE));
|
|
while (!(SPI1->SR & SPI_SR_TXE));
|
|
while ((SPI1->SR & SPI_SR_BSY));
|
|
while ((SPI1->SR & SPI_SR_BSY));
|
|
SPI1->CR1 &= ~(SPI_CR1_DFF);
|
|
SPI1->CR1 &= ~(SPI_CR1_DFF);
|
|
@@ -323,8 +332,10 @@ static void ST7735_WriteCharV(uint16_t x, uint16_t y, char ch, FontDefV font, ui
|
|
void ST7735_WriteStringV(uint16_t x, uint16_t y, const char* str, FontDefV font, uint16_t color, uint16_t bgcolor) {
|
|
void ST7735_WriteStringV(uint16_t x, uint16_t y, const char* str, FontDefV font, uint16_t color, uint16_t bgcolor) {
|
|
ST7735_Select();
|
|
ST7735_Select();
|
|
|
|
|
|
|
|
+ uint8_t w;
|
|
while (*str) {
|
|
while (*str) {
|
|
- if (x + font.width[(uint8_t)*str] >= ST7735_WIDTH) {
|
|
|
|
|
|
+ w = font.width[(uint8_t)*str];
|
|
|
|
+ if (x + w >= ST7735_WIDTH) {
|
|
x = 0;
|
|
x = 0;
|
|
y += font.height;
|
|
y += font.height;
|
|
if (y + font.height >= ST7735_HEIGHT) {
|
|
if (y + font.height >= ST7735_HEIGHT) {
|
|
@@ -339,7 +350,7 @@ void ST7735_WriteStringV(uint16_t x, uint16_t y, const char* str, FontDefV font,
|
|
}
|
|
}
|
|
|
|
|
|
ST7735_WriteCharV(x, y, *str, font, color, bgcolor);
|
|
ST7735_WriteCharV(x, y, *str, font, color, bgcolor);
|
|
- x += font.width[(uint8_t)*str];
|
|
|
|
|
|
+ x += w;
|
|
str ++;
|
|
str ++;
|
|
}
|
|
}
|
|
|
|
|