aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keyboards/cannonkeys/satisfaction75/config.h6
-rw-r--r--keyboards/cannonkeys/satisfaction75/satisfaction75.c16
-rw-r--r--keyboards/cannonkeys/satisfaction75/satisfaction75.h7
-rw-r--r--keyboards/cannonkeys/satisfaction75/satisfaction_oled.c66
4 files changed, 87 insertions, 8 deletions
diff --git a/keyboards/cannonkeys/satisfaction75/config.h b/keyboards/cannonkeys/satisfaction75/config.h
index 7fca7226b..53e4c18e5 100644
--- a/keyboards/cannonkeys/satisfaction75/config.h
+++ b/keyboards/cannonkeys/satisfaction75/config.h
@@ -74,6 +74,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
74// configure oled driver for the 128x32 oled 74// configure oled driver for the 128x32 oled
75#define OLED_UPDATE_INTERVAL 66 // ~15fps 75#define OLED_UPDATE_INTERVAL 66 // ~15fps
76 76
77// OLED_TIMEOUT is incompatible with the OLED_OFF mode
78#define OLED_TIMEOUT 0
79
80// OLED timeout reimplemented in the keyboard-specific code
81#define CUSTOM_OLED_TIMEOUT 60000
82
77// Custom config starts after VIA's EEPROM usage, 83// Custom config starts after VIA's EEPROM usage,
78// dynamic keymaps start after this. 84// dynamic keymaps start after this.
79// Custom config Usage: 85// Custom config Usage:
diff --git a/keyboards/cannonkeys/satisfaction75/satisfaction75.c b/keyboards/cannonkeys/satisfaction75/satisfaction75.c
index 304df3325..8b5016437 100644
--- a/keyboards/cannonkeys/satisfaction75/satisfaction75.c
+++ b/keyboards/cannonkeys/satisfaction75/satisfaction75.c
@@ -23,6 +23,9 @@ uint8_t layer;
23 23
24bool clock_set_mode = false; 24bool clock_set_mode = false;
25uint8_t oled_mode = OLED_DEFAULT; 25uint8_t oled_mode = OLED_DEFAULT;
26bool oled_repaint_requested = false;
27bool oled_wakeup_requested = false;
28uint32_t oled_sleep_timer;
26 29
27uint8_t encoder_value = 32; 30uint8_t encoder_value = 32;
28uint8_t encoder_mode = ENC_MODE_VOLUME; 31uint8_t encoder_mode = ENC_MODE_VOLUME;
@@ -158,6 +161,7 @@ void raw_hid_receive_kb( uint8_t *data, uint8_t length )
158 case id_oled_mode: 161 case id_oled_mode:
159 { 162 {
160 oled_mode = command_data[1]; 163 oled_mode = command_data[1];
164 oled_request_wakeup();
161 break; 165 break;
162 } 166 }
163 case id_encoder_modes: 167 case id_encoder_modes:
@@ -237,10 +241,12 @@ void read_host_led_state(void) {
237layer_state_t layer_state_set_kb(layer_state_t state) { 241layer_state_t layer_state_set_kb(layer_state_t state) {
238 state = layer_state_set_user(state); 242 state = layer_state_set_user(state);
239 layer = biton32(state); 243 layer = biton32(state);
244 oled_request_wakeup();
240 return state; 245 return state;
241} 246}
242 247
243bool process_record_kb(uint16_t keycode, keyrecord_t *record) { 248bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
249 oled_request_wakeup();
244 switch (keycode) { 250 switch (keycode) {
245 case OLED_TOGG: 251 case OLED_TOGG:
246 if(!clock_set_mode){ 252 if(!clock_set_mode){
@@ -289,6 +295,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
289 295
290bool encoder_update_kb(uint8_t index, bool clockwise) { 296bool encoder_update_kb(uint8_t index, bool clockwise) {
291 if (!encoder_update_user(index, clockwise)) return false; 297 if (!encoder_update_user(index, clockwise)) return false;
298 oled_request_wakeup();
292 encoder_value = (encoder_value + (clockwise ? 1 : -1)) % 64; 299 encoder_value = (encoder_value + (clockwise ? 1 : -1)) % 64;
293 if (index == 0) { 300 if (index == 0) {
294 if (layer == 0){ 301 if (layer == 0){
@@ -364,6 +371,7 @@ void matrix_init_kb(void)
364 rtcGetTime(&RTCD1, &last_timespec); 371 rtcGetTime(&RTCD1, &last_timespec);
365 backlight_init_ports(); 372 backlight_init_ports();
366 matrix_init_user(); 373 matrix_init_user();
374 oled_request_wakeup();
367} 375}
368 376
369 377
@@ -373,13 +381,7 @@ void housekeeping_task_kb(void) {
373 381
374 if (minutes_since_midnight != last_minute){ 382 if (minutes_since_midnight != last_minute){
375 last_minute = minutes_since_midnight; 383 last_minute = minutes_since_midnight;
376 } 384 oled_request_repaint();
377
378 if((oled_mode == OLED_OFF) && is_oled_on()){
379 oled_off();
380 }
381 if((oled_mode != OLED_OFF) && !is_oled_on()){
382 oled_on();
383 } 385 }
384} 386}
385 387
diff --git a/keyboards/cannonkeys/satisfaction75/satisfaction75.h b/keyboards/cannonkeys/satisfaction75/satisfaction75.h
index 9d20dd9c9..c6dbc31f1 100644
--- a/keyboards/cannonkeys/satisfaction75/satisfaction75.h
+++ b/keyboards/cannonkeys/satisfaction75/satisfaction75.h
@@ -72,6 +72,9 @@ extern uint8_t layer;
72 72
73// OLED Behavior 73// OLED Behavior
74extern uint8_t oled_mode; 74extern uint8_t oled_mode;
75extern bool oled_repaint_requested;
76extern bool oled_wakeup_requested;
77extern uint32_t oled_sleep_timer;
75 78
76// Encoder Behavior 79// Encoder Behavior
77extern uint8_t encoder_value; 80extern uint8_t encoder_value;
@@ -107,6 +110,10 @@ void set_custom_encoder_config(uint8_t encoder_idx, uint8_t behavior, uint16_t n
107 110
108void update_time_config(int8_t increment); 111void update_time_config(int8_t increment);
109 112
113void oled_request_wakeup(void);
114void oled_request_repaint(void);
115bool oled_task_needs_to_repaint(void);
116
110void backlight_init_ports(void); 117void backlight_init_ports(void);
111void backlight_set(uint8_t level); 118void backlight_set(uint8_t level);
112bool is_breathing(void); 119bool is_breathing(void);
diff --git a/keyboards/cannonkeys/satisfaction75/satisfaction_oled.c b/keyboards/cannonkeys/satisfaction75/satisfaction_oled.c
index 9589ecea8..443482eac 100644
--- a/keyboards/cannonkeys/satisfaction75/satisfaction_oled.c
+++ b/keyboards/cannonkeys/satisfaction75/satisfaction_oled.c
@@ -8,7 +8,7 @@ void draw_clock(void);
8__attribute__((weak)) oled_rotation_t oled_init_user(oled_rotation_t rotation) { return OLED_ROTATION_0; } 8__attribute__((weak)) oled_rotation_t oled_init_user(oled_rotation_t rotation) { return OLED_ROTATION_0; }
9 9
10__attribute__((weak)) void oled_task_user(void) { 10__attribute__((weak)) void oled_task_user(void) {
11 if (!is_oled_on()) { 11 if (!oled_task_needs_to_repaint()) {
12 return; 12 return;
13 } 13 }
14 oled_clear(); 14 oled_clear();
@@ -27,6 +27,70 @@ __attribute__((weak)) void oled_task_user(void) {
27 } 27 }
28} 28}
29 29
30// Request a repaint of the OLED image without resetting the OLED sleep timer.
31// Used for things like clock updates that should not keep the OLED turned on
32// if there is no other activity.
33void oled_request_repaint(void) {
34 if (is_oled_on()) {
35 oled_repaint_requested = true;
36 }
37}
38
39// Request a repaint of the OLED image and reset the OLED sleep timer.
40// Needs to be called after any activity that should keep the OLED turned on.
41void oled_request_wakeup(void) {
42 oled_wakeup_requested = true;
43}
44
45// Check whether oled_task_user() needs to repaint the OLED image. This
46// function should be called at the start of oled_task_user(); it also handles
47// the OLED sleep timer and the OLED_OFF mode.
48bool oled_task_needs_to_repaint(void) {
49 // In the OLED_OFF mode the OLED is kept turned off; any wakeup requests
50 // are ignored.
51 if ((oled_mode == OLED_OFF) && !clock_set_mode) {
52 oled_wakeup_requested = false;
53 oled_repaint_requested = false;
54 oled_off();
55 return false;
56 }
57
58 // If OLED wakeup was requested, reset the sleep timer and do a repaint.
59 if (oled_wakeup_requested) {
60 oled_wakeup_requested = false;
61 oled_repaint_requested = false;
62 oled_sleep_timer = timer_read32() + CUSTOM_OLED_TIMEOUT;
63 oled_on();
64 return true;
65 }
66
67 // If OLED repaint was requested, just do a repaint without touching the
68 // sleep timer.
69 if (oled_repaint_requested) {
70 oled_repaint_requested = false;
71 return true;
72 }
73
74 // If the OLED is currently off, skip the repaint (which would turn the
75 // OLED on if the image is changed in any way).
76 if (!is_oled_on()) {
77 return false;
78 }
79
80 // If the sleep timer has expired while the OLED was on, turn the OLED off.
81 if (timer_expired32(timer_read32(), oled_sleep_timer)) {
82 oled_off();
83 return false;
84 }
85
86 // Always perform a repaint if the OLED is currently on. (This can
87 // potentially be optimized to avoid unneeded repaints if all possible
88 // state changes are covered by oled_request_repaint() or
89 // oled_request_wakeup(), but then any missed calls to these functions
90 // would result in displaying a stale image.)
91 return true;
92}
93
30 94
31static void draw_line_h(uint8_t x, uint8_t y, uint8_t len) { 95static void draw_line_h(uint8_t x, uint8_t y, uint8_t len) {
32 for (uint8_t i = 0; i < len; i++) { 96 for (uint8_t i = 0; i < len; i++) {