VIA V3 - The Custom UI Update (#18222)
This commit is contained in:
parent
575b0e33fa
commit
bc6f8dc8b0
68 changed files with 751 additions and 886 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
133
keyboards/wilba_tech/via_test.c
Normal file
133
keyboards/wilba_tech/via_test.c
Normal file
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
if ( *channel_id == id_custom_channel ) {
|
||||
switch ( *command_id )
|
||||
{
|
||||
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:
|
||||
{
|
||||
// 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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue