summaryrefslogtreecommitdiffstats
path: root/keyboards/cannonkeys/satisfaction75/satisfaction75.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/cannonkeys/satisfaction75/satisfaction75.c')
-rw-r--r--keyboards/cannonkeys/satisfaction75/satisfaction75.c132
1 files changed, 113 insertions, 19 deletions
diff --git a/keyboards/cannonkeys/satisfaction75/satisfaction75.c b/keyboards/cannonkeys/satisfaction75/satisfaction75.c
index 1423b11b0..0e788b29b 100644
--- a/keyboards/cannonkeys/satisfaction75/satisfaction75.c
+++ b/keyboards/cannonkeys/satisfaction75/satisfaction75.c
@@ -5,9 +5,10 @@
#include "ch.h"
#include "hal.h"
-// #ifdef QWIIC_MICRO_OLED_ENABLE
+#ifdef QWIIC_MICRO_OLED_ENABLE
#include "micro_oled.h"
#include "qwiic.h"
+#endif
#include "timer.h"
@@ -93,21 +94,87 @@ void raw_hid_receive( uint8_t *data, uint8_t length )
}
case id_get_keyboard_value:
{
- if ( command_data[0] == id_uptime )
- {
- uint32_t value = timer_read32();
- command_data[1] = (value >> 24 ) & 0xFF;
- command_data[2] = (value >> 16 ) & 0xFF;
- command_data[3] = (value >> 8 ) & 0xFF;
- command_data[4] = value & 0xFF;
- }
- else
- {
- *command_id = id_unhandled;
- }
+ switch( command_data[0])
+ {
+ case id_uptime:
+ {
+ uint32_t value = timer_read32();
+ command_data[1] = (value >> 24 ) & 0xFF;
+ command_data[2] = (value >> 16 ) & 0xFF;
+ command_data[3] = (value >> 8 ) & 0xFF;
+ command_data[4] = value & 0xFF;
+ break;
+ }
+ case id_oled_default_mode:
+ {
+ uint8_t default_oled = eeprom_read_byte((uint8_t*)DYNAMIC_KEYMAP_DEFAULT_OLED);
+ command_data[1] = default_oled;
+ break;
+ }
+ case id_oled_mode:
+ {
+ command_data[1] = oled_mode;
+ break;
+
+ }
+ case id_encoder_modes:
+ {
+ command_data[1] = enabled_encoder_modes;
+ break;
+ }
+ case id_encoder_custom:
+ {
+ // uint8_t custom_encoder_idx = command_data[1];
+ // command_data[2] = 0x00;
+ // command_data[3] = 0x00;
+ // command_data[4] = 0x00;
+ // command_data[5] = 0x00;
+ // command_data[6] = 0x00;
+ // command_data[7] = 0x00;
+ break;
+ }
+ default:
+ {
+ *command_id = id_unhandled;
+ break;
+ }
+ }
break;
- }
+ }
#ifdef DYNAMIC_KEYMAP_ENABLE
+ case id_set_keyboard_value:
+ {
+ switch(command_data[0]){
+ case id_oled_default_mode:
+ {
+ eeprom_update_byte((uint8_t*)DYNAMIC_KEYMAP_DEFAULT_OLED, command_data[1]);
+ break;
+ }
+ case id_oled_mode:
+ {
+ oled_mode = command_data[1];
+ draw_ui();
+ break;
+ }
+ case id_encoder_modes:
+ {
+ enabled_encoder_modes = command_data[1];
+ eeprom_update_byte((uint8_t*)DYNAMIC_KEYMAP_ENABLED_ENCODER_MODES, enabled_encoder_modes);
+ break;
+ }
+ case id_encoder_custom:
+ {
+ // uint8_t custom_encoder_idx = command_data[1];
+ break;
+ }
+ default:
+ {
+ *command_id = id_unhandled;
+ break;
+ }
+ }
+ break;
+ }
case id_dynamic_keymap_get_keycode:
{
uint16_t keycode = dynamic_keymap_get_keycode( command_data[0], command_data[1], command_data[2] );
@@ -243,9 +310,11 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
queue_for_send = true;
switch (keycode) {
case OLED_TOGG:
- if (record->event.pressed) {
- oled_mode = (oled_mode + 1) % _NUM_OLED_MODES;
- draw_ui();
+ if(!clock_set_mode){
+ if (record->event.pressed) {
+ oled_mode = (oled_mode + 1) % _NUM_OLED_MODES;
+ draw_ui();
+ }
}
return false;
case CLOCK_SET:
@@ -325,12 +394,34 @@ void encoder_update_kb(uint8_t index, bool clockwise) {
}
}
+void dynamic_keymap_custom_reset(void){
+ void *p = (void*)(DYNAMIC_KEYMAP_CUSTOM_BACKLIGHT);
+ void *end = (void*)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR);
+ while ( p != end ) {
+ eeprom_update_byte(p, 0);
+ ++p;
+ }
+ eeprom_update_byte((uint8_t*)DYNAMIC_KEYMAP_ENABLED_ENCODER_MODES, 0x1F);
+}
+
+void save_backlight_config_to_eeprom(){
+ eeprom_update_byte((uint8_t*)DYNAMIC_KEYMAP_CUSTOM_BACKLIGHT, kb_backlight_config.raw);
+}
+
+void load_custom_config(){
+ kb_backlight_config.raw = eeprom_read_byte((uint8_t*)DYNAMIC_KEYMAP_CUSTOM_BACKLIGHT);
+#ifdef DYNAMIC_KEYMAP_ENABLE
+ oled_mode = eeprom_read_byte((uint8_t*)DYNAMIC_KEYMAP_DEFAULT_OLED);
+ enabled_encoder_modes = eeprom_read_byte((uint8_t*)DYNAMIC_KEYMAP_ENABLED_ENCODER_MODES);
+#endif
+}
+
void eeprom_init_kb(void)
{
// If the EEPROM has the magic, the data is good.
// OK to load from EEPROM.
if (eeprom_is_valid()) {
- //backlight_config_load();
+ load_custom_config();
} else {
// If the EEPROM has not been saved before, or is out of date,
// save the default values to the EEPROM. Default values
@@ -341,6 +432,8 @@ void eeprom_init_kb(void)
dynamic_keymap_reset();
// This resets the macros in EEPROM to nothing.
dynamic_keymap_macro_reset();
+ // Reset the custom stuff
+ dynamic_keymap_custom_reset();
#endif
// Save the magic number last, in case saving was interrupted
eeprom_set_valid(true);
@@ -367,7 +460,7 @@ void matrix_scan_kb(void) {
queue_for_send = true;
}
}
-
+#ifdef QWIIC_MICRO_OLED_ENABLE
if (queue_for_send && oled_mode != OLED_OFF) {
oled_sleeping = false;
read_host_led_state();
@@ -378,5 +471,6 @@ void matrix_scan_kb(void) {
send_command(DISPLAYOFF); /* 0xAE */
oled_sleeping = true;
}
+#endif
}