-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate to FreeRTOS for UI and camera control. (#126)
Still using the Arduino framework, however we now use the underlying FreeRTOS for better control over tasks. Initially, split the UI and control to separate tasks, furthermore, use a queue to manage camera control. This almost allows the UI to operate without constraints on camera traffic.
- Loading branch information
Showing
12 changed files
with
186 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef FURBLE_CONTROL_H | ||
#define FURBLE_CONTROL_H | ||
|
||
#include <Camera.h> | ||
|
||
#define CONTROL_CMD_QUEUE_LEN (32) | ||
|
||
typedef enum { | ||
CONTROL_CMD_SHUTTER_PRESS, | ||
CONTROL_CMD_SHUTTER_RELEASE, | ||
CONTROL_CMD_FOCUS_PRESS, | ||
CONTROL_CMD_FOCUS_RELEASE, | ||
CONTROL_CMD_GPS_UPDATE | ||
} control_cmd_t; | ||
|
||
void control_update_gps(Furble::Camera::gps_t &gps, Furble::Camera::timesync_t ×ync); | ||
void control_task(void *param); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,6 @@ struct FurbleCtx { | |
bool reconnected; | ||
}; | ||
|
||
void vUITask(void *param); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include <CameraList.h> | ||
|
||
#include "furble_control.h" | ||
|
||
static QueueHandle_t queue; | ||
|
||
static Furble::Camera::gps_t last_gps; | ||
static Furble::Camera::timesync_t last_timesync; | ||
|
||
void control_update_gps(Furble::Camera::gps_t &gps, Furble::Camera::timesync_t ×ync) { | ||
last_gps = gps; | ||
last_timesync = timesync; | ||
|
||
control_cmd_t cmd = CONTROL_CMD_GPS_UPDATE; | ||
xQueueSend(queue, &cmd, sizeof(control_cmd_t)); | ||
} | ||
|
||
void control_task(void *param) { | ||
queue = static_cast<QueueHandle_t>(param); | ||
|
||
while (true) { | ||
control_cmd_t cmd; | ||
BaseType_t ret = xQueueReceive(queue, &cmd, pdMS_TO_TICKS(50)); | ||
if (ret == pdTRUE) { | ||
for (size_t n = 0; n < Furble::CameraList::size(); n++) { | ||
Furble::Camera *camera = Furble::CameraList::get(n); | ||
if (!camera->isActive()) { | ||
continue; | ||
} | ||
|
||
switch (cmd) { | ||
case CONTROL_CMD_SHUTTER_PRESS: | ||
camera->shutterPress(); | ||
ESP_LOGI(LOG_TAG, "shutterPress()"); | ||
break; | ||
case CONTROL_CMD_SHUTTER_RELEASE: | ||
ESP_LOGI(LOG_TAG, "shutterRelease()"); | ||
camera->shutterRelease(); | ||
break; | ||
case CONTROL_CMD_FOCUS_PRESS: | ||
ESP_LOGI(LOG_TAG, "focusPress()"); | ||
camera->focusPress(); | ||
break; | ||
case CONTROL_CMD_FOCUS_RELEASE: | ||
ESP_LOGI(LOG_TAG, "focusRelease()"); | ||
camera->focusRelease(); | ||
break; | ||
case CONTROL_CMD_GPS_UPDATE: | ||
ESP_LOGI(LOG_TAG, "updateGeoData()"); | ||
camera->updateGeoData(last_gps, last_timesync); | ||
break; | ||
default: | ||
ESP_LOGE(LOG_TAG, "Invalid control command %d.", cmd); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.