Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions firmware/open_evse/J1772EvseController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,14 +276,14 @@ void J1772EVSEController::chargingOn()
Serial.print("relayHoldPwm: ");Serial.println(m_relayHoldPwm);
// turn on charging pin to close relay
digitalWrite(V6_CHARGING_PIN,HIGH);
digitalWrite(V6_CHARGING_PIN2,HIGH);
if (relay2Enable) {digitalWrite(V6_CHARGING_PIN2,HIGH); }
delay(m_relayCloseMs);
// switch to PWM to hold closed
analogWrite(V6_CHARGING_PIN,m_relayHoldPwm);
analogWrite(V6_CHARGING_PIN2,m_relayHoldPwm);
if (relay2Enable) {analogWrite(V6_CHARGING_PIN2,m_relayHoldPwm);}
#else // !RELAY_PWM
digitalWrite(V6_CHARGING_PIN,HIGH);
digitalWrite(V6_CHARGING_PIN2,HIGH);
if (relay2Enable) {digitalWrite(V6_CHARGING_PIN2,HIGH);}
#endif // RELAY_PWM
}
else {
Expand Down Expand Up @@ -317,6 +317,8 @@ void J1772EVSEController::chargingOn()
void J1772EVSEController::chargingOff()
{
// turn off charging current
//Note - we don't care if relay2 is enabled or not,
// in all cases we turn off both relays.
#ifdef OEV6
if (isV6()) {
#ifdef RELAY_AUTO_PWM_PIN
Expand Down
2 changes: 2 additions & 0 deletions firmware/open_evse/J1772EvseController.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ class J1772EVSEController {

#ifdef OEV6
uint8_t isV6() { return m_isV6; }
uint8_t relay2Enable = 1; //default to both relays enabled
#endif

#ifdef ADVPWR
Expand Down Expand Up @@ -292,6 +293,7 @@ class J1772EVSEController {
void Enable();
void Disable(); // panic stop - open relays abruptly
void Sleep(); // graceful stop - e.g. waiting for timer to fire- give the EV time to stop charging first
void Relay2Enable(uint8_t relay2on) { relay2Enable = relay2on; }

uint16_t GetFlags() { return m_wFlags; }
uint16_t GetVFlags() { return m_wVFlags; }
Expand Down
16 changes: 13 additions & 3 deletions firmware/open_evse/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ TempMonitor g_TempMonitor;
AutoCurrentCapacityController g_ACCController;
#endif

unsigned long OnboardDisplay::lastBacklightChangeMillis = 0;



//-- end global variables

// watchdog-safe delay - use this when delay is longer than watchdog
Expand Down Expand Up @@ -414,7 +418,6 @@ void OnboardDisplay::MakeChar(uint8_t n, PGM_P bytes)
void OnboardDisplay::Init()
{
WDT_RESET();

#ifdef RGBLCD
m_bFlags = 0;
#else
Expand Down Expand Up @@ -985,6 +988,11 @@ void OnboardDisplay::Update(int8_t updmode)
}
}
#endif // DELAYTIMER

if ( g_OBD.lastBacklightChangeMillis < millis() + LCD_BL_TIMEOUT) {
//turn backlight off after 5 secs
LcdSetBacklightColor(0);
}
#endif // LCD16X2
}

Expand Down Expand Up @@ -2492,7 +2500,7 @@ uint8_t StateTransitionReqFunc(uint8_t curPilotState,uint8_t newPilotState,uint8
void setup()
{
wdt_disable();

delay(400); // give I2C devices time to be ready before running code that wants to initialize I2C devices. Otherwise a hang can occur upon powerup.

Serial.begin(SERIAL_BAUD);
Expand Down Expand Up @@ -2541,7 +2549,9 @@ void loop()
#endif // PERIODIC_LCD_REFRESH_MS

ProcessInputs();


//BackLightTimeout();

// Delay Timer Handler - GoldServe
#ifdef DELAYTIMER
g_DelayTimer.CheckTime();
Expand Down
10 changes: 10 additions & 0 deletions firmware/open_evse/open_evse.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ extern AutoCurrentCapacityController g_ACCController;
//Adafruit RGBLCD (MCP23017) - can have RGB or monochrome backlight
#define RGBLCD

#define LCD_BL_TIMEOUT 5000
//select default LCD backlight mode. can be overridden w/CLI/RAPI
#define BKL_TYPE_MONO 0
#define BKL_TYPE_RGB 1
Expand Down Expand Up @@ -844,6 +845,7 @@ typedef union union4b {
#define OBD_UPD_HARDFAULT 2 // update w/ hard fault
class OnboardDisplay
{

#ifdef RED_LED_REG
DigitalPin pinRedLed;
#endif
Expand All @@ -865,6 +867,9 @@ class OnboardDisplay

void MakeChar(uint8_t n, PGM_P bytes);
public:

static unsigned long lastBacklightChangeMillis ;

OnboardDisplay();
void Init();

Expand Down Expand Up @@ -937,6 +942,11 @@ class OnboardDisplay
#endif // RGBLCD
}
void LcdSetBacklightColor(uint8_t c) {
static uint8_t lastColor = WHITE;
if (c != lastColor) {
lastBacklightChangeMillis = millis();
lastColor = c;
}
#ifdef RGBLCD
if (IsLcdBacklightMono()) {
if (c) c = WHITE;
Expand Down
14 changes: 14 additions & 0 deletions firmware/open_evse/rapi_proc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,20 @@ int EvseRapiProcessor::processCmd()
}
break;
#endif // VOLTMETER

#ifdef OEV6
case 'R': //Relay2 enable
if (tokenCnt == 2) {
if ( (uint8_t)dtou32(tokens[1]) == 1 ) {
g_EvseController.Relay2Enable(1);
} else {
g_EvseController.Relay2Enable(0);
}
}
rc = 0;
break;
#endif //OEV6

#ifdef DELAYTIMER
case 'T': // timer
if (tokenCnt == 5) {
Expand Down