Skip to content

Commit

Permalink
Merge branch 'lincomatic-development'
Browse files Browse the repository at this point in the history
  • Loading branch information
glynhudson committed Apr 9, 2020
2 parents 342f8f1 + 090adf2 commit 46adab6
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 84 deletions.
17 changes: 17 additions & 0 deletions firmware/open_evse/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
Change Log

20200330 SCL
- fixed SetAmmeterDirty(1) compile error

D6.2.1 20200327 SCL
- doPost() - don't compare against hardcoded 900 .. use ThreshAB
- send $AT during sleep if EV connect/disconnect

D6.2.0 20200327 SCL
- fix 1 sec delay in showing current when charging starts
- make space by taking stuff out of button menu that is still accessible via WiFi NOSETUP_MENU
- add RAPI $FF B to enable/disable front button
- fix bug in $AT.. was supposed to send GetCurrentCapacity(), not GetMaxCurrentCapacity()
- change $GC .. new 4th returned parameter is max current capacity
- bump RAPIVER to 5.1.0.
-> n.b. shouldn't really be using RAPIVER.. should just test for working
commands and # returned parameters

D6.1.3 20191217 SCL
- fix bug in displaying lock icon in SLEEP
- update EVSE status after receiving $S4 command
Expand Down
7 changes: 5 additions & 2 deletions firmware/open_evse/J1772EvseController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ uint8_t J1772EVSEController::doPost()
#endif //#ifdef SERDBG

m_Pilot.SetState(PILOT_STATE_N12);
if (reading > 900) { // IF EV is not connected its Okay to open the relay the do the L1/L2 and ground Check
if (reading >= m_ThreshData.m_ThreshAB) { // IF EV is not connected its Okay to open the relay the do the L1/L2 and ground Check

// save state with both relays off - for stuck relay state
RelayOff = ReadACPins();
Expand Down Expand Up @@ -1179,6 +1179,9 @@ void J1772EVSEController::Update(uint8_t forcetransition)
}
#endif // DELAYTIMER
g_OBD.Update(OBD_UPD_FORCE);
#ifdef RAPI
RapiSendEvseState();
#endif // RAPI
}
}

Expand Down Expand Up @@ -2105,4 +2108,4 @@ void J1772EVSEController::SetTimeLimit15(uint8_t mind15)
}
#endif // TIME_LIMIT

//-- end J1772EVSEController
//-- end J1772EVSEController
12 changes: 12 additions & 0 deletions firmware/open_evse/J1772EvseController.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ typedef uint8_t (*EvseStateTransitionReqFunc)(uint8_t prevPilotState,uint8_t cur
#define ECF_MONO_LCD 0x0100 // monochrome LCD backlight
#define ECF_GFI_TEST_DISABLED 0x0200 // no GFI self test
#define ECF_TEMP_CHK_DISABLED 0x0400 // no Temperature Monitoring
#define ECF_BUTTON_DISABLED 0x8000 // front panel button disabled
#define ECF_DEFAULT 0x0000

// J1772EVSEController volatile m_wVFlags bits - not saved to EEPROM
Expand Down Expand Up @@ -189,6 +190,9 @@ class J1772EVSEController {
void clrFlags(uint16_t flags) {
m_wFlags &= ~flags;
}
uint8_t flagIsSet(uint16_t flag) {
return (m_wFlags & flag) ? 1 : 0;
}
void setVFlags(uint16_t flags) {
m_wVFlags |= flags;
}
Expand Down Expand Up @@ -519,6 +523,14 @@ int GetHearbeatTrigger();
}
void SetInMenu() { setVFlags(ECVF_UI_IN_MENU); }
void ClrInMenu() { clrVFlags(ECVF_UI_IN_MENU); }
#ifdef BTN_MENU
void ButtonEnable(uint8_t tf) {
if (!tf) setFlags(ECF_BUTTON_DISABLED);
else clrFlags(ECF_BUTTON_DISABLED);
SaveEvseFlags();
}
uint8_t ButtonIsEnabled() { return flagIsSet(ECF_BUTTON_DISABLED) ? 0 : 1; }
#endif // BTN_MENU
};

#ifdef FT_ENDURANCE
Expand Down
6 changes: 5 additions & 1 deletion firmware/open_evse/open_evse.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#define clrBits(flags,bits) (flags &= ~(bits))

#ifndef VERSION
#define VERSION "D6.1.3"
#define VERSION "D6.2.1"
#endif // !VERSION

#include "Language_default.h" //Default language should always be included as bottom layer
Expand Down Expand Up @@ -237,6 +237,10 @@ extern AutoCurrentCapacityController g_ACCController;
// When within menus, short press cycles menu items, long press selects and exits current submenu
#define BTN_MENU

// take out basic setup stuff that the user really shouldn't be changing,
// which can be set via RAPI/WiFi module.. reclaims a lot of code space
#define NOSETUP_MENU

// When not in menus, short press instantly stops the EVSE - another short press resumes. Long press activates menus
// also allows menus to be manipulated even when in State B/C
#define BTN_ENABLE_TOGGLE
Expand Down
168 changes: 92 additions & 76 deletions firmware/open_evse/open_evse.ino
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@
#ifdef BTN_MENU
SettingsMenu g_SettingsMenu;
SetupMenu g_SetupMenu;
SvcLevelMenu g_SvcLevelMenu;
MaxCurrentMenu g_MaxCurrentMenu;
#ifndef NOSETUP_MENU
SvcLevelMenu g_SvcLevelMenu;
DiodeChkMenu g_DiodeChkMenu;
#ifdef RGBLCD
BklTypeMenu g_BklTypeMenu;
Expand All @@ -82,6 +83,7 @@ VentReqMenu g_VentReqMenu;
GndChkMenu g_GndChkMenu;
RlyChkMenu g_RlyChkMenu;
#endif // ADVPWR
#endif // NOSETUP_MENU
ResetMenu g_ResetMenu;
// Instantiate additional Menus - GoldServe
#if defined(DELAYTIMER_MENU)
Expand Down Expand Up @@ -122,14 +124,17 @@ Menu *g_SettingsMenuList[] = {
};

Menu *g_SetupMenuList[] = {
#ifdef NOSETUP_MENU
&g_MaxCurrentMenu,
&g_RTCMenu,
#else // !NOSETUP_MENU
#ifdef DELAYTIMER_MENU
&g_RTCMenu,
#endif // DELAYTIMER_MENU
#ifdef RGBLCD
&g_BklTypeMenu,
#endif // RGBLCD
&g_SvcLevelMenu,
&g_MaxCurrentMenu,
&g_DiodeChkMenu,
&g_VentReqMenu,
#ifdef ADVPWR
Expand All @@ -142,6 +147,7 @@ Menu *g_SetupMenuList[] = {
#ifdef TEMPERATURE_MONITORING
&g_TempOnOffMenu,
#endif // TEMPERATURE_MONITORING
#endif // NOSETUP_MENU
NULL
};

Expand Down Expand Up @@ -339,8 +345,8 @@ void TempMonitor::Read()
// Temperatures outside of these values work perfectly with 1/4 degree resolution.
// I wrote this note so nobody wastes time trying to "fix" this in software
// since fundamentally it is a hardware limitaion of the DS3231.
}
else
}
else
m_DS3231_temperature = TEMPERATURE_NOT_INSTALLED;

#endif // OPENEVSE_2
Expand Down Expand Up @@ -649,6 +655,9 @@ void OnboardDisplay::Update(int8_t updmode)
LcdPrint_P(g_psCharging);
#endif //Adafruit RGB LCD
// n.b. blue LED is on
#ifdef AMMETER
SetAmmeterDirty(1); // force ammeter update code below
#endif // AMMETER
break;
case EVSE_STATE_D: // vent required
SetGreenLed(0);
Expand Down Expand Up @@ -739,7 +748,7 @@ void OnboardDisplay::Update(int8_t updmode)
LcdSetCursor(0,0);
#ifdef AUTH_LOCK
if (g_EvseController.AuthLockIsOn()) {
LcdWrite(4);
LcdWrite(4);
}
#endif // AUTH_LOCK
LcdPrint_P(g_psDisabled);
Expand All @@ -765,7 +774,7 @@ void OnboardDisplay::Update(int8_t updmode)
LcdSetCursor(0,0);
#ifdef AUTH_LOCK
if (g_EvseController.AuthLockIsOn()) {
LcdWrite(4);
LcdWrite(4);
}
#endif // AUTH_LOCK
LcdPrint_P(g_psSleeping);
Expand Down Expand Up @@ -944,7 +953,7 @@ void OnboardDisplay::Update(int8_t updmode)
g_DelayTimer.PrintTimerIcon();
#ifdef AUTH_LOCK
if (g_EvseController.AuthLockIsOn()) {
LcdWrite(4);
LcdWrite(4);
}
#endif // AUTH_LOCK
LcdPrint_P(g_psSleeping);
Expand Down Expand Up @@ -1204,6 +1213,8 @@ Menu *SetupMenu::Select()
}
}

#ifndef NOSETUP_MENU

#if defined(ADVPWR) && defined(AUTOSVCLEVEL)
#define SVC_LVL_MNU_ITEMCNT 3
#else
Expand Down Expand Up @@ -1323,57 +1334,6 @@ Menu *SvcLevelMenu::Select()
return &g_SetupMenu;
}

MaxCurrentMenu::MaxCurrentMenu()
{
m_Title = g_psMaxCurrent;
}


void MaxCurrentMenu::Init()
{
uint8_t cursvclvl = g_EvseController.GetCurSvcLevel();
m_MinCurrent = MIN_CURRENT_CAPACITY_J1772;
if (cursvclvl == 1) {
m_MaxCurrent = MAX_CURRENT_CAPACITY_L1;
}
else {
m_MaxCurrent = MAX_CURRENT_CAPACITY_L2;
}

sprintf(g_sTmp,g_sMaxCurrentFmt,(cursvclvl == 1) ? "L1" : "L2");
g_OBD.LcdPrint(0,g_sTmp);
m_CurIdx = g_EvseController.GetCurrentCapacity();
if (m_CurIdx < m_MinCurrent) m_CurIdx = m_MinCurrent;
sprintf(g_sTmp,"+%dA",m_CurIdx);
g_OBD.LcdPrint(1,g_sTmp);
}

void MaxCurrentMenu::Next()
{
if (++m_CurIdx > m_MaxCurrent) {
m_CurIdx = m_MinCurrent;
}
g_OBD.LcdClearLine(1);
g_OBD.LcdSetCursor(0,1);
if (g_EvseController.GetCurrentCapacity() == m_CurIdx) {
g_OBD.LcdPrint(g_sPlus);
}
g_OBD.LcdPrint(m_CurIdx);
g_OBD.LcdPrint("A");
}

Menu *MaxCurrentMenu::Select()
{
g_OBD.LcdPrint(0,1,g_sPlus);
g_OBD.LcdPrint(m_CurIdx);
g_OBD.LcdPrint("A");
delay(500);
eeprom_write_byte((uint8_t*)((g_EvseController.GetCurSvcLevel() == 1) ? EOFS_CURRENT_CAPACITY_L1 : EOFS_CURRENT_CAPACITY_L2),m_CurIdx);
g_EvseController.SetCurrentCapacity(m_CurIdx);
return &g_SetupMenu;
}


DiodeChkMenu::DiodeChkMenu()
{
m_Title = g_psDiodeCheck;
Expand Down Expand Up @@ -1613,6 +1573,59 @@ Menu *RlyChkMenu::Select()
}
#endif // ADVPWR

#endif // NOSETUP_MENU

MaxCurrentMenu::MaxCurrentMenu()
{
m_Title = g_psMaxCurrent;
}


void MaxCurrentMenu::Init()
{
uint8_t cursvclvl = g_EvseController.GetCurSvcLevel();
m_MinCurrent = MIN_CURRENT_CAPACITY_J1772;
if (cursvclvl == 1) {
m_MaxCurrent = MAX_CURRENT_CAPACITY_L1;
}
else {
m_MaxCurrent = MAX_CURRENT_CAPACITY_L2;
}

sprintf(g_sTmp,g_sMaxCurrentFmt,(cursvclvl == 1) ? "L1" : "L2");
g_OBD.LcdPrint(0,g_sTmp);
m_CurIdx = g_EvseController.GetCurrentCapacity();
if (m_CurIdx < m_MinCurrent) m_CurIdx = m_MinCurrent;
sprintf(g_sTmp,"+%dA",m_CurIdx);
g_OBD.LcdPrint(1,g_sTmp);
}

void MaxCurrentMenu::Next()
{
if (++m_CurIdx > m_MaxCurrent) {
m_CurIdx = m_MinCurrent;
}
g_OBD.LcdClearLine(1);
g_OBD.LcdSetCursor(0,1);
if (g_EvseController.GetCurrentCapacity() == m_CurIdx) {
g_OBD.LcdPrint(g_sPlus);
}
g_OBD.LcdPrint(m_CurIdx);
g_OBD.LcdPrint("A");
}

Menu *MaxCurrentMenu::Select()
{
g_OBD.LcdPrint(0,1,g_sPlus);
g_OBD.LcdPrint(m_CurIdx);
g_OBD.LcdPrint("A");
delay(500);
eeprom_write_byte((uint8_t*)((g_EvseController.GetCurSvcLevel() == 1) ? EOFS_CURRENT_CAPACITY_L1 : EOFS_CURRENT_CAPACITY_L2),m_CurIdx);
g_EvseController.SetCurrentCapacity(m_CurIdx);
return &g_SetupMenu;
}


ResetMenu::ResetMenu()
{
m_Title = g_psReset;
Expand All @@ -1635,6 +1648,17 @@ void ResetMenu::Next()
g_OBD.LcdPrint(0,1,g_YesNoMenuItems[m_CurIdx]);
}

Menu *ResetMenu::Select()
{
g_OBD.LcdPrint(0,1,g_sPlus);
g_OBD.LcdPrint(g_YesNoMenuItems[m_CurIdx]);
delay(500);
if (m_CurIdx == 0) {
g_EvseController.Reboot();
}
return NULL;
}

#ifdef DELAYTIMER_MENU
// pluspos = -1 = suppress "+"
void DtsStrPrint1(uint16_t y,uint8_t mo,uint8_t d,uint8_t h,uint8_t mn,int8_t pluspos)
Expand Down Expand Up @@ -2120,17 +2144,6 @@ Menu *TimeLimitMenu::Select()
}
#endif // TIME_LIMIT

Menu *ResetMenu::Select()
{
g_OBD.LcdPrint(0,1,g_sPlus);
g_OBD.LcdPrint(g_YesNoMenuItems[m_CurIdx]);
delay(500);
if (m_CurIdx == 0) {
g_EvseController.Reboot();
}
return NULL;
}

BtnHandler::BtnHandler()
{
m_CurMenu = NULL;
Expand Down Expand Up @@ -2176,6 +2189,8 @@ int8_t BtnHandler::DoShortPress(int8_t infaultstate)

void BtnHandler::ChkBtn()
{
if (!g_EvseController.ButtonIsEnabled()) return;

WDT_RESET();

int8_t infaultstate = g_EvseController.InFaultState();
Expand Down Expand Up @@ -2408,13 +2423,6 @@ void EvseReset()
{
Wire.begin();

#ifdef RTC
g_RTC.begin();
#ifdef DELAYTIMER
g_DelayTimer.Init();
#endif // DELAYTIMER
#endif // RTC

#ifdef SERIALCLI
g_CLI.Init();
#endif // SERIALCLI
Expand All @@ -2427,6 +2435,14 @@ void EvseReset()

g_EvseController.Init();

#ifdef RTC
g_RTC.begin();
#ifdef DELAYTIMER
g_DelayTimer.Init(); // this *must* run after g_EvseController.Init() because it sets one of the vFlags
#endif // DELAYTIMER
#endif // RTC


#ifdef PP_AUTO_AMPACITY
g_ACCController.AutoSetCurrentCapacity();
#endif
Expand Down
Loading

0 comments on commit 46adab6

Please sign in to comment.