Commit f259912c authored by Robey Pointer's avatar Robey Pointer
Browse files

move cursor logic to be jit

parent 3bc9e0cc
......@@ -35,22 +35,19 @@ void text_display_scroll(text_display_t *display) {
}
void text_display_putc(text_display_t *display, uint8_t c) {
display->cells[display->cursor] = c;
display->cursor++;
if (display->cursor >= display->width * display->height) {
display->cursor -= display->width;
text_display_scroll(display);
}
display->cells[display->cursor] = c;
display->cursor++;
display->dirty = true;
}
void text_display_write(text_display_t *display, const char *text) {
while (*text) {
if (*text == '\n') {
display->cursor = ((display->cursor / display->width) + 1) * display->width;
if (display->cursor >= display->width * display->height) {
display->cursor -= display->width;
text_display_scroll(display);
}
} else {
text_display_putc(display, *text);
}
......@@ -59,6 +56,7 @@ void text_display_write(text_display_t *display, const char *text) {
}
void text_display_flush(text_display_t *display) {
if (!display->dirty) return;
uint8_t x_offset = (DisplayWidth - display->width * display->font->width) / 2;
oled_on();
......
......@@ -27,7 +27,7 @@ typedef struct {
typedef struct {
uint8_t cells[MAX_HEIGHT * MAX_WIDTH];
uint8_t invert[MAX_HEIGHT * MAX_WIDTH / 8];
uint8_t invert[(MAX_HEIGHT * MAX_WIDTH + 7) / 8];
uint8_t width;
uint8_t height;
uint8_t cursor;
......@@ -35,6 +35,8 @@ typedef struct {
const monospace_font_t *font;
} text_display_t;
extern const monospace_font_t font_oranj;
void text_display_init(text_display_t *display, const monospace_font_t *font);
void text_display_clear(text_display_t *display);
void text_display_scroll(text_display_t *display);
......
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