Extract UsbCommand_SetLedPwmBrightness() into its own file.

This commit is contained in:
László Monda
2017-11-05 18:08:35 +01:00
parent 84ffe50dac
commit 45420a348b
4 changed files with 22 additions and 12 deletions

View File

@@ -0,0 +1,10 @@
#include "usb_protocol_handler.h"
#include "slave_drivers/uhk_module_driver.h"
#include "led_pwm.h"
void UsbCommand_SetLedPwmBrightness(void)
{
uint8_t brightnessPercent = GenericHidInBuffer[1];
LedPwm_SetBrightness(brightnessPercent);
UhkModuleStates[UhkModuleDriverId_LeftKeyboardHalf].sourceVars.ledPwmBrightness = brightnessPercent;
}

View File

@@ -0,0 +1,8 @@
#ifndef __USB_COMMAND_SET_LED_PWM_BRIGHTNESS_H__
#define __USB_COMMAND_SET_LED_PWM_BRIGHTNESS_H__
// Functions:
void UsbCommand_SetLedPwmBrightness(void);
#endif

View File

@@ -27,6 +27,7 @@
#include "usb_commands/usb_command_reenumerate.h"
#include "usb_commands/usb_command_set_test_led.h"
#include "usb_commands/usb_command_get_adc_value.h"
#include "usb_commands/usb_command_set_led_pwm_brightness.h"
uint8_t UsbDebugInfo[USB_GENERIC_HID_OUT_BUFFER_LENGTH];
@@ -47,15 +48,6 @@ void SetUsbResponseWord(uint16_t response)
*((uint16_t*)(GenericHidOutBuffer+1)) = response;
}
// Per command protocol command handlers
void setLedPwm(void)
{
uint8_t brightnessPercent = GenericHidInBuffer[1];
LedPwm_SetBrightness(brightnessPercent);
UhkModuleStates[UhkModuleDriverId_LeftKeyboardHalf].sourceVars.ledPwmBrightness = brightnessPercent;
}
// The main protocol handler function
void UsbProtocolHandler(void)
@@ -80,8 +72,8 @@ void UsbProtocolHandler(void)
case UsbCommandId_ApplyConfig:
UsbCommand_ApplyConfig();
break;
case UsbCommandId_SetLedPwm:
setLedPwm();
case UsbCommandId_SetLedPwmBrightness:
UsbCommand_SetLedPwmBrightness();
break;
case UsbCommandId_GetAdcValue:
UsbCommand_GetAdcValue();

View File

@@ -14,7 +14,7 @@
UsbCommandId_WriteLedDriver = 3,
UsbCommandId_WriteUserConfiguration = 8,
UsbCommandId_ApplyConfig = 9,
UsbCommandId_SetLedPwm = 10,
UsbCommandId_SetLedPwmBrightness = 10,
UsbCommandId_GetAdcValue = 11,
UsbCommandId_LaunchEepromTransferLegacy = 12,
UsbCommandId_ReadHardwareConfiguration = 13,