Subversion Repositories group.electronics

Rev

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

Rev 49 Rev 51
Line 63... Line 63...
63
 
63
 
64
  DDRC		= 0B00000000;
64
  DDRC		= 0B00000000;
65
  PORTC		= 0B00110000;
65
  PORTC		= 0B00110000;
66
 
66
 
67
  /*
67
  /*
68
	PD0	- Input, Pullup, PCINT16	- Rotary 1a
68
	PD0	- Output
69
	PD1	- Input, Pullup, PCINT17	- Rotary 1b
69
	PD1	- Input, Pullup, PCINT17	- Rotary 1b
70
 
70
 
71
 
71
 
72
	PD4	- Output		- Keypad select status led
72
	PD4	- Output		- Keypad select status led
73
	PD5	- Input, Pullup		- Keypad 3
73
	PD5	- Input, Pullup		- Keypad 3
74
	PD6	- Input, Pullup		- Keypad 1
74
	PD6	- Input, Pullup		- Keypad 1
75
	PD7	- Input, Pullup		- Keypad 5
75
	PD7	- Input, Pullup		- Keypad 5
76
  */
76
  */
77
  DDRD		= 0B00010000;
77
  DDRD		= 0B00010001;
78
  PORTD		= 0B11100011;
78
  PORTD		= 0B11100011;
79
 
79
 
80
  PCMSK2 |= (( 1 << PCINT16 ) | ( 1 << PCINT17 )); //enable encoder pins interrupt sources
80
  PCMSK2 |= (( 1 << PCINT16 ) | ( 1 << PCINT17 )); //enable encoder pins interrupt sources
81
  PCICR |= ( 1 << PCIE2 ); //enable pin change interupts
81
  PCICR |= ( 1 << PCIE2 ); //enable pin change interupts
82
 
82
 
Line 96... Line 96...
96
	lcd_createChar(0x00, emblock);
96
	lcd_createChar(0x00, emblock);
97
 
97
 
98
  wdt_enable(WDTO_8S);
98
  wdt_enable(WDTO_8S);
99
 
99
 
100
	uint16_t oldsystime = systime; 
100
	uint16_t oldsystime = systime; 
-
 
101
	uint8_t oldpotVal = -1; 
101
 
102
 
102
	char strTime[] = {'T', 'i', 'm', 'e', ':', 0x00};
103
	char strTime[] = {'T', 'i', 'm', 'e', ':', 0x00};
103
	lcd_setCursor(0, 1);
104
	lcd_setCursor(0, 1);
104
	lcd_print(strTime);
105
	lcd_print(strTime);
105
 
106
 
106
  for(;;) {
107
  for(;;) {
107
    wdt_reset();
108
    wdt_reset();
-
 
109
 
108
	if (oldsystime != systime) {
110
	if (oldsystime != systime) {
109
		oldsystime = systime;
111
		oldsystime = systime;
110
		char syschar[6];
112
		char syschar[6];
111
		itoa(systime, syschar, 10);
113
		itoa(systime, syschar, 10);
112
		syschar[5] = 0x00;
114
		syschar[5] = 0x00;
113
		lcd_overprint(syschar, 5, 6, 1);
115
		lcd_overprint(syschar, 5, 6, 1);
114
 
116
 
-
 
117
 
115
		uint8_t potVal = map_8(analogRead(0), 0, 255, 0, 100);
118
	uint8_t potVal = map_8(analogRead(0), 0, 255, 0, 100);
-
 
119
	if (potVal != oldpotVal) {		
116
		lcd_pergraph(potVal, 0, 0);
120
		lcd_pergraph(potVal, 0, 0);
-
 
121
		oldpotVal = potVal;
117
		//char pot[4];
122
		char pot[3];
118
		//itoa(analogRead(0), pot, 10);
123
		itoa(potVal, pot, 10);
119
		//ilcd_overprint(pot, 4, 0, 0);
124
		lcd_overprint(pot, 3, 12, 0);
-
 
125
		lcd_char(0x25);
-
 
126
	}
120
	}
127
	}
121
  }
128
  }
122
}
129
}
123
 
130
 
124
uint8_t analogRead(uint8_t pin) {
131
uint8_t analogRead(uint8_t pin) {
Line 144... Line 151...
144
	// Clear the mask so we know we've delth with it
151
	// Clear the mask so we know we've delth with it
145
	pcIntMask[pcint] = 0;
152
	pcIntMask[pcint] = 0;
146
}
153
}
147
 
154
 
148
ISR(TIMER0_OVF_vect) {
155
ISR(TIMER0_OVF_vect) {
-
 
156
	xbi(PORTD, PD4);
149
	tmr0_ovf++;
157
	tmr0_ovf++;
150
	if (tmr0_ovf==255)
158
	if (tmr0_ovf>=58) {
-
 
159
		xbi(PORTD, PD0);
151
		systime++;
160
		systime++;
-
 
161
		tmr0_ovf = 0;
-
 
162
	}
-
 
163
	
152
}
164
}
153
 
165
 
154
ISR(PCINT1_vect)
166
ISR(PCINT1_vect)
155
{
167
{
156
        // Save the state and work out which pin caused
168
        // Save the state and work out which pin caused