diff --git a/example/example.c b/example/example.c index 46f3356..21d4440 100644 --- a/example/example.c +++ b/example/example.c @@ -7,7 +7,7 @@ int main(void) initScreen(&screen, HALF_BYTE_INTERFACE, TWO_LINES, FONT_5x7, CURSOR_ON | CURSOR_BLINK, LEFT_TO_RIGHT); sendText(&screen, "スウェーデン"); - sendCommand(&screen, DDRAM_AD_SET | 0x40); + setCursor(&screen, 0, 1); sendText(&screen, "オーストラリア"); resetPins(&screen); diff --git a/raspberrylcd.c b/raspberrylcd.c index e3ef72b..005c324 100644 --- a/raspberrylcd.c +++ b/raspberrylcd.c @@ -125,11 +125,7 @@ void sendText(LCDScreen* screen, const char* text) { for(const char* c = text; *c != '\x00'; c++) { - if(*c != '\xe3') - { - sendData(screen, *c); - } - else + if(*c == '\xe3') { uint16_t symbol = ((uint16_t)(*(c + 1)) << 8) | ((uint16_t)(*(c + 2))); @@ -230,6 +226,11 @@ void sendText(LCDScreen* screen, const char* text) } c += 2; } + else + { + sendData(screen, *c); + + } } } @@ -243,4 +244,9 @@ void sendChars(LCDScreen* screen, size_t len, ...) sendData(screen, (uint8_t)va_arg(args, int)); va_end(args); +} + +void setCursor(LCDScreen* screen, uint8_t x, uint8_t y) +{ + sendCommand(screen, DDRAM_AD_SET | (y << 6) | x); } \ No newline at end of file diff --git a/raspberrylcd.h b/raspberrylcd.h index 2fec79e..e4d7d84 100644 --- a/raspberrylcd.h +++ b/raspberrylcd.h @@ -151,4 +151,6 @@ extern void sendData(LCDScreen* screen, uint8_t data); extern void sendText(LCDScreen* screen, const char* text); extern void sendChars(LCDScreen* screen, unsigned int len, ...); +extern void setCursor(LCDScreen* screen, uint8_t x, uint8_t y); + #endif // RASPBERRY_LCD_H \ No newline at end of file