30 } u32; |
30 } u32; |
31 |
31 |
32 #define FUEL_FULL 10000 |
32 #define FUEL_FULL 10000 |
33 #define FUEL_JUMPSTART 5000 |
33 #define FUEL_JUMPSTART 5000 |
34 #define FUEL_DIV_DEFAULT 25 |
34 #define FUEL_DIV_DEFAULT 25 |
35 #define PITLANE_SPEEDLIMIT 15 |
35 #define PITLANE_SPEEDLIMIT 10 |
36 volatile uint8_t fuel_divisor = FUEL_DIV_DEFAULT; // default, can be set via serial command |
36 volatile uint8_t fuel_divisor = FUEL_DIV_DEFAULT; // default, can be set via serial command |
37 |
37 |
38 typedef struct { |
38 typedef struct { |
39 unsigned speedlimit:4; // 4bits speedlimit |
39 unsigned speedlimit:4; // 4bits speedlimit |
40 unsigned speedminimum:4; // 4bits speedminimum |
40 unsigned speedminimum:4; // 4bits speedminimum |
61 // 255 PANIC MODE -> TURN OFF TRACK POWER |
61 // 255 PANIC MODE -> TURN OFF TRACK POWER |
62 |
62 |
63 extern uint8_t btn_start = _BV(SW_START); |
63 extern uint8_t btn_start = _BV(SW_START); |
64 extern uint8_t old_start = _BV(SW_START); |
64 extern uint8_t old_start = _BV(SW_START); |
65 |
65 |
66 |
66 // todo: pack as bit structure: |
67 uint8_t liveinfo = 0; |
67 uint8_t liveinfo = 0; |
68 uint8_t fuel_enabled = 1; |
68 uint8_t fuel_enabled = 1; |
|
69 uint8_t pitlane_finishline = 0; |
69 |
70 |
70 volatile u32 sysclk; |
71 volatile u32 sysclk; |
71 volatile uint8_t sysclk_packettimer = 0; |
72 volatile uint8_t sysclk_packettimer = 0; |
72 volatile cardata slot[MAX_SLOTS]; |
73 volatile cardata slot[MAX_SLOTS]; |
73 |
74 |
149 uint8_t sender = (data & 0b1111); |
150 uint8_t sender = (data & 0b1111); |
150 data >>= 4; |
151 data >>= 4; |
151 uint8_t type = (data & 0b111); |
152 uint8_t type = (data & 0b111); |
152 if (type == 4) { |
153 if (type == 4) { |
153 // pitlane response |
154 // pitlane response |
154 if (status == 5) slot[car].canrefuel = 1; |
155 if (status == 5) { |
|
156 slot[car].canrefuel = 1; |
|
157 if (pitlane_finishline) slot[car].laps++; |
|
158 } |
155 if (status == 6) for (data=0; data<MAX_SLOTS; data++) slot[data].canrefuel = 0; |
159 if (status == 6) for (data=0; data<MAX_SLOTS; data++) slot[data].canrefuel = 0; |
156 if (status == 7) slot[car].canrefuel = 0; |
160 if (status == 7) slot[car].canrefuel = 0; |
157 } |
161 } |
158 RS232_puts("RW:"); |
162 RS232_puts("RW:"); |
159 RS232_putc(car + '0'); |
163 RS232_putc(car + '0'); |