Lua error display function reused

This commit is contained in:
Bertrand Songis
2015-09-26 09:00:36 +02:00
parent e57361f7e1
commit 3f6e1d0b3a
15 changed files with 73 additions and 42 deletions
+3 -33
View File
@@ -182,35 +182,6 @@ void displayCustomTelemetryScreen(uint8_t index)
displayNumbersTelemetryScreen(screen);
}
#if defined(LUA)
#define LUA_SCRIPT_ERROR_Y 3*FH
// TODO more visual appealing implementation and text translations
void displayLuaScriptError(uint8_t state, int index)
{
TelemetryScriptData & script = g_model.frsky.screens[index].script;
char filename[sizeof(script.file)+1];
strncpy(filename, script.file, sizeof(script.file));
filename[sizeof(script.file)] = '\0';
lcd_putsAtt(0, LUA_SCRIPT_ERROR_Y, filename, 0);
lcd_putsAtt(lcdLastPos, LUA_SCRIPT_ERROR_Y, ": ", 0);
switch (state) {
case SCRIPT_SYNTAX_ERROR:
lcd_putsAtt(lcdLastPos, LUA_SCRIPT_ERROR_Y, "Script syntax error", 0);
break;
case SCRIPT_PANIC:
lcd_putsAtt(lcdLastPos, LUA_SCRIPT_ERROR_Y, "Script panic", 0);
break;
case SCRIPT_KILLED:
lcd_putsAtt(lcdLastPos, LUA_SCRIPT_ERROR_Y, "Script killed", 0);
break;
default:
lcd_putsAtt(lcdLastPos, LUA_SCRIPT_ERROR_Y, "Unknown error", 0);
}
}
#endif
bool displayTelemetryScreen()
{
#if defined(LUA)
@@ -218,14 +189,13 @@ bool displayTelemetryScreen()
uint8_t state = isTelemetryScriptAvailable(s_frsky_view);
switch (state) {
case SCRIPT_OK:
return true; //contents will be drawed by Lua Task
return true; // contents will be drawed by Lua Task
case SCRIPT_NOFILE:
return false; //requested lua telemetry screen not available
return false; // requested lua telemetry screen not available
case SCRIPT_SYNTAX_ERROR:
case SCRIPT_PANIC:
case SCRIPT_KILLED:
//display script error
displayLuaScriptError(state, s_frsky_view+1);
luaError(state);
return true;
}
return false;