mirror of
https://github.com/qmk/qmk_firmware.git
synced 2026-09-07 10:53:17 +02:00
Fix use of via.h (#26316)
This commit is contained in:
@@ -16,13 +16,13 @@
|
|||||||
#include "ec_switch_matrix.h"
|
#include "ec_switch_matrix.h"
|
||||||
#include "action.h"
|
#include "action.h"
|
||||||
#include "print.h"
|
#include "print.h"
|
||||||
#include "via.h"
|
|
||||||
|
|
||||||
#ifdef SPLIT_KEYBOARD
|
#ifdef SPLIT_KEYBOARD
|
||||||
# include "transactions.h"
|
# include "transactions.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef VIA_ENABLE
|
#ifdef VIA_ENABLE
|
||||||
|
# include "via.h"
|
||||||
|
|
||||||
void ec_rescale_values(uint8_t item);
|
void ec_rescale_values(uint8_t item);
|
||||||
void ec_save_threshold_data(uint8_t option);
|
void ec_save_threshold_data(uint8_t option);
|
||||||
|
|||||||
@@ -17,4 +17,3 @@
|
|||||||
|
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
#include "../../wilba_tech/wt_rgb_backlight_keycodes.h"
|
#include "../../wilba_tech/wt_rgb_backlight_keycodes.h"
|
||||||
#include "via.h"
|
|
||||||
|
|||||||
@@ -17,4 +17,3 @@
|
|||||||
|
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
#include "../../wilba_tech/wt_rgb_backlight_keycodes.h"
|
#include "../../wilba_tech/wt_rgb_backlight_keycodes.h"
|
||||||
#include "via.h"
|
|
||||||
|
|||||||
@@ -17,4 +17,3 @@
|
|||||||
|
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
#include "../../wilba_tech/wt_rgb_backlight_keycodes.h"
|
#include "../../wilba_tech/wt_rgb_backlight_keycodes.h"
|
||||||
#include "via.h"
|
|
||||||
|
|||||||
@@ -17,4 +17,3 @@
|
|||||||
|
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
#include "../wilba_tech/wt_rgb_backlight_keycodes.h"
|
#include "../wilba_tech/wt_rgb_backlight_keycodes.h"
|
||||||
#include "via.h"
|
|
||||||
|
|||||||
@@ -20,10 +20,6 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "action.h"
|
#include "action.h"
|
||||||
|
|
||||||
#ifdef VIA_ENABLE
|
|
||||||
# include "via.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "quantum_keycodes.h"
|
#include "quantum_keycodes.h"
|
||||||
|
|
||||||
enum custom_keycodes {
|
enum custom_keycodes {
|
||||||
|
|||||||
@@ -17,4 +17,3 @@
|
|||||||
|
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
#include "../wilba_tech/wt_rgb_backlight_keycodes.h"
|
#include "../wilba_tech/wt_rgb_backlight_keycodes.h"
|
||||||
#include "via.h"
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
#include "quantum_keycodes.h"
|
#include "quantum_keycodes.h"
|
||||||
#include "keymap_us.h"
|
#include "keymap_us.h"
|
||||||
#include "print.h"
|
#include "print.h"
|
||||||
#include "via.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#define num_keycodes ARRAY_SIZE(lookup_table)
|
#define num_keycodes ARRAY_SIZE(lookup_table)
|
||||||
|
|||||||
@@ -20,5 +20,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
#ifdef RGB_BACKLIGHT_PORTICO
|
#ifdef RGB_BACKLIGHT_PORTICO
|
||||||
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
||||||
#include "via.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -22,5 +22,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
#ifdef RGB_BACKLIGHT_PORTICO75
|
#ifdef RGB_BACKLIGHT_PORTICO75
|
||||||
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
||||||
#include "via.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -17,4 +17,3 @@
|
|||||||
|
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
||||||
#include "via.h"
|
|
||||||
|
|||||||
@@ -18,4 +18,3 @@
|
|||||||
|
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
||||||
#include "via.h"
|
|
||||||
|
|||||||
@@ -17,4 +17,3 @@
|
|||||||
|
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
||||||
#include "via.h"
|
|
||||||
|
|||||||
@@ -17,4 +17,3 @@
|
|||||||
|
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
||||||
#include "via.h"
|
|
||||||
|
|||||||
@@ -17,4 +17,3 @@
|
|||||||
|
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
||||||
#include "via.h"
|
|
||||||
|
|||||||
@@ -18,4 +18,3 @@
|
|||||||
|
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
||||||
#include "via.h"
|
|
||||||
|
|||||||
@@ -18,4 +18,3 @@
|
|||||||
|
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
||||||
#include "via.h"
|
|
||||||
|
|||||||
@@ -18,4 +18,3 @@
|
|||||||
|
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
||||||
#include "via.h"
|
|
||||||
|
|||||||
@@ -1,132 +0,0 @@
|
|||||||
// 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 "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
|
|
||||||
@@ -18,4 +18,3 @@
|
|||||||
|
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
||||||
#include "via.h"
|
|
||||||
|
|||||||
@@ -18,4 +18,3 @@
|
|||||||
|
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
||||||
#include "via.h"
|
|
||||||
|
|||||||
@@ -18,4 +18,3 @@
|
|||||||
|
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
||||||
#include "via.h"
|
|
||||||
|
|||||||
@@ -24,9 +24,8 @@
|
|||||||
#include "keyboards/wilba_tech/wt_mono_backlight.h"
|
#include "keyboards/wilba_tech/wt_mono_backlight.h"
|
||||||
#endif // MONO_BACKLIGHT_ENABLED
|
#endif // MONO_BACKLIGHT_ENABLED
|
||||||
|
|
||||||
#include "via.h"
|
|
||||||
|
|
||||||
#ifndef VIA_ENABLE
|
#ifndef VIA_ENABLE
|
||||||
|
#include "via.h"
|
||||||
#include "eeprom.h"
|
#include "eeprom.h"
|
||||||
#include "version.h" // for QMK_BUILDDATE used in EEPROM magic
|
#include "version.h" // for QMK_BUILDDATE used in EEPROM magic
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -17,4 +17,3 @@
|
|||||||
|
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
||||||
#include "via.h"
|
|
||||||
|
|||||||
@@ -17,4 +17,3 @@
|
|||||||
|
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
||||||
#include "via.h"
|
|
||||||
|
|||||||
@@ -17,4 +17,3 @@
|
|||||||
|
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
#include "keyboards/wilba_tech/wt_rgb_backlight_keycodes.h"
|
||||||
#include "via.h"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user