fix trip update
This commit is contained in:
parent
df5133191d
commit
45b8a143f8
|
@ -1 +1 @@
|
||||||
Subproject commit c2eba898ac628c6827d17c142a54e601bda5797b
|
Subproject commit dc40db8e74366a779578c9fd3c9edbfc43e79972
|
|
@ -1,6 +1,9 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#define SERIAL_BAUD 115200 // [-] Baud rate for built-in Serial (used for the Serial Monitor)
|
#define SERIAL_BAUD 115200 // [-] Baud rate for built-in Serial (used for the Serial Monitor)
|
||||||
|
|
||||||
|
unsigned long loopmillis;
|
||||||
|
unsigned long last_loopmillis;
|
||||||
|
|
||||||
#include <OneButton.h>
|
#include <OneButton.h>
|
||||||
|
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
|
@ -22,7 +25,7 @@ uint8_t displaymode=0;
|
||||||
#define DISPLAY_STATS3 2
|
#define DISPLAY_STATS3 2
|
||||||
#define DISPLAY_MENU 3
|
#define DISPLAY_MENU 3
|
||||||
uint8_t menu_entrypos=0;
|
uint8_t menu_entrypos=0;
|
||||||
#define MENU_ENTRIES 7 // max id is MENU_ENTRIES-1
|
#define MENU_ENTRIES 8 // max id is MENU_ENTRIES-1
|
||||||
|
|
||||||
uint8_t error = 0;
|
uint8_t error = 0;
|
||||||
#define IMU_NO_CHANGE 2 //IMU values did not change for too long
|
#define IMU_NO_CHANGE 2 //IMU values did not change for too long
|
||||||
|
@ -263,7 +266,9 @@ void setup() {
|
||||||
|
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
unsigned long loopmillis=millis();
|
last_loopmillis=loopmillis;
|
||||||
|
loopmillis=millis();
|
||||||
|
|
||||||
|
|
||||||
btn_up.tick();
|
btn_up.tick();
|
||||||
btn_inc.tick();
|
btn_inc.tick();
|
||||||
|
@ -271,8 +276,11 @@ void loop() {
|
||||||
btn_down.tick();
|
btn_down.tick();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (loopmillis - last_adcupdated > ADC_UPDATEPERIOD) { //update analog readings
|
if (loopmillis - last_adcupdated > ADC_UPDATEPERIOD) { //update analog readings
|
||||||
|
|
||||||
|
|
||||||
int raw_length_a=analogRead(PIN_GAMETRAK_LENGTH_A);
|
int raw_length_a=analogRead(PIN_GAMETRAK_LENGTH_A);
|
||||||
int raw_length_b=analogRead(PIN_GAMETRAK_LENGTH_B);
|
int raw_length_b=analogRead(PIN_GAMETRAK_LENGTH_B);
|
||||||
|
|
||||||
|
@ -488,6 +496,7 @@ void loop() {
|
||||||
|
|
||||||
|
|
||||||
if (esc.sendPending(loopmillis)) {
|
if (esc.sendPending(loopmillis)) {
|
||||||
|
|
||||||
//calculate checksum
|
//calculate checksum
|
||||||
out_checksum = ((uint8_t) ((uint8_t)esc.getCmdL()) * ((uint8_t)esc.getCmdR())); //simple checksum
|
out_checksum = ((uint8_t) ((uint8_t)esc.getCmdL()) * ((uint8_t)esc.getCmdR())); //simple checksum
|
||||||
if (out_checksum == 0 || out_checksum == 255) {
|
if (out_checksum == 0 || out_checksum == 255) {
|
||||||
|
@ -622,6 +631,11 @@ void updateInputs(unsigned long loopmillis) {
|
||||||
gt_steer_limit = constrain(gt_steer_limit, 50, 1000);
|
gt_steer_limit = constrain(gt_steer_limit, 50, 1000);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 7:
|
||||||
|
if (button_inc_click) {
|
||||||
|
esc.resetStatistics();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -686,7 +700,7 @@ void display_show_stats() {
|
||||||
|
|
||||||
|
|
||||||
//updates only when display active
|
//updates only when display active
|
||||||
static float maxcurL=0;
|
/* static float maxcurL=0;
|
||||||
static float maxcurR=0;
|
static float maxcurR=0;
|
||||||
maxcurL=max(maxcurL,esc.getFiltered_curL());
|
maxcurL=max(maxcurL,esc.getFiltered_curL());
|
||||||
maxcurR=max(maxcurR,esc.getFiltered_curR());
|
maxcurR=max(maxcurR,esc.getFiltered_curR());
|
||||||
|
@ -694,14 +708,15 @@ void display_show_stats() {
|
||||||
static float mincurL=0;
|
static float mincurL=0;
|
||||||
static float mincurR=0;
|
static float mincurR=0;
|
||||||
mincurL=min(mincurL,esc.getFiltered_curL());
|
mincurL=min(mincurL,esc.getFiltered_curL());
|
||||||
mincurR=min(mincurR,esc.getFiltered_curR());
|
mincurR=min(mincurR,esc.getFiltered_curR());*/
|
||||||
|
|
||||||
|
|
||||||
display.print(F("Bat=")); display.print(esc.getFeedback_batVoltage()); display.print(F(" Temp=")); display.println(esc.getFeedback_boardTemp());
|
display.print(F("Bat=")); display.print(esc.getFeedback_batVoltage()); display.print(F(" min=")); display.println(esc.getMinBatVoltage());
|
||||||
display.print(F("nrf_delay=")); display.print(last_nrfreceive_delay);
|
display.print(F("Temp=")); display.println(esc.getFeedback_boardTemp());
|
||||||
display.print(F("maxdiff=")); display.println(raw_length_maxdiff);
|
|
||||||
display.print(F("DC max=")); display.print(maxcurL,1); display.print(F("/")); display.println(maxcurR,1); // display.print(F(" min=")); display.print(mincurL,1); display.print(F("/")); display.println(mincurR,1);
|
display.print(F("DC max=")); display.print(esc.getMaxcurL(),1); display.print(F("/")); display.println(esc.getMaxcurR(),1); // display.print(F(" min=")); display.print(mincurL,1); display.print(F("/")); display.println(mincurR,1);
|
||||||
display.print(F("trip=")); display.print(esc.getTrip(),0); display.print(F(",")); display.print(esc.getCurrentConsumed(),3); display.println(F("Ah"));
|
display.print(F("trip=")); display.print(esc.getTrip(),0); display.print(F(", ")); display.print(esc.getCurrentConsumed(),3); display.println(F("Ah"));
|
||||||
|
|
||||||
|
|
||||||
display.display(); // Show initial text
|
display.display(); // Show initial text
|
||||||
}
|
}
|
||||||
|
@ -714,7 +729,7 @@ void display_show_stats2() {
|
||||||
|
|
||||||
display.print(F("CMD=")); display.print(esc.getCmdL()); display.print(F(", ")); display.println(esc.getCmdR());
|
display.print(F("CMD=")); display.print(esc.getCmdL()); display.print(F(", ")); display.println(esc.getCmdR());
|
||||||
display.print(F("FBC=")); display.print(esc.getFeedback_cmd1()); display.print(F(", ")); display.println(esc.getFeedback_cmd2());
|
display.print(F("FBC=")); display.print(esc.getFeedback_cmd1()); display.print(F(", ")); display.println(esc.getFeedback_cmd2());
|
||||||
display.print(F("Speed=")); display.print(esc.getFeedback_speedL_meas()); display.print(F(", ")); display.println(esc.getFeedback_speedR_meas());
|
display.print(F("Speed=")); display.print(esc.getFeedback_speedL_meas()); display.print(F(",")); display.print(esc.getFeedback_speedR_meas()); display.print(F("=")); display.print(esc.getMeanSpeed()); display.println(F("ms"));
|
||||||
display.print(F("Length=")); display.println(gt_length);
|
display.print(F("Length=")); display.println(gt_length);
|
||||||
display.print(F("H=")); display.print(gt_horizontal); display.print(F(" V=")); display.println(gt_vertical);
|
display.print(F("H=")); display.print(gt_horizontal); display.print(F(" V=")); display.println(gt_vertical);
|
||||||
display.print(F("CMD=")); display.print(esc.getCmdL()); display.print(F(", ")); display.println(esc.getCmdR());
|
display.print(F("CMD=")); display.print(esc.getCmdL()); display.print(F(", ")); display.println(esc.getCmdR());
|
||||||
|
@ -729,6 +744,12 @@ void display_show_stats3() {
|
||||||
display.setTextColor(SSD1306_WHITE);
|
display.setTextColor(SSD1306_WHITE);
|
||||||
display.setCursor(0, 0);
|
display.setCursor(0, 0);
|
||||||
|
|
||||||
|
display.print(F("looptime=")); display.println(loopmillis-last_loopmillis);
|
||||||
|
display.print(F("feedback=")); display.println(esc.getFeedbackInterval());
|
||||||
|
|
||||||
|
display.print(F("nrf_delay=")); display.println(last_nrfreceive_delay);
|
||||||
|
display.print(F("maxdiff=")); display.println(raw_length_maxdiff);
|
||||||
|
|
||||||
|
|
||||||
display.display(); // Show initial text
|
display.display(); // Show initial text
|
||||||
}
|
}
|
||||||
|
@ -767,6 +788,13 @@ void display_show_menu() {
|
||||||
case 6:
|
case 6:
|
||||||
display.print(F("gt_steer_limit=")); display.println(gt_steer_limit);
|
display.print(F("gt_steer_limit=")); display.println(gt_steer_limit);
|
||||||
break;
|
break;
|
||||||
|
case 7:
|
||||||
|
if ((loopmillis/1000)%2==0) {
|
||||||
|
display.print(F("Inc to reset stats"));
|
||||||
|
}else{
|
||||||
|
display.print(F("t=")); display.println(esc.getTripTime(loopmillis)/1000); display.println(F("s"));
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue