summaryrefslogtreecommitdiff
path: root/keyboards/cannonkeys/satisfaction75
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2021-10-09 14:46:47 +0100
committerGitHub <noreply@github.com>2021-10-09 14:46:47 +0100
commit22cafb9a2046b0c6c7b9df8c719cd515bec4d798 (patch)
tree618cb30bbcbe098f8baed4fb11a7ea4952cdc58a /keyboards/cannonkeys/satisfaction75
parent7b753f227ada4c44df1e991b79e03fd6b56f7e69 (diff)
Migrate satisfaction75 away from QWIIC_DRIVERS (#14747)
* stash * refactor old draw * refactor old draw - tidy * refactor old draw - tidy * refactor old draw - reorder for diffs * refactor old draw - reorder for diffs
Diffstat (limited to 'keyboards/cannonkeys/satisfaction75')
-rw-r--r--keyboards/cannonkeys/satisfaction75/config.h10
-rw-r--r--keyboards/cannonkeys/satisfaction75/rules.mk5
-rw-r--r--keyboards/cannonkeys/satisfaction75/satisfaction75.c33
-rw-r--r--keyboards/cannonkeys/satisfaction75/satisfaction75.h11
-rw-r--r--keyboards/cannonkeys/satisfaction75/satisfaction_encoder.c2
-rw-r--r--keyboards/cannonkeys/satisfaction75/satisfaction_oled.c424
6 files changed, 186 insertions, 299 deletions
diff --git a/keyboards/cannonkeys/satisfaction75/config.h b/keyboards/cannonkeys/satisfaction75/config.h
index 43a872041c..7fca7226b1 100644
--- a/keyboards/cannonkeys/satisfaction75/config.h
+++ b/keyboards/cannonkeys/satisfaction75/config.h
@@ -71,14 +71,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Locking resynchronize hack */
#define LOCKING_RESYNC_ENABLE
-#ifdef QWIIC_MICRO_OLED_ENABLE
-
-#undef I2C_ADDRESS_SA0_1
-#define I2C_ADDRESS_SA0_1 0b0111100
-#define LCDWIDTH 128
-#define LCDHEIGHT 32
-
-#endif
+// configure oled driver for the 128x32 oled
+#define OLED_UPDATE_INTERVAL 66 // ~15fps
// Custom config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
diff --git a/keyboards/cannonkeys/satisfaction75/rules.mk b/keyboards/cannonkeys/satisfaction75/rules.mk
index 3f0f8cda7c..51f1dc52f5 100644
--- a/keyboards/cannonkeys/satisfaction75/rules.mk
+++ b/keyboards/cannonkeys/satisfaction75/rules.mk
@@ -23,10 +23,9 @@ CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = yes # Commands for debug and configuration
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
NKRO_ENABLE = yes # USB Nkey Rollover
-CUSTOM_MATRIX = no # Custom matrix file
ENCODER_ENABLE = yes
-QWIIC_ENABLE = yes
-QWIIC_DRIVERS += MICRO_OLED
+OLED_ENABLE = yes
+OLED_DRIVER = SSD1306
#BACKLIGHT_ENABLE = yes
DEFAULT_FOLDER = cannonkeys/satisfaction75/rev1
diff --git a/keyboards/cannonkeys/satisfaction75/satisfaction75.c b/keyboards/cannonkeys/satisfaction75/satisfaction75.c
index 682805f321..304df33258 100644
--- a/keyboards/cannonkeys/satisfaction75/satisfaction75.c
+++ b/keyboards/cannonkeys/satisfaction75/satisfaction75.c
@@ -5,11 +5,6 @@
#include <ch.h>
#include <hal.h>
-#ifdef QWIIC_MICRO_OLED_ENABLE
-#include "micro_oled.h"
-#include "qwiic.h"
-#endif
-
#include "timer.h"
#include "raw_hid.h"
@@ -20,18 +15,14 @@
/* Artificial delay added to get media keys to work in the encoder*/
#define MEDIA_KEY_DELAY 10
-uint16_t last_flush;
-
volatile uint8_t led_numlock = false;
volatile uint8_t led_capslock = false;
volatile uint8_t led_scrolllock = false;
uint8_t layer;
-bool queue_for_send = false;
bool clock_set_mode = false;
uint8_t oled_mode = OLED_DEFAULT;
-bool oled_sleeping = false;
uint8_t encoder_value = 32;
uint8_t encoder_mode = ENC_MODE_VOLUME;
@@ -167,7 +158,6 @@ void raw_hid_receive_kb( uint8_t *data, uint8_t length )
case id_oled_mode:
{
oled_mode = command_data[1];
- draw_ui();
break;
}
case id_encoder_modes:
@@ -247,18 +237,15 @@ void read_host_led_state(void) {
layer_state_t layer_state_set_kb(layer_state_t state) {
state = layer_state_set_user(state);
layer = biton32(state);
- queue_for_send = true;
return state;
}
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
- queue_for_send = true;
switch (keycode) {
case OLED_TOGG:
if(!clock_set_mode){
if (record->event.pressed) {
oled_mode = (oled_mode + 1) % _NUM_OLED_MODES;
- draw_ui();
}
}
return false;
@@ -303,7 +290,6 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
bool encoder_update_kb(uint8_t index, bool clockwise) {
if (!encoder_update_user(index, clockwise)) return false;
encoder_value = (encoder_value + (clockwise ? 1 : -1)) % 64;
- queue_for_send = true;
if (index == 0) {
if (layer == 0){
uint16_t mapped_code = 0;
@@ -376,7 +362,6 @@ void matrix_init_kb(void)
#endif // VIA_ENABLE
rtcGetTime(&RTCD1, &last_timespec);
- queue_for_send = true;
backlight_init_ports();
matrix_init_user();
}
@@ -388,22 +373,14 @@ void housekeeping_task_kb(void) {
if (minutes_since_midnight != last_minute){
last_minute = minutes_since_midnight;
- if(!oled_sleeping){
- queue_for_send = true;
- }
}
-#ifdef QWIIC_MICRO_OLED_ENABLE
- if (queue_for_send && oled_mode != OLED_OFF) {
- oled_sleeping = false;
- read_host_led_state();
- draw_ui();
- queue_for_send = false;
+
+ if((oled_mode == OLED_OFF) && is_oled_on()){
+ oled_off();
}
- if (timer_elapsed(last_flush) > ScreenOffInterval && !oled_sleeping) {
- send_command(DISPLAYOFF); /* 0xAE */
- oled_sleeping = true;
+ if((oled_mode != OLED_OFF) && !is_oled_on()){
+ oled_on();
}
-#endif
}
//
diff --git a/keyboards/cannonkeys/satisfaction75/satisfaction75.h b/keyboards/cannonkeys/satisfaction75/satisfaction75.h
index 13aaf68882..9d20dd9c93 100644
--- a/keyboards/cannonkeys/satisfaction75/satisfaction75.h
+++ b/keyboards/cannonkeys/satisfaction75/satisfaction75.h
@@ -14,9 +14,6 @@
#define EEPROM_DEFAULT_OLED (VIA_EEPROM_CUSTOM_CONFIG_ADDR+2)
#define EEPROM_CUSTOM_ENCODER (VIA_EEPROM_CUSTOM_CONFIG_ADDR+3)
-/* screen off after this many milliseconds */
-#define ScreenOffInterval 60000 /* milliseconds */
-
typedef union {
uint8_t raw;
struct {
@@ -74,10 +71,7 @@ extern volatile uint8_t led_scrolllock;
extern uint8_t layer;
// OLED Behavior
-extern uint16_t last_flush;
-extern bool queue_for_send;
extern uint8_t oled_mode;
-extern bool oled_sleeping;
// Encoder Behavior
extern uint8_t encoder_value;
@@ -113,11 +107,6 @@ void set_custom_encoder_config(uint8_t encoder_idx, uint8_t behavior, uint16_t n
void update_time_config(int8_t increment);
-__attribute__ ((weak))
-void draw_ui(void);
-void draw_default(void);
-void draw_clock(void);
-
void backlight_init_ports(void);
void backlight_set(uint8_t level);
bool is_breathing(void);
diff --git a/keyboards/cannonkeys/satisfaction75/satisfaction_encoder.c b/keyboards/cannonkeys/satisfaction75/satisfaction_encoder.c
index 8fcd720e2f..cefdbc5f9c 100644
--- a/keyboards/cannonkeys/satisfaction75/satisfaction_encoder.c
+++ b/keyboards/cannonkeys/satisfaction75/satisfaction_encoder.c
@@ -125,7 +125,6 @@ uint16_t handle_encoder_clockwise(){
#endif
case ENC_MODE_CLOCK_SET:
update_time_config(1);
- queue_for_send = true;
break;
}
return mapped_code;
@@ -171,7 +170,6 @@ uint16_t handle_encoder_ccw(){
case ENC_MODE_CLOCK_SET:
update_time_config(-1);
- queue_for_send = true;
break;
}
return mapped_code;
diff --git a/keyboards/cannonkeys/satisfaction75/satisfaction_oled.c b/keyboards/cannonkeys/satisfaction75/satisfaction_oled.c
index 6553bd1300..9589ecea86 100644
--- a/keyboards/cannonkeys/satisfaction75/satisfaction_oled.c
+++ b/keyboards/cannonkeys/satisfaction75/satisfaction_oled.c
@@ -1,271 +1,201 @@
#include "satisfaction75.h"
-#include "micro_oled.h"
-
-__attribute__ ((weak))
-void draw_ui() {
-#ifdef QWIIC_MICRO_OLED_ENABLE
- clear_buffer();
- last_flush = timer_read();
- send_command(DISPLAYON);
- if(clock_set_mode){
- draw_clock();
- return;
- }
- switch (oled_mode){
- default:
- case OLED_DEFAULT:
- draw_default();
- break;
- case OLED_TIME:
- draw_clock();
- break;
- case OLED_OFF:
- send_command(DISPLAYOFF);
- break;
- }
-#endif
+
+void draw_default(void);
+void draw_clock(void);
+
+#ifdef OLED_ENABLE
+
+__attribute__((weak)) oled_rotation_t oled_init_user(oled_rotation_t rotation) { return OLED_ROTATION_0; }
+
+__attribute__((weak)) void oled_task_user(void) {
+ if (!is_oled_on()) {
+ return;
+ }
+ oled_clear();
+ if (clock_set_mode) {
+ draw_clock();
+ return;
+ }
+ switch (oled_mode) {
+ default:
+ case OLED_DEFAULT:
+ draw_default();
+ break;
+ case OLED_TIME:
+ draw_clock();
+ break;
+ }
}
-void draw_encoder(int8_t startX, int8_t startY, bool show_legend){
- if(show_legend){
- draw_string(startX + 1, startY + 2, "ENC", PIXEL_ON, NORM, 0);
- } else {
- startX -= 22;
- }
- draw_rect_filled_soft(startX + 22, startY + 1, 3 + (3 * 6), 9, PIXEL_ON, NORM);
- char* mode_string = "";
- switch(encoder_mode){
- default:
- case ENC_MODE_VOLUME:
- mode_string = "VOL";
- break;
- case ENC_MODE_MEDIA:
- mode_string = "MED";
- break;
- case ENC_MODE_SCROLL:
- mode_string = "SCR";
- break;
- case ENC_MODE_BRIGHTNESS:
- mode_string = "BRT";
- break;
- case ENC_MODE_BACKLIGHT:
- mode_string = "BKL";
- break;
- case ENC_MODE_CLOCK_SET:
- mode_string = "CLK";
- break;
- case ENC_MODE_CUSTOM0:
- mode_string = "CS0";
- break;
- case ENC_MODE_CUSTOM1:
- mode_string = "CS1";
- break;
- case ENC_MODE_CUSTOM2:
- mode_string = "CS2";
- break;
- }
- draw_string(startX + 24, startY + 2, mode_string, PIXEL_ON, XOR, 0);
+
+static void draw_line_h(uint8_t x, uint8_t y, uint8_t len) {
+ for (uint8_t i = 0; i < len; i++) {
+ oled_write_pixel(i + x, y, true);
+ }
}
-void draw_layer_section(int8_t startX, int8_t startY, bool show_legend){
- if(show_legend){
- draw_string(startX + 1, startY + 2, "LAYER", PIXEL_ON, NORM, 0);
- } else {
- startX -= 32;
- }
- draw_rect_filled_soft(startX + 32, startY + 1, 9, 9, PIXEL_ON, NORM);
- draw_char(startX + 34, startY + 2, layer + 0x30, PIXEL_ON, XOR, 0);
+static void draw_line_v(uint8_t x, uint8_t y, uint8_t len) {
+ for (uint8_t i = 0; i < len; i++) {
+ oled_write_pixel(x, i + y, true);
+ }
}
-void draw_default(){
- uint8_t hour = last_minute / 60;
- uint16_t minute = last_minute % 60;
+static char* get_enc_mode(void) {
+ switch (encoder_mode) {
+ default:
+ case ENC_MODE_VOLUME:
+ return "VOL";
+ case ENC_MODE_MEDIA:
+ return "MED";
+ case ENC_MODE_SCROLL:
+ return "SCR";
+ case ENC_MODE_BRIGHTNESS:
+ return "BRT";
+ case ENC_MODE_BACKLIGHT:
+ return "BKL";
+ case ENC_MODE_CLOCK_SET:
+ return "CLK";
+ case ENC_MODE_CUSTOM0:
+ return "CS0";
+ case ENC_MODE_CUSTOM1:
+ return "CS1";
+ case ENC_MODE_CUSTOM2:
+ return "CS2";
+ }
+}
- if(encoder_mode == ENC_MODE_CLOCK_SET){
- hour = hour_config;
- minute = minute_config;
- }
+static char* get_time(void) {
+ uint8_t hour = last_minute / 60;
+ uint16_t minute = last_minute % 60;
- bool is_pm = (hour / 12) > 0;
- hour = hour % 12;
- if (hour == 0){
- hour = 12;
- }
- char hour_str[3] = "";
- char min_str[3] = "";
+ if (encoder_mode == ENC_MODE_CLOCK_SET) {
+ hour = hour_config;
+ minute = minute_config;
+ }
- sprintf(hour_str, "%02d", hour);
- sprintf(min_str, "%02d", minute);
+ bool is_pm = (hour / 12) > 0;
+ hour = hour % 12;
+ if (hour == 0) {
+ hour = 12;
+ }
- uint8_t mods = get_mods();
+ static char time_str[8] = "";
+ sprintf(time_str, "%02d:%02d%s", hour, minute, is_pm ? "pm" : "am");
-/* Layer indicator is 41 x 10 pixels */
- draw_layer_section(0,0,true);
+ return time_str;
+}
-#define ENCODER_INDICATOR_X 45
-#define ENCODER_INDICATOR_Y 0
- draw_encoder(ENCODER_INDICATOR_X, ENCODER_INDICATOR_Y, true);
-/* Matrix display is 19 x 9 pixels */
-#define MATRIX_DISPLAY_X 0
-#define MATRIX_DISPLAY_Y 18
+static char* get_date(void) {
+ int16_t year = last_timespec.year + 1980;
+ int8_t month = last_timespec.month;
+ int8_t day = last_timespec.day;
- for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
- for (uint8_t y = 0; y < MATRIX_COLS; y++) {
- draw_pixel(MATRIX_DISPLAY_X + y + 2, MATRIX_DISPLAY_Y + x + 2,(matrix_get_row(x) & (1 << y)) > 0, NORM);
+ if (encoder_mode == ENC_MODE_CLOCK_SET) {
+ year = year_config + 1980;
+ month = month_config;
+ day = day_config;
}
- }
- draw_rect_soft(MATRIX_DISPLAY_X, MATRIX_DISPLAY_Y, 19, 9, PIXEL_ON, NORM);
- /* hadron oled location on thumbnail */
- draw_rect_filled_soft(MATRIX_DISPLAY_X + 14, MATRIX_DISPLAY_Y + 2, 3, 1, PIXEL_ON, NORM);
-
-/* Mod display is 41 x 16 pixels */
-#define MOD_DISPLAY_X 30
-#define MOD_DISPLAY_Y 18
-
- if (mods & MOD_LSFT) {
- draw_rect_filled_soft(MOD_DISPLAY_X + 0, MOD_DISPLAY_Y, 5 + (1 * 6), 11, PIXEL_ON, NORM);
- draw_string(MOD_DISPLAY_X + 3, MOD_DISPLAY_Y + 2, "S", PIXEL_OFF, NORM, 0);
- } else {
- draw_string(MOD_DISPLAY_X + 3, MOD_DISPLAY_Y + 2, "S", PIXEL_ON, NORM, 0);
- }
- if (mods & MOD_LCTL) {
- draw_rect_filled_soft(MOD_DISPLAY_X + 10, MOD_DISPLAY_Y, 5 + (1 * 6), 11, PIXEL_ON, NORM);
- draw_string(MOD_DISPLAY_X + 13, MOD_DISPLAY_Y + 2, "C", PIXEL_OFF, NORM, 0);
- } else {
- draw_string(MOD_DISPLAY_X + 13, MOD_DISPLAY_Y + 2, "C", PIXEL_ON, NORM, 0);
- }
- if (mods & MOD_LALT) {
- draw_rect_filled_soft(MOD_DISPLAY_X + 20, MOD_DISPLAY_Y, 5 + (1 * 6), 11, PIXEL_ON, NORM);
- draw_string(MOD_DISPLAY_X + 23, MOD_DISPLAY_Y + 2, "A", PIXEL_OFF, NORM, 0);
- } else {
- draw_string(MOD_DISPLAY_X + 23, MOD_DISPLAY_Y + 2, "A", PIXEL_ON, NORM, 0);
- }
- if (mods & MOD_LGUI) {
- draw_rect_filled_soft(MOD_DISPLAY_X + 30, MOD_DISPLAY_Y, 5 + (1 * 6), 11, PIXEL_ON, NORM);
- draw_string(MOD_DISPLAY_X + 33, MOD_DISPLAY_Y + 2, "G", PIXEL_OFF, NORM, 0);
- } else {
- draw_string(MOD_DISPLAY_X + 33, MOD_DISPLAY_Y + 2, "G", PIXEL_ON, NORM, 0);
- }
-
-/* Lock display is 23 x 21 */
-#define LOCK_DISPLAY_X 100
-#define LOCK_DISPLAY_Y 0
-
- if (led_capslock == true) {
- draw_rect_filled_soft(LOCK_DISPLAY_X + 0, LOCK_DISPLAY_Y, 5 + (3 * 6), 9, PIXEL_ON, NORM);
- draw_string(LOCK_DISPLAY_X + 3, LOCK_DISPLAY_Y +1, "CAP", PIXEL_OFF, NORM, 0);
- } else if (led_capslock == false) {
- draw_string(LOCK_DISPLAY_X + 3, LOCK_DISPLAY_Y +1, "CAP", PIXEL_ON, NORM, 0);
- }
-
- if (led_scrolllock == true) {
- draw_rect_filled_soft(LOCK_DISPLAY_X + 0, LOCK_DISPLAY_Y + 11, 5 + (3 * 6), 9, PIXEL_ON, NORM);
- draw_string(LOCK_DISPLAY_X + 3, LOCK_DISPLAY_Y + 11 +1, "SCR", PIXEL_OFF, NORM, 0);
- } else if (led_scrolllock == false) {
- draw_string(LOCK_DISPLAY_X + 3, LOCK_DISPLAY_Y + 11 +1, "SCR", PIXEL_ON, NORM, 0);
- }
-
-#define TIME_DISPLAY_X 82
-#define TIME_DISPLAY_Y 22
- draw_string(TIME_DISPLAY_X, TIME_DISPLAY_Y, hour_str, PIXEL_ON, NORM, 0);
- draw_string(TIME_DISPLAY_X + 11, TIME_DISPLAY_Y, ":", PIXEL_ON, NORM, 0);
- draw_string(TIME_DISPLAY_X + 15, TIME_DISPLAY_Y, min_str, PIXEL_ON, NORM, 0);
- if(is_pm){
- draw_string(TIME_DISPLAY_X + 27, TIME_DISPLAY_Y, "pm", PIXEL_ON, NORM, 0);
- } else{
- draw_string(TIME_DISPLAY_X + 27, TIME_DISPLAY_Y, "am", PIXEL_ON, NORM, 0);
- }
-
- send_buffer();
+
+ static char date_str[11] = "";
+ sprintf(date_str, "%04d-%02d-%02d", year, month, day);
+
+ return date_str;
}
-void draw_clock(){
- int8_t hour = last_minute / 60;
- int16_t minute = last_minute % 60;
- int16_t year = last_timespec.year + 1980;
- int8_t month = last_timespec.month;
- int8_t day = last_timespec.day;
-
- if(encoder_mode == ENC_MODE_CLOCK_SET){
- hour = hour_config;
- minute = minute_config;
- year = year_config + 1980;
- month = month_config;
- day = day_config;
- }
-
- bool is_pm = (hour / 12) > 0;
- hour = hour % 12;
- if (hour == 0){
- hour = 12;
- }
- char hour_str[3] = "";
- char min_str[3] = "";
- char year_str[5] = "";
- char month_str[3] = "";
- char day_str[3] = "";
-
- sprintf(hour_str, "%02d", hour);
- sprintf(min_str, "%02d", minute);
- sprintf(year_str, "%d", year);
- sprintf(month_str, "%02d", month);
- sprintf(day_str, "%02d", day);
-
-
-#define DATE_DISPLAY_X 6
-#define DATE_DISPLAY_Y 0
- draw_string(DATE_DISPLAY_X, DATE_DISPLAY_Y, year_str, PIXEL_ON, NORM, 0);
- draw_string(DATE_DISPLAY_X + 25, DATE_DISPLAY_Y, "-", PIXEL_ON, NORM, 0);
- draw_string(DATE_DISPLAY_X + 31, DATE_DISPLAY_Y, month_str, PIXEL_ON, NORM, 0);
- draw_string(DATE_DISPLAY_X + 44, DATE_DISPLAY_Y, "-", PIXEL_ON, NORM, 0);
- draw_string(DATE_DISPLAY_X + 50, DATE_DISPLAY_Y, day_str, PIXEL_ON, NORM, 0);
-
-#define CLOCK_DISPLAY_X 6
-#define CLOCK_DISPLAY_Y 14
- draw_string(CLOCK_DISPLAY_X, CLOCK_DISPLAY_Y, hour_str, PIXEL_ON, NORM, 1);
- draw_string(CLOCK_DISPLAY_X + 17, CLOCK_DISPLAY_Y, ":", PIXEL_ON, NORM, 1);
- draw_string(CLOCK_DISPLAY_X + 25, CLOCK_DISPLAY_Y, min_str, PIXEL_ON, NORM, 1);
- if(is_pm){
- draw_string(CLOCK_DISPLAY_X + 41, CLOCK_DISPLAY_Y, "pm", PIXEL_ON, NORM, 1);
- } else{
- draw_string(CLOCK_DISPLAY_X + 41, CLOCK_DISPLAY_Y, "am", PIXEL_ON, NORM, 1);
- }
-
- if(clock_set_mode){
- switch(time_config_idx){
- case 0: // hour
- default:
- draw_line(CLOCK_DISPLAY_X, CLOCK_DISPLAY_Y + 17, CLOCK_DISPLAY_X + 16, CLOCK_DISPLAY_Y + 17, PIXEL_ON, NORM);
- break;
- case 1: // minute
- draw_line(CLOCK_DISPLAY_X + 25, CLOCK_DISPLAY_Y + 17, CLOCK_DISPLAY_X + 41, CLOCK_DISPLAY_Y + 17, PIXEL_ON, NORM);
- break;
- case 2: // year
- draw_line(DATE_DISPLAY_X, DATE_DISPLAY_Y + 9, DATE_DISPLAY_X + 23, DATE_DISPLAY_Y + 9, PIXEL_ON, NORM);
- break;
- case 3: // month
- draw_line(DATE_DISPLAY_X + 31, DATE_DISPLAY_Y + 9, DATE_DISPLAY_X + 43, DATE_DISPLAY_Y + 9, PIXEL_ON, NORM);
- break;
- case 4: //day
- draw_line(DATE_DISPLAY_X + 50, DATE_DISPLAY_Y + 9, DATE_DISPLAY_X + 61, DATE_DISPLAY_Y + 9,PIXEL_ON, NORM);
- break;
- }
- }
+void draw_default() {
+ oled_write_P(PSTR("LAYER "), false);
+ oled_write_char(get_highest_layer(layer_state) + 0x30, true);
+
+ oled_write_P(PSTR(" ENC "), false);
+ oled_write(get_enc_mode(), true);
+
+ led_t led_state = host_keyboard_led_state();
+ oled_set_cursor(18, 0);
+ oled_write_P(PSTR("CAP"), led_state.caps_lock);
+ oled_set_cursor(18, 1);
+ oled_write_P(PSTR("SCR"), led_state.scroll_lock);
+
+ uint8_t mod_state = get_mods();
+ oled_set_cursor(6, 3);
+ oled_write_P(PSTR("S"), mod_state & MOD_MASK_SHIFT);
+ oled_advance_char();
+ oled_write_P(PSTR("C"), mod_state & MOD_MASK_CTRL);
+ oled_advance_char();
+ oled_write_P(PSTR("A"), mod_state & MOD_MASK_ALT);
+ oled_advance_char();
+ oled_write_P(PSTR("G"), mod_state & MOD_MASK_GUI);
+ oled_advance_char();
+
+ oled_write(get_time(), false);
+
+/* Matrix display is 12 x 12 pixels */
+#define MATRIX_DISPLAY_X 0
+#define MATRIX_DISPLAY_Y 18
- draw_encoder(80, 0, true);
- draw_layer_section(80, 11, true);
+ // matrix
+ for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
+ for (uint8_t y = 0; y < MATRIX_COLS; y++) {
+ bool on = (matrix_get_row(x) & (1 << y)) > 0;
+ oled_write_pixel(MATRIX_DISPLAY_X + y + 2, MATRIX_DISPLAY_Y + x + 2, on);
+ }
+ }
-#define CAPS_DISPLAY_X 86
-#define CAPS_DISPLAY_Y 22
+ // outline
+ draw_line_h(MATRIX_DISPLAY_X, MATRIX_DISPLAY_Y, 19);
+ draw_line_h(MATRIX_DISPLAY_X, MATRIX_DISPLAY_Y + 9, 19);
+ draw_line_v(MATRIX_DISPLAY_X, MATRIX_DISPLAY_Y, 9);
+ draw_line_v(MATRIX_DISPLAY_X + 19, MATRIX_DISPLAY_Y, 9);
- if (led_capslock == true) {
- draw_rect_filled_soft(CAPS_DISPLAY_X, CAPS_DISPLAY_Y, 5 + (4 * 6), 9, PIXEL_ON, NORM);
- draw_string(CAPS_DISPLAY_X + 3, CAPS_DISPLAY_Y +1, "CAPS", PIXEL_OFF, NORM, 0);
- } else if (led_capslock == false) {
- draw_string(CAPS_DISPLAY_X + 3, CAPS_DISPLAY_Y +1, "CAPS", PIXEL_ON, NORM, 0);
- }
+ // oled location
+ draw_line_h(MATRIX_DISPLAY_X + 14, MATRIX_DISPLAY_Y + 2, 3);
+ // bodge extra lines for invert layer and enc mode
+ draw_line_v(35, 0, 8);
+ draw_line_v(71, 0, 8);
+}
- send_buffer();
+void draw_clock() {
+ oled_set_cursor(0, 0);
+ oled_write(get_date(), false);
+ oled_set_cursor(0, 2);
+ oled_write(get_time(), false);
+
+ oled_set_cursor(12, 0);
+ oled_write_P(PSTR(" ENC "), false);
+ oled_write(get_enc_mode(), true);
+
+ oled_set_cursor(13, 1);
+ oled_write_P(PSTR("LAYER "), false);
+ oled_write_char(get_highest_layer(layer_state) + 0x30, true);
+
+ led_t led_state = host_keyboard_led_state();
+ oled_set_cursor(15, 3);
+ oled_write_P(PSTR("CAPS"), led_state.caps_lock);
+
+ if (clock_set_mode) {
+ switch (time_config_idx) {
+ case 0: // hour
+ default:
+ draw_line_h(0, 25, 10);
+ break;
+ case 1: // minute
+ draw_line_h(18, 25, 10);
+ break;
+ case 2: // year
+ draw_line_h(0, 9, 24);
+ break;
+ case 3: // month
+ draw_line_h(30, 9, 10);
+ break;
+ case 4: // day
+ draw_line_h(48, 9, 10);
+ break;
+ }
+ }
+ // bodge extra lines for invert layer and enc mode
+ draw_line_v(101, 0, 8);
+ draw_line_v(113, 8, 8);
}
+
+#endif