Subversion Repositories group.electronics

Rev

Rev 136 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 136 Rev 139
Line 12... Line 12...
12
 
12
 
13
 
13
 
14
#ifndef NULL
14
#ifndef NULL
15
#define NULL    ((void *)0)
15
#define NULL    ((void *)0)
16
#endif
16
#endif
-
 
17
#ifndef PROTOTYPE
-
 
18
#define PROTOTYPE
-
 
19
#endif
17
 
20
 
18
 
21
 
19
void writeSegment(uint8_t digit, uint8_t value);
22
void writeSegment(uint8_t digit, uint8_t value);
20
void pcInterrupt(void);
23
void pcInterrupt(void);
21
void receiveEvent(uint8_t bytes);
24
void receiveEvent(uint8_t bytes);
Line 42... Line 45...
42
 
45
 
43
//volatile uint8_t doInt = 0;
46
//volatile uint8_t doInt = 0;
44
 
47
 
45
 
48
 
46
//uint8_t disVal[] = {8,8,8,8,8,8,8,8,8,8};
49
//uint8_t disVal[] = {8,8,8,8,8,8,8,8,8,8};
47
volatile uint8_t disVal[] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
50
volatile uint8_t disVal[] = {0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a};
48
volatile uint8_t disPt[] = {0, 0};
51
volatile uint16_t disPt = 0x00;
49
 
52
 
50
int main(void) {
53
int main(void) {
51
 
54
 
52
 
55
 
53
  /*
56
  /*
Line 92... Line 95...
92
    twires_onReceive(receiveEvent);
95
    twires_onReceive(receiveEvent);
93
 
96
 
94
    wdt_enable(WDTO_1S);	// Watchdog for 1 sec
97
    wdt_enable(WDTO_1S);	// Watchdog for 1 sec
95
    sei();			// Enable interrupts
98
    sei();			// Enable interrupts
96
 
99
 
-
 
100
    uint32_t refresh = systime;
-
 
101
    uint8_t disIdx = 0;
97
    
102
 
98
    // Init and clear the displays
103
    // Init and clear the displays
99
    hc595_init();
104
    hc595_init();
100
    hc595_write(0x00);
105
    hc595_write(0x00);
101
 
106
 
102
    uint32_t refresh = systime;
-
 
103
    uint8_t disIdx = 0;
-
 
104
 
-
 
105
 
107
 
106
 
108
 
107
    for(;;){
109
    for(;;){
108
    	 wdt_reset();
110
    	 wdt_reset();
109
 
111
 
Line 158... Line 160...
158
		}
160
		}
159
			break;
161
			break;
160
		case (0x08): {
162
		case (0x08): {
161
			// Recieve 2 bytes, for the decimal points
163
			// Recieve 2 bytes, for the decimal points
162
			//  5 bits used in eac byte
164
			//  5 bits used in eac byte
163
			disPt[0] = twires_receive();
165
			disPt = (uint16_t)twires_receive() << 8;
164
			disPt[1] = twires_receive();
166
			disPt |= (uint16_t)twires_receive();
165
		}
167
		}
166
			break;
168
			break;
167
		case (0x09): {
169
		case (0x09): {
168
			// Reset the rotary
170
			// Reset the rotary
169
			input.outer = 0;
171
			input.outer = 0;
Line 202... Line 204...
202
			break;
204
			break;
203
	}
205
	}
204
}
206
}
205
 
207
 
206
void writeSegment(uint8_t digit, uint8_t value) {
208
void writeSegment(uint8_t digit, uint8_t value) {
207
	uint8_t dp = 0;
209
	//uint8_t dp = 0;
208
	if (digit <= 4 && rbi(disPt[0], digit)) dp = 1;
210
	//if (digit <= 4 && rbi(disPt[0], digit)) dp = 1;
209
	if (digit > 4 && rbi(disPt[1], digit-5)) dp = 1;
211
	//if (digit > 4 && rbi(disPt[1], digit-5)) dp = 1;
210
 
212
 
211
	cbi(BL_PORT, BL_PIN);			// Blank the 4511
213
	cbi(BL_PORT, BL_PIN);			// Blank the 4511
212
	cbi(DP_PORT, DP_PIN);			// Drop the DP before changing digit
214
	cbi(DP_PORT, DP_PIN);			// Drop the DP before changing digit
-
 
215
 
-
 
216
// Changed my mind and reversed order of digit display for release version
-
 
217
//   0-9 is left to right on release, right to left on prototype
-
 
218
//   This below hack for the prototype means i didn't have to change the ls145n
-
 
219
//	 connections, but have been changed on the release version
-
 
220
#ifdef PROTOTYPE
-
 
221
	hc595_write((value << 4) | (9-(digit & 0x0f))); //Write the value and digit
-
 
222
#else
213
	hc595_write((value << 4) | (digit & 0x0f)); //Write the value and digit
223
	hc595_write((value << 4) | (digit & 0x0f)); //Write the value and digit
-
 
224
#endif
214
	if (dp) sbi(DP_PORT, DP_PIN);		// Add DP if required
225
	if (rbi(disPt, digit)) sbi(DP_PORT, DP_PIN);		// Add DP if required
215
	sbi(BL_PORT, BL_PIN);			// Enable the 4511
226
	sbi(BL_PORT, BL_PIN);			// Enable the 4511
216
}
227
}
217
 
228
 
218
void pcInterrupt() {
229
void pcInterrupt() {
219
	pcInt.mask = pcInt.current ^ pcInt.last;
230
	pcInt.mask = pcInt.current ^ pcInt.last;