Fix the state transfer of the test LED.
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
#define LOGIC_LED_ON 0U
|
||||
#define LOGIC_LED_OFF 1U
|
||||
|
||||
#if UHK_PCB_MAJOR_VERSION == 7
|
||||
#if UHK_PCB_MAJOR_VERSION >= 7
|
||||
|
||||
#define TEST_LED_GPIO GPIOB
|
||||
#define TEST_LED_PORT PORTB
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
#define TEST_LED_ON() GPIO_SetPinsOutput(TEST_LED_GPIO, 1U << TEST_LED_PIN)
|
||||
#define TEST_LED_OFF() GPIO_ClearPinsOutput(TEST_LED_GPIO, 1U << TEST_LED_PIN)
|
||||
#define TEST_LED_SET(state) GPIO_WritePinOutput(TEST_LED_GPIO, TEST_LED_PIN, !(state))
|
||||
#define TEST_LED_SET(state) GPIO_WritePinOutput(TEST_LED_GPIO, TEST_LED_PIN, (state))
|
||||
#define TEST_LED_TOGGLE() GPIO_TogglePinsOutput(TEST_LED_GPIO, 1U << TEST_LED_PIN)
|
||||
|
||||
// Functions:
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
#include "bridge_slave_uhk_module.h"
|
||||
#include "bridge_protocol.h"
|
||||
#include "main.h"
|
||||
#include "peripherials/test_led.h"
|
||||
|
||||
uhk_module_state_t UhkModuleStates[UHK_MODULE_MAX_COUNT];
|
||||
uhk_module_field_t currentUhkModuleField = UhkModuleField_SendKeystatesRequestCommand;
|
||||
uhk_module_state_t uhkModuleExternalStates[UHK_MODULE_MAX_COUNT];
|
||||
uint8_t txBuffer[2];
|
||||
@@ -11,6 +13,7 @@ uint8_t txBuffer[2];
|
||||
bool BridgeSlaveUhkModuleHandler(uint8_t uhkModuleId) {
|
||||
uhk_module_state_t *uhkModuleInternalState = UhkModuleStates + uhkModuleId;
|
||||
uhk_module_state_t *uhkModuleExternalState = uhkModuleExternalStates + uhkModuleId;
|
||||
uhkModuleInternalState->ledPwmBrightness = 0xff;
|
||||
|
||||
switch (currentUhkModuleField) {
|
||||
case UhkModuleField_SendKeystatesRequestCommand:
|
||||
@@ -24,13 +27,13 @@ bool BridgeSlaveUhkModuleHandler(uint8_t uhkModuleId) {
|
||||
break;
|
||||
case UhkModuleField_SendPwmBrightnessCommand:
|
||||
txBuffer[0] = BridgeCommand_SetLedPwmBrightness;
|
||||
txBuffer[1] = uhkModuleExternalState->ledPwmBrightness;
|
||||
txBuffer[1] = uhkModuleInternalState->ledPwmBrightness;
|
||||
I2cAsyncWrite(I2C_ADDRESS_LEFT_KEYBOARD_HALF, txBuffer, 2);
|
||||
currentUhkModuleField = UhkModuleField_SendTestLedCommand;
|
||||
break;
|
||||
case UhkModuleField_SendTestLedCommand:
|
||||
txBuffer[0] = BridgeCommand_SetTestLed;
|
||||
txBuffer[1] = uhkModuleExternalState->isTestLedOn;
|
||||
txBuffer[1] = uhkModuleInternalState->isTestLedOn;
|
||||
I2cAsyncWrite(I2C_ADDRESS_LEFT_KEYBOARD_HALF, txBuffer, 2);
|
||||
currentUhkModuleField = UhkModuleField_SendKeystatesRequestCommand;
|
||||
break;
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
// Variables:
|
||||
|
||||
uhk_module_state_t UhkModuleStates[UHK_MODULE_MAX_COUNT];
|
||||
extern uhk_module_state_t UhkModuleStates[UHK_MODULE_MAX_COUNT];
|
||||
|
||||
// Functions:
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#define TEST_LED_ON() GPIO_SetPinsOutput(TEST_LED_GPIO, 1U << TEST_LED_GPIO_PIN)
|
||||
#define TEST_LED_OFF() GPIO_ClearPinsOutput(TEST_LED_GPIO, 1U << TEST_LED_GPIO_PIN)
|
||||
#define TEST_LED_SET(state) GPIO_WritePinOutput(TEST_LED_GPIO, TEST_LED_GPIO_PIN, (state))
|
||||
#define TEST_LED_TOGGLE() GPIO_TogglePinsOutput(TEST_LED_GPIO, 1U << TEST_LED_GPIO_PIN)
|
||||
|
||||
// Functions:
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "config_buffer.h"
|
||||
#include "led_pwm.h"
|
||||
#include "bridge_protocol_scheduler.h"
|
||||
#include "bridge_slaves/bridge_slave_uhk_module.h"
|
||||
|
||||
void setError(uint8_t error);
|
||||
void setGenericError();
|
||||
@@ -120,18 +121,8 @@ void jumpToBootloader() {
|
||||
void getSetTestLed()
|
||||
{
|
||||
uint8_t ledState = GenericHidInBuffer[1];
|
||||
// uint8_t data[] = {1, ledState};
|
||||
// I2cWrite(I2C_MAIN_BUS_BASEADDR, I2C_ADDRESS_LEFT_KEYBOARD_HALF, data, sizeof(data));
|
||||
|
||||
switch (ledState) {
|
||||
case 0:
|
||||
TEST_LED_ON();
|
||||
break;
|
||||
case 1:
|
||||
TEST_LED_OFF();
|
||||
break;
|
||||
}
|
||||
SetLeds(ledState ? 0xff : 0);
|
||||
TEST_LED_SET(ledState);
|
||||
UhkModuleStates[0].isTestLedOn = ledState;
|
||||
}
|
||||
|
||||
void writeLedDriver()
|
||||
@@ -215,8 +206,7 @@ void setLedPwm()
|
||||
if (isRightKeyboardHalf) {
|
||||
LedPwm_SetBrightness(brightnessPercent);
|
||||
} else {
|
||||
uint8_t data[] = {2, brightnessPercent};
|
||||
I2cWrite(I2C_MAIN_BUS_BASEADDR, I2C_ADDRESS_LEFT_KEYBOARD_HALF, data, sizeof(data));
|
||||
UhkModuleStates[0].ledPwmBrightness = brightnessPercent;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user