From 45420a348b4d6903bf0038c05b19e51c43c32371 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Sun, 5 Nov 2017 18:08:35 +0100 Subject: [PATCH] Extract UsbCommand_SetLedPwmBrightness() into its own file. --- .../usb_command_set_led_pwm_brightness.c | 10 ++++++++++ .../usb_command_set_led_pwm_brightness.h | 8 ++++++++ right/src/usb_protocol_handler.c | 14 +++----------- right/src/usb_protocol_handler.h | 2 +- 4 files changed, 22 insertions(+), 12 deletions(-) create mode 100644 right/src/usb_commands/usb_command_set_led_pwm_brightness.c create mode 100644 right/src/usb_commands/usb_command_set_led_pwm_brightness.h diff --git a/right/src/usb_commands/usb_command_set_led_pwm_brightness.c b/right/src/usb_commands/usb_command_set_led_pwm_brightness.c new file mode 100644 index 0000000..2320d81 --- /dev/null +++ b/right/src/usb_commands/usb_command_set_led_pwm_brightness.c @@ -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; +} diff --git a/right/src/usb_commands/usb_command_set_led_pwm_brightness.h b/right/src/usb_commands/usb_command_set_led_pwm_brightness.h new file mode 100644 index 0000000..48a9ac1 --- /dev/null +++ b/right/src/usb_commands/usb_command_set_led_pwm_brightness.h @@ -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 diff --git a/right/src/usb_protocol_handler.c b/right/src/usb_protocol_handler.c index 22f1b11..43b5807 100644 --- a/right/src/usb_protocol_handler.c +++ b/right/src/usb_protocol_handler.c @@ -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(); diff --git a/right/src/usb_protocol_handler.h b/right/src/usb_protocol_handler.h index 5bc82ff..b5b9cf9 100644 --- a/right/src/usb_protocol_handler.h +++ b/right/src/usb_protocol_handler.h @@ -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,