improved only send changed status up,

This commit is contained in:
Yunhorn 2024-03-25 12:58:57 +08:00
parent 85a9fe722f
commit 7adb1031ee
3 changed files with 33 additions and 2 deletions

View File

@ -60,7 +60,7 @@ void MX_GPIO_Init(void)
GPIO_InitStruct.Pin = BUT1_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
#if 0

View File

@ -448,6 +448,7 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
/* Note: when "EventType == TX_ON_TIMER" this GPIO is not initialized */
//if (EventType == TX_ON_EVENT)
{
door_changed_flag =1;
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
}
break;
@ -557,6 +558,22 @@ static void SendTxData(void)
sensor_t sensor_data;
UTIL_TIMER_Time_t nextTxIn = 0;
door_status = HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_0);
door_changed_flag = 0;
if (door_status != door_previous_status)
{
door_previous_status = door_status;
}
#if 0
if (door_changed_flag ==1 )
{
door_changed_flag = 0;
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
UTIL_TIMER_Start(&TxTimer);
}
#endif
if (LmHandlerIsBusy() == false)
{
#ifdef CAYENNE_LPP
@ -611,7 +628,7 @@ static void SendTxData(void)
AppData.Buffer[i++] = 0;
AppData.Buffer[i++] = 0;
AppData.Buffer[i++] = (uint8_t)(99*GetBatteryLevel()/255); /* 1 (very low) to 254 (fully charged) */
AppData.Buffer[i++] = HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_0);
AppData.Buffer[i++] = door_status;
}
else
{
@ -666,6 +683,7 @@ static void SendTxData(void)
static void OnTxTimerEvent(void *context)
{
/* USER CODE BEGIN OnTxTimerEvent_1 */
#if 0
door_status = HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_0);
if (door_status != door_previous_status)
{
@ -681,6 +699,18 @@ static void OnTxTimerEvent(void *context)
/*Wait for next tx slot*/
UTIL_TIMER_Start(&TxTimer);
}
#endif
door_status = HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_0);
door_changed_flag = 0;
if (door_status != door_previous_status)
{
door_previous_status = door_status;
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
UTIL_TIMER_Start(&TxTimer);
}
/* USER CODE BEGIN OnTxTimerEvent_2 */
/* USER CODE END OnTxTimerEvent_2 */

View File

@ -78,5 +78,6 @@
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;memoryBlockExpressionList context=&quot;reserved-for-future-use&quot;/&gt;"/>
<stringAttribute key="process_factory_id" value="com.st.stm32cube.ide.mcu.debug.launch.HardwareDebugProcessFactory"/>
</launchConfiguration>