Ult
Projects
Urt
Ll Lr

Ult
Featured
Urt
Ll Lr

Ult
Log in
Urt
Ll Lr


Burning_man_counter_thumbnail_small
Digg_16x16 Delicious_16x16 Reddit_16x16 Technorati_16x16 Blinklist_16x16 Furl_16x16
8 images, 3 parts

Burning Man Countdown

Every year, a bunch of crazy, wacky artists travel from all over the US (but mostly from California) to travel to Burning Man. And each year, the internet gets flooded with fun pictures of all the great art shows, and I think, gee I wish I had remembered…

So I’ve built a handy little desktop Burning Man reminder for myself with a TouchShield and an Arduino, so I don’t miss it again next year. Here’s a little tutorial on how I built it. If you want one pre-programmed, just email me, and I’ll program your TouchShield with it before I send it…

Step 0: Download all the files you’ll need I’ve placed all the files, libraries, and programs you’ll need into one zip file, over here:

http://www.liquidware.org/uploads/idea82/Burning%20Man%20Countdown.zip

Step 1: Font library The first step was preparing the Arduino IDE with the proper libraries. That meant installing the touchLargeNums library (a library Chris and I built together to display small and large numbers on the TouchShield). To do this, shut down the Arduino application if it’s already open, and then copy the touchLargeNums folder from the zip file into the hardware/libraries folder in the Arduino directory. Then, restart the Arduino application, and you should see the library in the Sketch/Import Library pull-down menu at the top of the screen.

If you’ve already installed this library from a previous project, you’ll have to reinstall this library, since I’ve created some new functions that allow numbers to be written without blacking out the background. This means you can place a number on top of an image, and you can see the image around the number! The library also includes a scaled-up font function, which basically prints really large numbers on the screen (no more than 2 digits at a time, though).

Step 2: Install TouchShield picture uploader The next step is to install the TouchShield image uploader. This is an application that Mike (thanks!) wrote to load images onto the onboard memory of the TouchShield. It’s quite impressive, actually, and it works like a charm. It’s the zip file called TSImageUploader.zip, and you can just unzip it anywhere you’d like. In the folder, you’ll also find all the source code to the application, in case you’re curious about how the insides work, and how Mike figured out how to use the bootloader mode in a really clever way.

Step 3: Prepare pictures The TouchShield uses bitmap picture files, which can be as large as 128×128 pixels. I like to use the open source program Gimp to do my photo editing, and I find that it has a great set of functions to resize (Image -> Scale Image) and convert to bitmap (Save As, then end the file in .bmp). In the zip file, you can find the original files I used, called “burning man 1-4.jpg”, then the cropped pictures that end in .jpg, and finally the resized bitmaps that end in .bmp. In this case, I’ve already done the image work, but you could easily do this with your own pictures.

The last step in preparing the photos is to rename the files to be no more, and no less than 7 letters long. This is because the TouchShield creates a small flash-like storage area onboard, and accesses it like a normal memory. In my case, I had 4 pictures, and so I labelled them “burn001.bmp”, “burn002.bmp”, “burn003.bmp”, and “burn004.bmp”. I could have had more pictures, but I liked those 4 the best.

Step 4 Upload pictures Uploading pictures to the TouchShield requires that you load a special program onto the TouchShield first. The program holds the TouchShield in a special bootloader mode that just sits there, waiting for the computer to send picture data.

Just copy the program below into the Arduino IDE, then compile it (make sure you selected the TouchShield from the Tools->Board menu, and the correct Serial Port is selected). Then press the reset button on the TouchShield, and press the program button in the Arduino programming window.

void setup() { image_interface_begin(); }

void loop() {

}

Now, it’s time to switch over to Mike’s TSImageUploader.exe program. Just double click it, and a window will pop up. It will ask you to enter the COM port number (which is the same number as the port selected in the Tools->Serial Port menu in the Arduino programming window). Then, select File->Open from the TSImageUploader, and select the first bitmap picture, “burn001.bmp”. Then repeat the selection for burn002.bmp, burn003.bmp, and burn004.bmp. When they’re loaded, the images will be listed on the right hand side of the TSImageUpoader image. Finally, click the “Burn Bitmaps” button and just sit back and enjoy the status bar show.

Step 5: Edit the code sample We’re almost done… basically the last step, once the images are uploaded, is to reprogram the TouchShield with the program that will display the pictures that were just uploaded. The code below counts down 365 days, sets the font color for the numbers to nice bright orange, and then sets the number of pictures to display before jumping into the loop() function.

The loop() function uses a for loop to select picture 1, then 2, then 3, then 4, and then start all over again. Printbignum() is a special function I wrote that first determines how many digits the number is, and then offsets and resizes the digits accordingly. For 3 digits, I use a small font with the function putsb(), and for 2 and 1 digits I use a big font with putst(). I’m sure I could have written the code a little more efficiently, but at least it gets the job done :) Finally, I threw in a couple lines of code to stop when it displays a “0”, and then sit around and wait until the screen is touched.

If you wanted to add more pictures, you’d have to do 2 things. First, you’d change the line “numpix = 4” to however many pictures you have. Then, add another line in the loop() function, that would read something like, “if (i==4) bmp_draw(“burn005”,0,0);”. And so on.

Finally! You might have noticed that there’s a global variable up at the top of the code called demo. If you set demo to 1, then you can change demodelay to however many milliseconds you want the picture to stay up before switching to the next picture. That way, you don’t have to touch the screen every time to call up the next picture. I like turning this on for when I take videos :)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

#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);
  }
}

Step 6: Upload the program to the TouchShield

The last step is to compile the program above in the Arduino programming window, then press the reset button on the TouchShield, and the program button on the Arduino. And Voila! When it’s done, you’ll see a rotating image on the screen.

I’ve uploaded the rest of the TouchShield’s built-in commands are over at the function reference wiki.

0 Comments on Burning Man Countdown



Add A Comment:

Get in touch if you have any questions, or ideas for something you want me to build.