v1.0
This commit is contained in:
parent
cba6eadc13
commit
7db4d2cc6c
@ -37,7 +37,7 @@ void draw_battery(int16_t voltage, int32_t percent, int32_t trip_dist, uint32_t
|
||||
|
||||
// Displays the power bars at the top
|
||||
// Duty from COMM_GET_VALUES, scale 1000
|
||||
void draw_power_bars(int16_t duty);
|
||||
void draw_power_bars(int16_t duty, uint8_t regen);
|
||||
|
||||
// Displays the huge speed counter with avg and max values.
|
||||
// Speed from COMM_GET_VALUES_SETUP, scale 1000
|
||||
|
||||
@ -32,8 +32,8 @@ void run_dashboard_loop_test() {
|
||||
|
||||
draw_battery(654, i * 10 / 4, 13210000, 343000);
|
||||
draw_speed((((i/2) % 34)) * 1000, 0);
|
||||
int16_t duty = 1000 - (int16_t) i * 1000 / 200;
|
||||
draw_power_bars(duty);
|
||||
int16_t duty = (int16_t) (((int32_t) i) % 1000);
|
||||
draw_power_bars(duty, i % 10 >= 5);
|
||||
draw_power(100 * i / 20 * (duty < 0 ? -1 : 1), duty, 60 * 10);
|
||||
|
||||
draw_adc(i % 34, (400 - i + 16) % 34, i % 34 >= 2.5,
|
||||
@ -135,7 +135,7 @@ void update_values(uint8_t refresh_slow, uint8_t refresh_mid) {
|
||||
//float wheel_diameter = 0.246; // in meter
|
||||
//speed = ((float) rpm) * 3.14159265359 * wheel_diameter * 60 / 1000;
|
||||
|
||||
draw_power_bars(duty_cycle);
|
||||
draw_power_bars(duty_cycle, current_in_tot < 0);
|
||||
if (refresh_mid) {
|
||||
draw_speed((int32_t) (((float) speed) * 3.6), fault_code);
|
||||
draw_power(current_in_tot, duty_cycle, input_voltage_filtered);
|
||||
@ -371,11 +371,10 @@ void draw_battery(
|
||||
// Duty from COMM_GET_VALUES, scale 1000
|
||||
uint16_t last_width = 0;
|
||||
uint8_t last_regen = 0;
|
||||
void draw_power_bars(int16_t dutyy) {
|
||||
void draw_power_bars(int16_t dutyy, uint8_t regen) {
|
||||
uint16_t offset = LCD_WIDTH / 2;
|
||||
uint16_t max_width = LCD_WIDTH / 2;
|
||||
uint8_t regen = dutyy < 0;
|
||||
uint16_t duty = regen ? -dutyy : dutyy;
|
||||
uint16_t duty = dutyy < 0 ? -dutyy : dutyy;
|
||||
duty *= 1 / 0.8;// 80% duty means the bar is at 100%
|
||||
uint16_t width = ((float) duty / 1000.0) * max_width;
|
||||
|
||||
@ -506,9 +505,9 @@ int32_t last_power = 1000;
|
||||
// Duty from COMM_GET_VALUES, scale 1000
|
||||
// Input voltage from COMM_GET_VALUES, scale 10
|
||||
void draw_power(int32_t current_i, int16_t duty_i, int16_t voltage_i) {
|
||||
if (duty_i < 0 && current_i > 0) {
|
||||
current_i = -current_i;
|
||||
}
|
||||
// if (duty_i < 0 && current_i > 0) {
|
||||
// current_i = -current_i;
|
||||
// }
|
||||
int16_t current = current_i / 100;
|
||||
uint16_t duty = duty_i < 0 ? -duty_i / 10 : duty_i / 10;
|
||||
int32_t power = ((int32_t) voltage_i) * ((int32_t) current_i) / 10000 * 10;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user