diff options
author | ishtob <ishtob@gmail.com> | 2017-07-12 12:10:28 -0400 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2017-07-12 12:10:28 -0400 |
commit | 087af43dee545792f486069481460ed5997bc41b (patch) | |
tree | 94466dfcf27bca408c94ce1703cf8ac1e1511216 | |
parent | cc468523dfec8175939f575a214714eea8aaa7a3 (diff) | |
download | qmk_firmware-087af43dee545792f486069481460ed5997bc41b.tar.gz qmk_firmware-087af43dee545792f486069481460ed5997bc41b.zip |
fix implementation issues from SSD1306 clean up, added rotation (#1494)
* moved OLED update task to keymap
* fix splitting render display to keymap
* Added rotation option for OLED, fixed splitting display render update to keymap
* issues with attribute
-rw-r--r-- | drivers/avr/ssd1306.c | 16 | ||||
-rw-r--r-- | drivers/avr/ssd1306.h | 1 | ||||
-rw-r--r-- | keyboards/hadron/keymaps/default/config.h | 1 | ||||
-rw-r--r-- | keyboards/hadron/keymaps/default/keymap.c | 88 | ||||
-rw-r--r-- | keyboards/hadron/keymaps/side_numpad/config.h | 1 | ||||
-rw-r--r-- | keyboards/hadron/keymaps/side_numpad/keymap.c | 87 | ||||
-rw-r--r-- | keyboards/lets_split/keymaps/OLED_sample/config.h | 1 | ||||
-rw-r--r-- | keyboards/lets_split/keymaps/OLED_sample/keymap.c | 22 |
8 files changed, 203 insertions, 14 deletions
diff --git a/drivers/avr/ssd1306.c b/drivers/avr/ssd1306.c index 03a909e9df..bb8938bba3 100644 --- a/drivers/avr/ssd1306.c +++ b/drivers/avr/ssd1306.c @@ -134,14 +134,17 @@ bool iota_gfx_init(void) { send_cmd2(SetChargePump, 0x14 /* Enable */); send_cmd2(SetMemoryMode, 0 /* horizontal addressing */); -/// Flips the display orientation 0 degrees - send_cmd1(SegRemap | 0x1); - send_cmd1(ComScanDec); -/* +#ifdef OLED_ROTATE180 // the following Flip the display orientation 180 degrees send_cmd1(SegRemap); send_cmd1(ComScanInc); -// end flip */ +#endif +#ifndef OLED_ROTATE180 +// Flips the display orientation 0 degrees + send_cmd1(SegRemap | 0x1); + send_cmd1(ComScanDec); +#endif + send_cmd2(SetComPins, 0x2); send_cmd2(SetContrast, 0x8f); send_cmd2(SetPreCharge, 0xf1); @@ -304,9 +307,8 @@ void iota_gfx_flush(void) { matrix_render(&display); } -__attribute__((weak)) +__attribute__ ((weak)) void iota_gfx_task_user(void) { - } void iota_gfx_task(void) { diff --git a/drivers/avr/ssd1306.h b/drivers/avr/ssd1306.h index 1b6f8a4933..df6a75359f 100644 --- a/drivers/avr/ssd1306.h +++ b/drivers/avr/ssd1306.h @@ -79,7 +79,6 @@ void iota_gfx_write(const char *data); void iota_gfx_write_P(const char *data); void iota_gfx_clear_screen(void); -__attribute__((weak)) void iota_gfx_task_user(void); void matrix_clear(struct CharacterMatrix *matrix); diff --git a/keyboards/hadron/keymaps/default/config.h b/keyboards/hadron/keymaps/default/config.h index 4a5a8fad38..0f349ad932 100644 --- a/keyboards/hadron/keymaps/default/config.h +++ b/keyboards/hadron/keymaps/default/config.h @@ -9,6 +9,7 @@ #define USE_I2C #define SSD1306OLED +#define OLED_ROTATE180 /* ws2812 RGB LED*/ #define RGB_DI_PIN D4 diff --git a/keyboards/hadron/keymaps/default/keymap.c b/keyboards/hadron/keymaps/default/keymap.c index 24fa0b27f2..01cc8abab7 100644 --- a/keyboards/hadron/keymaps/default/keymap.c +++ b/keyboards/hadron/keymaps/default/keymap.c @@ -406,3 +406,91 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) return MACRO_NONE; } + +void matrix_update(struct CharacterMatrix *dest, + const struct CharacterMatrix *source) { + if (memcmp(dest->display, source->display, sizeof(dest->display))) { + memcpy(dest->display, source->display, sizeof(dest->display)); + dest->dirty = true; + } +} + +//assign the right code to your layers for OLED display +#define L_BASE 0 +#define L_LOWER 8 +#define L_RAISE 16 +#define L_FNLAYER 64 +#define L_NUMLAY 128 +#define L_NLOWER 136 +#define L_NFNLAYER 192 +#define L_MOUSECURSOR 256 +#define L_ADJUST 65560 + +void iota_gfx_task_user(void) { +#if DEBUG_TO_SCREEN + if (debug_enable) { + return; + } +#endif + + struct CharacterMatrix matrix; + + matrix_clear(&matrix); + matrix_write_P(&matrix, PSTR("USB: ")); +#ifdef PROTOCOL_LUFA + switch (USB_DeviceState) { + case DEVICE_STATE_Unattached: + matrix_write_P(&matrix, PSTR("Unattached")); + break; + case DEVICE_STATE_Suspended: + matrix_write_P(&matrix, PSTR("Suspended")); + break; + case DEVICE_STATE_Configured: + matrix_write_P(&matrix, PSTR("Connected")); + break; + case DEVICE_STATE_Powered: + matrix_write_P(&matrix, PSTR("Powered")); + break; + case DEVICE_STATE_Default: + matrix_write_P(&matrix, PSTR("Default")); + break; + case DEVICE_STATE_Addressed: + matrix_write_P(&matrix, PSTR("Addressed")); + break; + default: + matrix_write_P(&matrix, PSTR("Invalid")); + } +#endif + +// Define layers here, Have not worked out how to have text displayed for each layer. Copy down the number you see and add a case for it below + + char buf[40]; + snprintf(buf,sizeof(buf), "Undef-%ld", layer_state); + matrix_write_P(&matrix, PSTR("\n\nLayer: ")); + switch (layer_state) { + case L_BASE: + matrix_write_P(&matrix, PSTR("Default")); + break; + case L_RAISE: + matrix_write_P(&matrix, PSTR("Raise")); + break; + case L_LOWER: + matrix_write_P(&matrix, PSTR("Lower")); + break; + case L_ADJUST: + matrix_write_P(&matrix, PSTR("ADJUST")); + break; + default: + matrix_write(&matrix, buf); + } + + // Host Keyboard LED Status + char led[40]; + snprintf(led, sizeof(led), "\n%s %s %s", + (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ", + (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ", + (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " "); + matrix_write(&matrix, led); + matrix_update(&display, &matrix); +} + diff --git a/keyboards/hadron/keymaps/side_numpad/config.h b/keyboards/hadron/keymaps/side_numpad/config.h index 4a5a8fad38..0f349ad932 100644 --- a/keyboards/hadron/keymaps/side_numpad/config.h +++ b/keyboards/hadron/keymaps/side_numpad/config.h @@ -9,6 +9,7 @@ #define USE_I2C #define SSD1306OLED +#define OLED_ROTATE180 /* ws2812 RGB LED*/ #define RGB_DI_PIN D4 diff --git a/keyboards/hadron/keymaps/side_numpad/keymap.c b/keyboards/hadron/keymaps/side_numpad/keymap.c index cfe6cc539c..a5ccfd0222 100644 --- a/keyboards/hadron/keymaps/side_numpad/keymap.c +++ b/keyboards/hadron/keymaps/side_numpad/keymap.c @@ -416,3 +416,90 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) return MACRO_NONE; } + +void matrix_update(struct CharacterMatrix *dest, + const struct CharacterMatrix *source) { + if (memcmp(dest->display, source->display, sizeof(dest->display))) { + memcpy(dest->display, source->display, sizeof(dest->display)); + dest->dirty = true; + } +} + +//assign the right code to your layers for OLED display +#define L_BASE 0 +#define L_LOWER 8 +#define L_RAISE 16 +#define L_FNLAYER 64 +#define L_NUMLAY 128 +#define L_NLOWER 136 +#define L_NFNLAYER 192 +#define L_MOUSECURSOR 256 +#define L_ADJUST 65560 + +void iota_gfx_task_user(void) { +#if DEBUG_TO_SCREEN + if (debug_enable) { + return; + } +#endif + + struct CharacterMatrix matrix; + + matrix_clear(&matrix); + matrix_write_P(&matrix, PSTR("USB: ")); +#ifdef PROTOCOL_LUFA + switch (USB_DeviceState) { + case DEVICE_STATE_Unattached: + matrix_write_P(&matrix, PSTR("Unattached")); + break; + case DEVICE_STATE_Suspended: + matrix_write_P(&matrix, PSTR("Suspended")); + break; + case DEVICE_STATE_Configured: + matrix_write_P(&matrix, PSTR("Connected")); + break; + case DEVICE_STATE_Powered: + matrix_write_P(&matrix, PSTR("Powered")); + break; + case DEVICE_STATE_Default: + matrix_write_P(&matrix, PSTR("Default")); + break; + case DEVICE_STATE_Addressed: + matrix_write_P(&matrix, PSTR("Addressed")); + break; + default: + matrix_write_P(&matrix, PSTR("Invalid")); + } +#endif + +// Define layers here, Have not worked out how to have text displayed for each layer. Copy down the number you see and add a case for it below + + char buf[40]; + snprintf(buf,sizeof(buf), "Undef-%ld", layer_state); + matrix_write_P(&matrix, PSTR("\n\nLayer: ")); + switch (layer_state) { + case L_BASE: + matrix_write_P(&matrix, PSTR("Default")); + break; + case L_RAISE: + matrix_write_P(&matrix, PSTR("Raise")); + break; + case L_LOWER: + matrix_write_P(&matrix, PSTR("Lower")); + break; + case L_ADJUST: + matrix_write_P(&matrix, PSTR("ADJUST")); + break; + default: + matrix_write(&matrix, buf); + } + + // Host Keyboard LED Status + char led[40]; + snprintf(led, sizeof(led), "\n%s %s %s", + (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ", + (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ", + (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " "); + matrix_write(&matrix, led); + matrix_update(&display, &matrix); +} diff --git a/keyboards/lets_split/keymaps/OLED_sample/config.h b/keyboards/lets_split/keymaps/OLED_sample/config.h index c7cbc9372d..57ed7d763b 100644 --- a/keyboards/lets_split/keymaps/OLED_sample/config.h +++ b/keyboards/lets_split/keymaps/OLED_sample/config.h @@ -36,6 +36,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define FLIP_HALF #define SSD1306OLED +//#define OLED_ROTATE180 #define PREVENT_STUCK_MODIFIERS diff --git a/keyboards/lets_split/keymaps/OLED_sample/keymap.c b/keyboards/lets_split/keymaps/OLED_sample/keymap.c index ad32269c80..9553309f89 100644 --- a/keyboards/lets_split/keymaps/OLED_sample/keymap.c +++ b/keyboards/lets_split/keymaps/OLED_sample/keymap.c @@ -358,6 +358,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) return MACRO_NONE; } + void matrix_update(struct CharacterMatrix *dest, const struct CharacterMatrix *source) { if (memcmp(dest->display, source->display, sizeof(dest->display))) { @@ -366,6 +367,17 @@ void matrix_update(struct CharacterMatrix *dest, } } +//assign the right code to your layers for OLED display +#define L_BASE 0 +#define L_LOWER 8 +#define L_RAISE 16 +#define L_FNLAYER 64 +#define L_NUMLAY 128 +#define L_NLOWER 136 +#define L_NFNLAYER 192 +#define L_MOUSECURSOR 256 +#define L_ADJUST 65560 + void iota_gfx_task_user(void) { #if DEBUG_TO_SCREEN if (debug_enable) { @@ -408,18 +420,16 @@ void iota_gfx_task_user(void) { snprintf(buf,sizeof(buf), "Undef-%ld", layer_state); matrix_write_P(&matrix, PSTR("\n\nLayer: ")); switch (layer_state) { - case _QWERTY: - case _COLEMAK: - case _DVORAK: + case L_BASE: matrix_write_P(&matrix, PSTR("Default")); break; - case _RAISE: + case L_RAISE: matrix_write_P(&matrix, PSTR("Raise")); break; - case _LOWER: + case L_LOWER: matrix_write_P(&matrix, PSTR("Lower")); break; - case _ADJUST: + case L_ADJUST: matrix_write_P(&matrix, PSTR("ADJUST")); break; default: |