Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dlyubimov committed Jul 1, 2017
1 parent 161470c commit fa19d5f
Show file tree
Hide file tree
Showing 4 changed files with 1,034 additions and 1,046 deletions.
8 changes: 7 additions & 1 deletion Hydra_EVSE/Hydra_EVSE.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@


// for things like erroring out a car
// Note: for current implementation it is essential that CAR_B == CAR_A + 1 so don't change that.
#define BOTH 0x0
#define CAR_A 0x1
#define CAR_B 0x2
Expand Down Expand Up @@ -369,11 +370,15 @@ struct car_struct {
boolean isCarCharging();
int checkState();
unsigned long readCurrent();
char carLetter() { return 'A' + car - CAR_A; }
// main loop symmetrical logic:
void loopCheckPilot(unsigned int car_state);
void loopCurrentMonitor();
void loopCheckDelayedTransition();
// Inlines
char carLetter() { return 'A' + car - CAR_A; }
// Returns 0 for car A and 8 for car B. Typically, to print display status or current.
unsigned int dispCol() { return 8 * ( car - CAR_A ); }

};

#define EVENT_COUNT 4
Expand Down Expand Up @@ -483,6 +488,7 @@ extern void displayStatus(unsigned int status);
extern char errLetter(unsigned int status);
extern boolean &enable_dst;
extern Timezone dst;
extern car_struct cars[];


///////////////////////////////////////////////////////////
Expand Down
31 changes: 4 additions & 27 deletions Hydra_EVSE/Hydra_EVSE.ino
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,10 @@ car_struct cars[] =
car_struct(CAR_B, -1, CAR_B_RELAY, CAR_B_PILOT_OUT_PIN, CAR_B_PILOT_SENSE_PIN, CAR_B_CURRENT_PIN)
};
// TODO: in theory once we remove symmetry duplication in the code, we won't need this.
car_struct &car_a = cars[0], &car_b = cars[1];
car_struct &car_a(cars[0]), &car_b(cars[1]);


//unsigned long car_a_current_samples[ROLLING_AVERAGE_SIZE], car_b_current_samples[ROLLING_AVERAGE_SIZE];
//unsigned long incomingPilotMilliamps;
//unsigned int last_car_a_state, last_car_b_state;
//unsigned long car_a_overdraw_begin, car_b_overdraw_begin;
//unsigned long car_a_request_time, car_b_request_time;
//unsigned long car_a_error_time, car_b_error_time;
//unsigned long last_current_log_car_a, last_current_log_car_b;
unsigned long last_state_log;
unsigned long sequential_pilot_timeout;
//boolean seq_car_a_done = false, seq_car_b_done = false;
//unsigned int pilot_state_a, pilot_state_b;
unsigned char &operatingMode(persisted.operatingMode), sequential_mode_tiebreak;
unsigned long button_press_time, button_debounce_time;
#ifdef GROUND_TEST
Expand Down Expand Up @@ -476,20 +466,6 @@ void error(unsigned int status)
car_b.request_time = 0;
}

// display.setBacklight(RED);
// if (car == BOTH || car == CAR_A) {
// display.setCursor(0, 1);
// display.print(P("A:ERR "));
// display.print(err);
// display.print(' ');
// }
// if (car == BOTH || car == CAR_B) {
// display.setCursor(8, 1);
// display.print(P("B:ERR "));
// display.print(err);
// display.print(' ');
// }
//
displayStatus(status);
logInfo(P("Error %c on %s"), errLetter(status), car_str(car));
}
Expand Down Expand Up @@ -1991,8 +1967,9 @@ void car_struct::loopCurrentMonitor() {
// car A is under its limit. Cancel any overdraw in progress
overdraw_begin = 0;
}
display.setCursor(0, 1);
display.print("A:");
display.setCursor(dispCol(), 1);
display.print(carLetter());
display.print(':');
display.print(formatMilliamps(car_draw));
}
else
Expand Down
Loading

0 comments on commit fa19d5f

Please sign in to comment.