Squash of branch setup
This commit is contained in:
17
main/common/constants.h
Normal file
17
main/common/constants.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
// 800x480 = 384,000 pixels
|
||||
|
||||
#define EINK_WIDTH 800
|
||||
#define EINK_HEIGHT 480
|
||||
|
||||
#define CORE_0 0
|
||||
#define CORE_1 1
|
||||
|
||||
#define SYSTEM_SHUTDOWN_BIT (1 << 0)
|
||||
#define SYSTEM_RESTART_BIT (1 << 1)
|
||||
#define SYSTEM_START_BIT (1 << 2)
|
||||
//
|
||||
#define DISPLAY_READY_BIT (1 << 1)
|
||||
#define TOUCH_CALIBRATED_BIT (1 << 2)
|
||||
#define STORAGE_READY_BIT (1 << 3)
|
||||
#define NETWORK_READY_BIT (1 << 4)
|
||||
31
main/common/queue_defs.h
Normal file
31
main/common/queue_defs.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
#include <indev/lv_indev.h>
|
||||
|
||||
typedef enum {
|
||||
CMD_DISPLAY_UPDATE,
|
||||
CMD_SAVE_DATA,
|
||||
CMD_LOAD_DATA,
|
||||
CMD_REFRESH_DISPLAY,
|
||||
CMD_SYSTEM_STATUS,
|
||||
} cmd_type_t;
|
||||
|
||||
typedef struct {
|
||||
cmd_type_t type;
|
||||
uint32_t id;
|
||||
void* data;
|
||||
size_t len;
|
||||
QueueHandle_t reply_to; // NULL if one-way
|
||||
} async_cmd_t;
|
||||
|
||||
extern QueueHandle_t command_queue;
|
||||
|
||||
typedef struct {
|
||||
uint16_t x, y;
|
||||
lv_indev_state_t state; // LV_INDEV_STATE_PR/REL
|
||||
uint32_t timestamp;
|
||||
uint8_t gesture; // TAP, SWIPE, LONG_PRESS
|
||||
} touch_event_t;
|
||||
|
||||
extern QueueHandle_t touch_queue;
|
||||
|
||||
extern EventGroupHandle_t system_event_group;
|
||||
49
main/common/semaphore_guard.h
Normal file
49
main/common/semaphore_guard.h
Normal file
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/portmacro.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
struct SemaphoreGuard {
|
||||
public:
|
||||
|
||||
SemaphoreGuard(SemaphoreHandle_t semaphore) : semaphore(semaphore) { }
|
||||
|
||||
portBASE_TYPE take(TickType_t ticks_to_wait = portMAX_DELAY) {
|
||||
if (this->semaphore == nullptr) {
|
||||
ESP_LOGE("SemaphoreGuard", "Attempted to take a null semaphore");
|
||||
return pdFALSE;
|
||||
}
|
||||
portBASE_TYPE result = xSemaphoreTake(this->semaphore, ticks_to_wait);
|
||||
taken = (result == pdTRUE);
|
||||
return result;
|
||||
}
|
||||
|
||||
~SemaphoreGuard() {
|
||||
if (taken) {
|
||||
xSemaphoreGive(this->semaphore);
|
||||
}
|
||||
}
|
||||
|
||||
// allow move semantics
|
||||
SemaphoreGuard(SemaphoreGuard&& other) noexcept
|
||||
: semaphore(other.semaphore), taken(other.taken) {
|
||||
other.taken = false;
|
||||
}
|
||||
SemaphoreGuard& operator=(SemaphoreGuard&& other) noexcept {
|
||||
if (this != &other) {
|
||||
// move from other
|
||||
taken = other.taken;
|
||||
other.taken = false;
|
||||
semaphore = other.semaphore;
|
||||
other.semaphore = nullptr;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
// prevent copying
|
||||
SemaphoreGuard(const SemaphoreGuard&) = delete;
|
||||
SemaphoreGuard& operator=(const SemaphoreGuard&) = delete;
|
||||
SemaphoreHandle_t semaphore = nullptr;
|
||||
bool taken = false;
|
||||
};
|
||||
Reference in New Issue
Block a user