Have presentation of Fuel settings screen settled, need to allow adjustments
This commit is contained in:
parent
885573a4dc
commit
36a0755005
16 changed files with 539 additions and 241 deletions
|
@ -681,7 +681,8 @@ void loop()
|
|||
fFilteredTemperature = fFilteredTemperature * fAlpha + (1-fAlpha) * fTemperature;
|
||||
DefaultBTCParams.setTemperature_Actual((unsigned char)(fFilteredTemperature + 0.5)); // update [BTC] frame to send
|
||||
TempSensor.requestTemperatures(); // prep sensor for future reading
|
||||
reqDisplayUpdate();
|
||||
// reqDisplayUpdate();
|
||||
ScreenManager.reqUpdate();
|
||||
}
|
||||
CommState.set(CommStates::Idle);
|
||||
break;
|
||||
|
@ -875,7 +876,8 @@ void reqTempChange(int val)
|
|||
|
||||
pNVStorage->setTemperature(curTemp);
|
||||
|
||||
reqDisplayUpdate();
|
||||
// reqDisplayUpdate();
|
||||
ScreenManager.reqUpdate();
|
||||
}
|
||||
|
||||
int getSetTemp()
|
||||
|
@ -887,7 +889,7 @@ int getSetTemp()
|
|||
float getFixedHz()
|
||||
{
|
||||
if(pRxFrame) {
|
||||
return float(pRxFrame->getPump_Fixed()) / 10.f;
|
||||
return pRxFrame->getPump_Fixed();
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
@ -909,19 +911,22 @@ bool getThermostatMode()
|
|||
return pNVStorage->getThermostatMode() != 0;
|
||||
}
|
||||
|
||||
void reqDisplayUpdate()
|
||||
/*void reqDisplayUpdate()
|
||||
{
|
||||
bUpdateDisplay = true;
|
||||
}
|
||||
}*/
|
||||
|
||||
void checkDisplayUpdate()
|
||||
{
|
||||
// only update OLED when not processing blue wire
|
||||
if(bUpdateDisplay) {
|
||||
/* if(bUpdateDisplay) {
|
||||
if(pTxFrame && pRxFrame) {
|
||||
ScreenManager.update(*pTxFrame, *pRxFrame);
|
||||
bUpdateDisplay = false;
|
||||
}
|
||||
}*/
|
||||
if(pTxFrame && pRxFrame) {
|
||||
ScreenManager.checkUpdate(*pTxFrame, *pRxFrame);
|
||||
}
|
||||
|
||||
long tDelta = millis() - lastAnimationTime;
|
||||
|
@ -939,7 +944,7 @@ void reqPumpPrime(bool on)
|
|||
float getPumpHz()
|
||||
{
|
||||
if(pRxFrame) {
|
||||
return float(pRxFrame->getPump_Actual()) / 10.f;
|
||||
return pRxFrame->getPump_Actual();
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
|
|
@ -20,148 +20,5 @@
|
|||
*
|
||||
*/
|
||||
|
||||
const char MAIN_PAGE[] PROGMEM = R"=====(
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
var Socket;
|
||||
function init() {
|
||||
Socket = new WebSocket('ws://' + window.location.hostname + ':81/');
|
||||
Socket.onmessage = function(event){
|
||||
document.getElementById("TempCurrent").innerHTML = event.data;
|
||||
}
|
||||
}
|
||||
extern const char* MAIN_PAGE PROGMEM;
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style>
|
||||
.switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 60px;
|
||||
height: 34px;
|
||||
}
|
||||
|
||||
.switch input {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.slider {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #ccc;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
}
|
||||
|
||||
.slider:before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: 26px;
|
||||
width: 26px;
|
||||
left: 4px;
|
||||
bottom: 4px;
|
||||
background-color: white;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
}
|
||||
|
||||
input:checked + .slider {
|
||||
background-color: #2196F3;
|
||||
}
|
||||
|
||||
input:focus + .slider {
|
||||
box-shadow: 0 0 1px #2196F3;
|
||||
}
|
||||
|
||||
input:checked + .slider:before {
|
||||
-webkit-transform: translateX(26px);
|
||||
-ms-transform: translateX(26px);
|
||||
transform: translateX(26px);
|
||||
}
|
||||
|
||||
.slider.round {
|
||||
border-radius: 34px;
|
||||
}
|
||||
|
||||
.slider.round:before {
|
||||
border-radius: 50%;
|
||||
}
|
||||
</style>
|
||||
<title>Chinese Diesel Heater Web Controller Interface</title>
|
||||
</head>
|
||||
<body onload="javascript:init()">
|
||||
|
||||
<h1>Chinese Diesel Heater Web Control</h1>
|
||||
<div>OFF <label class="switch">
|
||||
<input type="checkbox" id="onofftoggle" onclick="OnOffCheck()">
|
||||
<span class="slider round"></span>
|
||||
</label> ON
|
||||
</div>
|
||||
<p id="text" style="display:none">Heater Is ON</p>
|
||||
<div>
|
||||
<h2>Temperature Control</h2>
|
||||
</div>
|
||||
<input id="slide" type="range" min="1" max="100" step="1" value="10">
|
||||
<div>
|
||||
<b>Desired Temp: </b>
|
||||
<Span id="sliderAmount"></Span>
|
||||
<div>
|
||||
</div>
|
||||
<b>Current Temp: </b><span id="TempCurrent">
|
||||
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
// Function to check the power on/off slide switch.
|
||||
function OnOffCheck(){
|
||||
// Get the checkbox status and place in the checkbox variable
|
||||
var checkBox = document.getElementById("onofftoggle");
|
||||
// Send a message to the Devel console of web browser for debugging
|
||||
|
||||
console.log(document.getElementById("onofftoggle").checked);
|
||||
// Get the output text
|
||||
var text = document.getElementById("text");
|
||||
// If the checkbox is checked, display the output text
|
||||
// We also need to send a message back into the esp as we cannot directly run Arduino Functions from within the javascript
|
||||
|
||||
if (checkBox.checked == true){
|
||||
//Insert Code Here To Turn On The Heater
|
||||
// Socket.send("P1");
|
||||
Socket.send("[CMD]ON");
|
||||
text.style.display = "block";
|
||||
}
|
||||
else{
|
||||
//Insert Code Here To Turn Off The Heater
|
||||
text.style.display = "none";
|
||||
// Socket.send("P0");
|
||||
Socket.send("[CMD]OFF");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
var slide = document.getElementById('slide');
|
||||
sliderDiv = document.getElementById("sliderAmount");
|
||||
|
||||
slide.oninput = function() {
|
||||
sliderDiv.innerHTML = this.value;
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
)=====";
|
|
@ -165,10 +165,10 @@ public:
|
|||
void setPump_Max(unsigned short Freq) { Controller.MaxPumpFreq = Freq; };
|
||||
void setPump_Actual(unsigned char Freq) { Heater.ActualPumpFreq = Freq; };
|
||||
void setPump_Fixed(unsigned char Freq) { Heater.FixedPumpFreq = Freq; };
|
||||
unsigned char getPump_Min() const { return Controller.MinPumpFreq; }; // Tx side, min pump freq
|
||||
unsigned char getPump_Max() const { return Controller.MaxPumpFreq; }; // Tx side, max pump freq
|
||||
unsigned char getPump_Actual() const { return Heater.ActualPumpFreq; }; // Rx style, actual
|
||||
unsigned char getPump_Fixed() const { return Heater.FixedPumpFreq; }; // Fixed mode pump frequency
|
||||
float getPump_Min() const { return float(Controller.MinPumpFreq) * 0.1f; }; // Tx side, min pump freq
|
||||
float getPump_Max() const { return float(Controller.MaxPumpFreq) * 0.1f; }; // Tx side, max pump freq
|
||||
float getPump_Actual() const { return float(Heater.ActualPumpFreq) * 0.1f; }; // Rx style, actual
|
||||
float getPump_Fixed() const { return float(Heater.FixedPumpFreq) * 0.1f; }; // Fixed mode pump frequency
|
||||
void setPump_Prime(bool on) { Controller.Prime = on ? 0x5A : 0; };
|
||||
// temperature set/get
|
||||
void setTemperature_Desired(unsigned char degC) { Controller.DesiredTemperature = degC; };
|
||||
|
|
|
@ -90,7 +90,7 @@ CScreen1::show(const CProtocol& CtlFrame, const CProtocol& HtrFrame)
|
|||
if(CtlFrame.isThermostat())
|
||||
desiredT = CtlFrame.getTemperature_Desired();
|
||||
else
|
||||
desiredT = -HtrFrame.getPump_Fixed() * 0.1f;
|
||||
desiredT = -HtrFrame.getPump_Fixed();
|
||||
}
|
||||
|
||||
showThermometer(desiredT, // read values from most recently sent [BTC] frame
|
||||
|
@ -108,7 +108,7 @@ CScreen1::show(const CProtocol& CtlFrame, const CProtocol& HtrFrame)
|
|||
|
||||
showFan(HtrFrame.getFan_Actual());
|
||||
|
||||
showFuel(HtrFrame.getPump_Actual() * 0.1f);
|
||||
showFuel(HtrFrame.getPump_Actual());
|
||||
|
||||
showBodyThermometer(HtrFrame.getTemperature_HeatExchg());
|
||||
}
|
||||
|
|
|
@ -133,6 +133,13 @@ CScreen2::show(const CProtocol& CtlFrame, const CProtocol& HtrFrame)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
CScreen2::animate()
|
||||
{
|
||||
// do nothing!!
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
CScreen2::keyHandler(uint8_t event)
|
||||
{
|
||||
|
@ -146,7 +153,8 @@ CScreen2::keyHandler(uint8_t event)
|
|||
else {
|
||||
_showMode = millis() + 5000;
|
||||
_nModeSel = 0;
|
||||
reqDisplayUpdate();
|
||||
// reqDisplayUpdate();
|
||||
_Manager.reqUpdate();
|
||||
}
|
||||
}
|
||||
// press RIGHT to selecxt next screen, or Thermostat mode when in mode select
|
||||
|
@ -156,7 +164,8 @@ CScreen2::keyHandler(uint8_t event)
|
|||
else {
|
||||
_showMode = millis() + 5000;
|
||||
_nModeSel = 1;
|
||||
reqDisplayUpdate();
|
||||
// reqDisplayUpdate();
|
||||
_Manager.reqUpdate();
|
||||
}
|
||||
}
|
||||
// press UP & DOWN to toggle thermostat / fixed Hz mode
|
||||
|
@ -219,7 +228,8 @@ CScreen2::keyHandler(uint8_t event)
|
|||
}
|
||||
_showSetMode = millis() + 2000;
|
||||
}
|
||||
reqDisplayUpdate();
|
||||
// reqDisplayUpdate();
|
||||
_Manager.reqUpdate();
|
||||
}
|
||||
|
||||
repeatCount = -1;
|
||||
|
|
|
@ -35,6 +35,6 @@ class CScreen2 : public CScreen
|
|||
public:
|
||||
CScreen2(C128x64_OLED& display, CScreenManager& mgr);
|
||||
void show(const CProtocol& CtlFrame, const CProtocol& HtrFrame);
|
||||
void animate() {};
|
||||
void animate();
|
||||
void keyHandler(uint8_t event);
|
||||
};
|
||||
|
|
|
@ -29,7 +29,7 @@ const int border = 3;
|
|||
const int radius = 4;
|
||||
const int Row[] = { 52, 40, 28, 16 } ;
|
||||
const int Col[] = { border, 70, 100};
|
||||
const char* Label0 = "Prev/Next Screen";
|
||||
const char* Label0 = "<- ->";
|
||||
const char* Label1[] = { "Thermostat",
|
||||
"Fixed Hz" };
|
||||
const char* Label2[] = { "Prime pump",
|
||||
|
@ -51,6 +51,7 @@ CScreen3::show(const CProtocol& CtlFrame, const CProtocol& HtrFrame)
|
|||
{
|
||||
CScreen::show(CtlFrame, HtrFrame);
|
||||
|
||||
// show next/prev screen navigation line
|
||||
CRect extents;
|
||||
_display.setCursor(_display.xCentre(), Row[0]);
|
||||
_display.printCentreJustified(Label0);
|
||||
|
@ -138,6 +139,13 @@ CScreen3::show(const CProtocol& CtlFrame, const CProtocol& HtrFrame)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
CScreen3::animate()
|
||||
{
|
||||
// do nothing!!
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
CScreen3::keyHandler(uint8_t event)
|
||||
{
|
||||
|
@ -203,7 +211,8 @@ CScreen3::keyHandler(uint8_t event)
|
|||
stopPump();
|
||||
}
|
||||
|
||||
reqDisplayUpdate();
|
||||
// reqDisplayUpdate();
|
||||
_Manager.reqUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,6 @@ class CScreen3 : public CScreen {
|
|||
public:
|
||||
CScreen3(C128x64_OLED& display, CScreenManager& mgr);
|
||||
void show(const CProtocol& CtlFrame, const CProtocol& HtrFrame);
|
||||
void animate() {};
|
||||
void animate();
|
||||
void keyHandler(uint8_t event);
|
||||
};
|
||||
|
|
|
@ -53,6 +53,13 @@ CScreen4::show(const CProtocol& CtlFrame, const CProtocol& HtrFrame)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
CScreen4::animate()
|
||||
{
|
||||
// do nothing!!
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
CScreen4::keyHandler(uint8_t event)
|
||||
{
|
||||
|
|
|
@ -29,6 +29,6 @@ class CScreen4 : public CScreen {
|
|||
public:
|
||||
CScreen4(C128x64_OLED& display, CScreenManager& mgr);
|
||||
void show(const CProtocol& CtlFrame, const CProtocol& HtrFrame);
|
||||
void animate() {};
|
||||
void animate();
|
||||
void keyHandler(uint8_t event);
|
||||
};
|
||||
|
|
263
Arduino/BTCDieselHeater/Screen5.cpp
Normal file
263
Arduino/BTCDieselHeater/Screen5.cpp
Normal file
|
@ -0,0 +1,263 @@
|
|||
/*
|
||||
* This file is part of the "bluetoothheater" distribution
|
||||
* (https://gitlab.com/mrjones.id.au/bluetoothheater)
|
||||
*
|
||||
* Copyright (C) 2018 Ray Jones <ray@mrjones.id.au>
|
||||
*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "128x64OLED.h"
|
||||
#include "display.h"
|
||||
#include "KeyPad.h"
|
||||
#include "helpers.h"
|
||||
#include "Screen5.h"
|
||||
#include "BTCWifi.h"
|
||||
|
||||
|
||||
CScreen5::CScreen5(C128x64_OLED& display, CScreenManager& mgr) : CScreen(display, mgr)
|
||||
{
|
||||
_bPWOK = false;
|
||||
_rowSel = 0;
|
||||
_colSel = 0;
|
||||
for(int i= 0; i < 4; i++)
|
||||
_PWdig[i] = -1;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CScreen5::show(const CProtocol& CtlFrame, const CProtocol& HtrFrame)
|
||||
{
|
||||
CScreen::show(CtlFrame, HtrFrame);
|
||||
|
||||
CRect extents;
|
||||
|
||||
_display.setCursor(0, 16);
|
||||
_display.print("Fuel Settings:");
|
||||
|
||||
if(_rowSel == 1) {
|
||||
_display.setCursor(0, 30);
|
||||
_display.print("Enter password...");
|
||||
_showPassword();
|
||||
}
|
||||
else {
|
||||
char str[16];
|
||||
int yPos = 28;
|
||||
const int border = 4;
|
||||
const int radius = 4;
|
||||
const int col2 = 90;
|
||||
const int col3 = _display.width() - border;
|
||||
CRect extents;
|
||||
_display.setCursor(0, yPos);
|
||||
_display.print("Pump (Hz)");
|
||||
_display.setCursor(col2, yPos);
|
||||
sprintf(str, "%.1f", CtlFrame.getPump_Min());
|
||||
_display.printRightJustified(str);
|
||||
if(_rowSel == 3 && _colSel == 0) {
|
||||
_display.getTextExtents(str, extents);
|
||||
extents.xPos = col2 - extents.width;
|
||||
extents.yPos = yPos;
|
||||
extents.Expand(border);
|
||||
_display.drawRoundRect(extents.xPos, extents.yPos, extents.width, extents.height, radius, WHITE);
|
||||
}
|
||||
_display.setCursor(col3, yPos);
|
||||
sprintf(str, "%.1f", CtlFrame.getPump_Max());
|
||||
_display.printRightJustified(str);
|
||||
if(_rowSel == 3 && _colSel == 1) {
|
||||
_display.getTextExtents(str, extents);
|
||||
extents.xPos = col3 - extents.width;
|
||||
extents.yPos = yPos;
|
||||
extents.Expand(border);
|
||||
_display.drawRoundRect(extents.xPos, extents.yPos, extents.width, extents.height, radius, WHITE);
|
||||
}
|
||||
yPos = 40;
|
||||
_display.setCursor(0, yPos);
|
||||
_display.print("Fan (RPM)");
|
||||
_display.setCursor(col2, yPos);
|
||||
sprintf(str, "%d", CtlFrame.getFan_Min());
|
||||
_display.printRightJustified(str);
|
||||
if(_rowSel == 2 && _colSel == 0) {
|
||||
_display.getTextExtents(str, extents);
|
||||
extents.xPos = col2 - extents.width;
|
||||
extents.yPos = yPos;
|
||||
extents.Expand(border);
|
||||
_display.drawRoundRect(extents.xPos, extents.yPos, extents.width, extents.height, radius, WHITE);
|
||||
}
|
||||
_display.setCursor(col3, yPos);
|
||||
sprintf(str, "%d", CtlFrame.getFan_Max());
|
||||
_display.printRightJustified(str);
|
||||
if(_rowSel == 2 && _colSel == 1) {
|
||||
_display.getTextExtents(str, extents);
|
||||
extents.xPos = col3 - extents.width;
|
||||
extents.yPos = yPos;
|
||||
extents.Expand(border);
|
||||
_display.drawRoundRect(extents.xPos, extents.yPos, extents.width, extents.height, radius, WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
_display.display();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CScreen5::animate()
|
||||
{
|
||||
// do nothing!!
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
CScreen5::keyHandler(uint8_t event)
|
||||
{
|
||||
if(event & keyPressed) {
|
||||
// press CENTRE
|
||||
if(event & key_Centre) {
|
||||
if(_rowSel == 1) {
|
||||
// match "1688"
|
||||
if((_PWdig[0] == 1) &&
|
||||
(_PWdig[1] == 6) &&
|
||||
(_PWdig[2] == 8) &&
|
||||
(_PWdig[3] == 8)) {
|
||||
_bPWOK = true;
|
||||
_rowSel = 2;
|
||||
_colSel = 0;
|
||||
}
|
||||
else {
|
||||
for(int i= 0; i < 4; i++)
|
||||
_PWdig[i] = -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
_bPWOK = false;
|
||||
_rowSel = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
// press LEFT
|
||||
if(event & key_Left) {
|
||||
switch(_rowSel) {
|
||||
case 0:
|
||||
_Manager.prevScreen();
|
||||
break;
|
||||
case 1:
|
||||
_colSel--;
|
||||
LOWERLIMIT(_colSel, 0);
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
_colSel = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// press RIGHT
|
||||
if(event & key_Right) {
|
||||
switch(_rowSel) {
|
||||
case 0:
|
||||
_Manager.nextScreen();
|
||||
break;
|
||||
case 1:
|
||||
_colSel++;
|
||||
UPPERLIMIT(_colSel, 3);
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
_colSel = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// press UP
|
||||
if(event & key_Up) {
|
||||
switch(_rowSel) {
|
||||
case 0:
|
||||
_rowSel = 1;
|
||||
_colSel = 0;
|
||||
break;
|
||||
case 1:
|
||||
_PWdig[_colSel]++;
|
||||
ROLLUPPERLIMIT(_PWdig[_colSel], 9, 0);
|
||||
break;
|
||||
case 2:
|
||||
_rowSel = 3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// press DOWN
|
||||
if(event & key_Down) {
|
||||
switch(_rowSel) {
|
||||
case 1:
|
||||
_PWdig[_colSel]--;
|
||||
ROLLLOWERLIMIT(_PWdig[_colSel], 0, 9);
|
||||
break;
|
||||
case 2:
|
||||
_rowSel--; // force skip over line 1 (password)
|
||||
// deliberately not breaking
|
||||
case 3:
|
||||
_rowSel--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
_Manager.reqUpdate();
|
||||
}
|
||||
|
||||
// escape PW entry by holding centre button
|
||||
if(event & keyRepeat) {
|
||||
if(event & key_Centre) {
|
||||
_rowSel == 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CScreen5::_showPassword()
|
||||
{
|
||||
// determine metrics of character sizing
|
||||
CRect extents;
|
||||
_display.getTextExtents("X", extents);
|
||||
int charWidth = extents.width;
|
||||
_display.getTextExtents(" ", extents);
|
||||
int spaceWidth = extents.width;
|
||||
|
||||
const int border = 3;
|
||||
const int radius = 4;
|
||||
|
||||
for(int i =0 ; i < 4; i++) {
|
||||
|
||||
int xPos = _display.xCentre() - (2 - i) * (charWidth + spaceWidth);
|
||||
// Serial.print(" xPos="); Serial.print(xPos);
|
||||
char str[8];
|
||||
|
||||
if(_PWdig[i] < 0) {
|
||||
strcpy(str, "-");
|
||||
}
|
||||
else {
|
||||
sprintf(str, "%d", _PWdig[i]);
|
||||
}
|
||||
_display.getTextExtents(str, extents);
|
||||
extents.xPos = xPos;
|
||||
extents.yPos = 46;
|
||||
if(_rowSel == 1 && _colSel == i) {
|
||||
// draw selection box
|
||||
extents.Expand(border);
|
||||
_display.drawRoundRect(extents.xPos, extents.yPos, extents.width, extents.height, radius, WHITE);
|
||||
// // draw white background
|
||||
// extents.Expand(1);
|
||||
// _display.fillRect(extents.xPos, extents.yPos, extents.width, extents.height, WHITE);
|
||||
extents.Expand(-border);
|
||||
}
|
||||
_display.setCursor(extents.xPos, extents.yPos);
|
||||
_display.print(str);
|
||||
}
|
||||
// Serial.println("");
|
||||
}
|
39
Arduino/BTCDieselHeater/Screen5.h
Normal file
39
Arduino/BTCDieselHeater/Screen5.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* This file is part of the "bluetoothheater" distribution
|
||||
* (https://gitlab.com/mrjones.id.au/bluetoothheater)
|
||||
*
|
||||
* Copyright (C) 2018 Ray Jones <ray@mrjones.id.au>
|
||||
*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
class C128x64_OLED;
|
||||
class CScreenManager;
|
||||
class CProtocol;
|
||||
|
||||
class CScreen5 : public CScreen {
|
||||
bool _bPWOK;
|
||||
int _PWdig[4];
|
||||
int _rowSel;
|
||||
int _colSel;
|
||||
void _showPassword();
|
||||
public:
|
||||
CScreen5(C128x64_OLED& display, CScreenManager& mgr);
|
||||
void show(const CProtocol& CtlFrame, const CProtocol& HtrFrame);
|
||||
void animate();
|
||||
void keyHandler(uint8_t event);
|
||||
};
|
|
@ -35,6 +35,7 @@
|
|||
#include "Screen2.h"
|
||||
#include "Screen3.h"
|
||||
#include "Screen4.h"
|
||||
#include "Screen5.h"
|
||||
#include "KeyPad.h"
|
||||
#include "helpers.h"
|
||||
#include "clock.h"
|
||||
|
@ -65,6 +66,15 @@
|
|||
// 128 x 64 OLED support
|
||||
SPIClass SPI; // default constructor opens HSPI on standard pins : MOSI=13,CLK=14,MISO=12(unused)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// splash creen created using image2cpp http://javl.github.io/image2cpp/
|
||||
// Settings:
|
||||
// Black background
|
||||
// Invert [X]
|
||||
// Arduino code, single bitmap
|
||||
// Identifier: DieselSplash
|
||||
// Draw Mode: Horizontal
|
||||
//
|
||||
const unsigned char DieselSplash [] PROGMEM = {
|
||||
// 'Splash2, 128x64px
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
@ -132,75 +142,7 @@ const unsigned char DieselSplash [] PROGMEM = {
|
|||
0x11, 0x49, 0x92, 0x94, 0xa1, 0x21, 0x14, 0x25, 0x10, 0x80, 0x85, 0x29, 0x44, 0x25, 0x50, 0x80,
|
||||
0x11, 0x39, 0x8e, 0x93, 0x18, 0xe1, 0x13, 0x1c, 0xcc, 0x80, 0x78, 0xc9, 0x34, 0x19, 0x4c, 0x80
|
||||
};
|
||||
/*
|
||||
// 'Splash2', 128x64px
|
||||
const uint8_t DieselSplash[SH1106_LCDHEIGHT * SH1106_LCDWIDTH / 8] PROGMEM = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x20, 0x10, 0x88, 0x48, 0x48, 0x48, 0x48, 0x48, 0x88,
|
||||
0x10, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x40, 0x40, 0x40, 0x40,
|
||||
0x40, 0x20, 0x20, 0x20, 0x20, 0x20, 0x10, 0x10, 0x10, 0x10, 0x10, 0x20, 0x20, 0x40, 0x40, 0x80,
|
||||
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x02, 0x12, 0x02, 0x04, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xc0, 0x40, 0xc0, 0x40, 0x20, 0x20, 0x20, 0x20, 0x20, 0x10, 0x10, 0x10, 0x10,
|
||||
0x10, 0x08, 0x08, 0x08, 0x18, 0x68, 0x88, 0x04, 0x04, 0x04, 0x04, 0x04, 0x02, 0x02, 0x02, 0x02,
|
||||
0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x01, 0x02, 0x02, 0x0c, 0x10, 0x20, 0xe0, 0x20, 0x20, 0x20, 0x60, 0x80, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xa0, 0xfe, 0x44, 0xa8, 0x10, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x80, 0x70, 0x0e, 0x01, 0x00, 0x00, 0x01, 0x02, 0x04, 0x18, 0x20, 0xc0, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x00,
|
||||
0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x40, 0x40, 0x40, 0x40, 0x40, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x04, 0x04, 0x04, 0x04, 0x04, 0x02,
|
||||
0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x3e, 0xc0, 0x00, 0x00, 0x03, 0x1c, 0xe0, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0f, 0x04, 0x02, 0x01, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x60, 0x60, 0xd0, 0x90, 0x0c,
|
||||
0x13, 0x60, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x40, 0x20, 0x20, 0x10, 0x13, 0xfc, 0x08, 0x08,
|
||||
0x08, 0x08, 0x04, 0x04, 0x04, 0x04, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x03,
|
||||
0x05, 0x04, 0x08, 0x08, 0x10, 0x20, 0x20, 0x40, 0x40, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x40,
|
||||
0x40, 0x40, 0x20, 0x20, 0x20, 0x20, 0x10, 0x10, 0x10, 0xff, 0x20, 0x20, 0x20, 0x10, 0x0f, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xc0, 0x80, 0x00, 0x00, 0x01, 0x07,
|
||||
0xfe, 0x02, 0x02, 0x03, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02,
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x3c, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x06, 0x0c, 0x0c, 0x0e,
|
||||
0x0f, 0x08, 0x08, 0x08, 0x1f, 0x20, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x40, 0x40, 0x40, 0x40, 0x40, 0xe0,
|
||||
0x20, 0x20, 0x20, 0x20, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x04, 0x04,
|
||||
0x04, 0x04, 0x04, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x04, 0x08, 0x1e, 0x11, 0x10,
|
||||
0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x04, 0x04, 0x04, 0x04, 0x04, 0x02, 0x1e, 0x22, 0x22, 0x22,
|
||||
0x21, 0x31, 0x1f, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x04, 0x06, 0x03,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xfc, 0x12, 0x11, 0x12, 0xfc, 0x00, 0x70, 0x88, 0x88, 0xfe, 0x00, 0x38, 0xc0,
|
||||
0xc0, 0x38, 0x00, 0x70, 0x88, 0x88, 0xf8, 0x00, 0xf0, 0x08, 0x08, 0xf8, 0x00, 0x70, 0x88, 0x88,
|
||||
0x50, 0x00, 0x70, 0xa8, 0xa8, 0x30, 0x00, 0x70, 0x88, 0x88, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff,
|
||||
0x10, 0x10, 0x10, 0xff, 0x00, 0x70, 0xa8, 0xa8, 0x30, 0x00, 0x70, 0x88, 0x88, 0xf8, 0x00, 0x7e,
|
||||
0x88, 0x88, 0x00, 0x70, 0xa8, 0xa8, 0x30, 0x00, 0xf8, 0x10, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00,
|
||||
0x7e, 0x81, 0x81, 0x81, 0x81, 0x42, 0x00, 0x70, 0x88, 0x88, 0x70, 0x00, 0xf0, 0x08, 0x08, 0xf8,
|
||||
0x00, 0x7e, 0x88, 0x88, 0x00, 0xf8, 0x10, 0x08, 0x08, 0x00, 0x70, 0x88, 0x88, 0x70, 0x00, 0xfe,
|
||||
0x00, 0xfe, 0x00, 0x70, 0xa8, 0xa8, 0x30, 0x00, 0xf8, 0x10, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
*/
|
||||
|
||||
CScreenManager::CScreenManager()
|
||||
{
|
||||
_pDisplay = NULL;
|
||||
|
@ -208,6 +150,7 @@ CScreenManager::CScreenManager()
|
|||
for(int i = 0; i < _maxScreens; i++)
|
||||
_pScreen[i] = NULL;
|
||||
_currentScreen = 1;
|
||||
_bReqUpdate = false;
|
||||
}
|
||||
|
||||
CScreenManager::~CScreenManager()
|
||||
|
@ -250,14 +193,26 @@ CScreenManager::init()
|
|||
_pScreen[1] = new CScreen2(*_pDisplay, *this);
|
||||
_pScreen[2] = new CScreen3(*_pDisplay, *this);
|
||||
_pScreen[3] = new CScreen4(*_pDisplay, *this);
|
||||
_pScreen[4] = new CScreen5(*_pDisplay, *this);
|
||||
|
||||
_switchScreen();
|
||||
}
|
||||
|
||||
void
|
||||
CScreenManager::update(const CProtocol& CtlFrame, const CProtocol& HtrFrame)
|
||||
CScreenManager::checkUpdate(const CProtocol& CtlFrame, const CProtocol& HtrFrame)
|
||||
{
|
||||
if(_pActiveScreen) _pActiveScreen->show(CtlFrame, HtrFrame);
|
||||
if(_bReqUpdate) {
|
||||
if(_pActiveScreen) {
|
||||
_pActiveScreen->show(CtlFrame, HtrFrame);
|
||||
_bReqUpdate = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CScreenManager::reqUpdate()
|
||||
{
|
||||
_bReqUpdate = true;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -272,7 +227,8 @@ CScreenManager::_switchScreen()
|
|||
if(_currentScreen < _maxScreens)
|
||||
_pActiveScreen = _pScreen[_currentScreen];
|
||||
|
||||
reqDisplayUpdate();
|
||||
// reqDisplayUpdate();
|
||||
reqUpdate();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -30,21 +30,23 @@ class C128x64_OLED;
|
|||
class CScreen;
|
||||
|
||||
class CScreenManager {
|
||||
static const int _maxScreens = 4;
|
||||
static const int _maxScreens = 5;
|
||||
CScreen* _pScreen[_maxScreens];
|
||||
CScreen* _pActiveScreen;
|
||||
C128x64_OLED* _pDisplay;
|
||||
int _currentScreen;
|
||||
bool _bReqUpdate;
|
||||
void _switchScreen();
|
||||
public:
|
||||
CScreenManager();
|
||||
~CScreenManager();
|
||||
void init();
|
||||
void update(const CProtocol& CtlFrame, const CProtocol& HtrFrame);
|
||||
void checkUpdate(const CProtocol& CtlFrame, const CProtocol& HtrFrame);
|
||||
void animate();
|
||||
void nextScreen();
|
||||
void prevScreen();
|
||||
void keyHandler(uint8_t event);
|
||||
void reqUpdate();
|
||||
};
|
||||
|
||||
class CScreen {
|
||||
|
|
|
@ -27,7 +27,7 @@ extern int getRunState();
|
|||
extern int getErrState();
|
||||
extern void reqTempChange(int val);
|
||||
extern int getSetTemp();
|
||||
extern void reqDisplayUpdate();
|
||||
//extern void reqDisplayUpdate();
|
||||
extern void reqThermoToggle();
|
||||
extern void setThermostatMode(unsigned char);
|
||||
extern bool getThermostatMode();
|
||||
|
@ -38,3 +38,5 @@ extern float getActualTemperature();
|
|||
|
||||
#define LOWERLIMIT(A, B) if(A < B) A = B
|
||||
#define UPPERLIMIT(A, B) if(A > B) A = B
|
||||
#define ROLLUPPERLIMIT(A, B, C) if(A > B) A = C
|
||||
#define ROLLLOWERLIMIT(A, B, C) if(A < B) A = C
|
||||
|
|
148
Arduino/BTCDieselHeater/mainpage.cpp
Normal file
148
Arduino/BTCDieselHeater/mainpage.cpp
Normal file
|
@ -0,0 +1,148 @@
|
|||
#include <Arduino.h>
|
||||
|
||||
const char* MAIN_PAGE PROGMEM = R"=====(
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
var Socket;
|
||||
function init() {
|
||||
Socket = new WebSocket('ws://' + window.location.hostname + ':81/');
|
||||
Socket.onmessage = function(event){
|
||||
document.getElementById("TempCurrent").innerHTML = event.data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style>
|
||||
.switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 60px;
|
||||
height: 34px;
|
||||
}
|
||||
|
||||
.switch input {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.slider {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #ccc;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
}
|
||||
|
||||
.slider:before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: 26px;
|
||||
width: 26px;
|
||||
left: 4px;
|
||||
bottom: 4px;
|
||||
background-color: white;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
}
|
||||
|
||||
input:checked + .slider {
|
||||
background-color: #2196F3;
|
||||
}
|
||||
|
||||
input:focus + .slider {
|
||||
box-shadow: 0 0 1px #2196F3;
|
||||
}
|
||||
|
||||
input:checked + .slider:before {
|
||||
-webkit-transform: translateX(26px);
|
||||
-ms-transform: translateX(26px);
|
||||
transform: translateX(26px);
|
||||
}
|
||||
|
||||
.slider.round {
|
||||
border-radius: 34px;
|
||||
}
|
||||
|
||||
.slider.round:before {
|
||||
border-radius: 50%;
|
||||
}
|
||||
</style>
|
||||
<title>Chinese Diesel Heater Web Controller Interface</title>
|
||||
</head>
|
||||
<body onload="javascript:init()">
|
||||
|
||||
<h1>Chinese Diesel Heater Web Control</h1>
|
||||
<div>OFF <label class="switch">
|
||||
<input type="checkbox" id="onofftoggle" onclick="OnOffCheck()">
|
||||
<span class="slider round"></span>
|
||||
</label> ON
|
||||
</div>
|
||||
<p id="text" style="display:none">Heater Is ON</p>
|
||||
<div>
|
||||
<h2>Temperature Control</h2>
|
||||
</div>
|
||||
<input id="slide" type="range" min="1" max="100" step="1" value="10">
|
||||
<div>
|
||||
<b>Desired Temp: </b>
|
||||
<Span id="sliderAmount"></Span>
|
||||
<div>
|
||||
</div>
|
||||
<b>Current Temp: </b><span id="TempCurrent">
|
||||
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
// Function to check the power on/off slide switch.
|
||||
function OnOffCheck(){
|
||||
// Get the checkbox status and place in the checkbox variable
|
||||
var checkBox = document.getElementById("onofftoggle");
|
||||
// Send a message to the Devel console of web browser for debugging
|
||||
|
||||
console.log(document.getElementById("onofftoggle").checked);
|
||||
// Get the output text
|
||||
var text = document.getElementById("text");
|
||||
// If the checkbox is checked, display the output text
|
||||
// We also need to send a message back into the esp as we cannot directly run Arduino Functions from within the javascript
|
||||
|
||||
if (checkBox.checked == true){
|
||||
//Insert Code Here To Turn On The Heater
|
||||
// Socket.send("P1");
|
||||
Socket.send("[CMD]ON");
|
||||
text.style.display = "block";
|
||||
}
|
||||
else{
|
||||
//Insert Code Here To Turn Off The Heater
|
||||
text.style.display = "none";
|
||||
// Socket.send("P0");
|
||||
Socket.send("[CMD]OFF");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
var slide = document.getElementById('slide');
|
||||
sliderDiv = document.getElementById("sliderAmount");
|
||||
|
||||
slide.oninput = function() {
|
||||
sliderDiv.innerHTML = this.value;
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
)=====";
|
||||
|
Loading…
Reference in a new issue