Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/lincomatic/open_evse
Browse files Browse the repository at this point in the history
…into development
  • Loading branch information
glynhudson committed Dec 14, 2017
2 parents d8c637d + 6ce7b0b commit d7010cf
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 13 deletions.
5 changes: 5 additions & 0 deletions firmware/open_evse/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Change Log

D4.11.0 20171207 SCL
- rewrite Gfi::SelfTest() so that it doesn't hang when the test pin has hardware failure
- clear elapsed charging time only when EV is disconnected and then reconnected (previously would reset every time charging stopped)


D4.10.4 20171121 SCL
- rewrite KWH_RECORDING code - class EnergyMeter
-> fix usage counting bug.. was erroneously assuming 1sec intervals
Expand Down
16 changes: 13 additions & 3 deletions firmware/open_evse/Gfi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ void Gfi::Reset()

uint8_t Gfi::SelfTest()
{
int i;
// wait for GFI pin to clear
for (i=0;i < 20;i++) {
WDT_RESET();
if (!pin.read()) break;
delay(50);
}
if (i == 20) return 2;

testInProgress = 1;
testSuccess = 0;
for(int i=0; !testSuccess && (i < GFI_TEST_CYCLES); i++) {
Expand All @@ -68,11 +77,12 @@ uint8_t Gfi::SelfTest()
}

// wait for GFI pin to clear
do {
delay(50);
for (i=0;i < 40;i++) {
WDT_RESET();
if (!pin.read()) break;
delay(50);
}
while(pin.read());
if (i == 40) return 3;

#ifndef OPENEVSE_2
// sometimes getting spurious GFI faults when testing just before closing
Expand Down
8 changes: 8 additions & 0 deletions firmware/open_evse/J1772EvseController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,14 @@ void J1772EVSEController::chargingOn()
#endif
m_bVFlags |= ECVF_CHARGING_ON;

if (m_bVFlags2 & ECVF2_SESSION_ENDED) {
m_AccumulatedChargeTime = 0;
m_bVFlags2 &= ~ECVF2_SESSION_ENDED;
}
else {
m_AccumulatedChargeTime += m_ElapsedChargeTime;
}

m_ChargeOnTime = now();
m_ChargeOnTimeMS = millis();
}
Expand Down
11 changes: 8 additions & 3 deletions firmware/open_evse/J1772EvseController.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ typedef uint8_t (*EvseStateTransitionReqFunc)(uint8_t prevPilotState,uint8_t cur
// J1772EVSEController volatile m_bVFlags2 bits - not saved to EEPROM
#define ECVF2_EV_CONNECTED 0x01 // EV connected - valid only when pilot not N12
#define ECVF2_EV_CONNECTED_PREV 0x02 // prev EV connected flag
#define ECVF2_SESSION_ENDED 0x04 // used for charging session time calc

#define ECVF2_DEFAULT 0x00
#define ECVF2_DEFAULT ECVF2_SESSION_ENDED


class J1772EVSEController {
Expand Down Expand Up @@ -164,6 +165,7 @@ class J1772EVSEController {
time_t m_ChargeOffTime; // unixtime when relay last opened
time_t m_ElapsedChargeTime;
time_t m_ElapsedChargeTimePrev;
time_t m_AccumulatedChargeTime;
#ifdef STATE_TRANSITION_REQ_FUNC
EvseStateTransitionReqFunc m_StateTransitionReqFunc;
#endif // STATE_TRANSITION_REQ_FUNC
Expand Down Expand Up @@ -272,7 +274,7 @@ class J1772EVSEController {
int SetCurrentCapacity(uint8_t amps,uint8_t updatelcd=0,uint8_t nosave=0);

time_t GetElapsedChargeTime() {
return m_ElapsedChargeTime;
return m_ElapsedChargeTime+m_AccumulatedChargeTime;
}
time_t GetElapsedChargeTimePrev() {
return m_ElapsedChargeTimePrev;
Expand Down Expand Up @@ -445,7 +447,10 @@ class J1772EVSEController {
#endif // AUTH_LOCK

void SetEvConnected() { setVFlags2(ECVF2_EV_CONNECTED); }
void ClrEvConnected() { clrVFlags2(ECVF2_EV_CONNECTED); }
void ClrEvConnected() {
clrVFlags2(ECVF2_EV_CONNECTED);
setVFlags2(ECVF2_SESSION_ENDED);
}
void SetEvConnectedPrev() { setVFlags2(ECVF2_EV_CONNECTED_PREV); }
void ClrEvConnectedPrev() { clrVFlags2(ECVF2_EV_CONNECTED_PREV); }
// EvConnected value valid when pilot state not N12
Expand Down
2 changes: 1 addition & 1 deletion firmware/open_evse/Language_default.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#define STR_GFI_SELF_TEST "GFI Self Test"
#define STR_TEMPERATURE_CHK "Temperature Chk"
#define STR_YES_NO {"Yes", "No"}
#define STR_RESTART_NOW "Restart Now"
#define STR_RESTART_NOW "Restart Now?"
#define STR_RESTART "Restart"
#define STR_EXIT "Exit"
#define STR_DATE_TIME "Date/Time"
Expand Down
3 changes: 2 additions & 1 deletion firmware/open_evse/open_evse.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@
#include "WProgram.h" // shouldn't need this but arduino sometimes messes up and puts inside an #ifdef
#endif // ARDUINO

#define VERSION "D4.10.4.EU"
#define setBits(flags,bits) (flags |= (bits))
#define clrBits(flags,bits) (flags &= ~(bits))

#define VERSION "D4.11.0.EU"

#include "Language_default.h" //Default language should always be included as bottom layer

// UK/EU specific settings (by OpenEnergyMonitor):
Expand Down
2 changes: 1 addition & 1 deletion firmware/open_evse/rapi_proc.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ GP - get temPerature (v1.0.3+)
GS - get state
response: $OK evsestate elapsed
evsestate(dec): EVSE_STATE_xxx
elapsed(dec): elapsed charge time in seconds (valid only when in state C)
elapsed(dec): elapsed charge time in seconds of current or last charging session
$GS*BE
GT - get time (RTC)
response: $OK yr mo day hr min sec yr=2-digit year
Expand Down
1 change: 0 additions & 1 deletion firmware/open_evse/strings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ const char g_psTemperatureFault[] PROGMEM = STR_OVER_TEMPERATURE;
const char g_psNoGround[] PROGMEM = STR_NO_GROUND;
const char g_psStuckRelay[] PROGMEM = STR_STUCK_RELAY;
const char g_psDisabled[] PROGMEM = STR_DISABLED;
//const char g_psWaiting[] PROGMEM = STR_WAITING;
const char g_psSleeping[] PROGMEM = STR_SLEEPING;
const char g_psEvConnected[] PROGMEM = STR_CONNECTED;
const char g_psResetting[] PROGMEM = STR_RESETTING;
Expand Down
6 changes: 3 additions & 3 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ lib_deps = ${common.lib_deps}
upload_protocol = usbasp
upload_flags = -p m328p

[env:openevse-v2]
# AVRISP mkII
[env:openevse-mk2isp]
platform = atmelavr
board = openevse
framework = arduino
lib_deps = ${common.lib_deps}
upload_protocol = stk500v2
upload_flags = -Pusb

upload_flags = -p atmega328p -P usb

0 comments on commit d7010cf

Please sign in to comment.