feat(colorlcd): Special Function to set main screen (#2160)
* Special Function to set main screen (#2135) * chore: Add new SF to LUA constants list * Companion support * Formatting * get rid of magic number * Add function to get the number of custom screens * Change screen numbering from 0-based to 1-based. * Allow SetScreen custom function for Color LCD only * add range protection * cleanup * yet, range protection once again * fix: paintSpecialFunctionLine can't alter SF param data * Fix screen initialization in companion * move screen switching to the UI * Trigger view change from guiMain() * chore: Change "SET" to "Set" for consistency * fix: Somehow missed extra comma in `TW` Co-authored-by: Peter Feerick <peter.feerick@gmail.com> Co-authored-by: elecpower <neilh713@tpg.com.au> Co-authored-by: Raphael Coeffic <raphael.coeffic@frafos.com>
This commit is contained in:
co-authored by
Peter Feerick
elecpower
Raphael Coeffic
parent
b0c1315f61
commit
4e49ac68be
@@ -22,6 +22,7 @@
|
||||
#include "special_functions.h"
|
||||
#include "opentx.h"
|
||||
#include "libopenui.h"
|
||||
#include "view_main.h"
|
||||
|
||||
#define SET_DIRTY() storageDirty(functions == g_model.customFn ? EE_MODEL : EE_GENERAL)
|
||||
|
||||
@@ -241,8 +242,19 @@ class SpecialFunctionEditPage : public Page
|
||||
break;
|
||||
}
|
||||
|
||||
case FUNC_SET_SCREEN:
|
||||
new StaticText(specialFunctionOneWindow, grid.getLabelSlot(), STR_VALUE,
|
||||
0, COLOR_THEME_PRIMARY1);
|
||||
CFN_PARAM(cfn) = (int16_t)max(CFN_PARAM(cfn), (int16_t)1);
|
||||
CFN_PARAM(cfn) = (int16_t)min(
|
||||
CFN_PARAM(cfn), (int16_t)ViewMain::instance()->getMainViewsCount());
|
||||
new NumberEdit(specialFunctionOneWindow, grid.getFieldSlot(), 1,
|
||||
ViewMain::instance()->getMainViewsCount(),
|
||||
GET_SET_DEFAULT(CFN_PARAM(cfn)));
|
||||
grid.nextLine();
|
||||
break;
|
||||
|
||||
case FUNC_ADJUST_GVAR: {
|
||||
|
||||
new StaticText(specialFunctionOneWindow, grid.getLabelSlot(), STR_GLOBALVAR, 0, COLOR_THEME_PRIMARY1);
|
||||
auto gvarchoice =
|
||||
new Choice(specialFunctionOneWindow, grid.getFieldSlot(), 0,
|
||||
@@ -549,6 +561,10 @@ class SpecialFunctionButton : public Button
|
||||
dc->drawNumber(col3, line1, CFN_PARAM(cfn), COLOR_THEME_SECONDARY1 | PREC1, sizeof(CFN_PARAM(cfn)), nullptr, "s");
|
||||
break;
|
||||
|
||||
case FUNC_SET_SCREEN:
|
||||
dc->drawNumber(col2, line2, CFN_PARAM(cfn), COLOR_THEME_SECONDARY1);
|
||||
break;
|
||||
|
||||
case FUNC_ADJUST_GVAR:
|
||||
switch(CFN_GVAR_MODE(cfn)) {
|
||||
case FUNC_ADJUST_GVAR_CONSTANT:
|
||||
|
||||
@@ -107,7 +107,7 @@ void ViewMain::addMainView(Window* view, uint32_t viewId)
|
||||
auto view_obj = view->getLvObj();
|
||||
lv_obj_set_parent(view_obj, tile);
|
||||
|
||||
auto user_data = (void*)(unsigned long)viewId;
|
||||
auto user_data = (void*)(intptr_t)viewId;
|
||||
lv_obj_add_event_cb(tile, tile_view_deleted_cb, LV_EVENT_CHILD_DELETED, user_data);
|
||||
}
|
||||
|
||||
@@ -140,6 +140,11 @@ void ViewMain::setCurrentMainView(unsigned viewId)
|
||||
lv_obj_set_tile_id(tile_view, viewId, 0, LV_ANIM_OFF);
|
||||
}
|
||||
|
||||
void setRequestedMainView(uint8_t view)
|
||||
{
|
||||
g_model.view = view;
|
||||
}
|
||||
|
||||
void ViewMain::nextMainView()
|
||||
{
|
||||
auto view = getCurrentMainView();
|
||||
|
||||
@@ -75,11 +75,10 @@ class ViewMain: public Window
|
||||
void onEvent(event_t event) override;
|
||||
void onClicked() override;
|
||||
void onCancel() override;
|
||||
|
||||
|
||||
protected:
|
||||
static ViewMain * _instance;
|
||||
|
||||
unsigned views = 0;
|
||||
lv_obj_t* tile_view = nullptr;
|
||||
TopbarImpl* topbar = nullptr;
|
||||
bool widget_select = false;
|
||||
|
||||
Reference in New Issue
Block a user