wip, good HALL-1 & HALL-2 response of flash dark-red, red-blue

This commit is contained in:
Yunhorn 2024-11-20 22:48:05 +08:00
parent 81da401c6a
commit 92e9a22480
2 changed files with 35 additions and 4 deletions

View File

@ -34,6 +34,7 @@
#include "CayenneLpp.h"
#include "sys_sensors.h"
#include "flash_if.h"
#include "stdio.h"
#ifdef CLOCK_SYNC
#include "LmhpClockSync.h"
@ -44,9 +45,11 @@
#include "app_tof_peoplecount.h"
#include "yunhorn_sts_prd_conf.h"
#include "yunhorn_sts_sensors.h"
#if defined(STS_O6)||defined(STS_T6)||defined(O1L)
#if (defined(STS_O6)||defined(STS_T6)||defined(O1L))
#include "sts_lamp_bar.h"
#endif
/* USER CODE END Includes */
/* External variables ---------------------------------------------------------*/
@ -68,6 +71,10 @@ extern volatile sts_fhmos_sensor_data_t sts_fhmos_data;
extern volatile sts_fhmos_sensor_config_t sts_fhmos_cfg;
extern volatile sts_fhmos_sensor_ambient_height_t sts_fhmos_bg;
// volatile LmHandlerAppData_t sts_app_data={ 0, 0, sts_data_buf };
extern volatile uint8_t sts_hall1_read, sts_hall2_read; // Above hall1_read == reed_hall_result, hall2_read == emergency_button
extern volatile uint8_t sts_hall3_read, sts_hall4_read;
extern volatile uint8_t sts_pir_state;
/* USER CODE END EV */
@ -595,16 +602,37 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
case BUT1_Pin:
/* Note: when "EventType == TX_ON_TIMER" this GPIO is not initialized */
if (EventType == TX_ON_EVENT)
HAL_Delay(100);
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin);
sts_hall1_read = HALL1_STATE;
printf("\r\n HALL 1 state =%d \r\n", sts_hall1_read);
if (sts_hall1_read == 0) sts_lamp_bar_color = STS_RED_DARK;
printf("\r\n lamp bar color =0x%02x \r\n", sts_lamp_bar_color);
//if (EventType == TX_ON_EVENT)
{
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
}
break;
#ifndef STS_R4
#if 0
#if 1
case BUT2_Pin:
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaStopJoinEvent), CFG_SEQ_Prio_0);
HAL_Delay(100);
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin);
sts_hall2_read = HALL2_STATE;
printf("\r\n HALL 2 state =%d \r\n", sts_hall2_read);
if (sts_hall2_read == 0) sts_lamp_bar_color = STS_RED_BLUE;
printf("\r\n lamp bar color =0x%02x \r\n", sts_lamp_bar_color);
{
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
}
//UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaStopJoinEvent), CFG_SEQ_Prio_0);
break;
#endif
#endif
@ -614,6 +642,9 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
break;
#endif
case PIR_Pin:
HAL_Delay(100);
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin);
sts_pir_state = PIR_STATE;
printf("\r\n PIR state =%d \r\n", sts_pir_state);
if (sts_pir_state == 1) fhmos_human_movement = 1;