|
@@ -104,6 +104,7 @@ static void ST7735_Reset(void) {
|
|
|
|
|
|
static void ST7735_WriteCommand(uint8_t cmd) {
|
|
|
LCD_DC_CMD;
|
|
|
+ // !!! TODO: немає сенсу пересилати 1 байт за допомогою DMA. треба переробити
|
|
|
spiSend(&ST7735_SPI_PORT, sizeof(cmd), &cmd);
|
|
|
}
|
|
|
|
|
@@ -174,6 +175,7 @@ void ST7735_DrawPixel(uint16_t x, uint16_t y, uint16_t color) {
|
|
|
|
|
|
ST7735_SetAddressWindow(x, y, x+1, y+1);
|
|
|
uint8_t data[] = {color >> 8, color & 0xFF};
|
|
|
+ // !!! TODO: тут пересилається 2 байти за допомогою DMA. треба переробити
|
|
|
ST7735_WriteData(data, sizeof(data));
|
|
|
|
|
|
ST7735_Unselect();
|
|
@@ -187,34 +189,22 @@ static void ST7735_WriteChar(uint16_t x, uint16_t y, char ch, FontDef font, uint
|
|
|
for(i = 0; i < font.height; i++) {
|
|
|
b = font.data[(ch - 32) * font.height + i];
|
|
|
for(j = 0; j < font.width; j++) {
|
|
|
- if ((b << j) & 0x8000) {
|
|
|
+ //unnecessary transformations
|
|
|
+ //if ((b << j) & 0x8000) {
|
|
|
+ if (b & 0x8000) {
|
|
|
uint8_t data[] = {color >> 8, color & 0xFF};
|
|
|
+ // !!! TODO: тут пересилається 2 байти за допомогою DMA. треба переробити
|
|
|
ST7735_WriteData(data, sizeof(data));
|
|
|
} else {
|
|
|
uint8_t data[] = {bgcolor >> 8, bgcolor & 0xFF};
|
|
|
+ // !!! TODO: тут пересилається 2 байти за допомогою DMA. треба переробити
|
|
|
ST7735_WriteData(data, sizeof(data));
|
|
|
}
|
|
|
+ b <<= 1;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-/*
|
|
|
-Simpler (and probably slower) implementation:
|
|
|
-
|
|
|
-static void ST7735_WriteChar(uint16_t x, uint16_t y, char ch, FontDef font, uint16_t color) {
|
|
|
- uint32_t i, b, j;
|
|
|
-
|
|
|
- for (i = 0; i < font.height; i++) {
|
|
|
- b = font.data[(ch - 32) * font.height + i];
|
|
|
- for (j = 0; j < font.width; j++) {
|
|
|
- if ((b << j) & 0x8000) {
|
|
|
- ST7735_DrawPixel(x + j, y + i, color);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-*/
|
|
|
-
|
|
|
void ST7735_WriteString(uint16_t x, uint16_t y, const char* str, FontDef font, uint16_t color, uint16_t bgcolor) {
|
|
|
ST7735_Select();
|
|
|
|