diff options
Diffstat (limited to 'keyboards/cannonkeys')
25 files changed, 289 insertions, 322 deletions
diff --git a/keyboards/cannonkeys/aella/rules.mk b/keyboards/cannonkeys/aella/rules.mk index e5bf1ef881..e3c94c282c 100644 --- a/keyboards/cannonkeys/aella/rules.mk +++ b/keyboards/cannonkeys/aella/rules.mk @@ -10,7 +10,7 @@ DFU_SUFFIX_ARGS = -v FFFF -p FFFF # Build Options # change yes to no to disable # -BOOTMAGIC_ENABLE = lite # Enable Bootmagic Lite +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite MOUSEKEY_ENABLE = yes # Mouse keys EXTRAKEY_ENABLE = yes # Audio control and System control CONSOLE_ENABLE = yes # Console for debug diff --git a/keyboards/cannonkeys/an_c/rules.mk b/keyboards/cannonkeys/an_c/rules.mk index 66e6b65776..1c8a0a4e14 100644 --- a/keyboards/cannonkeys/an_c/rules.mk +++ b/keyboards/cannonkeys/an_c/rules.mk @@ -12,7 +12,7 @@ DFU_SUFFIX_ARGS = -v FFFF -p FFFF # -BOOTMAGIC_ENABLE = lite # Enable Bootmagic Lite +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite MOUSEKEY_ENABLE = yes # Mouse keys EXTRAKEY_ENABLE = yes # Audio control and System control CONSOLE_ENABLE = yes # Console for debug diff --git a/keyboards/cannonkeys/atlas/rules.mk b/keyboards/cannonkeys/atlas/rules.mk index ee32cf30bd..a2519aa035 100644 --- a/keyboards/cannonkeys/atlas/rules.mk +++ b/keyboards/cannonkeys/atlas/rules.mk @@ -6,7 +6,7 @@ BOOTLOADER = stm32-dfu # Build Options # comment out to disable the options. -BOOTMAGIC_ENABLE = lite # Enable Bootmagic Lite +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite MOUSEKEY_ENABLE = yes # Mouse keys EXTRAKEY_ENABLE = yes # Audio control and System control CONSOLE_ENABLE = yes # Console for debug diff --git a/keyboards/cannonkeys/atlas_alps/rules.mk b/keyboards/cannonkeys/atlas_alps/rules.mk index 375db3aede..f9a0f9be2f 100644 --- a/keyboards/cannonkeys/atlas_alps/rules.mk +++ b/keyboards/cannonkeys/atlas_alps/rules.mk @@ -7,7 +7,7 @@ BOOTLOADER = atmel-dfu # Build Options # change yes to no to disable # -BOOTMAGIC_ENABLE = lite # Enable Bootmagic Lite +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite MOUSEKEY_ENABLE = yes # Mouse keys EXTRAKEY_ENABLE = yes # Audio control and System control CONSOLE_ENABLE = no # Console for debug diff --git a/keyboards/cannonkeys/balance/rules.mk b/keyboards/cannonkeys/balance/rules.mk index 2cd1e23fa9..6f2ef2794e 100644 --- a/keyboards/cannonkeys/balance/rules.mk +++ b/keyboards/cannonkeys/balance/rules.mk @@ -10,7 +10,7 @@ DFU_SUFFIX_ARGS = -p FFFF -v FFFF # Build Options # change yes to no to disable # -BOOTMAGIC_ENABLE = lite # Enable Bootmagic Lite +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite MOUSEKEY_ENABLE = yes # Mouse keys EXTRAKEY_ENABLE = yes # Audio control and System control CONSOLE_ENABLE = yes # Console for debug diff --git a/keyboards/cannonkeys/chimera65/rules.mk b/keyboards/cannonkeys/chimera65/rules.mk index 9c680a29b0..a1d2c6675f 100644 --- a/keyboards/cannonkeys/chimera65/rules.mk +++ b/keyboards/cannonkeys/chimera65/rules.mk @@ -9,7 +9,7 @@ BOOTLOADER = stm32-dfu # -BOOTMAGIC_ENABLE = lite # Enable Bootmagic Lite +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite MOUSEKEY_ENABLE = yes # Mouse keys EXTRAKEY_ENABLE = yes # Audio control and System control CONSOLE_ENABLE = yes # Console for debug diff --git a/keyboards/cannonkeys/db60/rules.mk b/keyboards/cannonkeys/db60/rules.mk index be4c05831b..43e9d6c998 100644 --- a/keyboards/cannonkeys/db60/rules.mk +++ b/keyboards/cannonkeys/db60/rules.mk @@ -10,7 +10,7 @@ DFU_SUFFIX_ARGS = -v FFFF -p FFFF # Build Options # comment out to disable the options. # -BOOTMAGIC_ENABLE = lite # Enable Bootmagic Lite +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite MOUSEKEY_ENABLE = yes # Mouse keys EXTRAKEY_ENABLE = yes # Audio control and System control CONSOLE_ENABLE = yes # Console for debug diff --git a/keyboards/cannonkeys/devastatingtkl/rules.mk b/keyboards/cannonkeys/devastatingtkl/rules.mk index 1a11e0a892..8c80d472c0 100644 --- a/keyboards/cannonkeys/devastatingtkl/rules.mk +++ b/keyboards/cannonkeys/devastatingtkl/rules.mk @@ -10,7 +10,7 @@ DFU_SUFFIX_ARGS = -v FFFF -p FFFF # Build Options # comment out to disable the options. # -BOOTMAGIC_ENABLE = lite # Enable Bootmagic Lite +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite MOUSEKEY_ENABLE = yes # Mouse keys EXTRAKEY_ENABLE = yes # Audio control and System control CONSOLE_ENABLE = yes # Console for debug diff --git a/keyboards/cannonkeys/instant60/rules.mk b/keyboards/cannonkeys/instant60/rules.mk index e483bb0722..8c2b499dfd 100644 --- a/keyboards/cannonkeys/instant60/rules.mk +++ b/keyboards/cannonkeys/instant60/rules.mk @@ -11,7 +11,7 @@ DFU_SUFFIX_ARGS = -v FFFF -p FFFF # comment out to disable the options. # -BOOTMAGIC_ENABLE = lite # Enable Bootmagic Lite +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite MOUSEKEY_ENABLE = yes # Mouse keys EXTRAKEY_ENABLE = yes # Audio control and System control CONSOLE_ENABLE = yes # Console for debug diff --git a/keyboards/cannonkeys/instant65/rules.mk b/keyboards/cannonkeys/instant65/rules.mk index aa0b3116a9..1f61cca45f 100644 --- a/keyboards/cannonkeys/instant65/rules.mk +++ b/keyboards/cannonkeys/instant65/rules.mk @@ -10,7 +10,7 @@ DFU_SUFFIX_ARGS = -v FFFF -p FFFF # Build Options # change yes to no to disable # -BOOTMAGIC_ENABLE = lite # Enable Bootmagic Lite +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite MOUSEKEY_ENABLE = yes # Mouse keys EXTRAKEY_ENABLE = yes # Audio control and System control CONSOLE_ENABLE = yes # Console for debug diff --git a/keyboards/cannonkeys/iron165/rules.mk b/keyboards/cannonkeys/iron165/rules.mk index 641a6c14da..e159c6ae82 100644 --- a/keyboards/cannonkeys/iron165/rules.mk +++ b/keyboards/cannonkeys/iron165/rules.mk @@ -7,7 +7,7 @@ BOOTLOADER = stm32-dfu # Build Options # comment out to disable the options. # -BOOTMAGIC_ENABLE = lite # Enable Bootmagic Lite +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite MOUSEKEY_ENABLE = yes # Mouse keys EXTRAKEY_ENABLE = yes # Audio control and System control CONSOLE_ENABLE = yes # Console for debug diff --git a/keyboards/cannonkeys/obliterated75/rules.mk b/keyboards/cannonkeys/obliterated75/rules.mk index 60b6bc58de..0f8ad7cadc 100644 --- a/keyboards/cannonkeys/obliterated75/rules.mk +++ b/keyboards/cannonkeys/obliterated75/rules.mk @@ -10,7 +10,7 @@ DFU_SUFFIX_ARGS = -v FFFF -p FFFF # Build Options # change yes to no to disable # -BOOTMAGIC_ENABLE = lite # Enable Bootmagic Lite +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite MOUSEKEY_ENABLE = yes # Mouse keys EXTRAKEY_ENABLE = yes # Audio control and System control CONSOLE_ENABLE = yes # Console for debug diff --git a/keyboards/cannonkeys/onyx/rules.mk b/keyboards/cannonkeys/onyx/rules.mk index 26b4fab43e..cfa8daced4 100644 --- a/keyboards/cannonkeys/onyx/rules.mk +++ b/keyboards/cannonkeys/onyx/rules.mk @@ -10,7 +10,7 @@ DFU_SUFFIX_ARGS = -v FFFF -p FFFF # Build Options # change yes to no to disable # -BOOTMAGIC_ENABLE = lite # Enable Bootmagic Lite +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite MOUSEKEY_ENABLE = yes # Mouse keys EXTRAKEY_ENABLE = yes # Audio control and System control CONSOLE_ENABLE = yes # Console for debug diff --git a/keyboards/cannonkeys/rekt1800/rules.mk b/keyboards/cannonkeys/rekt1800/rules.mk index 962b9dcf40..928e8d5171 100644 --- a/keyboards/cannonkeys/rekt1800/rules.mk +++ b/keyboards/cannonkeys/rekt1800/rules.mk @@ -10,7 +10,7 @@ DFU_SUFFIX_ARGS = -v FFFF -p FFFF # Build Options # comment out to disable the options. # -BOOTMAGIC_ENABLE = lite # Enable Bootmagic Lite +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite MOUSEKEY_ENABLE = yes # Mouse keys EXTRAKEY_ENABLE = yes # Audio control and System control CONSOLE_ENABLE = yes # Console for debug diff --git a/keyboards/cannonkeys/sagittarius/rules.mk b/keyboards/cannonkeys/sagittarius/rules.mk index 4abdb98945..2aed2c9a1a 100644 --- a/keyboards/cannonkeys/sagittarius/rules.mk +++ b/keyboards/cannonkeys/sagittarius/rules.mk @@ -10,7 +10,7 @@ DFU_SUFFIX_ARGS = -v FFFF -p FFFF # Build Options # change yes to no to disable # -BOOTMAGIC_ENABLE = lite # Enable Bootmagic Lite +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite MOUSEKEY_ENABLE = yes # Mouse keys EXTRAKEY_ENABLE = yes # Audio control and System control CONSOLE_ENABLE = yes # Console for debug diff --git a/keyboards/cannonkeys/satisfaction75/config.h b/keyboards/cannonkeys/satisfaction75/config.h index e100cc99b1..53e4c18e5e 100644 --- a/keyboards/cannonkeys/satisfaction75/config.h +++ b/keyboards/cannonkeys/satisfaction75/config.h @@ -53,9 +53,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. // I2C config #define I2C_DRIVER I2CD1 -#define I2C1_SCL_BANK GPIOB -#define I2C1_SCL 6 -#define I2C1_SDA 7 +#define I2C1_SCL_PIN B6 +#define I2C1_SDA_PIN B7 #define I2C1_SCL_PAL_MODE 1 #define I2C1_SDA_PAL_MODE 1 #define I2C1_TIMINGR_PRESC 0x00U @@ -72,14 +71,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. /* Locking resynchronize hack */ #define LOCKING_RESYNC_ENABLE -#ifdef QWIIC_MICRO_OLED_ENABLE +// configure oled driver for the 128x32 oled +#define OLED_UPDATE_INTERVAL 66 // ~15fps -#undef I2C_ADDRESS_SA0_1 -#define I2C_ADDRESS_SA0_1 0b0111100 -#define LCDWIDTH 128 -#define LCDHEIGHT 32 +// OLED_TIMEOUT is incompatible with the OLED_OFF mode +#define OLED_TIMEOUT 0 -#endif +// OLED timeout reimplemented in the keyboard-specific code +#define CUSTOM_OLED_TIMEOUT 60000 // 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..b74a4b35cd 100644 --- a/keyboards/cannonkeys/satisfaction75/rules.mk +++ b/keyboards/cannonkeys/satisfaction75/rules.mk @@ -16,17 +16,16 @@ SRC += led.c \ satisfaction_encoder.c \ satisfaction_oled.c -BOOTMAGIC_ENABLE = lite # Enable Bootmagic Lite +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite MOUSEKEY_ENABLE = yes # Mouse keys EXTRAKEY_ENABLE = yes # Audio control and System control 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..bd7eaf1885 100644 --- a/keyboards/cannonkeys/satisfaction75/satisfaction75.c +++ b/keyboards/cannonkeys/satisfaction75/satisfaction75.c @@ -5,33 +5,27 @@ #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" #include "dynamic_keymap.h" -#include "tmk_core/common/eeprom.h" +#include "eeprom.h" #include "version.h" // for QMK_BUILDDATE used in EEPROM magic /* 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; +bool oled_repaint_requested = false; +bool oled_wakeup_requested = false; +uint32_t oled_sleep_timer; uint8_t encoder_value = 32; uint8_t encoder_mode = ENC_MODE_VOLUME; @@ -167,7 +161,7 @@ void raw_hid_receive_kb( uint8_t *data, uint8_t length ) case id_oled_mode: { oled_mode = command_data[1]; - draw_ui(); + oled_request_wakeup(); break; } case id_encoder_modes: @@ -247,18 +241,17 @@ 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; + oled_request_wakeup(); return state; } bool process_record_kb(uint16_t keycode, keyrecord_t *record) { - queue_for_send = true; + oled_request_wakeup(); 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; @@ -302,8 +295,8 @@ 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; + oled_request_wakeup(); encoder_value = (encoder_value + (clockwise ? 1 : -1)) % 64; - queue_for_send = true; if (index == 0) { if (layer == 0){ uint16_t mapped_code = 0; @@ -376,9 +369,9 @@ void matrix_init_kb(void) #endif // VIA_ENABLE rtcGetTime(&RTCD1, &last_timespec); - queue_for_send = true; backlight_init_ports(); matrix_init_user(); + oled_request_wakeup(); } @@ -388,22 +381,8 @@ void housekeeping_task_kb(void) { if (minutes_since_midnight != last_minute){ last_minute = minutes_since_midnight; - if(!oled_sleeping){ - queue_for_send = true; - } + oled_request_repaint(); } -#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 (timer_elapsed(last_flush) > ScreenOffInterval && !oled_sleeping) { - send_command(DISPLAYOFF); /* 0xAE */ - oled_sleeping = true; - } -#endif } // diff --git a/keyboards/cannonkeys/satisfaction75/satisfaction75.h b/keyboards/cannonkeys/satisfaction75/satisfaction75.h index 13aaf68882..c6dbc31f1b 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,10 @@ 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; +extern bool oled_repaint_requested; +extern bool oled_wakeup_requested; +extern uint32_t oled_sleep_timer; // Encoder Behavior extern uint8_t encoder_value; @@ -113,10 +110,9 @@ 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 oled_request_wakeup(void); +void oled_request_repaint(void); +bool oled_task_needs_to_repaint(void); void backlight_init_ports(void); void backlight_set(uint8_t level); diff --git a/keyboards/cannonkeys/satisfaction75/satisfaction_encoder.c b/keyboards/cannonkeys/satisfaction75/satisfaction_encoder.c index 8fcd720e2f..0d2fdc359c 100644 --- a/keyboards/cannonkeys/satisfaction75/satisfaction_encoder.c +++ b/keyboards/cannonkeys/satisfaction75/satisfaction_encoder.c @@ -1,5 +1,5 @@ #include "satisfaction75.h" -#include "tmk_core/common/eeprom.h" +#include "eeprom.h" void pre_encoder_mode_change(){ if(encoder_mode == ENC_MODE_CLOCK_SET){ @@ -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..fff8b65bd7 100644 --- a/keyboards/cannonkeys/satisfaction75/satisfaction_oled.c +++ b/keyboards/cannonkeys/satisfaction75/satisfaction_oled.c @@ -1,271 +1,267 @@ #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 + +oled_rotation_t oled_init_kb(oled_rotation_t rotation) { return OLED_ROTATION_0; } + +bool oled_task_kb(void) { + if (!oled_task_user()) { return false; } + if (!oled_task_needs_to_repaint()) { + return false; + } + oled_clear(); + if (clock_set_mode) { + draw_clock(); + return false;; + } + switch (oled_mode) { + default: + case OLED_DEFAULT: + draw_default(); + break; + case OLED_TIME: + draw_clock(); + break; + } + return false; } -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); +// Request a repaint of the OLED image without resetting the OLED sleep timer. +// Used for things like clock updates that should not keep the OLED turned on +// if there is no other activity. +void oled_request_repaint(void) { + if (is_oled_on()) { + oled_repaint_requested = 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); +// Request a repaint of the OLED image and reset the OLED sleep timer. +// Needs to be called after any activity that should keep the OLED turned on. +void oled_request_wakeup(void) { + oled_wakeup_requested = true; } -void draw_default(){ - uint8_t hour = last_minute / 60; - uint16_t minute = last_minute % 60; +// Check whether oled_task_user() needs to repaint the OLED image. This +// function should be called at the start of oled_task_user(); it also handles +// the OLED sleep timer and the OLED_OFF mode. +bool oled_task_needs_to_repaint(void) { + // In the OLED_OFF mode the OLED is kept turned off; any wakeup requests + // are ignored. + if ((oled_mode == OLED_OFF) && !clock_set_mode) { + oled_wakeup_requested = false; + oled_repaint_requested = false; + oled_off(); + return false; + } - if(encoder_mode == ENC_MODE_CLOCK_SET){ - hour = hour_config; - minute = minute_config; - } + // If OLED wakeup was requested, reset the sleep timer and do a repaint. + if (oled_wakeup_requested) { + oled_wakeup_requested = false; + oled_repaint_requested = false; + oled_sleep_timer = timer_read32() + CUSTOM_OLED_TIMEOUT; + oled_on(); + return true; + } - bool is_pm = (hour / 12) > 0; - hour = hour % 12; - if (hour == 0){ - hour = 12; - } - char hour_str[3] = ""; - char min_str[3] = ""; + // If OLED repaint was requested, just do a repaint without touching the + // sleep timer. + if (oled_repaint_requested) { + oled_repaint_requested = false; + return true; + } - sprintf(hour_str, "%02d", hour); - sprintf(min_str, "%02d", minute); + // If the OLED is currently off, skip the repaint (which would turn the + // OLED on if the image is changed in any way). + if (!is_oled_on()) { + return false; + } - uint8_t mods = get_mods(); + // If the sleep timer has expired while the OLED was on, turn the OLED off. + if (timer_expired32(timer_read32(), oled_sleep_timer)) { + oled_off(); + return false; + } -/* Layer indicator is 41 x 10 pixels */ - draw_layer_section(0,0,true); + // Always perform a repaint if the OLED is currently on. (This can + // potentially be optimized to avoid unneeded repaints if all possible + // state changes are covered by oled_request_repaint() or + // oled_request_wakeup(), but then any missed calls to these functions + // would result in displaying a stale image.) + return true; +} -#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 - 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); +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); } - } - 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(); } -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; +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); } - } +} - draw_encoder(80, 0, true); - draw_layer_section(80, 11, true); +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"; + } +} -#define CAPS_DISPLAY_X 86 -#define CAPS_DISPLAY_Y 22 +static char* get_time(void) { + uint8_t hour = last_minute / 60; + uint16_t minute = last_minute % 60; - 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); - } + if (encoder_mode == ENC_MODE_CLOCK_SET) { + hour = hour_config; + minute = minute_config; + } + bool is_pm = (hour / 12) > 0; + hour = hour % 12; + if (hour == 0) { + hour = 12; + } - send_buffer(); + static char time_str[8] = ""; + sprintf(time_str, "%02d:%02d%s", hour, minute, is_pm ? "pm" : "am"); + return time_str; } + +static char* get_date(void) { + 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) { + year = year_config + 1980; + month = month_config; + day = day_config; + } + + static char date_str[11] = ""; + sprintf(date_str, "%04d-%02d-%02d", year, month, day); + + return date_str; +} + +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 + + // 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); + } + } + + // 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); + + // 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); +} + +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 diff --git a/keyboards/cannonkeys/savage65/rules.mk b/keyboards/cannonkeys/savage65/rules.mk index 92e945d8f5..d5f41eccd0 100644 --- a/keyboards/cannonkeys/savage65/rules.mk +++ b/keyboards/cannonkeys/savage65/rules.mk @@ -12,7 +12,7 @@ DFU_SUFFIX_ARGS = -v FFFF -p FFFF # -BOOTMAGIC_ENABLE = lite # Enable Bootmagic Lite +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite MOUSEKEY_ENABLE = yes # Mouse keys EXTRAKEY_ENABLE = yes # Audio control and System control CONSOLE_ENABLE = yes # Console for debug diff --git a/keyboards/cannonkeys/tmov2/rules.mk b/keyboards/cannonkeys/tmov2/rules.mk index 7464df414b..d068ea28a7 100644 --- a/keyboards/cannonkeys/tmov2/rules.mk +++ b/keyboards/cannonkeys/tmov2/rules.mk @@ -12,7 +12,7 @@ DFU_SUFFIX_ARGS = -v FFFF -p FFFF # -BOOTMAGIC_ENABLE = lite # Enable Bootmagic Lite +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite MOUSEKEY_ENABLE = yes # Mouse keys EXTRAKEY_ENABLE = yes # Audio control and System control CONSOLE_ENABLE = yes # Console for debug diff --git a/keyboards/cannonkeys/tsukuyomi/rules.mk b/keyboards/cannonkeys/tsukuyomi/rules.mk index aa0b3116a9..1f61cca45f 100644 --- a/keyboards/cannonkeys/tsukuyomi/rules.mk +++ b/keyboards/cannonkeys/tsukuyomi/rules.mk @@ -10,7 +10,7 @@ DFU_SUFFIX_ARGS = -v FFFF -p FFFF # Build Options # change yes to no to disable # -BOOTMAGIC_ENABLE = lite # Enable Bootmagic Lite +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite MOUSEKEY_ENABLE = yes # Mouse keys EXTRAKEY_ENABLE = yes # Audio control and System control CONSOLE_ENABLE = yes # Console for debug diff --git a/keyboards/cannonkeys/vicious40/rules.mk b/keyboards/cannonkeys/vicious40/rules.mk index 490af346fc..0b98c9aad8 100644 --- a/keyboards/cannonkeys/vicious40/rules.mk +++ b/keyboards/cannonkeys/vicious40/rules.mk @@ -10,7 +10,7 @@ DFU_SUFFIX_ARGS = -p FFFF -v FFFF # Build Options # change yes to no to disable # -BOOTMAGIC_ENABLE = lite # Enable Bootmagic Lite +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite MOUSEKEY_ENABLE = yes # Mouse keys EXTRAKEY_ENABLE = yes # Audio control and System control CONSOLE_ENABLE = yes # Console for debug |