From 0a645225b9c863a106921185a6c2e0c340f10694 Mon Sep 17 00:00:00 2001 From: Ryan Caltabiano Date: Mon, 15 Apr 2019 22:32:57 -0500 Subject: OLED Driver Feature --- keyboards/sol/common/glcdfont.c | 140 +++++++++-------- keyboards/sol/common/ssd1306.c | 329 ---------------------------------------- keyboards/sol/common/ssd1306.h | 92 ----------- 3 files changed, 68 insertions(+), 493 deletions(-) delete mode 100644 keyboards/sol/common/ssd1306.c delete mode 100644 keyboards/sol/common/ssd1306.h (limited to 'keyboards/sol/common') diff --git a/keyboards/sol/common/glcdfont.c b/keyboards/sol/common/glcdfont.c index 89665ba07..f772e3181 100644 --- a/keyboards/sol/common/glcdfont.c +++ b/keyboards/sol/common/glcdfont.c @@ -1,8 +1,4 @@ -// This is the 'classic' fixed-space bitmap font for Adafruit_GFX since 1.0. -// See gfxfont.h for newer custom bitmap font info. - -#ifndef FONT5X7_H -#define FONT5X7_H +#pragma once #ifdef __AVR__ #include @@ -13,7 +9,8 @@ #define PROGMEM #endif -// Standard ASCII 5x7 font +// Helidox 8x6 font with RGBKB SOL Logo +// Online editor: http://teripom.x0.com/ static const unsigned char font[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -144,27 +141,27 @@ static const unsigned char font[] PROGMEM = { 0x00, 0x41, 0x36, 0x08, 0x00, 0x00, 0x02, 0x01, 0x02, 0x04, 0x02, 0x00, 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x00, - 0x03, 0x07, 0x1F, 0x7F, 0xFF, 0xFF, - 0xFE, 0xF8, 0xF0, 0xC0, 0x20, 0xF8, - 0xFE, 0xFF, 0xFE, 0x79, 0x27, 0x1F, - 0x7F, 0xFF, 0xFF, 0xFE, 0xF8, 0xF0, - 0xC0, 0x20, 0xF8, 0xFE, 0xFF, 0xFF, - 0x7F, 0x3F, 0x3F, 0x7F, 0xFF, 0xFE, - 0xF8, 0xF0, 0xC0, 0x00, 0x00, 0x00, - 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xFF, 0x7F, 0x7F, 0x7F, - 0xBF, 0xBF, 0xC0, 0xC0, 0xC0, 0xE0, - 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0, - 0xF8, 0x78, 0x78, 0x7C, 0x3C, 0x3C, - 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, + 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, - 0xBF, 0xBF, 0xDF, 0xDF, 0xEF, 0xEF, - 0x00, 0x03, 0x07, 0x1F, 0x7F, 0xFF, - 0xFF, 0xFF, 0xFE, 0xF8, 0xE0, 0xC0, - 0xE0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, - 0x7F, 0x1F, 0x07, 0x03, 0x00, 0x00, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x0C, 0x90, + 0xB0, 0xE0, 0x72, 0x31, 0x9B, 0xDE, + 0xCE, 0xEC, 0xEE, 0xE9, 0xE9, 0xEC, + 0xCF, 0xDA, 0x99, 0x3E, 0x62, 0xE4, + 0xC4, 0x70, 0x10, 0x10, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, + 0xC0, 0xC0, 0x80, 0x80, 0x02, 0x85, + 0x85, 0x87, 0x85, 0x89, 0x89, 0x92, + 0xEA, 0xC6, 0xC4, 0x48, 0x50, 0x60, + 0x40, 0x40, 0x40, 0x40, 0xC0, 0xE0, + 0x50, 0x28, 0x10, 0x10, 0x60, 0xC0, + 0x40, 0x40, 0x40, 0x40, 0x80, 0x80, + 0x80, 0x80, 0x80, 0xE0, 0xF8, 0xFC, + 0xF8, 0xF0, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xF0, 0xF0, 0xF0, 0xE0, 0xEC, 0xEE, 0xF7, 0xF3, 0x70, 0x20, 0x00, 0x7C, 0x7C, 0x7C, 0x7E, 0x00, 0x7E, @@ -173,30 +170,30 @@ static const unsigned char font[] PROGMEM = { 0x4F, 0x5B, 0xFE, 0xC0, 0x00, 0x00, 0xC0, 0x00, 0xDC, 0xD7, 0xDE, 0xDE, 0xDE, 0xD7, 0xDC, 0x00, 0xC0, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xC1, 0xF3, - 0xCF, 0xBF, 0x7F, 0xFF, 0xFF, 0xFC, - 0xFB, 0xE7, 0x81, 0x00, 0x00, 0x00, - 0x00, 0x80, 0xE3, 0xCF, 0x3F, 0xFF, - 0xFF, 0xFF, 0xFC, 0xFB, 0xE7, 0x81, - 0x00, 0x00, 0x00, 0x00, 0x81, 0xE7, - 0xFF, 0xFF, 0xFF, 0xFF, 0x3C, 0x00, - 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xF8, 0xF8, 0xFC, 0x7C, 0x7E, - 0x7E, 0x3E, 0xFE, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xF7, 0xF7, 0xF7, 0xFB, - 0xFB, 0x7D, 0x7D, 0x7D, 0xBE, 0xBE, - 0xBE, 0xDF, 0xDF, 0xE0, 0xE0, 0x00, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0x00, 0xFC, 0xFC, 0x7C, 0x7E, 0x7E, - 0x3E, 0x3E, 0x1F, 0x1F, 0x1F, 0x0F, + 0x00, 0x00, 0x00, 0xE0, 0xEC, 0xDF, + 0xFC, 0xE0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x7F, 0x80, 0x80, + 0x80, 0x70, 0x0F, 0x00, 0x00, 0x80, + 0x7F, 0x00, 0x00, 0x7F, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x7F, + 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0xFF, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x40, 0x21, 0x33, 0x3B, 0x7B, + 0xFF, 0x00, 0x7C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, - 0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xE7, 0x81, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0x7C, 0x01, + 0xFF, 0xDE, 0x8C, 0x04, 0x0C, 0x08, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x7F, 0x80, + 0x80, 0xBE, 0xBE, 0x80, 0x80, 0x80, + 0xC1, 0xFF, 0x80, 0x04, 0x32, 0x5E, + 0x1C, 0x3D, 0x26, 0x10, 0xC1, 0xFF, + 0x3E, 0x00, 0x00, 0x08, 0x36, 0xC1, + 0x08, 0x08, 0x14, 0x77, 0x94, 0x94, + 0x94, 0xF7, 0x94, 0xF7, 0x9C, 0x9C, + 0xFF, 0xFF, 0x1E, 0x00, 0x00, 0x00, 0x0F, 0x1F, 0x3F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x3F, 0x1E, 0x0C, 0x00, 0x1F, 0x1F, 0x1F, 0x3F, 0x00, 0x3F, @@ -205,30 +202,31 @@ static const unsigned char font[] PROGMEM = { 0x20, 0x30, 0x78, 0x7F, 0x3B, 0x00, 0x03, 0x00, 0x0F, 0x7F, 0x0F, 0x0F, 0x0F, 0x7F, 0x0F, 0x00, 0x03, 0x00, + 0x40, 0x7C, 0x3F, 0x3F, 0x23, 0x01, + 0x23, 0x3F, 0x37, 0x6C, 0x40, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x06, 0x02, 0x06, + 0x4D, 0x4F, 0x8C, 0xF9, 0x73, 0x37, + 0x27, 0x2F, 0x2F, 0xAF, 0xEF, 0x6F, + 0x77, 0x17, 0x33, 0x79, 0xCC, 0x1F, + 0x31, 0x20, 0x21, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x40, 0xE0, + 0xA0, 0xA0, 0xD0, 0x90, 0x48, 0x48, + 0x25, 0x2B, 0x11, 0x09, 0x05, 0x03, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x03, 0x02, 0x04, 0x03, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x03, 0x0F, 0x1F, + 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x60, 0x70, 0x7C, 0x7F, 0x7F, 0x7F, - 0x7F, 0x1F, 0x06, 0x01, 0x03, 0x0F, - 0x3F, 0x7F, 0x7F, 0x7E, 0x7C, 0x7C, - 0x7E, 0x7F, 0x7F, 0x7F, 0x1F, 0x06, - 0x01, 0x07, 0x0F, 0x3F, 0x7F, 0x7F, - 0x7E, 0x7C, 0x7C, 0x7E, 0x7F, 0x7F, - 0x3F, 0x0F, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, - 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x7F, 0x7F, 0x7F, 0x7F, - 0x7F, 0x7F, 0x7D, 0x7D, 0x3D, 0x3E, - 0x1E, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F, - 0x07, 0x07, 0x07, 0x03, 0x03, 0x00, - 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, - 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, - 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x00, - 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, - 0x00, 0x40, 0x70, 0x78, 0x7E, 0x7F, - 0x7F, 0x7F, 0x3F, 0x0F, 0x03, 0x01, - 0x03, 0x0F, 0x3F, 0x7F, 0x7F, 0x7F, - 0x7E, 0x78, 0x70, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -239,6 +237,4 @@ static const unsigned char font[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -#endif // FONT5X7_H diff --git a/keyboards/sol/common/ssd1306.c b/keyboards/sol/common/ssd1306.c deleted file mode 100644 index b3e55a67c..000000000 --- a/keyboards/sol/common/ssd1306.c +++ /dev/null @@ -1,329 +0,0 @@ -#ifdef SSD1306OLED - -#include "ssd1306.h" -#include "i2c.h" -#include -#include "print.h" -#ifndef LOCAL_GLCDFONT -#include "common/glcdfont.c" -#else -#include -#endif -#ifdef ADAFRUIT_BLE_ENABLE -#include "adafruit_ble.h" -#endif -#ifdef PROTOCOL_LUFA -#include "lufa.h" -#endif -#include "sendchar.h" -#include "timer.h" - -// Set this to 1 to help diagnose early startup problems -// when testing power-on with ble. Turn it off otherwise, -// as the latency of printing most of the debug info messes -// with the matrix scan, causing keys to drop. -#define DEBUG_TO_SCREEN 0 - -//static uint16_t last_battery_update; -//static uint32_t vbat; -//#define BatteryUpdateInterval 10000 /* milliseconds */ -#define ScreenOffInterval 300000 /* milliseconds */ -#if DEBUG_TO_SCREEN -static uint8_t displaying; -#endif -static uint16_t last_flush; - -// Write command sequence. -// Returns true on success. -static inline bool _send_cmd1(uint8_t cmd) { - bool res = false; - - if (i2c_start_write(SSD1306_ADDRESS)) { - xprintf("failed to start write to %d\n", SSD1306_ADDRESS); - goto done; - } - - if (i2c_master_write(0x0 /* command byte follows */)) { - print("failed to write control byte\n"); - - goto done; - } - - if (i2c_master_write(cmd)) { - xprintf("failed to write command %d\n", cmd); - goto done; - } - res = true; -done: - i2c_master_stop(); - return res; -} - -// Write 2-byte command sequence. -// Returns true on success -static inline bool _send_cmd2(uint8_t cmd, uint8_t opr) { - if (!_send_cmd1(cmd)) { - return false; - } - return _send_cmd1(opr); -} - -// Write 3-byte command sequence. -// Returns true on success -static inline bool _send_cmd3(uint8_t cmd, uint8_t opr1, uint8_t opr2) { - if (!_send_cmd1(cmd)) { - return false; - } - if (!_send_cmd1(opr1)) { - return false; - } - return _send_cmd1(opr2); -} - -#define send_cmd1(c) if (!_send_cmd1(c)) {goto done;} -#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) { - matrix_clear(&display); - - // Clear all of the display bits (there can be random noise - // in the RAM on startup) - send_cmd3(PageAddr, 0, (DisplayHeight / 8) - 1); - send_cmd3(ColumnAddr, 0, DisplayWidth - 1); - - if (i2c_start_write(SSD1306_ADDRESS)) { - goto done; - } - if (i2c_master_write(0x40)) { - // Data mode - goto done; - } - for (uint8_t row = 0; row < MatrixRows; ++row) { - for (uint8_t col = 0; col < DisplayWidth; ++col) { - i2c_master_write(0); - } - } - - display.dirty = false; - -done: - i2c_master_stop(); -} - -#if DEBUG_TO_SCREEN -#undef sendchar -static int8_t capture_sendchar(uint8_t c) { - sendchar(c); - iota_gfx_write_char(c); - - if (!displaying) { - iota_gfx_flush(); - } - return 0; -} -#endif - -bool iota_gfx_init(bool rotate) { - bool success = false; - - i2c_master_init(); - send_cmd1(DisplayOff); - send_cmd2(SetDisplayClockDiv, 0x80); - send_cmd2(SetMultiPlex, DisplayHeight - 1); - - send_cmd2(SetDisplayOffset, 0); - - - send_cmd1(SetStartLine | 0x0); - send_cmd2(SetChargePump, 0x14 /* Enable */); - send_cmd2(SetMemoryMode, 0 /* horizontal addressing */); - - if(rotate){ - // the following Flip the display orientation 180 degrees - send_cmd1(SegRemap); - send_cmd1(ComScanInc); - }else{ - // Flips the display orientation 0 degrees - send_cmd1(SegRemap | 0x1); - send_cmd1(ComScanDec); - } - - send_cmd2(SetComPins, 0x2); - send_cmd2(SetContrast, 0x8f); - send_cmd2(SetPreCharge, 0xf1); - send_cmd2(SetVComDetect, 0x40); - send_cmd1(DisplayAllOnResume); - send_cmd1(NormalDisplay); - send_cmd1(DeActivateScroll); - send_cmd1(DisplayOn); - - send_cmd2(SetContrast, 0); // Dim - - clear_display(); - - success = true; - - iota_gfx_flush(); - -#if DEBUG_TO_SCREEN - print_set_sendchar(capture_sendchar); -#endif - -done: - return success; -} - -bool iota_gfx_off(void) { - bool success = false; - - send_cmd1(DisplayOff); - success = true; - -done: - return success; -} - -bool iota_gfx_on(void) { - bool success = false; - - send_cmd1(DisplayOn); - success = true; - -done: - return success; -} - -void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c) { - *matrix->cursor = c; - ++matrix->cursor; - - if (matrix->cursor - &matrix->display[0][0] == sizeof(matrix->display)) { - // We went off the end; scroll the display upwards by one line - memmove(&matrix->display[0], &matrix->display[1], - MatrixCols * (MatrixRows - 1)); - matrix->cursor = &matrix->display[MatrixRows - 1][0]; - memset(matrix->cursor, ' ', MatrixCols); - } -} - -void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c) { - matrix->dirty = true; - - if (c == '\n') { - // Clear to end of line from the cursor and then move to the - // start of the next line - uint8_t cursor_col = (matrix->cursor - &matrix->display[0][0]) % MatrixCols; - - while (cursor_col++ < MatrixCols) { - matrix_write_char_inner(matrix, ' '); - } - return; - } - - matrix_write_char_inner(matrix, c); -} - -void iota_gfx_write_char(uint8_t c) { - matrix_write_char(&display, c); -} - -void matrix_write(struct CharacterMatrix *matrix, const char *data) { - const char *end = data + strlen(data); - while (data < end) { - matrix_write_char(matrix, *data); - ++data; - } -} - -void iota_gfx_write(const char *data) { - matrix_write(&display, data); -} - -void matrix_write_P(struct CharacterMatrix *matrix, const char *data) { - while (true) { - uint8_t c = pgm_read_byte(data); - if (c == 0) { - return; - } - matrix_write_char(matrix, c); - ++data; - } -} - -void iota_gfx_write_P(const char *data) { - matrix_write_P(&display, data); -} - -void matrix_clear(struct CharacterMatrix *matrix) { - memset(matrix->display, ' ', sizeof(matrix->display)); - matrix->cursor = &matrix->display[0][0]; - matrix->dirty = true; -} - -void iota_gfx_clear_screen(void) { - matrix_clear(&display); -} - -void matrix_render(struct CharacterMatrix *matrix) { - last_flush = timer_read(); - iota_gfx_on(); -#if DEBUG_TO_SCREEN - ++displaying; -#endif - - // Move to the home position - send_cmd3(PageAddr, 0, MatrixRows - 1); - send_cmd3(ColumnAddr, 0, (MatrixCols * FontWidth) - 1); - - if (i2c_start_write(SSD1306_ADDRESS)) { - goto done; - } - if (i2c_master_write(0x40)) { - // Data mode - goto done; - } - - for (uint8_t row = 0; row < MatrixRows; ++row) { - for (uint8_t col = 0; col < MatrixCols; ++col) { - const uint8_t *glyph = font + (matrix->display[row][col] * FontWidth); - - for (uint8_t glyphCol = 0; glyphCol < FontWidth; ++glyphCol) { - uint8_t colBits = pgm_read_byte(glyph + glyphCol); - i2c_master_write(colBits); - } - - // 1 column of space between chars (it's not included in the glyph) - //i2c_master_write(0); - } - } - - matrix->dirty = false; - -done: - i2c_master_stop(); -#if DEBUG_TO_SCREEN - --displaying; -#endif -} - -void iota_gfx_flush(void) { - matrix_render(&display); -} - -__attribute__ ((weak)) -void iota_gfx_task_user(void) { -} - -void iota_gfx_task(void) { - iota_gfx_task_user(); - - if (display.dirty) { - iota_gfx_flush(); - } - - if (timer_elapsed(last_flush) > ScreenOffInterval) { - iota_gfx_off(); - } -} -#endif diff --git a/keyboards/sol/common/ssd1306.h b/keyboards/sol/common/ssd1306.h deleted file mode 100644 index 77ce7c211..000000000 --- a/keyboards/sol/common/ssd1306.h +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef SSD1306_H -#define SSD1306_H - -#include -#include -#include "pincontrol.h" - -enum ssd1306_cmds { - DisplayOff = 0xAE, - DisplayOn = 0xAF, - - SetContrast = 0x81, - DisplayAllOnResume = 0xA4, - - DisplayAllOn = 0xA5, - NormalDisplay = 0xA6, - InvertDisplay = 0xA7, - SetDisplayOffset = 0xD3, - SetComPins = 0xda, - SetVComDetect = 0xdb, - SetDisplayClockDiv = 0xD5, - SetPreCharge = 0xd9, - SetMultiPlex = 0xa8, - SetLowColumn = 0x00, - SetHighColumn = 0x10, - SetStartLine = 0x40, - - SetMemoryMode = 0x20, - ColumnAddr = 0x21, - PageAddr = 0x22, - - ComScanInc = 0xc0, - ComScanDec = 0xc8, - SegRemap = 0xa0, - SetChargePump = 0x8d, - ExternalVcc = 0x01, - SwitchCapVcc = 0x02, - - ActivateScroll = 0x2f, - DeActivateScroll = 0x2e, - SetVerticalScrollArea = 0xa3, - RightHorizontalScroll = 0x26, - LeftHorizontalScroll = 0x27, - VerticalAndRightHorizontalScroll = 0x29, - VerticalAndLeftHorizontalScroll = 0x2a, -}; - -// Controls the SSD1306 128x32 OLED display via i2c - -#ifndef SSD1306_ADDRESS -#define SSD1306_ADDRESS 0x3C -#endif - -#define DisplayHeight 32 -#define DisplayWidth 128 - -#define FontHeight 8 -#define FontWidth 6 - -#define MatrixRows (DisplayHeight / FontHeight) -#define MatrixCols (DisplayWidth / FontWidth) - -struct CharacterMatrix { - uint8_t display[MatrixRows][MatrixCols]; - uint8_t *cursor; - bool dirty; -}; - -struct CharacterMatrix display; - -bool iota_gfx_init(bool rotate); -void iota_gfx_task(void); -bool iota_gfx_off(void); -bool iota_gfx_on(void); -void iota_gfx_flush(void); -void iota_gfx_write_char(uint8_t c); -void iota_gfx_write(const char *data); -void iota_gfx_write_P(const char *data); -void iota_gfx_clear_screen(void); - -void iota_gfx_task_user(void); - -void matrix_clear(struct CharacterMatrix *matrix); -void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c); -void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c); -void matrix_write(struct CharacterMatrix *matrix, const char *data); -void matrix_write_P(struct CharacterMatrix *matrix, const char *data); -void matrix_render(struct CharacterMatrix *matrix); - - - -#endif -- cgit v1.2.3-24-g4f1b