diff -r 72f5eb420096 -r 52fd4283cd2c blackbox/main.c --- a/blackbox/main.c Sun Oct 28 11:23:18 2012 +0100 +++ b/blackbox/main.c Sun Oct 28 16:18:53 2012 +0100 @@ -13,15 +13,15 @@ #include "main.h" #include "lowlevel.h" -char ok[] PROGMEM="OK\n"; -char busy[] PROGMEM="BUSY\n"; -char prepare[] PROGMEM="!RACE PREPARE\n"; -char countdownstart[] PROGMEM="!COUNTDOWN\n"; -char racestart[] PROGMEM="!RACE START\n"; +const char ok[] PROGMEM="OK\n"; +const char busy[] PROGMEM="BUSY\n"; +const char prepare[] PROGMEM="!RACE PREPARE\n"; +const char countdownstart[] PROGMEM="!COUNTDOWN\n"; +const char racestart[] PROGMEM="!RACE START\n"; -char SHORTCUT[] PROGMEM="!SHORTCUT\n"; -char PANIC[] PROGMEM="!PANIC\n"; -char RESUME[] PROGMEM="!RESUME\n"; +const char SHORTCUT[] PROGMEM="!SHORTCUT\n"; +const char PANIC[] PROGMEM="!PANIC\n"; +const char RESUME[] PROGMEM="!RESUME\n"; typedef union { uint32_t value; @@ -40,9 +40,11 @@ unsigned speedminimum:4; // 4bits speedminimum unsigned seccnt:4; // 4 bits tenth seconds counter unsigned accel:4; // 4 bits last configured acceleration + unsigned speed:4; // 4 bits last speed unsigned trackswitch:1; // 1bit bool unsigned canrefuel:1; // 1bit bool unsigned unlimitedfuel:1; // 1bit bool + unsigned trackchange:1; // 1bit bool uint16_t jumpstart_time, laps, fuel; u32 lap_time_start, lap_time; } cardata; @@ -371,6 +373,8 @@ } } speed = tmp; + slot[controller].speed = tmp; + slot[controller].trackchange = (trackchange != 0); tmp = tmp << 1; if (trackchange != 0) tmp |= (1<<5); @@ -577,22 +581,35 @@ void slot_liveinfo(uint8_t idx) { if (liveinfo == 0) return; - // increment packet counter, if == 10 output some live info - if (slot[idx].seccnt == 10) { - // output current fuel status - RS232_putc('F'); - RS232_putc(':'); - RS232_putc(idx + '0'); - RS232_putc(':'); - itoa(slot[idx].fuel, s, 16); - RS232_puts(s); - RS232_putc(':'); - ultoa(sysclk.value, s, 16); - RS232_puts(s); - RS232_putc('\n'); - slot[idx].seccnt = 0; - } else slot[idx].seccnt++; + if (liveinfo == 1) { + // increment packet counter, if == 10 output some live info + if (slot[idx].seccnt == 10) { + // output current fuel status + RS232_putc('F'); + RS232_putc(':'); + RS232_putc(idx + '0'); + RS232_putc(':'); + itoa(slot[idx].fuel, s, 16); + RS232_puts(s); + RS232_putc(':'); + ultoa(sysclk.value, s, 16); + RS232_puts(s); + RS232_putc('\n'); + slot[idx].seccnt = 0; + } else slot[idx].seccnt++; + } else if ( (liveinfo - 2) == idx ) { + // output controller status LIVEINFO-2 for remote learning + RS232_putc('L'); + RS232_putc('N'); + RS232_putc(':'); + itoa(slot[idx].speed, s, 16); + RS232_puts(s); + RS232_putc(':'); + if (slot[idx].trackchange) + RS232_putc('X'); + RS232_putc('\n'); + } }