Click here for the full schematic
Note that the RTC will act erratically if the battery is not placed. If you are absolutely sure you don't want battery backup, stick some tinfoil in the battery holder. Otherwise i2c will hang and it will be a real pain to figure out whats going on!
Since we don't have a lot of spare pins on the microcontroller, we save 2 by having the pushbuttons connected 'totem-pole' style to the analog-digital converter. as each button is pressed, the resistor divider made of R3-R6 changes and thus we can tell which switch has been pushed. Note that we can't tell if more than one button is pressed - in this application we dont need to so thats OK.
This display has a parallel 8-bit interface and so it needs 8 bits for the port (DB0-7), and then 2 chip-select lines (CS0 and CS1) as well as an enable pin E, read/write select pin RW and command/data pin RS.
V0 is the contrast pin, and must be connected to a 10K pot tied between ground and VEE which is a negative voltage generated by the LCD.
The backlight of the display is an LED (anode is A cathode is K and is connected to ground). We use a 100 ohm (5V - 3.4Vf / 20mA = 80 ohms or so) resistor R2 to se the brightness. If the resistor is placed in slot R2 we save a pin but cannot adjust the brightness. if R2' is used, the backlight is connected to a PWM output of the micro which allows us to control the brightness in the configuration.
Because of the massive # of pins, the display requires, the only free pins are RX, TX, and PC1. PD3 is free if you solder R2 into the hardwired slot (see above). If you'd like to connect something to the i2c bus, there are already pull ups on there.. If you really need an extra pin, LCD_CS1 is always the invertion of LCD_CS0 so you can use a transistor and a pullup to create a 'not gate' and the use either PC0 or PD2.
The clock core code is in ratt.c, that's where the stuff that deals with setting and updating the time, snooze, talking to the RTC, beeping the piezo and running the main loop that animates the display.
Button debouncing and interface code is in buttons.c. The ADC runs constantly to look for changes in the resistor divider.
The configure menu system is all in config.c - it's basically a state machine, you shouldn't have to modify anything there.
The real drawing and any display logic code happens in anim.c. step() is called every TICK milliseconds, and the microcontroller does the work of figuring out where the 'ball' is heading and then whether each 'stick' should attempt to hit it or miss it (depending on whether the time changed).
If you want to design a clock display, you would pretty much just want to edit anim.c and have the init() and step() code change.
MONOCHRON® is a registered trademark of Adafruit Industries