Merge UhkModuleVars into uhkModuleStates. Also make uhkModuleStates globally accessible because it must be accessed by other parts of the firmware, so it's unpractical to keep it private and write accessor functions for it.
This commit is contained in:
@@ -8,9 +8,8 @@
|
||||
#include "bool_array_converter.h"
|
||||
#include "crc16.h"
|
||||
|
||||
uhk_module_vars_t UhkModuleVars[UHK_MODULE_MAX_COUNT];
|
||||
uhk_module_state_t uhkModuleStates[UHK_MODULE_MAX_COUNT];
|
||||
|
||||
static uhk_module_state_t uhkModuleStates[UHK_MODULE_MAX_COUNT];
|
||||
static i2c_message_t txMessage;
|
||||
|
||||
static uhk_module_i2c_addresses_t moduleIdsToI2cAddresses[] = {
|
||||
@@ -40,8 +39,8 @@ static status_t rx(i2c_message_t *rxMessage, uint8_t i2cAddress)
|
||||
|
||||
void UhkModuleSlaveDriver_Init(uint8_t uhkModuleDriverId)
|
||||
{
|
||||
uhk_module_vars_t *uhkModuleSourceVars = UhkModuleVars + uhkModuleDriverId;
|
||||
uhk_module_state_t *uhkModuleState = uhkModuleStates + uhkModuleDriverId;
|
||||
uhk_module_vars_t *uhkModuleSourceVars = &uhkModuleState->sourceVars;
|
||||
uhk_module_vars_t *uhkModuleTargetVars = &uhkModuleState->targetVars;
|
||||
|
||||
uhkModuleSourceVars->isTestLedOn = true;
|
||||
@@ -61,8 +60,8 @@ void UhkModuleSlaveDriver_Init(uint8_t uhkModuleDriverId)
|
||||
status_t UhkModuleSlaveDriver_Update(uint8_t uhkModuleDriverId)
|
||||
{
|
||||
status_t status = kStatus_Uhk_IdleSlave;
|
||||
uhk_module_vars_t *uhkModuleSourceVars = UhkModuleVars + uhkModuleDriverId;
|
||||
uhk_module_state_t *uhkModuleState = uhkModuleStates + uhkModuleDriverId;
|
||||
uhk_module_vars_t *uhkModuleSourceVars = &uhkModuleState->sourceVars;
|
||||
uhk_module_vars_t *uhkModuleTargetVars = &uhkModuleState->targetVars;
|
||||
uhk_module_phase_t *uhkModulePhase = &uhkModuleState->phase;
|
||||
uint8_t i2cAddress = uhkModuleState->firmwareI2cAddress;
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
uint8_t moduleId;
|
||||
uint8_t protocolVersion;
|
||||
uhk_module_phase_t phase;
|
||||
uhk_module_vars_t sourceVars;
|
||||
uhk_module_vars_t targetVars;
|
||||
i2c_message_t rxMessage;
|
||||
uint8_t firmwareI2cAddress;
|
||||
@@ -76,7 +77,7 @@
|
||||
|
||||
// Variables:
|
||||
|
||||
extern uhk_module_vars_t UhkModuleVars[UHK_MODULE_MAX_COUNT];
|
||||
extern uhk_module_state_t uhkModuleStates[UHK_MODULE_MAX_COUNT];
|
||||
|
||||
// Functions:
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ void setTestLed(void)
|
||||
{
|
||||
uint8_t ledState = GenericHidInBuffer[1];
|
||||
TEST_LED_SET(ledState);
|
||||
UhkModuleVars[0].isTestLedOn = ledState;
|
||||
uhkModuleStates[0].sourceVars.isTestLedOn = ledState;
|
||||
}
|
||||
|
||||
// To be removed. Now it's already part of getKeyboardState()
|
||||
@@ -147,7 +147,7 @@ void setLedPwm(void)
|
||||
{
|
||||
uint8_t brightnessPercent = GenericHidInBuffer[1];
|
||||
LedPwm_SetBrightness(brightnessPercent);
|
||||
UhkModuleVars[0].ledPwmBrightness = brightnessPercent;
|
||||
uhkModuleStates[0].sourceVars.ledPwmBrightness = brightnessPercent;
|
||||
}
|
||||
|
||||
void getAdcValue(void)
|
||||
|
||||
Reference in New Issue
Block a user