-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding configurable can RX/TX pins (#9)
* Adding configurable can RX/TX pins * Adding optional CAN enable Pin config
- Loading branch information
1 parent
9b392c9
commit 4fa06c0
Showing
10 changed files
with
228 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<!-- | ||
* This file is part of the esp8266 web interface | ||
* | ||
* Copyright (C) 2018 Johannes Huebner <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
--> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
<meta http-equiv="refresh" content="10;url=http://192.168.4.1/" /> | ||
<title>Modify settings</title> | ||
<link href="style.css" rel="stylesheet" type="text/css" /> | ||
</head> | ||
<body> | ||
Settings updated. <a href="/">Return to main page</a>. | ||
</body> | ||
</html> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!-- | ||
* This file is part of the esp8266 web interface | ||
* | ||
* Copyright (C) 2018 Johannes Huebner <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
--> | ||
<div id="settingsInner"> | ||
<h2>Settings</h2> | ||
<form id="settingsForm" enctype="multipart/form-data" action="settings" method="POST"> | ||
|
||
<p><label for="canTXPin">CAN TX Pin: </label><input id="canTXPin" name="canTXPin" type="text" value="%canTXPin%"/></p> | ||
<p><label for="canRXPin">CAN RX Pin: </label><input id="canRXPin" name="canRXPin" type="text" value="%canRXPin%"/></p> | ||
<p><label for="canEnablePin">CAN Enable Pin: </label><input id="canEnablePin" name="canEnablePin" type="text" value="%canEnablePin%"/> Set to 0 if not required</p> | ||
|
||
<p><strong>Open Inverter Can board:- TX Pin: 25 RX Pin: 26</strong></p> | ||
<p><strong>Lilygo T-Can board:- TX Pin: 27 RX Pin: 26 Can Enable Pin: 23</strong></p> | ||
<a href="#" onclick="ui.settingsForm('settingsForm');"><button> | ||
<img class="buttonimg" src="/icon-check-circle.png">Modify</button></a> | ||
</form> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var settings = { | ||
|
||
wifiValidatePasswordLength: function(pw) | ||
{ | ||
document.getElementById("apsubmit").disabled = pw.length < 8; | ||
}, | ||
|
||
populateSettingsTab: function() | ||
{ | ||
var settingsTab = document.getElementById("settings"); | ||
var settingsFetchRequest = new XMLHttpRequest(); | ||
settingsFetchRequest.onload = function() | ||
{ | ||
settingsTab.innerHTML = this.responseText; | ||
} | ||
settingsFetchRequest.open("GET", "/settings"); | ||
settingsFetchRequest.send(); | ||
}, | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include "config.h" | ||
#include <EEPROM.h> | ||
Config::Config() { | ||
} | ||
|
||
void Config::load() { | ||
|
||
EEPROM.begin(sizeof(settings)); | ||
EEPROM.get(0, settings); | ||
if (settings.version != EEPROM_VERSION) { | ||
//defaults | ||
settings.version = EEPROM_VERSION; | ||
settings.canRXPin = GPIO_NUM_26; | ||
settings.canTXPin = GPIO_NUM_25; | ||
settings.canEnablePin = 0; | ||
} | ||
} | ||
int Config::getCanRXPin() { | ||
return settings.canRXPin; | ||
} | ||
|
||
int Config::getCanTXPin() { | ||
return settings.canTXPin; | ||
} | ||
|
||
int Config::getCanEnablePin() { | ||
return settings.canEnablePin; | ||
} | ||
|
||
|
||
void Config::setCanEnablePin(int pin) { | ||
settings.canEnablePin = pin; | ||
} | ||
|
||
void Config::setCanTXPin(int pin) { | ||
settings.canTXPin = pin; | ||
} | ||
|
||
void Config::setCanRXPin(int pin) { | ||
settings.canRXPin = pin; | ||
} | ||
|
||
void Config::saveSettings() { | ||
EEPROM.put(0, settings); //save all change to eeprom | ||
EEPROM.commit(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#ifndef CONFIG_H | ||
#define CONFIG_H | ||
|
||
#define EEPROM_VERSION 2 | ||
typedef struct { | ||
int version; | ||
int canRXPin; | ||
int canTXPin; | ||
int canEnablePin; | ||
} EEPROMSettings; | ||
|
||
|
||
class Config | ||
{ | ||
public: | ||
Config(); | ||
void load(); | ||
int getCanRXPin(); | ||
void setCanRXPin(int pin); | ||
|
||
int getCanTXPin(); | ||
void setCanTXPin(int pin); | ||
|
||
|
||
int getCanEnablePin(); | ||
void setCanEnablePin(int pin); | ||
|
||
void saveSettings(); | ||
private: | ||
EEPROMSettings settings; | ||
|
||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters