Skip to content

Commit

Permalink
Migrate satisfaction75 away from QWIIC_DRIVERS (qmk#14747)
Browse files Browse the repository at this point in the history
* stash

* refactor old draw

* refactor old draw - tidy

* refactor old draw - tidy

* refactor old draw - reorder for diffs

* refactor old draw - reorder for diffs
  • Loading branch information
zvecr authored and ptrxyz committed Nov 6, 2021
1 parent 9033d23 commit 5920e28
Show file tree
Hide file tree
Showing 6 changed files with 186 additions and 299 deletions.
10 changes: 2 additions & 8 deletions keyboards/cannonkeys/satisfaction75/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 2 additions & 3 deletions keyboards/cannonkeys/satisfaction75/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 5 additions & 28 deletions keyboards/cannonkeys/satisfaction75/satisfaction75.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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;
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand All @@ -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
}

//
Expand Down
11 changes: 0 additions & 11 deletions keyboards/cannonkeys/satisfaction75/satisfaction75.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions keyboards/cannonkeys/satisfaction75/satisfaction_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 5920e28

Please sign in to comment.