Browse Source

Merge branch 'markusdd-development03' into development03

pull/854/head
lumapu 2 years ago
parent
commit
aa92308c13
  1. 3
      .github/workflows/compile_development.yml
  2. 3
      .github/workflows/compile_release.yml
  3. 45
      ahoy.code-workspace
  4. 11
      scripts/getVersion.py
  5. 28
      src/app.cpp
  6. 4
      src/app.h
  7. 4
      src/config/settings.h
  8. 4
      src/platformio.ini
  9. 1
      src/web/RestApi.h
  10. 12
      src/web/html/setup.html
  11. 3
      src/web/web.h

3
.github/workflows/compile_development.yml

@ -49,6 +49,9 @@ jobs:
- name: Run PlatformIO
run: pio run -d src --environment esp8266-release --environment esp8266-release-prometheus --environment esp8285-release --environment esp32-wroom32-release --environment esp32-wroom32-release-prometheus --environment opendtufusionv1-release
- name: Copy boot_app0.bin
run: cp ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin src/.pio/build/opendtufusionv1-release/ota.bin
- name: Rename Binary files
id: rename-binary-files
working-directory: src

3
.github/workflows/compile_release.yml

@ -53,6 +53,9 @@ jobs:
- name: Run PlatformIO
run: pio run -d src --environment esp8266-release --environment esp8266-release-prometheus --environment esp8285-release --environment esp32-wroom32-release --environment esp32-wroom32-release-prometheus --environment opendtufusionv1-release
- name: Copy boot_app0.bin
run: cp ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin src/.pio/build/opendtufusionv1-release/ota.bin
- name: Rename Binary files
id: rename-binary-files
working-directory: src

45
ahoy.code-workspace

@ -0,0 +1,45 @@
{
"folders": [
{
"path": "."
},
{
"path": "src"
}
],
"settings": {
"files.associations": {
"algorithm": "cpp",
"array": "cpp",
"chrono": "cpp",
"deque": "cpp",
"format": "cpp",
"forward_list": "cpp",
"functional": "cpp",
"initializer_list": "cpp",
"iterator": "cpp",
"list": "cpp",
"memory": "cpp",
"queue": "cpp",
"random": "cpp",
"regex": "cpp",
"vector": "cpp",
"xhash": "cpp",
"xlocmon": "cpp",
"xlocnum": "cpp",
"xmemory": "cpp",
"xstring": "cpp",
"xtree": "cpp",
"xutility": "cpp",
"*.tcc": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"string_view": "cpp",
"sstream": "cpp",
"istream": "cpp",
"ostream": "cpp"
},
"editor.formatOnSave": false
}
}

11
scripts/getVersion.py

@ -50,6 +50,7 @@ def readVersion(path, infile):
versionnumber += line[p+13:].rstrip() + "."
os.mkdir(path + "firmware/")
os.mkdir(path + "firmware/s3/")
sha = os.getenv("SHA",default="sha")
versionout = version[:-1] + "_" + sha + "_esp8266.bin"
@ -80,7 +81,7 @@ def readVersion(path, infile):
versionout = version[:-1] + "_" + sha + "_esp32s3.bin"
src = path + ".pio/build/opendtufusionv1-release/firmware.bin"
dst = path + "firmware/" + versionout
dst = path + "firmware/s3/" + versionout
os.rename(src, dst)
# other ESP32 bin files
@ -89,6 +90,14 @@ def readVersion(path, infile):
os.rename(src + "bootloader.bin", dst + "bootloader.bin")
os.rename(src + "partitions.bin", dst + "partitions.bin")
genOtaBin(path + "firmware/")
# other ESP32S3 bin files
src = path + ".pio/build/opendtufusionv1-release/"
dst = path + "firmware/s3/"
os.rename(src + "bootloader.bin", dst + "bootloader.bin")
os.rename(src + "partitions.bin", dst + "partitions.bin")
os.rename(src + "ota.bin", dst + "ota.bin")
os.rename("../scripts/gh-action-dev-build-flash.html", path + "install.html")
print("name=" + versionnumber[:-1] )

28
src/app.cpp

@ -387,30 +387,40 @@ void app::mqttSubRxCb(JsonObject obj) {
//-----------------------------------------------------------------------------
void app::setupLed(void) {
/** LED connection diagram
* \\
* PIN ---- |<----- 3.3V
*
* */
uint8_t led_off = (mConfig->led.led_high_active != 0) ? LOW : HIGH;
if (mConfig->led.led0 != 0xff) {
pinMode(mConfig->led.led0, OUTPUT);
digitalWrite(mConfig->led.led0, HIGH); // LED off
digitalWrite(mConfig->led.led0, led_off);
}
if (mConfig->led.led1 != 0xff) {
pinMode(mConfig->led.led1, OUTPUT);
digitalWrite(mConfig->led.led1, HIGH); // LED off
digitalWrite(mConfig->led.led1, led_off);
}
}
//-----------------------------------------------------------------------------
void app::updateLed(void) {
uint8_t led_off = (mConfig->led.led_high_active != 0) ? LOW : HIGH;
uint8_t led_on = (mConfig->led.led_high_active != 0) ? HIGH : LOW;
if (mConfig->led.led0 != 0xff) {
Inverter<> *iv = mSys.getInverterByPos(0);
if (NULL != iv) {
if (iv->isProducing(mTimestamp))
digitalWrite(mConfig->led.led0, LOW); // LED on
digitalWrite(mConfig->led.led0, led_on);
else
digitalWrite(mConfig->led.led0, HIGH); // LED off
digitalWrite(mConfig->led.led0, led_off);
}
}
if (mConfig->led.led1 != 0xff) {
if (getMqttIsConnected()) {
digitalWrite(mConfig->led.led1, led_on);
} else {
digitalWrite(mConfig->led.led1, led_off);
}
}
}

4
src/app.h

@ -213,8 +213,8 @@ class app : public IApp, public ah::Scheduler {
void mqttSubRxCb(JsonObject obj);
void setupLed(void);
void updateLed(void);
void setupLed();
void updateLed();
void tickReboot(void) {
DPRINTLN(DBG_INFO, F("Rebooting..."));

4
src/config/settings.h

@ -100,6 +100,7 @@ typedef struct {
typedef struct {
uint8_t led0; // first LED pin
uint8_t led1; // second LED pin
uint8_t led_high_active; // determines if LEDs are high or low active
} cfgLed_t;
typedef struct {
@ -378,6 +379,7 @@ class settings {
mCfg.led.led0 = DEF_PIN_OFF;
mCfg.led.led1 = DEF_PIN_OFF;
mCfg.led.led_high_active = LOW;
memset(&mCfg.inst, 0, sizeof(cfgInst_t));
@ -517,9 +519,11 @@ class settings {
if(set) {
obj[F("0")] = mCfg.led.led0;
obj[F("1")] = mCfg.led.led1;
obj[F("led_high_active")] = mCfg.led.led_high_active;
} else {
mCfg.led.led0 = obj[F("0")];
mCfg.led.led1 = obj[F("1")];
mCfg.led.led_high_active = obj[F("led_high_active")];
}
}

4
src/platformio.ini

@ -138,6 +138,10 @@ monitor_filters =
[env:opendtufusionv1-release]
platform = espressif32
board = esp32-s3-devkitc-1
upload_protocol = esp-builtin
upload_speed = 115200
debug_tool = esp-builtin
debug_speed = 12000
build_flags = -D RELEASE -std=gnu++14
build_unflags = -std=gnu++11
monitor_filters =

1
src/web/RestApi.h

@ -391,6 +391,7 @@ class RestApi {
obj[F("miso")] = mConfig->nrf.pinMiso;
obj[F("led0")] = mConfig->led.led0;
obj[F("led1")] = mConfig->led.led1;
obj[F("led_high_active")] = mConfig->led.led_high_active;
}
void getRadio(JsonObject obj) {

12
src/web/html/setup.html

@ -411,6 +411,10 @@
[47, "GPIO47"],
[48, "GPIO48"],
];
var led_high_active = [
[0, "low active"],
[1, "high active"],
];
const re = /11[2,4,6]1.*/;
@ -670,6 +674,14 @@
])
);
}
e.append(
ml("div", { class: "row mb-3" }, [
ml("div", { class: "col-12 col-sm-3 my-2" }, "LED polarity"),
ml("div", { class: "col-12 col-sm-9" },
sel('pinLedHighActive', led_high_active, obj['led_high_active'])
)
])
);
}
function parseRadio(obj) {

3
src/web/web.h

@ -34,7 +34,7 @@
#define WEB_SERIAL_BUF_SIZE 2048
const char *const pinArgNames[] = {"pinCs", "pinCe", "pinIrq", "pinSclk", "pinMosi", "pinMiso", "pinLed0", "pinLed1"};
const char *const pinArgNames[] = {"pinCs", "pinCe", "pinIrq", "pinSclk", "pinMosi", "pinMiso", "pinLed0", "pinLed1", "pinLedHighActive"};
template <class HMSYSTEM>
class Web {
@ -532,6 +532,7 @@ class Web {
case 5: mConfig->nrf.pinMiso = ((pin != 0xff) ? pin : DEF_MISO_PIN); break;
case 6: mConfig->led.led0 = pin; break;
case 7: mConfig->led.led1 = pin; break;
case 8: mConfig->led.led_high_active = pin; break; // this is not really a pin but a polarity, but handling it close to here makes sense
}
}

Loading…
Cancel
Save