diff options
author | William Wilgus <wilgus.william@gmail.com> | 2024-08-29 07:59:04 -0400 |
---|---|---|
committer | William Wilgus <wilgus.william@gmail.com> | 2024-08-29 07:59:04 -0400 |
commit | 054ba76d81aaca4a7a5495b644f6a0ebfc9172fc (patch) | |
tree | 833ec75dc748252bcf9462a30a970da0abf42f86 | |
parent | 14a8f9a863f5534333df1359822e2f126583d473 (diff) | |
download | rockbox-054ba76d81.tar.gz rockbox-054ba76d81.zip |
Morse code cheat sheet, better use [of] pixels available on screen
This improvement allows to show all characters even on a tiny screen
like the screen of the iPod Minis
Change-Id: Ibffd4f562d8bf9b3859528bbea59ca4f9190c4fd
-rw-r--r-- | apps/recorder/keyboard.c | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/apps/recorder/keyboard.c b/apps/recorder/keyboard.c index 736e9738c8..26ac6c1ae7 100644 --- a/apps/recorder/keyboard.c +++ b/apps/recorder/keyboard.c @@ -951,8 +951,8 @@ static void kbd_draw_picker(struct keyboard_parameters *pm, #ifdef HAVE_MORSE_INPUT if (state->morse_mode) { - const int w = 6, h = 8; /* sysfixed font width, height */ - int i, j, x, y; + const int w = 6, h = 9; /* sysfixed font width, height */ + int i, iNext, j, x, y; int sc_w = vp->width, sc_h = vp->height;//pm->main_y - pm->keyboard_margin - 1; /* Draw morse code screen with sysfont */ @@ -960,37 +960,47 @@ static void kbd_draw_picker(struct keyboard_parameters *pm, x = 0; y = 0; outline[1] = '\0'; - + /* Draw morse code table with code descriptions. */ - for (i = 0; morse_alphabets[i] != '\0'; i++) - { + for (i = 0; morse_alphabets[i] != '\0'; i++) { int morse_code; - outline[0] = morse_alphabets[i]; sc->putsxy(x, y, outline); - morse_code = morse_codes[i]; - for (j = 0; morse_code > 0x01; morse_code >>= 1) + for (j = 0; morse_code > 0x01; morse_code >>= 1) { j++; - - x += w + 3 + j*4; + } + x += w + 3 + j * 4; morse_code = morse_codes[i]; - for (; morse_code > 0x01; morse_code >>= 1) - { + for (; morse_code > 0x01; morse_code >>= 1) { x -= 4; - if (morse_code & 0x01) + if (morse_code & 0x01) { sc->fillrect(x, y + 2, 3, 4); - else + } else { sc->fillrect(x, y + 3, 1, 2); + } } - - x += w*5 - 3; - if (x + w*6 >= sc_w) - { + x += j * 4; + iNext = i + 1; + if (morse_alphabets[iNext] == '\0') { + break; + } + morse_code = morse_codes[iNext]; + for (j = 0; morse_code > 0x01; morse_code >>= 1) { + j++; + } + // If the next one will go out of line + bool needNewLine = x + w + 3 + j * 4 + w >= sc_w; + if (needNewLine) { + if (y + h >= sc_h) { + // No more height space + break; + } x = 0; y += h; - if (y + h >= sc_h) - break; + } else { + // Some pixels for spacing in the same line + x += w; } } } |