int main() { isLogging = RJ_LOGGING_EN; rjLogLevel = INF2; lifeLight.attach(&imAlive, ALIVE_BLINK_RATE); pc.baud(BAUD_RATE); shared_ptr<SharedSPI> sharedSPI = make_shared<SharedSPI>(RJ_SPI_MOSI, RJ_SPI_MISO, RJ_SPI_SCK); sharedSPI->format(8, 0); FILE* fp = fopen(filename.c_str(), "r"); AVR910 programmer(sharedSPI, RJ_KICKER_nCS, RJ_KICKER_nRESET); if (fp == nullptr) { pc.printf("Failed to open file.\r\n"); return -1; } pc.printf("Attempting to program...\r\n"); bool nSuccess = programmer.program(fp, ATTINY84A_PAGESIZE, ATTINY84A_NUM_PAGES); if (nSuccess) { pc.printf("Programming failed.\r\n"); } else { pc.printf("Programming succeeded.\r\n"); } fclose(fp); lifeLight.detach(); return 0; }
void snake::firstscreen() { _setcursortype(_NOCURSOR); color(); for (int i=75; i>=38; i--) { gotoxy(i,12); cputs("Snake "); gotoxy(24,13); cout<<"--*--*--*--*--*--*--*--*--*--*--"; delay(120); } gotoxy(19,25); cout<<"******** PRESS ANY KEY TO CONTINUE ********"; int g=getch(); if (g==0) g=getch(); if (g==27) programmer(); }
void ui_handler(void) /* Top level user interface handler. Checks whether one of the mode buttons have been pressed, and transfers control to the corresponding function. */ { // If a transfer is going on, simply use the 16 upper buttons as a progress // bar if (mode & MODE_TRANSFER) button_leds[midi_transfer_progress] = 0xFF; else if (mode & MODE_GETVALUE) ui_getvalue_handler(); else { if (button_pressed(BTN_PROGRAM)) { mode = MODE_PROGRAM; button_leds = programmer_leds; } else if (button_pressed(BTN_PATTERN)) { mode = MODE_PATTERN; button_leds = sequencer_leds; } else if (button_pressed(BTN_TRACK)) { mode = MODE_TRACK; //button_leds = track_leds; } else if (button_pressed(BTN_SETTINGS)) { mode = MODE_SETTINGS; button_leds = settings_leds; } switch (mode) { case MODE_PROGRAM: button_led_on(BTN_PROGRAM); programmer(); break; case MODE_PATTERN: //sequencer(); button_led_on(BTN_PATTERN); break; case MODE_TRACK: button_led_on(BTN_TRACK); break; // not implemented yet! case MODE_SETTINGS: settings(); button_led_on(BTN_SETTINGS); break; } // Todo: abstract away this ... if (button_on(BTN_SHIFT)) button_led_on(BTN_SHIFT); else button_led_off(BTN_SHIFT); } // Save current button states prev_input[0] = input[0]; prev_input[1] = input[1]; prev_input[2] = input[2]; //last_mode = mode; }
void playagain() { void main(); textcolor(7); clrscr(); char m,n; _setcursortype(_NOCURSOR); int p=1,v=0; for (int i=5; i<=75; i++) { gotoxy(i,2); cout<<char(196); gotoxy(i,6); cout<<char(196); } gotoxy(36,4); color(); cprintf("PLAY AGAIN ?"); gotoxy(10,8); textcolor(3); cprintf("YES"); gotoxy(10,10); textcolor(7); cprintf("NO"); gotoxy(9,8); cout<<char(16); while(v!=13) { v=getch(); if (v==0) v=getch(); if (v==27) programmer(); if (v==80) { if (p==1) { gotoxy(9,8); cout<<char(255); gotoxy(10,8); textcolor(7); cprintf("YES"); gotoxy(10,10); textcolor(3); cprintf("NO"); gotoxy(9,10); cout<<char(16); p=2; } else if (p==2) { gotoxy(9,10); cout<<char(255); gotoxy(10,10); textcolor(7); cprintf("NO"); gotoxy(10,8); textcolor(3); cprintf("YES"); gotoxy(9,8); cout<<char(16); p=1; } } if (v==72) { if (p==1) { gotoxy(9,8); cout<<char(255); gotoxy(10,8); textcolor(7); cprintf("YES"); gotoxy(10,10); textcolor(3); cprintf("NO"); gotoxy(9,10); cout<<char(16); p=2; } else if (p==2) { gotoxy(9,10); cout<<char(255); gotoxy(10,10); textcolor(7); cprintf("NO"); gotoxy(10,8); textcolor(3); cprintf("YES"); gotoxy(9,8); cout<<char(16); p=1; } } } switch(p) { case 1: main(); break; case 2: programmer(); break; } }
void snake::speedselect() { textcolor(7); clrscr(); char m,n; _setcursortype(_NOCURSOR); int p=2,v=0; for (int i=5; i<=75; i++) { gotoxy(i,2); cout<<char(196); gotoxy(i,6); cout<<char(196); } gotoxy(36,4); color(); cprintf("SELECT SPEED"); gotoxy(10,8); textcolor(3); cout<<"SLOW"; gotoxy(10,10); cprintf("MEDIUM"); gotoxy(9,10); cout<<char(16); gotoxy(10,12); cout<<"FAST"; while (v!=13) { v=getch(); if (v==0) v=getch(); if (v==13) break; if (v==27) programmer(); if (v==80) { if (p==1) { gotoxy(9,8); cout<<" "; gotoxy(9,10); cout<<char(16); gotoxy(10,8); textcolor(7); cprintf("SLOW"); gotoxy(10,10); textcolor(3); cprintf("MEDIUM"); p=2; } else if (p==2) { gotoxy(9,10); cout<<" "; gotoxy(9,12); cout<<char(16); textcolor(7); gotoxy(10,10); cprintf("MEDIUM"); gotoxy(10,12); textcolor(3); cprintf("FAST"); p=3; } else if (p==3) { gotoxy(9,12); cout<<" "; gotoxy(9,8); cout<<char(16); gotoxy(10,12); textcolor(7); cprintf("FAST"); gotoxy(10,8); textcolor(3); cprintf("SLOW"); p=1; } } if (v==72) { if (p==1) { gotoxy(9,8); cout<<" "; gotoxy(9,12); cout<<char(16); gotoxy(10,8); textcolor(7); cprintf("SLOW"); gotoxy(10,12); textcolor(3); cprintf("FAST"); p=3; } else if (p==2) { gotoxy(9,10); cout<<" "; gotoxy(9,8); cout<<char(16); gotoxy(10,10); textcolor(7); cprintf("MEDIUM"); gotoxy(10,8); textcolor(3); cprintf("SLOW"); p=1; } else if (p==3) { gotoxy(9,12); cout<<" "; gotoxy(9,10); cout<<char(16); textcolor(7); gotoxy(10,12); cprintf("FAST"); gotoxy(10,10); textcolor(3); cprintf("MEDIUM"); p=2; } } } switch(p) { case 1: speed=200; break; case 2: speed=120; break; case 3: speed=70; break; } }
void snake::game() { void main(); x=43; y=12; length=6; score=0; for(;;) { while (!kbhit()) { if ((eatx==x)&&(eaty==y)) { gamescore(); eatxy(); length=length+2; } gotoxy(x,y); cout<<""; /* for (int i=1; i<=length+1; i++) { if (newkey==72) { gotoxy(x,y+i); a[i]=x; b[i]=y+i; } if (newkey==75) { gotoxy(x+i,y); a[i]=x+i; b[i]=y; } if (newkey==80) { gotoxy(x,y-i); a[i]=x; b[i]=y-i; } if (newkey==77) { gotoxy(x-i,y); a[i]=x-i; b[i]=y; } if (i==length+1) cout<<" "; else cout<<"Û"; } */ delay(speed); gotoxy(x,y); checkcollision(); if (newkey==72) y--; if (newkey==75) x--; if (newkey==80) y++; if (newkey==77) x++; if (newkey==27) programmer(); if (newkey==13) getch(); if (newkey==110) main(); cout<<" "; } newkey=getch(); if (newkey==0) newkey=getch(); } }