Skip to content

Commit

Permalink
Toggle LCDlock using o and > buttons at powerup
Browse files Browse the repository at this point in the history
  • Loading branch information
mstegen committed Nov 7, 2024
1 parent c1cf86c commit cd981ad
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 17 deletions.
6 changes: 2 additions & 4 deletions SmartEVSE-3/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
.vscode
packed_fs.c
7 changes: 4 additions & 3 deletions SmartEVSE-3/data/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

let minCurrent=parseInt(data.settings.current_min.toFixed(1));
let maxCurrent=parseInt(data.settings.current_max.toFixed(1));
let lcdlock=parseInt(data.settings.LCDlock);
let lcdlock=parseInt(data.settings.lcdlock);
if (lcdlock)
document.getElementById("lcdlock").checked = true;

Expand Down Expand Up @@ -912,7 +912,7 @@ <h1 id="serialnr" class="h5 mb-0 text-white-800">SmartEVSE-</h1>
}
function toggleLCDlock() {
var LCDlockCheckbox = document.getElementById("lcdlock");
$.post( "/settings?LCDlock=" + (LCDlockCheckbox.checked == true ? 1 : 0));
$.post( "/settings?lcdlock=" + (LCDlockCheckbox.checked == true ? 1 : 0));
}
function toggleEnableOcpp() {
var enableOcppCheckbox = document.getElementById("enable_ocpp");
Expand Down Expand Up @@ -1057,10 +1057,11 @@ <h1 id="serialnr" class="h5 mb-0 text-white-800">SmartEVSE-</h1>
<button onclick="update()" style="width: 100px; display:inline-block;" title="Update your firmware">Update</button>
<button onclick="rawData()" style="width: 120px; display:inline-block;" title="Display your settings in JSON format">Raw Data</button>
</div>
<div class="col">
<!-- <div class="col">
<label for="lcdlock" style="width: 140px; display:inline-block;" title="Lock buttons on LCD screen">LCD Lock</label>
<input type="checkbox" id="lcdlock" value="lcdlock" onclick="toggleLCDlock()">
</div>
-->
</div>
<div class="row no-gutters align-items-center with_modem">
<div class="col-auto h5 mb-0 mr-3 font-weight-bold text-gray-800" style="width: 120px;">
Expand Down
1 change: 1 addition & 0 deletions SmartEVSE-3/include/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
#define OCPP_MODE 0
#define AUTOUPDATE 0 // default for Automatic Firmware Update: 0 = disabled, 1 = enabled
#define SB2_WIFI_MODE 0
#define LCD_LOCK 0 // 0 = LCD buttons operational, 1 = LCD buttons disabled

// Mode settings
#define MODE_NORMAL 0
Expand Down
30 changes: 20 additions & 10 deletions SmartEVSE-3/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ uint16_t ImportCurrent = IMPORT_CURRENT;
struct DelayedTimeStruct DelayedStartTime;
struct DelayedTimeStruct DelayedStopTime;
uint8_t DelayedRepeat; // 0 = no repeat, 1 = daily repeat
bool LCDlock = false; // Lock buttons on LCD display if true
uint8_t LCDlock = LCD_LOCK; // 0 = LCD buttons operational, 1 = LCD buttons disabled
uint8_t Grid = GRID; // Type of Grid connected to Sensorbox (0:4Wire / 1:3Wire )
uint8_t SB2_WIFImode = SB2_WIFI_MODE; // Sensorbox-2 WiFi Mode (0:Disabled / 1:Enabled / 2:Start Portal)
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)
Expand Down Expand Up @@ -3923,7 +3923,7 @@ void read_settings() {
DelayedStartTime.epoch2 = preferences.getULong("DelayedStartTim", DELAYEDSTARTTIME); //epoch2 is 4 bytes long on arduino; NVS key has reached max size
DelayedStopTime.epoch2 = preferences.getULong("DelayedStopTime", DELAYEDSTOPTIME); //epoch2 is 4 bytes long on arduino
DelayedRepeat = preferences.getUShort("DelayedRepeat", 0);
LCDlock = preferences.getUShort("LCDlock", 0);
LCDlock = preferences.getUChar("LCDlock", LCD_LOCK);
TZinfo = preferences.getString("TimezoneInfo","");
if (TZinfo != "") {
setenv("TZ",TZinfo.c_str(),1);
Expand Down Expand Up @@ -3997,6 +3997,7 @@ void write_settings(void) {
preferences.putString("RequiredEVCCID", String(RequiredEVCCID));
preferences.putUShort("maxTemp", maxTemp);
preferences.putUChar("AutoUpdate", AutoUpdate);
preferences.putUChar("LCDlock", LCDlock);

#if ENABLE_OCPP
preferences.putUChar("OcppMode", OcppMode);
Expand Down Expand Up @@ -4149,7 +4150,7 @@ bool handle_URI(struct mg_connection *c, struct mg_http_message *hm, webServerR
doc["settings"]["starttime"] = (DelayedStartTime.epoch2 ? DelayedStartTime.epoch2 + EPOCH2_OFFSET : 0);
doc["settings"]["stoptime"] = (DelayedStopTime.epoch2 ? DelayedStopTime.epoch2 + EPOCH2_OFFSET : 0);
doc["settings"]["repeat"] = DelayedRepeat;
doc["settings"]["LCDlock"] = LCDlock;
doc["settings"]["lcdlock"] = LCDlock;
#if MODEM
doc["settings"]["required_evccid"] = RequiredEVCCID;
doc["settings"]["modem"] = "Experiment";
Expand Down Expand Up @@ -4466,15 +4467,12 @@ bool handle_URI(struct mg_connection *c, struct mg_http_message *hm, webServerR
}
}

if(request->hasParam("LCDlock")) {
int lock = request->getParam("LCDlock")->value().toInt();
if(request->hasParam("lcdlock")) {
int lock = request->getParam("lcdlock")->value().toInt();
if (lock >= 0 && lock <= 1) { //boundary check
LCDlock = lock;
doc["LCDlock"] = lock;
if (preferences.begin("settings", false) ) {
preferences.putUShort("LCDlock", LCDlock);
preferences.end();
}
doc["lcdlock"] = lock;
write_settings();
}
}

Expand Down Expand Up @@ -5530,6 +5528,18 @@ void setup() {
read_settings(); // initialize with default data when starting for the first time
validate_settings();
ReadRFIDlist(); // Read all stored RFID's from storage

// Sample middle+right button, and lock/unlock LCD buttons.
pinMatrixOutDetach(PIN_LCD_SDO_B3, false, false); // disconnect MOSI pin
pinMode(PIN_LCD_SDO_B3, INPUT);
pinMode(PIN_LCD_A0_B2, INPUT);
if ((digitalRead(PIN_LCD_A0_B2) == 0) && (digitalRead(PIN_LCD_SDO_B3) == 0)) {
LCDlock = !LCDlock;
write_settings();
}
pinMode(PIN_LCD_SDO_B3, OUTPUT);
pinMatrixOutAttach(PIN_LCD_SDO_B3, VSPID_IN_IDX, false, false); // re-attach MOSI pin
pinMode(PIN_LCD_A0_B2, OUTPUT);

// Create Task EVSEStates, that handles changes in the CP signal
xTaskCreate(
Expand Down

0 comments on commit cd981ad

Please sign in to comment.