1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-19 14:25:11 +03:00

3djc/horus wizard (#4034)

* Initial commit

* Cosmetics

* Add dummy wizard for testing purposes

* Graphics enhancement by MHotar

* Only if LUA + cosmetics

* cosmetics on the sample wizards

* Remove warning
This commit is contained in:
3djc 2016-11-17 23:13:56 +01:00 committed by Bertrand Songis
parent e6e9d8eca1
commit cf10ab5f20
25 changed files with 172 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View file

@ -0,0 +1,17 @@
-- Init
local function init()
end
-- Main
local function run(event)
lcd.clear()
lcd.drawFilledRectangle(0, 0, LCD_W, LCD_H, TEXT_BGCOLOR)
lcd.drawText(50, 50, "You are running dummy glider wizard 1", TEXT_COLOR)
return 1
end
return { init=init, run=run }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7 KiB

View file

@ -0,0 +1,17 @@
-- Init
local function init()
end
-- Main
local function run(event)
lcd.clear()
lcd.drawFilledRectangle(0, 0, LCD_W, LCD_H, TEXT_BGCOLOR)
lcd.drawText(50, 50, "You are running dummy plane wizard", TEXT_COLOR)
return 1
end
return { init=init, run=run }

View file

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 84 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 403 B

After

Width:  |  Height:  |  Size: 403 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Before After
Before After

View file

@ -98,6 +98,127 @@ void setCurrentCategory(unsigned int index)
currentModel = NULL;
}
#if defined(LUA)
#define MAX_WIZARD_NAME_LEN (sizeof(WIZARD_PATH)+20)
#define WIZARD_SPACING 40
#define WIZARD_LEFT_SPACING 30
#define WIZARD_ICON_X 80
#define WIZARD_ICON_Y 110
#define WIZARD_TEXT_Y 195
uint8_t getWizardNumber()
{
uint8_t wizNbr=0;
DIR dir;
static FILINFO fno;
FRESULT res = f_opendir(&dir, WIZARD_PATH);
if (res == FR_OK) {
for (;;) {
res = f_readdir(&dir, &fno);
if (res != FR_OK || fno.fname[0] == 0) {
break;
}
if (fno.fattrib & AM_DIR) {
wizNbr++;
}
}
}
return wizNbr;
}
bool menuModelWizard(event_t event)
{
static uint8_t wizardSelected;
static uint8_t wizardNumber;
bool executeMe = false;
uint8_t first = 0;
DIR dir;
static FILINFO fno;
char wizpath[MAX_WIZARD_NAME_LEN];
if(wizardNumber == 0) {
wizardNumber = getWizardNumber();
}
switch(event) {
case 0:
// no need to refresh the screen
return false;
case EVT_KEY_FIRST(KEY_EXIT):
chainMenu(menuModelSelect);
return false;
case EVT_KEY_BREAK(KEY_ENTER):
executeMe = true;
break;
case EVT_ROTARY_RIGHT:
if (wizardSelected < wizardNumber-1) {
wizardSelected++;
}
if (wizardSelected > 3) {
first = wizardSelected - 3;
}
break;
case EVT_ROTARY_LEFT:
if (wizardSelected != 0) {
wizardSelected--;
}
if(wizardSelected < first)
{
first = wizardSelected;
}
break;
}
strncpy(wizpath, WIZARD_PATH, sizeof(WIZARD_PATH));
strcpy(&wizpath[sizeof(WIZARD_PATH)-1], "/");
lcdDrawSolidFilledRect(0, 0, LCD_W, LCD_H, TEXT_BGCOLOR);
lcd->drawBitmap(0, 0, BitmapBuffer::load(getThemePath("wizard/background.png")));
FRESULT res = f_opendir(&dir, WIZARD_PATH);
if (res == FR_OK) {
for (uint8_t wizidx=0;;wizidx++) {
res = f_readdir(&dir, &fno);
if (res != FR_OK || fno.fname[0] == 0) {
break;
}
if (fno.fattrib & AM_DIR) {
if((wizidx >= first) && (wizidx < (first+4))) {
uint16_t x = WIZARD_LEFT_SPACING + (wizidx - first) * (WIZARD_SPACING + WIZARD_ICON_X);
strcpy(&wizpath[sizeof(WIZARD_PATH)], fno.fname);
strcpy(&wizpath[sizeof(WIZARD_PATH) + strlen(fno.fname)], "/icon.png");
lcdDrawText(x + 10, WIZARD_TEXT_Y, fno.fname);
lcd->drawBitmap(x, WIZARD_ICON_Y, BitmapBuffer::load(wizpath));
if(wizidx == wizardSelected ) {
if (wizardSelected < 5) {
lcdDrawRect(x, WIZARD_ICON_Y, 85, 130, 2, SOLID, MAINVIEW_GRAPHICS_COLOR_INDEX);
lcdDrawRect(x+5, WIZARD_TEXT_Y, 75, 4, 2, SOLID, MAINVIEW_GRAPHICS_COLOR_INDEX);
}
if (executeMe) {
strcpy(&wizpath[sizeof(WIZARD_PATH)+strlen(fno.fname)], "/wizard.lua");
if (isFileAvailable(wizpath)) {
wizpath[sizeof(WIZARD_PATH) + strlen(fno.fname)] = 0;
f_chdir(wizpath);
luaExec(WIZARD_NAME);
}
}
}
}
}
}
f_closedir(&dir);
if(wizardNumber == 0) {
lcdDrawText(40, LCD_H / 2, STR_SDCARD_NOWIZ);
return true;
}
}
return true;
}
#endif
void onModelSelectMenu(const char * result)
{
if (result == STR_SELECT_MODEL) {
@ -121,6 +242,9 @@ void onModelSelectMenu(const char * result)
currentModel = modelslist.currentModel = modelslist.addModel(currentCategory, createModel());
selectMode = MODE_SELECT_MODEL;
setCurrentModel(currentCategory->size() - 1);
#if defined(LUA)
chainMenu(menuModelWizard);
#endif
}
else if (result == STR_DUPLICATE_MODEL) {
char duplicatedFilename[LEN_MODEL_FILENAME+1];

View file

@ -415,7 +415,7 @@ void modelDefault(uint8_t id)
applyDefaultTemplate();
#if defined(LUA)
#if defined(LUA) && defined(PCBTARANIS) //Horus uses menuModelWizard() for wizard
if (isFileAvailable(WIZARD_PATH "/" WIZARD_NAME)) {
f_chdir(WIZARD_PATH);
luaExec(WIZARD_NAME);

View file

@ -487,6 +487,7 @@ const pm_char STR_RESTORE_MODEL[] PROGMEM = TR_RESTORE_MODEL;
const pm_char STR_SDCARD_ERROR[] PROGMEM = TR_SDCARD_ERROR;
const pm_char STR_NO_SDCARD[] PROGMEM = TR_NO_SDCARD;
const pm_char STR_SDCARD_FULL[] PROGMEM = TR_SDCARD_FULL;
const pm_char STR_SDCARD_NOWIZ[] PROGMEM = TR_SDCARD_NOWIZ;
const pm_char STR_INCOMPATIBLE[] PROGMEM = TR_INCOMPATIBLE;
const pm_char STR_LOGS_PATH[] PROGMEM = LOGS_PATH;
const pm_char STR_LOGS_EXT[] PROGMEM = LOGS_EXT;

View file

@ -709,6 +709,7 @@ extern const pm_char STR_RESET_BTN[];
extern const pm_char STR_DELETE_ERROR[];
extern const pm_char STR_NO_SDCARD[];
extern const pm_char STR_SDCARD_FULL[];
extern const pm_char STR_SDCARD_NOWIZ[];
extern const pm_char STR_INCOMPATIBLE[];
extern const pm_char STR_LOGS_PATH[];
extern const pm_char STR_LOGS_EXT[];

View file

@ -934,6 +934,7 @@
#define TR_SDCARD_ERROR "Chyba SD karty"
#define TR_NO_SDCARD "Není SD karta"
#define TR_SDCARD_FULL "Plná SD karta"
#define TR_SDCARD_NOWIZ "No wizard found on SD Card"
#define TR_INCOMPATIBLE "Nekompatibilní"
#define TR_WARNING "KONTROLA"
#define TR_EEPROMWARN "EEPROM"

View file

@ -937,6 +937,7 @@
#define TR_SDCARD_ERROR "SD-Kartenfehler"
#define TR_NO_SDCARD "Keine SD-Karte"
#define TR_SDCARD_FULL "SD-Karte voll"
#define TR_SDCARD_NOWIZ "No wizard found on SD Card"
#define TR_INCOMPATIBLE "Nicht kompatibel"
#define TR_WARNING "WARNUNG"
#define TR_EEPROMWARN "EEPROM"

View file

@ -903,6 +903,7 @@
#define TR_SDCARD_ERROR TR("SD error", "SD card error")
#define TR_NO_SDCARD "No SD card"
#define TR_SDCARD_FULL "SD card full"
#define TR_SDCARD_NOWIZ "No wizard found on SD Card"
#define TR_INCOMPATIBLE "Incompatible"
#define TR_WARNING "WARNING"
#define TR_EEPROMWARN "EEPROM"

View file

@ -882,6 +882,7 @@
#define TR_SDCARD_ERROR "SDCARD Error"
#define TR_NO_SDCARD "No SDCARD"
#define TR_SDCARD_FULL "SD Card Full"
#define TR_SDCARD_NOWIZ "No wizard found on SD Card"
#define TR_INCOMPATIBLE "Incompatible"
#define TR_WARNING "AVISO"
#define TR_EEPROMWARN "EEPROM"

View file

@ -882,6 +882,7 @@
#define TR_SDCARD_ERROR "SDCARD Error"
#define TR_NO_SDCARD "No SDCARD"
#define TR_SDCARD_FULL "SD Card Full"
#define TR_SDCARD_NOWIZ "No wizard found on SD Card"
#define TR_INCOMPATIBLE "Incompatible"
#define TR_WARNING "WARNING"
#define TR_EEPROMWARN "FINSKA"

View file

@ -914,6 +914,7 @@
#define TR_SDCARD_ERROR "Erreur carte SD"
#define TR_NO_SDCARD "Carte SD indisponible"
#define TR_SDCARD_FULL "Carte SD pleine"
#define TR_SDCARD_NOWIZ "No wizard found on SD Card"
#define TR_INCOMPATIBLE "Incompatible"
#define TR_WARNING "ALERTE"
#define TR_EEPROMWARN "EEPROM"

View file

@ -917,6 +917,7 @@
#define TR_SDCARD_ERROR "Errore SD"
#define TR_NO_SDCARD "No SDCARD"
#define TR_SDCARD_FULL "SD Card Piena"
#define TR_SDCARD_NOWIZ "No wizard found on SD Card"
#define TR_INCOMPATIBLE "Incompatibile"
#define TR_WARNING "AVVISO"
#define TR_EEPROMWARN "EEPROM"

View file

@ -911,6 +911,7 @@
#define TR_SDCARD_ERROR "SD-Kaart fout"
#define TR_NO_SDCARD "Geen SD-Kaart"
#define TR_SDCARD_FULL "SD-Kaart vol"
#define TR_SDCARD_NOWIZ "No wizard found on SD Card"
#define TR_INCOMPATIBLE "Niet compatibel"
#define TR_WARNING "MELDING"
#define TR_EEPROMWARN "EEPROM"

View file

@ -919,6 +919,7 @@
#define TR_SDCARD_ERROR "Błąd karty SD"
#define TR_NO_SDCARD "Brak karty SD"
#define TR_SDCARD_FULL "Karta Pełna "
#define TR_SDCARD_NOWIZ "No wizard found on SD Card"
#define TR_INCOMPATIBLE "Niekompatybilne"
#define TR_WARNING "UWAGA"
#define TR_EEPROMWARN "EEPROM"

View file

@ -877,6 +877,7 @@
#define TR_SDCARD_ERROR "SDCARD Erro"
#define TR_NO_SDCARD "Sem SDCARD"
#define TR_SDCARD_FULL "SD Card Full"
#define TR_SDCARD_NOWIZ "No wizard found on SD Card"
#define TR_INCOMPATIBLE "Incompativel"
#define TR_WARNING "AVISO"
#define TR_EEPROMWARN "EEPROM"

View file

@ -930,6 +930,7 @@
#define TR_SDCARD_ERROR "SDCARD-fel"
#define TR_NO_SDCARD "SDCARD saknas"
#define TR_SDCARD_FULL "SD-kort Fullt"
#define TR_SDCARD_NOWIZ "No wizard found on SD Card"
#define TR_INCOMPATIBLE "Inkompatibel"
#define TR_WARNING "VARNING"
#define TR_EEPROMWARN "EEPROM"