26 } u32; |
26 } u32; |
27 |
27 |
28 #define FUEL_FULL 10000 |
28 #define FUEL_FULL 10000 |
29 #define FUEL_JUMPSTART 5000 |
29 #define FUEL_JUMPSTART 5000 |
30 #define FUEL_DIV_DEFAULT 25 |
30 #define FUEL_DIV_DEFAULT 25 |
|
31 #define PITLANE_SPEEDLIMIT 4 |
31 volatile uint8_t fuel_divisor = FUEL_DIV_DEFAULT; // default, can be set via serial command |
32 volatile uint8_t fuel_divisor = FUEL_DIV_DEFAULT; // default, can be set via serial command |
32 |
33 |
33 typedef struct { |
34 typedef struct { |
34 unsigned speedlimit:4; // 4bits speedlimit |
35 unsigned speedlimit:4; // 4bits speedlimit |
35 unsigned speedminimum:4; // 4bits speedminimum |
36 unsigned speedminimum:4; // 4bits speedminimum |
309 |
310 |
310 if (controller < 4) { |
311 if (controller < 4) { |
311 if (tmp < slot[controller].speedminimum) tmp = slot[controller].speedminimum; |
312 if (tmp < slot[controller].speedminimum) tmp = slot[controller].speedminimum; |
312 if ((mode == 2) && (tmp != 0)) { jumpstart(controller); tmp = 0; } |
313 if ((mode == 2) && (tmp != 0)) { jumpstart(controller); tmp = 0; } |
313 if (tmp > slot[controller].speedlimit) tmp = slot[controller].speedlimit; |
314 if (tmp > slot[controller].speedlimit) tmp = slot[controller].speedlimit; |
|
315 if (slot[controller].canrefuel && (tmp > PITLANE_SPEEDLIMIT)) tmp = PITLANE_SPEEDLIMIT; |
314 speed = tmp; |
316 speed = tmp; |
315 tmp = tmp << 1; |
317 tmp = tmp << 1; |
316 } else { |
318 } else { |
317 if ((mode == 0) && (tmp < slot[controller].speedminimum)) tmp = slot[controller].speedminimum; |
319 if ((mode == 0) && (tmp < slot[controller].speedminimum)) tmp = slot[controller].speedminimum; |
318 if (tmp > slot[controller].speedlimit) tmp = slot[controller].speedlimit; |
320 if (tmp > slot[controller].speedlimit) tmp = slot[controller].speedlimit; |
496 slot[car0-1].lap_time_start.value = clk.value; |
498 slot[car0-1].lap_time_start.value = clk.value; |
497 } |
499 } |
498 } |
500 } |
499 } car0 = 0; |
501 } car0 = 0; |
500 |
502 |
|
503 |
501 if (car1 != car1_state) { |
504 if (car1 != car1_state) { |
502 car1_state = car1; |
505 car1_state = car1; |
503 if (car1_state != 0) { |
506 if (car1_state != 0) { |
504 diff.value = clk.value - slot[car1-1].lap_time_start.value; |
507 diff.value = clk.value - slot[car1-1].lap_time_start.value; |
505 if ( diff.value > 3000 ) { // minimum 1.5 second for 1 lap! |
508 if ( diff.value > 3000 ) { // minimum 1.5 second for 1 lap! |