Skip to content

Commit

Permalink
Fix millis() bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dalathegreat committed Nov 27, 2023
1 parent bf1e10c commit 470ddc7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Software/Software.ino
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,9 @@ void send_can() {
#ifdef SERIAL_LINK_RECEIVER
//---- Receives serial data and transfers to the Inverter
void receive_serial() {
static unsigned long currentMillis = millis();
if (currentMillis - previousMillis1ms > interval1) { //--- try 2 second
unsigned long currentMillis = millis();
Serial.println(currentMillis);
if (currentMillis - previousMillis1ms >= interval1) { //--- try 2 second
previousMillis1ms = currentMillis;
manageSerialLinkReceiver();
}
Expand All @@ -415,9 +416,9 @@ void receive_serial() {
#ifdef SERIAL_LINK_TRANSMITTER
//---- Gets data from Battery and serial Transmits the data to the Receiver
void send_serial() {
static unsigned long currentMillis = millis();
unsigned long currentMillis = millis();
if (bms_status == ACTIVE) {
if (currentMillis - previousMillis1ms > interval1) { //--- try 2 second
if (currentMillis - previousMillis1ms >= interval1) { //--- try 2 second
previousMillis1ms = currentMillis;
manageSerialLinkTransmitter();
}
Expand Down
1 change: 1 addition & 0 deletions Software/src/battery/SERIAL-LINK-RECEIVER-FROM-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ void manageSerialLinkReceiver() {
}

void update_values_serial_link() {
Serial.print("SOC: ");
Serial.println(SOC);
Serial.println(StateOfHealth);
Serial.println(battery_voltage);
Expand Down

0 comments on commit 470ddc7

Please sign in to comment.