Commit 171927de authored by Robey Pointer's avatar Robey Pointer
Browse files

rename text_display to display

parent c6cc926e
......@@ -165,8 +165,8 @@ static void remote_check_for_low_battery(void) {
low_battery_alert = 1;
}
if (was_low && !low_battery_alert) {
text_display_clear();
text_display_flush();
display_clear();
display_flush();
}
}
......@@ -402,8 +402,8 @@ int execute_meta_function(int keycode) {
else if (keycode == KEY_Z) {
low_battery_alert = !low_battery_alert;
if (!low_battery_alert) {
text_display_clear();
text_display_flush();
display_clear();
display_flush();
}
return 0;
}
......@@ -629,7 +629,7 @@ void SetupHardware()
kbd_brightness_init();
oled_init();
text_display_init(&font_oranj);
display_init(&font_oranj);
gfx_clear();
gfx_flush();
hid_report_init();
......
......@@ -47,25 +47,25 @@ void CALLBACK_HID_Device_ProcessHIDReport(
const uint32_t command = *(uint32_t *)data;
if (command == CMD_TEXT_FRAME) {
text_display_init(&font_oranj);
text_display_clear();
for (int i = 4; i < report_size; i++) text_display_putc(data[i]);
text_display_flush();
display_init(&font_oranj);
display_clear();
for (int i = 4; i < report_size; i++) display_putc(data[i]);
display_flush();
} else if (command == CMD_TEXT_WRITE) {
text_display_write_len((const char *)&data[4], report_size - 4);
text_display_flush();
display_write_len((const char *)&data[4], report_size - 4);
display_flush();
} else if (command == CMD_REPORT_POWER) {
const char *report = controller_request("0c");
if (report) text_display_write(report);
text_display_flush();
if (report) display_write(report);
display_flush();
} else if (command == CMD_UX_POWER) {
ux_show_battery();
} else if (command == CMD_UX_STATUS) {
ux_show_status();
} else if (command == CMD_TEST) {
text_display_init(&font_bizcat);
text_display_write("This is a test.");
text_display_flush();
display_init(&font_bizcat);
display_write("This is a test.");
display_flush();
}
#if 0
......
......@@ -29,14 +29,14 @@ static bool text_dirty = false;
static bool text_inverting = false;
static uint8_t text_roll = 0; // FIXME hack
void text_display_init(const monospace_font_t *font) {
void display_init(const monospace_font_t *font) {
text_font = font;
text_height = DisplayHeight / text_font->height;
text_width = DisplayWidth / text_font->width;
text_display_clear();
display_clear();
}
void text_display_clear(void) {
void display_clear(void) {
memset(framebuffer, 0, sizeof(framebuffer));
memset(text_cells, ' ', sizeof(text_cells));
memset(text_invert, 0, sizeof(text_invert));
......@@ -46,7 +46,7 @@ void text_display_clear(void) {
text_roll = 0;
}
void text_display_clear_line(uint8_t line) {
void display_clear_line(uint8_t line) {
memset(text_cells + line * text_width, ' ', text_width);
for (int i = line * text_width; i < (line + 1) * text_width; i++) {
text_invert[i >> 3] &= ~(1 << (i & 7));
......@@ -54,7 +54,7 @@ void text_display_clear_line(uint8_t line) {
}
// scroll up one line.
void text_display_scroll(void) {
void display_scroll(void) {
memmove(text_cells, text_cells + text_width, (text_height - 1) * text_width);
// this is a pain: scroll the invert bits too.
......@@ -64,14 +64,14 @@ void text_display_scroll(void) {
text_invert[i] = (text_invert[i + bytes] >> bits) + (text_invert[i + bytes + 1] << (8 - bits));
}
text_display_clear_line(text_height - 1);
display_clear_line(text_height - 1);
text_dirty = true;
}
void text_display_putc(uint8_t c) {
void display_putc(uint8_t c) {
while (text_cursor >= text_width * text_height) {
text_cursor -= text_width;
text_display_scroll();
display_scroll();
}
text_cells[text_cursor] = c;
uint8_t invert_bit = 1 << (text_cursor & 7);
......@@ -81,7 +81,7 @@ void text_display_putc(uint8_t c) {
text_dirty = true;
}
void text_display_write_len(const char *text, int len) {
void display_write_len(const char *text, int len) {
for (int i = 0; i < len; i++) {
switch (text[i]) {
case '\n':
......@@ -89,7 +89,7 @@ void text_display_write_len(const char *text, int len) {
break;
case 0x0c:
// clear
text_display_clear();
display_clear();
break;
case 0x0e:
// "shift out": invert
......@@ -100,25 +100,25 @@ void text_display_write_len(const char *text, int len) {
text_inverting = false;
break;
default:
text_display_putc(text[i]);
display_putc(text[i]);
}
}
}
void text_display_write(const char *text) {
text_display_write_len(text, strlen(text));
void display_write(const char *text) {
display_write_len(text, strlen(text));
}
void text_display_move(uint8_t x, uint8_t y) {
void display_move(uint8_t x, uint8_t y) {
text_cursor = text_width * y + x;
if (text_cursor >= text_width * text_height) text_cursor = 0;
}
void text_display_invert(bool invert) {
void display_invert(bool invert) {
text_inverting = invert;
}
void text_display_render(void) {
static void render(void) {
oled_on();
oled_home();
oled_start_render();
......@@ -126,7 +126,7 @@ void text_display_render(void) {
oled_finish_render();
}
void text_display_flush(void) {
void display_flush(void) {
if (!text_dirty) return;
uint8_t x_offset = (DisplayWidth - text_width * text_font->width) / 2;
int stride = (text_font->height + 7) / 8;
......@@ -162,6 +162,6 @@ void text_display_flush(void) {
for (uint8_t x = 0; x < DisplayWidth; x++) oled_render(0);
}
text_display_render();
render();
text_dirty = false;
}
......@@ -28,13 +28,13 @@ typedef struct {
extern const monospace_font_t font_oranj;
extern const monospace_font_t font_bizcat;
void text_display_init(const monospace_font_t *font);
void text_display_clear(void);
void text_display_clear_line(uint8_t line);
void text_display_scroll(void);
void text_display_putc(uint8_t c);
void text_display_write_len(const char *text, int len);
void text_display_write(const char *text);
void text_display_move(uint8_t x, uint8_t y);
void text_display_invert(bool invert);
void text_display_flush(void);
void display_init(const monospace_font_t *font);
void display_clear(void);
void display_clear_line(uint8_t line);
void display_scroll(void);
void display_putc(uint8_t c);
void display_write_len(const char *text, int len);
void display_write(const char *text);
void display_move(uint8_t x, uint8_t y);
void display_invert(bool invert);
void display_flush(void);
......@@ -43,36 +43,36 @@ void ux_show_battery(void) {
controller_probe_batteries(&info);
// plot, using oranj (6x8) so all the info will fit
text_display_init(&font_oranj);
display_init(&font_oranj);
char str[32];
sprintf(str, "%s %s %3d%%",
show_one_battery(info.decivolts[0]), show_one_battery(info.decivolts[4]), info.total_percent);
text_display_write(str);
display_write(str);
sprintf(str, "%s %s ",
show_one_battery(info.decivolts[1]), show_one_battery(info.decivolts[5]));
text_display_write(str);
display_write(str);
sprintf(str, "%s %s %5.2fA",
show_one_battery(info.decivolts[2]), show_one_battery(info.decivolts[6]), info.total_amps);
text_display_write(str);
display_write(str);
sprintf(str, "%s %s %5.2fV",
show_one_battery(info.decivolts[3]), show_one_battery(info.decivolts[7]), info.total_volts);
text_display_write(str);
text_display_flush();
display_write(str);
display_flush();
}
void ux_show_status(void) {
text_display_init(&font_oranj);
display_init(&font_oranj);
#ifndef KBD_VARIANT_STANDALONE
const char *response = controller_request("s");
text_display_write(response);
display_write(response);
#endif
text_display_move(0, 2);
text_display_write("MNT Reform Keyboard");
text_display_move(0, 3);
text_display_write(KBD_FW_REV);
text_display_flush();
display_move(0, 2);
display_write("MNT Reform Keyboard");
display_move(0, 3);
display_write(KBD_FW_REV);
display_flush();
}
#define BATTERY_EMPTY_LEFT 0
......@@ -81,17 +81,17 @@ void ux_show_status(void) {
#define BATTERY_ALERT_RIGHT 13
void ux_blink_low_battery(bool blink) {
// switch to the large font, and sneakily drop down one half-row
text_display_init(&font_bizcat);
display_init(&font_bizcat);
// display->roll = 1;
text_display_move(7, 0);
display_move(7, 0);
if (blink) {
text_display_putc(BATTERY_ALERT_LEFT);
text_display_putc(BATTERY_ALERT_RIGHT);
display_putc(BATTERY_ALERT_LEFT);
display_putc(BATTERY_ALERT_RIGHT);
} else {
text_display_putc(BATTERY_EMPTY_LEFT);
text_display_putc(BATTERY_EMPTY_RIGHT);
display_putc(BATTERY_EMPTY_LEFT);
display_putc(BATTERY_EMPTY_RIGHT);
}
text_display_flush();
display_flush();
// display->roll = 0;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment