aboutsummaryrefslogtreecommitdiffstats
path: root/keyboards/cannonkeys
diff options
context:
space:
mode:
authorWilba <Jason.S.Williams@gmail.com>2020-01-21 05:18:25 +1100
committerMechMerlin <30334081+mechmerlin@users.noreply.github.com>2020-01-20 10:18:25 -0800
commit484a9b12bc3961fc0dd9481d3cb734959db42191 (patch)
treeca2e4219b6514c1033be3ab3a975bd24f723f2ba /keyboards/cannonkeys
parentce81c4f89b61560ee35436b351b27fd23568c32f (diff)
downloadfirmware-484a9b12bc3961fc0dd9481d3cb734959db42191.tar.gz
firmware-484a9b12bc3961fc0dd9481d3cb734959db42191.tar.bz2
firmware-484a9b12bc3961fc0dd9481d3cb734959db42191.zip
Add VIA support for QMK backlight, QMK RGBLight (#7911)
* Add VIA support for QMK backlight, QMK RGBLight * clang-format changes
Diffstat (limited to 'keyboards/cannonkeys')
-rw-r--r--keyboards/cannonkeys/an_c/config.h6
-rw-r--r--keyboards/cannonkeys/instant60/config.h6
-rw-r--r--keyboards/cannonkeys/iron165/config.h3
-rw-r--r--keyboards/cannonkeys/satisfaction75/config.h3
-rw-r--r--keyboards/cannonkeys/satisfaction75/led_custom.h2
-rw-r--r--keyboards/cannonkeys/satisfaction75/satisfaction75.c63
-rw-r--r--keyboards/cannonkeys/savage65/config.h6
-rw-r--r--keyboards/cannonkeys/stm32f072/keyboard.c78
-rw-r--r--keyboards/cannonkeys/stm32f072/led_custom.h2
-rw-r--r--keyboards/cannonkeys/tmov2/config.h6
10 files changed, 175 insertions, 0 deletions
diff --git a/keyboards/cannonkeys/an_c/config.h b/keyboards/cannonkeys/an_c/config.h
index 55414ba50..6390e0789 100644
--- a/keyboards/cannonkeys/an_c/config.h
+++ b/keyboards/cannonkeys/an_c/config.h
@@ -62,6 +62,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 1
+// VIA lighting is handled by the keyboard-level code
+#define VIA_CUSTOM_LIGHTING_ENABLE
+
+// Let VIA handle the QMK RGBLIGHT
+#define VIA_QMK_RGBLIGHT_ENABLE
+
/*
* Feature disable options
* These options are also useful to firmware size reduction.
diff --git a/keyboards/cannonkeys/instant60/config.h b/keyboards/cannonkeys/instant60/config.h
index 2d23d5f83..4fa76cb88 100644
--- a/keyboards/cannonkeys/instant60/config.h
+++ b/keyboards/cannonkeys/instant60/config.h
@@ -62,6 +62,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 1
+// VIA lighting is handled by the keyboard-level code
+#define VIA_CUSTOM_LIGHTING_ENABLE
+
+// Let VIA handle the QMK RGBLIGHT
+#define VIA_QMK_RGBLIGHT_ENABLE
+
/*
* Feature disable options
* These options are also useful to firmware size reduction.
diff --git a/keyboards/cannonkeys/iron165/config.h b/keyboards/cannonkeys/iron165/config.h
index 640f6fb65..6350514d7 100644
--- a/keyboards/cannonkeys/iron165/config.h
+++ b/keyboards/cannonkeys/iron165/config.h
@@ -54,6 +54,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 1
+// VIA lighting is handled by the keyboard-level code
+#define VIA_CUSTOM_LIGHTING_ENABLE
+
/*
* Feature disable options
* These options are also useful to firmware size reduction.
diff --git a/keyboards/cannonkeys/satisfaction75/config.h b/keyboards/cannonkeys/satisfaction75/config.h
index 7a4354c8a..69d02806e 100644
--- a/keyboards/cannonkeys/satisfaction75/config.h
+++ b/keyboards/cannonkeys/satisfaction75/config.h
@@ -73,6 +73,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// 6 for 3x custom encoder settings, left, right, and press (18 bytes)
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 21
+// VIA lighting is handled by the keyboard-level code
+#define VIA_CUSTOM_LIGHTING_ENABLE
+
/*
* Feature disable options
* These options are also useful to firmware size reduction.
diff --git a/keyboards/cannonkeys/satisfaction75/led_custom.h b/keyboards/cannonkeys/satisfaction75/led_custom.h
index fe5c9e5dc..d818b48ce 100644
--- a/keyboards/cannonkeys/satisfaction75/led_custom.h
+++ b/keyboards/cannonkeys/satisfaction75/led_custom.h
@@ -3,3 +3,5 @@
void backlight_task(void);
void breathing_interrupt_disable(void);
void breathing_interrupt_enable(void);
+void breathing_enable(void);
+void breathing_disable(void);
diff --git a/keyboards/cannonkeys/satisfaction75/satisfaction75.c b/keyboards/cannonkeys/satisfaction75/satisfaction75.c
index 0fe09c384..f92067c98 100644
--- a/keyboards/cannonkeys/satisfaction75/satisfaction75.c
+++ b/keyboards/cannonkeys/satisfaction75/satisfaction75.c
@@ -55,6 +55,54 @@ backlight_config_t kb_backlight_config = {
};
#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]);
@@ -139,6 +187,21 @@ void raw_hid_receive_kb( uint8_t *data, uint8_t length )
}
break;
}
+ 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.
diff --git a/keyboards/cannonkeys/savage65/config.h b/keyboards/cannonkeys/savage65/config.h
index b69aba39e..98ec1067a 100644
--- a/keyboards/cannonkeys/savage65/config.h
+++ b/keyboards/cannonkeys/savage65/config.h
@@ -62,6 +62,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 1
+// VIA lighting is handled by the keyboard-level code
+#define VIA_CUSTOM_LIGHTING_ENABLE
+
+// Let VIA handle the QMK RGBLIGHT
+#define VIA_QMK_RGBLIGHT_ENABLE
+
/*
* Feature disable options
* These options are also useful to firmware size reduction.
diff --git a/keyboards/cannonkeys/stm32f072/keyboard.c b/keyboards/cannonkeys/stm32f072/keyboard.c
index bf35a76c1..fdda018fc 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
diff --git a/keyboards/cannonkeys/stm32f072/led_custom.h b/keyboards/cannonkeys/stm32f072/led_custom.h
index 28e0f02ed..550d5b84c 100644
--- a/keyboards/cannonkeys/stm32f072/led_custom.h
+++ b/keyboards/cannonkeys/stm32f072/led_custom.h
@@ -4,3 +4,5 @@ void backlight_task(void);
void breathing_interrupt_disable(void);
void breathing_interrupt_enable(void);
void breathing_toggle(void);
+void breathing_enable(void);
+void breathing_disable(void);
diff --git a/keyboards/cannonkeys/tmov2/config.h b/keyboards/cannonkeys/tmov2/config.h
index d5f1d0788..159382fbc 100644
--- a/keyboards/cannonkeys/tmov2/config.h
+++ b/keyboards/cannonkeys/tmov2/config.h
@@ -62,6 +62,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 1
+// VIA lighting is handled by the keyboard-level code
+#define VIA_CUSTOM_LIGHTING_ENABLE
+
+// Let VIA handle the QMK RGBLIGHT
+#define VIA_QMK_RGBLIGHT_ENABLE
+
/*
* Feature disable options
* These options are also useful to firmware size reduction.