mirror of
https://github.com/silenty4ng/uv-k5-firmware-chinese-lts
synced 2025-01-15 14:54:40 +00:00
flashlight
This commit is contained in:
parent
93845cbc74
commit
3f3fe9d21c
3 changed files with 69 additions and 68 deletions
|
@ -91,9 +91,9 @@
|
||||||
</key>
|
</key>
|
||||||
</component>
|
</component>
|
||||||
<component name="RunManager" selected="Shell Script.未命名 (1)">
|
<component name="RunManager" selected="Shell Script.未命名 (1)">
|
||||||
<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="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 name="未命名 (1)" type="ShConfigurationType" nameIsGenerated="true">
|
<configuration name="未命名 (1)" type="ShConfigurationType" nameIsGenerated="true">
|
||||||
|
@ -155,6 +155,7 @@
|
||||||
<workItem from="1701834513154" duration="11699000" />
|
<workItem from="1701834513154" duration="11699000" />
|
||||||
<workItem from="1701908787854" duration="5232000" />
|
<workItem from="1701908787854" duration="5232000" />
|
||||||
<workItem from="1701917497420" duration="1955000" />
|
<workItem from="1701917497420" duration="1955000" />
|
||||||
|
<workItem from="1701921618473" duration="1000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00021" summary="按键锁定改回以前逻辑">
|
<task id="LOCAL-00021" summary="按键锁定改回以前逻辑">
|
||||||
<created>1701563372624</created>
|
<created>1701563372624</created>
|
||||||
|
|
66
app/app.c
66
app/app.c
|
@ -2063,69 +2063,3 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||||
|
|
||||||
gUpdateDisplay = true;
|
gUpdateDisplay = true;
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_FLASHLIGHT
|
|
||||||
|
|
||||||
#include "driver/gpio.h"
|
|
||||||
#include "bsp/dp32g030/gpio.h"
|
|
||||||
|
|
||||||
#include "flashlight.h"
|
|
||||||
|
|
||||||
enum FlashlightMode_t gFlashLightState;
|
|
||||||
|
|
||||||
void FlashlightTimeSlice()
|
|
||||||
{
|
|
||||||
if (gFlashLightState == FLASHLIGHT_BLINK && (gFlashLightBlinkCounter & 15u) == 0) {
|
|
||||||
GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gFlashLightState == FLASHLIGHT_SOS) {
|
|
||||||
const uint16_t u = 15;
|
|
||||||
static uint8_t c;
|
|
||||||
static uint16_t next;
|
|
||||||
|
|
||||||
if (gFlashLightBlinkCounter - next > 7 * u) {
|
|
||||||
c = 0;
|
|
||||||
next = gFlashLightBlinkCounter + 1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gFlashLightBlinkCounter == next) {
|
|
||||||
if (c==0) {
|
|
||||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
|
||||||
} else {
|
|
||||||
GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (c >= 18) {
|
|
||||||
next = gFlashLightBlinkCounter + 7 * u;
|
|
||||||
c = 0;
|
|
||||||
} else if(c==7 || c==9 || c==11) {
|
|
||||||
next = gFlashLightBlinkCounter + 3 * u;
|
|
||||||
} else {
|
|
||||||
next = gFlashLightBlinkCounter + u;
|
|
||||||
}
|
|
||||||
c++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ACTION_FlashLight(void)
|
|
||||||
{
|
|
||||||
switch (gFlashLightState) {
|
|
||||||
case FLASHLIGHT_OFF:
|
|
||||||
gFlashLightState++;
|
|
||||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
|
||||||
break;
|
|
||||||
case FLASHLIGHT_ON:
|
|
||||||
case FLASHLIGHT_BLINK:
|
|
||||||
gFlashLightState++;
|
|
||||||
break;
|
|
||||||
case FLASHLIGHT_SOS:
|
|
||||||
default:
|
|
||||||
gFlashLightState = 0;
|
|
||||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
66
app/flashlight.c
Normal file
66
app/flashlight.c
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
#ifdef ENABLE_FLASHLIGHT
|
||||||
|
|
||||||
|
#include "driver/gpio.h"
|
||||||
|
#include "bsp/dp32g030/gpio.h"
|
||||||
|
|
||||||
|
#include "flashlight.h"
|
||||||
|
|
||||||
|
enum FlashlightMode_t gFlashLightState;
|
||||||
|
|
||||||
|
void FlashlightTimeSlice()
|
||||||
|
{
|
||||||
|
if (gFlashLightState == FLASHLIGHT_BLINK && (gFlashLightBlinkCounter & 15u) == 0) {
|
||||||
|
GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gFlashLightState == FLASHLIGHT_SOS) {
|
||||||
|
const uint16_t u = 15;
|
||||||
|
static uint8_t c;
|
||||||
|
static uint16_t next;
|
||||||
|
|
||||||
|
if (gFlashLightBlinkCounter - next > 7 * u) {
|
||||||
|
c = 0;
|
||||||
|
next = gFlashLightBlinkCounter + 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gFlashLightBlinkCounter == next) {
|
||||||
|
if (c==0) {
|
||||||
|
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
||||||
|
} else {
|
||||||
|
GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c >= 18) {
|
||||||
|
next = gFlashLightBlinkCounter + 7 * u;
|
||||||
|
c = 0;
|
||||||
|
} else if(c==7 || c==9 || c==11) {
|
||||||
|
next = gFlashLightBlinkCounter + 3 * u;
|
||||||
|
} else {
|
||||||
|
next = gFlashLightBlinkCounter + u;
|
||||||
|
}
|
||||||
|
c++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ACTION_FlashLight(void)
|
||||||
|
{
|
||||||
|
switch (gFlashLightState) {
|
||||||
|
case FLASHLIGHT_OFF:
|
||||||
|
gFlashLightState++;
|
||||||
|
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
||||||
|
break;
|
||||||
|
case FLASHLIGHT_ON:
|
||||||
|
case FLASHLIGHT_BLINK:
|
||||||
|
gFlashLightState++;
|
||||||
|
break;
|
||||||
|
case FLASHLIGHT_SOS:
|
||||||
|
default:
|
||||||
|
gFlashLightState = 0;
|
||||||
|
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in a new issue