Skip to content

Commit

Permalink
Fix for Web interface status and schematic
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiejones85 committed Mar 27, 2023
1 parent 6a54c44 commit b90bf97
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 29 deletions.
2 changes: 2 additions & 0 deletions ESP32-Chademo/ESP32-Chademo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ void setup() {

pinMode(CHADEMO_IN2, INPUT);
pinMode(CHADEMO_IN1, INPUT);
pinMode(CHADEMO_OUT1, OUTPUT);
pinMode(CHADEMO_OUT2, OUTPUT);
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, HIGH);

Expand Down
4 changes: 3 additions & 1 deletion ESP32-Chademo/Globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#define CAN_BAUD 500000
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define EEPROM_VALID 0xEE
#define EEPROM_VALID 0xCC

//These have been moved to eeprom. After initial compile the values will be read from EEPROM.
//These thus set the default value to write to eeprom upon first start up
Expand All @@ -39,6 +39,8 @@ typedef struct
uint8_t capacity; //27
uint8_t debuggingLevel; //29
bool useBms;
bool currentMissmatch;

} EESettings;

extern EESettings settings;
Expand Down
41 changes: 13 additions & 28 deletions ESP32-Chademo/data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,8 @@ function setValue(id, value) {
element.innerHTML = value
}

// STARTUP,
SEND_INITIAL_PARAMS,
WAIT_FOR_EVSE_PARAMS,
SET_CHARGE_BEGIN,
WAIT_FOR_BEGIN_CONFIRMATION,
CLOSE_CONTACTORS,
WAIT_FOR_PRECHARGE,
RUNNING,
CEASE_CURRENT,
WAIT_FOR_ZERO_CURRENT,
OPEN_CONTACTOR,
FAULTED,
STOPPED,
LIMBO
//
function updateText(key, data) {
if (key == 'status') {
if (key == 'chademoState') {
if (data == 0) {
setValue('mode', "Waiting");
} else if (data == 1) {
Expand Down Expand Up @@ -115,7 +100,7 @@ function onLoad() {
function onOpen(evt) {
console.log("Socket Connected");
}

function onMessage(json) {
Object.keys(json).forEach(function(key) {
updateGauge(key, json[key]);
Expand All @@ -128,32 +113,32 @@ function onMessage(json) {
function onError(evt) {
console.log("Socket Error")
}

function doSend(message) {
websocket.send(message);
}

function writeToScreen(message) {
var pre = document.createElement("p");
pre.style.wordWrap = "break-word";
var pre = document.createElement("p");
pre.style.wordWrap = "break-word";
pre.innerHTML = message; output.appendChild(pre);
}

function chargerWebSocket(wsUri) {
websocket = new WebSocket(wsUri);

websocket.onopen = function(evt) {
onOpen(evt)
};

websocket.onclose = function(evt) {
console.log(evt)
};

websocket.onmessage = function(evt) {
onMessage(JSON.parse(evt.data))
};

websocket.onerror = function(evt) {
onError(evt)
};
Expand All @@ -164,18 +149,18 @@ function onMessage(json) {
}

/** @brief uploads file to web server, if bin-file uploaded, starts a firmware upgrade */
function uploadFile()
function uploadFile()
{
var xmlhttp = new XMLHttpRequest();
var form = document.getElementById('uploadform');

if (form.getFormData)
var fd = form.getFormData();
else
var fd = new FormData(form);
var file = document.getElementById('updatefile').files[0].name;

xmlhttp.onload = function()
xmlhttp.onload = function()
{
document.getElementById("bar").innerHTML = "<p>Upload complete</p>";
if (file.endsWith(".hex"))
Expand All @@ -188,4 +173,4 @@ function uploadFile()

xmlhttp.open("POST", "/edit");
xmlhttp.send(fd);
}
}
Binary file added Hardware/Schematic_ESP32-Chademo.pdf
Binary file not shown.

0 comments on commit b90bf97

Please sign in to comment.