Skip to content

Commit 4136e7c

Browse files
committed
Add examples recompiled against UWP windows designer
1 parent 29991c3 commit 4136e7c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2913
-454
lines changed
Lines changed: 107 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,107 @@
1-
{"version":"1.00","projectName":"C:\\Users\\dave\\Documents\\Arduino\\libraries\\tcMenu\\examples\\analogDfRobot\\analogDfRobot.emf","author":"dave","lastEdited":{"seconds":1574526348,"nanos":899682800},"namingRecursive":false,"items":[{"parentId":0,"type":"analogItem","item":{"maxValue":1024,"offset":0,"divisor":1,"unitName":"","name":"Value A0","id":1,"eepromAddress":-1,"readOnly":false,"localOnly":false}},{"parentId":0,"type":"subMenu","item":{"secured":false,"name":"LED States","id":2,"eepromAddress":-1,"readOnly":false,"localOnly":false}},{"parentId":2,"type":"boolItem","item":{"naming":"ON_OFF","name":"LED 1","id":3,"eepromAddress":2,"functionName":"onLed1","readOnly":false,"localOnly":false}},{"parentId":2,"type":"boolItem","item":{"naming":"ON_OFF","name":"LED 2","id":4,"eepromAddress":3,"functionName":"onLed2","readOnly":false,"localOnly":false}},{"parentId":0,"type":"largeNumItem","item":{"digitsAllowed":8,"decimalPlaces":4,"name":"LgeNum","id":5,"eepromAddress":10,"readOnly":false,"localOnly":false}},{"parentId":0,"type":"textItem","item":{"textLength":6,"itemType":"PLAIN_TEXT","name":"Text","id":6,"eepromAddress":4,"readOnly":false,"localOnly":false}}],"codeOptions":{"embeddedPlatform":"ARDUINO","lastDisplayUuid":"bcd5fe34-9e9f-4fcb-9edf-f4e3caca0674","lastInputUuid":"7daa6a81-dd09-422e-b83c-bda5045abaef","lastRemoteUuid":"2c101fec-1f7d-4ff3-8d2b-992ad41e7fcb","applicationUUID":"2ba37227-a412-40b7-94e7-42caf9bb0ff4","applicationName":"DfRobot","lastProperties":[],"namingRecursive":false}}
1+
{
2+
"lastEdited": {
3+
"seconds": 1584199664,
4+
"nanos": 0
5+
},
6+
"codeOptions": {
7+
"applicationUUID": "2ba37227-a412-40b7-94e7-42caf9bb0ff4",
8+
"applicationName": "DfRobot",
9+
"lastInputUuid": "7daa6a81-dd09-422e-b83c-bda5045abaef",
10+
"lastDisplayUuid": "bcd5fe34-9e9f-4fcb-9edf-f4e3caca0674",
11+
"lastRemoteUuid": "2c101fec-1f7d-4ff3-8d2b-992ad41e7fcb",
12+
"embeddedPlatform": "ARDUINO_AVR",
13+
"namingRecursive": false,
14+
"saveToSrc": false,
15+
"lastProperties": []
16+
},
17+
"projectName": "Uses the DF Robot shield for both input and display",
18+
"namingRecursive": false,
19+
"version": "1.00",
20+
"items": [
21+
{
22+
"parentId": 0,
23+
"type": "analogItem",
24+
"item": {
25+
"name": "Value A0",
26+
"eepromAddress": -1,
27+
"id": 1,
28+
"readOnly": false,
29+
"localOnly": false,
30+
"visible": true,
31+
"maxValue": 1024,
32+
"offset": 0,
33+
"divisor": 1,
34+
"unitName": ""
35+
}
36+
},
37+
{
38+
"parentId": 0,
39+
"type": "subMenu",
40+
"item": {
41+
"name": "LED States",
42+
"eepromAddress": -1,
43+
"id": 2,
44+
"readOnly": false,
45+
"localOnly": false,
46+
"visible": true,
47+
"secured": false
48+
}
49+
},
50+
{
51+
"parentId": 2,
52+
"type": "boolItem",
53+
"item": {
54+
"name": "LED 1",
55+
"eepromAddress": 2,
56+
"id": 3,
57+
"readOnly": false,
58+
"localOnly": false,
59+
"visible": true,
60+
"functionName": "onLed1",
61+
"naming": "ON_OFF"
62+
}
63+
},
64+
{
65+
"parentId": 2,
66+
"type": "boolItem",
67+
"item": {
68+
"name": "LED 2",
69+
"eepromAddress": 3,
70+
"id": 4,
71+
"readOnly": false,
72+
"localOnly": false,
73+
"visible": true,
74+
"functionName": "onLed2",
75+
"naming": "ON_OFF"
76+
}
77+
},
78+
{
79+
"parentId": 0,
80+
"type": "largeNumItem",
81+
"item": {
82+
"name": "LgeNum",
83+
"eepromAddress": 10,
84+
"id": 5,
85+
"readOnly": false,
86+
"localOnly": false,
87+
"visible": true,
88+
"decimalPlaces": 4,
89+
"digitsAllowed": 8
90+
}
91+
},
92+
{
93+
"parentId": 0,
94+
"type": "textItem",
95+
"item": {
96+
"name": "Text",
97+
"eepromAddress": 4,
98+
"id": 6,
99+
"readOnly": false,
100+
"localOnly": false,
101+
"visible": true,
102+
"itemType": "PLAIN_TEXT",
103+
"textLength": 6
104+
}
105+
}
106+
]
107+
}

examples/analogDfRobot/analogDfRobot_menu.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ LiquidCrystalRenderer renderer(lcd, 16, 2);
1919

2020
// Global Menu Item declarations
2121

22-
RENDERING_CALLBACK_NAME_INVOKE(fnTextRtCall, textItemRenderFn, "Text", 4, NULL)
22+
RENDERING_CALLBACK_NAME_INVOKE(fnTextRtCall, textItemRenderFn, "Text", 4, NO_CALLBACK)
2323
TextMenuItem menuText(fnTextRtCall, 6, 6, NULL);
24-
RENDERING_CALLBACK_NAME_INVOKE(fnLgeNumRtCall, largeNumItemRenderFn, "LgeNum", 10, NULL)
24+
RENDERING_CALLBACK_NAME_INVOKE(fnLgeNumRtCall, largeNumItemRenderFn, "LgeNum", 10, NO_CALLBACK)
2525
EditableLargeNumberMenuItem menuLgeNum(fnLgeNumRtCall, 5, 8, 4, &menuText);
2626
const BooleanMenuInfo PROGMEM minfoLED2 = { "LED 2", 4, 3, 1, onLed2, NAMING_ON_OFF };
2727
BooleanMenuItem menuLED2(&minfoLED2, false, NULL);
2828
const BooleanMenuInfo PROGMEM minfoLED1 = { "LED 1", 3, 2, 1, onLed1, NAMING_ON_OFF };
2929
BooleanMenuItem menuLED1(&minfoLED1, false, &menuLED2);
30-
const SubMenuInfo PROGMEM minfoLEDStates = { "LED States", 2, 0xFFFF, 0, NULL };
31-
RENDERING_CALLBACK_NAME_INVOKE(fnLEDStatesRtCall, backSubItemRenderFn, "LED States", -1, NULL)
30+
const SubMenuInfo PROGMEM minfoLEDStates = { "LED States", 2, 0xFFFF, 0, NO_CALLBACK };
31+
RENDERING_CALLBACK_NAME_INVOKE(fnLEDStatesRtCall, backSubItemRenderFn, "LED States", -1, NO_CALLBACK)
3232
BackMenuItem menuBackLEDStates(fnLEDStatesRtCall, &menuLED1);
3333
SubMenuItem menuLEDStates(&minfoLEDStates, &menuBackLEDStates, &menuLgeNum);
34-
const AnalogMenuInfo PROGMEM minfoValueA0 = { "Value A0", 1, 0xFFFF, 1024, NULL, 0, 1, "" };
34+
const AnalogMenuInfo PROGMEM minfoValueA0 = { "Value A0", 1, 0xFFFF, 1024, NO_CALLBACK, 0, 1, "" };
3535
AnalogMenuItem menuValueA0(&minfoValueA0, 0, &menuLEDStates);
3636

3737

examples/analogDfRobot/analogDfRobot_menu.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
#include <tcMenu.h>
1515
#include <RuntimeMenuItem.h>
16-
#include <RuntimeMenuItem.h>
1716
#include <LiquidCrystalIO.h>
1817
#include "tcMenuLiquidCrystal.h"
1918
#include <DfRobotInputAbstraction.h>

examples/colorTftEthernet32/EthernetTransport.cpp

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,74 @@
1212
#include "EthernetTransport.h"
1313
#include <TaskManager.h>
1414

15-
EthernetTagValServer remoteServer = EthernetTagValServer();
15+
#if ETHERNET_BUFFER_SIZE > 0 // we need buffering when dealing with Ethernet2
1616

1717
EthernetTagValTransport::EthernetTagValTransport() {
18+
bufferPosition = 0;
19+
}
20+
21+
EthernetTagValTransport::~EthernetTagValTransport() {
22+
}
23+
24+
bool EthernetTagValTransport::available() {
25+
return client && client.connected();
26+
}
27+
28+
bool EthernetTagValTransport::connected() {
29+
return client && client.connected();
30+
}
31+
32+
int EthernetTagValTransport::writeChar(char data) {
33+
// only uncomment below for worst case debugging..
34+
// serdebug2("writing ", data);
35+
if(bufferPosition >= sizeof(bufferData)) {
36+
flush();
37+
// if the buffer isn't empty, something went wrong.
38+
if(bufferPosition != 0) return 0;
39+
}
40+
41+
42+
// and lastly add the byte
43+
return bufferData[bufferPosition++] = data;
44+
}
45+
46+
int EthernetTagValTransport::writeStr(const char* data) {
47+
// only uncomment below for worst case debugging..
48+
// serdebug2("writing ", data);
49+
int i = 0;
50+
int len = strlen(data);
51+
for(int i = 0; i < len; ++i) {
52+
if(writeChar(data[i]) == 0) {
53+
return 0;
54+
}
55+
}
56+
return len;
57+
}
58+
59+
void EthernetTagValTransport::flush() {
60+
if(!client || bufferPosition == 0) return;
61+
62+
if(client.write(bufferData, bufferPosition) == bufferPosition) {
63+
serdebugF2("Buffer written ", bufferPosition);
64+
bufferPosition = 0;
65+
}
66+
else {
67+
serdebugF2("Buffer write fail ", bufferPosition);
68+
}
69+
client.flush();
70+
}
71+
72+
uint8_t EthernetTagValTransport::readByte() {
73+
return client.read();
74+
}
75+
76+
bool EthernetTagValTransport::readAvailable() {
77+
return client && client.connected() && client.available();
78+
}
79+
80+
#else // unbuffed client for all fully implemented stacks
81+
82+
EthernetTagValTransport::EthernetTagValTransport() {
1883
}
1984

2085
EthernetTagValTransport::~EthernetTagValTransport() {
@@ -52,6 +117,9 @@ bool EthernetTagValTransport::readAvailable() {
52117
return client && client.connected() && client.available();
53118
}
54119

120+
121+
#endif
122+
55123
EthernetTagValServer::EthernetTagValServer() : messageProcessor(msgHandlers, MSG_HANDLERS_SIZE) {
56124
this->server = NULL;
57125
}
@@ -83,11 +151,13 @@ void EthernetTagValServer::exec() {
83151
}
84152
}
85153

86-
int fromWiFiRSSITo4StateIndicator(int strength) {
154+
int fromWiFiRSSITo4StateIndicator(int strength) {
87155
int qualityIcon = 0;
88156
if(strength > -50) qualityIcon = 4;
89157
else if(strength > -60) qualityIcon = 3;
90158
else if(strength > -75) qualityIcon = 2;
91159
else if(strength > -90) qualityIcon = 1;
92160
return qualityIcon;
93-
}
161+
}
162+
163+
EthernetTagValServer remoteServer = EthernetTagValServer();

examples/colorTftEthernet32/EthernetTransport.h

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,41 @@
1919
#include <Ethernet.h>
2020
#include <tcUtil.h>
2121

22+
#ifndef ETHERNET_BUFFER_SIZE
23+
#define ETHERNET_BUFFER_SIZE 64
24+
#endif
25+
26+
#if ETHERNET_BUFFER_SIZE > 0
27+
28+
/**
29+
* An implementation of TagValueTransport that is able to read and write via a buffer to sockets.
30+
*/
31+
class EthernetTagValTransport : public TagValueTransport {
32+
private:
33+
EthernetClient client;
34+
uint8_t bufferData[ETHERNET_BUFFER_SIZE];
35+
int bufferPosition;
36+
public:
37+
EthernetTagValTransport();
38+
virtual ~EthernetTagValTransport();
39+
void setClient(EthernetClient client) { this->client = client; }
40+
41+
void endMsg() override {
42+
TagValueTransport::endMsg();
43+
flush();
44+
}
45+
int writeChar(char data) override ;
46+
int writeStr(const char* data) override;
47+
void flush() override;
48+
bool available() override;
49+
bool connected() override;
50+
uint8_t readByte() override;
51+
bool readAvailable() override;
52+
void close() override;
53+
};
54+
55+
#else // ethernet buffering not needed
56+
2257
/**
2358
* An implementation of TagValueTransport that is able to read and write using sockets.
2459
*/
@@ -40,6 +75,8 @@ class EthernetTagValTransport : public TagValueTransport {
4075
virtual void close();
4176
};
4277

78+
#endif // ethernet buffering check
79+
4380
/**
4481
* This is the actual server component that manages all the ethernet connections.
4582
* It holds the connector, transport and processors that are needed to be able
@@ -62,7 +99,7 @@ class EthernetTagValServer : public Executable {
6299
/**
63100
* Sets the mode of authentication used with your remote, if you don't call this the system will
64101
* default to no authentication; which is probably fine for serial / bluetooth serial.
65-
*
102+
*
66103
* This should always be called before begin(), to ensure this in your code always ensure this
67104
* is called BEFORE setupMenu().
68105
*

0 commit comments

Comments
 (0)