Pass kerning when writing string

In order to be able to print more compact strings also pass the
kerning parameter to `lcd_write_string_page()`.
This commit is contained in:
finga 2021-09-24 23:37:04 +02:00
parent a34a58535b
commit 22095d6e78

View file

@ -289,10 +289,11 @@ static void lcd_write_character_page(const char character,
} }
static void lcd_write_string_page(const char* string, static void lcd_write_string_page(const char* string,
const uint8_t kerning,
const uint8_t page, const uint8_t page,
const bool invert) { const bool invert) {
for (uint8_t i = 0; string[i] != 0; i++) { for (uint8_t i = 0; string[i] != 0; i++) {
lcd_write_kerning(2, invert); lcd_write_kerning(kerning, invert);
lcd_write_character_page(string[i], page, invert); lcd_write_character_page(string[i], page, invert);
} }
} }
@ -328,14 +329,14 @@ static void twi_error(bool inverted) {
for (uint8_t i = 0; i < 2; i++) { for (uint8_t i = 0; i < 2; i++) {
lcd_move_cursor(0, i); lcd_move_cursor(0, i);
lcd_write_string_page("TW_STATUS:\0", i, inverted); lcd_write_string_page("TW_STATUS:\0", 2, i, inverted);
lcd_write_kerning(2, inverted); lcd_write_kerning(2, inverted);
lcd_write_integer_page(TW_STATUS, 3, i, inverted); lcd_write_integer_page(TW_STATUS, 3, i, inverted);
} }
for (uint8_t i = 0; i < 2; i++) { for (uint8_t i = 0; i < 2; i++) {
lcd_move_cursor(0, i + 2); lcd_move_cursor(0, i + 2);
lcd_write_string_page("TW_DATA:\0", i, inverted); lcd_write_string_page("TW_DATA:\0", 2, i, inverted);
lcd_write_kerning(16, inverted); lcd_write_kerning(16, inverted);
lcd_write_integer_page(TWDR, 3, i, inverted); lcd_write_integer_page(TWDR, 3, i, inverted);
} }
@ -457,19 +458,19 @@ static void draw_home(void) {
for (uint8_t i = 0; i < 2; i++) { for (uint8_t i = 0; i < 2; i++) {
lcd_move_cursor(0, i); lcd_move_cursor(0, i);
lcd_write_string_page("CH1\0", i, ch1_selected); lcd_write_string_page("CH1\0", 2, i, ch1_selected);
lcd_write_kerning(2, ch1_selected); lcd_write_kerning(2, ch1_selected);
lcd_move_cursor(0, 2 + i); lcd_move_cursor(0, 2 + i);
lcd_write_string_page("CH2\0", i, ch2_selected); lcd_write_string_page("CH2\0", 2, i, ch2_selected);
lcd_write_kerning(2, ch2_selected); lcd_write_kerning(2, ch2_selected);
lcd_move_cursor(0, 4 + i); lcd_move_cursor(0, 4 + i);
lcd_write_string_page("CH3\0", i, ch3_selected); lcd_write_string_page("CH3\0", 2, i, ch3_selected);
lcd_write_kerning(2, ch3_selected); lcd_write_kerning(2, ch3_selected);
lcd_move_cursor(33, 6 + i); lcd_move_cursor(33, 6 + i);
lcd_write_string_page("SETUP\0", i, setup_selected); lcd_write_string_page("SETUP\0", 2, i, setup_selected);
lcd_write_kerning(2, setup_selected); lcd_write_kerning(2, setup_selected);
} }
} }
@ -504,13 +505,13 @@ static void draw_setup(void) {
for (uint8_t i = 0; i < 2; i++) { for (uint8_t i = 0; i < 2; i++) {
lcd_move_cursor(0, i); lcd_move_cursor(0, i);
lcd_write_kerning(30, true); lcd_write_kerning(30, true);
lcd_write_string_page("SETUP\0", i, true); lcd_write_string_page("SETUP\0", 2, i, true);
lcd_write_kerning(33, true); lcd_write_kerning(33, true);
} }
for (uint8_t i = 0; i < 2; i++) { for (uint8_t i = 0; i < 2; i++) {
lcd_move_cursor(0, 2 + i); lcd_move_cursor(0, 2 + i);
lcd_write_string_page("CONTRAST:\0", i, contrast_selected); lcd_write_string_page("CONTRAST:\0", 2, i, contrast_selected);
lcd_write_kerning(2, contrast_selected); lcd_write_kerning(2, contrast_selected);
lcd_write_kerning(16, false); lcd_write_kerning(16, false);
lcd_write_integer_page(value_contrast, 2, i, lcd_write_integer_page(value_contrast, 2, i,
@ -520,7 +521,7 @@ static void draw_setup(void) {
for (uint8_t i = 0; i < 2; i++) { for (uint8_t i = 0; i < 2; i++) {
lcd_move_cursor(0, 4 + i); lcd_move_cursor(0, 4 + i);
lcd_write_string_page("BACKLIGHT:\0", i, backlight_selected); lcd_write_string_page("BACKLIGHT:\0", 2, i, backlight_selected);
lcd_write_kerning(2, backlight_selected); lcd_write_kerning(2, backlight_selected);
lcd_write_kerning(5, false); lcd_write_kerning(5, false);
lcd_write_integer_page(value_backlight, 3, i, lcd_write_integer_page(value_backlight, 3, i,
@ -530,7 +531,7 @@ static void draw_setup(void) {
for (uint8_t i = 0; i < 2; i++) { for (uint8_t i = 0; i < 2; i++) {
lcd_move_cursor(33, 6 + i); lcd_move_cursor(33, 6 + i);
lcd_write_string_page("BACK:\0", i, back_selected); lcd_write_string_page("BACK:\0", 2, i, back_selected);
lcd_write_kerning(2, back_selected); lcd_write_kerning(2, back_selected);
} }
} }