diff options
| Commit | 28e2190b4c4034a82cb60b3ff1afcf5f34153b07 (patch) | |
|---|---|---|
| Author | 2024-05-26 09:54:54 +0300 | |
| Committer | 2024-05-26 09:54:54 +0300 | |
| Files | dfd71e51a50ee7601dff037f878743f7a3dcc9bb | |
| uni-projects-28e2190b4c4034a82cb60b3ff1afcf5f34153b07.tar uni-projects-28e2190b4c4034a82cb60b3ff1afcf5f34153b07.tar.gz uni-projects-28e2190b4c4034a82cb60b3ff1afcf5f34153b07.zip | ||
| Parent | d24f9487d2bb45ab31e6b9fdc4a6f6fa05f3ce0d (diff) | |
[iot/goam] Display println now prints text wrapping
1 files changed, 23 insertions, 15 deletions
| -rw-r--r-- | Year 3/Internet of things/goam/main/display.c | 38 |
diff --git a/Year 3/Internet of things/goam/main/display.c b/Year 3/Internet of things/goam/main/display.c index 025c85e..6480d78 100644 --- a/Year 3/Internet of things/goam/main/display.c +++ b/Year 3/Internet of things/goam/main/display.c @@ -113,24 +113,32 @@ extern const uint8_t bitpixel_chars[256][16]; unsigned char out_page_row[LAST_COL + 1]; void display_println(const char* str) { - for (int linepage = 0; linepage <= 1; linepage++) { - int column; - for (column = 0; column <= LAST_COL; column++) { - if (str[column / bitpixel_char_width] == '\0') { - column--; - break; + do { + int column, character; + for (int linepage = 0; linepage <= 1; linepage++) { + for (column = 0; column <= LAST_COL; column++) { + character = (int)str[column / bitpixel_char_width]; + if (character == '\0') { + column--; + break; + } + // The font currently only has capital letters, this converts lowercase to capital + if ('a' <= character && character <= 'z') { + character -= 'a' - 'A'; + } + out_page_row[column] = bitpixel_chars[character] + [(column * 2 + linepage) % bitpixel_char_height]; } - out_page_row[column] = bitpixel_chars[(int)str[column / bitpixel_char_width]] - [(column * 2 + linepage) % bitpixel_char_height]; - } - send(DATA_STREAM, out_page_row, column); - if (column < sizeof(out_page_row)) { - display_output_newpage(); - } + send(DATA_STREAM, out_page_row, column); + if (column < sizeof(out_page_row)) { + display_output_newpage(); + } - current_page = PAGE_INC; - } + current_page = PAGE_INC; + } + str += column / bitpixel_char_width + (character == '\0'); + } while (*str != '\0' && current_page > 0); } void display_printon(const char* str, unsigned char line) { |
