start wlvgl
This commit is contained in:
parent
6542b16a96
commit
a680363bf9
@ -16,6 +16,7 @@ set(SOURCES
|
|||||||
"state_tracking.cpp"
|
"state_tracking.cpp"
|
||||||
"tft.cpp"
|
"tft.cpp"
|
||||||
"wires.cpp"
|
"wires.cpp"
|
||||||
|
"wlvgl.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
target_sources(${COMPONENT_LIB} PRIVATE ${SOURCES})
|
target_sources(${COMPONENT_LIB} PRIVATE ${SOURCES})
|
||||||
|
|||||||
@ -8,11 +8,11 @@ static const char* TAG = "leds";
|
|||||||
|
|
||||||
static led_strip_handle_t leds;
|
static led_strip_handle_t leds;
|
||||||
|
|
||||||
|
// TODO: rename these to playback_handler
|
||||||
static bool replay_handler(const char* event, char* arg) {
|
static bool replay_handler(const char* event, char* arg) {
|
||||||
if (strcmp(event, "LED_SET") == 0) {
|
if (strcmp(event, "LED_SET") == 0) {
|
||||||
uint32_t led = atoi(strtok(arg, ","));
|
uint32_t led = atoi(strtok(arg, ","));
|
||||||
uint32_t color = atoi(strtok(NULL, ","));
|
uint32_t color = atoi(strtok(NULL, ","));
|
||||||
ESP_LOGI("leds", "color: %ld", color);
|
|
||||||
led_set(led, color);
|
led_set(led, color);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
#include "state_tracking.h"
|
#include "state_tracking.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "wlvgl.h"
|
||||||
|
|
||||||
static const char* PLAYBACK_TAG = "playback";
|
static const char* PLAYBACK_TAG = "playback";
|
||||||
|
|
||||||
@ -171,6 +172,7 @@ bool start_recording() {
|
|||||||
state = STATE_RECORDING;
|
state = STATE_RECORDING;
|
||||||
recording_start_time = xTaskGetTickCount();
|
recording_start_time = xTaskGetTickCount();
|
||||||
xTaskCreate(flush_file_task, "flush_recording", 2048, NULL, 2, &flush_file_task_handle);
|
xTaskCreate(flush_file_task, "flush_recording", 2048, NULL, 2, &flush_file_task_handle);
|
||||||
|
reset_wlv_tables(); // TODO: generify this
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,6 +200,7 @@ bool start_playback() {
|
|||||||
state = STATE_PLAYBACK;
|
state = STATE_PLAYBACK;
|
||||||
playback_start_time = xTaskGetTickCount();
|
playback_start_time = xTaskGetTickCount();
|
||||||
xTaskCreate(playback_task, "playback", 4096, NULL, 2, &playback_task_handle);
|
xTaskCreate(playback_task, "playback", 4096, NULL, 2, &playback_task_handle);
|
||||||
|
reset_wlv_tables(); // TODO: generify this
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
55
main/drivers/wlvgl.cpp
Normal file
55
main/drivers/wlvgl.cpp
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#include "wlvgl.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
/// A table that maps an incrementing integer to a style reference
|
||||||
|
static std::vector<lv_style_t*> style_table;
|
||||||
|
|
||||||
|
/// A table that maps an incrementing integer to a style reference
|
||||||
|
static std::vector<lv_obj_t*> obj_table;
|
||||||
|
|
||||||
|
void reset_wlv_tables() {
|
||||||
|
style_table.clear();
|
||||||
|
obj_table.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
lv_obj_t wlv_obj_create(lv_obj_t* parent) {
|
||||||
|
// initialize the obj
|
||||||
|
lv_obj_t value = lv_obj_create(parent);
|
||||||
|
|
||||||
|
if (is_state_tracking()) {
|
||||||
|
// add the style to the table
|
||||||
|
obj_table.push_back(value);
|
||||||
|
size_t obj_index = obj_table.size();
|
||||||
|
|
||||||
|
char buf[8];
|
||||||
|
sprintf(buf, "%d", obj_index);
|
||||||
|
event_occured("lv_obj_create", buf);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wlv_style_init(lv_style_t* style) {
|
||||||
|
// initialize the style
|
||||||
|
lv_style_init(style);
|
||||||
|
|
||||||
|
if (is_state_tracking()) {
|
||||||
|
// add the style to the table
|
||||||
|
style_table.push_back(style);
|
||||||
|
size_t style_index = style_table.size();
|
||||||
|
|
||||||
|
char buf[8];
|
||||||
|
sprintf(buf, "%d", style_index);
|
||||||
|
event_occured("lv_style_init", buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wlv_obj_set_style_bg_color(lv_obj_t* obj, lv_color_t value, lv_style_selector_t selector) {
|
||||||
|
lv_obj_set_style_bg_color(obj, value, selector);
|
||||||
|
|
||||||
|
if (is_state_tracking()) {
|
||||||
|
char buf[8];
|
||||||
|
sprintf(buf, "%d", style_index);
|
||||||
|
event_occured("lv_obj_set_style_bg_color", buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
13
main/drivers/wlvgl.h
Normal file
13
main/drivers/wlvgl.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef WLVGL_H
|
||||||
|
#define WLVGL_H
|
||||||
|
|
||||||
|
#include "lvgl.h"
|
||||||
|
#include "state_tracking.h"
|
||||||
|
|
||||||
|
void reset_wlv_tables();
|
||||||
|
|
||||||
|
void wlv_obj_create(lv_obj_t* parent);
|
||||||
|
void wlv_style_init(lv_style_t* style);
|
||||||
|
void wlv_obj_set_style_bg_color(struct _lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector);
|
||||||
|
|
||||||
|
#endif /* WLVGL_H */
|
||||||
@ -120,7 +120,6 @@ void display_game_results(void) {
|
|||||||
|
|
||||||
lv_style_init(&game_results_style);
|
lv_style_init(&game_results_style);
|
||||||
lv_style_set_text_color(&game_results_style, lv_color_white());
|
lv_style_set_text_color(&game_results_style, lv_color_white());
|
||||||
// lv_style_set_bg_color(&game_results_style, lv_color_black());
|
|
||||||
lv_style_set_text_align(&game_results_style, LV_TEXT_ALIGN_LEFT);
|
lv_style_set_text_align(&game_results_style, LV_TEXT_ALIGN_LEFT);
|
||||||
|
|
||||||
overall_results_label = lv_label_create(scr);
|
overall_results_label = lv_label_create(scr);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user