300 lines
6.8 KiB
C
300 lines
6.8 KiB
C
#include <sysinit.h>
|
|
|
|
#include "basic/basic.h"
|
|
|
|
//#include "lcd/render.h"
|
|
//#include "lcd/display.h"
|
|
//#include "lcd/allfonts.h"
|
|
//#include "lcd/backlight.h"
|
|
//#include "lcd/print.h"
|
|
|
|
#include "usetable.h"
|
|
|
|
void incBacklight(void);
|
|
void decBacklight(void);
|
|
void paintLogo(bool);
|
|
void leiwandInit(void);
|
|
void leiwandDisplay(void);
|
|
|
|
/**************************************************************************/
|
|
#include "leiwand.h"
|
|
/**************************************************************************/
|
|
|
|
void ram(void) {
|
|
int key;
|
|
leiwandInit();
|
|
while (1) {
|
|
leiwandDisplay();
|
|
// Exit on enter+left
|
|
key=getInputRaw();
|
|
if(key== BTN_ENTER + BTN_LEFT)
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
|
|
void leiwandDisplay(void) {
|
|
int dx=0;
|
|
char key = 0;
|
|
//backlightInit();
|
|
int i;
|
|
int j;
|
|
char str[] = "LeiwandVille";
|
|
char msg[] = " Just cool! ";
|
|
#define msglen 12
|
|
int pos[msglen];
|
|
int dir[msglen];
|
|
int round = 0;
|
|
bool upPressed=false;
|
|
bool rightPressed=false;
|
|
bool downPressed=false;
|
|
int demoround = 0;
|
|
|
|
//lcdToggleFlag(LCD_INVERTED);
|
|
|
|
for(i = 0; i < msglen; i++) {
|
|
pos[i] = 1 + (i * 2);
|
|
dir[i] = 0;
|
|
}
|
|
|
|
while (1) {
|
|
lcdDisplay();
|
|
delayms(20);
|
|
|
|
key= getInputRaw();
|
|
|
|
// Easy flashing
|
|
if((key&(BTN_ENTER|BTN_LEFT))==(BTN_ENTER|BTN_LEFT)){
|
|
//DoString(0,8,"Enter ISP!");
|
|
//lcdDisplay();
|
|
//ISPandReset();
|
|
return;
|
|
}
|
|
|
|
/*
|
|
// INVERT
|
|
if(((key&(BTN_RIGHT))==(BTN_RIGHT))){
|
|
if(!rightPressed) {
|
|
lcdToggleFlag(LCD_INVERTED);
|
|
}
|
|
rightPressed = true;
|
|
} else {
|
|
rightPressed = false;
|
|
}
|
|
*/
|
|
|
|
// BRIGHTER
|
|
if(((key&(BTN_UP))==(BTN_UP))){
|
|
if(!upPressed) {
|
|
incBacklight();
|
|
}
|
|
upPressed = true;
|
|
} else {
|
|
upPressed = false;
|
|
}
|
|
|
|
// DARKER
|
|
if(((key&(BTN_DOWN))==(BTN_DOWN))){
|
|
if(!downPressed) {
|
|
decBacklight();
|
|
}
|
|
downPressed = true;
|
|
} else {
|
|
downPressed = false;
|
|
}
|
|
|
|
|
|
round++;
|
|
if(round > 200) {
|
|
round = 0;
|
|
gpioSetValue (RB_LED0, CFG_LED_OFF);
|
|
gpioSetValue (RB_LED2, CFG_LED_OFF);
|
|
if(demoround == 1) {
|
|
paintLogo(true);
|
|
} else {
|
|
paintLogo(false);
|
|
delayms(1000);
|
|
}
|
|
demoround++;
|
|
}
|
|
if(demoround == 4) {
|
|
demoround = 0;
|
|
}
|
|
|
|
for(i = 0; i < msglen; i++) {
|
|
if(dir[i] == 1) {
|
|
if(pos[i] >= 30) {
|
|
dir[i] = 0;
|
|
} else {
|
|
pos[i]++;
|
|
}
|
|
} else {
|
|
if(pos[i] == 0) {
|
|
dir[i] = 1;
|
|
} else {
|
|
pos[i]--;
|
|
}
|
|
}
|
|
}
|
|
|
|
lcdFill(0);
|
|
//font=&Font_7x8;
|
|
for(i = 0; i < msglen; i++) {
|
|
if(str[i] != 32) {
|
|
dx=DoChar(i*8, pos[i], str[i]);
|
|
}
|
|
}
|
|
if(round < 100) {
|
|
// Second line of message
|
|
for(i = 0; i < msglen; i++) {
|
|
if(msg[i] != 32) {
|
|
dx=DoChar(i*8, 15+pos[i], msg[i]);
|
|
}
|
|
}
|
|
} else {
|
|
// INVADERS
|
|
//font = &Font_Invaders;
|
|
for(i = 2; i < 10; i+= 2) {
|
|
dx=DoChar(i*8, 15+pos[i], 'x');
|
|
}
|
|
}
|
|
//font=&Font_7x8;
|
|
if(round < 50) {
|
|
dx=DoString(0, 60, " Visit us! ");
|
|
} else if(round < 100) {
|
|
dx=DoString(0, 60, " We are ");
|
|
} else if(round < 150) {
|
|
dx=DoString(0, 60, " next to the ");
|
|
} else {
|
|
dx=DoString(0, 60, " phone booth ");
|
|
if((round % 6) < 3) {
|
|
gpioSetValue (RB_LED0, CFG_LED_ON);
|
|
gpioSetValue (RB_LED2, CFG_LED_ON);
|
|
for(i = 0; i < 96; i++) {
|
|
for(j = 0; j < 8; j++) {
|
|
lcdSetPixel(i, j+60, !lcdGetPixel(i, j+60));
|
|
}
|
|
}
|
|
} else {
|
|
gpioSetValue (RB_LED0, CFG_LED_OFF);
|
|
gpioSetValue (RB_LED2, CFG_LED_OFF);
|
|
}
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
#define cfg_size (2 << 14)
|
|
void tick_scroll(void){
|
|
return;
|
|
};
|
|
|
|
void leiwandInit(void) {
|
|
char *delimeter = (char *)0;
|
|
char readbuffer[15];
|
|
char cfgfile[] = "leiwand.cfg";
|
|
gpioSetValue (RB_LED0, CFG_LED_ON);
|
|
gpioSetValue (RB_LED2, CFG_LED_OFF);
|
|
gpioSetValue (RB_LED3, CFG_LED_OFF);
|
|
paintLogo(false);
|
|
delayms(200);
|
|
gpioSetValue (RB_LED0, CFG_LED_OFF);
|
|
gpioSetValue (RB_LED2, CFG_LED_ON);
|
|
DoString(0,0,"Loading");
|
|
lcdDisplay();
|
|
delayms(1000);
|
|
gpioSetValue (RB_LED2, CFG_LED_OFF);
|
|
gpioSetValue (RB_LED3, CFG_LED_ON);
|
|
paintLogo(false);
|
|
DoString(0,0,"Decrunching");
|
|
lcdDisplay();
|
|
// Init config file
|
|
if (readFile(cfgfile, readbuffer, 15) == -1) {
|
|
writeFile(cfgfile, delimeter, cfg_size);
|
|
}
|
|
delayms(1000);
|
|
gpioSetValue (RB_LED0, CFG_LED_OFF);
|
|
gpioSetValue (RB_LED2, CFG_LED_OFF);
|
|
gpioSetValue (RB_LED3, CFG_LED_OFF);
|
|
}
|
|
|
|
void incBacklight(void) {
|
|
/*
|
|
uint32_t brightness = backlightGetBrightness();
|
|
if (brightness < 100) {
|
|
backlightSetBrightness(brightness + 10);
|
|
}
|
|
*/
|
|
return;
|
|
}
|
|
|
|
void decBacklight(void) {
|
|
/*
|
|
uint32_t brightness = backlightGetBrightness();
|
|
if (brightness > 0) {
|
|
backlightSetBrightness(brightness - 10);
|
|
}
|
|
*/
|
|
return;
|
|
}
|
|
|
|
void paintLogo(bool animate) {
|
|
int i;
|
|
int j;
|
|
int t;
|
|
uint8_t pixel;
|
|
int bc = 8;
|
|
int next = 0;
|
|
int mask = 1;
|
|
|
|
|
|
lcdFill(0);
|
|
lcdDisplay();
|
|
for(i = 0; i < 68; i++) {
|
|
for(j = 0; j < 68; j++) {
|
|
if(bc == 8) {
|
|
mask = 1;
|
|
bc = 0;
|
|
pixel = lv_logo[next];
|
|
next++;
|
|
}
|
|
if((pixel & mask) > 0) {
|
|
lcdSetPixel(14+j, i, true);
|
|
} else {
|
|
lcdSetPixel(14+j, i, false);
|
|
}
|
|
bc++;
|
|
mask = mask << 1;
|
|
pixel >> 2;
|
|
}
|
|
//lcdDisplay();
|
|
}
|
|
lcdDisplay();
|
|
if(!animate) {
|
|
return;
|
|
}
|
|
|
|
/*
|
|
for(i = 0; i < 30; i++) {
|
|
delayms(20);
|
|
}
|
|
*/
|
|
|
|
for(t=0; t < 8; t++) {
|
|
for(i=0; i < 96; i++) {
|
|
for(j=0; j < 68; j++) {
|
|
lcdSetPixel(i, j, !lcdGetPixel(i,j));
|
|
}
|
|
lcdDisplay();
|
|
}
|
|
}
|
|
|
|
/*
|
|
for(i = 0; i < 50; i++) {
|
|
delayms(20);
|
|
}
|
|
*/
|
|
|
|
return;
|
|
}
|