Subversion Repositories group.electronics

Rev

Rev 44 | Rev 49 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 44 Rev 48
Line 15... Line 15...
15
 
15
 
16
volatile uint8_t pcIntCurr[3] = {0,0,0};
16
volatile uint8_t pcIntCurr[3] = {0,0,0};
17
volatile uint8_t pcIntLast[3] = {0,0,0};
17
volatile uint8_t pcIntLast[3] = {0,0,0};
18
volatile uint8_t pcIntMask[3] = {0,0,0};
18
volatile uint8_t pcIntMask[3] = {0,0,0};
19
 
19
 
-
 
20
volatile uint8_t tmr0_ovf = 0;
-
 
21
volatile uint16_t systime = 0;
-
 
22
 
-
 
23
uint8_t analogRead(uint8_t);
-
 
24
 
-
 
25
uint8_t emblock[] = {	0B00011111,
-
 
26
			0B00010001,
-
 
27
			0B00010001,
-
 
28
			0B00010001,
-
 
29
			0B00010001,
-
 
30
			0B00010001,
-
 
31
			0B00010001,
-
 
32
			0B00011111 };
-
 
33
			
-
 
34
 
20
int main(void) {
35
int main(void) {
21
 
36
 
22
  ACSR |= (1<<ACD); // Disable analog comparator
37
  ACSR |= (1<<ACD); // Disable analog comparator
23
 
38
 
24
  /*
39
  /*
Line 76... Line 91...
76
//	i2c_writeByte(0x01);
91
//	i2c_writeByte(0x01);
77
//	i2c_endTransmission(1);
92
//	i2c_endTransmission(1);
78
 
93
 
79
	i2c_master();
94
	i2c_master();
80
	lcd_init();
95
	lcd_init();
-
 
96
	lcd_createChar(0x00, emblock);
81
 
97
 
82
	uint8_t chars = 7;
98
  wdt_enable(WDTO_8S);
83
	char text[] = { 'R', 'h', 'i', 'a', 'n', 'n', 'o', 'n' };
-
 
84
 
-
 
85
	uint8_t i = 0;
-
 
86
	for (i=0; i<=chars; i++)
-
 
87
		lcd_char((uint8_t) text[i]);
-
 
88
 
-
 
89
 
99
 
-
 
100
	uint16_t oldsystime = systime; 
90
 
101
 
-
 
102
	char strTime[] = {'T', 'i', 'm', 'e', ':', 0x00};
-
 
103
	lcd_setCursor(0, 1);
-
 
104
	lcd_print(strTime);
91
 
105
 
92
  wdt_enable(WDTO_8S);
-
 
93
 
-
 
94
  for(;;) {
106
  for(;;) {
95
    wdt_reset();
107
    wdt_reset();
-
 
108
	if (oldsystime != systime) {
-
 
109
		oldsystime = systime;
-
 
110
		char syschar[6];
-
 
111
		itoa(systime, syschar, 10);
-
 
112
		syschar[5] = 0x00;
-
 
113
		lcd_setCursor(6,1);
-
 
114
		lcd_print(syschar);
96
 
115
 
-
 
116
		char pot[4];
-
 
117
		itoa(analogRead(0), pot, 10);
-
 
118
		//pot[3] = 0x00;
-
 
119
		//lcd_setCursor(0,0);
-
 
120
		//lcd_print(pot);
-
 
121
		lcd_overprint(pot, 4, 0, 0);
-
 
122
 
-
 
123
		lcd_setCursor(9, 0);
-
 
124
		lcd_char(0x00);
-
 
125
	}
97
  }
126
  }
98
}
127
}
99
 
128
 
100
uint8_t analogRead(uint8_t pin) {
129
uint8_t analogRead(uint8_t pin) {
101
	ADMUX = (1<<ADLAR) | (1<<REFS0) | (0<<REFS1) | (pin & 0x0f);
130
	ADMUX = (1<<ADLAR) | (1<<REFS0) | (0<<REFS1) | (pin & 0x0f);
Line 120... Line 149...
120
	// Clear the mask so we know we've delth with it
149
	// Clear the mask so we know we've delth with it
121
	pcIntMask[pcint] = 0;
150
	pcIntMask[pcint] = 0;
122
}
151
}
123
 
152
 
124
ISR(TIMER0_OVF_vect) {
153
ISR(TIMER0_OVF_vect) {
-
 
154
	tmr0_ovf++;
-
 
155
	if (tmr0_ovf==255)
-
 
156
		systime++;
125
}
157
}
126
 
158
 
127
ISR(PCINT1_vect)
159
ISR(PCINT1_vect)
128
{
160
{
129
        // Save the state and work out which pin caused
161
        // Save the state and work out which pin caused