change HID_RxCpltCallback position

pull/148/head
cqc 2 years ago
parent 6b5bb481d8
commit c856ed233a

@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="CMakePresetLoader"><![CDATA[{
"useNewFormat": true
}]]></component>
<component name="CMakeReloadState"> <component name="CMakeReloadState">
<option name="reloaded" value="true" /> <option name="reloaded" value="true" />
</component> </component>
@ -18,10 +21,6 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="064cb8dd-c74c-418a-a862-af96d67ded4c" name="Changes" comment=""> <list default="true" id="064cb8dd-c74c-418a-a862-af96d67ded4c" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/BSP/u8g2/cpp/U8g2lib.hpp" beforeDir="false" afterPath="$PROJECT_DIR$/BSP/u8g2/cpp/U8g2lib.hpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Ctrl/Motor/knob.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Ctrl/Motor/knob.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Ctrl/Motor/knob.h" beforeDir="false" afterPath="$PROJECT_DIR$/Ctrl/Motor/knob.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/UserApp/main.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/UserApp/main.cpp" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -59,15 +58,18 @@
</component> </component>
<component name="PropertiesComponent"><![CDATA[{ <component name="PropertiesComponent"><![CDATA[{
"keyToString": { "keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.cidr.known.project.marker": "true", "RunOnceActivity.cidr.known.project.marker": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true", "SHARE_PROJECT_CONFIGURATION_FILES": "true",
"WebServerToolWindowFactoryState": "true", "WebServerToolWindowFactoryState": "true",
"cf.first.check.clang-format": "false", "cf.first.check.clang-format": "false",
"cidr.known.project.marker": "true", "cidr.known.project.marker": "true",
"cmake.loaded.for.project": "true", "cmake.loaded.for.project": "true",
"last_opened_file_path": "E:/OnWorking/HelloWord-Keyboard/2.Firmware/HelloWord-Dynamic-fw/Ctrl/Motor", "last_opened_file_path": "D:/DEV_TOOLS/Projets/HelloWord-Keyboard/2.Firmware/HelloWord-Keyboard-fw",
"settings.editor.selected.configurable": "CMakeSettings", "settings.editor.selected.configurable": "CMakeSettings",
"structure.view.defaults.are.configured": "true" "structure.view.defaults.are.configured": "true",
"vue.rearranger.settings.migration": "true"
} }
}]]></component> }]]></component>
<component name="RecentsManager"> <component name="RecentsManager">
@ -87,9 +89,19 @@
</key> </key>
</component> </component>
<component name="RunManager"> <component name="RunManager">
<configuration default="true" type="CLionExternalRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" PASS_PARENT_ENVS_2="true"> <configuration default="true" type="lua.app" factoryName="Lua Application">
<option name="program" value="lua.exe" />
<option name="file" value="" />
<option name="workingDir" value="$PROJECT_DIR$/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ex.h" />
<option name="debuggerType" value="1" />
<option name="params" value="" />
<option name="charset" value="UTF-8" />
<option name="showConsole" value="true" />
<method v="2" />
</configuration>
<configuration default="true" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" PASS_PARENT_ENVS_2="true">
<method v="2"> <method v="2">
<option name="CLION.EXTERNAL.BUILD" enabled="true" /> <option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method> </method>
</configuration> </configuration>
<configuration default="true" type="PythonConfigurationType" factoryName="Python"> <configuration default="true" type="PythonConfigurationType" factoryName="Python">
@ -132,16 +144,6 @@
<option name="CLION.COMPOUND.BUILD" enabled="true" /> <option name="CLION.COMPOUND.BUILD" enabled="true" />
</method> </method>
</configuration> </configuration>
<configuration default="true" type="lua.app" factoryName="Lua Application">
<option name="program" value="lua.exe" />
<option name="file" value="" />
<option name="workingDir" value="$PROJECT_DIR$/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ex.h" />
<option name="debuggerType" value="1" />
<option name="params" value="" />
<option name="charset" value="UTF-8" />
<option name="showConsole" value="true" />
<method v="2" />
</configuration>
<configuration default="true" type="tests" factoryName="Autodetect"> <configuration default="true" type="tests" factoryName="Autodetect">
<module name="HelloWord-Dynamic-fw" /> <module name="HelloWord-Dynamic-fw" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
@ -279,6 +281,7 @@
<workItem from="1658479549618" duration="6478000" /> <workItem from="1658479549618" duration="6478000" />
<workItem from="1658499259416" duration="4546000" /> <workItem from="1658499259416" duration="4546000" />
<workItem from="1659172165877" duration="1356000" /> <workItem from="1659172165877" duration="1356000" />
<workItem from="1676859689038" duration="190000" />
</task> </task>
<servers /> <servers />
</component> </component>

@ -44,7 +44,7 @@ extern "C" {
#define CUSTOM_HID_EPIN_ADDR 0x81U #define CUSTOM_HID_EPIN_ADDR 0x81U
#define CUSTOM_HID_EPIN_SIZE 64U #define CUSTOM_HID_EPIN_SIZE 64U
#define CUSTOM_HID_EPOUT_ADDR 0x01U #define CUSTOM_HID_EPOUT_ADDR 0x02U
#define CUSTOM_HID_EPOUT_SIZE 64U #define CUSTOM_HID_EPOUT_SIZE 64U
#define USB_CUSTOM_HID_CONFIG_DESC_SIZ 41U #define USB_CUSTOM_HID_CONFIG_DESC_SIZ 41U

@ -632,7 +632,7 @@ static uint8_t USBD_CUSTOM_HID_DataIn(USBD_HandleTypeDef *pdev,
* @param epnum: endpoint index * @param epnum: endpoint index
* @retval status * @retval status
*/ */
void HID_RxCpltCallback(uint8_t* _data);
static uint8_t USBD_CUSTOM_HID_DataOut(USBD_HandleTypeDef *pdev, static uint8_t USBD_CUSTOM_HID_DataOut(USBD_HandleTypeDef *pdev,
uint8_t epnum) uint8_t epnum)
@ -640,9 +640,9 @@ static uint8_t USBD_CUSTOM_HID_DataOut(USBD_HandleTypeDef *pdev,
USBD_CUSTOM_HID_HandleTypeDef *hhid = (USBD_CUSTOM_HID_HandleTypeDef *)pdev->pClassData; USBD_CUSTOM_HID_HandleTypeDef *hhid = (USBD_CUSTOM_HID_HandleTypeDef *)pdev->pClassData;
// ((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData)->OutEvent(hhid->Report_buf[0], ((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData)->OutEvent(hhid->Report_buf[0],
// hhid->Report_buf[1]); hhid->Report_buf[1]);
HID_RxCpltCallback( hhid->Report_buf);
USBD_LL_PrepareReceive(pdev, CUSTOM_HID_EPOUT_ADDR, hhid->Report_buf, USBD_LL_PrepareReceive(pdev, CUSTOM_HID_EPOUT_ADDR, hhid->Report_buf,
USBD_CUSTOMHID_OUTREPORT_BUF_SIZE); USBD_CUSTOMHID_OUTREPORT_BUF_SIZE);

@ -32,7 +32,7 @@
/* USER CODE BEGIN PV */ /* USER CODE BEGIN PV */
/* Private variables ---------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/
void HID_RxCpltCallback(uint8_t* _data);
/* USER CODE END PV */ /* USER CODE END PV */
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY

@ -7,7 +7,8 @@
KeyboardConfig_t config; KeyboardConfig_t config;
HWKeyboard keyboard(&hspi1); HWKeyboard keyboard(&hspi1);
static bool isSoftWareControlColor = false;
static bool isReceiveSuccess = false;
/* Main Entry ----------------------------------------------------------------*/ /* Main Entry ----------------------------------------------------------------*/
void Main() void Main()
{ {
@ -39,13 +40,20 @@ void Main()
if (t > 250) fadeDir = false; if (t > 250) fadeDir = false;
else if (t < 1) fadeDir = true; else if (t < 1) fadeDir = true;
if(isReceiveSuccess){
keyboard.SyncLights();
isReceiveSuccess = false;
}
if(!isSoftWareControlColor)
{
/*---- This is a demo RGB effect ----*/
for (uint8_t i = 0; i < HWKeyboard::LED_NUMBER; i++) for (uint8_t i = 0; i < HWKeyboard::LED_NUMBER; i++)
keyboard.SetRgbBufferByID(i, HWKeyboard::Color_t{(uint8_t) t, 50, 0}); keyboard.SetRgbBufferByID(i, HWKeyboard::Color_t{(uint8_t)t, 50, 20});
/*-----------------------------------*/ /*-----------------------------------*/
// Send RGB buffers to LEDs
keyboard.SyncLights(); keyboard.SyncLights();
} }
}
} }
/* Event Callbacks -----------------------------------------------------------*/ /* Event Callbacks -----------------------------------------------------------*/
@ -80,5 +88,17 @@ void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef* hspi)
extern "C" extern "C"
void HID_RxCpltCallback(uint8_t* _data) void HID_RxCpltCallback(uint8_t* _data)
{ {
if(_data[1] == 0xbd) isSoftWareControlColor= false;
if(_data[1] == 0xac) {
isSoftWareControlColor = true;
uint8_t pageIndex = _data[2];
for (uint8_t i = 0; i < 10; i++) {
if(i+pageIndex*10>=HWKeyboard::LED_NUMBER) {
isReceiveSuccess = true;
break;
}
keyboard.SetRgbBufferByID(i+pageIndex*10,
HWKeyboard::Color_t{_data[3+i*3], _data[4+i*3], _data[5+i*3]});
}
}
} }
Loading…
Cancel
Save