Skip to content

Commit 3eb7f63

Browse files
author
dave
committed
More example updates for 2.2 release
1 parent f694801 commit 3eb7f63

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

examples/esp8266WifiOled/EthernetTransport.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ void EthernetTagValTransport::flush() {
3030
if((int)client.write(writeBuffer, writeBufferPos) == writeBufferPos) {
3131
serdebugF2("Buffer written ", writeBufferPos);
3232
writeBufferPos = 0;
33-
client.flush();
34-
}
33+
client.flush();
34+
}
3535
else {
36+
writeBufferPos = 0;
3637
close();
3738
}
3839
}

examples/esp8266WifiOled/Greenhouse.emf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@
325325
},
326326
{
327327
"name": "SWITCH_IODEVICE",
328-
"latestValue": "",
328+
"latestValue": "io8574",
329329
"subsystem": "INPUT"
330330
},
331331
{
@@ -413,6 +413,10 @@
413413
"saveToSrc": false,
414414
"useCppMain": false,
415415
"eepromDefinition": "eeprom:",
416-
"authenticatorDefinition": "rom:100:6"
416+
"authenticatorDefinition": "rom:100:6",
417+
"projectIoExpanders": [
418+
"deviceIO:",
419+
"pcf8574:io8574:32:12"
420+
]
417421
}
418422
}

examples/esp8266WifiOled/esp8266WifiOled.ino

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,9 @@ char fileChoicesArray[255]{};
3434
#define WINDOW_PIN 3
3535
#define HEATER_PIN 4
3636

37-
// this is the interrupt pin connection from the PCF8574 back to the ESP8266 board.
38-
#define IO_INTERRUPT_PIN 12
39-
40-
41-
//
42-
// ESP boards tend to have few pins available for general purpose use, to make things easier
43-
// this sketch assumes the rotary encoder and switch are attached to a PCF8574 IO Expander.
44-
// Change in menu designer's code generator to remove this if you prefer to use device pins.
45-
//
46-
//IoAbstractionRef io8574 = new LoggingIoAbstraction(ioFrom8574(0x20, IO_INTERRUPT_PIN), 8);
47-
IoAbstractionRef io8574 = ioFrom8574(0x20, IO_INTERRUPT_PIN);
48-
4937
// we add two widgets that show both the connection status and wifi signal strength
5038
// these are added to the renderer and rendered upon any change.
39+
// https://www.thecoderscorner.com/products/arduino-libraries/tc-menu/rendering-with-tcmenu-lcd-tft-oled/#titlewidget-for-presenting-state-in-icon-form
5140
TitleWidget connectedWidget(iconsConnection, 2, 16, 12);
5241
TitleWidget wifiWidget(iconsWifi, 5, 16, 12, &connectedWidget);
5342

examples/esp8266WifiOled/esp8266WifiOled_menu.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// Global variable declarations
1616
const PROGMEM ConnectorLocalInfo applicationInfo = { "ESP8266 Greenhouse", "01b9cb76-c108-4be3-a133-6159f8f1c9c1" };
1717
TcMenuRemoteServer remoteServer(applicationInfo);
18+
IoAbstractionRef ioexp_io8574 = ioFrom8574(0x20, 12);
1819
ArduinoEEPROMAbstraction glArduinoEeprom(&EEPROM);
1920
EepromAuthenticatorManager authManager(6);
2021
U8G2_SH1106_128X64_NONAME_F_HW_I2C gfx(U8G2_R0, 16, U8X8_PIN_NONE, U8X8_PIN_NONE);
@@ -80,17 +81,17 @@ void setupMenu() {
8081
authManager.initialise(menuMgr.getEepromAbstraction(), 100);
8182
menuMgr.setAuthenticator(&authManager);
8283
// Now add any readonly, non-remote and visible flags.
83-
menuTomatoTemp.setReadOnly(true);
8484
menuIpAddress.setReadOnly(true);
85+
menuTomatoTemp.setReadOnly(true);
8586
menuCucumberTemp.setReadOnly(true);
86-
menuPwd.setLocalOnly(true);
8787
menuSSID.setLocalOnly(true);
88+
menuPwd.setLocalOnly(true);
8889
menuSecretEntry.setVisible(false);
8990

9091
// Code generated by plugins.
9192
gfx.begin();
9293
renderer.setUpdatesPerSecond(10);
93-
switches.initialise(internalDigitalIo(), true);
94+
switches.initialise(ioexp_io8574, true);
9495
menuMgr.initForEncoder(&renderer, &menuTomatoTemp, 13, 12, 14);
9596
remoteServer.addConnection(&ethernetConnection);
9697
renderer.setTitleMode(BaseGraphicalRenderer::TITLE_FIRST_ROW);

examples/esp8266WifiOled/esp8266WifiOled_menu.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include <RemoteMenuItem.h>
2020
#include <RuntimeMenuItem.h>
2121
#include <ScrollChoiceMenuItem.h>
22+
#include <IoAbstraction.h>
23+
#include <IoAbstractionWire.h>
2224
#include <ArduinoEEPROMAbstraction.h>
2325
#include <RemoteAuthentication.h>
2426

@@ -30,6 +32,9 @@ extern GraphicsDeviceRenderer renderer;
3032
extern WiFiServer server;
3133
extern EthernetInitialisation ethernetInitialisation;
3234

35+
// Any externals needed by IO expanders, EEPROMs etc
36+
extern IoAbstractionRef ioexp_io8574;
37+
3338
// Global Menu Item exports
3439
extern EepromAuthenticationInfoMenuItem menuAuthenticator;
3540
extern RemoteMenuItem menuIoTMonitor;

0 commit comments

Comments
 (0)