1 /*********************************************
2 * vim: set sw=8 ts=8 si :
3 * Author: Guido Socher, Copyright: GPL
4 * This is a test program which will write "LCD works"
6 * This program is also used to test the keypad. It
7 * displays the button last pressed.
9 * See http://www.tuxgraphics.org/electronics/
12 * Clock frequency : Internal clock 8 Mhz
13 *********************************************/
15 #include <avr/pgmspace.h>
17 #define F_CPU 8000000UL // 8 MHz
18 #include <util/delay.h>
26 // set output to VCC, red LED off
27 #define LEDOFF PORTD|=(1<<PORTD0)
28 // set output to GND, red LED on
29 #define LEDON PORTD&=~(1<<PORTD0)
30 // to test the state of the LED
31 #define LEDISOFF PORTD&(1<<PORTD0)
33 void delay_ms(uint16_t ms)
34 /* delay for a minimum of <ms> */
36 // we use a calibrated macro. This is more
37 // accurate and not so much compiler dependent
52 DDRD|= (1<<DDD0); // LED, enable PD0, LED as output
57 lcd_puts("use U+/U-");
59 lcd_puts("and store");
64 lcd_puts_p(PSTR("pause"));
73 dac_val=0xFFF; //max, 13bit
79 itoa(dac_val,out_buf,10);
88 lcd_puts_p(PSTR("up"));
95 lcd_puts_p(PSTR("down"));
99 if (check_store_button()){
101 lcd_puts_p(PSTR("pause"));
106 check_u_button(&cnt);
110 lcd_puts_p(PSTR("up"));
117 lcd_puts_p(PSTR("down"));
121 if (check_store_button()){
123 lcd_puts_p(PSTR("pause"));