Skip to content

Commit

Permalink
dead code removal. reconstituting some of the timeouts.clear() use af…
Browse files Browse the repository at this point in the history
…ter the separating out the relay.change.
  • Loading branch information
dlyubimov committed Jul 9, 2017
1 parent 1fa12da commit 3d93c7c
Show file tree
Hide file tree
Showing 4 changed files with 1,387 additions and 1,422 deletions.
1 change: 1 addition & 0 deletions Hydra_EVSE/Hydra_EVSE.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ struct car_struct {
};

#define EVENT_COUNT 4

typedef struct event_struct {
unsigned char hour;
unsigned char minute;
Expand Down
53 changes: 7 additions & 46 deletions Hydra_EVSE/Hydra_EVSE.ino
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,12 @@ void error(unsigned int status)
// (that is, turn off the oscillator) whenever we want.
// Stop flipping, one way or another
unsigned int car = status & CAR_MASK;
timeouts.sequential_pilot_timeout = 0;

// kick off gfi timer
// Cancel all pending events except for the relay test protection
// timeouts.sequential_pilot_timeout = 0;
timeouts.clear();

// kick off gfi retry timer (if under the allowed number of attempts).
if ( (status & STATUS_MASK) == STATUS_ERR_G && gfi_count++ < GFI_CLEAR_ATTEMPTS) {
timeouts.gfi_time = millis();
}
Expand Down Expand Up @@ -491,18 +494,6 @@ void car_struct::setRelay(unsigned int state)
if (relay_state == state ) return;
digitalWrite(relay_pin, state);
relay_state = state;
// switch (us) {
// case CAR_A:
// if (relay_state_a == state) return; // did nothing.
// digitalWrite(CAR_A_RELAY, state);
// relay_state_a = state;
// break;
// case CAR_B:
// if (relay_state_b == state) return; // did nothing.
// digitalWrite(CAR_B_RELAY, state);
// relay_state_b = state;
// break;
// }
// This only counts if we actually changed anything.
relay_change_time = millis();
}
Expand All @@ -513,20 +504,6 @@ void car_struct::setRelay(unsigned int state)
/*static inline*/ boolean car_struct::isCarCharging()
{
if (paused) return false;
// switch (car) {
// case CAR_A:
// if (last_car_a_state == STATE_E) return LOW;
// if (car_a_request_time != 0) return HIGH;
// return relay_state_a;
// break;
// case CAR_B:
// if (last_car_b_state == STATE_E) return LOW;
// if (car_b_request_time != 0) return HIGH;
// return relay_state_b;
// break;
// default:
// return LOW; // This should not be possible
// }
if (last_state == STATE_E) return LOW;
if (request_time != 0) return HIGH;
return relay_state;
Expand All @@ -543,19 +520,6 @@ void car_struct::setPilot(unsigned int which)
// set the outgoing pilot for the given car to either HALF state, FULL state, or HIGH.
// int pin;
char pilot_derate = car == CAR_A ? persisted.calib.pilot_a : persisted.calib.pilot_b;
// switch (car) {
// case CAR_A:
// pin = CAR_A_PILOT_OUT_PIN;
// pilot_state_a = which;
// pilot_derate = persisted.calib.pilot_a;
// break;
// case CAR_B:
// pin = CAR_B_PILOT_OUT_PIN;
// pilot_state_b = which;
// pilot_derate = persisted.calib.pilot_b;
// break;
// default: return;
// }
if (which == LOW || which == HIGH)
{
// This is what the pwm library does anyway.
Expand All @@ -582,11 +546,6 @@ void car_struct::setPilot(unsigned int which)
pilot_state = which;
}

//static inline unsigned int pilotState(unsigned int car)
//{
// return (car == CAR_A) ? car_a.pilot_state : car_b.pilot_state;
//}

int car_struct::checkState()
{
// poll the pilot state pin for 10 ms (should be 10 pilot cycles), looking for the low and high.
Expand Down Expand Up @@ -2132,7 +2091,9 @@ void loop()
{
if (!paused)
{
// cancel all events except for relay check guarding period
timeouts.clear();

if (operatingMode == MODE_SEQUENTIAL)
{
// remember which car was active
Expand Down
Loading

0 comments on commit 3d93c7c

Please sign in to comment.