Skip to content

Commit

Permalink
Compass Reading in Idle Task core 1
Browse files Browse the repository at this point in the history
  • Loading branch information
jgauchia committed Jul 1, 2024
1 parent dc6ff3b commit 54c5f74
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 19 deletions.
9 changes: 0 additions & 9 deletions lib/gui/src/mainScr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,6 @@ void updateMainScreen(lv_timer_t *t)
switch (activeTile)
{
case COMPASS:
#ifdef ENABLE_COMPASS
if (!waitScreenRefresh)
heading = getHeading();
#endif
lv_obj_send_event(compassHeading, LV_EVENT_VALUE_CHANGED, NULL);


Expand All @@ -205,11 +201,6 @@ void updateMainScreen(lv_timer_t *t)
break;

case MAP:
// if (GPS.location.isUpdated())
#ifdef ENABLE_COMPASS
if (!waitScreenRefresh)
heading = getHeading();
#endif
lv_obj_send_event(mapTile, LV_EVENT_REFRESH, NULL);
break;

Expand Down
58 changes: 49 additions & 9 deletions lib/tasks/tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ time_t local, utc = 0;
TaskHandle_t LVGLTaskHandler;

/**
* @brief Task1 - LVGL Task
* @brief LVGL Task
*
* @param pvParameters
*/
void lvglTask(void *pvParameters)
{
log_v("Task1 - LVGL Task - running on core %d", xPortGetCoreID());
log_v("LVGL Task - running on core %d", xPortGetCoreID());
log_v("Stack size: %d", uxTaskGetStackHighWaterMark(NULL));
while (1)
{
Expand All @@ -29,7 +29,7 @@ void lvglTask(void *pvParameters)
}

/**
* @brief Init Task1 LVGL Task
* @brief Init LVGL Task
*
*/
void initLvglTask()
Expand All @@ -39,15 +39,15 @@ void initLvglTask()
}

/**
* @brief Task 2 - Read GPS data
* @brief Read GPS data
*
* @param pvParameters
*/
void gpsTask(void *pvParameters)
{
log_v("Task 2 - GPS Task - running on core %d", xPortGetCoreID());
log_v("GPS Task - running on core %d", xPortGetCoreID());
log_v("Stack size: %d", uxTaskGetStackHighWaterMark(NULL));
for (;;)
while (1)
{
while (gps->available() > 0)
{
Expand Down Expand Up @@ -81,7 +81,7 @@ void gpsTask(void *pvParameters)
}

/**
* @brief Init Task 2 GPS task
* @brief Init GPS task
*
*/
void initGpsTask()
Expand All @@ -90,14 +90,54 @@ void initGpsTask()
delay(500);
}

/**
* @brief CLI task
*
* @param param
*/
#ifndef DISABLE_CLI
void cliTask(void *param) {
for (;;) {
void cliTask(void *param)
{
while(1)
{
wcli.loop();
vTaskDelay(60 / portTICK_PERIOD_MS);
}
vTaskDelete(NULL);
}

/**
* @brief Init CLI task
*
*/
void initCLITask() { xTaskCreatePinnedToCore(cliTask, "cliTask ", 4000, NULL, 1, NULL, 1); }

#endif

#ifdef ENABLE_COMPASS
/**
* @brief Read Compass data task
*
* @param pvParameters
*/
void compassTask(void *pvParameters)
{
log_v("Compass Task - running on core %d", xPortGetCoreID());
log_v("Stack size: %d", uxTaskGetStackHighWaterMark(NULL));
while (1)
{
heading = getHeading();
vTaskDelay(200);
}
}

/**
* @brief Init Compass data task
*
*/
void initCompassTask()
{
xTaskCreatePinnedToCore(compassTask, PSTR("Compass Task"), 8192, NULL,tskIDLE_PRIORITY , NULL, 1);
delay(500);
}
#endif
2 changes: 2 additions & 0 deletions lib/tasks/tasks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,7 @@ void initLvglTask();
void gpsTask(void *pvParameters);
void initGpsTask();
void initCLITask();
void compassTask(void *pvParameters);
void initCompassTask();

#endif
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ monitor_filters =
esp32_exception_decoder
extra_scripts = pre:prebuild.py
build_flags =
-D CORE_DEBUG_LEVEL=0
-D CORE_DEBUG_LEVEL=5
-D USE_LINE_BUFFER=1
-D DISABLE_RADIO=1
-D BAUDRATE=115200
Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ void setup()
lv_screen_load(searchSatScreen);
#endif
initLvglTask();
initCompassTask();

#ifndef DISABLE_CLI
initCLI();
Expand Down

0 comments on commit 54c5f74

Please sign in to comment.