summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common_features.mk7
-rw-r--r--docs/feature_oled_driver.md246
-rw-r--r--docs/hardware_drivers.md6
-rw-r--r--drivers/arm/i2c_master.c40
-rw-r--r--drivers/arm/i2c_master.h20
-rwxr-xr-xdrivers/avr/i2c_master.c4
-rwxr-xr-xdrivers/avr/i2c_master.h6
-rw-r--r--drivers/oled/glcdfont.c240
-rw-r--r--drivers/oled/oled_driver.c528
-rw-r--r--drivers/oled/oled_driver.h183
-rw-r--r--keyboards/cannonkeys/satisfaction75/i2c_master.c46
-rw-r--r--keyboards/sol/common/glcdfont.c140
-rw-r--r--keyboards/sol/common/ssd1306.c329
-rw-r--r--keyboards/sol/common/ssd1306.h92
-rw-r--r--keyboards/sol/i2c.c162
-rw-r--r--keyboards/sol/i2c.h49
-rwxr-xr-xkeyboards/sol/keymaps/brianweyer/config.h2
-rwxr-xr-xkeyboards/sol/keymaps/brianweyer/keymap.c146
-rwxr-xr-xkeyboards/sol/keymaps/brianweyer/rules.mk14
-rw-r--r--keyboards/sol/keymaps/danielhklein/keymap.c145
-rw-r--r--keyboards/sol/keymaps/danielhklein/rules.mk8
-rw-r--r--keyboards/sol/keymaps/default/keymap.c145
-rw-r--r--keyboards/sol/keymaps/default/rules.mk8
-rw-r--r--keyboards/sol/keymaps/kageurufu/rules.mk7
-rw-r--r--keyboards/sol/rev1/config.h6
-rw-r--r--keyboards/sol/rev1/rev1.c7
-rw-r--r--keyboards/sol/rev1/split_util.h2
-rw-r--r--keyboards/sol/rules.mk7
-rw-r--r--quantum/quantum.c13
-rw-r--r--quantum/quantum.h4
30 files changed, 1540 insertions, 1072 deletions
diff --git a/common_features.mk b/common_features.mk
index eb623d18fa..fbfbc3ebc6 100644
--- a/common_features.mk
+++ b/common_features.mk
@@ -336,3 +336,10 @@ ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
endif
COMMON_VPATH += $(QUANTUM_PATH)/split_common
endif
+
+ifeq ($(strip $(OLED_DRIVER_ENABLE)), yes)
+ OPT_DEFS += -DOLED_DRIVER_ENABLE
+ COMMON_VPATH += $(DRIVER_PATH)/oled
+ QUANTUM_LIB_SRC += i2c_master.c
+ SRC += oled_driver.c
+endif
diff --git a/docs/feature_oled_driver.md b/docs/feature_oled_driver.md
new file mode 100644
index 0000000000..f261bbef18
--- /dev/null
+++ b/docs/feature_oled_driver.md
@@ -0,0 +1,246 @@
+# OLED Driver
+
+## OLED Supported Hardware
+
+128x32 OLED modules using SSD1306 driver IC over I2C. Supported on AVR based keyboards. Possible but untested hardware includes ARM based keyboards and other sized OLED modules using SSD1306 over I2C, such as 128x64.
+
+!> Warning: This OLED Driver currently uses the new i2c_master driver from split common code. If your split keyboard uses i2c to communication between sides this driver could cause an address conflict (serial is fine). Please contact your keyboard vendor and ask them to migrate to the latest split common code to fix this.
+
+## Usage
+
+To enable the OLED feature, there are three steps. First, when compiling your keyboard, you'll need to set `OLED_DRIVER_ENABLE=yes` in `rules.mk`, e.g.:
+
+```
+BOOTMAGIC_ENABLE = no
+MOUSEKEY_ENABLE = no
+STENO_ENABLE = no
+EXTRAKEY_ENABLE = yes
+OLED_DRIVER_ENABLE = yes
+```
+
+This enables the feature and the `OLED_DRIVER_ENABLE` define. Then in your `keymap.c` file, you will need to implement the user task call, e.g:
+
+```C++
+#ifdef OLED_DRIVER_ENABLE
+void oled_task_user(void) {
+ // Host Keyboard Layer Status
+ oled_write_P(PSTR("Layer: "), false);
+ switch (biton32(layer_state)) {
+ case _QWERTY:
+ oled_write_P(PSTR("Default\n"), false);
+ break;
+ case _FN:
+ oled_write_P(PSTR("FN\n"), false);
+ break;
+ case _ADJ:
+ oled_write_P(PSTR("ADJ\n"), false);
+ break;
+ default:
+ // Or use the write_ln shortcut
+ oled_write_P(PSTR("Undefined\n"), false);
+ }
+
+ // Host Keyboard LED Status
+ uint8_t led_usb_state = host_keyboard_leds();
+ oled_write_P(led_usb_state & (1<<USB_LED_NUM_LOCK) ? PSTR("NUMLCK ") : PSTR(" "), false);
+ oled_write_P(led_usb_state & (1<<USB_LED_CAPS_LOCK) ? PSTR("CAPLCK ") : PSTR(" "), false);
+ oled_write_P(led_usb_state & (1<<USB_LED_SCROLL_LOCK) ? PSTR("SCRLCK ") : PSTR(" "), false);
+}
+#endif
+```
+
+
+## Other Examples
+
+In split keyboards, it is very common to have two OLED displays that each render different content and oriented flipped differently. You can do this by switching which content to render by using the return from `is_keyboard_master()` or `is_keyboard_left()` found in `split_util.h`, e.g:
+
+```C++
+#ifdef OLED_DRIVER_ENABLE
+uint8_t oled_init_user(uint8_t rotation) {
+ if (!is_keyboard_master())
+ return OLED_ROTATION_180; // flips the display 180 degrees if offhand
+ return rotation;
+}
+
+void oled_task_user(void) {
+ if (is_keyboard_master()) {
+ render_status(); // Renders the current keyboard state (layer, lock, caps, scroll, etc)
+ } else {
+ render_logo(); // Renders a statuc logo
+ oled_scroll_left(); // Turns on scrolling
+ }
+}
+#endif
+```
+
+
+ ## Basic Configuration
+
+|Define |Default |Description |
+|-----------------------|---------------|------------------------------------------------|
+|`OLED_DISPLAY_ADDRESS` |`0x3C` |The i2c address of the OLED Display |
+|`OLED_FONT_H` |`"glcdfont.c"` |The font code file to use for custom fonts |
+|`OLED_FONT_START` |`0` |The starting characer index for custom fonts |
+|`OLED_FONT_END` |`224` |The ending characer index for custom fonts |
+|`OLED_FONT_WIDTH` |`6` |The font width |
+|`OLED_FONT_HEIGHT` |`8` |The font height (untested) |
+|`OLED_DISABLE_TIMEOUT` |*Not defined* |Disables the built in OLED timeout feature. Useful when implementing custom timeout rules.|
+
+
+
+ ## 128x64 & Custom sized OLED Displays
+
+ The default display size for this feature is 128x32 and all necessary defines are precalculated with that in mind. We have added a define, `OLED_DISPLAY_128X64`, to switch all the values to be used in a 128x64 display, as well as added a custom define, `OLED_DISPLAY_CUSTOM`, that allows you to provide the necessary values to the driver.
+
+|Define |Default |Description |
+|-----------------------|---------------|-----------------------------------------------------------------|
+|`OLED_DISPLAY_128X64` |*Not defined* |Changes the display defines for use with 128x64 displays. |
+|`OLED_DISPLAY_CUSTOM` |*Not defined* |Changes the display defines for use with custom displays.<br />Requires user to implement the below defines. |
+|`OLED_DISPLAY_WIDTH` |`128` |The width of the OLED display. |
+|`OLED_DISPLAY_HEIGHT` |`32` |The height of the OLED display. |
+|`OLED_MATRIX_SIZE` |`512` |The local buffer size to allocate.<br />`(OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH)`|
+|`OLED_BLOCK_TYPE` |`uint8_t` |The unsigned integer type to use for dirty rendering.|
+|`OLED_BLOCK_COUNT` |`8` |The number of blocks the display is divided into for dirty rendering.<br />`(sizeof(OLED_BLOCK_TYPE) * 8)`|
+|`OLED_BLOCK_SIZE` |`64` |The size of each block for dirty rendering<br />`(OLED_MATRIX_SIZE / OLED_BLOCK_COUNT)`|
+|`OLED_SOURCE_MAP` |`{ 0, ... N }` |Precalculated source array to use for mapping source buffer to target OLED memory in 90 degree rendering. |
+|`OLED_TARGET_MAP` |`{ 48, ... N }`|Precalculated target array to use for mapping source buffer to target OLED memory in 90 degree rendering. |
+
+
+### 90 Degree Rotation - Technical Mumbo Jumbo
+
+ OLED displays driven by SSD1306 drivers only natively support in hard ware 0 degree and 180 degree rendering. This feature is done in software and not free. Using this feature will increase the time to calculate what data to send over i2c to the OLED. If you are strapped for cycles, this can cause keycodes to not register. In testing however, the rendering time on an `atmega32u4` board only went from 2ms to 5ms and keycodes not registering was only noticed once we hit 15ms.
+
+ 90 Degree Rotated Rendering is achieved by using bitwise operations to rotate each 8 block of memory and uses two precalculated arrays to remap buffer memory to OLED memory. The memory map defines are precalculated for remap performance and are calculated based on the OLED Height, Width, and Block Size. For example, in the default 128x32 implementation we have a 64 byte block size. This gives us eight 8 byte blocks that need to be rotated and rendered. The OLED renders horizontally two 8 byte blocks before moving down a page, e.g:
+
+| | | | | | |
+|---|---|---|---|---|---|
+| 0 | 1 | | | | |
+| 2 | 3 | | | | |
+| 4 | 5 | | | | |
+| 6 | 7 | | | | |
+
+However the local buffer is stored as if it was Height x Width display instead of Width x Height, e.g:
+
+| | | | | | |
+|---|---|---|---|---|---|
+| 3 | 7 | | | | |
+| 2 | 6 | | | | |
+| 1 | 5 | | | | |
+| 0 | 4 | | | | |
+
+So those precalculated arrays just index the memory offsets in the order in which each one iterates its data.
+
+## OLED API
+
+```C++
+// Initialize the OLED display, rotating the rendered output 180 degrees if true.
+// Returns true if the OLED was initialized successfully
+bool oled_init(bool flip180);
+
+// Called at the start of oled_init, weak function overridable by the user
+// flip180 - the value passed into oled_init
+// Return true if you want the oled to be flip180
+bool oled_init_user(bool flip180);
+
+// Clears the display buffer, resets cursor position to 0, and sets the buffer to dirty for rendering
+void oled_clear(void);
+
+// Renders the dirty chunks of the buffer to OLED display
+void oled_render(void);
+
+// Moves cursor to character position indicated by column and line, wraps if out of bounds
+// Max column denoted by 'oled_max_chars()' and max lines by 'oled_max_lines()' functions
+void oled_set_cursor(uint8_t col, uint8_t line);
+
+// Advances the cursor to the next page, writing ' ' if true
+// Wraps to the begining when out of bounds
+void oled_advance_page(bool clearPageRemainder);
+
+// Moves the cursor forward 1 character length
+// Advance page if there is not enough room for the next character
+// Wraps to the begining when out of bounds
+void oled_advance_char(void);
+
+// Writes a single character to the buffer at current cursor position
+// Advances the cursor while writing, inverts the pixels if true
+// Main handler that writes character data to the display buffer
+void oled_write_char(const char data, bool invert);
+
+// Writes a string to the buffer at current cursor position
+// Advances the cursor while writing, inverts the pixels if true
+void oled_write(const char *data, bool invert);
+
+// Writes a string to the buffer at current cursor position
+// Advances the cursor while writing, inverts the pixels if true
+// Advances the cursor to the next page, wiring ' ' to the remainder of the current page
+void oled_write_ln(const char *data, bool invert);
+
+// Writes a PROGMEM string to the buffer at current cursor position
+// Advances the cursor while writing, inverts the pixels if true
+// Remapped to call 'void oled_write(const char *data, bool invert);' on ARM
+void oled_write_P(const char *data, bool invert);
+
+// Writes a PROGMEM string to the buffer at current cursor position
+// Advances the cursor while writing, inverts the pixels if true
+// Advances the cursor to the next page, wiring ' ' to the remainder of the current page
+// Remapped to call 'void oled_write_ln(const char *data, bool invert);' on ARM
+void oled_write_ln_P(const char *data, bool invert);
+
+// Can be used to manually turn on the screen if it is off
+// Returns true if the screen was on or turns on
+bool oled_on(void);
+
+// Can be used to manually turn off the screen if it is on
+// Returns true if the screen was off or turns off
+bool oled_off(void);
+
+// Basically it's oled_render, but with timeout management and oled_task_user calling!
+void oled_task(void);
+
+// Called at the start of oled_task, weak function overridable by the user
+void oled_task_user(void);
+
+// Scrolls the entire display right
+// Returns true if the screen was scrolling or starts scrolling
+// NOTE: display contents cannot be changed while scrolling
+bool oled_scroll_right(void);
+
+// Scrolls the entire display left
+// Returns true if the screen was scrolling or starts scrolling
+// NOTE: display contents cannot be changed while scrolling
+bool oled_scroll_left(void);
+
+// Turns off display scrolling
+// Returns true if the screen was not scrolling or stops scrolling
+bool oled_scroll_off(void);
+
+// Returns the maximum number of characters that will fit on a line
+uint8_t oled_max_chars(void);
+
+// Returns the maximum number of lines that will fit on the oled
+uint8_t oled_max_lines(void);
+```
+
+## SSD1306.h driver conversion guide
+
+|Old API |Recommended New API |
+|---------------------------|-----------------------------------|
+|`struct CharacterMatrix` |*removed - delete all references* |
+|`iota_gfx_init` |`oled_init` |
+|`iota_gfx_on` |`oled_on` |
+|`iota_gfx_off` |`oled_off` |
+|`iota_gfx_flush` |`oled_render` |
+|`iota_gfx_write_char` |`oled_write_char` |
+|`iota_gfx_write` |`oled_write` |
+|`iota_gfx_write_P` |`oled_write_P` |
+|`iota_gfx_clear_screen` |`oled_clear` |
+|`matrix_clear` |*removed - delete all references* |
+|`matrix_write_char_inner` |`oled_write_char` |
+|`matrix_write_char` |`oled_write_char` |
+|`matrix_write` |`oled_write` |
+|`matrix_write_ln` |`oled_write_ln` |
+|`matrix_write_P` |`oled_write_P` |
+|`matrix_write_ln_P` |`oled_write_ln_P` |
+|`matrix_render` |`oled_render` |
+|`iota_gfx_task` |`oled_task` |
+|`iota_gfx_task_user` |`oled_task_user` |
diff --git a/docs/hardware_drivers.md b/docs/hardware_drivers.md
index 4c1266f224..023e92982c 100644
--- a/docs/hardware_drivers.md
+++ b/docs/hardware_drivers.md
@@ -14,9 +14,9 @@ QMK is used on a lot of different hardware. While support for the most common MC
Support for addressing pins on the ProMicro by their Arduino name rather than their AVR name. This needs to be better documented, if you are trying to do this and reading the code doesn't help please [open an issue](https://github.com/qmk/qmk_firmware/issues/new) and we can help you through the process.
-## SSD1306 (AVR Only)
+## SSD1306 OLED Driver
-Support for SSD1306 based OLED displays. This needs to be better documented, if you are trying to do this and reading the code doesn't help please [open an issue](https://github.com/qmk/qmk_firmware/issues/new) and we can help you through the process.
+Support for SSD1306 based OLED displays. For more information see the [OLED Driver Feature](feature_oled_driver.md) page.
## uGFX
@@ -32,4 +32,4 @@ Support for up to 2 drivers. Each driver impliments 2 charlieplex matrices to in
## IS31FL3733
-Support for up to a single driver with room for expansion. Each driver can control 192 individual LEDs or 64 RGB LEDs. For more information on how to setup the driver see the [RGB Matrix](feature_rgb_matrix.md) page. \ No newline at end of file
+Support for up to a single driver with room for expansion. Each driver can control 192 individual LEDs or 64 RGB LEDs. For more information on how to setup the driver see the [RGB Matrix](feature_rgb_matrix.md) page.
diff --git a/drivers/arm/i2c_master.c b/drivers/arm/i2c_master.c
index 0e5edcc380..7369398cc4 100644
--- a/drivers/arm/i2c_master.c
+++ b/drivers/arm/i2c_master.c
@@ -42,6 +42,18 @@ static const I2CConfig i2cconfig = {
0
};
+static i2c_status_t chibios_to_qmk(const msg_t* status) {
+ switch (*status) {
+ case I2C_NO_ERROR:
+ return I2C_STATUS_SUCCESS;
+ case I2C_TIMEOUT:
+ return I2C_STATUS_TIMEOUT;
+ // I2C_BUS_ERROR, I2C_ARBITRATION_LOST, I2C_ACK_FAILURE, I2C_OVERRUN, I2C_PEC_ERROR, I2C_SMB_ALERT
+ default:
+ return I2C_STATUS_ERROR;
+ }
+}
+
__attribute__ ((weak))
void i2c_init(void)
{
@@ -57,29 +69,30 @@ void i2c_init(void)
//i2cInit(); //This is invoked by halInit() so no need to redo it.
}
-// This is usually not needed
-uint8_t i2c_start(uint8_t address)
+i2c_status_t i2c_start(uint8_t address)
{
i2c_address = address;
i2cStart(&I2C_DRIVER, &i2cconfig);
- return 0;
+ return I2C_STATUS_SUCCESS;
}
-uint8_t i2c_transmit(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout)
+i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout)
{
i2c_address = address;
i2cStart(&I2C_DRIVER, &i2cconfig);
- return i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, 0, 0, MS2ST(timeout));
+ msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, 0, 0, MS2ST(timeout));
+ return chibios_to_qmk(&status);
}
-uint8_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout)
+i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout)
{
i2c_address = address;
i2cStart(&I2C_DRIVER, &i2cconfig);
- return i2cMasterReceiveTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, MS2ST(timeout));
+ msg_t status = i2cMasterReceiveTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, MS2ST(timeout));
+ return chibios_to_qmk(&status);
}
-uint8_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)
+i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout)
{
i2c_address = devaddr;
i2cStart(&I2C_DRIVER, &i2cconfig);
@@ -91,18 +104,19 @@ uint8_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t l
}
complete_packet[0] = regaddr;
- return i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), complete_packet, length + 1, 0, 0, MS2ST(timeout));
+ msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), complete_packet, length + 1, 0, 0, MS2ST(timeout));
+ return chibios_to_qmk(&status);
}
-uint8_t i2c_readReg(uint8_t devaddr, uint8_t* regaddr, uint8_t* data, uint16_t length, uint16_t timeout)
+i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t* regaddr, uint8_t* data, uint16_t length, uint16_t timeout)
{
i2c_address = devaddr;
i2cStart(&I2C_DRIVER, &i2cconfig);
- return i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), regaddr, 1, data, length, MS2ST(timeout));
+ msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), regaddr, 1, data, length, MS2ST(timeout));
+ return chibios_to_qmk(&status);
}
-uint8_t i2c_stop(void)
+void i2c_stop(void)
{
i2cStop(&I2C_DRIVER);
- return 0;
}
diff --git a/drivers/arm/i2c_master.h b/drivers/arm/i2c_master.h
index 4ab2301f8c..a15f1702dd 100644
--- a/drivers/arm/i2c_master.h
+++ b/drivers/arm/i2c_master.h
@@ -40,11 +40,17 @@
#define I2C_DRIVER I2CD1
#endif
+typedef int16_t i2c_status_t;
+
+#define I2C_STATUS_SUCCESS (0)
+#define I2C_STATUS_ERROR (-1)
+#define I2C_STATUS_TIMEOUT (-2)
+
void i2c_init(void);
-uint8_t i2c_start(uint8_t address);
-uint8_t i2c_transmit(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout);
-uint8_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout);
-uint8_t i2c_transmit_receive(uint8_t address, uint8_t * tx_body, uint16_t tx_length, uint8_t * rx_body, uint16_t rx_length);
-uint8_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout);
-uint8_t i2c_readReg(uint8_t devaddr, uint8_t* regaddr, uint8_t* data, uint16_t length, uint16_t timeout);
-uint8_t i2c_stop(void);
+i2c_status_t i2c_start(uint8_t address);
+i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout);
+i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout);
+i2c_status_t i2c_transmit_receive(uint8_t address, uint8_t * tx_body, uint16_t tx_length, uint8_t * rx_body, uint16_t rx_length);
+i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout);
+i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t* regaddr, uint8_t* data, uint16_t length, uint16_t timeout);
+void i2c_stop(void);
diff --git a/drivers/avr/i2c_master.c b/drivers/avr/i2c_master.c
index ba6d0d1586..a7364bae08 100755
--- a/drivers/avr/i2c_master.c
+++ b/drivers/avr/i2c_master.c
@@ -121,7 +121,7 @@ int16_t i2c_read_nack(uint16_t timeout) {
return TWDR;
}
-i2c_status_t i2c_transmit(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout) {
+i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout) {
i2c_status_t status = i2c_start(address | I2C_WRITE, timeout);
for (uint16_t i = 0; i < length && status >= 0; i++) {
@@ -155,7 +155,7 @@ i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16
return (status < 0) ? status : I2C_STATUS_SUCCESS;
}
-i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout) {
+i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout) {
i2c_status_t status = i2c_start(devaddr | 0x00, timeout);
if (status >= 0) {
status = i2c_write(regaddr, timeout);
diff --git a/drivers/avr/i2c_master.h b/drivers/avr/i2c_master.h
index 81a7fb5e32..b4613115d9 100755
--- a/drivers/avr/i2c_master.h
+++ b/drivers/avr/i2c_master.h
@@ -22,10 +22,10 @@ i2c_status_t i2c_start(uint8_t address, uint16_t timeout);
i2c_status_t i2c_write(uint8_t data, uint16_t timeout);
int16_t i2c_read_ack(uint16_t timeout);
int16_t i2c_read_nack(uint16_t timeout);
-i2c_status_t i2c_transmit(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout);
+i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout);
i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout);
-i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout);
+i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout);
i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout);
void i2c_stop(void);
-#endif // I2C_MASTER_H \ No newline at end of file
+#endif // I2C_MASTER_H
diff --git a/drivers/oled/glcdfont.c b/drivers/oled/glcdfont.c
new file mode 100644
index 0000000000..150be9e944
--- /dev/null
+++ b/drivers/oled/glcdfont.c
@@ -0,0 +1,240 @@
+#pragma once
+
+#ifdef __AVR__
+ #include <avr/io.h>
+ #include <avr/pgmspace.h>
+#elif defined(ESP8266)
+ #include <pgmspace.h>
+#else
+ #define PROGMEM
+#endif
+
+// Helidox 8x6 font with QMK Firmware Logo
+// Online editor: http://teripom.x0.com/
+
+static const unsigned char font[] PROGMEM = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x00,
+ 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x00,
+ 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x00,
+ 0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x00,
+ 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x00,
+ 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00,
+ 0x00, 0x18, 0x3C, 0x18, 0x00, 0x00,
+ 0xF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 0x08, 0x64, 0x62, 0x00,
+ 0x36, 0x49, 0x56, 0x20, 0x50, 0x00,
+ 0x00, 0x08, 0x07, 0x03, 0x00, 0x00,
+ 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00,
+ 0x00, 0x41, 0x22, 0x1C, 0x00, 0x00,
+ 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x00,
+ 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00,
+ 0x00, 0x80, 0x70, 0x30, 0x00, 0x00,
+ 0x08, 0x08, 0x08, 0x08, 0x08, 0x00,
+ 0x00, 0x00, 0x60, 0x60, 0x00, 0x00,
+ 0x20, 0x10, 0x08, 0x04, 0x02, 0x00,
+ 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00,
+ 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00,
+ 0x72, 0x49, 0x49, 0x49, 0x46, 0x00,
+ 0x21, 0x41, 0x49, 0x4D, 0x33, 0x00,
+ 0x18, 0x14, 0x12, 0x7F, 0x10, 0x00,
+ 0x27, 0x45, 0x45, 0x45, 0x39, 0x00,
+ 0x3C, 0x4A, 0x49, 0x49, 0x31, 0x00,
+ 0x41, 0x21, 0x11, 0x09, 0x07, 0x00,
+ 0x36, 0x49, 0x49, 0x49, 0x36, 0x00,
+ 0x46, 0x49, 0x49, 0x29, 0x1E, 0x00,
+ 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
+ 0x00, 0x40, 0x34, 0x00, 0x00, 0x00,
+ 0x00, 0x08, 0x14, 0x22, 0x41, 0x00,
+ 0x14, 0x14, 0x14, 0x14, 0x14, 0x00,
+ 0x00, 0x41, 0x22, 0x14, 0x08, 0x00,
+ 0x02, 0x01, 0x59, 0x09, 0x06, 0x00,
+ 0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x00,
+ 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x00,
+ 0x7F, 0x49, 0x49, 0x49, 0x36, 0x00,
+ 0x3E, 0x41, 0x41, 0x41, 0x22, 0x00,
+ 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x00,
+ 0x7F, 0x49, 0x49, 0x49, 0x41, 0x00,
+ 0x7F, 0x09, 0x09, 0x09, 0x01, 0x00,
+ 0x3E, 0x41, 0x41, 0x51, 0x73, 0x00,
+ 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00,
+ 0x00, 0x41, 0x7F, 0x41, 0x00, 0x00,
+ 0x20, 0x40, 0x41, 0x3F, 0x01, 0x00,
+ 0x7F, 0x08, 0x14, 0x22, 0x41, 0x00,
+ 0x7F, 0x40, 0x40, 0x40, 0x40, 0x00,
+ 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x00,
+ 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00,
+ 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00,
+ 0x7F, 0x09, 0x09, 0x09, 0x06, 0x00,
+ 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00,
+ 0x7F, 0x09, 0x19, 0x29, 0x46, 0x00,
+ 0x26, 0x49, 0x49, 0x49, 0x32, 0x00,
+ 0x03, 0x01, 0x7F, 0x01, 0x03, 0x00,
+ 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00,
+ 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00,
+ 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x00,
+ 0x63, 0x14, 0x08, 0x14, 0x63, 0x00,
+ 0x03, 0x04, 0x78, 0x04, 0x03, 0x00,
+ 0x61, 0x59, 0x49, 0x4D, 0x43, 0x00,
+ 0x00, 0x7F, 0x41, 0x41, 0x41, 0x00,
+ 0x02, 0x04, 0x08, 0x10, 0x20, 0x00,
+ 0x00, 0x41, 0x41, 0x41, 0x7F, 0x00,
+ 0x04, 0x02, 0x01, 0x02, 0x04, 0x00,
+ 0x40, 0x40, 0x40, 0x40, 0x40, 0x00,
+ 0x00, 0x03, 0x07, 0x08, 0x00, 0x00,
+ 0x20, 0x54, 0x54, 0x78, 0x40, 0x00,
+ 0x7F, 0x28, 0x44, 0x44, 0x38, 0x00,
+ 0x38, 0x44, 0x44, 0x44, 0x28, 0x00,
+ 0x38, 0x44, 0x44, 0x28, 0x7F, 0x00,
+ 0x38, 0x54, 0x54, 0x54, 0x18, 0x00,
+ 0x00, 0x08, 0x7E, 0x09, 0x02, 0x00,
+ 0x18, 0xA4, 0xA4, 0x9C, 0x78, 0x00,
+ 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00,
+ 0x00, 0x44, 0x7D, 0x40, 0x00, 0x00,
+ 0x20, 0x40, 0x40, 0x3D, 0x00, 0x00,
+ 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00,
+ 0x00, 0x41, 0x7F, 0x40, 0x00, 0x00,
+ 0x7C, 0x04, 0x78, 0x04, 0x78, 0x00,
+ 0x7C, 0x08, 0x04, 0x04, 0x78, 0x00,
+ 0x38, 0x44, 0x44, 0x44, 0x38, 0x00,
+ 0xFC, 0x18, 0x24, 0x24, 0x18, 0x00,
+ 0x18, 0x24, 0x24, 0x18, 0xFC, 0x00,
+ 0x7C, 0x08, 0x04, 0x04, 0x08, 0x00,
+ 0x48, 0x54, 0x54, 0x54, 0x24, 0x00,
+ 0x04, 0x04, 0x3F, 0x44, 0x24, 0x00,
+ 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x00,
+ 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00,
+ 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00,
+ 0x44, 0x28, 0x10, 0x28, 0x44, 0x00,
+ 0x4C, 0x90, 0x90, 0x90, 0x7C, 0x00,
+ 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00,
+ 0x00, 0x08, 0x36, 0x41, 0x00, 0x00,
+ 0x00, 0x00, 0x77, 0x00, 0x00, 0x00,
+ 0x00, 0x41, 0x36, 0x08, 0x00, 0x00,
+ 0x02, 0x01, 0x02, 0x04, 0x02, 0x00,
+ 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x00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x7B, 0x7F, 0x78, 0x30, 0x20,
+ 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,
+ 0x01, 0x01, 0x01, 0x07, 0x0F, 0x0F,
+ 0x7F, 0x0F, 0x7F, 0x0F, 0x0F, 0x7E,
+ 0x0F, 0x0F, 0x7F, 0x0F, 0x7F, 0x0F,
+ 0x0F, 0x07, 0x01, 0x01, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01, 0x01, 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, 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, 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,
+};
diff --git a/drivers/oled/oled_driver.c b/drivers/oled/oled_driver.c
new file mode 100644
index 0000000000..aa025d7a4c
--- /dev/null
+++ b/drivers/oled/oled_driver.c
@@ -0,0 +1,528 @@
+/*
+Copyright 2019 Ryan Caltabiano <https://github.com/XScorpion2>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.