summaryrefslogtreecommitdiff
path: root/keyboards/cannonkeys/stm32f072/keyboard.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/cannonkeys/stm32f072/keyboard.c')
-rw-r--r--keyboards/cannonkeys/stm32f072/keyboard.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/keyboards/cannonkeys/stm32f072/keyboard.c b/keyboards/cannonkeys/stm32f072/keyboard.c
index bf35a76c18..fdda018fc4 100644
--- a/keyboards/cannonkeys/stm32f072/keyboard.c
+++ b/keyboards/cannonkeys/stm32f072/keyboard.c
@@ -126,8 +126,86 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
return process_record_user(keycode, record);;
}
+#ifdef VIA_ENABLE
+void backlight_get_value( uint8_t *data )
+{
+ uint8_t *value_id = &(data[0]);
+ uint8_t *value_data = &(data[1]);
+ switch (*value_id)
+ {
+ case id_qmk_backlight_brightness:
+ {
+ // level / BACKLIGHT_LEVELS * 255
+ value_data[0] = ((uint16_t)kb_backlight_config.level) * 255 / BACKLIGHT_LEVELS;
+ break;
+ }
+ case id_qmk_backlight_effect:
+ {
+ value_data[0] = kb_backlight_config.breathing ? 1 : 0;
+ break;
+ }
+ }
+}
+void backlight_set_value( uint8_t *data )
+{
+ uint8_t *value_id = &(data[0]);
+ uint8_t *value_data = &(data[1]);
+ switch (*value_id)
+ {
+ case id_qmk_backlight_brightness:
+ {
+ // level / 255 * BACKLIGHT_LEVELS
+ kb_backlight_config.level = ((uint16_t)value_data[0]) * BACKLIGHT_LEVELS / 255;
+ backlight_set(kb_backlight_config.level);
+ break;
+ }
+ case id_qmk_backlight_effect:
+ {
+ if ( value_data[0] == 0 ) {
+ kb_backlight_config.breathing = false;
+ breathing_disable();
+ } else {
+ kb_backlight_config.breathing = true;
+ breathing_enable();
+ }
+ break;
+ }
+ }
+}
+
+void raw_hid_receive_kb( uint8_t *data, uint8_t length )
+{
+ uint8_t *command_id = &(data[0]);
+ uint8_t *command_data = &(data[1]);
+ switch ( *command_id )
+ {
+ case id_lighting_set_value:
+ {
+ backlight_set_value(command_data);
+ break;
+ }
+ case id_lighting_get_value:
+ {
+ backlight_get_value(command_data);
+ break;
+ }
+ case id_lighting_save:
+ {
+ backlight_config_save();
+ break;
+ }
+ default:
+ {
+ // Unhandled message.
+ *command_id = id_unhandled;
+ break;
+ }
+ }
+ // DO NOT call raw_hid_send(data,length) here, let caller do this
+}
+#endif
//
// In the case of VIA being disabled, we still need to check if