温湿度读取没问题,板子不对
This commit is contained in:
parent
fb2982a6ac
commit
6a8040ca2f
|
@ -16,7 +16,8 @@
|
||||||
"type_traits": "cpp",
|
"type_traits": "cpp",
|
||||||
"shell.h": "c",
|
"shell.h": "c",
|
||||||
"ch59x_common.h": "c",
|
"ch59x_common.h": "c",
|
||||||
"flexible_button.h": "c"
|
"flexible_button.h": "c",
|
||||||
|
"stdint.h": "c"
|
||||||
},
|
},
|
||||||
"marscode.chatLanguage": "cn"
|
"marscode.chatLanguage": "cn"
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#define KEY_TIMOUT_MS 1000
|
||||||
|
#define KEY_LONG_PRESS_MS 5000
|
||||||
|
#define KEY_SACN_MS 40
|
||||||
|
|
||||||
#define KEY_SCAN_EVT (0x0001 << 0)
|
#define KEY_SCAN_EVT (0x0001 << 0)
|
||||||
#define KEY_WAKEUP_EVT (0x0001 << 1)
|
#define KEY_WAKEUP_EVT (0x0001 << 1)
|
||||||
#define KEY_RELEASE_EVT (0x0001 << 2)
|
#define KEY_RELEASE_EVT (0x0001 << 2)
|
||||||
|
|
|
@ -378,6 +378,25 @@ uint8_t GXHTC3C_GetTempHumi(float *humi, float *temp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GXHTC3C_Read(void)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
GXHTC3C_Wakeup();
|
||||||
|
DelayMs(20);
|
||||||
|
|
||||||
|
GXHTC3C_GetStart();
|
||||||
|
DelayMs(20);
|
||||||
|
float humi, temp;
|
||||||
|
ret = GXHTC3C_GetTempHumi(&humi, &temp);
|
||||||
|
if (ret == 0)
|
||||||
|
{
|
||||||
|
logDebug("humi %.2f %, temp %.2f C", humi, temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
GXHTC3C_Sleep();
|
||||||
|
}
|
||||||
|
|
||||||
void GXHTC3C_Init(void)
|
void GXHTC3C_Init(void)
|
||||||
{
|
{
|
||||||
#if 1
|
#if 1
|
||||||
|
@ -388,10 +407,10 @@ void GXHTC3C_Init(void)
|
||||||
DelayMs(100);
|
DelayMs(100);
|
||||||
|
|
||||||
GXHTC3C_Wakeup();
|
GXHTC3C_Wakeup();
|
||||||
DelayMs(3);
|
DelayMs(20);
|
||||||
|
|
||||||
GXHTC3C_GetStart();
|
GXHTC3C_GetStart();
|
||||||
DelayMs(4);
|
DelayMs(20);
|
||||||
float humi, temp;
|
float humi, temp;
|
||||||
ret = GXHTC3C_GetTempHumi(&humi, &temp);
|
ret = GXHTC3C_GetTempHumi(&humi, &temp);
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
|
@ -401,6 +420,11 @@ void GXHTC3C_Init(void)
|
||||||
|
|
||||||
GXHTC3C_Sleep();
|
GXHTC3C_Sleep();
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
GXHTC3C_Read();
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,6 @@ static void KEY_Task_ProcessTmosMsg(tmos_event_hdr_t *pMsg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define KEY_TIMOUT_MS 1000
|
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
static uint16_t KEY_Task_ProcessEvent(uint8_t task_id, uint16_t events)
|
static uint16_t KEY_Task_ProcessEvent(uint8_t task_id, uint16_t events)
|
||||||
{
|
{
|
||||||
|
@ -56,7 +54,7 @@ static uint16_t KEY_Task_ProcessEvent(uint8_t task_id, uint16_t events)
|
||||||
static volatile bool key_vaild_for_long_press = false;
|
static volatile bool key_vaild_for_long_press = false;
|
||||||
if (IS_KEY_Vaild())
|
if (IS_KEY_Vaild())
|
||||||
{
|
{
|
||||||
if (key_vaild_times > 100)
|
if (key_vaild_times > (KEY_LONG_PRESS_MS / KEY_SACN_MS))
|
||||||
{ //> 20ms*100=2000ms
|
{ //> 20ms*100=2000ms
|
||||||
if (false == key_vaild_for_long_press)
|
if (false == key_vaild_for_long_press)
|
||||||
{
|
{
|
||||||
|
@ -79,7 +77,7 @@ static uint16_t KEY_Task_ProcessEvent(uint8_t task_id, uint16_t events)
|
||||||
|
|
||||||
if (key_vaild_times)
|
if (key_vaild_times)
|
||||||
{
|
{
|
||||||
if ((key_vaild_times) < 100)
|
if ((key_vaild_times) < (KEY_LONG_PRESS_MS / KEY_SACN_MS))
|
||||||
{
|
{
|
||||||
p_handler(kKeyShort);
|
p_handler(kKeyShort);
|
||||||
}
|
}
|
||||||
|
@ -93,7 +91,7 @@ static uint16_t KEY_Task_ProcessEvent(uint8_t task_id, uint16_t events)
|
||||||
{
|
{
|
||||||
key_timeout_cnt--;
|
key_timeout_cnt--;
|
||||||
logDebug("key_timeout_cnt %d", key_timeout_cnt);
|
logDebug("key_timeout_cnt %d", key_timeout_cnt);
|
||||||
tmos_start_task(key_task_id, KEY_SCAN_EVT, MS1_TO_SYSTEM_TIME(40)); // 40ms
|
tmos_start_task(key_task_id, KEY_SCAN_EVT, MS1_TO_SYSTEM_TIME(KEY_SACN_MS)); // 40ms
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -147,8 +145,6 @@ void BSP_KEY_ExitLowpower(void)
|
||||||
PWR_PeriphWakeUpCfg(DISABLE, RB_GPIO_WAKE_MODE | RB_SLP_GPIO_WAKE, Long_Delay);
|
PWR_PeriphWakeUpCfg(DISABLE, RB_GPIO_WAKE_MODE | RB_SLP_GPIO_WAKE, Long_Delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
uint8_t read_button_GPIO(uint8_t button_id)
|
uint8_t read_button_GPIO(uint8_t button_id)
|
||||||
{
|
{
|
||||||
|
@ -269,7 +265,7 @@ void BSP_KEY_Init(app_task_evt_handler_t handler)
|
||||||
// 开启GPIOB中断
|
// 开启GPIOB中断
|
||||||
PFIC_EnableIRQ(GPIO_B_IRQn);
|
PFIC_EnableIRQ(GPIO_B_IRQn);
|
||||||
|
|
||||||
tmos_start_task(key_task_id, KEY_SCAN_EVT, MS1_TO_SYSTEM_TIME(20));
|
tmos_start_task(key_task_id, KEY_SCAN_EVT, MS1_TO_SYSTEM_TIME(KEY_SACN_MS));
|
||||||
|
|
||||||
// tmos_start_task(key_task_id, KEY_SCAN_EVT, MS1_TO_SYSTEM_TIME(5));
|
// tmos_start_task(key_task_id, KEY_SCAN_EVT, MS1_TO_SYSTEM_TIME(5));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue