new battery bar

Dependencies:   CAN_IDs CanControl Dashboard PinDetect PowerControl mbed-rtos mbed

Committer:
zathorix
Date:
Mon May 22 18:39:20 2017 +0000
Revision:
18:aa6feb4b73e7
Parent:
17:91ba27c14991
Child:
22:8fdbdfbdf74a
Screens not working yet

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kwasymodo 1:c5d8ea5d049b 1 /*******************************************************************************
kwasymodo 4:dfd10f43cc8b 2 This software is especially designed for Solarboat Twente for the use in their Solarboat v1.0
kwasymodo 1:c5d8ea5d049b 3
kwasymodo 1:c5d8ea5d049b 4 Written by:
kwasymodo 1:c5d8ea5d049b 5 Niels Leijen, Jesse van Rhijn, Bram Seinhorst
kwasymodo 1:c5d8ea5d049b 6
kwasymodo 1:c5d8ea5d049b 7 Thanks to:
kwasymodo 1:c5d8ea5d049b 8 Jasper Admiraal, Hidde Pik (hihihihi), Lisa Postma, Heleen Jeurink, Ruben Peters,
kwasymodo 1:c5d8ea5d049b 9 Martijn Groot Jebbink, Martijn Wilpshaar, Bram Seinhorst, Robert Geels, Arnoud Meutstege,
kwasymodo 4:dfd10f43cc8b 10 Jeroen te Braake, Ids de Vos, Jesse van Rhijn, Sam Benou, Niels Leijen and Mark Bruijn
kwasymodo 1:c5d8ea5d049b 11
kwasymodo 1:c5d8ea5d049b 12 DISCLAIMER:
kwasymodo 1:c5d8ea5d049b 13 THIS SOFTWARE IS SUPPLIED "AS IS" WITHOUT ANY WARRANTIES AND SUPPORT.
kwasymodo 1:c5d8ea5d049b 14 SOLARBOATTWENTE ASSUMES NO RESPONSIBILITY OR LIABILITY FOR THE USE OF THE SOFTWARE.
kwasymodo 1:c5d8ea5d049b 15 *******************************************************************************/
kwasymodo 1:c5d8ea5d049b 16
kwasymodo 1:c5d8ea5d049b 17 // uncomment to send debug information
kwasymodo 1:c5d8ea5d049b 18 #define DEBUG
kwasymodo 1:c5d8ea5d049b 19
kwasymodo 1:c5d8ea5d049b 20 //include 3rd party libraries
kwasymodo 4:dfd10f43cc8b 21 #include "mbed.h" //needs to be revision 136 else SD filesystem will not work
kwasymodo 1:c5d8ea5d049b 22 #include "rtos.h"
kwasymodo 1:c5d8ea5d049b 23
kwasymodo 1:c5d8ea5d049b 24 // include Solarboat libraries
kwasymodo 1:c5d8ea5d049b 25 #include "pinout.h"
zathorix 14:0ad1bc8be76b 26 #include "CAN_IDs.h"
kwasymodo 1:c5d8ea5d049b 27 #include "PowerControl.h"
zathorix 16:c5427db9edf0 28 #include "TelemetryAndDaq.h"
zathorix 16:c5427db9edf0 29 #include "Dashboard.h"
kwasymodo 1:c5d8ea5d049b 30
zathorix 15:56b25cffa523 31 #define SPEED_THRESH 0.02 //threshold for setting speed to prevent CAN spam
zathorix 14:0ad1bc8be76b 32
kwasymodo 1:c5d8ea5d049b 33 // initialize serial connection for debug
kwasymodo 1:c5d8ea5d049b 34 #ifdef DEBUG
kwasymodo 3:b164662f9740 35 RawSerial pc(SERIAL_TX, SERIAL_RX);
kwasymodo 1:c5d8ea5d049b 36 #endif
kwasymodo 1:c5d8ea5d049b 37
kwasymodo 1:c5d8ea5d049b 38 // initialize canbus
kwasymodo 1:c5d8ea5d049b 39 CAN can(CAN_RD, CAN_TD);
kwasymodo 1:c5d8ea5d049b 40
zathorix 14:0ad1bc8be76b 41 //init throttle
zathorix 14:0ad1bc8be76b 42 AnalogIn analogThrottle(STEER_THROTTLE);
zathorix 14:0ad1bc8be76b 43
zathorix 18:aa6feb4b73e7 44 //initialize steering wheel buttons
zathorix 18:aa6feb4b73e7 45
zathorix 18:aa6feb4b73e7 46 //NEEDS FIXING!!!!!!!!!!!
zathorix 18:aa6feb4b73e7 47 DigitalIn menu_button(STEER_MENU);
zathorix 18:aa6feb4b73e7 48 DigitalIn fly_button(STEER_FLY);
zathorix 18:aa6feb4b73e7 49 DigitalIn reverse_button(STEER_REV);
zathorix 18:aa6feb4b73e7 50
kwasymodo 1:c5d8ea5d049b 51 // initialze onboard leds
kwasymodo 1:c5d8ea5d049b 52 DigitalOut ledError(LED3);
kwasymodo 1:c5d8ea5d049b 53 DigitalOut ledSD(LED1);
kwasymodo 1:c5d8ea5d049b 54 DigitalOut ledFona(LED5);
kwasymodo 1:c5d8ea5d049b 55 DigitalOut led24V(LED4);
kwasymodo 1:c5d8ea5d049b 56
kwasymodo 11:005a50dd7db5 57 DigitalOut buckXSens(BUCK3);
kwasymodo 11:005a50dd7db5 58 DigitalOut buckScreen(BUCK4);
kwasymodo 11:005a50dd7db5 59 DigitalOut buck24V(BUCK5);
kwasymodo 1:c5d8ea5d049b 60
zathorix 16:c5427db9edf0 61 //external classes
zathorix 16:c5427db9edf0 62 extern DataAcquisition daq;
zathorix 17:91ba27c14991 63 extern Telemetrics telemetrics;
zathorix 18:aa6feb4b73e7 64 extern Dashboard dash;
kwasymodo 1:c5d8ea5d049b 65
zathorix 16:c5427db9edf0 66 //external variables
zathorix 16:c5427db9edf0 67 extern long long int starttime;
kwasymodo 11:005a50dd7db5 68
zathorix 16:c5427db9edf0 69 //external threads
zathorix 16:c5427db9edf0 70 extern Thread threadbg;
kwasymodo 1:c5d8ea5d049b 71
zathorix 15:56b25cffa523 72 //global var for speed; ugly solution but works
zathorix 14:0ad1bc8be76b 73 float speed = 0;
zathorix 14:0ad1bc8be76b 74
zathorix 16:c5427db9edf0 75 //thread function declarations
zathorix 16:c5427db9edf0 76 void readThrottle();
zathorix 16:c5427db9edf0 77 void power();
zathorix 16:c5427db9edf0 78 void test();
zathorix 16:c5427db9edf0 79 void background();
zathorix 18:aa6feb4b73e7 80 void screens();
zathorix 18:aa6feb4b73e7 81
zathorix 18:aa6feb4b73e7 82 //screen function declarations
zathorix 18:aa6feb4b73e7 83 void readEssentials();
zathorix 18:aa6feb4b73e7 84
zathorix 18:aa6feb4b73e7 85 //Screen placeholder variables
zathorix 18:aa6feb4b73e7 86 int battery_percentage_left = 0;
zathorix 18:aa6feb4b73e7 87 int battery_minutes_left = 0;
zathorix 18:aa6feb4b73e7 88 int race_percentage_left = 0;
zathorix 18:aa6feb4b73e7 89 int race_minutes_left = 0;
zathorix 18:aa6feb4b73e7 90 int race_minutes_done = 0;
zathorix 18:aa6feb4b73e7 91 int throttle_power = 0;
zathorix 18:aa6feb4b73e7 92 int advised_throttle_power = 0;
zathorix 18:aa6feb4b73e7 93 int power_in = 0;
zathorix 18:aa6feb4b73e7 94 int power_out = 0;
zathorix 18:aa6feb4b73e7 95 int voltage_in = 0;
zathorix 18:aa6feb4b73e7 96 int motor_temperature = 0;
zathorix 18:aa6feb4b73e7 97 int battery_temperature = 0;
zathorix 18:aa6feb4b73e7 98 int velocity = 0;
zathorix 18:aa6feb4b73e7 99 int rpm_motor = 0;
zathorix 18:aa6feb4b73e7 100 int checkIfButtonPressed(int current_menu);
zathorix 18:aa6feb4b73e7 101 int battery_voltage = 0;
zathorix 18:aa6feb4b73e7 102 int current_menu = 0;
zathorix 18:aa6feb4b73e7 103 time_t start = time(0);
zathorix 18:aa6feb4b73e7 104 void readEssentials();
zathorix 18:aa6feb4b73e7 105 bool menu_button_pressed = true;
zathorix 18:aa6feb4b73e7 106 bool reverse_button_pressed = true;
zathorix 18:aa6feb4b73e7 107 bool fly_request = true;
zathorix 18:aa6feb4b73e7 108 bool transmitting = false;
zathorix 18:aa6feb4b73e7 109 bool reverse = false;
zathorix 18:aa6feb4b73e7 110
zathorix 14:0ad1bc8be76b 111
kwasymodo 1:c5d8ea5d049b 112 // Thread 0 - DO NOT CHANGE THIS!
kwasymodo 1:c5d8ea5d049b 113 int main() {
kwasymodo 1:c5d8ea5d049b 114 #ifdef DEBUG
kwasymodo 1:c5d8ea5d049b 115 pc.baud(115200);
kwasymodo 3:b164662f9740 116 pc.printf("Starting SOS V1.0\n");
kwasymodo 1:c5d8ea5d049b 117 #endif
kwasymodo 1:c5d8ea5d049b 118 // change CAN frequency
kwasymodo 1:c5d8ea5d049b 119 can.frequency(250000);
kwasymodo 1:c5d8ea5d049b 120
kwasymodo 1:c5d8ea5d049b 121 // initialze threads
zathorix 15:56b25cffa523 122 Thread threadpower;
zathorix 15:56b25cffa523 123 Thread threadtest;
zathorix 14:0ad1bc8be76b 124 Thread threadthrottle;
zathorix 18:aa6feb4b73e7 125 Thread threaddash;
kwasymodo 1:c5d8ea5d049b 126
kwasymodo 1:c5d8ea5d049b 127 // start threads
zathorix 15:56b25cffa523 128 threadpower.start(&power);
zathorix 16:c5427db9edf0 129 threadbg.start(&background);
zathorix 15:56b25cffa523 130 threadtest.start(&test);
zathorix 18:aa6feb4b73e7 131 threaddash.start(&screens);
zathorix 14:0ad1bc8be76b 132 threadthrottle.start(&readThrottle);
zathorix 17:91ba27c14991 133
zathorix 17:91ba27c14991 134 telemetrics.enable();
zathorix 16:c5427db9edf0 135 daq.enable(starttime);
zathorix 16:c5427db9edf0 136
zathorix 16:c5427db9edf0 137 //BMS message parser, now imlpemented in DAQ lib
zathorix 16:c5427db9edf0 138 /*CANMessage msg;
kwasymodo 11:005a50dd7db5 139 while(1) {
kwasymodo 11:005a50dd7db5 140 if(can.read(msg)) {
kwasymodo 11:005a50dd7db5 141 pc.printf("Message received: 0x %x; %u %u%u %d%d %c %u %u\n", msg.id, msg.data[0], msg.data[1], msg.data[2], msg.data[3], msg.data[4], msg.data[5], msg.data[6], msg.data[7]);
zathorix 16:c5427db9edf0 142 }
zathorix 16:c5427db9edf0 143 Thread::wait(10);
zathorix 16:c5427db9edf0 144 }*/
zathorix 16:c5427db9edf0 145 Thread::wait(osWaitForever);
zathorix 16:c5427db9edf0 146 }
zathorix 16:c5427db9edf0 147
zathorix 16:c5427db9edf0 148 //send motor command
zathorix 16:c5427db9edf0 149 void sendMotorSpeed(float throttle) {
zathorix 16:c5427db9edf0 150 if ((abs(throttle - speed)) > SPEED_THRESH) {
zathorix 16:c5427db9edf0 151 union {
zathorix 16:c5427db9edf0 152 char msg[4];
zathorix 16:c5427db9edf0 153 float value;
zathorix 16:c5427db9edf0 154 } packet;
zathorix 16:c5427db9edf0 155 packet.value = throttle;
zathorix 16:c5427db9edf0 156 can.write(CANMessage(MOTOR_COMMAND, packet.msg));
zathorix 16:c5427db9edf0 157 printf("Sent motor speed: %f\r\n", packet.value);
zathorix 16:c5427db9edf0 158 speed = throttle;
kwasymodo 11:005a50dd7db5 159 }
zathorix 16:c5427db9edf0 160 }
zathorix 16:c5427db9edf0 161
zathorix 16:c5427db9edf0 162 //thread functions
zathorix 16:c5427db9edf0 163 void readThrottle() {
zathorix 16:c5427db9edf0 164 float throttleread;
zathorix 16:c5427db9edf0 165 while(1) {
zathorix 16:c5427db9edf0 166 throttleread = 2*(0.5 - analogThrottle.read());
zathorix 16:c5427db9edf0 167 sendMotorSpeed(throttleread);
zathorix 16:c5427db9edf0 168 Thread::wait(10);
zathorix 16:c5427db9edf0 169 }
zathorix 16:c5427db9edf0 170 }
zathorix 16:c5427db9edf0 171
zathorix 16:c5427db9edf0 172
zathorix 16:c5427db9edf0 173
zathorix 16:c5427db9edf0 174 void power() {
zathorix 16:c5427db9edf0 175 PowerControl powercontrol(PUSH_GREEN);
zathorix 16:c5427db9edf0 176
zathorix 16:c5427db9edf0 177 #ifdef DEBUG
zathorix 16:c5427db9edf0 178 pc.printf("Thread 1 - Power started\r\n ");
zathorix 16:c5427db9edf0 179 #endif
zathorix 16:c5427db9edf0 180
kwasymodo 1:c5d8ea5d049b 181 Thread::wait(osWaitForever);
zathorix 16:c5427db9edf0 182 }
zathorix 16:c5427db9edf0 183
zathorix 16:c5427db9edf0 184 void test() {
zathorix 16:c5427db9edf0 185 ledError = 0;
zathorix 16:c5427db9edf0 186 ledSD = 0;
zathorix 16:c5427db9edf0 187 ledFona = 0 ;
zathorix 16:c5427db9edf0 188 led24V=1;
zathorix 16:c5427db9edf0 189
zathorix 16:c5427db9edf0 190 //DigitalOut buckCan(BUCK2);
zathorix 16:c5427db9edf0 191 buckXSens = 0;
zathorix 18:aa6feb4b73e7 192 buckScreen = 1;
zathorix 16:c5427db9edf0 193 buck24V = 1;
zathorix 16:c5427db9edf0 194 }
zathorix 18:aa6feb4b73e7 195
zathorix 18:aa6feb4b73e7 196 void screens()
zathorix 18:aa6feb4b73e7 197 {
zathorix 18:aa6feb4b73e7 198 dash.powerOnOLED(1);
zathorix 18:aa6feb4b73e7 199 dash.powerOnOLED(2);
zathorix 18:aa6feb4b73e7 200 dash.powerOnOLED(3);
zathorix 18:aa6feb4b73e7 201
zathorix 18:aa6feb4b73e7 202 dash.clearDisplay(1);
zathorix 18:aa6feb4b73e7 203 dash.clearDisplay(2);
zathorix 18:aa6feb4b73e7 204 dash.clearDisplay(3);
zathorix 18:aa6feb4b73e7 205
zathorix 18:aa6feb4b73e7 206 while(1) {
zathorix 18:aa6feb4b73e7 207
zathorix 18:aa6feb4b73e7 208 Thread::wait(100);
zathorix 18:aa6feb4b73e7 209
zathorix 18:aa6feb4b73e7 210 //listen to menu button
zathorix 18:aa6feb4b73e7 211 current_menu = checkIfButtonPressed(current_menu);
zathorix 18:aa6feb4b73e7 212 //listen to steering wheel at all time
zathorix 18:aa6feb4b73e7 213 readEssentials();
zathorix 18:aa6feb4b73e7 214 //check for errors at all time
zathorix 18:aa6feb4b73e7 215 dash.checkForErrors(current_menu, velocity, battery_temperature, motor_temperature, battery_percentage_left, battery_minutes_left);
zathorix 18:aa6feb4b73e7 216
zathorix 18:aa6feb4b73e7 217
zathorix 18:aa6feb4b73e7 218 switch (current_menu) {
zathorix 18:aa6feb4b73e7 219
zathorix 18:aa6feb4b73e7 220 case 0:
zathorix 18:aa6feb4b73e7 221 //circular display (1)
zathorix 18:aa6feb4b73e7 222 //updateProgressCircle(1, race_percentage_left);
zathorix 18:aa6feb4b73e7 223 race_minutes_done = time(0)/60; //TODO give starting point
zathorix 18:aa6feb4b73e7 224 dash.showRaceMinutesDone(race_minutes_done);
zathorix 18:aa6feb4b73e7 225 dash.showRaceMinutesLeft(race_minutes_left);
zathorix 18:aa6feb4b73e7 226 dash.showRacePercentageLeft(race_percentage_left);
zathorix 18:aa6feb4b73e7 227
zathorix 18:aa6feb4b73e7 228 //main display (2)
zathorix 18:aa6feb4b73e7 229 dash.displayTime();
zathorix 18:aa6feb4b73e7 230 dash.checkTransmitter(transmitting);
zathorix 18:aa6feb4b73e7 231 dash.displayVelocity(velocity);
zathorix 18:aa6feb4b73e7 232 dash.displayThrottle(throttle_power, reverse);
zathorix 18:aa6feb4b73e7 233 //displayAdvisedThrottle(advised_throttle_power);
zathorix 18:aa6feb4b73e7 234 dash.updatePowerBars(power_out, power_in);
zathorix 18:aa6feb4b73e7 235
zathorix 18:aa6feb4b73e7 236 //circular display (3)
zathorix 18:aa6feb4b73e7 237 //updateProgressCircle(3, battery_percentage_left);
zathorix 18:aa6feb4b73e7 238 dash.showBatteryMinutesLeft(battery_minutes_left);
zathorix 18:aa6feb4b73e7 239 dash.showBatteryPercentageLeft(battery_percentage_left);
zathorix 18:aa6feb4b73e7 240 break;
zathorix 18:aa6feb4b73e7 241
zathorix 18:aa6feb4b73e7 242 case 1:
zathorix 18:aa6feb4b73e7 243 //circular display (1)
zathorix 18:aa6feb4b73e7 244 //updateProgressCircle(1, race_percentage_left);
zathorix 18:aa6feb4b73e7 245 race_minutes_done = time(0)/60; //TODO give starting point
zathorix 18:aa6feb4b73e7 246 dash.showRaceMinutesDone(race_minutes_done);
zathorix 18:aa6feb4b73e7 247 dash.showRaceMinutesLeft(race_minutes_left);
zathorix 18:aa6feb4b73e7 248 dash.showRacePercentageLeft(race_percentage_left);
zathorix 18:aa6feb4b73e7 249
zathorix 18:aa6feb4b73e7 250 //main display (2)
zathorix 18:aa6feb4b73e7 251 dash.displayData1(rpm_motor, battery_temperature, motor_temperature, voltage_in, power_out, power_in);
zathorix 18:aa6feb4b73e7 252
zathorix 18:aa6feb4b73e7 253 //circular display (3)
zathorix 18:aa6feb4b73e7 254 //updateProgressCircle(3, battery_percentage_left);
zathorix 18:aa6feb4b73e7 255 dash.showBatteryMinutesLeft(battery_minutes_left);
zathorix 18:aa6feb4b73e7 256 dash.showBatteryPercentageLeft(battery_percentage_left);
zathorix 18:aa6feb4b73e7 257 break;
zathorix 18:aa6feb4b73e7 258
zathorix 18:aa6feb4b73e7 259 case 2:
zathorix 18:aa6feb4b73e7 260 //circular display (1)
zathorix 18:aa6feb4b73e7 261 //updateProgressCircle(1, race_percentage_left);
zathorix 18:aa6feb4b73e7 262 race_minutes_done = time(0)/60; //TODO give starting point
zathorix 18:aa6feb4b73e7 263 dash.showRaceMinutesDone(race_minutes_done);
zathorix 18:aa6feb4b73e7 264 dash.showRaceMinutesLeft(race_minutes_left);
zathorix 18:aa6feb4b73e7 265 dash.showRacePercentageLeft(race_percentage_left);
zathorix 18:aa6feb4b73e7 266
zathorix 18:aa6feb4b73e7 267 //main display (2)
zathorix 18:aa6feb4b73e7 268 dash.displayData2(battery_voltage, battery_temperature, motor_temperature, voltage_in, power_out, power_in);
zathorix 18:aa6feb4b73e7 269
zathorix 18:aa6feb4b73e7 270 //circular display (3)
zathorix 18:aa6feb4b73e7 271 //updateProgressCircle(3, battery_percentage_left);
zathorix 18:aa6feb4b73e7 272 dash.showBatteryMinutesLeft(battery_minutes_left);
zathorix 18:aa6feb4b73e7 273 dash.showBatteryPercentageLeft(battery_percentage_left);
zathorix 18:aa6feb4b73e7 274 break;
zathorix 18:aa6feb4b73e7 275 default:
zathorix 18:aa6feb4b73e7 276 //empty, catch
zathorix 18:aa6feb4b73e7 277 break;
zathorix 18:aa6feb4b73e7 278 }
zathorix 18:aa6feb4b73e7 279 }
zathorix 18:aa6feb4b73e7 280 }
zathorix 18:aa6feb4b73e7 281
zathorix 18:aa6feb4b73e7 282 int checkIfButtonPressed(int current_menu)
zathorix 18:aa6feb4b73e7 283 {
zathorix 18:aa6feb4b73e7 284 //--------------MENU BUTTON--------------------
zathorix 18:aa6feb4b73e7 285 if (menu_button == 0 && menu_button_pressed == false) {
zathorix 18:aa6feb4b73e7 286 menu_button_pressed = true;
zathorix 18:aa6feb4b73e7 287 start = time(0);
zathorix 18:aa6feb4b73e7 288 current_menu++;
zathorix 18:aa6feb4b73e7 289 if (current_menu > 2) current_menu = 0;
zathorix 18:aa6feb4b73e7 290 dash.clearDisplay(1);
zathorix 18:aa6feb4b73e7 291 dash.clearDisplay(2);
zathorix 18:aa6feb4b73e7 292 dash.clearDisplay(3);
zathorix 18:aa6feb4b73e7 293 } else if (menu_button == 1) menu_button_pressed = false;
zathorix 18:aa6feb4b73e7 294 //timeout for back to home screen
zathorix 18:aa6feb4b73e7 295 double seconds_since_start = difftime(time(0), start);
zathorix 18:aa6feb4b73e7 296 if (current_menu != 0 && seconds_since_start > MENU_TIMEOUT_TIME) {
zathorix 18:aa6feb4b73e7 297 current_menu = 0;
zathorix 18:aa6feb4b73e7 298 dash.clearDisplay(1);
zathorix 18:aa6feb4b73e7 299 dash.clearDisplay(2);
zathorix 18:aa6feb4b73e7 300 dash.clearDisplay(3);
zathorix 18:aa6feb4b73e7 301 }
zathorix 18:aa6feb4b73e7 302
zathorix 18:aa6feb4b73e7 303 //--------------REVERSE BUTTON--------------------
zathorix 18:aa6feb4b73e7 304 if (reverse_button == 0 && reverse_button_pressed == false) {
zathorix 18:aa6feb4b73e7 305 reverse_button_pressed = true;
zathorix 18:aa6feb4b73e7 306 if (velocity < MAX_REVERSE_VELOCITY) reverse = !reverse;
zathorix 18:aa6feb4b73e7 307 } else if (reverse_button == 1) reverse_button_pressed = false;
zathorix 18:aa6feb4b73e7 308
zathorix 18:aa6feb4b73e7 309 //--------------FLY BUTTON--------------------
zathorix 18:aa6feb4b73e7 310 if (fly_button == 0 && fly_request == false) {
zathorix 18:aa6feb4b73e7 311 fly_request = true;
zathorix 18:aa6feb4b73e7 312 if (velocity > MIN_FLY_VELOCITY) fly_request = !fly_request;
zathorix 18:aa6feb4b73e7 313 } else if (fly_button == 1) fly_request = false;
zathorix 18:aa6feb4b73e7 314
zathorix 18:aa6feb4b73e7 315 //return for menu
zathorix 18:aa6feb4b73e7 316 return current_menu;
zathorix 18:aa6feb4b73e7 317 }
zathorix 18:aa6feb4b73e7 318
zathorix 18:aa6feb4b73e7 319 void readEssentials()
zathorix 18:aa6feb4b73e7 320 {
zathorix 18:aa6feb4b73e7 321
zathorix 18:aa6feb4b73e7 322 //get current throttle set + adjust params -------- DEBUG
zathorix 18:aa6feb4b73e7 323 throttle_power = 100*(1 - analogThrottle);
zathorix 18:aa6feb4b73e7 324 power_out = 580;
zathorix 18:aa6feb4b73e7 325 power_in = 680;
zathorix 18:aa6feb4b73e7 326 velocity = 0.1*throttle_power;
zathorix 18:aa6feb4b73e7 327 battery_minutes_left = throttle_power/6;
zathorix 18:aa6feb4b73e7 328 battery_percentage_left = throttle_power/5;
zathorix 18:aa6feb4b73e7 329 motor_temperature = 68;
zathorix 18:aa6feb4b73e7 330 battery_temperature = 24;
zathorix 18:aa6feb4b73e7 331 battery_voltage = 45;
zathorix 18:aa6feb4b73e7 332 rpm_motor = throttle_power;
zathorix 18:aa6feb4b73e7 333 voltage_in = 44;
zathorix 18:aa6feb4b73e7 334 race_minutes_left = 12;
zathorix 18:aa6feb4b73e7 335 race_percentage_left = 100*race_minutes_done/(race_minutes_left+race_minutes_done);
zathorix 18:aa6feb4b73e7 336 }