Lua telemetry screens. Still not finished:

- the scripts need to be wakedup even when not displayed
- I only tested telem0.lua, but theorically we could have 7 telemetry
screens
This commit is contained in:
bsongis
2014-06-18 22:42:04 +02:00
parent 0af5794cfa
commit 2416dde7bb
4 changed files with 47 additions and 8 deletions
+2 -2
View File
@@ -340,7 +340,7 @@ void displayTimers()
// Main timer
if (g_model.timers[0].mode) {
TimerState & timerState = timersStates[0];
putsTimer(TIMERS_X, TIMER1_Y, timerState.val, MIDSIZE|LEFT, MIDSIZE|LEFT);
putsTimer(TIMERS_X, TIMER1_Y, timerState.val, TIMEHOUR|MIDSIZE|LEFT, TIMEHOUR|MIDSIZE|LEFT);
putsTimerMode(TIMERS_X, TIMER1_Y-6, g_model.timers[0].mode, SMLSIZE);
if (g_model.timers[0].persistent) lcd_putcAtt(TIMERS_R, TIMER1_Y+1, 'P', SMLSIZE);
if (timerState.val < 0) {
@@ -353,7 +353,7 @@ void displayTimers()
// Second timer
if (g_model.timers[1].mode) {
TimerState & timerState = timersStates[1];
putsTimer(TIMERS_X, TIMER2_Y, timerState.val, MIDSIZE|LEFT, MIDSIZE|LEFT);
putsTimer(TIMERS_X, TIMER2_Y, timerState.val, TIMEHOUR|MIDSIZE|LEFT, TIMEHOUR|MIDSIZE|LEFT);
putsTimerMode(TIMERS_X, TIMER2_Y-6, g_model.timers[1].mode, SMLSIZE);
if (g_model.timers[1].persistent) lcd_putcAtt(TIMERS_R, TIMER2_Y+1, 'P', SMLSIZE);
if (timerState.val < 0) {
+2 -2
View File
@@ -552,7 +552,7 @@ void lcd_outdezNAtt(xcoord_t x, uint8_t y, lcdint_t val, LcdFlags flags, uint8_t
}
else if (midsize) {
x -= 3;
xn = x+1;
xn = x;
}
else if (tinsize) {
x--;
@@ -912,7 +912,7 @@ void putsTimer(xcoord_t x, uint8_t y, putstime_t tme, LcdFlags att, LcdFlags att
#if defined(PCBTARANIS)
#define separator ':'
if (att & MIDSIZE) {
if (att & TIMEHOUR) {
div_t qr2 = div(qr.quot, 60);
lcd_outdezNAtt(x, y, qr2.quot, att|LEADING0|LEFT, 2);
lcd_putcAtt(lcdLastPos, y, separator, att&att2);
+5 -1
View File
@@ -113,7 +113,6 @@
#define SMLSIZE 0x0200
#define TINSIZE 0x0400
#define STREXPANDED 0x0800
#define TIMEBLINK 0x1000
#else
#define MIDSIZE DBLSIZE
#define SMLSIZE 0x00
@@ -127,6 +126,11 @@
#define GREY_MASK(x) ((x) & 0xF000)
#endif
#if defined(CPUARM)
#define TIMEBLINK 0x10000
#define TIMEHOUR 0x20000
#endif
#if defined(CPUARM)
#define LcdFlags uint32_t
#else
+38 -3
View File
@@ -65,8 +65,8 @@ ScriptInternalData standaloneScript = { SCRIPT_NOFILE, 0 };
uint16_t maxLuaInterval = 0;
uint16_t maxLuaDuration = 0;
#define PERMANENT_SCRIPTS_MAX_INSTRUCTIONS (1000/100)
#define MANUAL_SCRIPTS_MAX_INSTRUCTIONS (10000/100)
#define PERMANENT_SCRIPTS_MAX_INSTRUCTIONS (10000/100)
#define MANUAL_SCRIPTS_MAX_INSTRUCTIONS (20000/100)
#define SCRIPTS_MAX_HEAP 50
#define SET_LUA_INSTRUCTIONS_COUNT(x) (instructionsPercent=0, lua_sethook(L, hook, LUA_MASKCOUNT, x))
@@ -155,7 +155,11 @@ static int luaGetValue(lua_State *L)
}
else {
const char *what = luaL_checkstring(L, 1);
if (!strcmp(what, "altitude")) {
if (!strcmp(what, "altitude-max")) {
lua_pushnumber(L, frskyData.hub.maxAltitude);
return 1;
}
else if (!strcmp(what, "altitude")) {
lua_pushnumber(L, double(frskyData.hub.baroAltitude)/100);
return 1;
}
@@ -250,6 +254,16 @@ static int luaLcdDrawText(lua_State *L)
return 0;
}
static int luaLcdDrawTimer(lua_State *L)
{
int x = luaL_checkinteger(L, 1);
int y = luaL_checkinteger(L, 2);
int seconds = luaL_checkinteger(L, 3);
int att = luaL_checkinteger(L, 4);
putsTimer(x, y, seconds, att|LEFT, att);
return 0;
}
static int luaLcdDrawNumber(lua_State *L)
{
int x = luaL_checkinteger(L, 1);
@@ -314,6 +328,25 @@ static int luaLcdDrawFilledRectangle(lua_State *L)
return 0;
}
#if 0
static int luaLcdDrawGauge(lua_State *L)
{
int x = luaL_checkinteger(L, 1);
int y = luaL_checkinteger(L, 2);
int w = luaL_checkinteger(L, 3);
int h = luaL_checkinteger(L, 4);
int num = luaL_checkinteger(L, 5);
int den = luaL_checkinteger(L, 6);
int flags = luaL_checkinteger(L, 7);
lcd_rect(x, y, w, h);
uint8_t len = limit((uint8_t)1, uint8_t(w*num/den), uint8_t(w));
for (int i=1; i<h-1; i++) {
lcd_hline(x+1, y+i, len);
}
return 0;
}
#endif
static int luaLcdDrawScreenTitle(lua_State *L)
{
const char * str = luaL_checkstring(L, 1);
@@ -1020,7 +1053,9 @@ static const luaL_Reg lcdLib[] = {
{ "drawLine", luaLcdDrawLine },
{ "drawRectangle", luaLcdDrawRectangle },
{ "drawFilledRectangle", luaLcdDrawFilledRectangle },
// { "drawGauge", luaLcdDrawGauge },
{ "drawText", luaLcdDrawText },
{ "drawTimer", luaLcdDrawTimer },
{ "drawNumber", luaLcdDrawNumber },
{ "drawSwitch", luaLcdDrawSwitch },
{ "drawSource", luaLcdDrawSource },