forked from forks/qmk_firmware
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
This commit is contained in:
parent
7b753f227a
commit
22cafb9a20
|
@ -71,14 +71,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
/* Locking resynchronize hack */
|
/* Locking resynchronize hack */
|
||||||
#define LOCKING_RESYNC_ENABLE
|
#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
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Custom config starts after VIA's EEPROM usage,
|
// Custom config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
|
|
|
@ -23,10 +23,9 @@ CONSOLE_ENABLE = yes # Console for debug
|
||||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||||
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
|
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
|
||||||
NKRO_ENABLE = yes # USB Nkey Rollover
|
NKRO_ENABLE = yes # USB Nkey Rollover
|
||||||
CUSTOM_MATRIX = no # Custom matrix file
|
|
||||||
ENCODER_ENABLE = yes
|
ENCODER_ENABLE = yes
|
||||||
QWIIC_ENABLE = yes
|
OLED_ENABLE = yes
|
||||||
QWIIC_DRIVERS += MICRO_OLED
|
OLED_DRIVER = SSD1306
|
||||||
#BACKLIGHT_ENABLE = yes
|
#BACKLIGHT_ENABLE = yes
|
||||||
|
|
||||||
DEFAULT_FOLDER = cannonkeys/satisfaction75/rev1
|
DEFAULT_FOLDER = cannonkeys/satisfaction75/rev1
|
||||||
|
|
|
@ -5,11 +5,6 @@
|
||||||
#include <ch.h>
|
#include <ch.h>
|
||||||
#include <hal.h>
|
#include <hal.h>
|
||||||
|
|
||||||
#ifdef QWIIC_MICRO_OLED_ENABLE
|
|
||||||
#include "micro_oled.h"
|
|
||||||
#include "qwiic.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
#include "raw_hid.h"
|
#include "raw_hid.h"
|
||||||
|
@ -20,18 +15,14 @@
|
||||||
/* Artificial delay added to get media keys to work in the encoder*/
|
/* Artificial delay added to get media keys to work in the encoder*/
|
||||||
#define MEDIA_KEY_DELAY 10
|
#define MEDIA_KEY_DELAY 10
|
||||||
|
|
||||||
uint16_t last_flush;
|
|
||||||
|
|
||||||
volatile uint8_t led_numlock = false;
|
volatile uint8_t led_numlock = false;
|
||||||
volatile uint8_t led_capslock = false;
|
volatile uint8_t led_capslock = false;
|
||||||
volatile uint8_t led_scrolllock = false;
|
volatile uint8_t led_scrolllock = false;
|
||||||
|
|
||||||
uint8_t layer;
|
uint8_t layer;
|
||||||
|
|
||||||
bool queue_for_send = false;
|
|
||||||
bool clock_set_mode = false;
|
bool clock_set_mode = false;
|
||||||
uint8_t oled_mode = OLED_DEFAULT;
|
uint8_t oled_mode = OLED_DEFAULT;
|
||||||
bool oled_sleeping = false;
|
|
||||||
|
|
||||||
uint8_t encoder_value = 32;
|
uint8_t encoder_value = 32;
|
||||||
uint8_t encoder_mode = ENC_MODE_VOLUME;
|
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:
|
case id_oled_mode:
|
||||||
{
|
{
|
||||||
oled_mode = command_data[1];
|
oled_mode = command_data[1];
|
||||||
draw_ui();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case id_encoder_modes:
|
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) {
|
layer_state_t layer_state_set_kb(layer_state_t state) {
|
||||||
state = layer_state_set_user(state);
|
state = layer_state_set_user(state);
|
||||||
layer = biton32(state);
|
layer = biton32(state);
|
||||||
queue_for_send = true;
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
||||||
queue_for_send = true;
|
|
||||||
switch (keycode) {
|
switch (keycode) {
|
||||||
case OLED_TOGG:
|
case OLED_TOGG:
|
||||||
if(!clock_set_mode){
|
if(!clock_set_mode){
|
||||||
if (record->event.pressed) {
|
if (record->event.pressed) {
|
||||||
oled_mode = (oled_mode + 1) % _NUM_OLED_MODES;
|
oled_mode = (oled_mode + 1) % _NUM_OLED_MODES;
|
||||||
draw_ui();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
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) {
|
bool encoder_update_kb(uint8_t index, bool clockwise) {
|
||||||
if (!encoder_update_user(index, clockwise)) return false;
|
if (!encoder_update_user(index, clockwise)) return false;
|
||||||
encoder_value = (encoder_value + (clockwise ? 1 : -1)) % 64;
|
encoder_value = (encoder_value + (clockwise ? 1 : -1)) % 64;
|
||||||
queue_for_send = true;
|
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
if (layer == 0){
|
if (layer == 0){
|
||||||
uint16_t mapped_code = 0;
|
uint16_t mapped_code = 0;
|
||||||
|
@ -376,7 +362,6 @@ void matrix_init_kb(void)
|
||||||
#endif // VIA_ENABLE
|
#endif // VIA_ENABLE
|
||||||
|
|
||||||
rtcGetTime(&RTCD1, &last_timespec);
|
rtcGetTime(&RTCD1, &last_timespec);
|
||||||
queue_for_send = true;
|
|
||||||
backlight_init_ports();
|
backlight_init_ports();
|
||||||
matrix_init_user();
|
matrix_init_user();
|
||||||
}
|
}
|
||||||
|
@ -388,22 +373,14 @@ void housekeeping_task_kb(void) {
|
||||||
|
|
||||||
if (minutes_since_midnight != last_minute){
|
if (minutes_since_midnight != last_minute){
|
||||||
last_minute = minutes_since_midnight;
|
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) {
|
if((oled_mode == OLED_OFF) && is_oled_on()){
|
||||||
oled_sleeping = false;
|
oled_off();
|
||||||
read_host_led_state();
|
|
||||||
draw_ui();
|
|
||||||
queue_for_send = false;
|
|
||||||
}
|
}
|
||||||
if (timer_elapsed(last_flush) > ScreenOffInterval && !oled_sleeping) {
|
if((oled_mode != OLED_OFF) && !is_oled_on()){
|
||||||
send_command(DISPLAYOFF); /* 0xAE */
|
oled_on();
|
||||||
oled_sleeping = true;
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -14,9 +14,6 @@
|
||||||
#define EEPROM_DEFAULT_OLED (VIA_EEPROM_CUSTOM_CONFIG_ADDR+2)
|
#define EEPROM_DEFAULT_OLED (VIA_EEPROM_CUSTOM_CONFIG_ADDR+2)
|
||||||
#define EEPROM_CUSTOM_ENCODER (VIA_EEPROM_CUSTOM_CONFIG_ADDR+3)
|
#define EEPROM_CUSTOM_ENCODER (VIA_EEPROM_CUSTOM_CONFIG_ADDR+3)
|
||||||
|
|
||||||
/* screen off after this many milliseconds */
|
|
||||||
#define ScreenOffInterval 60000 /* milliseconds */
|
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
uint8_t raw;
|
uint8_t raw;
|
||||||
struct {
|
struct {
|
||||||
|
@ -74,10 +71,7 @@ extern volatile uint8_t led_scrolllock;
|
||||||
extern uint8_t layer;
|
extern uint8_t layer;
|
||||||
|
|
||||||
// OLED Behavior
|
// OLED Behavior
|
||||||
extern uint16_t last_flush;
|
|
||||||
extern bool queue_for_send;
|
|
||||||
extern uint8_t oled_mode;
|
extern uint8_t oled_mode;
|
||||||
extern bool oled_sleeping;
|
|
||||||
|
|
||||||
// Encoder Behavior
|
// Encoder Behavior
|
||||||
extern uint8_t encoder_value;
|
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);
|
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_init_ports(void);
|
||||||
void backlight_set(uint8_t level);
|
void backlight_set(uint8_t level);
|
||||||
bool is_breathing(void);
|
bool is_breathing(void);
|
||||||
|
|
|
@ -125,7 +125,6 @@ uint16_t handle_encoder_clockwise(){
|
||||||
#endif
|
#endif
|
||||||
case ENC_MODE_CLOCK_SET:
|
case ENC_MODE_CLOCK_SET:
|
||||||
update_time_config(1);
|
update_time_config(1);
|
||||||
queue_for_send = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return mapped_code;
|
return mapped_code;
|
||||||
|
@ -171,7 +170,6 @@ uint16_t handle_encoder_ccw(){
|
||||||
|
|
||||||
case ENC_MODE_CLOCK_SET:
|
case ENC_MODE_CLOCK_SET:
|
||||||
update_time_config(-1);
|
update_time_config(-1);
|
||||||
queue_for_send = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return mapped_code;
|
return mapped_code;
|
||||||
|
|
|
@ -1,271 +1,201 @@
|
||||||
#include "satisfaction75.h"
|
#include "satisfaction75.h"
|
||||||
#include "micro_oled.h"
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
void draw_default(void);
|
||||||
void draw_ui() {
|
void draw_clock(void);
|
||||||
#ifdef QWIIC_MICRO_OLED_ENABLE
|
|
||||||
clear_buffer();
|
#ifdef OLED_ENABLE
|
||||||
last_flush = timer_read();
|
|
||||||
send_command(DISPLAYON);
|
__attribute__((weak)) oled_rotation_t oled_init_user(oled_rotation_t rotation) { return OLED_ROTATION_0; }
|
||||||
if(clock_set_mode){
|
|
||||||
draw_clock();
|
__attribute__((weak)) void oled_task_user(void) {
|
||||||
return;
|
if (!is_oled_on()) {
|
||||||
}
|
return;
|
||||||
switch (oled_mode){
|
}
|
||||||
default:
|
oled_clear();
|
||||||
case OLED_DEFAULT:
|
if (clock_set_mode) {
|
||||||
draw_default();
|
draw_clock();
|
||||||
break;
|
return;
|
||||||
case OLED_TIME:
|
}
|
||||||
draw_clock();
|
switch (oled_mode) {
|
||||||
break;
|
default:
|
||||||
case OLED_OFF:
|
case OLED_DEFAULT:
|
||||||
send_command(DISPLAYOFF);
|
draw_default();
|
||||||
break;
|
break;
|
||||||
}
|
case OLED_TIME:
|
||||||
#endif
|
draw_clock();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_encoder(int8_t startX, int8_t startY, bool show_legend){
|
|
||||||
if(show_legend){
|
static void draw_line_h(uint8_t x, uint8_t y, uint8_t len) {
|
||||||
draw_string(startX + 1, startY + 2, "ENC", PIXEL_ON, NORM, 0);
|
for (uint8_t i = 0; i < len; i++) {
|
||||||
} else {
|
oled_write_pixel(i + x, y, true);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_layer_section(int8_t startX, int8_t startY, bool show_legend){
|
static void draw_line_v(uint8_t x, uint8_t y, uint8_t len) {
|
||||||
if(show_legend){
|
for (uint8_t i = 0; i < len; i++) {
|
||||||
draw_string(startX + 1, startY + 2, "LAYER", PIXEL_ON, NORM, 0);
|
oled_write_pixel(x, i + y, true);
|
||||||
} 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_default(){
|
static char* get_enc_mode(void) {
|
||||||
uint8_t hour = last_minute / 60;
|
switch (encoder_mode) {
|
||||||
uint16_t minute = last_minute % 60;
|
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){
|
static char* get_time(void) {
|
||||||
hour = hour_config;
|
uint8_t hour = last_minute / 60;
|
||||||
minute = minute_config;
|
uint16_t minute = last_minute % 60;
|
||||||
}
|
|
||||||
|
|
||||||
bool is_pm = (hour / 12) > 0;
|
if (encoder_mode == ENC_MODE_CLOCK_SET) {
|
||||||
hour = hour % 12;
|
hour = hour_config;
|
||||||
if (hour == 0){
|
minute = minute_config;
|
||||||
hour = 12;
|
}
|
||||||
}
|
|
||||||
char hour_str[3] = "";
|
|
||||||
char min_str[3] = "";
|
|
||||||
|
|
||||||
sprintf(hour_str, "%02d", hour);
|
bool is_pm = (hour / 12) > 0;
|
||||||
sprintf(min_str, "%02d", minute);
|
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 */
|
return time_str;
|
||||||
draw_layer_section(0,0,true);
|
}
|
||||||
|
|
||||||
#define ENCODER_INDICATOR_X 45
|
static char* get_date(void) {
|
||||||
#define ENCODER_INDICATOR_Y 0
|
int16_t year = last_timespec.year + 1980;
|
||||||
draw_encoder(ENCODER_INDICATOR_X, ENCODER_INDICATOR_Y, true);
|
int8_t month = last_timespec.month;
|
||||||
/* Matrix display is 19 x 9 pixels */
|
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_X 0
|
||||||
#define MATRIX_DISPLAY_Y 18
|
#define MATRIX_DISPLAY_Y 18
|
||||||
|
|
||||||
for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
|
// matrix
|
||||||
for (uint8_t y = 0; y < MATRIX_COLS; y++) {
|
for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
|
||||||
draw_pixel(MATRIX_DISPLAY_X + y + 2, MATRIX_DISPLAY_Y + x + 2,(matrix_get_row(x) & (1 << y)) > 0, NORM);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
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 */
|
// outline
|
||||||
#define MOD_DISPLAY_X 30
|
draw_line_h(MATRIX_DISPLAY_X, MATRIX_DISPLAY_Y, 19);
|
||||||
#define MOD_DISPLAY_Y 18
|
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 (mods & MOD_LSFT) {
|
// oled location
|
||||||
draw_rect_filled_soft(MOD_DISPLAY_X + 0, MOD_DISPLAY_Y, 5 + (1 * 6), 11, PIXEL_ON, NORM);
|
draw_line_h(MATRIX_DISPLAY_X + 14, MATRIX_DISPLAY_Y + 2, 3);
|
||||||
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 */
|
// bodge extra lines for invert layer and enc mode
|
||||||
#define LOCK_DISPLAY_X 100
|
draw_line_v(35, 0, 8);
|
||||||
#define LOCK_DISPLAY_Y 0
|
draw_line_v(71, 0, 8);
|
||||||
|
|
||||||
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(){
|
void draw_clock() {
|
||||||
int8_t hour = last_minute / 60;
|
oled_set_cursor(0, 0);
|
||||||
int16_t minute = last_minute % 60;
|
oled_write(get_date(), false);
|
||||||
int16_t year = last_timespec.year + 1980;
|
oled_set_cursor(0, 2);
|
||||||
int8_t month = last_timespec.month;
|
oled_write(get_time(), false);
|
||||||
int8_t day = last_timespec.day;
|
|
||||||
|
|
||||||
if(encoder_mode == ENC_MODE_CLOCK_SET){
|
oled_set_cursor(12, 0);
|
||||||
hour = hour_config;
|
oled_write_P(PSTR(" ENC "), false);
|
||||||
minute = minute_config;
|
oled_write(get_enc_mode(), true);
|
||||||
year = year_config + 1980;
|
|
||||||
month = month_config;
|
|
||||||
day = day_config;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool is_pm = (hour / 12) > 0;
|
oled_set_cursor(13, 1);
|
||||||
hour = hour % 12;
|
oled_write_P(PSTR("LAYER "), false);
|
||||||
if (hour == 0){
|
oled_write_char(get_highest_layer(layer_state) + 0x30, true);
|
||||||
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);
|
led_t led_state = host_keyboard_led_state();
|
||||||
sprintf(min_str, "%02d", minute);
|
oled_set_cursor(15, 3);
|
||||||
sprintf(year_str, "%d", year);
|
oled_write_P(PSTR("CAPS"), led_state.caps_lock);
|
||||||
sprintf(month_str, "%02d", month);
|
|
||||||
sprintf(day_str, "%02d", day);
|
|
||||||
|
|
||||||
|
if (clock_set_mode) {
|
||||||
#define DATE_DISPLAY_X 6
|
switch (time_config_idx) {
|
||||||
#define DATE_DISPLAY_Y 0
|
case 0: // hour
|
||||||
draw_string(DATE_DISPLAY_X, DATE_DISPLAY_Y, year_str, PIXEL_ON, NORM, 0);
|
default:
|
||||||
draw_string(DATE_DISPLAY_X + 25, DATE_DISPLAY_Y, "-", PIXEL_ON, NORM, 0);
|
draw_line_h(0, 25, 10);
|
||||||
draw_string(DATE_DISPLAY_X + 31, DATE_DISPLAY_Y, month_str, PIXEL_ON, NORM, 0);
|
break;
|
||||||
draw_string(DATE_DISPLAY_X + 44, DATE_DISPLAY_Y, "-", PIXEL_ON, NORM, 0);
|
case 1: // minute
|
||||||
draw_string(DATE_DISPLAY_X + 50, DATE_DISPLAY_Y, day_str, PIXEL_ON, NORM, 0);
|
draw_line_h(18, 25, 10);
|
||||||
|
break;
|
||||||
#define CLOCK_DISPLAY_X 6
|
case 2: // year
|
||||||
#define CLOCK_DISPLAY_Y 14
|
draw_line_h(0, 9, 24);
|
||||||
draw_string(CLOCK_DISPLAY_X, CLOCK_DISPLAY_Y, hour_str, PIXEL_ON, NORM, 1);
|
break;
|
||||||
draw_string(CLOCK_DISPLAY_X + 17, CLOCK_DISPLAY_Y, ":", PIXEL_ON, NORM, 1);
|
case 3: // month
|
||||||
draw_string(CLOCK_DISPLAY_X + 25, CLOCK_DISPLAY_Y, min_str, PIXEL_ON, NORM, 1);
|
draw_line_h(30, 9, 10);
|
||||||
if(is_pm){
|
break;
|
||||||
draw_string(CLOCK_DISPLAY_X + 41, CLOCK_DISPLAY_Y, "pm", PIXEL_ON, NORM, 1);
|
case 4: // day
|
||||||
} else{
|
draw_line_h(48, 9, 10);
|
||||||
draw_string(CLOCK_DISPLAY_X + 41, CLOCK_DISPLAY_Y, "am", PIXEL_ON, NORM, 1);
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
draw_encoder(80, 0, true);
|
|
||||||
draw_layer_section(80, 11, true);
|
|
||||||
|
|
||||||
#define CAPS_DISPLAY_X 86
|
|
||||||
#define CAPS_DISPLAY_Y 22
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
send_buffer();
|
|
||||||
|
|
||||||
|
// bodge extra lines for invert layer and enc mode
|
||||||
|
draw_line_v(101, 0, 8);
|
||||||
|
draw_line_v(113, 8, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue