RadioSet: Add MT868 LongFast preset definion
This commit is contained in:
parent
e04474bb83
commit
b5c27e5cb4
50
ExternalApps/RadioSet/main/Source/Preset.h
Normal file
50
ExternalApps/RadioSet/main/Source/Preset.h
Normal file
@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
|
||||
#include <tt_hal_radio.h>
|
||||
|
||||
#include "Str.h"
|
||||
|
||||
class Preset {
|
||||
struct PresetItem {
|
||||
RadioParameter parameter;
|
||||
float value;
|
||||
PresetItem* next = nullptr;
|
||||
};
|
||||
|
||||
Str name;
|
||||
Modulation modulation;
|
||||
PresetItem* first = nullptr;
|
||||
PresetItem* last = nullptr;
|
||||
public:
|
||||
Preset(const char* const name, Modulation modulation)
|
||||
: name(name)
|
||||
, modulation(modulation)
|
||||
{}
|
||||
|
||||
virtual ~Preset() {
|
||||
PresetItem* n = first;
|
||||
while(n) {
|
||||
auto next = n->next;
|
||||
delete n;
|
||||
n = next;
|
||||
}
|
||||
}
|
||||
|
||||
void addParameter(RadioParameter parameter, float value) {
|
||||
auto node = new PresetItem;
|
||||
node->parameter = parameter;
|
||||
node->value = value;
|
||||
|
||||
if (last) {
|
||||
last->next = node;
|
||||
last = node;
|
||||
} else {
|
||||
first = node;
|
||||
last = node;
|
||||
}
|
||||
}
|
||||
|
||||
PresetItem* first() {
|
||||
return first;
|
||||
}
|
||||
};
|
||||
@ -1,12 +1,12 @@
|
||||
#include "RadioSet.h"
|
||||
#include "Str.h"
|
||||
#include "Preset.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <ctype.h>
|
||||
#include <tt_lvgl_toolbar.h>
|
||||
#include <tt_message_queue.h>
|
||||
|
||||
#include <initializer_list>
|
||||
|
||||
#include "tt_app_alertdialog.h"
|
||||
|
||||
@ -548,6 +548,7 @@ class SettingsView {
|
||||
static constexpr Modulation LAST_MODULATION = MODULATION_LRFHSS;
|
||||
static constexpr size_t MAX_MODEMS = LAST_MODULATION + 1;
|
||||
static constexpr size_t MAX_PARAMS = RADIO_NARROWGRID + 1;
|
||||
static constexpr size_t MAX_PRESETS = 32;
|
||||
|
||||
RadioHandle radios[MAX_RADIOS] = {0};
|
||||
size_t radioCount = 0;
|
||||
@ -560,6 +561,8 @@ class SettingsView {
|
||||
ParameterInput* paramInputs[MAX_PARAMS] = {0};
|
||||
size_t paramsAvailableCount = 0;
|
||||
|
||||
Preset* presets[MAX_PRESETS] = {0};
|
||||
size_t presetsCount = 0;
|
||||
|
||||
lv_obj_t* mainPanel = nullptr;
|
||||
lv_obj_t* deviceForm = nullptr;
|
||||
@ -571,6 +574,11 @@ class SettingsView {
|
||||
lv_obj_t *propertiesForm = nullptr;
|
||||
|
||||
public:
|
||||
void addPreset(Preset* preset) {
|
||||
presets[presetsCount] = preset;
|
||||
presetsCount++;
|
||||
}
|
||||
|
||||
void queryRadios() {
|
||||
DeviceId devices[MAX_RADIOS];
|
||||
uint16_t device_count = 0;
|
||||
@ -941,6 +949,18 @@ void RadioSet::onShow(AppHandle appHandle, lv_obj_t* parent) {
|
||||
lv_obj_remove_flag(wrapper, LV_OBJ_FLAG_SCROLLABLE);
|
||||
|
||||
settingsView = new SettingsView(wrapper);
|
||||
|
||||
auto presetMtEu868LongFast = new Preset("Meshtastic 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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user