Mon Aug 17, 2015 3:38 pm
mougino wrote:jonnection wrote:Amazingly fast work Nicolas
I downloaded the code and wanted to examine it to see if I would be able to get any ideas how to reduce memory use (in Operation Fox I had to do absolutely everything to get it to the 30kb size)
But, at least on this crappy old computer I have with me right now with Arduino ide 1.0.4 I am unable to compile the code
Are you sure that you compiled this package on your computer ? Perhaps there is some new features in Arduino IDE that make it work but at leas IDE 1.0.4 gave these errors.
Anyhow, I got it to compile by chucking everything into 1 ino file. Looking at it right now.
Hm yes you are right, it seems this happens only when you #define LNG ENG
If you keep the #define LNG FRA it compiles fine.
This must be a last minute change I made in this version with a misplaced #if or #endif somewhere. Unfortunately, I'm already sailing on new seas I changed a big deal of code since yesterday and I'm a little reluctant to spend time looking for the ENG error in the old version
I'll make sure this doesn't happen in the new version I'm working on. Thanks for the feedback anyway!
Nicolas
Wed Aug 19, 2015 1:32 pm
Wed Aug 19, 2015 11:51 pm
Sat Aug 22, 2015 7:13 am
Mon Aug 24, 2015 11:51 am
void Gamebuino::popup(const char* text, uint8_t duration){
#if (ENABLE_GUI > 0)
popupText = (reinterpret_cast <const __FlashStringHelper*> (text));
popupTimeLeft = duration+12;
#endif
}
PROGMEM const char keyboard[] =
#ifdef FRENCH
"azertyuiopqsdfghjklmwxcvbn_\030<";
#else
"qwertyuiopasdfghjkl<zxcvbnm_\030";
#endif
void printAlpha(boolean caps, byte i) {
char c=(char)pgm_read_byte(&(keyboard[i])); // read char array in PROGMEM
if(caps && c>='a' && c<='z') c=c&~(0x20); // if(caps) convert to upper case
gb.display.print(c); gb.display.print(F(" "));
}
void alphaKeyboard(char* tgt, byte lmax) {
byte x=0, y=0;
boolean caps=false;
while(1) {
if (gb.update()) {
// draw input bar
gb.display.cursorY++; if(strlen(tgt)) gb.display.print(tgt);
gb.display.cursorY--; if((gb.frameCount/4)%2) gb.display.print(F("_"));
gb.display.drawFastHLine(0,gb.display.fontHeight+1,LCDWIDTH);
// draw keyboard
moveCursor(3, gb.display.fontHeight+5);
for(byte i=0; i<10; i++) printAlpha(caps, i);
moveCursor(3, CURRENT+gb.display.fontHeight+2);
for(byte i=10; i<20; i++) printAlpha(caps, i);
moveCursor(3, CURRENT+gb.display.fontHeight+2);
for(byte i=20; i<29; i++) printAlpha(caps, i);
gb.display.println(F("ok"));
moveCursor(3, CURRENT+2);
for(char c='0'; c<='9'; c++) { gb.display.print(c); gb.display.print(F(" ")); }
// draw select box
gb.display.drawRoundRect(2*x*gb.display.fontWidth+1, (y+1)*(gb.display.fontHeight+2)+(y?1:2), ((x==9 && y==2)?2:1)*gb.display.fontWidth+3, gb.display.fontHeight+3, 3);
// draw legend
#ifdef FRENCH
moveCursor(LCDWIDTH-7*gb.display.fontWidth-6, LCDHEIGHT-gb.display.fontHeight+1);
gb.display.print(F("annuler"));
#else
moveCursor(LCDWIDTH-6*gb.display.fontWidth-6, LCDHEIGHT-gb.display.fontHeight+1);
gb.display.print(F("cancel"));
#endif
gb.display.print(F("\026"));
// handle user input
if(gb.buttons.pressed(BTN_RIGHT)) x=(x+1)%10;
if(gb.buttons.pressed(BTN_LEFT)) { x--; if(x==255) x=9; }
if(gb.buttons.pressed(BTN_DOWN)) y=(y+1)%4;
if(gb.buttons.pressed(BTN_UP)) { y--; if(y==255) y=3; }
if(gb.buttons.pressed(BTN_B)) { tgt[0]=NULL; break; } // Cancelled by user
if(gb.buttons.pressed(BTN_A)) {
byte l=strlen(tgt);
if(x==9 && y==2) { // Ok
break;
} else if(y==3) { // 0-9
if(l<lmax) { tgt[l++]=(char)'0'+x; tgt[l]=NULL; }
} else { // Other key
char c=(char)pgm_read_byte(&(keyboard[10*y+x])); // read char array in PROGMEM
if(c=='<') { // Del
if(l) tgt[l-1]=NULL;
} else if(c=='\030' || c=='\031') { // Shift
caps=!caps;
} else if(l<lmax) { // a-z, A-Z
if(c=='_') c=' '; else if(caps) c=c&~(0x20); // convert space +if(caps) put in upper case
tgt[l++]=(char)c; tgt[l]=NULL;
} // if(l<lmax)
} // Other key
} // if(gb.buttons.pressed(BTN_A))
} // if (gb.update())
} // while(1)
} // alphaKeyboard()
Mon Aug 24, 2015 11:59 am
#define NCHRX 21 // number of characters per line with font3x5
#define NCHRY 8 // number of lines per screen with font3x5
#define CURRENT 100
#define PREVLINE 150
#define NEXTLINE 200
void moveCursor(byte x, byte y) {
gb.display.cursorX+=
(x>=CURRENT-NCHRX?x-CURRENT // relative CURRENT +/- n
:x-gb.display.cursorX); // absolute
gb.display.cursorY+=
(y>=NEXTLINE-NCHRY?y-NEXTLINE+gb.display.fontHeight: // relative NEXTLINE +/- n
(y>=PREVLINE-NCHRY?y-PREVLINE-gb.display.fontHeight: // relative PREVLINE +/- n
(y>=CURRENT?y-CURRENT // relative CURRENT +/- n
:y-gb.display.cursorY))); // absolute
}
Mon Aug 24, 2015 2:00 pm
Mon Aug 24, 2015 5:10 pm
Mon Aug 24, 2015 7:35 pm
Mon Aug 24, 2015 8:04 pm