DWM22测试板

This commit is contained in:
2026-07-29 17:37:05 +08:00
parent 6d114add28
commit 99d4844c01
100 changed files with 6604 additions and 4433 deletions
@@ -102,7 +102,12 @@ static uint8_t pair_command_replay;
#define PAIRING_WINDOW_TICKS 50000UL
#define RF433_RELEASE_TIMEOUT_TICKS 1500U
#define RF433_MS_TO_SAMPLE_TICKS(ms) ((uint16_t)((ms) * (1000U / RF433_DECODER_SAMPLE_US)))
#define RF433_MODE_REPEAT_TICKS ((uint32_t)RF433_MS_TO_SAMPLE_TICKS(500U))
uint8_t long_flag_s=0;
static volatile uint32_t rf433_sample_ticks;
static uint32_t rf433_mode_last_action_tick;
static uint8_t rf433_mode_last_key;
static uint8_t rf433_mode_action_valid;
void _433_fun(void);
@@ -422,8 +427,38 @@ static void set_click(){
}
}
static uint8_t rf433_is_mode_step_command(uint8_t command)
{
return command == Mode_add || command == Mode_dow;
}
/*
* Act immediately on the first valid mode frame. Repeated frames carrying
* the same key are accepted at most once every 500 ms. Keep this independent
* from the generic 150 ms release detector so an occasional missing RF frame
* cannot turn one physical hold into several rapid short presses.
*/
static uint8_t rf433_mode_step_ready(uint8_t command)
{
uint32_t now = rf433_sample_ticks;
if(!rf433_mode_action_valid ||
rf433_mode_last_key != command ||
(uint32_t)(now - rf433_mode_last_action_tick) >=
RF433_MODE_REPEAT_TICKS)
{
rf433_mode_last_key = command;
rf433_mode_last_action_tick = now;
rf433_mode_action_valid = 1U;
return 1U;
}
return 0U;
}
void rf433_receive(void)//RF433 sample, called every 100 us
{
rf433_sample_ticks++;
rf433_decoder_sample((RF_DATA == HIGH_LEVEL) ? 1U : 0U);
if(long_time > 0U)
@@ -473,8 +508,15 @@ void _433_fun(){
pair_deferred_receive_data = receive_data;
return;
}
if(Key_TypeDef.KEY_STATE_Click==1||KEY_STATE_re==1) return;
set_click();
if(rf433_is_mode_step_command(res_data))
{
if(!rf433_mode_step_ready(res_data)) return;
}
else
{
if(Key_TypeDef.KEY_STATE_Click==1||KEY_STATE_re==1) return;
set_click();
}
switch(res_data){
//椭圆
case ON://单击