Skip to content

Commit 29991c3

Browse files
committed
Very small fix to remoteconnector, #45, start of support for visible flag, examples generated from new UWP client
1 parent c3c5ca4 commit 29991c3

File tree

11 files changed

+209
-70
lines changed

11 files changed

+209
-70
lines changed

examples/analogDfRobot/analogDfRobot.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ void CALLBACK_FUNCTION onLed2(int id) {
3030
// TODO: write your own second LED function..
3131
// Called whenever you change the LED2 menu item..
3232
}
33+

examples/analogDfRobot/analogDfRobot_menu.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
77
All the variables you may need access to are marked extern in this file for easy
88
use elsewhere.
9-
*/
9+
*/
1010

1111
#include <tcMenu.h>
1212
#include "analogDfRobot_menu.h"
1313

1414
// Global variable declarations
1515

16+
const PROGMEM ConnectorLocalInfo applicationInfo = { "DfRobot", "2ba37227-a412-40b7-94e7-42caf9bb0ff4" };
1617
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
1718
LiquidCrystalRenderer renderer(lcd, 16, 2);
1819

@@ -22,17 +23,17 @@ RENDERING_CALLBACK_NAME_INVOKE(fnTextRtCall, textItemRenderFn, "Text", 4, NULL)
2223
TextMenuItem menuText(fnTextRtCall, 6, 6, NULL);
2324
RENDERING_CALLBACK_NAME_INVOKE(fnLgeNumRtCall, largeNumItemRenderFn, "LgeNum", 10, NULL)
2425
EditableLargeNumberMenuItem menuLgeNum(fnLgeNumRtCall, 5, 8, 4, &menuText);
25-
const PROGMEM BooleanMenuInfo minfoLED2 = { "LED 2", 4, 3, 1, onLed2, NAMING_ON_OFF };
26+
const BooleanMenuInfo PROGMEM minfoLED2 = { "LED 2", 4, 3, 1, onLed2, NAMING_ON_OFF };
2627
BooleanMenuItem menuLED2(&minfoLED2, false, NULL);
27-
const PROGMEM BooleanMenuInfo minfoLED1 = { "LED 1", 3, 2, 1, onLed1, NAMING_ON_OFF };
28+
const BooleanMenuInfo PROGMEM minfoLED1 = { "LED 1", 3, 2, 1, onLed1, NAMING_ON_OFF };
2829
BooleanMenuItem menuLED1(&minfoLED1, false, &menuLED2);
30+
const SubMenuInfo PROGMEM minfoLEDStates = { "LED States", 2, 0xFFFF, 0, NULL };
2931
RENDERING_CALLBACK_NAME_INVOKE(fnLEDStatesRtCall, backSubItemRenderFn, "LED States", -1, NULL)
30-
const PROGMEM SubMenuInfo minfoLEDStates = { "LED States", 2, 0xffff, 0, NO_CALLBACK };
3132
BackMenuItem menuBackLEDStates(fnLEDStatesRtCall, &menuLED1);
3233
SubMenuItem menuLEDStates(&minfoLEDStates, &menuBackLEDStates, &menuLgeNum);
33-
const PROGMEM AnalogMenuInfo minfoValueA0 = { "Value A0", 1, 0xffff, 1024, NO_CALLBACK, 0, 1, "" };
34+
const AnalogMenuInfo PROGMEM minfoValueA0 = { "Value A0", 1, 0xFFFF, 1024, NULL, 0, 1, "" };
3435
AnalogMenuItem menuValueA0(&minfoValueA0, 0, &menuLEDStates);
35-
const PROGMEM ConnectorLocalInfo applicationInfo = { "DfRobot", "2ba37227-a412-40b7-94e7-42caf9bb0ff4" };
36+
3637

3738
// Set up code
3839

@@ -43,5 +44,6 @@ void setupMenu() {
4344
pinMode(A0, INPUT);
4445
switches.initialise(inputFromDfRobotShield(), false);
4546
menuMgr.initForUpDownOk(&renderer, &menuValueA0, DF_KEY_DOWN, DF_KEY_UP, DF_KEY_SELECT);
46-
}
4747

48+
49+
}

examples/analogDfRobot/analogDfRobot_menu.h

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,39 @@
66
77
All the variables you may need access to are marked extern in this file for easy
88
use elsewhere.
9-
*/
9+
*/
1010

1111
#ifndef MENU_GENERATED_CODE_H
1212
#define MENU_GENERATED_CODE_H
1313

1414
#include <tcMenu.h>
15+
#include <RuntimeMenuItem.h>
16+
#include <RuntimeMenuItem.h>
1517
#include <LiquidCrystalIO.h>
16-
#include <IoAbstraction.h>
18+
#include "tcMenuLiquidCrystal.h"
1719
#include <DfRobotInputAbstraction.h>
18-
#include <RuntimeMenuItem.h>
1920
#include <EditableLargeNumberMenuItem.h>
20-
#include "tcMenuLiquidCrystal.h"
2121

22-
// all define statements needed
23-
#define TCMENU_USING_PROGMEM true
22+
void setupMenu(); // forward reference of the menu setup function.
23+
extern const PROGMEM ConnectorLocalInfo applicationInfo; // defines the app info to the linker.
24+
25+
// Global variables that need exporting
2426

25-
// all variables that need exporting
2627
extern LiquidCrystal lcd;
2728
extern LiquidCrystalRenderer renderer;
2829

29-
// all menu item forward references.
30+
// Callback functions must always include CALLBACK_FUNCTION after the return type
31+
#define CALLBACK_FUNCTION
32+
33+
// Global Menu Item exports
34+
3035
extern TextMenuItem menuText;
3136
extern EditableLargeNumberMenuItem menuLgeNum;
37+
void CALLBACK_FUNCTION onLed2(int id);
3238
extern BooleanMenuItem menuLED2;
39+
void CALLBACK_FUNCTION onLed1(int id);
3340
extern BooleanMenuItem menuLED1;
34-
extern BackMenuItem menuBackLEDStates;
3541
extern SubMenuItem menuLEDStates;
3642
extern AnalogMenuItem menuValueA0;
37-
extern const ConnectorLocalInfo applicationInfo;
38-
39-
// Callback functions must always include CALLBACK_FUNCTION after the return type
40-
#define CALLBACK_FUNCTION
41-
42-
void CALLBACK_FUNCTION onLed1(int id);
43-
void CALLBACK_FUNCTION onLed2(int id);
44-
45-
void setupMenu();
4643

4744
#endif // MENU_GENERATED_CODE_H
Lines changed: 148 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,148 @@
1-
{"version":"1.00","projectName":"C:\\Users\\dave\\Documents\\Arduino\\libraries\\tcMenu\\examples\\ledFlashNoRemote\\ledFlashNoRemote.emf","author":"dave","lastEdited":{"seconds":1573239124,"nanos":186735200},"namingRecursive":false,"items":[{"parentId":0,"type":"boolItem","item":{"naming":"ON_OFF","name":"BuiltIn LED","id":1,"eepromAddress":2,"functionName":"onLedChange","readOnly":false,"localOnly":false}},{"parentId":0,"type":"analogItem","item":{"maxValue":1024,"offset":0,"divisor":200,"unitName":"V","name":"A0Volts","id":2,"eepromAddress":-1,"readOnly":false,"localOnly":false}},{"parentId":0,"type":"actionMenu","item":{"name":"Save LED state","id":3,"eepromAddress":-1,"functionName":"onSaveState","readOnly":false,"localOnly":false}}],"codeOptions":{"embeddedPlatform":"ARDUINO","lastDisplayUuid":"61f370f4-0294-41cf-8988-1458f242914a","lastInputUuid":"6dd87e7d-e751-4912-a70d-91793b1d3d87","lastRemoteUuid":"2c101fec-1f7d-4ff3-8d2b-992ad41e7fcb","applicationUUID":"86bb814a-5b77-45eb-8050-7dba18617635","applicationName":"LED Blink","lastProperties":[{"name":"LCD_RS","latestValue":"8","subsystem":"DISPLAY"},{"name":"LCD_EN","latestValue":"9","subsystem":"DISPLAY"},{"name":"LCD_D4","latestValue":"4","subsystem":"DISPLAY"},{"name":"LCD_D5","latestValue":"5","subsystem":"DISPLAY"},{"name":"LCD_D6","latestValue":"6","subsystem":"DISPLAY"},{"name":"LCD_D7","latestValue":"7","subsystem":"DISPLAY"},{"name":"LCD_WIDTH","latestValue":"16","subsystem":"DISPLAY"},{"name":"LCD_HEIGHT","latestValue":"2","subsystem":"DISPLAY"},{"name":"LCD_BACKLIGHT","latestValue":"10","subsystem":"DISPLAY"},{"name":"LCD_PWM_PIN","latestValue":"-1","subsystem":"DISPLAY"},{"name":"LCD_IO_DEVICE","latestValue":"","subsystem":"DISPLAY"},{"name":"PULLUP_LOGIC","latestValue":"true","subsystem":"INPUT"},{"name":"INTERRUPT_SWITCHES","latestValue":"false","subsystem":"INPUT"},{"name":"SWITCH_IODEVICE","latestValue":"","subsystem":"INPUT"},{"name":"ENCODER_PIN_A","latestValue":"2","subsystem":"INPUT"},{"name":"ENCODER_PIN_B","latestValue":"3","subsystem":"INPUT"},{"name":"ENCODER_PIN_OK","latestValue":"A3","subsystem":"INPUT"}],"namingRecursive":false}}
1+
{
2+
"lastEdited": {
3+
"seconds": 1581267923,
4+
"nanos": 0
5+
},
6+
"codeOptions": {
7+
"applicationUUID": "86bb814a-5b77-45eb-8050-7dba18617635",
8+
"applicationName": "LED Blink",
9+
"lastInputUuid": "6dd87e7d-e751-4912-a70d-91793b1d3d87",
10+
"lastDisplayUuid": "61f370f4-0294-41cf-8988-1458f242914a",
11+
"lastRemoteUuid": "2c101fec-1f7d-4ff3-8d2b-992ad41e7fcb",
12+
"embeddedPlatform": "ARDUINO_AVR",
13+
"namingRecursive": false,
14+
"saveToSrc": true,
15+
"lastProperties": [
16+
{
17+
"name": "LCD_RS",
18+
"latestValue": "8",
19+
"subsystem": "DISPLAY"
20+
},
21+
{
22+
"name": "LCD_EN",
23+
"latestValue": "9",
24+
"subsystem": "DISPLAY"
25+
},
26+
{
27+
"name": "LCD_D4",
28+
"latestValue": "4",
29+
"subsystem": "DISPLAY"
30+
},
31+
{
32+
"name": "LCD_D5",
33+
"latestValue": "5",
34+
"subsystem": "DISPLAY"
35+
},
36+
{
37+
"name": "LCD_D6",
38+
"latestValue": "6",
39+
"subsystem": "DISPLAY"
40+
},
41+
{
42+
"name": "LCD_D7",
43+
"latestValue": "7",
44+
"subsystem": "DISPLAY"
45+
},
46+
{
47+
"name": "LCD_WIDTH",
48+
"latestValue": "16",
49+
"subsystem": "DISPLAY"
50+
},
51+
{
52+
"name": "LCD_HEIGHT",
53+
"latestValue": "2",
54+
"subsystem": "DISPLAY"
55+
},
56+
{
57+
"name": "LCD_BACKLIGHT",
58+
"latestValue": "10",
59+
"subsystem": "DISPLAY"
60+
},
61+
{
62+
"name": "LCD_PWM_PIN",
63+
"latestValue": "-1",
64+
"subsystem": "DISPLAY"
65+
},
66+
{
67+
"name": "LCD_IO_DEVICE",
68+
"latestValue": "",
69+
"subsystem": "DISPLAY"
70+
},
71+
{
72+
"name": "PULLUP_LOGIC",
73+
"latestValue": "true",
74+
"subsystem": "INPUT"
75+
},
76+
{
77+
"name": "INTERRUPT_SWITCHES",
78+
"latestValue": "false",
79+
"subsystem": "INPUT"
80+
},
81+
{
82+
"name": "SWITCH_IODEVICE",
83+
"latestValue": "",
84+
"subsystem": "INPUT"
85+
},
86+
{
87+
"name": "ENCODER_PIN_A",
88+
"latestValue": "2",
89+
"subsystem": "INPUT"
90+
},
91+
{
92+
"name": "ENCODER_PIN_B",
93+
"latestValue": "3",
94+
"subsystem": "INPUT"
95+
},
96+
{
97+
"name": "ENCODER_PIN_OK",
98+
"latestValue": "A3",
99+
"subsystem": "INPUT"
100+
}
101+
]
102+
},
103+
"projectName": "C:\\Users\\dave\\Documents\\Arduino\\libraries\\tcMenu\\examples\\ledFlashNoRemote\\ledFlashNoRemote.emf",
104+
"namingRecursive": false,
105+
"version": "1.00",
106+
"items": [
107+
{
108+
"parentId": 0,
109+
"type": "boolItem",
110+
"item": {
111+
"name": "BuiltIn LED",
112+
"eepromAddress": 2,
113+
"id": 1,
114+
"readOnly": false,
115+
"localOnly": false,
116+
"functionName": "onLedChange",
117+
"naming": "ON_OFF"
118+
}
119+
},
120+
{
121+
"parentId": 0,
122+
"type": "analogItem",
123+
"item": {
124+
"name": "A0Volts",
125+
"eepromAddress": -1,
126+
"id": 2,
127+
"readOnly": false,
128+
"localOnly": false,
129+
"maxValue": 1024,
130+
"offset": 0,
131+
"divisor": 200,
132+
"unitName": "V"
133+
}
134+
},
135+
{
136+
"parentId": 0,
137+
"type": "actionMenu",
138+
"item": {
139+
"name": "Save LED state",
140+
"eepromAddress": -1,
141+
"id": 3,
142+
"readOnly": false,
143+
"localOnly": false,
144+
"functionName": "onSaveState"
145+
}
146+
}
147+
]
148+
}

examples/ledFlashNoRemote/ledFlashNoRemote_menu.cpp renamed to examples/ledFlashNoRemote/src/ledFlashNoRemote_menu.cpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,36 @@
66
77
All the variables you may need access to are marked extern in this file for easy
88
use elsewhere.
9-
*/
9+
*/
1010

1111
#include <tcMenu.h>
12-
#include "ledFlashNoRemote_menu.h"
12+
#include <ledFlashNoRemote_menu.h>
1313

1414
// Global variable declarations
1515

16-
LiquidCrystal lcd(LCD_RS, LCD_EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7);
17-
LiquidCrystalRenderer renderer(lcd, LCD_WIDTH, LCD_HEIGHT);
16+
const PROGMEM ConnectorLocalInfo applicationInfo = { "LED Blink", "86bb814a-5b77-45eb-8050-7dba18617635" };
17+
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
18+
LiquidCrystalRenderer renderer(lcd, 16, 2);
1819

1920
// Global Menu Item declarations
2021

21-
const PROGMEM AnyMenuInfo minfoSaveLEDState = { "Save LED state", 3, 0xffff, 0, onSaveState };
22-
ActionMenuItem menuSaveLEDState(&minfoSaveLEDState, NULL);
23-
const PROGMEM AnalogMenuInfo minfoA0Volts = { "A0Volts", 2, 0xffff, 1024, NO_CALLBACK, 0, 200, "V" };
22+
const ActionMenuInfo PROGMEM minfoSaveLEDState = { "Save LED state", 3, 0xFFFF, 0, onSaveState };
23+
ActionMenuItem menuSaveLEDState(&minfoSaveLEDState, false, NULL);
24+
const AnalogMenuInfo PROGMEM minfoA0Volts = { "A0Volts", 2, 0xFFFF, 1024, NULL, 0, 200, "V" };
2425
AnalogMenuItem menuA0Volts(&minfoA0Volts, 0, &menuSaveLEDState);
25-
const PROGMEM BooleanMenuInfo minfoBuiltInLED = { "BuiltIn LED", 1, 2, 1, onLedChange, NAMING_ON_OFF };
26+
const BooleanMenuInfo PROGMEM minfoBuiltInLED = { "BuiltIn LED", 1, 2, 1, onLedChange, NAMING_ON_OFF };
2627
BooleanMenuItem menuBuiltInLED(&minfoBuiltInLED, false, &menuA0Volts);
27-
const PROGMEM ConnectorLocalInfo applicationInfo = { "LED Blink", "86bb814a-5b77-45eb-8050-7dba18617635" };
28+
2829

2930
// Set up code
3031

3132
void setupMenu() {
33+
switches.initialise(ioUsingArduino(), true);
34+
menuMgr.initForEncoder(&renderer, menuBuiltInLED, 2, 3, A3);
3235
lcd.setIoAbstraction(ioUsingArduino());
33-
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
34-
lcd.configureBacklightPin(LCD_BACKLIGHT);
36+
lcd.begin(16, 2);
37+
lcd.configureBacklightPin(10);
3538
lcd.backlight();
36-
switches.initialise(ioUsingArduino(), true);
37-
menuMgr.initForEncoder(&renderer, &menuBuiltInLED, ENCODER_PIN_A, ENCODER_PIN_B, ENCODER_PIN_OK);
38-
}
3939

40+
41+
}

examples/ledFlashNoRemote/ledFlashNoRemote_menu.h renamed to examples/ledFlashNoRemote/src/ledFlashNoRemote_menu.h

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
All the variables you may need access to are marked extern in this file for easy
88
use elsewhere.
9-
*/
9+
*/
1010

1111
#ifndef MENU_GENERATED_CODE_H
1212
#define MENU_GENERATED_CODE_H
@@ -15,38 +15,20 @@
1515
#include <LiquidCrystalIO.h>
1616
#include "tcMenuLiquidCrystal.h"
1717

18-
// all define statements needed
19-
#define TCMENU_USING_PROGMEM true
20-
#define LCD_RS 8
21-
#define LCD_EN 9
22-
#define LCD_D4 4
23-
#define LCD_D5 5
24-
#define LCD_D6 6
25-
#define LCD_D7 7
26-
#define LCD_WIDTH 16
27-
#define LCD_HEIGHT 2
28-
#define LCD_BACKLIGHT 10
29-
#define LCD_PWM_PIN -1
30-
#define ENCODER_PIN_A 2
31-
#define ENCODER_PIN_B 3
32-
#define ENCODER_PIN_OK A3
33-
34-
// all variables that need exporting
35-
extern LiquidCrystal lcd;
36-
extern LiquidCrystalRenderer renderer;
37-
38-
// all menu item forward references.
39-
extern ActionMenuItem menuSaveLEDState;
40-
extern AnalogMenuItem menuA0Volts;
41-
extern BooleanMenuItem menuBuiltInLED;
42-
extern const ConnectorLocalInfo applicationInfo;
18+
// Global variables that need exporting
19+
20+
extern LiquidCrystal LiquidCrystal;
21+
extern LiquidCrystalRenderer LiquidCrystalRenderer;
4322

4423
// Callback functions must always include CALLBACK_FUNCTION after the return type
4524
#define CALLBACK_FUNCTION
4625

47-
void CALLBACK_FUNCTION onLedChange(int id);
48-
void CALLBACK_FUNCTION onSaveState(int id);
26+
// Global Menu Item exports
4927

50-
void setupMenu();
28+
void CALLBACK_FUNCTION onSaveState(int id);
29+
extern ActionMenuItem menuSaveLEDState;
30+
extern AnalogMenuItem menuA0Volts;
31+
void CALLBACK_FUNCTION onLedChange(int id);
32+
extern BooleanMenuItem menuBuiltInLED;
5133

5234
#endif // MENU_GENERATED_CODE_H
File renamed without changes.
File renamed without changes.

src/MenuItems.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ MenuItem::MenuItem(MenuType menuType, const AnyMenuInfo* menuInfo, MenuItem* nex
1313
if(menuInfo != NULL) this->info = menuInfo;
1414
this->next = next;
1515
this->setChanged(true); // items always start out needing redrawing.
16+
this->setVisible(true); // always start out visible.
1617
}
1718

1819
bool MenuItem::isSendRemoteNeeded(uint8_t remoteNo) {

src/MenuItems.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ enum Flags : byte {
201201
MENUITEM_EDITING = 4,
202202
/** the menu item is secured, and must be accessed with a pin */
203203
MENUITEM_PIN_SECURED = 5,
204+
/** the menu item is visible on the display and remote */
205+
MENUITEM_PIN_VISIBLE = 6,
204206
/** indicates that remote 0 needs to resend this item */
205207
MENUITEM_REMOTE_SEND0 = 10,
206208
/** indicates that remote 1 needs to resend this item */
@@ -376,6 +378,11 @@ class MenuItem {
376378
/** returns true if this item requires a pin to display, , currently only available locally */
377379
bool isSecured() { return bitRead(flags, MENUITEM_PIN_SECURED); }
378380

381+
/** sets this item to need pin security in order to display, currently only available locally */
382+
void setVisible(bool visible) { bitWrite(flags, MENUITEM_PIN_VISIBLE, visible); }
383+
/** returns true if this item requires a pin to display, , currently only available locally */
384+
bool isVisible() { return bitRead(flags, MENUITEM_PIN_VISIBLE); }
385+
379386
/** gets the next menu (sibling) at this level */
380387
MenuItem* getNext() { return next; }
381388
void setNext(MenuItem* next) { this->next = next; }

0 commit comments

Comments
 (0)