kopia lustrzana https://github.com/pjalocha/esp32-ogn-tracker
Run separate task for regular checks like LED, push button, sound start/stop
rodzic
849a5c599a
commit
8ed7d2f3e3
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
static char Line[128];
|
static char Line[128];
|
||||||
|
|
||||||
FIFO<uint8_t, 8> KeyBuffer;
|
// FIFO<uint8_t, 8> KeyBuffer;
|
||||||
|
|
||||||
// ========================================================================================================================
|
// ========================================================================================================================
|
||||||
|
|
||||||
|
@ -225,7 +225,12 @@ static void ProcessCtrlL(void) // print syste
|
||||||
}
|
}
|
||||||
|
|
||||||
void SleepIn(void)
|
void SleepIn(void)
|
||||||
{ xSemaphoreTake(CONS_Mutex, portMAX_DELAY);
|
{
|
||||||
|
#ifdef WITH_SPIFFS
|
||||||
|
FlashLog_SaveReq=1;
|
||||||
|
vTaskDelay(1000);
|
||||||
|
#endif
|
||||||
|
xSemaphoreTake(CONS_Mutex, portMAX_DELAY);
|
||||||
Format_String(CONS_UART_Write, "Sleep-in\n");
|
Format_String(CONS_UART_Write, "Sleep-in\n");
|
||||||
xSemaphoreGive(CONS_Mutex);
|
xSemaphoreGive(CONS_Mutex);
|
||||||
|
|
||||||
|
@ -262,7 +267,7 @@ void SleepIn(void)
|
||||||
|
|
||||||
PowerMode=0;
|
PowerMode=0;
|
||||||
for(int Idx=0; Idx<1500; Idx++)
|
for(int Idx=0; Idx<1500; Idx++)
|
||||||
{ LED_TimerCheck(1);
|
{ // LED_TimerCheck(1);
|
||||||
vTaskDelay(1); }
|
vTaskDelay(1); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -327,7 +332,13 @@ static void ProcessInput(void)
|
||||||
if(Byte==0x03) ProcessCtrlC(); // if Ctrl-C received: print parameters
|
if(Byte==0x03) ProcessCtrlC(); // if Ctrl-C received: print parameters
|
||||||
if(Byte==0x0C) ProcessCtrlL(); // if Ctrl-L received: list log files
|
if(Byte==0x0C) ProcessCtrlL(); // if Ctrl-L received: list log files
|
||||||
if(Byte==0x16) ProcessCtrlV(); // if Ctrl-L received: suspend (verbose) printout
|
if(Byte==0x16) ProcessCtrlV(); // if Ctrl-L received: suspend (verbose) printout
|
||||||
if(Byte==0x18) esp_restart() ; // if Ctrl-X received then restart
|
if(Byte==0x18)
|
||||||
|
{
|
||||||
|
#ifdef WITH_SPIFFS
|
||||||
|
FlashLog_SaveReq=1;
|
||||||
|
#endif
|
||||||
|
vTaskDelay(1000);
|
||||||
|
esp_restart(); } // if Ctrl-X received then restart
|
||||||
// if(Byte==0x19) Shutdown(); // if Ctrl-Y receiver: shutdown
|
// if(Byte==0x19) Shutdown(); // if Ctrl-Y receiver: shutdown
|
||||||
#endif
|
#endif
|
||||||
NMEA.ProcessByte(Byte); // pass the byte through the NMEA processor
|
NMEA.ProcessByte(Byte); // pass the byte through the NMEA processor
|
||||||
|
@ -368,6 +379,9 @@ void vTaskCTRL(void* pvParameters)
|
||||||
bool PowerOffRequest = AXP.readLongPressIRQ() /* || AXP.readShortPressIRQ() */ ;
|
bool PowerOffRequest = AXP.readLongPressIRQ() /* || AXP.readShortPressIRQ() */ ;
|
||||||
if(PowerOffRequest)
|
if(PowerOffRequest)
|
||||||
{ PowerMode=0;
|
{ PowerMode=0;
|
||||||
|
#ifdef WITH_SPIFFS
|
||||||
|
FlashLog_SaveReq=1;
|
||||||
|
#endif
|
||||||
xSemaphoreTake(CONS_Mutex, portMAX_DELAY);
|
xSemaphoreTake(CONS_Mutex, portMAX_DELAY);
|
||||||
Format_String(CONS_UART_Write, "Power-Off Request\n");
|
Format_String(CONS_UART_Write, "Power-Off Request\n");
|
||||||
xSemaphoreGive(CONS_Mutex);
|
xSemaphoreGive(CONS_Mutex);
|
||||||
|
@ -405,11 +419,11 @@ void vTaskCTRL(void* pvParameters)
|
||||||
AXP.clearIRQ(); }
|
AXP.clearIRQ(); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LED_TimerCheck(1); // update the LED flashes
|
// LED_TimerCheck(1); // update the LED flashes
|
||||||
#ifdef WITH_BEEPER
|
// #ifdef WITH_BEEPER
|
||||||
Play_TimerCheck(); // update the LED flashes
|
// Play_TimerCheck(); // update the LED flashes
|
||||||
#endif
|
// #endif
|
||||||
|
/*
|
||||||
int32_t PressRelease=Button_TimerCheck(); // 0 = no change
|
int32_t PressRelease=Button_TimerCheck(); // 0 = no change
|
||||||
#ifdef DEBUG_PRINT
|
#ifdef DEBUG_PRINT
|
||||||
if(PressRelease!=0)
|
if(PressRelease!=0)
|
||||||
|
@ -427,7 +441,7 @@ void vTaskCTRL(void* pvParameters)
|
||||||
else // very long push
|
else // very long push
|
||||||
{ }
|
{ }
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
uint32_t Time=TimeSync_Time();
|
uint32_t Time=TimeSync_Time();
|
||||||
bool TimeChange = Time!=PrevTime;
|
bool TimeChange = Time!=PrevTime;
|
||||||
uint32_t Sec = (Time-1)%60;
|
uint32_t Sec = (Time-1)%60;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "fifo.h"
|
#include "fifo.h"
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
|
|
||||||
extern FIFO<uint8_t, 8> KeyBuffer;
|
// extern FIFO<uint8_t, 8> KeyBuffer;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
|
|
38
main/hal.cpp
38
main/hal.cpp
|
@ -495,6 +495,10 @@ uint8_t BARO_I2C = (uint8_t)I2C_BUS;
|
||||||
#define PIN_BUTTON GPIO_NUM_39
|
#define PIN_BUTTON GPIO_NUM_39
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// ======================================================================================================
|
||||||
|
|
||||||
|
FIFO<uint8_t, 8> KeyBuffer;
|
||||||
|
|
||||||
// ======================================================================================================
|
// ======================================================================================================
|
||||||
// 48-bit unique ID of the chip
|
// 48-bit unique ID of the chip
|
||||||
|
|
||||||
|
@ -1594,7 +1598,7 @@ void vApplicationIdleHook(void) // when RTOS is idle: should call "sleep until a
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
void vApplicationTickHook(void) // RTOS timer tick hook
|
void vApplicationTickHook(void) // RTOS timer tick hook
|
||||||
{ LED_TimerCheck();
|
{ // LED_TimerCheck(1);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1937,6 +1941,38 @@ void IO_Configuration(void)
|
||||||
|
|
||||||
// ======================================================================================================
|
// ======================================================================================================
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
void vTaskTICK(void* pvParameters)
|
||||||
|
{
|
||||||
|
for( ; ; )
|
||||||
|
{ vTaskDelay(1);
|
||||||
|
LED_TimerCheck(1);
|
||||||
|
|
||||||
|
#ifdef WITH_BEEPER
|
||||||
|
Play_TimerCheck(); // update the LED flashes
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int32_t PressRelease=Button_TimerCheck(); // 0 = no change
|
||||||
|
#ifdef DEBUG_PRINT
|
||||||
|
if(PressRelease!=0)
|
||||||
|
{ xSemaphoreTake(CONS_Mutex, portMAX_DELAY);
|
||||||
|
Format_String(CONS_UART_Write, "Button: ");
|
||||||
|
Format_SignDec(CONS_UART_Write, PressRelease);
|
||||||
|
Format_String(CONS_UART_Write, "ms\n");
|
||||||
|
xSemaphoreGive(CONS_Mutex); }
|
||||||
|
#endif
|
||||||
|
if(PressRelease>0)
|
||||||
|
{ if(PressRelease<=700) // short button push: switch pages
|
||||||
|
{ KeyBuffer.Write(0x01); }
|
||||||
|
else if(PressRelease<=3000) // longer button push: some page action
|
||||||
|
{ KeyBuffer.Write(0x41); }
|
||||||
|
else // very long push
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ======================================================================================================
|
// ======================================================================================================
|
||||||
|
|
||||||
int NVS_Init(void)
|
int NVS_Init(void)
|
||||||
|
|
11
main/hal.h
11
main/hal.h
|
@ -8,6 +8,8 @@
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "freertos/queue.h"
|
#include "freertos/queue.h"
|
||||||
|
|
||||||
|
#include "fifo.h"
|
||||||
|
|
||||||
// ============================================================================================================
|
// ============================================================================================================
|
||||||
|
|
||||||
#define WITH_ESP32
|
#define WITH_ESP32
|
||||||
|
@ -26,6 +28,10 @@
|
||||||
|
|
||||||
// ============================================================================================================
|
// ============================================================================================================
|
||||||
|
|
||||||
|
extern FIFO<uint8_t, 8> KeyBuffer;
|
||||||
|
|
||||||
|
// ============================================================================================================
|
||||||
|
|
||||||
extern uint8_t PowerMode; // 0=sleep/minimal power, 1=comprimize, 2=full power
|
extern uint8_t PowerMode; // 0=sleep/minimal power, 1=comprimize, 2=full power
|
||||||
|
|
||||||
// ============================================================================================================
|
// ============================================================================================================
|
||||||
|
@ -212,4 +218,9 @@ extern AXP192 AXP;
|
||||||
void Sleep(void);
|
void Sleep(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
#endif
|
||||||
|
void vTaskTICK(void* pvParameters);
|
||||||
|
|
||||||
#endif // __HAL_H__
|
#endif // __HAL_H__
|
||||||
|
|
|
@ -110,6 +110,7 @@ void app_main(void)
|
||||||
#ifdef WITH_SOUND
|
#ifdef WITH_SOUND
|
||||||
xTaskCreate(vTaskSOUND, "SOUND", 2048, 0, tskIDLE_PRIORITY+3, 0);
|
xTaskCreate(vTaskSOUND, "SOUND", 2048, 0, tskIDLE_PRIORITY+3, 0);
|
||||||
#endif
|
#endif
|
||||||
|
xTaskCreate(vTaskTICK , "TICK", 1024, 0, tskIDLE_PRIORITY+2, 0);
|
||||||
// xTaskCreate(vTaskCTRL, "CTRL", 1536, 0, tskIDLE_PRIORITY+2, 0);
|
// xTaskCreate(vTaskCTRL, "CTRL", 1536, 0, tskIDLE_PRIORITY+2, 0);
|
||||||
vTaskCTRL(0); // run directly the CTRL task, instead of creating a separate one.
|
vTaskCTRL(0); // run directly the CTRL task, instead of creating a separate one.
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue