diff -r 173d0863a804 -r 0b38de31ad5d blackbox/main.c --- a/blackbox/main.c Sat Dec 10 16:37:55 2011 +0100 +++ b/blackbox/main.c Sat Dec 10 17:12:47 2011 +0100 @@ -26,8 +26,9 @@ } u32; #define FUEL_FULL 10000 -#define FUEL_DIVISOR 25 -//#define FUEL_DIVISOR 10 +#define FUEL_DIV_DEFAULT 25 +volatile uint8_t fuel_divisor = FUEL_DIV_DEFAULT; // default, can be set via serial command + typedef struct { unsigned speedlimit:4; // 4bits speedlimit unsigned speedminimum:4; // 4bits speedminimum @@ -204,6 +205,20 @@ case 'F': // set fuel enabled fuel_enabled = buffer[1]-'0'; + if (buffer[2] == ':') { + // convert fuel divisor + buffer[0] = '0'; // atoi expects zeros! + buffer[1] = '0'; + buffer[2] = '0'; + RS232_puts("DivisorChange: "); + itoa(fuel_divisor, s, 10); + RS232_puts(s); + RS232_putc('>'); + fuel_divisor = atoi(buffer); + itoa(fuel_divisor, s, 10); + RS232_puts(s); + RS232_putc(' '); + } RS232_puts_p(ok); break; @@ -334,7 +349,7 @@ if (fuel_enabled) { if (speed != 0) { // do the fuel calculation, regardless if fuel logic active or not - tmp = (uint8_t)(((slot[controller].accel * speed) + 1) / FUEL_DIVISOR); + tmp = (uint8_t)(((slot[controller].accel * speed) + 1) / fuel_divisor); if (tmp == 0) tmp = 1; if (slot[controller].fuel > 0) { // enough fuel left to decrement? @@ -349,6 +364,7 @@ } return 1; } + return 1; } else return 0; }