104 lines
3.4 KiB
C++
104 lines
3.4 KiB
C++
#include "RadioSet.h"
|
|
#include "Str.h"
|
|
#include "LinkedList.h"
|
|
#include "Preset.h"
|
|
#include "Utils.h"
|
|
|
|
#include <cstdio>
|
|
#include <ctype.h>
|
|
#include <tt_lvgl_toolbar.h>
|
|
|
|
constexpr const char* TAG = "RadioSet";
|
|
|
|
// Debug function which colors all children randomly
|
|
// TODO: Remove before flight
|
|
void clownvomit(lv_obj_t *obj) {
|
|
static auto rng = []() {
|
|
static int color = 0xC0FE;
|
|
const int a = 4711;
|
|
const int m = 0x10001;
|
|
color = (a * color) % m;
|
|
return color;
|
|
};
|
|
|
|
const int darken = 0x0E0E0E;
|
|
const int lighten = 0xFEFEFE;
|
|
lv_obj_set_style_bg_color(obj, lv_color_hex(rng() & darken), 0);
|
|
|
|
uint32_t i;
|
|
for(i = 0; i < lv_obj_get_child_count(obj); i++) {
|
|
lv_obj_t * child = lv_obj_get_child(obj, i);
|
|
lv_obj_set_style_bg_color(child, lv_color_hex(rng() & darken), 0);
|
|
lv_obj_set_style_border_color(child, lv_color_hex(rng() | lighten), 0);
|
|
lv_obj_set_style_border_width(child, 1, 0);
|
|
clownvomit(child);
|
|
}
|
|
}
|
|
/*
|
|
void scrollbar_highlight(lv_event_t * e) {
|
|
lv_obj_t * obj = lv_event_get_target(e);
|
|
}*/
|
|
|
|
|
|
class TermView {
|
|
|
|
};
|
|
|
|
|
|
void RadioSet::onShow(AppHandle appHandle, lv_obj_t* parent) {
|
|
lv_obj_remove_flag(parent, LV_OBJ_FLAG_SCROLLABLE);
|
|
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
|
|
lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT);
|
|
|
|
lv_obj_t* toolbar = tt_lvgl_toolbar_create_for_app(parent, appHandle);
|
|
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
|
|
|
|
uiDropDownMenu = lv_dropdown_create(toolbar);
|
|
|
|
lv_dropdown_set_options(uiDropDownMenu, LV_SYMBOL_ENVELOPE " Terminal\n" LV_SYMBOL_SETTINGS " Settings");
|
|
lv_dropdown_set_text(uiDropDownMenu, "Menu");
|
|
lv_dropdown_set_symbol(uiDropDownMenu, LV_SYMBOL_DOWN);
|
|
lv_dropdown_set_selected_highlight(uiDropDownMenu, true);
|
|
lv_obj_set_style_border_color(uiDropDownMenu, lv_color_hex(0xFAFAFA), LV_PART_MAIN);
|
|
lv_obj_set_style_border_width(uiDropDownMenu, 1, LV_PART_MAIN);
|
|
lv_obj_align(uiDropDownMenu, LV_ALIGN_RIGHT_MID, 0, 0);
|
|
lv_obj_set_width(uiDropDownMenu, 120);
|
|
|
|
lv_obj_t* wrapper = lv_obj_create(parent);
|
|
lv_obj_set_flex_flow(wrapper, LV_FLEX_FLOW_COLUMN);
|
|
lv_obj_set_flex_align(wrapper, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START);
|
|
lv_obj_set_flex_grow(wrapper, 1);
|
|
lv_obj_set_width(wrapper, LV_PCT(100));
|
|
lv_obj_set_height(wrapper, LV_PCT(100));
|
|
lv_obj_set_style_pad_all(wrapper, 0, LV_PART_MAIN);
|
|
lv_obj_set_style_pad_row(wrapper, 0, LV_PART_MAIN);
|
|
lv_obj_set_style_border_width(wrapper, 0, 0);
|
|
lv_obj_remove_flag(wrapper, LV_OBJ_FLAG_SCROLLABLE);
|
|
|
|
settingsView = new SettingsView(wrapper);
|
|
|
|
auto presetMtEu868LongFast = new Preset("MT EU868 LongFast", MODULATION_LORA);
|
|
presetMtEu868LongFast->addParameter(RADIO_FREQUENCY, 869.525);
|
|
presetMtEu868LongFast->addParameter(RADIO_BANDWIDTH, 250.0);
|
|
presetMtEu868LongFast->addParameter(RADIO_SPREADFACTOR, 11);
|
|
presetMtEu868LongFast->addParameter(RADIO_CODINGRATE, 6);
|
|
presetMtEu868LongFast->addParameter(RADIO_SYNCWORD, 0x2B);
|
|
presetMtEu868LongFast->addParameter(RADIO_PREAMBLES, 16);
|
|
|
|
settingsView->addPreset(presetMtEu868LongFast);
|
|
settingsView->updatePresets();
|
|
}
|
|
|
|
|
|
RadioSet::~RadioSet() {
|
|
if (termView) {
|
|
delete termView;
|
|
}
|
|
if (settingsView) {
|
|
delete settingsView;
|
|
}
|
|
}
|
|
|
|
// ????
|
|
extern "C" void __cxa_pure_virtual() { crash("Entered the Virtual Zone..."); }
|