# HG changeset patch # User Malte Bayer # Date 1355611570 -3600 # Node ID 0d6fbfaae49b0cd56f36f3b20516b9df9fad0cef # Parent edaf6a50276aaa925d424130f1b96d4d9e16d65a mem save ;-P diff -r edaf6a50276a -r 0d6fbfaae49b blackbox/main.c --- a/blackbox/main.c Sat Dec 15 23:21:19 2012 +0100 +++ b/blackbox/main.c Sat Dec 15 23:46:10 2012 +0100 @@ -47,7 +47,8 @@ unsigned canrefuel:1; // 1bit bool unsigned unlimitedfuel:1; // 1bit bool unsigned trackchange:1; // 1bit bool - uint16_t jumpstart_time, laps, fuel; + uint16_t jumpstart_time, fuel; + uint8_t laps; u32 lap_time_start, lap_time; } cardata; @@ -65,9 +66,13 @@ extern uint8_t old_start = _BV(SW_START); // todo: pack as bit structure: -uint8_t liveinfo = 0; -uint8_t fuel_enabled = 1; -uint8_t pitlane_finishline = 0; + +typedef struct { + unsigned fuel_enabled:1; + unsigned pitlane_finishline:1; + unsigned liveinfo:6; +} switches_s; +switches_s switches; volatile u32 sysclk; volatile uint8_t sysclk_packettimer = 0; @@ -155,7 +160,7 @@ // pitlane response if (status == 5) { slot[car].canrefuel = 1; - if (pitlane_finishline) slot[car].laps++; + if (switches.pitlane_finishline) slot[car].laps++; } if (status == 6) for (data=0; data 0)) { // do the fuel calculation, regardless if fuel logic active or not tmp = (uint8_t)(((slot[controller].accel * speed) + 1) / fuel_divisor); @@ -598,9 +603,9 @@ } void slot_liveinfo(uint8_t idx) { - if (liveinfo == 0) return; + if (switches.liveinfo == 0) return; - if (liveinfo == 1) { + if (switches.liveinfo == 1) { // increment packet counter, if == 10 output some live info if (slot[idx].seccnt == 10) { // output current fuel status @@ -616,7 +621,7 @@ RS232_putc('\n'); slot[idx].seccnt = 0; } else slot[idx].seccnt++; - } else if ( (liveinfo - 2) == idx ) { + } else if ( (switches.liveinfo - 2) == idx ) { // output controller status LIVEINFO-2 for remote learning RS232_putc('L'); RS232_putc('N'); @@ -635,6 +640,10 @@ { uint8_t packet_index = 1; + switches.fuel_enabled = 1; + switches.pitlane_finishline = 0; + switches.liveinfo = 0; + init_hardware(); reset_vars(); LED(3, 1); // enable middle led == idle mode