Skip to content

Commit 5920e28

Browse files
zvecrptrxyz
authored andcommitted
Migrate satisfaction75 away from QWIIC_DRIVERS (qmk#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
1 parent 9033d23 commit 5920e28

File tree

6 files changed

+186
-299
lines changed

6 files changed

+186
-299
lines changed

keyboards/cannonkeys/satisfaction75/config.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
7171
/* Locking resynchronize hack */
7272
#define LOCKING_RESYNC_ENABLE
7373

74-
#ifdef QWIIC_MICRO_OLED_ENABLE
75-
76-
#undef I2C_ADDRESS_SA0_1
77-
#define I2C_ADDRESS_SA0_1 0b0111100
78-
#define LCDWIDTH 128
79-
#define LCDHEIGHT 32
80-
81-
#endif
74+
// configure oled driver for the 128x32 oled
75+
#define OLED_UPDATE_INTERVAL 66 // ~15fps
8276

8377
// Custom config starts after VIA's EEPROM usage,
8478
// dynamic keymaps start after this.

keyboards/cannonkeys/satisfaction75/rules.mk

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ CONSOLE_ENABLE = yes # Console for debug
2323
COMMAND_ENABLE = yes # Commands for debug and configuration
2424
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
2525
NKRO_ENABLE = yes # USB Nkey Rollover
26-
CUSTOM_MATRIX = no # Custom matrix file
2726
ENCODER_ENABLE = yes
28-
QWIIC_ENABLE = yes
29-
QWIIC_DRIVERS += MICRO_OLED
27+
OLED_ENABLE = yes
28+
OLED_DRIVER = SSD1306
3029
#BACKLIGHT_ENABLE = yes
3130

3231
DEFAULT_FOLDER = cannonkeys/satisfaction75/rev1

keyboards/cannonkeys/satisfaction75/satisfaction75.c

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
#include <ch.h>
66
#include <hal.h>
77

8-
#ifdef QWIIC_MICRO_OLED_ENABLE
9-
#include "micro_oled.h"
10-
#include "qwiic.h"
11-
#endif
12-
138
#include "timer.h"
149

1510
#include "raw_hid.h"
@@ -20,18 +15,14 @@
2015
/* Artificial delay added to get media keys to work in the encoder*/
2116
#define MEDIA_KEY_DELAY 10
2217

23-
uint16_t last_flush;
24-
2518
volatile uint8_t led_numlock = false;
2619
volatile uint8_t led_capslock = false;
2720
volatile uint8_t led_scrolllock = false;
2821

2922
uint8_t layer;
3023

31-
bool queue_for_send = false;
3224
bool clock_set_mode = false;
3325
uint8_t oled_mode = OLED_DEFAULT;
34-
bool oled_sleeping = false;
3526

3627
uint8_t encoder_value = 32;
3728
uint8_t encoder_mode = ENC_MODE_VOLUME;
@@ -167,7 +158,6 @@ void raw_hid_receive_kb( uint8_t *data, uint8_t length )
167158
case id_oled_mode:
168159
{
169160
oled_mode = command_data[1];
170-
draw_ui();
171161
break;
172162
}
173163
case id_encoder_modes:
@@ -247,18 +237,15 @@ void read_host_led_state(void) {
247237
layer_state_t layer_state_set_kb(layer_state_t state) {
248238
state = layer_state_set_user(state);
249239
layer = biton32(state);
250-
queue_for_send = true;
251240
return state;
252241
}
253242

254243
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
255-
queue_for_send = true;
256244
switch (keycode) {
257245
case OLED_TOGG:
258246
if(!clock_set_mode){
259247
if (record->event.pressed) {
260248
oled_mode = (oled_mode + 1) % _NUM_OLED_MODES;
261-
draw_ui();
262249
}
263250
}
264251
return false;
@@ -303,7 +290,6 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
303290
bool encoder_update_kb(uint8_t index, bool clockwise) {
304291
if (!encoder_update_user(index, clockwise)) return false;
305292
encoder_value = (encoder_value + (clockwise ? 1 : -1)) % 64;
306-
queue_for_send = true;
307293
if (index == 0) {
308294
if (layer == 0){
309295
uint16_t mapped_code = 0;
@@ -376,7 +362,6 @@ void matrix_init_kb(void)
376362
#endif // VIA_ENABLE
377363

378364
rtcGetTime(&RTCD1, &last_timespec);
379-
queue_for_send = true;
380365
backlight_init_ports();
381366
matrix_init_user();
382367
}
@@ -388,22 +373,14 @@ void housekeeping_task_kb(void) {
388373

389374
if (minutes_since_midnight != last_minute){
390375
last_minute = minutes_since_midnight;
391-
if(!oled_sleeping){
392-
queue_for_send = true;
393-
}
394376
}
395-
#ifdef QWIIC_MICRO_OLED_ENABLE
396-
if (queue_for_send && oled_mode != OLED_OFF) {
397-
oled_sleeping = false;
398-
read_host_led_state();
399-
draw_ui();
400-
queue_for_send = false;
377+
378+
if((oled_mode == OLED_OFF) && is_oled_on()){
379+
oled_off();
401380
}
402-
if (timer_elapsed(last_flush) > ScreenOffInterval && !oled_sleeping) {
403-
send_command(DISPLAYOFF); /* 0xAE */
404-
oled_sleeping = true;
381+
if((oled_mode != OLED_OFF) && !is_oled_on()){
382+
oled_on();
405383
}
406-
#endif
407384
}
408385

409386
//

keyboards/cannonkeys/satisfaction75/satisfaction75.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
#define EEPROM_DEFAULT_OLED (VIA_EEPROM_CUSTOM_CONFIG_ADDR+2)
1515
#define EEPROM_CUSTOM_ENCODER (VIA_EEPROM_CUSTOM_CONFIG_ADDR+3)
1616

17-
/* screen off after this many milliseconds */
18-
#define ScreenOffInterval 60000 /* milliseconds */
19-
2017
typedef union {
2118
uint8_t raw;
2219
struct {
@@ -74,10 +71,7 @@ extern volatile uint8_t led_scrolllock;
7471
extern uint8_t layer;
7572

7673
// OLED Behavior
77-
extern uint16_t last_flush;
78-
extern bool queue_for_send;
7974
extern uint8_t oled_mode;
80-
extern bool oled_sleeping;
8175

8276
// Encoder Behavior
8377
extern uint8_t encoder_value;
@@ -113,11 +107,6 @@ void set_custom_encoder_config(uint8_t encoder_idx, uint8_t behavior, uint16_t n
113107

114108
void update_time_config(int8_t increment);
115109

116-
__attribute__ ((weak))
117-
void draw_ui(void);
118-
void draw_default(void);
119-
void draw_clock(void);
120-
121110
void backlight_init_ports(void);
122111
void backlight_set(uint8_t level);
123112
bool is_breathing(void);

keyboards/cannonkeys/satisfaction75/satisfaction_encoder.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ uint16_t handle_encoder_clockwise(){
125125
#endif
126126
case ENC_MODE_CLOCK_SET:
127127
update_time_config(1);
128-
queue_for_send = true;
129128
break;
130129
}
131130
return mapped_code;
@@ -171,7 +170,6 @@ uint16_t handle_encoder_ccw(){
171170

172171
case ENC_MODE_CLOCK_SET:
173172
update_time_config(-1);
174-
queue_for_send = true;
175173
break;
176174
}
177175
return mapped_code;

0 commit comments

Comments
 (0)