reform

MNT Reform: Open Source Portable Computer
Log (Feed) | Files | Refs (Tags) | README

commit a51dceea5946e926a48807870d76379b63b5c370
parent c66188157e5d726d1467b5352201baf348a3aad4
Author: Lukas F. Hartmann <lukas@mntre.com>
Date:   Thu,  5 Oct 2023 12:16:10 +0200

Merge branch 'master' of source.mnt.re:reform/reform

Diffstat:
Mreform2-keyboard-fw/hid_report.c | 3+--
Mreform2-keyboard-fw/kbdgfx-demo/kbdgfx.c | 8++++----
Mreform2-keyboard-fw/oled.c | 10+++++-----
Mreform2-keyboard-fw/oled.h | 1+
4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/reform2-keyboard-fw/hid_report.c b/reform2-keyboard-fw/hid_report.c @@ -68,7 +68,6 @@ void hid_report_cmd(uint8_t* data) { matrix_render_direct(data+4); } else if (command == CMD_OLED_CLEAR) { - gfx_clear(); - gfx_flush(); + oled_clear(); } } diff --git a/reform2-keyboard-fw/kbdgfx-demo/kbdgfx.c b/reform2-keyboard-fw/kbdgfx-demo/kbdgfx.c @@ -12,11 +12,11 @@ #include <unistd.h> #define ROWS 4 -#define COLS 126 +#define COLS 128 #define BUFSZ (5+COLS*ROWS) #define FBUFSZ COLS*ROWS*8 -// our unpacked, wasteful framebuffer (one byte per pixel, 126x32) +// our unpacked, wasteful framebuffer (one byte per pixel, 128x32) uint8_t fb[FBUFSZ]; // the buffer we're sending to the keyboard (bit packed and column byte order) @@ -58,8 +58,8 @@ void fill_pattern(uint8_t bitpattern, uint8_t* dst) { } void draw_sine(float t, uint8_t* dst) { - for (int x=0; x<126; x++) { - int y = 16 + sin(t + ((float)x/126.0 * 3.141))*12; + for (int x=0; x<128; x++) { + int y = 16 + sin(t + ((float)x/128.0 * 3.141))*12; if (y < 0) y = 0; if (y > 31) y = 31; diff --git a/reform2-keyboard-fw/oled.c b/reform2-keyboard-fw/oled.c @@ -66,7 +66,7 @@ static inline bool _send_cmd3(uint8_t cmd, uint8_t opr1, uint8_t opr2) { #define send_cmd2(c,o) if (!_send_cmd2(c,o)) {goto done;} #define send_cmd3(c,o1,o2) if (!_send_cmd3(c,o1,o2)) {goto done;} -static void clear_display(void) { +void oled_clear(void) { matrix_clear(&display); // Clear all of the display bits (there can be random noise @@ -129,7 +129,7 @@ bool gfx_init(bool rotate) { send_cmd2(SetContrast, 0); // Dim - clear_display(); + oled_clear(); success = true; @@ -323,15 +323,15 @@ void matrix_render_direct(uint8_t* bitmap) { gfx_on(); // Move to the home position - send_cmd3(PageAddr, 0, MatrixRows - 1); - send_cmd3(ColumnAddr, 0, (MatrixCols * FontWidth) - 1); + send_cmd3(PageAddr, 0, (DisplayHeight / 8) - 1); + send_cmd3(ColumnAddr, 0, DisplayWidth - 1); i2c_start_write(SSD1306_ADDRESS); i2c_master_write(0x40); int c = 0; for (uint16_t y=0; y<4; y++) { - for (uint16_t x=0; x<126; x++) { + for (uint16_t x=0; x<128; x++) { i2c_master_write(bitmap[c++]); } } diff --git a/reform2-keyboard-fw/oled.h b/reform2-keyboard-fw/oled.h @@ -93,6 +93,7 @@ void matrix_write_P(struct CharacterMatrix *matrix, const char *data); void matrix_render(struct CharacterMatrix *matrix); void matrix_render_direct(uint8_t* bitmap); +void oled_clear(void); void oled_brightness_inc(void); void oled_brightness_dec(void);