Bsongis/lua interpreter added on x7d (#3999)

* [X7D] Lua option added (only standalone scripts)

* [X7D] Compilation fix

* [X7D] Compilation fix

* [X7D] Compilation fix

* [X7D] Compilation fix
This commit is contained in:
Bertrand Songis
2016-11-10 21:41:16 +01:00
committed by GitHub
parent 35571ad4d1
commit d58244ebde
23 changed files with 174 additions and 120 deletions
+9
View File
@@ -404,6 +404,15 @@ void drawStatusLine();
#define EDIT_MODE_INIT -1
#endif
#if defined(VIRTUAL_INPUTS)
uint8_t getExposCount();
void insertExpo(uint8_t idx);
void deleteExpo(uint8_t idx);
uint8_t getMixesCount();
void insertMix(uint8_t idx);
void deleteMix(uint8_t idx);
#endif
typedef int (*FnFuncP) (int x);
void drawFunction(FnFuncP fn, uint8_t offset=0);
+89 -77
View File
@@ -608,7 +608,7 @@ void lcdDrawNumber(coord_t x, coord_t y, lcdint_t val, LcdFlags flags, uint8_t l
}
else {
// TODO needed on CPUAVR? y &= ~0x07;
lcdDrawFilledRect(xn, y+2*FH-3, ln, 2);
lcdDrawSolidFilledRect(xn, y+2*FH-3, ln, 2);
}
}
if (neg) lcdDrawChar(x, y, '-', flags);
@@ -665,6 +665,40 @@ void lcdDrawLine(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat, Lc
}
#endif
#if defined(CPUM64)
void lcdDrawVerticalLine(coord_t x, int8_t y, int8_t h, uint8_t pat)
{
if (x >= LCD_W) return;
if (h<0) { y+=h; h=-h; }
if (y<0) { h+=y; y=0; }
if (y+h > LCD_H) { h = LCD_H - y; }
if (pat==DOTTED && !(y%2))
pat = ~pat;
uint8_t *p = &displayBuf[ y / 8 * LCD_W + x ];
y = (y & 0x07);
if (y) {
ASSERT_IN_DISPLAY(p);
*p ^= ~(BITMASK(y)-1) & pat;
p += LCD_W;
h -= 8-y;
}
while (h>0) {
ASSERT_IN_DISPLAY(p);
*p ^= pat;
p += LCD_W;
h -= 8;
}
if (h < 0) h += 8;
if (h) {
p -= LCD_W;
ASSERT_IN_DISPLAY(p);
*p ^= ~(BITMASK(h)-1) & pat;
}
}
void lcdDrawSolidVerticalLine(coord_t x, scoord_t y, scoord_t h)
{
lcdDrawVerticalLine(x, y, h, SOLID);
@@ -678,6 +712,59 @@ void lcdDrawRect(coord_t x, coord_t y, coord_t w, coord_t h, uint8_t pat, LcdFla
lcdDrawHorizontalLine(x, y+h-1, w, pat);
lcdDrawHorizontalLine(x, y, w, pat);
}
#else
void lcdDrawVerticalLine(coord_t x, scoord_t y, scoord_t h, uint8_t pat, LcdFlags att)
{
if (x >= LCD_W) return;
#if defined(CPUARM)
// should never happen on 9X
if (y >= LCD_H) return;
#endif
if (h<0) { y+=h; h=-h; }
if (y<0) { h+=y; y=0; }
if (y+h > LCD_H) { h = LCD_H - y; }
if (pat==DOTTED && !(y%2))
pat = ~pat;
uint8_t *p = &displayBuf[ y / 8 * LCD_W + x ];
y = (y & 0x07);
if (y) {
ASSERT_IN_DISPLAY(p);
uint8_t msk = ~(BITMASK(y)-1);
h -= 8-y;
if (h < 0)
msk -= ~(BITMASK(8+h)-1);
lcdMaskPoint(p, msk & pat, att);
p += LCD_W;
}
while (h>=8) {
ASSERT_IN_DISPLAY(p);
lcdMaskPoint(p, pat, att);
p += LCD_W;
h -= 8;
}
if (h>0) {
ASSERT_IN_DISPLAY(p);
lcdMaskPoint(p, (BITMASK(h)-1) & pat, att);
}
}
void lcdDrawSolidVerticalLine(coord_t x, scoord_t y, scoord_t h, LcdFlags att)
{
lcdDrawVerticalLine(x, y, h, SOLID, att);
}
void lcdDrawRect(coord_t x, coord_t y, coord_t w, coord_t h, uint8_t pat, LcdFlags att)
{
lcdDrawVerticalLine(x, y, h, pat, att);
lcdDrawVerticalLine(x+w-1, y, h, pat, att);
if (~att & ROUND) { x+=1; w-=2; }
lcdDrawHorizontalLine(x, y+h-1, w, pat, att);
lcdDrawHorizontalLine(x, y, w, pat, att);
}
#endif
#if !defined(BOOT)
void lcdDrawFilledRect(coord_t x, scoord_t y, coord_t w, coord_t h, uint8_t pat, LcdFlags att)
@@ -781,7 +868,7 @@ void drawSource(coord_t x, coord_t y, uint32_t idx, LcdFlags att)
}
else if (idx <= MIXSRC_LAST_INPUT) {
lcdDrawChar(x+2, y+1, CHR_INPUT, TINSIZE);
lcdDrawFilledRect(x, y, 7, 7);
lcdDrawSolidFilledRect(x, y, 7, 7);
if (ZEXIST(g_model.inputNames[idx-MIXSRC_FIRST_INPUT]))
lcdDrawSizedText(x+8, y, g_model.inputNames[idx-MIXSRC_FIRST_INPUT], LEN_INPUT_NAME, ZCHAR|att);
else
@@ -1411,43 +1498,6 @@ void lcdDrawChar(coord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
}
#endif
#if defined(CPUM64)
void lcdDrawVerticalLine(coord_t x, int8_t y, int8_t h, uint8_t pat)
{
if (x >= LCD_W) return;
if (h<0) { y+=h; h=-h; }
if (y<0) { h+=y; y=0; }
if (y+h > LCD_H) { h = LCD_H - y; }
if (pat==DOTTED && !(y%2))
pat = ~pat;
uint8_t *p = &displayBuf[ y / 8 * LCD_W + x ];
y = (y & 0x07);
if (y) {
ASSERT_IN_DISPLAY(p);
*p ^= ~(BITMASK(y)-1) & pat;
p += LCD_W;
h -= 8-y;
}
while (h>0) {
ASSERT_IN_DISPLAY(p);
*p ^= pat;
p += LCD_W;
h -= 8;
}
if (h < 0) h += 8;
if (h) {
p -= LCD_W;
ASSERT_IN_DISPLAY(p);
*p ^= ~(BITMASK(h)-1) & pat;
}
}
#else
// allows the att parameter...
#endif
#define LCD_IMG_FUNCTION(NAME, TYPE, READ_BYTE) \
void NAME(coord_t x, coord_t y, TYPE img, uint8_t idx, LcdFlags att) \
{ \
@@ -1523,44 +1573,6 @@ void lcdDrawHorizontalLine(coord_t x, coord_t y, coord_t w, uint8_t pat, LcdFlag
}
}
void lcdDrawVerticalLine(coord_t x, scoord_t y, scoord_t h, uint8_t pat, LcdFlags att)
{
if (x >= LCD_W) return;
#if defined(CPUARM)
// should never happen on 9X
if (y >= LCD_H) return;
#endif
if (h<0) { y+=h; h=-h; }
if (y<0) { h+=y; y=0; }
if (y+h > LCD_H) { h = LCD_H - y; }
if (pat==DOTTED && !(y%2))
pat = ~pat;
uint8_t *p = &displayBuf[ y / 8 * LCD_W + x ];
y = (y & 0x07);
if (y) {
ASSERT_IN_DISPLAY(p);
uint8_t msk = ~(BITMASK(y)-1);
h -= 8-y;
if (h < 0)
msk -= ~(BITMASK(8+h)-1);
lcdMaskPoint(p, msk & pat, att);
p += LCD_W;
}
while (h>=8) {
ASSERT_IN_DISPLAY(p);
lcdMaskPoint(p, pat, att);
p += LCD_W;
h -= 8;
}
if (h>0) {
ASSERT_IN_DISPLAY(p);
lcdMaskPoint(p, (BITMASK(h)-1) & pat, att);
}
}
#if defined(PWR_PRESS_BUTTON)
void drawShutdownAnimation(uint32_t index)
{
+7 -2
View File
@@ -226,10 +226,11 @@ void lcdDrawPoint(coord_t x, coord_t y, 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 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);
#if defined(CPUM64)
void lcdDrawSolidVerticalLine(coord_t x, scoord_t y, scoord_t h);
void lcdDrawVerticalLine(coord_t x, scoord_t y, int8_t h, uint8_t pat);
#else
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);
#endif
@@ -237,7 +238,11 @@ void lcdDrawSolidVerticalLine(coord_t x, scoord_t y, scoord_t h);
void lcdDrawLine(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat=SOLID, LcdFlags att=0);
#endif
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, LcdFlags att=0);
inline void lcdDrawSolidFilledRect(coord_t x, scoord_t y, coord_t w, coord_t h, LcdFlags att=0)
{
lcdDrawFilledRect(x, y, w, h, SOLID, att);
}
void lcdDrawRect(coord_t x, coord_t y, coord_t w, coord_t h, uint8_t pat=SOLID, LcdFlags att=0);
void lcdInvertLine(int8_t line);
+1 -1
View File
@@ -540,7 +540,7 @@ void menuModelExposAll(event_t event)
}
if (cur == sub) {
/* invert the raw when it's the current one */
lcdDrawFilledRect(EXPO_LINE_SELECT_POS+1, y, LCD_W-EXPO_LINE_SELECT_POS-2, 7);
lcdDrawSolidFilledRect(EXPO_LINE_SELECT_POS+1, y, LCD_W-EXPO_LINE_SELECT_POS-2, 7);
}
}
}
+2 -2
View File
@@ -380,7 +380,7 @@ void drawOffsetBar(uint8_t x, uint8_t y, MixData * md)
if (barMin <= barMax) {
int8_t right = (barMax * GAUGE_WIDTH) / 200;
int8_t left = ((barMin * GAUGE_WIDTH) / 200)-1;
lcdDrawFilledRect(x+GAUGE_WIDTH/2+left, y+2, right-left, GAUGE_HEIGHT-3);
lcdDrawSolidFilledRect(x+GAUGE_WIDTH/2+left, y+2, right-left, GAUGE_HEIGHT-3);
}
lcdDrawSolidVerticalLine(x+GAUGE_WIDTH/2-1, y, GAUGE_HEIGHT+1);
if (barMin == -101) {
@@ -882,7 +882,7 @@ void menuModelExpoMix(uint8_t expo, event_t event)
}
if (cur == sub) {
/* invert the raw when it's the current one */
lcdDrawFilledRect(expo ? EXPO_LINE_SELECT_POS+1 : 23, y, expo ? (LCD_W-EXPO_LINE_SELECT_POS-2) : (LCD_W-24), 7);
lcdDrawSolidFilledRect(expo ? EXPO_LINE_SELECT_POS+1 : 23, y, expo ? (LCD_W-EXPO_LINE_SELECT_POS-2) : (LCD_W-24), 7);
}
}
}
+2 -2
View File
@@ -178,7 +178,7 @@ void drawOffsetBar(uint8_t x, uint8_t y, MixData * md)
if (barMin <= barMax) {
int8_t right = (barMax * gaugeWidth) / 200;
int8_t left = ((barMin * gaugeWidth) / 200)-1;
lcdDrawFilledRect(x+gaugeWidth/2+left, y+2, right-left, gaugeHeight-3);
lcdDrawSolidFilledRect(x+gaugeWidth/2+left, y+2, right-left, gaugeHeight-3);
}
lcdDrawSolidVerticalLine(x+gaugeWidth/2-1, y, gaugeHeight+1);
if (barMin == -101) {
@@ -569,7 +569,7 @@ void menuModelMixAll(event_t event)
}
if (cur == sub) {
/* invert the raw when it's the current one */
lcdDrawFilledRect(23, y, LCD_W-24, 7);
lcdDrawSolidFilledRect(23, y, LCD_W-24, 7);
}
}
}
+1 -1
View File
@@ -375,7 +375,7 @@ void menuModelSelect(event_t event)
}
if (s_copyMode && (vertpos_t)sub==i+menuVerticalOffset) {
lcdDrawFilledRect(9, y, MODELSEL_W-1-9, 7);
lcdDrawSolidFilledRect(9, y, MODELSEL_W-1-9, 7);
lcdDrawRect(8, y-1, MODELSEL_W-1-7, 9, s_copyMode == COPY_MODE ? SOLID : DOTTED);
}
}
+1 -1
View File
@@ -886,7 +886,7 @@ void menuModelSetup(event_t event)
}
}
else {
lcdDrawFilledRect(MODEL_SETUP_2ND_COLUMN, y, LCD_W - MODEL_SETUP_2ND_COLUMN, 8);
lcdDrawSolidFilledRect(MODEL_SETUP_2ND_COLUMN, y, LCD_W - MODEL_SETUP_2ND_COLUMN, 8);
}
}
}
+2 -2
View File
@@ -72,7 +72,7 @@ void drawAlertBox(const pm_char * title, const pm_char * text, const char * acti
lcdDrawText(MESSAGE_LCD_OFFSET, 2*FH, STR_WARNING, DBLSIZE);
#endif
lcdDrawFilledRect(0, 0, LCD_W, 32);
lcdDrawSolidFilledRect(0, 0, LCD_W, 32);
if (text) {
lcdDrawTextAlignedLeft(5*FH, text);
}
@@ -150,7 +150,7 @@ const char * runPopupMenu(event_t event)
for (uint8_t i=0; i<display_count; i++) {
lcdDrawText(MENU_X+6, i*(FH+1) + y + 2, popupMenuItems[i], popupMenuFlags);
if (i == s_menu_item) lcdDrawFilledRect(MENU_X+1, i*(FH+1) + y + 1, MENU_W-2, 9);
if (i == s_menu_item) lcdDrawSolidFilledRect(MENU_X+1, i*(FH+1) + y + 1, MENU_W-2, 9);
}
if (popupMenuNoItems > display_count) {
+2
View File
@@ -32,6 +32,8 @@ void drawMessageBox();
void showMessageBox(const pm_char * title);
void runPopupWarning(event_t event);
#define DRAW_MESSAGE_BOX(title) (warningText = title, drawMessageBox(), warningText = NULL)
#if defined(CPUARM)
extern void (*popupFunc)(event_t event);
extern int16_t warningInputValue;
+21 -9
View File
@@ -56,6 +56,13 @@ inline bool isFilenameLower(bool isfile, const char * fn, const char * line)
return (!isfile && line[SD_SCREEN_FILE_LENGTH+1]) || (isfile==(bool)line[SD_SCREEN_FILE_LENGTH+1] && strcasecmp(fn, line) < 0);
}
void getSelectionFullPath(char * lfn)
{
f_getcwd(lfn, _MAX_LFN);
strcat(lfn, PSTR("/"));
strcat(lfn, reusableBuffer.sdmanager.lines[menuVerticalPosition - HEADER_LINE - menuVerticalOffset]);
}
void onSdManagerMenu(const char * result)
{
TCHAR lfn[_MAX_LFN+1];
@@ -68,9 +75,7 @@ void onSdManagerMenu(const char * result)
POPUP_CONFIRMATION(STR_CONFIRM_FORMAT);
}
else if (result == STR_DELETE_FILE) {
f_getcwd(lfn, _MAX_LFN);
strcat_P(lfn, PSTR("/"));
strcat(lfn, reusableBuffer.sdmanager.lines[index]);
getSelectionFullPath(lfn);
f_unlink(lfn);
strncpy(statusLineMsg, reusableBuffer.sdmanager.lines[index], 13);
strcpy_P(statusLineMsg+min((uint8_t)strlen(statusLineMsg), (uint8_t)13), STR_REMOVED);
@@ -80,19 +85,21 @@ void onSdManagerMenu(const char * result)
}
#if defined(CPUARM)
/* TODO else if (result == STR_LOAD_FILE) {
f_getcwd(lfn, _MAX_LFN);
strcat(lfn, "/");
strcat(lfn, reusableBuffer.sdmanager.lines[index]);
getSelectionFullPath(lfn);
POPUP_WARNING(eeLoadModelSD(lfn));
} */
else if (result == STR_PLAY_FILE) {
f_getcwd(lfn, _MAX_LFN);
strcat(lfn, "/");
strcat(lfn, reusableBuffer.sdmanager.lines[index]);
getSelectionFullPath(lfn);
audioQueue.stopAll();
audioQueue.playFile(lfn, 0, ID_PLAY_FROM_SD_MANAGER);
}
#endif
#if defined(LUA)
else if (result == STR_EXECUTE_FILE) {
getSelectionFullPath(lfn);
luaExec(lfn);
}
#endif
}
void menuRadioSdManager(event_t _event)
@@ -180,6 +187,11 @@ void menuRadioSdManager(event_t _event)
else */ if (!strcasecmp(ext, SOUNDS_EXT)) {
POPUP_MENU_ADD_ITEM(STR_PLAY_FILE);
}
#endif
#if defined(LUA)
else if (!strcasecmp(ext, SCRIPTS_EXT)) {
POPUP_MENU_ADD_ITEM(STR_EXECUTE_FILE);
}
#endif
if (!READ_ONLY()) {
POPUP_MENU_ADD_ITEM(STR_DELETE_FILE);
+2 -2
View File
@@ -188,13 +188,13 @@ void displayBattVoltage()
{
#if defined(BATTGRAPH)
putsVBat(VBATT_X-8, VBATT_Y+1, RIGHT);
lcdDrawFilledRect(VBATT_X-25, VBATT_Y+9, 21, 5);
lcdDrawSolidFilledRect(VBATT_X-25, VBATT_Y+9, 21, 5);
lcdDrawSolidVerticalLine(VBATT_X-4, VBATT_Y+10, 3);
uint8_t count = GET_TXBATT_BARS();
for (uint8_t i=0; i<count; i+=2)
lcdDrawSolidVerticalLine(VBATT_X-24+i, VBATT_Y+10, 3);
if (!IS_TXBATT_WARNING() || BLINK_ON_PHASE)
lcdDrawFilledRect(VBATT_X-26, VBATT_Y, 24, 15);
lcdDrawSolidFilledRect(VBATT_X-26, VBATT_Y, 24, 15);
#else
LcdFlags att = (IS_TXBATT_WARNING() ? BLINK|INVERS : 0) | BIGSIZE;
putsVBat(VBATT_X-1, VBATT_Y, att|NO_UNIT);
+3 -3
View File
@@ -38,7 +38,7 @@ void drawCheckBox(coord_t x, coord_t y, uint8_t value, LcdFlags attr)
if (value)
lcdDrawChar(x+1, y, '#');
if (attr)
lcdDrawFilledRect(x, y, 7, 7);
lcdDrawSolidFilledRect(x, y, 7, 7);
else
lcdDrawSquare(x, y, 7);
#else
@@ -103,14 +103,14 @@ void drawSlider(coord_t x, coord_t y, uint8_t value, uint8_t max, uint8_t attr)
{
lcdDrawChar(x+(value*4*FW)/max, y, '$');
lcdDrawSolidHorizontalLine(x, y+3, 5*FW-1, FORCE);
if (attr && (!(attr & BLINK) || !BLINK_ON_PHASE)) lcdDrawFilledRect(x, y, 5*FW-1, FH-1);
if (attr && (!(attr & BLINK) || !BLINK_ON_PHASE)) lcdDrawSolidFilledRect(x, y, 5*FW-1, FH-1);
}
#elif defined(GRAPHICS)
void display5posSlider(coord_t x, coord_t y, uint8_t value, uint8_t attr)
{
lcdDrawChar(x+2*FW+(value*FW), y, '$');
lcdDrawSolidHorizontalLine(x, y+3, 5*FW-1, SOLID);
if (attr && (!(attr & BLINK) || !BLINK_ON_PHASE)) lcdDrawFilledRect(x, y, 5*FW-1, FH-1);
if (attr && (!(attr & BLINK) || !BLINK_ON_PHASE)) lcdDrawSolidFilledRect(x, y, 5*FW-1, FH-1);
}
#endif
+1
View File
@@ -31,6 +31,7 @@
void drawMessageBox(const char * title);
void showMessageBox(const char * title);
void runPopupWarning(event_t event);
#define DRAW_MESSAGE_BOX(title) drawMessageBox(title)
extern void (*popupFunc)(event_t event);
extern int16_t warningInputValue;
+1 -1
View File
@@ -61,7 +61,7 @@ inline bool isFilenameLower(bool isfile, const char * fn, const char * line)
return (!isfile && IS_FILE(line)) || (isfile==IS_FILE(line) && strcasecmp(fn, line) < 0);
}
void getSelectionFullPath(char *lfn)
void getSelectionFullPath(char * lfn)
{
f_getcwd(lfn, _MAX_LFN);
strcat(lfn, PSTR("/"));