mirror of https://github.com/lumapu/ahoy.git
lumapu
3 years ago
12 changed files with 232 additions and 16 deletions
@ -0,0 +1,87 @@ |
|||
#ifndef __HM1200_DECODE__ |
|||
#define __HM1200_DECODE__ |
|||
|
|||
typedef struct { |
|||
double u; |
|||
double i; |
|||
double p; |
|||
uint16_t y_d; // yield day
|
|||
double y_t; // yield total
|
|||
} ch_t; |
|||
|
|||
typedef struct { |
|||
ch_t ch_dc[4]; |
|||
ch_t ch_ac; |
|||
double temp; |
|||
double pct; |
|||
double acFreq; |
|||
} hoyData_t; |
|||
|
|||
class hm1200Decode { |
|||
public: |
|||
hm1200Decode() { |
|||
memset(&mData, 0, sizeof(hoyData_t)); |
|||
} |
|||
~hm1200Decode() {} |
|||
|
|||
void convert(uint8_t buf[], uint8_t len) { |
|||
switch(buf[0]) { |
|||
case 0x01: convCmd01(buf, len); break; |
|||
case 0x02: convCmd02(buf, len); break; |
|||
case 0x03: convCmd03(buf, len); break; |
|||
case 0x84: convCmd84(buf, len); break; |
|||
default: break; |
|||
} |
|||
} |
|||
|
|||
|
|||
hoyData_t mData; |
|||
|
|||
private: |
|||
void convCmd01(uint8_t buf[], uint8_t len) { |
|||
mData.ch_dc[0].u = ((buf[ 3] << 8) | buf[ 4]) / 10.0f; |
|||
mData.ch_dc[0].i = ((buf[ 5] << 8) | buf[ 6]) / 100.0f; |
|||
mData.ch_dc[1].i = ((buf[ 7] << 8) | buf[ 8]) / 100.0f; |
|||
mData.ch_dc[0].p = ((buf[ 9] << 8) | buf[10]) / 10.0f; |
|||
mData.ch_dc[1].p = ((buf[11] << 8) | buf[12]) / 10.0f; |
|||
mData.ch_dc[0].y_t = ((buf[13] << 24) | (buf[14] << 16) |
|||
| (buf[15] << 8) | buf[16]) / 1000.0f; |
|||
} |
|||
|
|||
|
|||
void convCmd02(uint8_t buf[], uint8_t len) { |
|||
mData.ch_dc[1].y_t = ((buf[ 1] << 24) | (buf[ 2] << 16) |
|||
| (buf[ 3] << 8) | buf[ 4]) / 1000.0f; |
|||
mData.ch_dc[0].y_d = ((buf[ 5] << 8) | buf[ 6]); |
|||
mData.ch_dc[1].y_d = ((buf[ 7] << 8) | buf[ 8]); |
|||
mData.ch_dc[1].u = ((buf[ 9] << 8) | buf[10]) / 10.0f; |
|||
mData.ch_dc[2].i = ((buf[11] << 8) | buf[12]) / 100.0f; |
|||
mData.ch_dc[3].i = ((buf[13] << 8) | buf[14]) / 100.0f; |
|||
mData.ch_dc[2].p = ((buf[15] << 8) | buf[16]) / 10.0f; |
|||
} |
|||
|
|||
|
|||
void convCmd03(uint8_t buf[], uint8_t len) { |
|||
mData.ch_dc[3].p = ((buf[ 1] << 8) | buf[ 2]) / 10.0f; |
|||
mData.ch_dc[2].y_t = ((buf[ 3] << 24) | (buf[4] << 16) |
|||
| (buf[ 5] << 8) | buf[ 6]) / 1000.0f; |
|||
mData.ch_dc[3].y_t = ((buf[ 7] << 24) | (buf[8] << 16) |
|||
| (buf[ 9] << 8) | buf[10]) / 1000.0f; |
|||
mData.ch_dc[2].y_d = ((buf[11] << 8) | buf[12]); |
|||
mData.ch_dc[3].y_d = ((buf[13] << 8) | buf[14]); |
|||
mData.ch_ac.u = ((buf[15] << 8) | buf[16]) / 10.0f; |
|||
} |
|||
|
|||
|
|||
void convCmd84(uint8_t buf[], uint8_t len) { |
|||
mData.acFreq = ((buf[ 1] << 8) | buf[ 2]) / 100.0f; |
|||
mData.ch_ac.p = ((buf[ 3] << 8) | buf[ 4]) / 10.0f; |
|||
mData.ch_ac.i = ((buf[ 7] << 8) | buf[ 8]) / 100.0f; |
|||
mData.pct = ((buf[ 9] << 8) | buf[10]) / 10.0f; |
|||
mData.temp = ((buf[11] << 8) | buf[12]) / 10.0f; |
|||
} |
|||
|
|||
// private member variables
|
|||
}; |
|||
|
|||
#endif /*__HM1200_DECODE__*/ |
@ -1,4 +1,5 @@ |
|||
..\tools\fileConv.exe index.html h\index_html.h index_html |
|||
..\tools\fileConv.exe setup.html h\setup_html.h setup_html |
|||
..\tools\fileConv.exe hoymiles.html h\hoymiles_html.h hoymiles_html |
|||
..\tools\fileConv.exe style.css h\style_css.h style_css |
|||
pause |
|||
|
@ -0,0 +1 @@ |
|||
String hoymiles_html = "<!doctype html><html><head><title>Index - {DEVICE}</title><link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\"/><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><script type=\"text/javascript\"> getAjax('/livedata', 'livedata') window.setInterval(\"getAjax('/livedata', 'livedata')\", 10000); function getAjax(url, resid) { var http = null; http = new XMLHttpRequest(); if(http != null) { http.open(\"GET\", url, true); http.onreadystatechange = print; http.send(null); } function print() { if(http.readyState == 4) { document.getElementById(resid).innerHTML = http.responseText; } } } </script><style type=\"text/css\"></style></head><body><h1>AHOY - {DEVICE}</h1><div id=\"content\" class=\"content\"><p><a href=\"/\">Home</a><br/></p><div id=\"livedata\"></div><p>Every 10 seconds the values are updated</p></div><div id=\"footer\"><p class=\"left\">© 2022</p><p class=\"right\">AHOY :: {VERSION}</p></div></body></html>"; |
@ -1 +1 @@ |
|||
String index_html = "<!doctype html><html><head><title>Index - {DEVICE}</title><link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\"/><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><script type=\"text/javascript\"> window.setInterval(\"getAjax('/uptime', 'uptime')\", 1000); window.setInterval(\"getAjax('/time', 'time')\", 1000); window.setInterval(\"getAjax('/cmdstat', 'cmds')\", 2000); function getAjax(url, resid) { var http = null; http = new XMLHttpRequest(); if(http != null) { http.open(\"GET\", url, true); http.onreadystatechange = print; http.send(null); } function print() { if(http.readyState == 4) { document.getElementById(resid).innerHTML = http.responseText; } } } </script></head><body><h1>AHOY - {DEVICE}</h1><div id=\"content\" class=\"content\"><p><a href=\"/update\">Update</a><br/><br/><a href=\"/setup\">Setup</a><br/><a href=\"/reboot\">Reboot</a></p><p><span class=\"des\">Uptime: </span><span id=\"uptime\"></span></p><p><span class=\"des\">Time: </span><span id=\"time\"></span></p><p><span class=\"des\">Statistics: </span><pre id=\"cmds\"></pre></p></div><div id=\"footer\"><p class=\"left\">© 2022</p><p class=\"right\">AHOY :: {VERSION}</p></div></body></html>"; |
|||
String index_html = "<!doctype html><html><head><title>Index - {DEVICE}</title><link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\"/><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><script type=\"text/javascript\"> window.setInterval(\"getAjax('/uptime', 'uptime')\", 1000); window.setInterval(\"getAjax('/time', 'time')\", 1000); window.setInterval(\"getAjax('/cmdstat', 'cmds')\", 2000); function getAjax(url, resid) { var http = null; http = new XMLHttpRequest(); if(http != null) { http.open(\"GET\", url, true); http.onreadystatechange = print; http.send(null); } function print() { if(http.readyState == 4) { document.getElementById(resid).innerHTML = http.responseText; } } } </script></head><body><h1>AHOY - {DEVICE}</h1><div id=\"content\" class=\"content\"><p><a href=\"/hoymiles\">Hoymiles</a><br/><a href=\"/update\">Update</a><br/><br/><a href=\"/setup\">Setup</a><br/><a href=\"/reboot\">Reboot</a></p><p><span class=\"des\">Uptime: </span><span id=\"uptime\"></span></p><p><span class=\"des\">Time: </span><span id=\"time\"></span></p><p><span class=\"des\">Statistics: </span><pre id=\"cmds\"></pre></p></div><div id=\"footer\"><p class=\"left\">© 2022</p><p class=\"right\">AHOY :: {VERSION}</p></div></body></html>"; |
|||
|
@ -1 +1 @@ |
|||
String style_css = "h1 { margin: 0; padding: 20pt; font-size: 22pt; color: #fff; background-color: #006ec0; display: block; text-transform: uppercase; } html, body { font-family: Arial; margin: 0; padding: 0; } p { text-align: justify; font-size: 13pt; } .des { font-size: 14pt; color: #006ec0; padding-bottom: 0px !important; } .fw { width: 60px; display: block; float: left; } .color { width: 50px; height: 50px; border: 1px solid #ccc; } .range { width: 300px; } a:link, a:visited { text-decoration: none; font-size: 13pt; color: #006ec0; } a:hover, a:focus { color: #f00; } #content { padding: 15px 15px 60px 15px; } #footer { position: fixed; bottom: 0px; height: 45px; background-color: #006ec0; width: 100%; } #footer p { color: #fff; padding-left: 20px; padding-right: 20px; font-size: 10pt !important; } #footer a { color: #fff; } #footer a:hover { color: #f00; } div.content { background-color: #fff; padding-bottom: 65px; overflow: hidden; } span.warn { display: inline-block; padding-left: 20px; color: #ff9900; font-style: italic; } input { padding: 10px; font-size: 13pt; } input.button { background-color: #006ec0; color: #fff; border: 0px; float: right; text-transform: uppercase; } input.cb { margin-bottom: 20px; } label { font-size: 14pt; } .left { float: left; } .right { float: right; } .inputWrp { position: relative; } .inputWrp .inputText { height: 35px; width: 90%; margin-bottom: 20px; border: 1px solid #ccc; border-top: none; border-right: none; } .inputWrp .floating_label { position: absolute; pointer-events: none; top: 20px; left: 10px; transition: 0.2s ease all; } .inputWrp input:focus ~ .floating_label, .inputWrp input:not(:focus):valid ~ .floating_label { top: 0px; left: 20px; font-size: 10px; color: blue; opacity: 1; } "; |
|||
String style_css = "h1 { margin: 0; padding: 20pt; font-size: 22pt; color: #fff; background-color: #006ec0; display: block; text-transform: uppercase; } html, body { font-family: Arial; margin: 0; padding: 0; } p { text-align: justify; font-size: 13pt; } .des { font-size: 14pt; color: #006ec0; padding-bottom: 0px !important; } .fw { width: 60px; display: block; float: left; } .color { width: 50px; height: 50px; border: 1px solid #ccc; } .range { width: 300px; } a:link, a:visited { text-decoration: none; font-size: 13pt; color: #006ec0; } a:hover, a:focus { color: #f00; } #content { padding: 15px 15px 60px 15px; } #footer { position: fixed; bottom: 0px; height: 45px; background-color: #006ec0; width: 100%; } #footer p { color: #fff; padding-left: 20px; padding-right: 20px; font-size: 10pt !important; } #footer a { color: #fff; } #footer a:hover { color: #f00; } div.content { background-color: #fff; padding-bottom: 65px; overflow: hidden; } span.warn { display: inline-block; padding-left: 20px; color: #ff9900; font-style: italic; } input { padding: 10px; font-size: 13pt; } input.button { background-color: #006ec0; color: #fff; border: 0px; float: right; text-transform: uppercase; } input.cb { margin-bottom: 20px; } label { font-size: 14pt; } .left { float: left; } .right { float: right; } .inputWrp { position: relative; } .inputWrp .inputText { height: 35px; width: 90%; margin-bottom: 20px; border: 1px solid #ccc; border-top: none; border-right: none; } .inputWrp .floating_label { position: absolute; pointer-events: none; top: 20px; left: 10px; transition: 0.2s ease all; } .inputWrp input:focus ~ .floating_label, .inputWrp input:not(:focus):valid ~ .floating_label { top: 0px; left: 20px; font-size: 10px; color: blue; opacity: 1; } div.module { display: block; width: 250px; height: 410px; background-color: #006ec0; display: inline-block; position: relative; margin-right: 20px; margin-bottom: 20px; } div.module .value, div.module .info, div.module .header { color: #fff; display: block; width: 100%; text-align: center; } div.module .unit { font-size: 19px; margin-left: 10px; } div.module .value { margin-top: 20px; font-size: 30px; } div.module .info { margin-top: 3px; font-size: 10px; } div.module .header { background-color: #003c80; padding: 10px 0 10px 0; } "; |
|||
|
@ -0,0 +1,42 @@ |
|||
<!doctype html> |
|||
<html> |
|||
<head> |
|||
<title>Index - {DEVICE}</title> |
|||
<link rel="stylesheet" type="text/css" href="style.css"/> |
|||
<meta name="viewport" content="width=device-width, initial-scale=1"> |
|||
<script type="text/javascript"> |
|||
getAjax('/livedata', 'livedata') |
|||
window.setInterval("getAjax('/livedata', 'livedata')", 10000); |
|||
|
|||
function getAjax(url, resid) { |
|||
var http = null; |
|||
http = new XMLHttpRequest(); |
|||
if(http != null) { |
|||
http.open("GET", url, true); |
|||
http.onreadystatechange = print; |
|||
http.send(null); |
|||
} |
|||
|
|||
function print() { |
|||
if(http.readyState == 4) { |
|||
document.getElementById(resid).innerHTML = http.responseText; |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
<style type="text/css"> |
|||
</style> |
|||
</head> |
|||
<body> |
|||
<h1>AHOY - {DEVICE}</h1> |
|||
<div id="content" class="content"> |
|||
<p><a href="/">Home</a><br/></p> |
|||
<div id="livedata"></div> |
|||
<p>Every 10 seconds the values are updated</p> |
|||
</div> |
|||
<div id="footer"> |
|||
<p class="left">© 2022</p> |
|||
<p class="right">AHOY :: {VERSION}</p> |
|||
</div> |
|||
</body> |
|||
</html> |
Loading…
Reference in new issue