diff options
author | Wilba <wilba@wilba.tech> | 2022-11-10 07:46:44 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-10 07:46:44 +1100 |
commit | bc6f8dc8b0822e5e03893eacffa42a7badb4c2fa (patch) | |
tree | b1e8a219803f30b7347e479734a5c6e7352a5f30 /keyboards/wilba_tech | |
parent | 575b0e33fa47034f5cfaf6f7cd98570268efa0a2 (diff) |
VIA V3 - The Custom UI Update (#18222)
Diffstat (limited to 'keyboards/wilba_tech')
25 files changed, 175 insertions, 92 deletions
diff --git a/keyboards/wilba_tech/rama_works_kara/config.h b/keyboards/wilba_tech/rama_works_kara/config.h index 7c9489e922..d713c41bb9 100644 --- a/keyboards/wilba_tech/rama_works_kara/config.h +++ b/keyboards/wilba_tech/rama_works_kara/config.h @@ -108,6 +108,3 @@ // Backlight config starts after VIA's EEPROM usage, // dynamic keymaps start after this. #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 - -// VIA lighting is handled by the keyboard-level code -#define VIA_CUSTOM_LIGHTING_ENABLE diff --git a/keyboards/wilba_tech/rama_works_koyu/config.h b/keyboards/wilba_tech/rama_works_koyu/config.h index 9b5048d11a..de2d4aafba 100644 --- a/keyboards/wilba_tech/rama_works_koyu/config.h +++ b/keyboards/wilba_tech/rama_works_koyu/config.h @@ -109,6 +109,3 @@ // Backlight config starts after VIA's EEPROM usage, // dynamic keymaps start after this. #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 - -// VIA lighting is handled by the keyboard-level code -#define VIA_CUSTOM_LIGHTING_ENABLE diff --git a/keyboards/wilba_tech/rama_works_m10_c/config.h b/keyboards/wilba_tech/rama_works_m10_c/config.h index 456023d414..9c893ac1b3 100644 --- a/keyboards/wilba_tech/rama_works_m10_c/config.h +++ b/keyboards/wilba_tech/rama_works_m10_c/config.h @@ -103,6 +103,3 @@ // Backlight config starts after VIA's EEPROM usage, // dynamic keymaps start after this. #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 51 - -// VIA lighting is handled by the keyboard-level code -#define VIA_CUSTOM_LIGHTING_ENABLE diff --git a/keyboards/wilba_tech/rama_works_m50_a/config.h b/keyboards/wilba_tech/rama_works_m50_a/config.h index 6284a4027a..47d47fae18 100644 --- a/keyboards/wilba_tech/rama_works_m50_a/config.h +++ b/keyboards/wilba_tech/rama_works_m50_a/config.h @@ -101,6 +101,3 @@ // Backlight config starts after VIA's EEPROM usage, // dynamic keymaps start after this. #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 - -// VIA lighting is handled by the keyboard-level code -#define VIA_CUSTOM_LIGHTING_ENABLE diff --git a/keyboards/wilba_tech/rama_works_m60_a/config.h b/keyboards/wilba_tech/rama_works_m60_a/config.h index 22abe6ee60..05f12caaf2 100644 --- a/keyboards/wilba_tech/rama_works_m60_a/config.h +++ b/keyboards/wilba_tech/rama_works_m60_a/config.h @@ -108,6 +108,3 @@ // Backlight config starts after VIA's EEPROM usage, // dynamic keymaps start after this. #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 - -// VIA lighting is handled by the keyboard-level code -#define VIA_CUSTOM_LIGHTING_ENABLE diff --git a/keyboards/wilba_tech/rama_works_m65_b/config.h b/keyboards/wilba_tech/rama_works_m65_b/config.h index 1982b2e8e1..ba99a20f97 100644 --- a/keyboards/wilba_tech/rama_works_m65_b/config.h +++ b/keyboards/wilba_tech/rama_works_m65_b/config.h @@ -101,6 +101,3 @@ // Backlight config starts after VIA's EEPROM usage, // dynamic keymaps start after this. #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 - -// VIA lighting is handled by the keyboard-level code -#define VIA_CUSTOM_LIGHTING_ENABLE diff --git a/keyboards/wilba_tech/rama_works_m65_bx/config.h b/keyboards/wilba_tech/rama_works_m65_bx/config.h index 83c2be2001..7e2a0ce122 100644 --- a/keyboards/wilba_tech/rama_works_m65_bx/config.h +++ b/keyboards/wilba_tech/rama_works_m65_bx/config.h @@ -101,6 +101,3 @@ // Backlight config starts after VIA's EEPROM usage, // dynamic keymaps start after this. #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 - -// VIA lighting is handled by the keyboard-level code -#define VIA_CUSTOM_LIGHTING_ENABLE diff --git a/keyboards/wilba_tech/rama_works_m6_a/config.h b/keyboards/wilba_tech/rama_works_m6_a/config.h index d77613628e..e964bcf21b 100644 --- a/keyboards/wilba_tech/rama_works_m6_a/config.h +++ b/keyboards/wilba_tech/rama_works_m6_a/config.h @@ -100,6 +100,3 @@ // Backlight config starts after VIA's EEPROM usage, // dynamic keymaps start after this. #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 43 - -// VIA lighting is handled by the keyboard-level code -#define VIA_CUSTOM_LIGHTING_ENABLE diff --git a/keyboards/wilba_tech/rama_works_m6_b/config.h b/keyboards/wilba_tech/rama_works_m6_b/config.h index d6978c8a16..9f29bcb38a 100644 --- a/keyboards/wilba_tech/rama_works_m6_b/config.h +++ b/keyboards/wilba_tech/rama_works_m6_b/config.h @@ -143,6 +143,3 @@ // Backlight config starts after VIA's EEPROM usage, // dynamic keymaps start after this. #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 43 - -// VIA lighting is handled by the keyboard-level code -#define VIA_CUSTOM_LIGHTING_ENABLE diff --git a/keyboards/wilba_tech/rama_works_u80_a/config.h b/keyboards/wilba_tech/rama_works_u80_a/config.h index 4653556190..9cfc23c8f8 100644 --- a/keyboards/wilba_tech/rama_works_u80_a/config.h +++ b/keyboards/wilba_tech/rama_works_u80_a/config.h @@ -153,6 +153,3 @@ // Backlight config starts after VIA's EEPROM usage, // dynamic keymaps start after this. #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 - -// VIA lighting is handled by the keyboard-level code -#define VIA_CUSTOM_LIGHTING_ENABLE diff --git a/keyboards/wilba_tech/via_test.c b/keyboards/wilba_tech/via_test.c new file mode 100644 index 0000000000..6a74df5164 --- /dev/null +++ b/keyboards/wilba_tech/via_test.c @@ -0,0 +1,133 @@ +// Copyright 2022 Jason Williams (@wilba) +// SPDX-License-Identifier: GPL-2.0-or-later + +// This is a test harness for VIA custom UI. +// +// It handles channel IDs 0-7, value IDs 0-7. +// +// It's useful for testing custom UI on a PCB without compiling in +// features, especially features that will cause firmware to freeze +// if the PCB doesn't have support. +// +// To use: +// - add `SRC = keyboards/wilba_tech/via_test.c` to rules.mk +// - add `#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 128` to config.h +// (or change to match CHANNELS*VALUES*2) + +#include "quantum.h" +#include "via.h" + +#ifdef VIA_ENABLE + +#define CHANNELS 8 +#define VALUES 8 +uint8_t g_value[CHANNELS][VALUES][2]; + +void values_init(void) +{ + for ( uint8_t channel_id = 0; channel_id < CHANNELS; channel_id++ ) { + for ( uint8_t value_id = 0; value_id < VALUES; value_id++ ) { + g_value[channel_id][value_id][0] = 0x00; + g_value[channel_id][value_id][1] = 0x00; + } + } +} + +void values_load(void) +{ + eeprom_read_block( g_value, ((void*)VIA_EEPROM_CUSTOM_CONFIG_ADDR), VIA_EEPROM_CUSTOM_CONFIG_SIZE ); +} + +void values_save(void) +{ + eeprom_update_block( g_value, ((void*)VIA_EEPROM_CUSTOM_CONFIG_ADDR), VIA_EEPROM_CUSTOM_CONFIG_SIZE ); +} + +// We do this to test if VIA is sending save commands per channel +// Not relevant for real situations +void values_save_on_channel(uint8_t channel_id) +{ + uint16_t offset = channel_id * VALUES * 2; + eeprom_update_block( ((void*)g_value) + offset, + ((void*)VIA_EEPROM_CUSTOM_CONFIG_ADDR) + offset, + VALUES * 2 ); +} + +void via_init_kb(void) +{ + values_init(); + + // If the EEPROM has the magic, the data is good. + // OK to load from EEPROM + if (via_eeprom_is_valid()) { + values_load(); + } else { + values_save(); + // DO NOT set EEPROM valid here, let caller do this + } +} + +void set_value( uint8_t channel_id, uint8_t *data ) +{ + // data = [ value_id, value_data ] + uint8_t *value_id = &(data[0]); + uint8_t *value_data = &(data[1]); + if ( *value_id >= 0 && *value_id < VALUES ) { + g_value[channel_id][*value_id][0] = value_data[0]; + g_value[channel_id][*value_id][1] = value_data[1]; + } +} + +void get_value( uint8_t channel_id, uint8_t *data ) +{ + // data = [ value_id, value_data ] + uint8_t *value_id = &(data[0]); + uint8_t *value_data = &(data[1]); + if ( *value_id >= 0 && *value_id < VALUES ) { + value_data[0] = g_value[channel_id][*value_id][0]; + value_data[1] = g_value[channel_id][*value_id][1]; + } +} + +void via_custom_value_command(uint8_t *data, uint8_t length) { + // data = [ command_id, channel_id, value_id, value_data ] + uint8_t *command_id = &(data[0]); + uint8_t *channel_id = &(data[1]); + uint8_t *value_id_and_data = &(data[2]); + + if ( *channel_id >= 0 && *channel_id < CHANNELS ) { + switch ( *command_id ) + { + case id_custom_set_value: + { + set_value(*channel_id,value_id_and_data); + break; + } + case id_custom_get_value: + { + get_value(*channel_id,value_id_and_data); + break; + } + case id_custom_save: + { + //for ( uint8_t i=0; i<CHANNELS; i++) { + values_save_on_channel(*channel_id); + //} + break; + } + default: + { + // Unhandled message. + *command_id = id_unhandled; + break; + } + } + return; + } + else { + *command_id = id_unhandled; + } + + // DO NOT call raw_hid_send(data,length) here, let caller do this +} +#endif // VIA_ENABLE
\ No newline at end of file diff --git a/keyboards/wilba_tech/wt60_a/config.h b/keyboards/wilba_tech/wt60_a/config.h index c2b85fee76..c9079bcb83 100644 --- a/keyboards/wilba_tech/wt60_a/config.h +++ b/keyboards/wilba_tech/wt60_a/config.h @@ -121,6 +121,3 @@ // Backlight config starts after VIA's EEPROM usage, // dynamic keymaps start after this. #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7 - -// VIA lighting is handled by the keyboard-level code -#define VIA_CUSTOM_LIGHTING_ENABLE diff --git a/keyboards/wilba_tech/wt60_b/config.h b/keyboards/wilba_tech/wt60_b/config.h index 43a10844da..2ae153b13f 100644 --- a/keyboards/wilba_tech/wt60_b/config.h +++ b/keyboards/wilba_tech/wt60_b/config.h @@ -104,6 +104,3 @@ // Backlight config starts after VIA's EEPROM usage, // dynamic keymaps start after this. #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 - -// VIA lighting is handled by the keyboard-level code -#define VIA_CUSTOM_LIGHTING_ENABLE diff --git a/keyboards/wilba_tech/wt60_bx/config.h b/keyboards/wilba_tech/wt60_bx/config.h index d26b3a02ba..75d0bfbf42 100644 --- a/keyboards/wilba_tech/wt60_bx/config.h +++ b/keyboards/wilba_tech/wt60_bx/config.h @@ -104,6 +104,3 @@ // Backlight config starts after VIA's EEPROM usage, // dynamic keymaps start after this. #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 - -// VIA lighting is handled by the keyboard-level code -#define VIA_CUSTOM_LIGHTING_ENABLE diff --git a/keyboards/wilba_tech/wt60_c/config.h b/keyboards/wilba_tech/wt60_c/config.h index 489207d56c..85beba49c7 100644 --- a/keyboards/wilba_tech/wt60_c/config.h +++ b/keyboards/wilba_tech/wt60_c/config.h @@ -105,6 +105,3 @@ // Backlight config starts after VIA's EEPROM usage, // dynamic keymaps start after this. #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 - -// VIA lighting is handled by the keyboard-level code -#define VIA_CUSTOM_LIGHTING_ENABLE diff --git a/keyboards/wilba_tech/wt60_xt/wt60_xt.c b/keyboards/wilba_tech/wt60_xt/wt60_xt.c index f575b032df..4413140513 100644 --- a/keyboards/wilba_tech/wt60_xt/wt60_xt.c +++ b/keyboards/wilba_tech/wt60_xt/wt60_xt.c @@ -26,6 +26,7 @@ float tone_numlk_on[][2] = SONG(NUM_LOCK_ON_SOUND); float tone_numlk_off[][2] = SONG(NUM_LOCK_OFF_SOUND); float tone_scroll_on[][2] = SONG(SCROLL_LOCK_ON_SOUND); float tone_scroll_off[][2] = SONG(SCROLL_LOCK_OFF_SOUND); +float tone_device_indication[][2] = SONG(FANTASIE_IMPROMPTU); #endif @@ -95,3 +96,9 @@ bool led_update_kb(led_t led_state) { return true; } + +void via_set_device_indication(uint8_t value) { + if ( value == 0 ) { + PLAY_SONG(tone_device_indication); + } +}
\ No newline at end of file diff --git a/keyboards/wilba_tech/wt65_a/config.h b/keyboards/wilba_tech/wt65_a/config.h index 062e2d8564..0d8dd5a0d1 100644 --- a/keyboards/wilba_tech/wt65_a/config.h +++ b/keyboards/wilba_tech/wt65_a/config.h @@ -121,6 +121,3 @@ // Backlight config starts after VIA's EEPROM usage, // dynamic keymaps start after this. #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7 - -// VIA lighting is handled by the keyboard-level code -#define VIA_CUSTOM_LIGHTING_ENABLE diff --git a/keyboards/wilba_tech/wt65_b/config.h b/keyboards/wilba_tech/wt65_b/config.h index 8320daef0a..4bfbcdcb08 100644 --- a/keyboards/wilba_tech/wt65_b/config.h +++ b/keyboards/wilba_tech/wt65_b/config.h @@ -121,6 +121,3 @@ // Backlight config starts after VIA's EEPROM usage, // dynamic keymaps start after this. #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7 - -// VIA lighting is handled by the keyboard-level code -#define VIA_CUSTOM_LIGHTING_ENABLE diff --git a/keyboards/wilba_tech/wt75_a/config.h b/keyboards/wilba_tech/wt75_a/config.h index 415774aa17..627069ca09 100644 --- a/keyboards/wilba_tech/wt75_a/config.h +++ b/keyboards/wilba_tech/wt75_a/config.h @@ -121,6 +121,3 @@ // Backlight config starts after VIA's EEPROM usage, // dynamic keymaps start after this. #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7 - -// VIA lighting is handled by the keyboard-level code -#define VIA_CUSTOM_LIGHTING_ENABLE diff --git a/keyboards/wilba_tech/wt75_b/config.h b/keyboards/wilba_tech/wt75_b/config.h index 98b3d937f9..6d2c9fa17c 100644 --- a/keyboards/wilba_tech/wt75_b/config.h +++ b/keyboards/wilba_tech/wt75_b/config.h @@ -121,6 +121,3 @@ // Backlight config starts after VIA's EEPROM usage, // dynamic keymaps start after this. #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7 - -// VIA lighting is handled by the keyboard-level code -#define VIA_CUSTOM_LIGHTING_ENABLE diff --git a/keyboards/wilba_tech/wt75_c/config.h b/keyboards/wilba_tech/wt75_c/config.h index d8cf5a1a95..fcaa9622d4 100644 --- a/keyboards/wilba_tech/wt75_c/config.h +++ b/keyboards/wilba_tech/wt75_c/config.h @@ -121,6 +121,3 @@ // Backlight config starts after VIA's EEPROM usage, // dynamic keymaps start after this. #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7 - -// VIA lighting is handled by the keyboard-level code -#define VIA_CUSTOM_LIGHTING_ENABLE diff --git a/keyboards/wilba_tech/wt80_a/config.h b/keyboards/wilba_tech/wt80_a/config.h index 2bc81b2fa5..500d4bc797 100644 --- a/keyboards/wilba_tech/wt80_a/config.h +++ b/keyboards/wilba_tech/wt80_a/config.h @@ -121,6 +121,3 @@ // Backlight config starts after VIA's EEPROM usage, // dynamic keymaps start after this. #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7 - -// VIA lighting is handled by the keyboard-level code -#define VIA_CUSTOM_LIGHTING_ENABLE diff --git a/keyboards/wilba_tech/wt_main.c b/keyboards/wilba_tech/wt_main.c index bc1a1d3c87..3f89066a6c 100644 --- a/keyboards/wilba_tech/wt_main.c +++ b/keyboards/wilba_tech/wt_main.c @@ -132,36 +132,45 @@ void suspend_wakeup_init_kb(void) // Moving this to the bottom of this source file is a workaround // for an intermittent compiler error for Atmel compiler. #ifdef VIA_ENABLE -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 ) - { +void via_custom_value_command_kb(uint8_t *data, uint8_t length) { + uint8_t *command_id = &(data[0]); + uint8_t *channel_id = &(data[1]); + uint8_t *value_id_and_data = &(data[2]); + #if RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED - case id_lighting_set_value: - { - backlight_config_set_value(command_data); - break; - } - case id_lighting_get_value: - { - backlight_config_get_value(command_data); - break; - } - case id_lighting_save: - { - backlight_config_save(); - break; - } -#endif // RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED - default: + if ( *channel_id == id_custom_channel ) { + switch ( *command_id ) { - // Unhandled message. - *command_id = id_unhandled; - *command_data = *command_data; // force use of variable - break; + case id_custom_set_value: + { + backlight_config_set_value(value_id_and_data); + break; + } + case id_custom_get_value: + { + backlight_config_get_value(value_id_and_data); + break; + } + case id_custom_save: + { + backlight_config_save(); + break; + } + default: + { + // Unhandled message. + *command_id = id_unhandled; + break; + } } + return; } +#else + *command_id = id_unhandled; + *channel_id = *channel_id; // force use of variable + *value_id_and_data = *value_id_and_data; // force use of variable +#endif // RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED + // DO NOT call raw_hid_send(data,length) here, let caller do this } #endif // VIA_ENABLE diff --git a/keyboards/wilba_tech/zeal60/config.h b/keyboards/wilba_tech/zeal60/config.h index eaf7b76504..94a8a599f4 100644 --- a/keyboards/wilba_tech/zeal60/config.h +++ b/keyboards/wilba_tech/zeal60/config.h @@ -107,6 +107,3 @@ // Backlight config starts after VIA's EEPROM usage, // dynamic keymaps start after this. #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 - -// VIA lighting is handled by the keyboard-level code -#define VIA_CUSTOM_LIGHTING_ENABLE diff --git a/keyboards/wilba_tech/zeal65/config.h b/keyboards/wilba_tech/zeal65/config.h index d5e83a11e3..4cbd12c0a5 100644 --- a/keyboards/wilba_tech/zeal65/config.h +++ b/keyboards/wilba_tech/zeal65/config.h @@ -107,6 +107,3 @@ // Backlight config starts after VIA's EEPROM usage, // dynamic keymaps start after this. #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 - -// VIA lighting is handled by the keyboard-level code -#define VIA_CUSTOM_LIGHTING_ENABLE |