Skip to content

Commit cd981ad

Browse files
committed
Toggle LCDlock using o and > buttons at powerup
1 parent c1cf86c commit cd981ad

File tree

4 files changed

+27
-17
lines changed

4 files changed

+27
-17
lines changed

SmartEVSE-3/.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
.pio
2-
.vscode/.browse.c_cpp.db*
3-
.vscode/c_cpp_properties.json
4-
.vscode/launch.json
5-
.vscode/ipch
2+
.vscode
3+
packed_fs.c

SmartEVSE-3/data/index.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
let minCurrent=parseInt(data.settings.current_min.toFixed(1));
4444
let maxCurrent=parseInt(data.settings.current_max.toFixed(1));
45-
let lcdlock=parseInt(data.settings.LCDlock);
45+
let lcdlock=parseInt(data.settings.lcdlock);
4646
if (lcdlock)
4747
document.getElementById("lcdlock").checked = true;
4848

@@ -912,7 +912,7 @@ <h1 id="serialnr" class="h5 mb-0 text-white-800">SmartEVSE-</h1>
912912
}
913913
function toggleLCDlock() {
914914
var LCDlockCheckbox = document.getElementById("lcdlock");
915-
$.post( "/settings?LCDlock=" + (LCDlockCheckbox.checked == true ? 1 : 0));
915+
$.post( "/settings?lcdlock=" + (LCDlockCheckbox.checked == true ? 1 : 0));
916916
}
917917
function toggleEnableOcpp() {
918918
var enableOcppCheckbox = document.getElementById("enable_ocpp");
@@ -1057,10 +1057,11 @@ <h1 id="serialnr" class="h5 mb-0 text-white-800">SmartEVSE-</h1>
10571057
<button onclick="update()" style="width: 100px; display:inline-block;" title="Update your firmware">Update</button>
10581058
<button onclick="rawData()" style="width: 120px; display:inline-block;" title="Display your settings in JSON format">Raw Data</button>
10591059
</div>
1060-
<div class="col">
1060+
<!-- <div class="col">
10611061
<label for="lcdlock" style="width: 140px; display:inline-block;" title="Lock buttons on LCD screen">LCD Lock</label>
10621062
<input type="checkbox" id="lcdlock" value="lcdlock" onclick="toggleLCDlock()">
10631063
</div>
1064+
-->
10641065
</div>
10651066
<div class="row no-gutters align-items-center with_modem">
10661067
<div class="col-auto h5 mb-0 mr-3 font-weight-bold text-gray-800" style="width: 120px;">

SmartEVSE-3/include/main.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@
179179
#define OCPP_MODE 0
180180
#define AUTOUPDATE 0 // default for Automatic Firmware Update: 0 = disabled, 1 = enabled
181181
#define SB2_WIFI_MODE 0
182+
#define LCD_LOCK 0 // 0 = LCD buttons operational, 1 = LCD buttons disabled
182183

183184
// Mode settings
184185
#define MODE_NORMAL 0

SmartEVSE-3/src/main.cpp

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ uint16_t ImportCurrent = IMPORT_CURRENT;
189189
struct DelayedTimeStruct DelayedStartTime;
190190
struct DelayedTimeStruct DelayedStopTime;
191191
uint8_t DelayedRepeat; // 0 = no repeat, 1 = daily repeat
192-
bool LCDlock = false; // Lock buttons on LCD display if true
192+
uint8_t LCDlock = LCD_LOCK; // 0 = LCD buttons operational, 1 = LCD buttons disabled
193193
uint8_t Grid = GRID; // Type of Grid connected to Sensorbox (0:4Wire / 1:3Wire )
194194
uint8_t SB2_WIFImode = SB2_WIFI_MODE; // Sensorbox-2 WiFi Mode (0:Disabled / 1:Enabled / 2:Start Portal)
195195
uint8_t RFIDReader = RFID_READER; // RFID Reader (0:Disabled / 1:Enabled / 2:Enable One / 3:Learn / 4:Delete / 5:Delete All / 6: Remote via OCPP)
@@ -3923,7 +3923,7 @@ void read_settings() {
39233923
DelayedStartTime.epoch2 = preferences.getULong("DelayedStartTim", DELAYEDSTARTTIME); //epoch2 is 4 bytes long on arduino; NVS key has reached max size
39243924
DelayedStopTime.epoch2 = preferences.getULong("DelayedStopTime", DELAYEDSTOPTIME); //epoch2 is 4 bytes long on arduino
39253925
DelayedRepeat = preferences.getUShort("DelayedRepeat", 0);
3926-
LCDlock = preferences.getUShort("LCDlock", 0);
3926+
LCDlock = preferences.getUChar("LCDlock", LCD_LOCK);
39273927
TZinfo = preferences.getString("TimezoneInfo","");
39283928
if (TZinfo != "") {
39293929
setenv("TZ",TZinfo.c_str(),1);
@@ -3997,6 +3997,7 @@ void write_settings(void) {
39973997
preferences.putString("RequiredEVCCID", String(RequiredEVCCID));
39983998
preferences.putUShort("maxTemp", maxTemp);
39993999
preferences.putUChar("AutoUpdate", AutoUpdate);
4000+
preferences.putUChar("LCDlock", LCDlock);
40004001

40014002
#if ENABLE_OCPP
40024003
preferences.putUChar("OcppMode", OcppMode);
@@ -4149,7 +4150,7 @@ bool handle_URI(struct mg_connection *c, struct mg_http_message *hm, webServerR
41494150
doc["settings"]["starttime"] = (DelayedStartTime.epoch2 ? DelayedStartTime.epoch2 + EPOCH2_OFFSET : 0);
41504151
doc["settings"]["stoptime"] = (DelayedStopTime.epoch2 ? DelayedStopTime.epoch2 + EPOCH2_OFFSET : 0);
41514152
doc["settings"]["repeat"] = DelayedRepeat;
4152-
doc["settings"]["LCDlock"] = LCDlock;
4153+
doc["settings"]["lcdlock"] = LCDlock;
41534154
#if MODEM
41544155
doc["settings"]["required_evccid"] = RequiredEVCCID;
41554156
doc["settings"]["modem"] = "Experiment";
@@ -4466,15 +4467,12 @@ bool handle_URI(struct mg_connection *c, struct mg_http_message *hm, webServerR
44664467
}
44674468
}
44684469

4469-
if(request->hasParam("LCDlock")) {
4470-
int lock = request->getParam("LCDlock")->value().toInt();
4470+
if(request->hasParam("lcdlock")) {
4471+
int lock = request->getParam("lcdlock")->value().toInt();
44714472
if (lock >= 0 && lock <= 1) { //boundary check
44724473
LCDlock = lock;
4473-
doc["LCDlock"] = lock;
4474-
if (preferences.begin("settings", false) ) {
4475-
preferences.putUShort("LCDlock", LCDlock);
4476-
preferences.end();
4477-
}
4474+
doc["lcdlock"] = lock;
4475+
write_settings();
44784476
}
44794477
}
44804478

@@ -5530,6 +5528,18 @@ void setup() {
55305528
read_settings(); // initialize with default data when starting for the first time
55315529
validate_settings();
55325530
ReadRFIDlist(); // Read all stored RFID's from storage
5531+
5532+
// Sample middle+right button, and lock/unlock LCD buttons.
5533+
pinMatrixOutDetach(PIN_LCD_SDO_B3, false, false); // disconnect MOSI pin
5534+
pinMode(PIN_LCD_SDO_B3, INPUT);
5535+
pinMode(PIN_LCD_A0_B2, INPUT);
5536+
if ((digitalRead(PIN_LCD_A0_B2) == 0) && (digitalRead(PIN_LCD_SDO_B3) == 0)) {
5537+
LCDlock = !LCDlock;
5538+
write_settings();
5539+
}
5540+
pinMode(PIN_LCD_SDO_B3, OUTPUT);
5541+
pinMatrixOutAttach(PIN_LCD_SDO_B3, VSPID_IN_IDX, false, false); // re-attach MOSI pin
5542+
pinMode(PIN_LCD_A0_B2, OUTPUT);
55335543

55345544
// Create Task EVSEStates, that handles changes in the CP signal
55355545
xTaskCreate(

0 commit comments

Comments
 (0)