支持DOCK按键控制

This commit is contained in:
wu58430 2024-01-11 18:02:08 +08:00
parent b46c77b9f8
commit c3c3cf15ed
6 changed files with 143 additions and 78 deletions

View file

@ -20,8 +20,14 @@
</configurations>
</component>
<component name="ChangeListManager">
<list default="true" id="cea36e80-e289-4d69-9030-7186d540ac0e" name="更改" comment="修复收音机缺失文字">
<list default="true" id="cea36e80-e289-4d69-9030-7186d540ac0e" name="更改" comment="赞助">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Makefile" beforeDir="false" afterPath="$PROJECT_DIR$/Makefile" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/app.c" beforeDir="false" afterPath="$PROJECT_DIR$/app/app.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/uart.c" beforeDir="false" afterPath="$PROJECT_DIR$/app/uart.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/driver/keyboard.c" beforeDir="false" afterPath="$PROJECT_DIR$/driver/keyboard.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/driver/keyboard.h" beforeDir="false" afterPath="$PROJECT_DIR$/driver/keyboard.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.c" beforeDir="false" afterPath="$PROJECT_DIR$/main.c" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -70,27 +76,27 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"ASKED_ADD_EXTERNAL_FILES": "true",
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.cidr.known.project.marker": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"WebServerToolWindowFactoryState": "false",
"cf.first.check.clang-format": "false",
"cidr.known.project.marker": "true",
"last_opened_file_path": "C:/Users/RUPC/Desktop/UV-K6/uv-k5-firmware-chinese/Makefile",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"settings.editor.selected.configurable": "language.cpp.clang-tidy",
"structure.view.defaults.are.configured": "true",
"vue.rearranger.settings.migration": "true"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;ASKED_ADD_EXTERNAL_FILES&quot;: &quot;true&quot;,
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.cidr.known.project.marker&quot;: &quot;true&quot;,
&quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
&quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
&quot;cf.first.check.clang-format&quot;: &quot;false&quot;,
&quot;cidr.known.project.marker&quot;: &quot;true&quot;,
&quot;last_opened_file_path&quot;: &quot;C:/Users/RUPC/Desktop/UV-K6/uv-k5-firmware-chinese/Makefile&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;language.cpp.clang-tidy&quot;,
&quot;structure.view.defaults.are.configured&quot;: &quot;true&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}]]></component>
}</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="C:\Users\RUPC\Desktop\UV-K6\uv-k5-firmware-chinese" />
@ -100,7 +106,7 @@
<recent name="C:\Users\RUPC\Desktop\UV-K6\uv-k5-firmware-chinese\app" />
</key>
</component>
<component name="RunManager" selected="Shell Script.win docker">
<component name="RunManager" selected="Makefile 目标.both">
<configuration name="all" type="MAKEFILE_TARGET_RUN_CONFIGURATION" factoryName="Makefile" temporary="true">
<makefile filename="$PROJECT_DIR$/Makefile" target="all" workingDirectory="" arguments="">
<envs />
@ -195,9 +201,9 @@
</list>
<recent_temporary>
<list>
<item itemvalue="Makefile 目标.build" />
<item itemvalue="Makefile 目标.full" />
<item itemvalue="Makefile 目标.all" />
<item itemvalue="Makefile 目标.build" />
<item itemvalue="Makefile 目标.flash" />
<item itemvalue="Makefile 目标.clean" />
</list>
@ -278,49 +284,9 @@
<workItem from="1704853919857" duration="595000" />
<workItem from="1704856873722" duration="3844000" />
<workItem from="1704864846118" duration="988000" />
<workItem from="1704875852857" duration="9244000" />
</task>
<task id="LOCAL-00070" summary="fix https://github.com/losehu/uv-k5-firmware-chinese/issues/15">
<created>1701941650076</created>
<option name="number" value="00070" />
<option name="presentableId" value="LOCAL-00070" />
<option name="project" value="LOCAL" />
<updated>1701941650076</updated>
</task>
<task id="LOCAL-00071" summary="fix https://github.com/losehu/uv-k5-firmware-chinese/issues/15">
<created>1701941657863</created>
<option name="number" value="00071" />
<option name="presentableId" value="LOCAL-00071" />
<option name="project" value="LOCAL" />
<updated>1701941657863</updated>
</task>
<task id="LOCAL-00072" summary="增加开机画面">
<created>1701941724553</created>
<option name="number" value="00072" />
<option name="presentableId" value="LOCAL-00072" />
<option name="project" value="LOCAL" />
<updated>1701941724553</updated>
</task>
<task id="LOCAL-00073" summary="关闭MDC1200信息显示">
<created>1701941769531</created>
<option name="number" value="00073" />
<option name="presentableId" value="LOCAL-00073" />
<option name="project" value="LOCAL" />
<updated>1701941769531</updated>
</task>
<task id="LOCAL-00074" summary="Makefile">
<created>1701963619702</created>
<option name="number" value="00074" />
<option name="presentableId" value="LOCAL-00074" />
<option name="project" value="LOCAL" />
<updated>1701963619702</updated>
</task>
<task id="LOCAL-00075" summary="Makefile">
<created>1702009339056</created>
<option name="number" value="00075" />
<option name="presentableId" value="LOCAL-00075" />
<option name="project" value="LOCAL" />
<updated>1702009339056</updated>
<workItem from="1704875852857" duration="14958000" />
<workItem from="1704939946494" duration="32000" />
<workItem from="1704940032053" duration="4985000" />
</task>
<task id="LOCAL-00076" summary="Makefile">
<created>1702009532422</created>
@ -623,7 +589,49 @@
<option name="project" value="LOCAL" />
<updated>1704888827675</updated>
</task>
<option name="localTasksCounter" value="119" />
<task id="LOCAL-00119" summary="更新README">
<created>1704889055543</created>
<option name="number" value="00119" />
<option name="presentableId" value="LOCAL-00119" />
<option name="project" value="LOCAL" />
<updated>1704889055543</updated>
</task>
<task id="LOCAL-00120" summary="修改docker编译">
<created>1704891380381</created>
<option name="number" value="00120" />
<option name="presentableId" value="LOCAL-00120" />
<option name="project" value="LOCAL" />
<updated>1704891380381</updated>
</task>
<task id="LOCAL-00121" summary="赞助">
<created>1704891973032</created>
<option name="number" value="00121" />
<option name="presentableId" value="LOCAL-00121" />
<option name="project" value="LOCAL" />
<updated>1704891973032</updated>
</task>
<task id="LOCAL-00122" summary="4M TEST">
<created>1704898312561</created>
<option name="number" value="00122" />
<option name="presentableId" value="LOCAL-00122" />
<option name="project" value="LOCAL" />
<updated>1704898312561</updated>
</task>
<task id="LOCAL-00123" summary="信道长度">
<created>1704898326550</created>
<option name="number" value="00123" />
<option name="presentableId" value="LOCAL-00123" />
<option name="project" value="LOCAL" />
<updated>1704898326550</updated>
</task>
<task id="LOCAL-00124" summary="赞助">
<created>1704956580565</created>
<option name="number" value="00124" />
<option name="presentableId" value="LOCAL-00124" />
<option name="project" value="LOCAL" />
<updated>1704956580565</updated>
</task>
<option name="localTasksCounter" value="125" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -650,13 +658,8 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="readme add" />
<MESSAGE value="重构" />
<MESSAGE value="clion" />
<MESSAGE value="开机音修复" />
<MESSAGE value="MDC联系人" />
<MESSAGE value="MDC PY" />
<MESSAGE value="赞助" />
<MESSAGE value="110" />
<MESSAGE value="中英文字符对齐" />
<MESSAGE value="支持中文编译选项ENABLE_CHINESE_FULL" />
@ -675,14 +678,19 @@
<MESSAGE value="修复信道名显示" />
<MESSAGE value="同时编译多个版本" />
<MESSAGE value="修复收音机缺失文字" />
<option name="LAST_COMMIT_MESSAGE" value="修复收音机缺失文字" />
<MESSAGE value="更新README" />
<MESSAGE value="修改docker编译" />
<MESSAGE value="4M TEST" />
<MESSAGE value="信道长度" />
<MESSAGE value="赞助" />
<option name="LAST_COMMIT_MESSAGE" value="赞助" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType">
<url>file://$PROJECT_DIR$/app/uart.c</url>
<line>636</line>
<line>658</line>
<option name="timeStamp" value="1" />
</line-breakpoint>
<line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType">

View file

@ -51,6 +51,7 @@ ENABLE_UART_RW_BK_REGS ?= 0
ENABLE_AUDIO_BAR_DEFAULT ?=0
ENABLE_EEPROM_4M ?=1
ENABLE_CHINESE_FULL = 4
ENABLE_DOCK = 1
# ---- DEBUGGING ----
ENABLE_AM_FIX_SHOW_DATA ?= 0
@ -297,6 +298,10 @@ endif
ifeq ($(ENABLE_MDC1200),1)
CFLAGS += -DENABLE_MDC1200
endif
ifeq ($(ENABLE_DOCK),1)
CFLAGS += -DENABLE_DOCK
endif
ifeq ($(ENABLE_TIMER),1)
CFLAGS += -DENABLE_TIMER
endif

View file

@ -1016,6 +1016,7 @@ static void CheckKeys(void)
// -------------------- PTT ------------------------
if (gPttIsPressed)
{
if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || SerialConfigInProgress())
{ // PTT released or serial comms config in progress
if (++gPttDebounceCounter >= 3 || SerialConfigInProgress()) // 30ms

View file

@ -52,7 +52,14 @@ typedef struct {
uint16_t ID;
uint16_t Size;
} Header_t;
#ifdef ENABLE_DOCK
typedef struct {
Header_t Header;
uint8_t Key;
uint8_t Padding;
uint32_t Timestamp;
} CMD_0801_t; // simulate key press
#endif
typedef struct {
uint8_t Padding[2];
uint16_t ID;
@ -632,6 +639,21 @@ static void CMD_0538(const uint8_t *pBuffer)//write
SendReply(&Reply, sizeof(Reply));
}
#endif
#ifdef ENABLE_DOCK
static void CMD_0801(const uint8_t *pBuffer)
{
const CMD_0801_t *pCmd = (const CMD_0801_t *)pBuffer;
const uint8_t key = pCmd->Key & 0x1f;
const bool click = pCmd->Key & 32;
if(key != KEY_INVALID)
{
gSimulateKey = key;
gDebounceDefeat = 0;
}
gSimulateHold = click ? KEY_INVALID : key;
}
#endif
void UART_HandleCommand(void) {
switch (UART_Command.Header.ID) {
#if ENABLE_CHINESE_FULL==4
@ -641,6 +663,12 @@ void UART_HandleCommand(void) {
case 0x0538://write
CMD_0538(UART_Command.Buffer);
break;
#endif
#ifdef ENABLE_DOCK
case 0x0801:
CMD_0801(UART_Command.Buffer);
break;
#endif
case 0x0514:
CMD_0514(UART_Command.Buffer);

View file

@ -26,7 +26,11 @@ KEY_Code_t gKeyReading0 = KEY_INVALID;
KEY_Code_t gKeyReading1 = KEY_INVALID;
uint16_t gDebounceCounter = 0;
bool gWasFKeyPressed = false;
#ifdef ENABLE_DOCK
KEY_Code_t gSimulateKey = KEY_INVALID;
KEY_Code_t gSimulateHold = KEY_INVALID;
uint8_t gDebounceDefeat = 0;
#endif
static const struct {
// Using a 16 bit pre-calculated shift and invert is cheaper
@ -94,6 +98,21 @@ static const struct {
KEY_Code_t KEYBOARD_Poll(void)
{
#ifdef ENABLE_DOCK
if(gSimulateKey != KEY_INVALID)
{
const KEY_Code_t temp = gSimulateKey;
if(gDebounceDefeat++ >= 5)
gSimulateKey = KEY_INVALID;
return temp;
}
if(gSimulateHold != KEY_INVALID)
{
return gSimulateHold;
}
#endif
KEY_Code_t Key = KEY_INVALID;
// if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT))

View file

@ -51,6 +51,10 @@ extern uint16_t gDebounceCounter;
extern bool gWasFKeyPressed;
KEY_Code_t KEYBOARD_Poll(void);
#ifdef ENABLE_DOCK
extern KEY_Code_t gSimulateKey;
extern KEY_Code_t gSimulateHold;
extern uint8_t gDebounceDefeat;
#endif
#endif