1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-25 01:05:10 +03:00

[Horus] UI continued

This commit is contained in:
Bertrand Songis 2016-02-16 20:45:25 +01:00
parent e72a049683
commit 33910c8721
35 changed files with 301 additions and 75 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

View file

@ -259,11 +259,11 @@ const uint8_t LBM_STAR1[] __DMA = {
*/ */
const uint8_t LBM_HORUS[] __DMA = { const uint8_t LBM_HORUS[] __DMA = {
#include "bmp_horus.lbm" #include "alpha_horus.lbm"
}; };
const uint8_t LBM_STICK_BACKGROUND[] __DMA = { const uint8_t LBM_STICK_BACKGROUND[] __DMA = {
#include "bmp_stick_background.lbm" #include "alpha_stick_background.lbm"
}; };
const uint8_t LBM_STICK_POINTER[] __DMA = { const uint8_t LBM_STICK_POINTER[] __DMA = {
@ -299,7 +299,7 @@ const uint8_t LBM_SHUTDOWN[] __DMA = {
}; };
const uint8_t LBM_SLEEP[] __DMA = { const uint8_t LBM_SLEEP[] __DMA = {
#include "bmp_sleep.lbm" #include "alpha_sleep.lbm"
}; };
const uint8_t LBM_SHUTDOWN_CIRCLE[] __DMA = { const uint8_t LBM_SHUTDOWN_CIRCLE[] __DMA = {

View file

@ -75,3 +75,17 @@ Layout * loadLayout(const char * name, Layout::PersistentData * persistentData)
} }
return NULL; return NULL;
} }
void loadCustomScreens()
{
for (unsigned int i=0; i<MAX_CUSTOM_SCREENS; i++) {
char name[sizeof(g_model.screenData[i].layoutName)+1];
memset(name, 0, sizeof(name));
strncpy(name, g_model.screenData[i].layoutName, sizeof(g_model.screenData[i].layoutName));
customScreens[i] = loadLayout(name, &g_model.screenData[i].layoutData);
}
if (customScreens[0] == NULL) {
customScreens[0] = registeredLayouts[0]->create(&g_model.screenData[0].layoutData);
}
}

View file

@ -161,5 +161,6 @@ class BaseLayoutFactory: public LayoutFactory
extern unsigned int countRegisteredLayouts; extern unsigned int countRegisteredLayouts;
extern const LayoutFactory * registeredLayouts[MAX_REGISTERED_LAYOUTS]; extern const LayoutFactory * registeredLayouts[MAX_REGISTERED_LAYOUTS];
Layout * loadLayout(const char * name, Layout::PersistentData * persistentData); Layout * loadLayout(const char * name, Layout::PersistentData * persistentData);
void loadCustomScreens();
#endif // _LAYOUT_H_ #endif // _LAYOUT_H_

View file

@ -182,7 +182,7 @@ bool menuCommonCalib(evt_t event)
break; break;
} }
lcdDrawBitmap((LCD_W-206)/2, LCD_H-220, LBM_HORUS); lcdDrawAlphaBitmap((LCD_W-206)/2, LCD_H-220, LBM_HORUS);
drawSticks(); drawSticks();
drawPots(); drawPots();

View file

@ -301,10 +301,9 @@ bool menuScreensTheme(evt_t event)
lcdDrawText(MENUS_MARGIN_LEFT, y + FH / 2, "Theme"); lcdDrawText(MENUS_MARGIN_LEFT, y + FH / 2, "Theme");
const Theme * new_theme = editThemeChoice<const Theme>(SCREENS_SETUP_2ND_COLUMN, y, registeredThemes, countRegisteredThemes, theme, needsOffsetCheck, attr, event); const Theme * new_theme = editThemeChoice<const Theme>(SCREENS_SETUP_2ND_COLUMN, y, registeredThemes, countRegisteredThemes, theme, needsOffsetCheck, attr, event);
if (new_theme) { if (new_theme) {
theme = new_theme; loadTheme(new_theme);
theme->load(); strncpy(g_eeGeneral.themeName, new_theme->getName(), sizeof(g_eeGeneral.themeName));
// strncpy(g_model.screenData[T].layoutName, factory->getName(), sizeof(g_model.screenData[T].layoutName)); storageDirty(EE_GENERAL);
storageDirty(EE_MODEL);
} }
break; break;
} }
@ -317,12 +316,8 @@ bool menuScreensTheme(evt_t event)
return true; return true;
} }
bool menuScreenAdd(evt_t event) bool menuScreenAdd(evt_t event);
{ void onScreenSetupMenu(const char * result);
menuPageCount = updateMainviewsMenu();
MENU_WITH_OPTIONS("Add main view", LBM_MAINVIEWS_ICONS, menuTabMainviews, menuPageCount, menuPageCount-1, 0, { uint8_t(NAVIGATION_LINE_BY_LINE|uint8_t(countRegisteredLayouts-1)), ORPHAN_ROW, 0, 0, 0, 0 });
return true;
}
template <int T> template <int T>
bool menuScreenSetup(evt_t event) bool menuScreenSetup(evt_t event)
@ -342,6 +337,8 @@ bool menuScreenSetup(evt_t event)
menuPageCount = updateMainviewsMenu(); menuPageCount = updateMainviewsMenu();
MENU_WITH_OPTIONS(title, LBM_MAINVIEWS_ICONS, menuTabMainviews, menuPageCount, T+1, linesCount, { uint8_t(NAVIGATION_LINE_BY_LINE|uint8_t(countRegisteredLayouts-1)), ORPHAN_ROW, 0, 0, 0, 0 }); MENU_WITH_OPTIONS(title, LBM_MAINVIEWS_ICONS, menuTabMainviews, menuPageCount, T+1, linesCount, { uint8_t(NAVIGATION_LINE_BY_LINE|uint8_t(countRegisteredLayouts-1)), ORPHAN_ROW, 0, 0, 0, 0 });
for (int i=0; i<NUM_BODY_LINES; i++) { for (int i=0; i<NUM_BODY_LINES; i++) {
coord_t y = MENU_CONTENT_TOP + i * FH; coord_t y = MENU_CONTENT_TOP + i * FH;
int k = i + menuVerticalOffset; int k = i + menuVerticalOffset;
@ -384,6 +381,13 @@ bool menuScreenSetup(evt_t event)
} }
} }
if (menuVerticalPosition == -1 && T > 0 && event == EVT_KEY_LONG(KEY_ENTER)) {
killEvents(KEY_ENTER);
menuHorizontalPosition = T;
POPUP_MENU_ADD_ITEM(STR_REMOVE_SCREEN);
popupMenuHandler = onScreenSetupMenu;
}
return true; return true;
} }
@ -419,3 +423,31 @@ int updateMainviewsMenu()
} }
return 1+MAX_CUSTOM_SCREENS; return 1+MAX_CUSTOM_SCREENS;
} }
bool menuScreenAdd(evt_t event)
{
menuPageCount = updateMainviewsMenu();
if (event == EVT_KEY_BREAK(KEY_ENTER)) {
customScreens[menuPageCount-2] = registeredLayouts[0]->create(&g_model.screenData[menuPageCount-2].layoutData);
chainMenu(menuMainviews[menuPageCount-2]);
return false;
}
MENU_WITH_OPTIONS("Add main view", LBM_MAINVIEWS_ICONS, menuTabMainviews, menuPageCount, menuPageCount-1, 0, { uint8_t(NAVIGATION_LINE_BY_LINE|uint8_t(countRegisteredLayouts-1)), ORPHAN_ROW, 0, 0, 0, 0 });
return true;
}
void onScreenSetupMenu(const char * result)
{
if (result == STR_REMOVE_SCREEN) {
if (menuHorizontalPosition != MAX_CUSTOM_SCREENS-1) {
memmove(&g_model.screenData[menuHorizontalPosition], &g_model.screenData[menuHorizontalPosition + 1], sizeof(CustomScreenData) * (MAX_CUSTOM_SCREENS - menuHorizontalPosition - 1));
memmove(&customScreens[menuHorizontalPosition], &customScreens[menuHorizontalPosition + 1], sizeof(Layout *) * (MAX_CUSTOM_SCREENS - menuHorizontalPosition - 1));
}
memset(&g_model.screenData[MAX_CUSTOM_SCREENS-1], 0, sizeof(CustomScreenData));
customScreens[MAX_CUSTOM_SCREENS-1] = NULL;
chainMenu(menuMainviews[menuHorizontalPosition > 0 ? menuHorizontalPosition-1 : 0]);
}
}

View file

@ -40,3 +40,17 @@ const Theme * getTheme(const char * name)
return NULL; return NULL;
} }
void loadTheme(const Theme * new_theme)
{
theme = new_theme;
theme->load();
}
void loadTheme()
{
char name[sizeof(g_eeGeneral.themeName)+1];
memset(name, 0, sizeof(name));
strncpy(name, g_eeGeneral.themeName, sizeof(g_eeGeneral.themeName));
const Theme * new_theme = getTheme(name);
loadTheme(new_theme ? new_theme : theme);
}

View file

@ -61,6 +61,11 @@ extern const Theme * theme;
#define MAX_REGISTERED_THEMES 10 #define MAX_REGISTERED_THEMES 10
extern unsigned int countRegisteredThemes; extern unsigned int countRegisteredThemes;
void registerTheme(const Theme * theme);
extern const Theme * registeredThemes[MAX_REGISTERED_THEMES]; // TODO dynamic extern const Theme * registeredThemes[MAX_REGISTERED_THEMES]; // TODO dynamic
const Theme * getTheme(const char * name);
void loadTheme(const Theme * theme);
void loadTheme();
#endif // _THEME_H_ #endif // _THEME_H_

View file

@ -50,7 +50,7 @@ void drawTopbarDatetime()
#define STICK_PANEL_WIDTH 68 #define STICK_PANEL_WIDTH 68
void drawStick(coord_t x, coord_t y, int16_t xval, int16_t yval) void drawStick(coord_t x, coord_t y, int16_t xval, int16_t yval)
{ {
lcdDrawBitmap(x, y, LBM_STICK_BACKGROUND); lcdDrawAlphaBitmap(x, y, LBM_STICK_BACKGROUND);
lcdDrawAlphaBitmap(x + 2 + STICK_PANEL_WIDTH/2 + STICK_PANEL_WIDTH/2 * xval/RESX, y + 2 + STICK_PANEL_WIDTH/2 - STICK_PANEL_WIDTH/2 * yval/RESX, LBM_STICK_POINTER); lcdDrawAlphaBitmap(x + 2 + STICK_PANEL_WIDTH/2 + STICK_PANEL_WIDTH/2 * xval/RESX, y + 2 + STICK_PANEL_WIDTH/2 - STICK_PANEL_WIDTH/2 * yval/RESX, LBM_STICK_POINTER);
} }
@ -426,7 +426,7 @@ int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int
void drawSleepBitmap() void drawSleepBitmap()
{ {
lcdClear(); lcdClear();
lcdDrawBitmap((LCD_W-SLEEP_BITMAP_WIDTH)/2, (LCD_H-SLEEP_BITMAP_HEIGHT)/2, LBM_SLEEP); lcdDrawAlphaBitmap((LCD_W-SLEEP_BITMAP_WIDTH)/2, (LCD_H-SLEEP_BITMAP_HEIGHT)/2, LBM_SLEEP);
lcdRefresh(); lcdRefresh();
} }

View file

@ -498,9 +498,9 @@ void lcdDrawLine(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat, Lc
} }
} }
void lcdDrawSolidVerticalLine(coord_t x, scoord_t y, scoord_t h) void lcdDrawSolidVerticalLine(coord_t x, scoord_t y, scoord_t h, LcdFlags att)
{ {
lcdDrawVerticalLine(x, y, h, SOLID); lcdDrawVerticalLine(x, y, h, SOLID, att);
} }
#endif #endif

View file

@ -179,7 +179,7 @@ void lcdDrawPoint(coord_t x, coord_t y, LcdFlags att=0);
void lcdMaskPoint(uint8_t *p, uint8_t mask, LcdFlags att=0); void lcdMaskPoint(uint8_t *p, uint8_t mask, LcdFlags att=0);
void lcdDrawSolidHorizontalLine(coord_t x, coord_t y, coord_t w, LcdFlags att=0); void lcdDrawSolidHorizontalLine(coord_t x, coord_t y, coord_t w, LcdFlags att=0);
void lcdDrawHorizontalLine(coord_t x, coord_t y, coord_t w, uint8_t pat, LcdFlags att=0); void lcdDrawHorizontalLine(coord_t x, coord_t y, coord_t w, uint8_t pat, LcdFlags att=0);
void lcdDrawSolidVerticalLine(coord_t x, scoord_t y, scoord_t h); void lcdDrawSolidVerticalLine(coord_t x, scoord_t y, scoord_t h, LcdFlags att=0);
void lcdDrawVerticalLine(coord_t x, scoord_t y, scoord_t h, uint8_t pat, LcdFlags att=0); void lcdDrawVerticalLine(coord_t x, scoord_t y, scoord_t h, uint8_t pat, LcdFlags att=0);
void lcdDrawLine(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat=SOLID, LcdFlags att=0); void lcdDrawLine(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat=SOLID, LcdFlags att=0);
void lcdDrawFilledRect(coord_t x, scoord_t y, coord_t w, coord_t h, uint8_t pat=SOLID, LcdFlags att=0); void lcdDrawFilledRect(coord_t x, scoord_t y, coord_t w, coord_t h, uint8_t pat=SOLID, LcdFlags att=0);

View file

@ -39,7 +39,7 @@
#include "opentx.h" #include "opentx.h"
#include "bin_allocator.h" #include "bin_allocator.h"
#include "lua/lua_api.h" #include "lua/lua_api.h"
#if defined(LUA_COMPILER) && defined(SIMU) #if defined(LUA_COMPILER) && defined(SIMU)
#include <lundump.h> #include <lundump.h>
#include <lstate.h> #include <lstate.h>
@ -185,7 +185,12 @@ void luaRegisterAll()
void luaInit() void luaInit()
{ {
TRACE("luaInit");
#if !defined(COLORLCD)
luaClose(); luaClose();
#endif
if (luaState != INTERPRETER_PANIC) { if (luaState != INTERPRETER_PANIC) {
#if defined(USE_BIN_ALLOCATOR) #if defined(USE_BIN_ALLOCATOR)
L = lua_newstate(bin_l_alloc, NULL); //we use our own allocator! L = lua_newstate(bin_l_alloc, NULL); //we use our own allocator!
@ -212,6 +217,10 @@ void luaInit()
luaDisable(); luaDisable();
} }
} }
#if defined(COLORLCD)
luaLoadThemes();
#endif
} }
void luaFree(ScriptInternalData & sid) void luaFree(ScriptInternalData & sid)
@ -271,7 +280,7 @@ static void luaCompileAndSave(const char *bytecodeName)
} }
#endif #endif
int luaLoad(const char *filename, ScriptInternalData & sid, ScriptInputsOutputs * sio=NULL) int luaLoad(const char * filename, ScriptInternalData & sid, ScriptInputsOutputs * sio=NULL)
{ {
int init = 0; int init = 0;
@ -301,7 +310,7 @@ int luaLoad(const char *filename, ScriptInternalData & sid, ScriptInputsOutputs
luaL_checktype(L, -1, LUA_TTABLE); luaL_checktype(L, -1, LUA_TTABLE);
for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) { for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) {
const char *key = lua_tostring(L, -2); const char * key = lua_tostring(L, -2);
if (!strcmp(key, "init")) { if (!strcmp(key, "init")) {
init = luaL_ref(L, LUA_REGISTRYINDEX); init = luaL_ref(L, LUA_REGISTRYINDEX);
lua_pushnil(L); lua_pushnil(L);
@ -529,9 +538,12 @@ void luaError(uint8_t error, bool acknowledge)
} }
} }
void luaExec(const char *filename) void luaExec(const char * filename)
{ {
#if !defined(COLORLCD)
luaInit(); luaInit();
#endif
if (luaState != INTERPRETER_PANIC) { if (luaState != INTERPRETER_PANIC) {
standaloneScript.state = SCRIPT_NOFILE; standaloneScript.state = SCRIPT_NOFILE;
int result = luaLoad(filename, standaloneScript); int result = luaLoad(filename, standaloneScript);
@ -618,7 +630,7 @@ void luaDoOneRunStandalone(evt_t evt)
} }
} }
} }
bool luaDoOneRunPermanentScript(uint8_t evt, int i, uint32_t scriptType) bool luaDoOneRunPermanentScript(uint8_t evt, int i, uint32_t scriptType)
{ {
ScriptInternalData & sid = scriptInternalData[i]; ScriptInternalData & sid = scriptInternalData[i];
@ -761,10 +773,12 @@ bool luaTask(uint8_t evt, uint8_t scriptType, bool allowLcdUsage)
// run permanent scripts // run permanent scripts
if (luaState & INTERPRETER_RELOAD_PERMANENT_SCRIPTS) { if (luaState & INTERPRETER_RELOAD_PERMANENT_SCRIPTS) {
luaState = 0; luaState = 0;
#if !defined(COLORLCD)
luaInit(); luaInit();
if (luaState == INTERPRETER_PANIC) return false; if (luaState == INTERPRETER_PANIC) return false;
luaLoadPermanentScripts(); luaLoadPermanentScripts();
if (luaState == INTERPRETER_PANIC) return false; if (luaState == INTERPRETER_PANIC) return false;
#endif
} }
for (int i=0; i<luaScriptsCount; i++) { for (int i=0; i<luaScriptsCount; i++) {
@ -787,3 +801,152 @@ int luaGetMemUsed()
{ {
return (lua_gc(L, LUA_GCCOUNT, 0) << 10) + lua_gc(L, LUA_GCCOUNTB, 0); return (lua_gc(L, LUA_GCCOUNT, 0) << 10) + lua_gc(L, LUA_GCCOUNTB, 0);
} }
#if defined(COLORLCD)
#define THEME_FILENAME_MAXLEN (42) // max length (example: /SCRIPTS/THEMES/mytheme.lua)
class LuaTheme: public Theme
{
friend int luaLoadTheme(const char * filename);
public:
LuaTheme(const char * name, const uint8_t * bitmap):
Theme(name, bitmap),
loadFunction(0),
drawBackgroundFunction(0),
drawTopbarBackgroundFunction(0)
{
}
void exec(int function) const
{
if (function) {
SET_LUA_INSTRUCTIONS_COUNT(PERMANENT_SCRIPTS_MAX_INSTRUCTIONS);
lua_rawgeti(L, LUA_REGISTRYINDEX, function);
if (lua_pcall(L, 0, 0, 0) != 0) {
TRACE("Error in theme %s: %s", name, lua_tostring(L, -1));
}
}
}
virtual void load() const
{
luaLcdAllowed = true;
exec(loadFunction);
}
virtual void drawBackground() const
{
exec(drawBackgroundFunction);
}
virtual void drawTopbarBackground(const uint8_t * icon) const
{
exec(drawTopbarBackgroundFunction);
}
protected:
int loadFunction;
int drawBackgroundFunction;
int drawTopbarBackgroundFunction;
};
int luaLoadTheme(const char * filename)
{
TRACE("luaLoadTheme from file %s", filename);
int init = 0;
if (luaState == INTERPRETER_PANIC) {
return SCRIPT_PANIC;
}
#if defined(LUA_COMPILER) && defined(SIMU)
luaCompileAndSave(filename);
#endif
SET_LUA_INSTRUCTIONS_COUNT(MANUAL_SCRIPTS_MAX_INSTRUCTIONS);
PROTECT_LUA() {
if (luaL_loadfile(L, filename) == 0 &&
lua_pcall(L, 0, 1, 0) == 0 &&
lua_istable(L, -1)) {
const char * name=NULL, * bitmap=NULL;
int loadFunction=0, drawBackgroundFunction=0, drawTopbarBackgroundFunction=0;
luaL_checktype(L, -1, LUA_TTABLE);
for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) {
const char * key = lua_tostring(L, -2);
if (!strcmp(key, "name")) {
name = luaL_checkstring(L, -1);
}
else if (!strcmp(key, "bitmap")) {
bitmap = luaL_checkstring(L, -1);
}
else if (!strcmp(key, "load")) {
loadFunction = luaL_ref(L, LUA_REGISTRYINDEX);
lua_pushnil(L);
}
else if (!strcmp(key, "drawBackground")) {
drawBackgroundFunction = luaL_ref(L, LUA_REGISTRYINDEX);
lua_pushnil(L);
}
else if (!strcmp(key, "drawTopbarBackground")) {
drawTopbarBackgroundFunction = luaL_ref(L, LUA_REGISTRYINDEX);
lua_pushnil(L);
}
}
if (name && bitmap) {
char path[THEME_FILENAME_MAXLEN+1] = THEMES_PATH;
path[sizeof(THEMES_PATH)-1] = '/';
strcpy(path+sizeof(THEMES_PATH), bitmap);
uint8_t * bitmapData = (uint8_t *)malloc(BITMAP_BUFFER_SIZE(51, 31));
bmpLoad(bitmapData, path, 51, 31);
LuaTheme * theme = new LuaTheme(name, bitmapData);
theme->loadFunction = loadFunction;
theme->drawBackgroundFunction = drawBackgroundFunction;
theme->drawTopbarBackgroundFunction = drawTopbarBackgroundFunction;
}
}
else {
TRACE("Error in script %s: %s", filename, lua_tostring(L, -1));
}
}
else {
luaDisable();
return SCRIPT_PANIC;
}
UNPROTECT_LUA();
}
void luaLoadThemes()
{
char path[THEME_FILENAME_MAXLEN+1] = THEMES_PATH;
FILINFO fno;
DIR dir;
char * fn; /* This function is assuming non-Unicode cfg. */
TCHAR lfn[_MAX_LFN + 1];
fno.lfname = lfn;
fno.lfsize = sizeof(lfn);
FRESULT res = f_opendir(&dir, path); /* Open the directory */
if (res == FR_OK) {
for (;;) {
res = f_readdir(&dir, &fno); /* Read a directory item */
if (res != FR_OK || fno.fname[0] == 0) break; /* Break on error or end of dir */
fn = * fno.lfname ? fno.lfname : fno.fname;
uint8_t len = strlen(fn);
bool found = false;
// Eliminates directories / non wav files
if (len < 5 || strcasecmp(fn+len-4, SCRIPTS_EXT) || (fno.fattrib & AM_DIR)) continue;
path[sizeof(THEMES_PATH)-1] = '/';
strcpy(path+sizeof(THEMES_PATH), fn);
luaLoadTheme(path);
}
}
}
#endif

View file

@ -152,8 +152,11 @@ struct LuaField {
char desc[50]; char desc[50];
}; };
bool luaFindFieldByName(const char * name, LuaField & field, unsigned int flags=0); bool luaFindFieldByName(const char * name, LuaField & field, unsigned int flags=0);
void luaLoadThemes();
#else // defined(LUA) #else // defined(LUA)
#define luaInit()
#define LUA_LOAD_MODEL_SCRIPTS() #define LUA_LOAD_MODEL_SCRIPTS()
#define luaLoadThemes()
#endif // defined(LUA) #endif // defined(LUA)
#endif // _LUA_API_H_ #endif // _LUA_API_H_

View file

@ -440,7 +440,8 @@ enum UartModes {
char anaNames[NUM_STICKS+NUM_POTS][LEN_ANA_NAME]; \ char anaNames[NUM_STICKS+NUM_POTS][LEN_ANA_NAME]; \
char currModelFilename[LEN_MODEL_FILENAME+1]; \ char currModelFilename[LEN_MODEL_FILENAME+1]; \
uint8_t bluetoothEnable; \ uint8_t bluetoothEnable; \
char bluetoothName[LEN_BLUETOOTH_NAME]; char bluetoothName[LEN_BLUETOOTH_NAME]; \
char themeName[8];
#elif defined(PCBFLAMENCO) #elif defined(PCBFLAMENCO)
#define LEN_SWITCH_NAME 3 #define LEN_SWITCH_NAME 3
#define LEN_ANA_NAME 3 #define LEN_ANA_NAME 3

View file

@ -1880,24 +1880,6 @@ void doMixerCalculations()
s_mixer_first_run_done = true; s_mixer_first_run_done = true;
} }
#if defined(COLORLCD)
void loadCustomScreens()
{
for (unsigned int i=0; i<MAX_CUSTOM_SCREENS; i++) {
char name[sizeof(g_model.screenData[i].layoutName)+1];
memset(name, 0, sizeof(name));
strncpy(name, g_model.screenData[i].layoutName, sizeof(g_model.screenData[i].layoutName));
customScreens[i] = loadLayout(name, &g_model.screenData[i].layoutData);
}
if (customScreens[0] == NULL) {
customScreens[0] = registeredLayouts[0]->create(&g_model.screenData[0].layoutData);
}
}
#else
#define loadCustomScreens()
#endif
#if defined(NAVIGATION_STICKS) #if defined(NAVIGATION_STICKS)
uint8_t StickScrollAllowed; uint8_t StickScrollAllowed;
uint8_t StickScrollTimer; uint8_t StickScrollTimer;
@ -1938,13 +1920,16 @@ void opentxStart()
} }
#endif #endif
#if defined(COLORLCD)
luaInit();
loadTheme();
#endif
#if defined(GUI) #if defined(GUI)
checkAlarm(); checkAlarm();
checkAll(); checkAll();
#endif #endif
loadCustomScreens();
#if defined(GUI) #if defined(GUI)
if (g_eeGeneral.chkSum != evalChkSum()) { if (g_eeGeneral.chkSum != evalChkSum()) {
chainMenu(menuFirstCalib); chainMenu(menuFirstCalib);
@ -2601,10 +2586,6 @@ int main(void)
lcdInit(); lcdInit();
#endif #endif
#if defined(COLORLCD)
theme->load();
#endif
stackPaint(); stackPaint();
#if defined(GUI) #if defined(GUI)

View file

@ -2,7 +2,7 @@
* Copyright (C) OpenTX * Copyright (C) OpenTX
* *
* Based on code named * Based on code named
* th9x - http://code.google.com/p/th9x * th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x * er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x * gruvin9x - http://code.google.com/p/gruvin9x
* *
@ -36,6 +36,7 @@
#define EEPROMS_PATH ROOT_PATH "EEPROMS" #define EEPROMS_PATH ROOT_PATH "EEPROMS"
#define SCRIPTS_PATH ROOT_PATH "SCRIPTS" #define SCRIPTS_PATH ROOT_PATH "SCRIPTS"
#define WIZARD_PATH SCRIPTS_PATH "/WIZARD" #define WIZARD_PATH SCRIPTS_PATH "/WIZARD"
#define THEMES_PATH SCRIPTS_PATH "/THEMES"
#define WIZARD_NAME "wizard.lua" #define WIZARD_NAME "wizard.lua"
#define TEMPLATES_PATH SCRIPTS_PATH "/TEMPLATES" #define TEMPLATES_PATH SCRIPTS_PATH "/TEMPLATES"
#define SCRIPTS_MIXES_PATH SCRIPTS_PATH "/MIXES" #define SCRIPTS_MIXES_PATH SCRIPTS_PATH "/MIXES"

View file

@ -2,7 +2,7 @@
* Copyright (C) OpenTX * Copyright (C) OpenTX
* *
* Based on code named * Based on code named
* th9x - http://code.google.com/p/th9x * th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x * er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x * gruvin9x - http://code.google.com/p/gruvin9x
* *
@ -87,9 +87,12 @@ void postModelLoad(bool newModel)
referenceModelAudioFiles(); referenceModelAudioFiles();
#endif #endif
#if defined(COLORLCD)
loadCustomScreens();
#endif
LOAD_MODEL_BITMAP(); LOAD_MODEL_BITMAP();
LUA_LOAD_MODEL_SCRIPTS(); LUA_LOAD_MODEL_SCRIPTS();
SEND_FAILSAFE_1S(); SEND_FAILSAFE_1S();
PLAY_MODEL_NAME(); PLAY_MODEL_NAME();
} }

View file

@ -2,7 +2,7 @@
* Copyright (C) OpenTX * Copyright (C) OpenTX
* *
* Based on code named * Based on code named
* th9x - http://code.google.com/p/th9x * th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x * er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x * gruvin9x - http://code.google.com/p/gruvin9x
* *
@ -300,7 +300,7 @@ void *eeprom_write_function(void *)
} }
eeprom_pointer++; eeprom_pointer++;
eeprom_buffer_data++; eeprom_buffer_data++;
if (fp && eeprom_buffer_size == 1) { if (fp && eeprom_buffer_size == 1) {
fflush(fp); fflush(fp);
} }
@ -326,14 +326,10 @@ void * main_thread(void *)
try { try {
#endif #endif
#if defined(PCBHORUS)
theme->load();
#endif
#if defined(CPUARM) #if defined(CPUARM)
stackPaint(); stackPaint();
#endif #endif
s_current_protocol[0] = 255; s_current_protocol[0] = 255;
menuLevel = 0; menuLevel = 0;
@ -415,11 +411,11 @@ void StartMainThread(bool tests)
#endif #endif
/* /*
g_tmr10ms must be non-zero otherwise some SF functions (that use this timer as a marker when it was last executed) g_tmr10ms must be non-zero otherwise some SF functions (that use this timer as a marker when it was last executed)
will be executed twice on startup. Normal radio does not see this issue because g_tmr10ms is already a big number will be executed twice on startup. Normal radio does not see this issue because g_tmr10ms is already a big number
before the first call to the Special Functions. Not so in the simulator. before the first call to the Special Functions. Not so in the simulator.
There is another issue, some other function static variables depend on this value. If simulator is started There is another issue, some other function static variables depend on this value. If simulator is started
multiple times in one Companion session, they are set to their initial values only first time the simulator multiple times in one Companion session, they are set to their initial values only first time the simulator
is started. Therefore g_tmr10ms must also be set to non-zero value only the first time, then it must be left is started. Therefore g_tmr10ms must also be set to non-zero value only the first time, then it must be left
alone to continue from the previous simulator session value. See the issue #2446 alone to continue from the previous simulator session value. See the issue #2446
@ -428,11 +424,11 @@ void StartMainThread(bool tests)
if (g_tmr10ms == 0) { if (g_tmr10ms == 0) {
g_tmr10ms = 1; g_tmr10ms = 1;
} }
#if defined(RTCLOCK) #if defined(RTCLOCK)
g_rtcTime = time(0); g_rtcTime = time(0);
#endif #endif
main_thread_running = (tests ? 1 : 2); main_thread_running = (tests ? 1 : 2);
pthread_create(&main_thread_pid, NULL, &main_thread, NULL); pthread_create(&main_thread_pid, NULL, &main_thread, NULL);
} }
@ -484,10 +480,10 @@ int32_t getVolume()
#if defined(SIMU_AUDIO) && defined(CPUARM) #if defined(SIMU_AUDIO) && defined(CPUARM)
void copyBuffer(uint8_t * dest, uint16_t * buff, unsigned int samples) void copyBuffer(uint8_t * dest, uint16_t * buff, unsigned int samples)
{ {
for(unsigned int i=0; i<samples; i++) { for(unsigned int i=0; i<samples; i++) {
int sample = ((int32_t)(uint32_t)(buff[i]) - 0x8000); // conversion from uint16_t int sample = ((int32_t)(uint32_t)(buff[i]) - 0x8000); // conversion from uint16_t
*((uint16_t*)dest) = (int16_t)((sample * simuAudio.currentVolume)/127); *((uint16_t*)dest) = (int16_t)((sample * simuAudio.currentVolume)/127);
dest += 2; dest += 2;
} }
@ -579,7 +575,7 @@ void * audioThread(void *)
} }
void StartAudioThread(int volumeGain) void StartAudioThread(int volumeGain)
{ {
simuAudio.leftoverLen = 0; simuAudio.leftoverLen = 0;
simuAudio.threadRunning = true; simuAudio.threadRunning = true;
simuAudio.volumeGain = volumeGain; simuAudio.volumeGain = volumeGain;
@ -759,7 +755,7 @@ char *findTrueFileName(const char *path)
strcat(result, ffd.cFileName); strcat(result, ffd.cFileName);
TRACE("\tfound: %s", ffd.cFileName); TRACE("\tfound: %s", ffd.cFileName);
fileMap.insert(filemap_t:: value_type(path, result)); fileMap.insert(filemap_t:: value_type(path, result));
return result; return result;
} }
} }
} }
@ -789,7 +785,7 @@ char *findTrueFileName(const char *path)
TRACE("\tfound: %s", res->d_name); TRACE("\tfound: %s", res->d_name);
fileMap.insert(filemap_t:: value_type(path, result)); fileMap.insert(filemap_t:: value_type(path, result));
simu::closedir(dir); simu::closedir(dir);
return result; return result;
} }
} }
} }
@ -1047,7 +1043,7 @@ FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs)
{ {
// just fake that we always have some clusters free // just fake that we always have some clusters free
*nclst = 10; *nclst = 10;
return FR_OK; return FR_OK;
} }
#if defined(PCBSKY9X) #if defined(PCBSKY9X)
@ -1107,7 +1103,7 @@ void traceDiskStatus()
{ {
if (noDiskStatus > 0) { if (noDiskStatus > 0) {
TRACE("disk_status() called %d times", noDiskStatus); TRACE("disk_status() called %d times", noDiskStatus);
noDiskStatus = 0; noDiskStatus = 0;
} }
} }
@ -1186,7 +1182,7 @@ DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff)
DWORD noSectors = buf.st_size / 512; DWORD noSectors = buf.st_size / 512;
*(DWORD*)buff = noSectors; *(DWORD*)buff = noSectors;
TRACE("disk_ioctl(GET_SECTOR_COUNT) = %u", noSectors); TRACE("disk_ioctl(GET_SECTOR_COUNT) = %u", noSectors);
return RES_OK; return RES_OK;
} }
return RES_ERROR; return RES_ERROR;
} }

View file

@ -44,7 +44,6 @@
extern const char * zchar2string(const char * zstring, int size); extern const char * zchar2string(const char * zstring, int size);
#define EXPECT_ZSTREQ(c_string, z_string) EXPECT_STREQ(c_string, zchar2string(z_string, sizeof(z_string))) #define EXPECT_ZSTREQ(c_string, z_string) EXPECT_STREQ(c_string, zchar2string(z_string, sizeof(z_string)))
extern void luaInit();
::testing::AssertionResult __luaExecStr(const char * str) ::testing::AssertionResult __luaExecStr(const char * str)
{ {

View file

@ -32,7 +32,7 @@ static luaR_result luaR_findkey(const void *where, const char *key, int type, in
/* Find a global "read only table" in the constant lua_rotable array */ /* Find a global "read only table" in the constant lua_rotable array */
luaR_result luaR_findglobal(const char *name, lu_byte *ptype) { luaR_result luaR_findglobal(const char *name, lu_byte *ptype) {
unsigned i; unsigned i;
*ptype = LUA_TNIL; *ptype = LUA_TNIL;
if (strlen(name) > LUA_MAX_ROTABLE_NAME) if (strlen(name) > LUA_MAX_ROTABLE_NAME)
return 0; return 0;
@ -60,13 +60,13 @@ int luaR_findfunction(lua_State *L, const luaL_Reg *ptable) {
lua_pushlightfunction(L, (void*)(size_t)res); lua_pushlightfunction(L, (void*)(size_t)res);
else else
lua_pushnil(L); lua_pushnil(L);
return 1; return 1;
} }
luaR_result luaR_findentry(void *data, const char *key, lu_byte *ptype) { luaR_result luaR_findentry(void *data, const char *key, lu_byte *ptype) {
int found; int found;
unsigned idx = (unsigned)(size_t)data - 1; unsigned idx = (unsigned)(size_t)data - 1;
luaR_result res; luaR_result res;
*ptype = LUA_TNIL; *ptype = LUA_TNIL;
/* First look at the functions */ /* First look at the functions */
res = luaR_findkey(lua_rotable[idx].pfuncs, key, LUAR_FINDFUNCTION, &found); res = luaR_findkey(lua_rotable[idx].pfuncs, key, LUAR_FINDFUNCTION, &found);

View file

@ -578,6 +578,7 @@ const pm_char STR_MODEL_SELECT[] PROGMEM = TR_MODEL_SELECT;
const pm_char STR_SELECT_WIDGET[] PROGMEM = TR_SELECT_WIDGET; const pm_char STR_SELECT_WIDGET[] PROGMEM = TR_SELECT_WIDGET;
const pm_char STR_REMOVE_WIDGET[] PROGMEM = TR_REMOVE_WIDGET; const pm_char STR_REMOVE_WIDGET[] PROGMEM = TR_REMOVE_WIDGET;
const pm_char STR_WIDGET_SETTINGS[] PROGMEM = TR_WIDGET_SETTINGS; const pm_char STR_WIDGET_SETTINGS[] PROGMEM = TR_WIDGET_SETTINGS;
const pm_char STR_REMOVE_SCREEN[] PROGMEM = TR_REMOVE_SCREEN;
#endif #endif
#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) #if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS)

View file

@ -829,6 +829,7 @@ extern const pm_char STR_BLCOLOR[];
extern const pm_char STR_SELECT_WIDGET[]; extern const pm_char STR_SELECT_WIDGET[];
extern const pm_char STR_REMOVE_WIDGET[]; extern const pm_char STR_REMOVE_WIDGET[];
extern const pm_char STR_WIDGET_SETTINGS[]; extern const pm_char STR_WIDGET_SETTINGS[];
extern const pm_char STR_REMOVE_SCREEN[];
#endif #endif
#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) #if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS)

View file

@ -1102,6 +1102,7 @@
#define TR_SELECT_WIDGET "Select widget" #define TR_SELECT_WIDGET "Select widget"
#define TR_REMOVE_WIDGET "Remove widget" #define TR_REMOVE_WIDGET "Remove widget"
#define TR_WIDGET_SETTINGS "Widget settings" #define TR_WIDGET_SETTINGS "Widget settings"
#define TR_REMOVE_SCREEN "Remove screen"
#define TR_MENU_INPUTS "\314Vstupy" #define TR_MENU_INPUTS "\314Vstupy"
#define TR_MENU_LUA "\322Lua skripty" #define TR_MENU_LUA "\322Lua skripty"

View file

@ -1105,6 +1105,7 @@
#define TR_SELECT_WIDGET "Select widget" #define TR_SELECT_WIDGET "Select widget"
#define TR_REMOVE_WIDGET "Remove widget" #define TR_REMOVE_WIDGET "Remove widget"
#define TR_WIDGET_SETTINGS "Widget settings" #define TR_WIDGET_SETTINGS "Widget settings"
#define TR_REMOVE_SCREEN "Remove screen"
// ----------------------------- Symbole für Auswahlliste---------- // ----------------------------- Symbole für Auswahlliste----------
#define TR_MENU_INPUTS "\314Inputs" #define TR_MENU_INPUTS "\314Inputs"
#define TR_MENU_LUA "\322Lua Scripte" #define TR_MENU_LUA "\322Lua Scripte"

View file

@ -1131,6 +1131,7 @@
#define TR_SELECT_WIDGET "Select widget" #define TR_SELECT_WIDGET "Select widget"
#define TR_REMOVE_WIDGET "Remove widget" #define TR_REMOVE_WIDGET "Remove widget"
#define TR_WIDGET_SETTINGS "Widget settings" #define TR_WIDGET_SETTINGS "Widget settings"
#define TR_REMOVE_SCREEN "Remove screen"
#define TR_MENU_INPUTS "\314Inputs" #define TR_MENU_INPUTS "\314Inputs"
#define TR_MENU_LUA "\322Lua scripts" #define TR_MENU_LUA "\322Lua scripts"

View file

@ -1057,6 +1057,7 @@
#define TR_SELECT_WIDGET "Select widget" #define TR_SELECT_WIDGET "Select widget"
#define TR_REMOVE_WIDGET "Remove widget" #define TR_REMOVE_WIDGET "Remove widget"
#define TR_WIDGET_SETTINGS "Widget settings" #define TR_WIDGET_SETTINGS "Widget settings"
#define TR_REMOVE_SCREEN "Remove screen"
#define TR_MENU_INPUTS "\314Inputs" #define TR_MENU_INPUTS "\314Inputs"
#define TR_MENU_LUA "\322Lua scripts" #define TR_MENU_LUA "\322Lua scripts"

View file

@ -1057,6 +1057,7 @@
#define TR_SELECT_WIDGET "Select widget" #define TR_SELECT_WIDGET "Select widget"
#define TR_REMOVE_WIDGET "Remove widget" #define TR_REMOVE_WIDGET "Remove widget"
#define TR_WIDGET_SETTINGS "Widget settings" #define TR_WIDGET_SETTINGS "Widget settings"
#define TR_REMOVE_SCREEN "Remove screen"
#define TR_MENU_INPUTS "\314Inputs" #define TR_MENU_INPUTS "\314Inputs"
#define TR_MENU_LUA "\322Lua scripts" #define TR_MENU_LUA "\322Lua scripts"

View file

@ -1092,6 +1092,7 @@
#define TR_SELECT_WIDGET "Select widget" #define TR_SELECT_WIDGET "Select widget"
#define TR_REMOVE_WIDGET "Remove widget" #define TR_REMOVE_WIDGET "Remove widget"
#define TR_WIDGET_SETTINGS "Widget settings" #define TR_WIDGET_SETTINGS "Widget settings"
#define TR_REMOVE_SCREEN "Remove screen"
#define TR_MENU_INPUTS "\314Entrées" #define TR_MENU_INPUTS "\314Entrées"
#define TR_MENU_LUA "\322Scripts Lua" #define TR_MENU_LUA "\322Scripts Lua"

View file

@ -1104,6 +1104,7 @@
#define TR_SELECT_WIDGET "Select widget" #define TR_SELECT_WIDGET "Select widget"
#define TR_REMOVE_WIDGET "Remove widget" #define TR_REMOVE_WIDGET "Remove widget"
#define TR_WIDGET_SETTINGS "Widget settings" #define TR_WIDGET_SETTINGS "Widget settings"
#define TR_REMOVE_SCREEN "Remove screen"
#define TR_MENU_INPUTS "\314Ingressi" #define TR_MENU_INPUTS "\314Ingressi"
#define TR_MENU_LUA "\322Lua scripts" #define TR_MENU_LUA "\322Lua scripts"

View file

@ -1123,6 +1123,7 @@
#define TR_SELECT_WIDGET "Select widget" #define TR_SELECT_WIDGET "Select widget"
#define TR_REMOVE_WIDGET "Remove widget" #define TR_REMOVE_WIDGET "Remove widget"
#define TR_WIDGET_SETTINGS "Widget settings" #define TR_WIDGET_SETTINGS "Widget settings"
#define TR_REMOVE_SCREEN "Remove screen"
#define TR_MENU_INPUTS "\314Inputs" #define TR_MENU_INPUTS "\314Inputs"

View file

@ -1105,6 +1105,7 @@
#define TR_SELECT_WIDGET "Select widget" #define TR_SELECT_WIDGET "Select widget"
#define TR_REMOVE_WIDGET "Remove widget" #define TR_REMOVE_WIDGET "Remove widget"
#define TR_WIDGET_SETTINGS "Widget settings" #define TR_WIDGET_SETTINGS "Widget settings"
#define TR_REMOVE_SCREEN "Remove screen"
#define TR_MENU_INPUTS "\314Wejści" #define TR_MENU_INPUTS "\314Wejści"
#define TR_MENU_LUA "\322SkryptyLUA" #define TR_MENU_LUA "\322SkryptyLUA"

View file

@ -1051,6 +1051,7 @@
#define TR_SELECT_WIDGET "Select widget" #define TR_SELECT_WIDGET "Select widget"
#define TR_REMOVE_WIDGET "Remove widget" #define TR_REMOVE_WIDGET "Remove widget"
#define TR_WIDGET_SETTINGS "Widget settings" #define TR_WIDGET_SETTINGS "Widget settings"
#define TR_REMOVE_SCREEN "Remove screen"
#define TR_MENU_INPUTS "\314Inputs" #define TR_MENU_INPUTS "\314Inputs"
#define TR_MENU_LUA "\322Lua scripts" #define TR_MENU_LUA "\322Lua scripts"

View file

@ -1128,6 +1128,7 @@
#define TR_SELECT_WIDGET "Select widget" #define TR_SELECT_WIDGET "Select widget"
#define TR_REMOVE_WIDGET "Remove widget" #define TR_REMOVE_WIDGET "Remove widget"
#define TR_WIDGET_SETTINGS "Widget settings" #define TR_WIDGET_SETTINGS "Widget settings"
#define TR_REMOVE_SCREEN "Remove screen"
#define TR_MENU_INPUTS "\314Inputs" #define TR_MENU_INPUTS "\314Inputs"
#define TR_MENU_LUA "\322Lua scripts" #define TR_MENU_LUA "\322Lua scripts"