![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
dashboardv4solarboat
Fork of mbed_blinky by
Revision 17:f8d3d1f0d8d1, committed 2017-05-21
- Comitter:
- Marrkk_92
- Date:
- Sun May 21 19:33:42 2017 +0000
- Parent:
- 16:21658c9e697c
- Commit message:
- dash v6
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
oled_driver.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue May 02 17:25:18 2017 +0000 +++ b/main.cpp Sun May 21 19:33:42 2017 +0000 @@ -1,7 +1,7 @@ -#include "mbed.h" -#include "oled_driver.h" +#include "mbed.h" +#include "oled_driver.h" -#define MENU_TIMEOUT_TIME 50.0 //menu timeout in seconds [s] +#define MENU_TIMEOUT_TIME 5.0 //menu timeout in seconds [s] #define MAX_POWER_IN 1500 //max power in for power bars [W] #define MAX_POWER_OUT 2000 //max power out for power bars [W] #define MAX_TEMP_MOTOR 80 //alert when exceeding temp ['C] @@ -11,11 +11,10 @@ #define MIN_FLY_VELOCITY 15 //min velocity to request fly [km/h] #define BATTERY_LOW_ALERT 10 //min battery percentage [%, min] -//digital and analog inputs -DigitalIn reverse_button(D14); -DigitalIn menu_button(D15); -DigitalIn fly_button(D12); -AnalogIn analog_throttle(A5); +DigitalIn menu_button(D0); +DigitalIn fly_button(D0); +DigitalIn reverse_button(D0); +AnalogIn analog_throttle(A0); //global variables int battery_percentage_left = 0; @@ -53,10 +52,11 @@ clearDisplay(2); clearDisplay(3); - welcomeScreen(); + //welcomeScreen(); while(1) { + //listen to menu button current_menu = checkIfButtonPressed(current_menu); //listen to steering wheel at all time @@ -64,6 +64,7 @@ //check for errors at all time checkForErrors(current_menu, velocity, battery_temperature, motor_temperature, MAX_TEMP_MOTOR, MAX_TEMP_BATTERY, battery_percentage_left, battery_minutes_left, BATTERY_LOW_ALERT); + switch (current_menu) { case 0: @@ -73,21 +74,21 @@ showRaceMinutesDone(race_minutes_done); showRaceMinutesLeft(race_minutes_left); showRacePercentageLeft(race_percentage_left); - + //main display (2) displayTime(); checkTransmitter(transmitting); displayVelocity(velocity); displayThrottle(throttle_power, reverse); - displayAdvisedThrottle(advised_throttle_power); + //displayAdvisedThrottle(advised_throttle_power); updatePowerBars(power_out, power_in, MAX_POWER_OUT, MAX_POWER_IN); - + //circular display (3) //updateProgressCircle(3, battery_percentage_left); showBatteryMinutesLeft(battery_minutes_left); showBatteryPercentageLeft(battery_percentage_left); - break; - + break; + case 1: //circular display (1) //updateProgressCircle(1, race_percentage_left); @@ -95,13 +96,16 @@ showRaceMinutesDone(race_minutes_done); showRaceMinutesLeft(race_minutes_left); showRacePercentageLeft(race_percentage_left); - + + //main display (2) + displayData1(rpm_motor, battery_temperature, motor_temperature, voltage_in, power_out, power_in); + //circular display (3) //updateProgressCircle(3, battery_percentage_left); showBatteryMinutesLeft(battery_minutes_left); showBatteryPercentageLeft(battery_percentage_left); - break; - + break; + case 2: //circular display (1) //updateProgressCircle(1, race_percentage_left); @@ -109,35 +113,18 @@ showRaceMinutesDone(race_minutes_done); showRaceMinutesLeft(race_minutes_left); showRacePercentageLeft(race_percentage_left); - + //main display (2) - displayData1(rpm_motor, battery_temperature, motor_temperature, voltage_in, power_out, power_in); - + displayData2(battery_voltage, battery_temperature, motor_temperature, voltage_in, power_out, power_in); + //circular display (3) //updateProgressCircle(3, battery_percentage_left); showBatteryMinutesLeft(battery_minutes_left); showBatteryPercentageLeft(battery_percentage_left); - break; - - case 3: - //circular display (1) - //updateProgressCircle(1, race_percentage_left); - race_minutes_done = time(0)/60; //TODO give starting point - showRaceMinutesDone(race_minutes_done); - showRaceMinutesLeft(race_minutes_left); - showRacePercentageLeft(race_percentage_left); - - //main display (2) - displayData2(battery_voltage, battery_temperature, motor_temperature, voltage_in, power_out, power_in); - - //circular display (3) - //updateProgressCircle(3, battery_percentage_left); - showBatteryMinutesLeft(battery_minutes_left); - showBatteryPercentageLeft(battery_percentage_left); - break; + break; default: //empty, catch - break; + break; } } } @@ -149,7 +136,7 @@ menu_button_pressed = true; start = time(0); current_menu++; - if (current_menu > 3) current_menu = 0; + if (current_menu > 2) current_menu = 0; clearDisplay(1); clearDisplay(2); clearDisplay(3); @@ -181,22 +168,19 @@ void readEssentials() { + //get current throttle set + adjust params -------- DEBUG - throttle_power = 1000*analog_throttle; - - - power_out = 1.5*throttle_power; - power_in = 1.9*throttle_power; - velocity = 0.2*throttle_power; - battery_minutes_left = 0.1*throttle_power; - battery_percentage_left = 0.15*throttle_power; - motor_temperature = 0.5*throttle_power; - battery_temperature = 0.2*throttle_power; - battery_voltage = 300.1*throttle_power; - rpm_motor = throttle_power; - voltage_in = 200.1*throttle_power; - race_minutes_left = 0.13*throttle_power; + //throttle_power = 500 - (500*analog_throttle); + power_out = 580; + power_in = 680; + velocity = 0.1*throttle_power; + battery_minutes_left = throttle_power/6; + battery_percentage_left = throttle_power/5; + motor_temperature = 68; + battery_temperature = 24; + battery_voltage = 45; + rpm_motor = 6*throttle_power; + voltage_in = 44; + race_minutes_left = 12; race_percentage_left = 100*race_minutes_done/(race_minutes_left+race_minutes_done); - if (throttle_power > 3) transmitting = true; - else transmitting = false; }
--- a/oled_driver.h Tue May 02 17:25:18 2017 +0000 +++ b/oled_driver.h Sun May 21 19:33:42 2017 +0000 @@ -1,19 +1,21 @@ #include "oled_characters.h" //all OLED chars + logos #define PI 3.141592 -#define SPI_FREQUENCY 9000000 +#define SPI_FREQUENCY 5000000 //digital outputs and SPI -SPI spi(D11, NC, D13); //mosi, miso, sclk -DigitalOut RST(D3); //reset 0: reset 1: normal operation -DigitalOut DC(D2); //set input as data or command 0: command 1: data -DigitalOut CS_1(D8); //chipSelect 1 0: selected 1: not selected -DigitalOut CS_2(D9); //chipSelect 2 0: selected 1: not selected -DigitalOut CS_3(D10); //chipSelect 3 0: selected 1: not selected -DigitalOut motor_temp_alert_led(D5); // -DigitalOut battery_temp_alert_led(D4); // -DigitalOut battery_low_alert_led(D6); // -DigitalOut fly_ready_led(D7); // +SPI spi(PB_15, NC, PB_13); // mosi, miso, sclk +DigitalOut RST(PB_12); //reset 0: reset 1: normal operation +DigitalOut DC(PA_10); //set input as data or command 0: command 1: data + +DigitalOut battery_temp_alert_led(PC_1); +DigitalOut motor_temp_alert_led(PA_8); +DigitalOut battery_low_alert_led(PB_10); +DigitalOut fly_ready_led(PB_0); + +DigitalOut CS_1(PB_3); //chipSelect 0: selected 1: not selected +DigitalOut CS_2(PB_5); //chipSelect 0: selected 1: not selected +DigitalOut CS_3(PB_4); //chipSelect 0: selected 1: not selected bool error_alert; //internal error booleaan @@ -287,7 +289,7 @@ if (battery_temp_alert) amount_of_errors++; if (battery_low_alert) amount_of_errors++; } - + /* //if in error screen display ALL errors if (current_menu == 1) { writeLetter(2, 'E', 66, 59); @@ -314,10 +316,10 @@ amount_of_errors++; } //if (error_alert) { -// writeLetter(2, 'E', 57 - (10*amount_of_errors), 59); -// writeNumber(2, 4, 57 - (10*amount_of_errors), 55, 1, false); -// amount_of_errors++; -// } + // writeLetter(2, 'E', 57 - (10*amount_of_errors), 59); + // writeNumber(2, 4, 57 - (10*amount_of_errors), 55, 1, false); + // amount_of_errors++; + // } for (int j = amount_of_errors; j <= 25; j++) { if (j < 6) { @@ -325,9 +327,9 @@ writeLetter(2, ' ', 57 - (10*j), 55); } //else if (j > 5 && j < 11) writeLetter(2, ' ', 64 - (10*(j-5)), 47); -// else if (j > 10 && j < 16) writeLetter(2, ' ', 64 - (10*(j-10)), 35); -// else if (j > 15 && j < 21) writeLetter(2, ' ', 64 - (10*(j-15)), 23); -// else if (j > 20 && j < 26) writeLetter(2, ' ', 64 - (10*(j-20)), 11); + // else if (j > 10 && j < 16) writeLetter(2, ' ', 64 - (10*(j-10)), 35); + // else if (j > 15 && j < 21) writeLetter(2, ' ', 64 - (10*(j-15)), 23); + // else if (j > 20 && j < 26) writeLetter(2, ' ', 64 - (10*(j-20)), 11); } if (amount_of_errors < 1) { @@ -347,7 +349,7 @@ } else if (current_menu == 0 && !error_alert) { //clear if no errors drawBitmap(2, 92, 64, 48, 7, 10); - } + } */ } void showBatteryMinutesLeft(int battery_minutes_left) @@ -454,18 +456,18 @@ void displayAdvisedThrottle(int advised_throttle_power) { - writeNumber(2, advised_throttle_power, 41, 31, 4, false); - writeLetter(2, 'r', 41, 21); - writeLetter(2, 'p', 41, 17); - writeLetter(2, 'm', 41, 13); +// writeNumber(2, advised_throttle_power, 41, 31, 4, false); +// writeLetter(2, 'r', 41, 21); +// writeLetter(2, 'p', 41, 17); +// writeLetter(2, 'm', 41, 13); } void displayThrottle(int throttle_power, bool reverse) { - writeNumber(2, throttle_power, 50, 31, 4, false); - writeLetter(2, 'r', 50, 21); - writeLetter(2, 'p', 50, 17); - writeLetter(2, 'm', 50, 13); + writeNumber(2, throttle_power, 45, 31, 4, false); + writeLetter(2, 'r', 45, 21); + writeLetter(2, 'p', 45, 17); + writeLetter(2, 'm', 45, 13); if (reverse) { writeLetter(2, 'R', 15, 31); @@ -519,11 +521,11 @@ { if (velocity < 1) velocity = 0; - writeNumber(2, velocity, 32, 31, 3, false); - writeLetter(2, 'k', 32, 21); - writeLetter(2, 'm', 32, 17); - writeLetter(2, '/', 32, 13); - writeLetter(2, 'h', 32, 9); + writeNumber(2, velocity, 35, 31, 3, false); + writeLetter(2, 'k', 35, 21); + writeLetter(2, 'm', 35, 17); + writeLetter(2, '/', 35, 13); + writeLetter(2, 'h', 35, 9); } void writeLetter(int screen_number, char input, int row, int col)