pitlane/main.c

changeset 72
60c4b28fd773
parent 71
2a49d2586fbf
child 73
ec888cfa024e
equal deleted inserted replaced
71:2a49d2586fbf 72:60c4b28fd773
251 //OSCCAL = 0xa0; 251 //OSCCAL = 0xa0;
252 //OSCCAL = 0x9A; 252 //OSCCAL = 0x9A;
253 //OSCCAL = 0xa0; // internal oscillator @ 4 mhz.... doesnt work accurate! 253 //OSCCAL = 0xa0; // internal oscillator @ 4 mhz.... doesnt work accurate!
254 254
255 RS232_init(); // initialize RS232 interface 255 RS232_init(); // initialize RS232 interface
256 RS232_puts_p(PSTR("Freeslot TrackSwitch / Pitlane v1.3\n")); 256 RS232_puts_p(PSTR("Freeslot TrackSwitch / Pitlane v1.4\n"));
257 sei(); 257 sei();
258 258
259 259
260 DDR(SOLENOID_A_PORT) |= _BV(SOLENOID_A_PIN); 260 DDR(SOLENOID_A_PORT) |= _BV(SOLENOID_A_PIN);
261 DDR(SOLENOID_B_PORT) |= _BV(SOLENOID_B_PIN); 261 DDR(SOLENOID_B_PORT) |= _BV(SOLENOID_B_PIN);
285 4 = ZZ -> pitlane exit 285 4 = ZZ -> pitlane exit
286 5 = BC 286 5 = BC
287 */ 287 */
288 if (sens[0].car != sens[0].state) { 288 if (sens[0].car != sens[0].state) {
289 sens[0].state = sens[0].car; 289 sens[0].state = sens[0].car;
290 #if TRACKSWITCH_TYPE != TYPE_PITLANE 290 #if (TRACKSWITCH_TYPE != TYPE_PITLANE)
291 if ( (sens[0].state != 0) && (slot[sens[0].state-1].trackswitch == 0) && (slot[sens[0].state-1].speed>0) ) { 291 if ( (sens[0].state != 0) && (slot[sens[0].state-1].trackswitch == 0) && (slot[sens[0].state-1].speed>0) ) {
292 response = (1 | ((sens[0].state-1)<<1) | (1 << 4)); 292 response = (1 | ((sens[0].state-1)<<1) | (1 << 4));
293 293
294 // set inside status 294 // set inside status
295 slot[sens[0].state].inside = 1; 295 slot[sens[0].state].inside = 1;
302 302
303 SOLENOID_A_PORT |= _BV(SOLENOID_A_PIN); 303 SOLENOID_A_PORT |= _BV(SOLENOID_A_PIN);
304 solenoid_delay(); 304 solenoid_delay();
305 SOLENOID_A_PORT &= ~_BV(SOLENOID_A_PIN); 305 SOLENOID_A_PORT &= ~_BV(SOLENOID_A_PIN);
306 solenoid_delay(); 306 solenoid_delay();
307 } 307 } else
308 #endif 308 #endif
309 if (sens[0].state != 0) { 309 if (sens[0].state != 0) {
310 response = (1 | ((sens[0].state-1)<<1)); 310 response = (1 | ((sens[0].state-1)<<1));
311 RS232_putc('A'); 311 RS232_putc('A');
312 RS232_putc('A'); 312 RS232_putc('A');
332 332
333 SOLENOID_B_PORT |= _BV(SOLENOID_B_PIN); 333 SOLENOID_B_PORT |= _BV(SOLENOID_B_PIN);
334 solenoid_delay(); 334 solenoid_delay();
335 SOLENOID_B_PORT &= ~_BV(SOLENOID_B_PIN); 335 SOLENOID_B_PORT &= ~_BV(SOLENOID_B_PIN);
336 solenoid_delay(); 336 solenoid_delay();
337 } 337 } else
338 if (sens[1].state != 0) { 338 if (sens[1].state != 0) {
339 response = (1 | ((sens[1].state)<<1) | (2 << 4)); 339 response = (1 | ((sens[1].state)<<1) | (2 << 4));
340 RS232_putc('B'); 340 RS232_putc('B');
341 RS232_putc('B'); 341 RS232_putc('B');
342 RS232_putc('0'+sens[1].state); 342 RS232_putc('0'+sens[1].state);

mercurial