Arduino and TouchShield Burning Man 2009 countdown from Matt Bitz on Vimeo.
Arduino and TouchShield Burning Man 2009 from Matt Bitz on Vimeo.
I've just uploaded all the source code, pictures, and image uploader utility over at the projects page.
For a shortcut, here's the source code for the TouchShield:
#include "touchLargeNums.h"
largeNum myFont = largeNum();
POINT p;
unsigned long days;
char out[5];
COLOR c = {236,191,51};
int demo = 0;
int demodelay = 100;
int numpix = 4;
void setup()
{
//uncomment this to stall the touchshield into picture uploading mode
//image_interface_begin();
days = 365;//365;
myFont.setForeColor(c);
numpix = 4;
}
void loop()
{
for(int i=0;i<numpix;i++){
if (i==0) bmp_draw("burn001",0,0);
if (i==1) bmp_draw("burn002",0,0);
if (i==2) bmp_draw("burn003",0,0);
if (i==3) bmp_draw("burn004",0,0);
printbignum(days--);
if (days == -1) {
while(!touch_get_cursor(&p)){};
days = 365;
};
if (!demo) {
while(!touch_get_cursor(&p)){};
} else {
delay(demodelay);
};
}
} //end loop
void printbignum(unsigned int num) {
int len = 3;
//itoa(num,out,10);
dtostrf(num,3,0,out);
//dtostrf((unsigned int)out[1],3,0,out);
if (out[0]==32 && out[1]==32) {
len=1;
} else if (out[0]==32 && out[1]!=32) {
len=2;
}
if(len==2) {
dtostrf(num,2,0,out);
myFont.putst(out,10,15);
} else if (len==1) {
dtostrf(num,1,0,out);
myFont.putst(out,18,15);
} else if (len==3) {
dtostrf(num,3,0,out);
myFont.putsb(out,30,45);
}
}
No comments:
Post a Comment