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"?>
<project version="4">
<component name="CMakePresetLoader"><![CDATA[{
"useNewFormat": true
}]]></component>
<component name="CMakeReloadState">
<option name="reloaded" value="true" />
</component>
@ -18,10 +21,6 @@
<component name="ChangeListManager">
<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$/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>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -59,15 +58,18 @@
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.cidr.known.project.marker": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"WebServerToolWindowFactoryState": "true",
"cf.first.check.clang-format": "false",
"cidr.known.project.marker": "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",
"structure.view.defaults.are.configured": "true"
"structure.view.defaults.are.configured": "true",
"vue.rearranger.settings.migration": "true"
}
}]]></component>
<component name="RecentsManager">
@ -87,9 +89,19 @@
</key>
</component>
<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">
<option name="CLION.EXTERNAL.BUILD" enabled="true" />
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
<configuration default="true" type="PythonConfigurationType" factoryName="Python">
@ -132,16 +144,6 @@
<option name="CLION.COMPOUND.BUILD" enabled="true" />
</method>
</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">
<module name="HelloWord-Dynamic-fw" />
<option name="INTERPRETER_OPTIONS" value="" />
@ -279,6 +281,7 @@
<workItem from="1658479549618" duration="6478000" />
<workItem from="1658499259416" duration="4546000" />
<workItem from="1659172165877" duration="1356000" />
<workItem from="1676859689038" duration="190000" />
</task>
<servers />
</component>

@ -44,7 +44,7 @@ extern "C" {
#define CUSTOM_HID_EPIN_ADDR 0x81U
#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 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
* @retval status
*/
void HID_RxCpltCallback(uint8_t* _data);
static uint8_t USBD_CUSTOM_HID_DataOut(USBD_HandleTypeDef *pdev,
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_ItfTypeDef *)pdev->pUserData)->OutEvent(hhid->Report_buf[0],
// hhid->Report_buf[1]);
HID_RxCpltCallback( hhid->Report_buf);
((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData)->OutEvent(hhid->Report_buf[0],
hhid->Report_buf[1]);
USBD_LL_PrepareReceive(pdev, CUSTOM_HID_EPOUT_ADDR, hhid->Report_buf,
USBD_CUSTOMHID_OUTREPORT_BUF_SIZE);

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

@ -7,7 +7,8 @@
KeyboardConfig_t config;
HWKeyboard keyboard(&hspi1);
static bool isSoftWareControlColor = false;
static bool isReceiveSuccess = false;
/* Main Entry ----------------------------------------------------------------*/
void Main()
{
@ -39,12 +40,19 @@ void Main()
if (t > 250) fadeDir = false;
else if (t < 1) fadeDir = true;
for (uint8_t i = 0; i < HWKeyboard::LED_NUMBER; i++)
keyboard.SetRgbBufferByID(i, HWKeyboard::Color_t{(uint8_t) t, 50, 0});
/*-----------------------------------*/
// Send RGB buffers to LEDs
keyboard.SyncLights();
if(isReceiveSuccess){
keyboard.SyncLights();
isReceiveSuccess = false;
}
if(!isSoftWareControlColor)
{
/*---- This is a demo RGB effect ----*/
for (uint8_t i = 0; i < HWKeyboard::LED_NUMBER; i++)
keyboard.SetRgbBufferByID(i, HWKeyboard::Color_t{(uint8_t)t, 50, 20});
/*-----------------------------------*/
keyboard.SyncLights();
}
}
}
@ -80,5 +88,17 @@ void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef* hspi)
extern "C"
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