fix(color): portrait layout issues (#5474)
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
#include "afhds3_options.h"
|
||||
#include "edgetx.h"
|
||||
|
||||
static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1),
|
||||
static const lv_coord_t col_dsc[] = {LV_GRID_FR(2), LV_GRID_FR(3),
|
||||
LV_GRID_TEMPLATE_LAST};
|
||||
static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT,
|
||||
LV_GRID_TEMPLATE_LAST};
|
||||
@@ -40,46 +40,25 @@ static const uint16_t _v0_index2pwmvalue[] = {50, 333, 50};
|
||||
static uint16_t _v1_pwmvalue_type[2][32] = {0xff};
|
||||
static uint8_t channel_num[]={18, 10, 18, 8, 12};
|
||||
|
||||
struct PWMfrequencyChoice : public Window {
|
||||
PWMfrequencyChoice(Window* parent, uint8_t moduleIdx, uint8_t channelIdx);
|
||||
PWMfrequencyChoice(Window* parent, uint8_t moduleIdx);
|
||||
|
||||
static LAYOUT_VAL(NUM_W, 60, 60)
|
||||
|
||||
static void pwmfreq_changed(lv_event_t* e)
|
||||
{
|
||||
auto obj = lv_event_get_target(e);
|
||||
auto dat = (Choice*)lv_obj_get_user_data(obj);
|
||||
if (!dat) return;
|
||||
private:
|
||||
NumberEdit* num_edit = nullptr;
|
||||
};
|
||||
|
||||
auto num_edit_obj = (lv_obj_t*)lv_event_get_user_data(e);
|
||||
if (!num_edit_obj) return;
|
||||
|
||||
if (dat->getIntValue() == 4) {
|
||||
lv_obj_clear_flag(num_edit_obj, LV_OBJ_FLAG_HIDDEN);
|
||||
} else {
|
||||
lv_obj_add_flag(num_edit_obj, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
}
|
||||
static void pwmfreq_changedV0(lv_event_t* e)
|
||||
{
|
||||
auto obj = lv_event_get_target(e);
|
||||
auto dat = (Choice*)lv_obj_get_user_data(obj);
|
||||
if (!dat) return;
|
||||
|
||||
auto num_edit_obj = (lv_obj_t*)lv_event_get_user_data(e);
|
||||
if (!num_edit_obj) return;
|
||||
|
||||
if (dat->getIntValue() == 2) {
|
||||
lv_obj_clear_flag(num_edit_obj, LV_OBJ_FLAG_HIDDEN);
|
||||
} else {
|
||||
lv_obj_add_flag(num_edit_obj, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
}
|
||||
PWMfrequencyChoice::PWMfrequencyChoice(Window* parent, uint8_t moduleIdx, uint8_t channelIdx) :
|
||||
Window(parent, rect_t{})
|
||||
{
|
||||
padAll(PAD_TINY);
|
||||
setFlexLayout(LV_FLEX_FLOW_ROW, PAD_TINY, LV_SIZE_CONTENT);
|
||||
uint16_t &pwmvalue_type = _v1_pwmvalue_type[moduleIdx][channelIdx];
|
||||
auto cfg = afhds3::getConfig(moduleIdx);
|
||||
auto vCfg = &cfg->v1;
|
||||
if( 0xff ==pwmvalue_type )
|
||||
if( 0xff == pwmvalue_type )
|
||||
{
|
||||
if ( 50 == vCfg->PWMFrequenciesV1.PWMFrequencies[channelIdx] ) pwmvalue_type = 0;
|
||||
else if ( 333 == vCfg->PWMFrequenciesV1.PWMFrequencies[channelIdx] ) pwmvalue_type = 1;
|
||||
@@ -87,64 +66,58 @@ PWMfrequencyChoice::PWMfrequencyChoice(Window* parent, uint8_t moduleIdx, uint8_
|
||||
else if ( 1 == vCfg->PWMFrequenciesV1.PWMFrequencies[channelIdx] ) pwmvalue_type = 3;
|
||||
else pwmvalue_type = 4;
|
||||
}
|
||||
auto choice = new Choice(this, rect_t{}, _v1_pwmfreq_types, 0, 4,
|
||||
new Choice(this, rect_t{}, _v1_pwmfreq_types, 0, 4,
|
||||
[=,&pwmvalue_type]{
|
||||
return pwmvalue_type;
|
||||
},
|
||||
[=,&pwmvalue_type](int32_t newValue) {
|
||||
pwmvalue_type=newValue;
|
||||
pwmvalue_type = newValue;
|
||||
vCfg->PWMFrequenciesV1.PWMFrequencies[channelIdx] = _v1_index2pwmvalue[newValue];
|
||||
DIRTY_CMD(cfg, afhds3::DirtyConfig::DC_RX_CMD_FREQUENCY_V1);
|
||||
if (num_edit)
|
||||
num_edit->show(pwmvalue_type == 4);
|
||||
});
|
||||
auto num_edit = new NumberEdit(this, rect_t{}, 50, 400,
|
||||
num_edit = new NumberEdit(this, {0, 0, NUM_W, 0}, 50, 400,
|
||||
[=,&pwmvalue_type] { return (pwmvalue_type==4?vCfg->PWMFrequenciesV1.PWMFrequencies[channelIdx]:50); },
|
||||
[=](int16_t newVal) {
|
||||
vCfg->PWMFrequenciesV1.PWMFrequencies[channelIdx] = newVal;
|
||||
DIRTY_CMD(cfg, afhds3::DirtyConfig::DC_RX_CMD_FREQUENCY_V1);
|
||||
});
|
||||
c_obj = choice->getLvObj();
|
||||
auto btn_obj = num_edit->getLvObj();
|
||||
lv_obj_add_event_cb(c_obj, pwmfreq_changed, LV_EVENT_VALUE_CHANGED, btn_obj);
|
||||
lv_event_send(c_obj, LV_EVENT_VALUE_CHANGED, nullptr);
|
||||
num_edit->show(pwmvalue_type == 4);
|
||||
}
|
||||
|
||||
PWMfrequencyChoice::PWMfrequencyChoice(Window* parent, uint8_t moduleIdx ) :
|
||||
Window(parent, rect_t{})
|
||||
{
|
||||
padAll(PAD_TINY);
|
||||
setFlexLayout(LV_FLEX_FLOW_ROW, PAD_TINY, LV_SIZE_CONTENT);
|
||||
uint16_t &pwmvalue_type = _v1_pwmvalue_type[moduleIdx][0];
|
||||
auto cfg = afhds3::getConfig(moduleIdx);
|
||||
auto vCfg = &cfg->v0;
|
||||
if( 0xff ==pwmvalue_type )
|
||||
if( 0xff == pwmvalue_type )
|
||||
{
|
||||
if ( 50 == (vCfg->PWMFrequency.Frequency&0x7fff) ) pwmvalue_type = 0;
|
||||
else if ( 333 == (vCfg->PWMFrequency.Frequency&0x7fff) ) pwmvalue_type = 1;
|
||||
else pwmvalue_type = 2;
|
||||
}
|
||||
auto choice = new Choice(this, rect_t{}, _v0_pwmfreq_types, 0, 2,
|
||||
new Choice(this, rect_t{}, _v0_pwmfreq_types, 0, 2,
|
||||
[=,&pwmvalue_type]{
|
||||
return pwmvalue_type;
|
||||
},
|
||||
[=,&pwmvalue_type](int32_t newValue) {
|
||||
pwmvalue_type=newValue;
|
||||
pwmvalue_type = newValue;
|
||||
vCfg->PWMFrequency.Frequency = _v0_index2pwmvalue[newValue];
|
||||
DIRTY_CMD(cfg, afhds3::DirtyConfig::DC_RX_CMD_FREQUENCY_V0);
|
||||
if (num_edit)
|
||||
num_edit->show(pwmvalue_type == 2);
|
||||
});
|
||||
auto num_edit = new NumberEdit(this, rect_t{}, 50, 400,
|
||||
num_edit = new NumberEdit(this, {0, 0, NUM_W, 0}, 50, 400,
|
||||
[=,&pwmvalue_type] { return (pwmvalue_type==2?vCfg->PWMFrequency.Frequency&0x7fff:50); },
|
||||
[=](int16_t newVal) {
|
||||
vCfg->PWMFrequency.Frequency = newVal;
|
||||
DIRTY_CMD(cfg, afhds3::DirtyConfig::DC_RX_CMD_FREQUENCY_V0);
|
||||
});
|
||||
c_obj = choice->getLvObj();
|
||||
auto btn_obj = num_edit->getLvObj();
|
||||
lv_obj_add_event_cb(c_obj, pwmfreq_changedV0, LV_EVENT_VALUE_CHANGED, btn_obj);
|
||||
lv_event_send(c_obj, LV_EVENT_VALUE_CHANGED, nullptr);
|
||||
}
|
||||
|
||||
void PWMfrequencyChoice::update() const
|
||||
{
|
||||
lv_event_send(c_obj, LV_EVENT_VALUE_CHANGED, nullptr);
|
||||
num_edit->show(pwmvalue_type == 2);
|
||||
}
|
||||
|
||||
AFHDS3_Options::AFHDS3_Options(uint8_t moduleIdx) : Page(ICON_MODEL_SETUP)
|
||||
@@ -159,7 +132,7 @@ AFHDS3_Options::AFHDS3_Options(uint8_t moduleIdx) : Page(ICON_MODEL_SETUP)
|
||||
title += ")";
|
||||
header->setTitle2(title);
|
||||
|
||||
body->setFlexLayout();
|
||||
body->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_TINY);
|
||||
|
||||
FlexGridLayout grid(col_dsc, row_dsc, PAD_TINY);
|
||||
|
||||
@@ -167,14 +140,13 @@ AFHDS3_Options::AFHDS3_Options(uint8_t moduleIdx) : Page(ICON_MODEL_SETUP)
|
||||
auto vCfg = &cfg->v0;
|
||||
|
||||
auto line = body->newLine(grid);
|
||||
std::string temp_str = "PWM";
|
||||
temp_str += TR_POWERMETER_FREQ;
|
||||
std::string temp_str = "PWM ";
|
||||
temp_str += STR_POWERMETER_FREQ;
|
||||
new StaticText(line, rect_t{}, temp_str);
|
||||
new PWMfrequencyChoice(line, moduleIdx);
|
||||
line = body->newLine(grid);
|
||||
|
||||
temp_str = "PWM";
|
||||
temp_str += " ";
|
||||
temp_str = "PWM ";
|
||||
temp_str += STR_SYNC;
|
||||
new StaticText(line, rect_t{}, temp_str);
|
||||
new ToggleSwitch(line, rect_t{}, GET_SET_AND_SYNC(cfg, vCfg->PWMFrequency.Synchronized,
|
||||
|
||||
@@ -24,15 +24,6 @@
|
||||
#include "page.h"
|
||||
#include "pulses/afhds3_config.h"
|
||||
|
||||
struct PWMfrequencyChoice : public Window {
|
||||
PWMfrequencyChoice(Window* parent, uint8_t moduleIdx, uint8_t channelIdx);
|
||||
PWMfrequencyChoice(Window* parent, uint8_t moduleIdx);
|
||||
void update() const;
|
||||
|
||||
private:
|
||||
lv_obj_t* c_obj;
|
||||
};
|
||||
|
||||
class AFHDS3_Options : public Page
|
||||
{
|
||||
afhds3::Config_u* cfg;
|
||||
|
||||
@@ -49,7 +49,7 @@ AFHDS3Settings::AFHDS3Settings(Window* parent, const FlexGridLayout& g,
|
||||
md(&g_model.moduleData[moduleIdx]),
|
||||
grid(g)
|
||||
{
|
||||
setFlexLayout();
|
||||
setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_TINY);
|
||||
|
||||
FormLine* line;
|
||||
|
||||
@@ -68,7 +68,8 @@ AFHDS3Settings::AFHDS3Settings(Window* parent, const FlexGridLayout& g,
|
||||
new StaticText(line, rect_t{}, STR_TYPE);
|
||||
|
||||
afhds3TypeForm = new Window(line, rect_t{});
|
||||
afhds3TypeForm->setFlexLayout(LV_FLEX_FLOW_ROW_WRAP);
|
||||
afhds3TypeForm->padAll(PAD_TINY);
|
||||
afhds3TypeForm->setFlexLayout(LV_FLEX_FLOW_ROW_WRAP, PAD_TINY);
|
||||
lv_obj_set_style_grid_cell_x_align(afhds3TypeForm->getLvObj(),
|
||||
LV_GRID_ALIGN_STRETCH, 0);
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ class ChannelFailsafeEdit : public NumberEdit
|
||||
|
||||
public:
|
||||
ChannelFailsafeEdit(Window* parent, uint8_t ch, int vmin, int vmax) :
|
||||
NumberEdit(parent, rect_t{}, vmin, vmax, nullptr), channel(ch)
|
||||
NumberEdit(parent, rect_t{0, 0, NUM_W, 0}, vmin, vmax, nullptr), channel(ch)
|
||||
{
|
||||
setGetValueHandler(
|
||||
[=]() { return calcRESXto1000(g_model.failsafeChannels[ch]); });
|
||||
@@ -150,6 +150,8 @@ class ChannelFailsafeEdit : public NumberEdit
|
||||
g_model.failsafeChannels[channel] = channelOutputs[channel];
|
||||
update();
|
||||
}
|
||||
|
||||
static LAYOUT_VAL(NUM_W, 70, 70)
|
||||
};
|
||||
|
||||
class ChannelFSCombo : public Window
|
||||
@@ -164,7 +166,7 @@ class ChannelFSCombo : public Window
|
||||
|
||||
setFlexLayout(LV_FLEX_FLOW_ROW, PAD_TINY, LV_SIZE_CONTENT);
|
||||
|
||||
lv_obj_set_style_pad_column(lvobj, PAD_SMALL, 0);
|
||||
lv_obj_set_style_pad_column(lvobj, PAD_TINY, 0);
|
||||
lv_obj_set_style_flex_cross_place(lvobj, LV_FLEX_ALIGN_CENTER, 0);
|
||||
|
||||
edit = new ChannelFailsafeEdit(this, ch, vmin, vmax);
|
||||
@@ -182,7 +184,7 @@ class ChannelFSCombo : public Window
|
||||
void update() { edit->update(); }
|
||||
};
|
||||
|
||||
static const lv_coord_t line_col_dsc[] = {LV_GRID_FR(2), LV_GRID_FR(3),
|
||||
static const lv_coord_t line_col_dsc[] = {LV_GRID_FR(2), LV_GRID_FR(5),
|
||||
LV_GRID_FR(3), LV_GRID_TEMPLATE_LAST};
|
||||
static const lv_coord_t line_row_dsc[] = {LV_GRID_CONTENT,
|
||||
LV_GRID_TEMPLATE_LAST};
|
||||
@@ -193,12 +195,6 @@ static void set_failsafe(lv_event_t* e)
|
||||
if (combo) combo->update();
|
||||
}
|
||||
|
||||
#if PORTRAIT_LCD
|
||||
#define FS_BARGRAPH_WIDTH (LV_DPI_DEF / 2)
|
||||
#else
|
||||
#define FS_BARGRAPH_WIDTH (LV_DPI_DEF)
|
||||
#endif
|
||||
|
||||
FailSafePage::FailSafePage(uint8_t moduleIdx) : Page(ICON_STATS_ANALOGS)
|
||||
{
|
||||
header->setTitle(STR_FAILSAFESET);
|
||||
@@ -236,7 +232,7 @@ FailSafePage::FailSafePage(uint8_t moduleIdx) : Page(ICON_STATS_ANALOGS)
|
||||
|
||||
// Channel bargraph
|
||||
auto bar = new ChannelFailsafeBargraph(
|
||||
line, rect_t{0, 0, FS_BARGRAPH_WIDTH, 32}, ch);
|
||||
line, rect_t{0, 0, FS_BARGRAPH_WIDTH, EdgeTxStyles::UI_ELEMENT_HEIGHT}, ch);
|
||||
lv_obj_set_style_grid_cell_x_align(bar->getLvObj(), LV_GRID_ALIGN_END, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,4 +27,6 @@ class FailSafePage : public Page
|
||||
{
|
||||
public:
|
||||
explicit FailSafePage(uint8_t moduleIdx);
|
||||
|
||||
static LAYOUT_VAL(FS_BARGRAPH_WIDTH, 130, 90)
|
||||
};
|
||||
|
||||
@@ -85,6 +85,8 @@ class ModuleWindow : public Window
|
||||
|
||||
uint8_t getModuleIdx() const { return moduleIdx; }
|
||||
|
||||
static LAYOUT_VAL(NUM_W, 60, 60)
|
||||
|
||||
protected:
|
||||
uint8_t moduleIdx;
|
||||
|
||||
@@ -279,7 +281,7 @@ void ModuleWindow::updateModule()
|
||||
|
||||
// Model index
|
||||
auto modelId = &g_model.header.modelId[moduleIdx];
|
||||
rxID = new NumberEdit(box, rect_t{}, 0, getMaxRxNum(moduleIdx),
|
||||
rxID = new NumberEdit(box, {0, 0, NUM_W, 0}, 0, getMaxRxNum(moduleIdx),
|
||||
GET_DEFAULT(*modelId), [=](int32_t newValue) {
|
||||
if (newValue != *modelId) {
|
||||
*modelId = newValue;
|
||||
|
||||
Reference in New Issue
Block a user