Skip to content

Commit 7374934

Browse files
committed
Bump version, start building examples.
1 parent 66d648b commit 7374934

22 files changed

+1363
-23
lines changed

examples/esp32SimHub/ESP32TouchKeysAbstraction.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <PlatformDetermination.h>
22
#include "ESP32TouchKeysAbstraction.h"
3+
#include <driver/touch_sensor.h>
34

45
volatile int intCount = 0;
56

examples/esp32SimHub/esp32SimHub.emf

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,8 @@
320320
"subsystem": "INPUT"
321321
},
322322
{
323-
"name": "INTERRUPT_SWITCHES",
324-
"latestValue": "true",
323+
"name": "SW_POLLING_MODE",
324+
"latestValue": "SWITCHES_POLL_EVERYTHING",
325325
"subsystem": "INPUT"
326326
},
327327
{
@@ -412,6 +412,10 @@
412412
"authenticatorDefinition": "",
413413
"projectIoExpanders": [
414414
"deviceIO:"
415-
]
415+
],
416+
"menuInMenuCollection": {
417+
"menuDefinitions": []
418+
},
419+
"packageNamespace": ""
416420
}
417421
}

examples/esp32SimHub/esp32SimHub_menu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void setupMenu() {
7474
gfx.begin();
7575
gfx.setRotation(1);
7676
renderer.setUpdatesPerSecond(5);
77-
switches.initialiseInterrupt(&esp32Touch, false);
77+
switches.init(internalDigitalIo(), SWITCHES_POLL_EVERYTHING, false);
7878
menuMgr.initForUpDownOk(&renderer, &menuSpeed, 7, 5, 6);
7979
esp32Touch.ensureInterruptRegistered();
8080
remoteServer.addConnection(&simhubConnection);
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
/*
2+
* Copyright (c) 2018 https://www.thecoderscorner.com (Dave Cherry).
3+
* This product is licensed under an Apache license, see the LICENSE file in the top-level directory.
4+
*/
5+
6+
/**
7+
* Ethernet remote capability plugin. This file is a plugin file and should not be directly edited,
8+
* it will be replaced each time the project is built. If you want to edit this file in place,
9+
* make sure to rename it first.
10+
*/
11+
12+
#include "EthernetTransport.h"
13+
#include <TaskManager.h>
14+
15+
using namespace tcremote;
16+
17+
#if ETHERNET_BUFFER_SIZE > 0 // we need buffering when dealing with Ethernet2
18+
19+
bool EthernetTagValTransport::available() {
20+
return client && client.connected();
21+
}
22+
23+
bool EthernetTagValTransport::connected() {
24+
return client && client.connected();
25+
}
26+
27+
void EthernetTagValTransport::flush() {
28+
if(!client || writeBufferPos == 0) return;
29+
30+
if((int)client.write(writeBuffer, writeBufferPos) == writeBufferPos) {
31+
serdebugF2("Buffer written ", writeBufferPos);
32+
writeBufferPos = 0;
33+
client.flush();
34+
}
35+
else {
36+
writeBufferPos = 0;
37+
close();
38+
}
39+
}
40+
41+
int EthernetTagValTransport::fillReadBuffer(uint8_t* dataBuffer, int maxData) {
42+
if(client && client.connected() && client.available()) {
43+
auto amt = client.read(dataBuffer, maxData);
44+
if(amt <= 0) {
45+
close();
46+
return 0;
47+
}
48+
serdebugF2("read to buffer ", amt);
49+
return amt;
50+
}
51+
return 0;
52+
}
53+
54+
void EthernetTagValTransport::close() {
55+
serdebugF("socket close");
56+
BaseBufferedRemoteTransport::close();
57+
client.stop();
58+
}
59+
60+
#else // unbuffed client - requires library to support Nagle algorythm.
61+
62+
bool EthernetTagValTransport::available() {
63+
return client && client.connected();
64+
}
65+
66+
bool EthernetTagValTransport::connected() {
67+
return client && client.connected();
68+
}
69+
70+
int EthernetTagValTransport::writeChar(char data) {
71+
// only uncomment below for worst case debugging..
72+
// serdebug2("writing ", data);
73+
return client.write(data);
74+
}
75+
76+
int EthernetTagValTransport::writeStr(const char* data) {
77+
// only uncomment below for worst case debugging..
78+
// serdebug2("writing ", data);
79+
return client.write(data);
80+
}
81+
82+
void EthernetTagValTransport::flush() {
83+
if(client) client.flush();
84+
}
85+
86+
uint8_t EthernetTagValTransport::readByte() {
87+
return client.read();
88+
}
89+
90+
bool EthernetTagValTransport::readAvailable() {
91+
return client && client.connected() && client.available();
92+
}
93+
94+
void EthernetTagValTransport::close() {
95+
serdebugF("socket close");
96+
client.stop();
97+
currentField.msgType = UNKNOWN_MSG_TYPE;
98+
currentField.fieldType = FVAL_PROCESSING_AWAITINGMSG;
99+
}
100+
101+
#endif
102+
103+
104+
int tcremote::fromWiFiRSSITo4StateIndicator(int strength) {
105+
int qualityIcon = 0;
106+
if(strength > -50) qualityIcon = 4;
107+
else if(strength > -60) qualityIcon = 3;
108+
else if(strength > -75) qualityIcon = 2;
109+
else if(strength > -90) qualityIcon = 1;
110+
return qualityIcon;
111+
}
112+
113+
bool EthernetInitialisation::attemptInitialisation() {
114+
#ifdef ARDUINO_ARCH_STM32
115+
// we'll keep checking if the link is up before trying to initialise further
116+
if(Ethernet.linkStatus() == LinkOFF) return false;
117+
#endif
118+
serdebugF("Initialising server ");
119+
this->server->begin();
120+
initialised = true;
121+
return initialised;
122+
}
123+
124+
bool EthernetInitialisation::attemptNewConnection(BaseRemoteServerConnection *remoteServerConnection) {
125+
auto client = server->available();
126+
if(client) {
127+
serdebugF("Client found");
128+
auto* tvCon = reinterpret_cast<TagValueRemoteServerConnection*>(remoteServerConnection);
129+
reinterpret_cast<EthernetTagValTransport*>(tvCon->transport())->setClient(client);
130+
return true;
131+
}
132+
return false;
133+
}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/*
2+
* Copyright (c) 2018 https://www.thecoderscorner.com (Dave Cherry).
3+
* This product is licensed under an Apache license, see the LICENSE file in the top-level directory.
4+
*/
5+
6+
/**
7+
* @file EthernetTransport.h
8+
*
9+
* Ethernet remote capability plugin. This file is a plugin file and should not be directly edited,
10+
* it will be replaced each time the project is built. If you want to edit this file in place,
11+
* make sure to rename it first.
12+
*/
13+
14+
#ifndef TCMENU_ETHERNETTRANSPORT_H_
15+
#define TCMENU_ETHERNETTRANSPORT_H_
16+
17+
#include <RemoteConnector.h>
18+
#include <TaskManager.h>
19+
#include <WiFi.h>
20+
#include <tcUtil.h>
21+
#include <remote/BaseRemoteComponents.h>
22+
23+
#ifndef ETHERNET_BUFFER_SIZE
24+
#define ETHERNET_BUFFER_SIZE 96
25+
#endif
26+
27+
#if ETHERNET_BUFFER_SIZE > 0
28+
#include <remote/BaseBufferedRemoteTransport.h>
29+
#endif
30+
31+
namespace tcremote {
32+
33+
#if ETHERNET_BUFFER_SIZE > 0
34+
35+
/**
36+
* An implementation of TagValueTransport that is able to read and write via a buffer to sockets.
37+
*/
38+
class EthernetTagValTransport : public tcremote::BaseBufferedRemoteTransport {
39+
private:
40+
WiFiClient client;
41+
public:
42+
EthernetTagValTransport() : BaseBufferedRemoteTransport(BUFFER_MESSAGES_TILL_FULL, ETHERNET_BUFFER_SIZE, MAX_VALUE_LEN) { }
43+
~EthernetTagValTransport() override = default;
44+
void setClient(WiFiClient cl) { this->client = cl; }
45+
46+
int fillReadBuffer(uint8_t* data, int maxSize) override;
47+
void flush() override;
48+
bool available() override;
49+
bool connected() override;
50+
void close() override;
51+
};
52+
53+
#else // ethernet buffering not needed
54+
55+
/**
56+
* An implementation of TagValueTransport that is able to read and write using sockets.
57+
*/
58+
class EthernetTagValTransport : public TagValueTransport {
59+
private:
60+
WiFiClient client;
61+
public:
62+
EthernetTagValTransport() : TagValueTransport(TagValueTransportType::TVAL_UNBUFFERED) {};
63+
~EthernetTagValTransport() override = default;
64+
void setClient(WiFiClient client) { this->client = client; }
65+
66+
int writeChar(char data) override ;
67+
int writeStr(const char* data) override;
68+
void flush() override;
69+
bool available() override;
70+
bool connected() override;
71+
uint8_t readByte() override;
72+
bool readAvailable() override;
73+
void close() override;
74+
};
75+
76+
#endif // ethernet buffering check
77+
78+
/**
79+
* This class provides the initialisation and connection generation logic for ethernet connections.
80+
*/
81+
class EthernetInitialisation : public DeviceInitialisation {
82+
private:
83+
WiFiServer *server;
84+
public:
85+
explicit EthernetInitialisation(WiFiServer* server) : server(server) {}
86+
87+
bool attemptInitialisation() override;
88+
89+
bool attemptNewConnection(BaseRemoteServerConnection *transport) override;
90+
};
91+
92+
/**
93+
* This function converts from a RSSI (Radio Strength indicator)
94+
* measurement into a series of icons (of the ones we have defined
95+
* in the stock icons. The input is the RSSI figure in dB as an
96+
* integer.
97+
* @param strength the signal strength (usually negative) as an int
98+
* @return a state that can be used with the standard wifi TitleWidget
99+
*/
100+
int fromWiFiRSSITo4StateIndicator(int strength);
101+
102+
} // namespace tcremote
103+
104+
#ifndef TC_MANUAL_NAMESPACING
105+
using namespace tcremote;
106+
#endif // TC_MANUAL_NAMESPACING
107+
108+
#endif /* TCMENU_ETHERNETTRANSPORT_H_ */
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#ifndef TCMENU_THEME_MONO_INVERSE
2+
#define TCMENU_THEME_MONO_INVERSE
3+
4+
color_t defaultItemPaletteMono[] = {1, 0, 1, 1};
5+
color_t defaultTitlePaletteMono[] = {0, 1, 0, 0};
6+
7+
#define TITLE_PADDING 2
8+
#define TITLE_SPACING 2
9+
10+
void installMonoInverseTitleTheme(GraphicsDeviceRenderer& bgr, const MenuFontDef& itemFont, const MenuFontDef& titleFont, bool needEditingIcons) {
11+
bgr.setDisplayDimensions(bgr.getDeviceDrawable()->getDisplayDimensions().x, bgr.getDeviceDrawable()->getDisplayDimensions().y);
12+
auto& factory = bgr.getGraphicsPropertiesFactory();
13+
14+
factory.setSelectedColors(0, 2);
15+
16+
MenuPadding titlePadding(TITLE_PADDING);
17+
MenuPadding itemPadding(1);
18+
int titleHeight = bgr.heightForFontPadding(titleFont.fontData, titleFont.fontMag, titlePadding);
19+
int itemHeight = bgr.heightForFontPadding(itemFont.fontData, itemFont.fontMag, itemPadding);
20+
21+
factory.addImageToCache(DrawableIcon(SPECIAL_ID_EDIT_ICON, Coord(8, 6),DrawableIcon::ICON_XBITMAP, loResEditingIcon));
22+
factory.addImageToCache(DrawableIcon(SPECIAL_ID_ACTIVE_ICON, Coord(8, 6),DrawableIcon::ICON_XBITMAP, loResActiveIcon));
23+
24+
factory.setDrawingPropertiesDefault(ItemDisplayProperties::COMPTYPE_TITLE, defaultTitlePaletteMono, titlePadding, titleFont.fontData, titleFont.fontMag,
25+
TITLE_SPACING, titleHeight + 1, GridPosition::JUSTIFY_TITLE_LEFT_WITH_VALUE, MenuBorder(0));
26+
factory.setDrawingPropertiesDefault(ItemDisplayProperties::COMPTYPE_ITEM, defaultItemPaletteMono, itemPadding, itemFont.fontData, itemFont.fontMag,
27+
1, itemHeight, GridPosition::JUSTIFY_TITLE_LEFT_VALUE_RIGHT , MenuBorder(0));
28+
factory.setDrawingPropertiesDefault(ItemDisplayProperties::COMPTYPE_ACTION, defaultItemPaletteMono, itemPadding, itemFont.fontData, itemFont.fontMag,
29+
1, itemHeight, GridPosition::JUSTIFY_TITLE_LEFT_WITH_VALUE, MenuBorder(0));
30+
31+
tcgfx::ConfigurableItemDisplayPropertiesFactory::refreshCache();
32+
}
33+
34+
#endif //TCMENU_THEME_MONO_INVERSE

0 commit comments

Comments
 (0)