The hardware components of this system are not worth drawing a circuit diagram for:
- Basic ATmega328 with 16MHz crystal and 22pF balancing capacitors (you know the score)
- An ENC28J60 ethernet module (e.g., from eBay)
- An ST7735 TFT display with SD-card (e.g., from Adafruit)
- Stripboard, connectors, etc.
- Err, that's it!
The software is where the real action lies. This baby (a 600+ line sketch!) crams in the following libraries:
- Adafruit_GFX and Adafruit_ST7735 for drawing the pretty pictures,
- EtherCard for Internet connectivity (DHCP, DNS and Web-client),
- TinyXML to parse Web-service responses, such as this one,
- Petit FatFS to read from the SD card,
- MemoryFree to see how tight RAM was getting.
The restrictions of the AVR chip steered the implementation in interesting directions:
- All string constants stored in flash, using either F() or PSTR().
- Using the TFT screen for debugging rather than Serial (saves 128 bytes RAM).
- Graphics downloaded from Yahoo! in advance, converted into bitmaps and stored on a cheap SD card.
- Buffer-sharing between the XML parser and reading from the SD-card. (In particular, most SD-card libraries require their own 512-byte buffer for output, see this earlier post.)
- Reclamation of some flash on the AVR using Optiboot.
- Displaying wind-direction without using transcendental functions (i.e., sin, cos) used the nice trick of successive rotations. (This is apparently due to the legendary Marvin Minsky, in hakmem 149.)
There is almost no free space left on the chip: just under 200 bytes of RAM (which I guess is needed for the stack) and 512 bytes of flash!
Here's another picture showing forecast data:
Hey, I'm at the moment looking around how to use ST7735 TFT display with SD-card, can you please help or just give an usefull link how to simple implement a code for avr atmega328p just for use this display?
ReplyDeleteWhen i search i found lots of tuturials and code for arduino, but i want to work only with avr...
Thanks from now, simple reply to this post and thanks :)
Convert the Adafruit libraries from C++ to C: pretty easy I reckon.
DeleteYou can find lots of C libraries for SD cards, check out Petit FatFs. It also provides an SPI implementation which you can re-use to support your converted Adafruit_GFX library.
More info on available choices here: http://programmablehardware.blogspot.ie/2013/07/accessing-sd-cards-from-microcontrollers.html
Really thanks for your fast reply, the idea of translate adafruit libraries as good! I started this job, but after another search i found this amazing work.. that includes adafruit libraries already translated:
Deletehttp://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/bth44_pb334/bth44_pb334/index.html