Skip to content

Commit 48e603b

Browse files
author
dave
committed
Uno dfRobot example recompiled on V2.1 designer
1 parent 2ae9192 commit 48e603b

File tree

4 files changed

+194
-20
lines changed

4 files changed

+194
-20
lines changed
Lines changed: 180 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,180 @@
1-
{"version":"1.00","projectName":"/Users/dave/Documents/Arduino/tcLibraryDev/lib/tcMenu/examples/analogDfRobot/analogDfRobot.emf","author":"dave","lastEdited":{"seconds":1615990001,"nanos":454077000},"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,"visible":true}},{"parentId":0,"type":"subMenu","item":{"secured":false,"name":"LED States","id":2,"eepromAddress":-1,"readOnly":false,"localOnly":false,"visible":true}},{"parentId":2,"type":"boolItem","item":{"naming":"ON_OFF","name":"L1","id":3,"eepromAddress":2,"functionName":"onLed1","readOnly":false,"localOnly":false,"visible":true}},{"parentId":2,"type":"boolItem","item":{"naming":"ON_OFF","name":"L2","id":4,"eepromAddress":3,"functionName":"onLed2","readOnly":false,"localOnly":false,"visible":true}},{"parentId":0,"type":"largeNumItem","item":{"digitsAllowed":8,"decimalPlaces":4,"negativeAllowed":true,"name":"LgeNum","id":5,"eepromAddress":10,"readOnly":false,"localOnly":false,"visible":true}},{"parentId":0,"type":"textItem","item":{"textLength":6,"itemType":"PLAIN_TEXT","name":"Text","id":6,"eepromAddress":4,"readOnly":false,"localOnly":false,"visible":true}},{"parentId":0,"type":"scrollItem","item":{"itemWidth":10,"eepromOffset":0,"numEntries":20,"choiceMode":"CUSTOM_RENDERFN","name":"Choose Item","id":8,"eepromAddress":18,"readOnly":false,"localOnly":false,"visible":true}},{"parentId":0,"type":"analogItem","item":{"maxValue":65000,"offset":0,"divisor":0,"unitName":"","name":"Commits","id":7,"eepromAddress":-1,"readOnly":true,"localOnly":false,"visible":true}}],"codeOptions":{"embeddedPlatform":"ARDUINO","lastDisplayUuid":"bcd5fe34-9e9f-4fcb-9edf-f4e3caca0674","lastInputUuid":"7daa6a81-dd09-422e-b83c-bda5045abaef","lastRemoteUuid":"2c101fec-1f7d-4ff3-8d2b-992ad41e7fcb","lastThemeUuid":"850dc0a3-f534-47c2-94d8-1e64ff368a54","applicationUUID":"2ba37227-a412-40b7-94e7-42caf9bb0ff4","applicationName":"DfRobot","lastProperties":[{"name":"UNO_OR_FULL","latestValue":"unoLcd","subsystem":"DISPLAY"},{"name":"UPDATES_PER_SEC","latestValue":"2","subsystem":"DISPLAY"},{"name":"ITEM_FONT","latestValue":"def:,1","subsystem":"THEME"},{"name":"TITLE_FONT","latestValue":"def:,1","subsystem":"THEME"},{"name":"FONT_INCLUDE_FOLDER","latestValue":"","subsystem":"THEME"},{"name":"BORDER_FOR_ACTIONS","latestValue":"0","subsystem":"THEME"},{"name":"TITLE_SHOW_MODE","latestValue":"TITLE_FIRST_ROW","subsystem":"THEME"},{"name":"USE_SLIDER_ANALOG","latestValue":"true","subsystem":"THEME"}],"namingRecursive":false,"saveToSrc":false,"useCppMain":false}}
1+
{
2+
"version": "1.00",
3+
"projectName": "/Users/dave/Documents/Arduino/tcLibraryDev/lib/tcMenu/examples/analogDfRobot/analogDfRobot.emf",
4+
"author": "dave",
5+
"items": [
6+
{
7+
"parentId": 0,
8+
"type": "analogItem",
9+
"item": {
10+
"maxValue": 1024,
11+
"offset": 0,
12+
"divisor": 1,
13+
"unitName": "",
14+
"name": "Value A0",
15+
"variableName": "ValueA0",
16+
"id": 1,
17+
"eepromAddress": -1,
18+
"readOnly": true,
19+
"localOnly": false,
20+
"visible": true
21+
}
22+
},
23+
{
24+
"parentId": 0,
25+
"type": "subMenu",
26+
"item": {
27+
"secured": false,
28+
"name": "LED States",
29+
"id": 2,
30+
"eepromAddress": -1,
31+
"readOnly": false,
32+
"localOnly": false,
33+
"visible": true
34+
}
35+
},
36+
{
37+
"parentId": 2,
38+
"type": "boolItem",
39+
"item": {
40+
"naming": "ON_OFF",
41+
"name": "L1",
42+
"id": 3,
43+
"eepromAddress": 2,
44+
"functionName": "onLed1",
45+
"readOnly": false,
46+
"localOnly": false,
47+
"visible": true
48+
}
49+
},
50+
{
51+
"parentId": 2,
52+
"type": "boolItem",
53+
"item": {
54+
"naming": "ON_OFF",
55+
"name": "L2",
56+
"id": 4,
57+
"eepromAddress": 3,
58+
"functionName": "onLed2",
59+
"readOnly": false,
60+
"localOnly": false,
61+
"visible": true
62+
}
63+
},
64+
{
65+
"parentId": 0,
66+
"type": "largeNumItem",
67+
"item": {
68+
"digitsAllowed": 8,
69+
"decimalPlaces": 4,
70+
"negativeAllowed": true,
71+
"name": "LgeNum",
72+
"id": 5,
73+
"eepromAddress": 10,
74+
"readOnly": false,
75+
"localOnly": false,
76+
"visible": true
77+
}
78+
},
79+
{
80+
"parentId": 0,
81+
"type": "textItem",
82+
"item": {
83+
"textLength": 6,
84+
"itemType": "PLAIN_TEXT",
85+
"name": "Text",
86+
"id": 6,
87+
"eepromAddress": 4,
88+
"readOnly": false,
89+
"localOnly": false,
90+
"visible": true
91+
}
92+
},
93+
{
94+
"parentId": 0,
95+
"type": "scrollItem",
96+
"item": {
97+
"itemWidth": 10,
98+
"eepromOffset": 0,
99+
"numEntries": 20,
100+
"choiceMode": "CUSTOM_RENDERFN",
101+
"name": "Choose Item",
102+
"id": 8,
103+
"eepromAddress": 18,
104+
"readOnly": false,
105+
"localOnly": false,
106+
"visible": true
107+
}
108+
},
109+
{
110+
"parentId": 0,
111+
"type": "analogItem",
112+
"item": {
113+
"maxValue": 65000,
114+
"offset": 0,
115+
"divisor": 0,
116+
"unitName": "",
117+
"name": "Commits",
118+
"id": 7,
119+
"eepromAddress": -1,
120+
"readOnly": true,
121+
"localOnly": false,
122+
"visible": true
123+
}
124+
}
125+
],
126+
"codeOptions": {
127+
"embeddedPlatform": "ARDUINO",
128+
"lastDisplayUuid": "bcd5fe34-9e9f-4fcb-9edf-f4e3caca0674",
129+
"lastInputUuid": "7daa6a81-dd09-422e-b83c-bda5045abaef",
130+
"lastRemoteUuid": "2c101fec-1f7d-4ff3-8d2b-992ad41e7fcb",
131+
"lastThemeUuid": "850dc0a3-f534-47c2-94d8-1e64ff368a54",
132+
"applicationUUID": "2ba37227-a412-40b7-94e7-42caf9bb0ff4",
133+
"applicationName": "DfRobot",
134+
"lastProperties": [
135+
{
136+
"name": "UNO_OR_FULL",
137+
"latestValue": "unoLcd",
138+
"subsystem": "DISPLAY"
139+
},
140+
{
141+
"name": "UPDATES_PER_SEC",
142+
"latestValue": "2",
143+
"subsystem": "DISPLAY"
144+
},
145+
{
146+
"name": "ITEM_FONT",
147+
"latestValue": "def:,1",
148+
"subsystem": "THEME"
149+
},
150+
{
151+
"name": "TITLE_FONT",
152+
"latestValue": "def:,1",
153+
"subsystem": "THEME"
154+
},
155+
{
156+
"name": "BORDER_FOR_ACTIONS",
157+
"latestValue": "0",
158+
"subsystem": "THEME"
159+
},
160+
{
161+
"name": "TITLE_SHOW_MODE",
162+
"latestValue": "TITLE_FIRST_ROW",
163+
"subsystem": "THEME"
164+
},
165+
{
166+
"name": "USE_SLIDER_ANALOG",
167+
"latestValue": "true",
168+
"subsystem": "THEME"
169+
},
170+
{
171+
"name": "NEED_EDITING_ICONS",
172+
"latestValue": "false",
173+
"subsystem": "THEME"
174+
}
175+
],
176+
"namingRecursive": false,
177+
"saveToSrc": false,
178+
"useCppMain": false
179+
}
180+
}

examples/analogDfRobot/analogDfRobot.ino

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ ArduinoAnalogDevice analog;
1111
//using namespace tcgfx;
1212

1313
void setup() {
14-
/* auto& factory = renderer.getLcdDisplayPropertiesFactory();
15-
// we now create a grid for the two led controls in the submenu, this shows how to override the default grid for a few items.
16-
// In most cases the automatic rendering works fine when a few items are overriden as long as the row you request hasn't yet been taken.
17-
factory.addGridPosition(&menuL1, GridPosition(GridPosition::DRAW_TEXTUAL_ITEM, GridPosition::JUSTIFY_TITLE_LEFT_WITH_VALUE, 2, 1, 1, 1));
18-
factory.addGridPosition(&menuL2, GridPosition(GridPosition::DRAW_TEXTUAL_ITEM, GridPosition::JUSTIFY_RIGHT_WITH_VALUE, 2, 2, 1, 1));*/
1914
// first we setup the menu
2015
setupMenu();
2116

@@ -24,7 +19,6 @@ void setup() {
2419
analog.initPin(A1, DIR_IN);
2520

2621
// now we read the value of A0 every 200millis and set it onto a menu item
27-
menuValueA0.setReadOnly(true);
2822
taskManager.scheduleFixedRate(200, [] {
2923
menuValueA0.setCurrentValue(int(analog.getCurrentFloat(A1) * 100.0));
3024
});
@@ -74,3 +68,5 @@ int CALLBACK_FUNCTION fnChooseItemRtCall(RuntimeMenuItem * item, uint8_t row, Re
7468
}
7569

7670

71+
72+

examples/analogDfRobot/analogDfRobot_menu.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
// Global variable declarations
1515

1616
const PROGMEM ConnectorLocalInfo applicationInfo = { "DfRobot", "2ba37227-a412-40b7-94e7-42caf9bb0ff4" };
17-
1817
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
1918
LiquidCrystalRenderer renderer(lcd, 16, 2);
2019

@@ -41,6 +40,9 @@ AnalogMenuItem menuValueA0(&minfoValueA0, 0, &menuLEDStates);
4140
// Set up code
4241

4342
void setupMenu() {
43+
menuValueA0.setReadOnly(true);
44+
menuCommits.setReadOnly(true);
45+
4446
lcd.begin(16, 2);
4547
renderer.setUpdatesPerSecond(2);
4648
lcd.configureBacklightPin(10);
@@ -50,8 +52,5 @@ void setupMenu() {
5052
menuMgr.initForUpDownOk(&renderer, &menuValueA0, DF_KEY_DOWN, DF_KEY_UP, DF_KEY_SELECT);
5153
menuMgr.setBackButton(DF_KEY_LEFT);
5254
menuMgr.setNextButton(DF_KEY_RIGHT);
53-
54-
// Read only and local only function calls
55-
menuCommits.setReadOnly(true);
5655
}
5756

examples/analogDfRobot/analogDfRobot_menu.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@
1313

1414
#include <Arduino.h>
1515
#include <tcMenu.h>
16-
1716
#include <LiquidCrystalIO.h>
1817
#include "tcMenuLiquidCrystal.h"
1918
#include <DfRobotInputAbstraction.h>
2019
#include <ScrollChoiceMenuItem.h>
2120
#include <RuntimeMenuItem.h>
2221
#include <EditableLargeNumberMenuItem.h>
2322

24-
// all define statements needed
25-
#define UNO_OR_FULL unoLcd
26-
#define UPDATES_PER_SEC 2
23+
void setupMenu(); // forward reference of the menu setup function.
24+
extern const PROGMEM ConnectorLocalInfo applicationInfo; // contains app name and ID
25+
26+
// Global variables that need exporting
2727

28-
// all variables that need exporting
2928
extern LiquidCrystal lcd;
3029
extern LiquidCrystalRenderer renderer;
3130

32-
// all menu item forward references.
31+
// Global Menu Item exports
32+
3333
extern AnalogMenuItem menuCommits;
3434
extern ScrollChoiceMenuItem menuChooseItem;
3535
extern TextMenuItem menuText;
@@ -39,7 +39,9 @@ extern BooleanMenuItem menuL1;
3939
extern BackMenuItem menuBackLEDStates;
4040
extern SubMenuItem menuLEDStates;
4141
extern AnalogMenuItem menuValueA0;
42-
extern const ConnectorLocalInfo applicationInfo;
42+
43+
// Provide a wrapper to get hold of the root menu item
44+
inline MenuItem& rootMenuItem() { return menuValueA0; }
4345

4446
// Callback functions must always include CALLBACK_FUNCTION after the return type
4547
#define CALLBACK_FUNCTION
@@ -48,6 +50,4 @@ int fnChooseItemRtCall(RuntimeMenuItem* item, uint8_t row, RenderFnMode mode, ch
4850
void CALLBACK_FUNCTION onLed1(int id);
4951
void CALLBACK_FUNCTION onLed2(int id);
5052

51-
void setupMenu();
52-
5353
#endif // MENU_GENERATED_CODE_H

0 commit comments

Comments
 (0)