Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit28e2190b4c4034a82cb60b3ff1afcf5f34153b07 (patch)
Author
 Syndamia <kamen@syndamia.com>
2024-05-26 09:54:54 +0300
Committer
 Syndamia <kamen@syndamia.com>
2024-05-26 09:54:54 +0300
Filesdfd71e51a50ee7601dff037f878743f7a3dcc9bb
uni-projects-28e2190b4c4034a82cb60b3ff1afcf5f34153b07.tar
uni-projects-28e2190b4c4034a82cb60b3ff1afcf5f34153b07.tar.gz
uni-projects-28e2190b4c4034a82cb60b3ff1afcf5f34153b07.zip
Parentd24f9487d2bb45ab31e6b9fdc4a6f6fa05f3ce0d (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.c38
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) {