mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-03-11 21:15:30 +00:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
254e010594 | ||
|
|
4c92e592d6 | ||
|
|
72bdb6e363 | ||
|
|
05bdbaf1f5 | ||
|
|
6cca25788e | ||
|
|
e929f87ea9 | ||
|
|
21a4102553 | ||
|
|
768645fc0a | ||
|
|
c670549dea | ||
|
|
147b2ca33e | ||
|
|
c645b82ed3 | ||
|
|
26bb8a0fea | ||
|
|
507ed13770 | ||
|
|
a0f53a0c52 | ||
|
|
13bbc81b7f | ||
|
|
7412ba2697 |
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Report a bug
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Hardware information:**
|
||||
- Meter: [e.g. Aidon]
|
||||
- AMS reader: [e.g. Pow-U, ESP32 etc]
|
||||
- M-bus adapter (if applicable):
|
||||
|
||||
**Relevant firmware information:**
|
||||
- Version: [e.g. 1.5.0]
|
||||
- MQTT: [yes/no]
|
||||
- HAN GPIO: [e.g. GPIO5]
|
||||
- Temperature sensors [e.g. 3xDS18B20]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
22
.github/ISSUE_TEMPLATE/support.md
vendored
Normal file
22
.github/ISSUE_TEMPLATE/support.md
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
name: Support
|
||||
about: Request support
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe your problem**
|
||||
A clear and concise description of what the problem is.
|
||||
|
||||
**Hardware information:**
|
||||
- Meter: [e.g. Aidon]
|
||||
- AMS reader: [e.g. Pow-U, ESP32 etc]
|
||||
- M-bus adapter (if applicable):
|
||||
|
||||
**Relevant firmware information:**
|
||||
- Version: [e.g. 1.5.0]
|
||||
- MQTT: [yes/no]
|
||||
- HAN GPIO: [e.g. GPIO5]
|
||||
- Temperature sensors [e.g. 3xDS18B20]
|
||||
@@ -299,10 +299,10 @@ time_t HanReader::getTime(byte *buffer, int start, int length, bool respectTimez
|
||||
tm.Second = second;
|
||||
|
||||
time_t time = makeTime(tm);
|
||||
if(respectTimezone && tzMinutes != 0x8000) {
|
||||
if(respectTimezone && (tzMinutes | 0x8000) != 0x8000 && tzMinutes <= 720 && tzMinutes >= -720) {
|
||||
time -= tzMinutes * 60;
|
||||
if(respectDsc && dsc)
|
||||
time -= 3600;
|
||||
time += 3600;
|
||||
} else {
|
||||
if(respectDsc && dsc)
|
||||
time += 3600;
|
||||
|
||||
@@ -220,6 +220,7 @@ bool AmsConfiguration::getDebugConfig(DebugConfig& config) {
|
||||
EEPROM.end();
|
||||
return true;
|
||||
} else {
|
||||
clearDebug(config);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -232,6 +233,12 @@ bool AmsConfiguration::setDebugConfig(DebugConfig& config) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
void AmsConfiguration::clearDebug(DebugConfig& config) {
|
||||
config.level = 5;
|
||||
config.telnet = false;
|
||||
config.serial = false;
|
||||
}
|
||||
|
||||
bool AmsConfiguration::getDomoticzConfig(DomoticzConfig& config) {
|
||||
if(hasConfig()) {
|
||||
EEPROM.begin(EEPROM_SIZE);
|
||||
|
||||
@@ -286,6 +286,7 @@ public:
|
||||
|
||||
bool getDebugConfig(DebugConfig&);
|
||||
bool setDebugConfig(DebugConfig&);
|
||||
void clearDebug(DebugConfig&);
|
||||
|
||||
bool pinUsed(uint8_t, GpioConfig&);
|
||||
|
||||
|
||||
@@ -16,15 +16,23 @@ AmsData::AmsData(uint8_t meterType, bool substituteMissing, HanReader& hanReader
|
||||
extractFromKaifa(hanReader, listSize);
|
||||
break;
|
||||
case METER_TYPE_AIDON:
|
||||
extractFromAidon(hanReader, listSize, substituteMissing);
|
||||
extractFromAidon(hanReader, listSize);
|
||||
break;
|
||||
case METER_TYPE_KAMSTRUP:
|
||||
extractFromKamstrup(hanReader, listSize, substituteMissing);
|
||||
extractFromKamstrup(hanReader, listSize);
|
||||
break;
|
||||
case METER_TYPE_OMNIPOWER:
|
||||
extractFromOmnipower(hanReader, listSize, substituteMissing);
|
||||
extractFromOmnipower(hanReader, listSize);
|
||||
break;
|
||||
}
|
||||
threePhase = l1voltage > 0 && l2voltage > 0 && l3voltage > 0;
|
||||
twoPhase = (l1voltage > 0 && l2voltage > 0) || (l2voltage > 0 && l3voltage > 0) || (l3voltage > 0 && l1voltage > 0);
|
||||
|
||||
if(threePhase) {
|
||||
if(substituteMissing) {
|
||||
l2current = (((activeImportPower - activeExportPower) * sqrt(3)) - (l1voltage * l1current) - (l3voltage * l3current)) / l2voltage;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AmsData::extractFromKaifa(HanReader& hanReader, uint8_t listSize) {
|
||||
@@ -90,7 +98,7 @@ void AmsData::extractFromKaifa(HanReader& hanReader, uint8_t listSize) {
|
||||
}
|
||||
}
|
||||
|
||||
void AmsData::extractFromAidon(HanReader& hanReader, uint8_t listSize, bool substituteMissing) {
|
||||
void AmsData::extractFromAidon(HanReader& hanReader, uint8_t listSize) {
|
||||
switch(listSize) {
|
||||
case (uint8_t)Aidon::List1:
|
||||
listType = 1;
|
||||
@@ -171,15 +179,12 @@ void AmsData::extractFromAidon(HanReader& hanReader, uint8_t listSize, bool subs
|
||||
l1voltage = ((float) hanReader.getInt( (uint8_t)Aidon_List3PhaseIT::VoltageL1)) / 10;
|
||||
l2voltage = ((float) hanReader.getInt( (uint8_t)Aidon_List3PhaseIT::VoltageL2)) / 10;
|
||||
l3voltage = ((float) hanReader.getInt( (uint8_t)Aidon_List3PhaseIT::VoltageL3)) / 10;
|
||||
if(substituteMissing) {
|
||||
l2current = (((activeImportPower - activeExportPower) * sqrt(3)) - (l1voltage * l1current) - (l3voltage * l3current)) / l2voltage;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AmsData::extractFromKamstrup(HanReader& hanReader, uint8_t listSize, bool substituteMissing) {
|
||||
void AmsData::extractFromKamstrup(HanReader& hanReader, uint8_t listSize) {
|
||||
switch(listSize) {
|
||||
case (uint8_t)Kamstrup::List3PhaseITShort:
|
||||
case (uint8_t)Kamstrup::List3PhaseShort:
|
||||
@@ -254,14 +259,11 @@ void AmsData::extractFromKamstrup(HanReader& hanReader, uint8_t listSize, bool s
|
||||
l1voltage = hanReader.getInt( (uint8_t)Kamstrup_List3Phase::VoltageL1);
|
||||
l2voltage = hanReader.getInt( (uint8_t)Kamstrup_List3Phase::VoltageL2);
|
||||
l3voltage = hanReader.getInt( (uint8_t)Kamstrup_List3Phase::VoltageL3);
|
||||
if(substituteMissing) {
|
||||
l2current = (((activeImportPower - activeExportPower) * sqrt(3)) - (l1voltage * l1current) - (l3voltage * l3current)) / l2voltage;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void AmsData::extractFromOmnipower(HanReader& hanReader, uint8_t listSize, bool substituteMissing) {
|
||||
void AmsData::extractFromOmnipower(HanReader& hanReader, uint8_t listSize) {
|
||||
switch(listSize) {
|
||||
case (uint8_t)Kamstrup::List3PhaseITShort:
|
||||
case (uint8_t)Kamstrup::List3PhaseShort:
|
||||
@@ -269,7 +271,7 @@ void AmsData::extractFromOmnipower(HanReader& hanReader, uint8_t listSize, bool
|
||||
case (uint8_t)Kamstrup::List3PhaseITLong:
|
||||
case (uint8_t)Kamstrup::List3PhaseLong:
|
||||
case (uint8_t)Kamstrup::List1PhaseLong:
|
||||
extractFromKamstrup(hanReader, listSize, substituteMissing);
|
||||
extractFromKamstrup(hanReader, listSize);
|
||||
break;
|
||||
case (uint8_t)Omnipower::DLMS:
|
||||
meterTimestamp = hanReader.getTime( (uint8_t)Omnipower_DLMS::MeterClock, true, true);
|
||||
@@ -340,6 +342,7 @@ void AmsData::apply(AmsData& other) {
|
||||
this->l2voltage = other.getL2Voltage();
|
||||
this->l3voltage = other.getL3Voltage();
|
||||
this->threePhase = other.isThreePhase();
|
||||
this->twoPhase = other.isTwoPhase();
|
||||
case 1:
|
||||
this->activeImportPower = other.getActiveImportPower();
|
||||
}
|
||||
@@ -432,3 +435,7 @@ float AmsData::getReactiveExportCounter() {
|
||||
bool AmsData::isThreePhase() {
|
||||
return this->threePhase;
|
||||
}
|
||||
|
||||
bool AmsData::isTwoPhase() {
|
||||
return this->twoPhase;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ public:
|
||||
float getReactiveExportCounter();
|
||||
|
||||
bool isThreePhase();
|
||||
bool isTwoPhase();
|
||||
|
||||
private:
|
||||
unsigned long lastUpdateMillis = 0;
|
||||
@@ -58,12 +59,12 @@ private:
|
||||
uint16_t activeImportPower = 0, reactiveImportPower = 0, activeExportPower = 0, reactiveExportPower = 0;
|
||||
float l1voltage = 0, l2voltage = 0, l3voltage = 0, l1current = 0, l2current = 0, l3current = 0;
|
||||
float activeImportCounter = 0, reactiveImportCounter = 0, activeExportCounter = 0, reactiveExportCounter = 0;
|
||||
bool threePhase = false, counterEstimated = false;
|
||||
bool threePhase = false, twoPhase = false, counterEstimated = false;
|
||||
|
||||
void extractFromKaifa(HanReader& hanReader, uint8_t listSize);
|
||||
void extractFromAidon(HanReader& hanReader, uint8_t listSize, bool substituteMissing);
|
||||
void extractFromKamstrup(HanReader& hanReader, uint8_t listSize, bool substituteMissing);
|
||||
void extractFromOmnipower(HanReader& hanReader, uint8_t listSize, bool substituteMissing);
|
||||
void extractFromAidon(HanReader& hanReader, uint8_t listSize);
|
||||
void extractFromKamstrup(HanReader& hanReader, uint8_t listSize);
|
||||
void extractFromOmnipower(HanReader& hanReader, uint8_t listSize);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -68,6 +68,7 @@ AmsMqttHandler* mqttHandler = NULL;
|
||||
HanReader hanReader;
|
||||
|
||||
Stream *hanSerial;
|
||||
SoftwareSerial *swSerial = NULL;
|
||||
|
||||
GpioConfig gpioConfig;
|
||||
MeterConfig meterConfig;
|
||||
@@ -140,21 +141,11 @@ void setup() {
|
||||
|
||||
bool shared = false;
|
||||
config.getMeterConfig(meterConfig);
|
||||
Serial.flush();
|
||||
Serial.end();
|
||||
if(gpioConfig.hanPin == 3) {
|
||||
shared = true;
|
||||
switch(meterConfig.type) {
|
||||
case METER_TYPE_KAMSTRUP:
|
||||
case METER_TYPE_OMNIPOWER:
|
||||
Serial.begin(2400, SERIAL_8N1);
|
||||
break;
|
||||
default:
|
||||
Serial.begin(2400, SERIAL_8E1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!shared) {
|
||||
Serial.begin(115200);
|
||||
setupHanPort(gpioConfig.hanPin, meterConfig.type);
|
||||
}
|
||||
|
||||
DebugConfig debug;
|
||||
@@ -459,9 +450,11 @@ void setupHanPort(int pin, int newMeterType) {
|
||||
debugI("Setting up HAN on pin %d for meter type %d", pin, newMeterType);
|
||||
|
||||
HardwareSerial *hwSerial = NULL;
|
||||
if(pin == 3) {
|
||||
if(pin == 3 || pin == 113) {
|
||||
hwSerial = &Serial;
|
||||
}
|
||||
|
||||
|
||||
#if defined(ESP32)
|
||||
if(pin == 9) {
|
||||
hwSerial = &Serial1;
|
||||
@@ -478,7 +471,9 @@ void setupHanPort(int pin, int newMeterType) {
|
||||
|
||||
if(hwSerial != NULL) {
|
||||
debugD("Hardware serial");
|
||||
Serial.flush();
|
||||
hwSerial->flush();
|
||||
hwSerial->end();
|
||||
|
||||
switch(newMeterType) {
|
||||
case METER_TYPE_KAMSTRUP:
|
||||
case METER_TYPE_OMNIPOWER:
|
||||
@@ -488,11 +483,27 @@ void setupHanPort(int pin, int newMeterType) {
|
||||
hwSerial->begin(2400, SERIAL_8E1);
|
||||
break;
|
||||
}
|
||||
|
||||
#if defined(ESP8266)
|
||||
if(pin == 3) {
|
||||
debugI("Switching UART0 to pin 1 & 3");
|
||||
Serial.pins(1,3);
|
||||
} else if(pin == 113) {
|
||||
debugI("Switching UART0 to pin 15 & 13");
|
||||
Serial.pins(15,13);
|
||||
}
|
||||
#endif
|
||||
|
||||
hanSerial = hwSerial;
|
||||
} else {
|
||||
debugD("Software serial");
|
||||
Serial.flush();
|
||||
SoftwareSerial *swSerial = new SoftwareSerial(pin);
|
||||
|
||||
if(swSerial != NULL) {
|
||||
swSerial->end();
|
||||
delete swSerial;
|
||||
}
|
||||
swSerial = new SoftwareSerial(pin);
|
||||
|
||||
switch(newMeterType) {
|
||||
case METER_TYPE_KAMSTRUP:
|
||||
@@ -505,6 +516,7 @@ void setupHanPort(int pin, int newMeterType) {
|
||||
}
|
||||
hanSerial = swSerial;
|
||||
|
||||
Serial.end();
|
||||
Serial.begin(115200);
|
||||
}
|
||||
|
||||
|
||||
@@ -129,15 +129,17 @@ bool HwTools::updateTemperatures() {
|
||||
delay(10);
|
||||
}
|
||||
} else {
|
||||
sensorApi->requestTemperatures();
|
||||
if(sensorCount > 0) {
|
||||
sensorApi->requestTemperatures();
|
||||
|
||||
for(int x = 0; x < sensorCount; x++) {
|
||||
TempSensorData *data = tempSensors[x];
|
||||
float t = sensorApi->getTempC(data->address);
|
||||
data->lastRead = t;
|
||||
if(t > -85) {
|
||||
data->changed = data->lastValidRead != t;
|
||||
data->lastValidRead = t;
|
||||
for(int x = 0; x < sensorCount; x++) {
|
||||
TempSensorData *data = tempSensors[x];
|
||||
float t = sensorApi->getTempC(data->address);
|
||||
data->lastRead = t;
|
||||
if(t > -85) {
|
||||
data->changed = data->lastValidRead != t;
|
||||
data->lastValidRead = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,55 +23,47 @@ bool DomoticzMqttHandler::publish(AmsData* data, AmsData* previousState) {
|
||||
return ret;
|
||||
|
||||
if (config.vl1idx > 0){
|
||||
if (data->getL1Voltage() > 0.1){
|
||||
char val[16];
|
||||
snprintf(val, 16, "%.2f", data->getL1Voltage());
|
||||
char json[192];
|
||||
snprintf_P(json, sizeof(json), DOMOTICZ_JSON,
|
||||
config.vl1idx,
|
||||
val
|
||||
);
|
||||
ret |= mqtt->publish("domoticz/in", json);
|
||||
}
|
||||
char val[16];
|
||||
snprintf(val, 16, "%.2f", data->getL1Voltage());
|
||||
char json[192];
|
||||
snprintf_P(json, sizeof(json), DOMOTICZ_JSON,
|
||||
config.vl1idx,
|
||||
val
|
||||
);
|
||||
ret |= mqtt->publish("domoticz/in", json);
|
||||
}
|
||||
|
||||
if (config.vl2idx > 0){
|
||||
if (data->getL2Voltage() > 0.1){
|
||||
char val[16];
|
||||
snprintf(val, 16, "%.2f", data->getL2Voltage());
|
||||
char json[192];
|
||||
snprintf_P(json, sizeof(json), DOMOTICZ_JSON,
|
||||
config.vl2idx,
|
||||
val
|
||||
);
|
||||
ret |= mqtt->publish("domoticz/in", json);
|
||||
}
|
||||
char val[16];
|
||||
snprintf(val, 16, "%.2f", data->getL2Voltage());
|
||||
char json[192];
|
||||
snprintf_P(json, sizeof(json), DOMOTICZ_JSON,
|
||||
config.vl2idx,
|
||||
val
|
||||
);
|
||||
ret |= mqtt->publish("domoticz/in", json);
|
||||
}
|
||||
|
||||
if (config.vl3idx > 0){
|
||||
if (data->getL3Voltage() > 0.1){
|
||||
char val[16];
|
||||
snprintf(val, 16, "%.2f", data->getL3Voltage());
|
||||
char json[192];
|
||||
snprintf_P(json, sizeof(json), DOMOTICZ_JSON,
|
||||
config.vl3idx,
|
||||
val
|
||||
);
|
||||
ret |= mqtt->publish("domoticz/in", json);
|
||||
}
|
||||
char val[16];
|
||||
snprintf(val, 16, "%.2f", data->getL3Voltage());
|
||||
char json[192];
|
||||
snprintf_P(json, sizeof(json), DOMOTICZ_JSON,
|
||||
config.vl3idx,
|
||||
val
|
||||
);
|
||||
ret |= mqtt->publish("domoticz/in", json);
|
||||
}
|
||||
|
||||
if (config.cl1idx > 0){
|
||||
if(data->getL1Current() > 0.0) {
|
||||
char val[16];
|
||||
snprintf(val, 16, "%.1f;%.1f;%.1f", data->getL1Current(), data->getL2Current(), data->getL3Current());
|
||||
char json[192];
|
||||
snprintf_P(json, sizeof(json), DOMOTICZ_JSON,
|
||||
config.cl1idx,
|
||||
val
|
||||
);
|
||||
ret |= mqtt->publish("domoticz/in", json);
|
||||
}
|
||||
char val[16];
|
||||
snprintf(val, 16, "%.1f;%.1f;%.1f", data->getL1Current(), data->getL2Current(), data->getL3Current());
|
||||
char json[192];
|
||||
snprintf_P(json, sizeof(json), DOMOTICZ_JSON,
|
||||
config.cl1idx,
|
||||
val
|
||||
);
|
||||
ret |= mqtt->publish("domoticz/in", json);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -117,9 +117,11 @@ void AmsWebServer::loop() {
|
||||
server.handleClient();
|
||||
|
||||
if(maxPwr == 0 && meterState->getListType() > 1 && meterConfig->mainFuse > 0 && meterConfig->distributionSystem > 0) {
|
||||
int voltage = meterConfig->distributionSystem == 2 ? 400 : 230;
|
||||
if(meterState->isThreePhase()) {
|
||||
int voltage = meterConfig->distributionSystem == 2 ? 400 : 230;
|
||||
maxPwr = meterConfig->mainFuse * sqrt(3) * voltage;
|
||||
} else if(meterState->isTwoPhase()) {
|
||||
maxPwr = meterConfig->mainFuse * voltage;
|
||||
} else {
|
||||
maxPwr = meterConfig->mainFuse * 230;
|
||||
}
|
||||
@@ -189,7 +191,7 @@ void AmsWebServer::temperaturePost() {
|
||||
delay(1);
|
||||
}
|
||||
|
||||
if (debugger->isActive(RemoteDebug::DEBUG)) config->print(debugger);
|
||||
//if (debugger->isActive(RemoteDebug::DEBUG)) config->print(debugger);
|
||||
if(config->save()) {
|
||||
printD("Successfully saved temperature sensors");
|
||||
server.sendHeader("Location", String("/temperature"), true);
|
||||
@@ -693,7 +695,7 @@ void AmsWebServer::dataJson() {
|
||||
mqttStatus = 3;
|
||||
}
|
||||
|
||||
char json[280];
|
||||
char json[290];
|
||||
snprintf_P(json, sizeof(json), DATA_JSON,
|
||||
maxPwr == 0 ? meterState->isThreePhase() ? 20000 : 10000 : maxPwr,
|
||||
meterConfig->productionCapacity,
|
||||
@@ -741,6 +743,9 @@ void AmsWebServer::handleSetup() {
|
||||
} else {
|
||||
SystemConfig sys { server.arg("board").toInt() };
|
||||
|
||||
DebugConfig debugConfig;
|
||||
config->getDebugConfig(debugConfig);
|
||||
|
||||
config->clear();
|
||||
|
||||
config->clearGpio(*gpioConfig);
|
||||
@@ -759,7 +764,6 @@ void AmsWebServer::handleSetup() {
|
||||
gpioConfig->apPin = 0;
|
||||
gpioConfig->ledPin = 2;
|
||||
gpioConfig->ledInverted = true;
|
||||
gpioConfig->tempSensorPin = 5;
|
||||
gpioConfig->ledPinRed = 13;
|
||||
gpioConfig->ledPinGreen = 14;
|
||||
gpioConfig->ledRgbInverted = true;
|
||||
@@ -777,7 +781,6 @@ void AmsWebServer::handleSetup() {
|
||||
gpioConfig->apPin = 0;
|
||||
gpioConfig->ledPin = 2;
|
||||
gpioConfig->ledInverted = true;
|
||||
gpioConfig->tempSensorPin = 5;
|
||||
gpioConfig->ledPinRed = 13;
|
||||
gpioConfig->ledPinGreen = 14;
|
||||
gpioConfig->ledRgbInverted = true;
|
||||
@@ -787,7 +790,6 @@ void AmsWebServer::handleSetup() {
|
||||
gpioConfig->apPin = 0;
|
||||
gpioConfig->ledPin = 2;
|
||||
gpioConfig->ledInverted = true;
|
||||
gpioConfig->tempSensorPin = 5;
|
||||
gpioConfig->ledPinRed = 13;
|
||||
gpioConfig->ledPinGreen = 14;
|
||||
gpioConfig->ledRgbInverted = true;
|
||||
@@ -797,7 +799,6 @@ void AmsWebServer::handleSetup() {
|
||||
gpioConfig->apPin = 4;
|
||||
gpioConfig->ledPin = 2;
|
||||
gpioConfig->ledInverted = true;
|
||||
gpioConfig->tempSensorPin = 14;
|
||||
gpioConfig->vccMultiplier = 1100;
|
||||
break;
|
||||
case 100: // ESP8266
|
||||
@@ -810,13 +811,11 @@ void AmsWebServer::handleSetup() {
|
||||
gpioConfig->apPin = 4;
|
||||
gpioConfig->ledPin = 5;
|
||||
gpioConfig->ledInverted = true;
|
||||
gpioConfig->tempSensorPin = 14;
|
||||
break;
|
||||
case 202: // Feather
|
||||
gpioConfig->hanPin = 16;
|
||||
gpioConfig->ledPin = 2;
|
||||
gpioConfig->ledInverted = false;
|
||||
gpioConfig->tempSensorPin = 14;
|
||||
break;
|
||||
case 203: // DevKitC
|
||||
gpioConfig->hanPin = 16;
|
||||
@@ -828,7 +827,6 @@ void AmsWebServer::handleSetup() {
|
||||
gpioConfig->apPin = 0;
|
||||
gpioConfig->ledPin = 2;
|
||||
gpioConfig->ledInverted = false;
|
||||
gpioConfig->tempSensorPin = 14;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -889,6 +887,8 @@ void AmsWebServer::handleSetup() {
|
||||
success = false;
|
||||
}
|
||||
|
||||
config->setDebugConfig(debugConfig);
|
||||
|
||||
if(success && config->save()) {
|
||||
performRestart = true;
|
||||
server.sendHeader("Location","/restart-wait");
|
||||
@@ -1068,7 +1068,7 @@ void AmsWebServer::handleSave() {
|
||||
|
||||
printI("Saving configuration now...");
|
||||
|
||||
if (debugger->isActive(RemoteDebug::DEBUG)) config->print(debugger);
|
||||
//if (debugger->isActive(RemoteDebug::DEBUG)) config->print(debugger);
|
||||
if (config->save()) {
|
||||
printI("Successfully saved.");
|
||||
if(config->isWifiChanged()) {
|
||||
@@ -1191,26 +1191,31 @@ void AmsWebServer::configDebugHtml() {
|
||||
String AmsWebServer::getSerialSelectOptions(int selected) {
|
||||
String gpioOptions;
|
||||
if(selected == 3) {
|
||||
gpioOptions += "<option value=\"3\" selected>UART0</option>";
|
||||
gpioOptions += "<option value=\"3\" selected>UART0 (GPIO3)</option>";
|
||||
} else {
|
||||
gpioOptions += "<option value=\"3\">UART0</option>";
|
||||
gpioOptions += "<option value=\"3\">UART0 (GPIO3)</option>";
|
||||
}
|
||||
#if defined(ESP32)
|
||||
int numGpio = 24;
|
||||
int gpios[] = {4,5,6,7,8,10,11,12,13,14,15,17,18,19,21,22,23,25,32,33,34,35,36,39};
|
||||
if(selected == 9) {
|
||||
gpioOptions += "<option value=\"9\" selected>UART1</option>";
|
||||
gpioOptions += "<option value=\"9\" selected>UART1 (GPIO9)</option>";
|
||||
} else {
|
||||
gpioOptions += "<option value=\"9\">UART1</option>";
|
||||
gpioOptions += "<option value=\"9\">UART1 (GPIO9)</option>";
|
||||
}
|
||||
if(selected == 16) {
|
||||
gpioOptions += "<option value=\"16\" selected>UART2</option>";
|
||||
gpioOptions += "<option value=\"16\" selected>UART2 (GPIO16)</option>";
|
||||
} else {
|
||||
gpioOptions += "<option value=\"16\">UART2</option>";
|
||||
gpioOptions += "<option value=\"16\">UART2 (GPIO16)</option>";
|
||||
}
|
||||
#elif defined(ESP8266)
|
||||
int numGpio = 9;
|
||||
int gpios[] = {4,5,9,10,12,13,14,15,16};
|
||||
if(selected == 113) {
|
||||
gpioOptions += "<option value=\"113\" selected>UART2 (GPIO13)</option>";
|
||||
} else {
|
||||
gpioOptions += "<option value=\"113\">UART2 (GPIO13)</option>";
|
||||
}
|
||||
#endif
|
||||
|
||||
for(int i = 0; i < numGpio; i++) {
|
||||
|
||||
@@ -147,6 +147,7 @@ $(function() {
|
||||
case '/gpio':
|
||||
case '/debugging':
|
||||
case '/firmware':
|
||||
$('#firmware-warn').show();
|
||||
case '/reset':
|
||||
$('#system-link').addClass('active');
|
||||
break;
|
||||
@@ -307,11 +308,22 @@ var fetch = function() {
|
||||
});
|
||||
}
|
||||
|
||||
if(vm && vm.gaugeMeter && json.u1) {
|
||||
var v = parseFloat(json.u1);
|
||||
if(json.u2) {
|
||||
v = (v+parseFloat(json.u2)+parseFloat(json.u3)) / 3;
|
||||
if(vm && vm.gaugeMeter) {
|
||||
var c = 0;
|
||||
var t = 0;
|
||||
if(json.u1) {
|
||||
t += parseFloat(json.u1);
|
||||
c++;
|
||||
}
|
||||
if(json.u2) {
|
||||
t += parseFloat(json.u2);
|
||||
c++;
|
||||
}
|
||||
if(json.u3) {
|
||||
t += parseFloat(json.u3);
|
||||
c++;
|
||||
}
|
||||
v = t/c;
|
||||
var pct = (Math.max(v-207, 1)*100/46);
|
||||
vm.gaugeMeter({
|
||||
percent: pct,
|
||||
@@ -319,18 +331,21 @@ var fetch = function() {
|
||||
});
|
||||
}
|
||||
|
||||
if(am && am.gaugeMeter && json.i1 && json.mf) {
|
||||
var v = parseFloat(json.i1);
|
||||
if(am && am.gaugeMeter && json.mf) {
|
||||
var a = 0;
|
||||
if(json.i1) {
|
||||
a = Math.max(a, parseFloat(json.i1));
|
||||
}
|
||||
if(json.i2) {
|
||||
v = Math.max(v, parseFloat(json.i2));
|
||||
a = Math.max(a, parseFloat(json.i2));
|
||||
}
|
||||
if(json.i3) {
|
||||
v = Math.max(v, parseFloat(json.i3));
|
||||
a = Math.max(a, parseFloat(json.i3));
|
||||
}
|
||||
var pct = (v*100)/parseInt(json.mf);
|
||||
var pct = (a*100)/parseInt(json.mf);
|
||||
am.gaugeMeter({
|
||||
percent: pct,
|
||||
text: v.toFixed(1)
|
||||
text: a.toFixed(1)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
"e" : %d,
|
||||
"ri" : %d,
|
||||
"re" : %d,
|
||||
"ic" : %.1f,
|
||||
"ec" : %.1f,
|
||||
"ric" : %.1f,
|
||||
"rec" : %.1f,
|
||||
"u1" : %.1f,
|
||||
"u2" : %.1f,
|
||||
"u3" : %.1f,
|
||||
"ic" : %.2f,
|
||||
"ec" : %.2f,
|
||||
"ric" : %.2f,
|
||||
"rec" : %.2f,
|
||||
"u1" : %.2f,
|
||||
"u2" : %.2f,
|
||||
"u3" : %.2f,
|
||||
"i1" : %.2f,
|
||||
"i2" : %.2f,
|
||||
"i3" : %.2f,
|
||||
"v" : %.2f,
|
||||
"v" : %.3f,
|
||||
"r" : %d,
|
||||
"t" : %.1f,
|
||||
"t" : %.2f,
|
||||
"u" : %lu,
|
||||
"m" : %lu,
|
||||
"em" : %d,
|
||||
|
||||
@@ -20,10 +20,10 @@
|
||||
"U1" : %.2f,
|
||||
"U2" : %.2f,
|
||||
"U3" : %.2f,
|
||||
"tPI" : %.1f,
|
||||
"tPO" : %.1f,
|
||||
"tQI" : %.1f,
|
||||
"tQO" : %.1f,
|
||||
"tPI" : %.2f,
|
||||
"tPO" : %.2f,
|
||||
"tQI" : %.2f,
|
||||
"tQO" : %.2f,
|
||||
"rtc" : %lu
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,12 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="firmware-warn" style="display: none;">
|
||||
<br/>
|
||||
<div class="alert alert-danger">
|
||||
WARNING: Units powered over M-bus must be connected to an external power supply during firmware upload. Failure to do so may cause power-down during upload resulting in non-functioning unit.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="row form-group">
|
||||
|
||||
Reference in New Issue
Block a user