Skip to content

Commit 8eb58f6

Browse files
committed
Fixes before release.
1 parent 3890411 commit 8eb58f6

File tree

6 files changed

+24
-38
lines changed

6 files changed

+24
-38
lines changed

examples/avr/keyboardEthernetShield/keyboardEthernetShield.ino

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <EepromAbstraction.h>
1919
#include <Ethernet.h>
2020
#include <IoLogging.h>
21-
#include <stockIcons/wifiAndConnectionIconsLCD.h>
2221

2322
using namespace tcremote;
2423

@@ -34,12 +33,6 @@ const char pgmListPressed[] PROGMEM = "List Item Pressed";
3433
const char pgmHeaderSavedItem[] PROGMEM = "Saved Item";
3534
const char * romSpaceNames = "item 01item 02item 03item 04item 05item 06item 07item 08item 09item 10 ";
3635

37-
// We add a title widget that shows when a user is connected to the device. Connection icons
38-
// are in the standard icon set we included at the top.
39-
// Yes even on LCD we now support title widgets, but they eat up a few of your custom chars.
40-
// The width must always be 1, and the height is the first custom character that is used.
41-
TitleWidget connectedWidget(iconsConnection, 2, 1, 0);
42-
4336
// used by the take over display logic.
4437
int counter = 0;
4538

@@ -61,15 +54,6 @@ void prepareLayout() {
6154
GridPosition(GridPosition::DRAW_TEXTUAL_ITEM, GridPosition::JUSTIFY_RIGHT_WITH_VALUE, 2, 2, 2, 1));
6255
}
6356

64-
// when there's a change in communication status (client connects for example) this gets called.
65-
void onCommsChange(CommunicationInfo info) {
66-
if(info.remoteNo == 0) {
67-
connectedWidget.setCurrentState(info.connected ? 1 : 0);
68-
}
69-
// this relies on logging in IoAbstraction's ioLogging.h, to turn it on visit the file for instructions.
70-
serdebugF4("Comms notify (rNo, con, enum)", info.remoteNo, info.connected, info.errorMode);
71-
}
72-
7357
void setup() {
7458
//
7559
// If you are using serial (connectivity or logging) and wire they must be initialised
@@ -88,11 +72,6 @@ void setup() {
8872
// Here we set the character to be used for back, next and editing for the "cursor".
8973
renderer.setEditorChars(0b01111111, 0b01111110, '=');
9074

91-
// You can also have title widgets on LCDs, maximum of 7 states. They use up the custom chars 0..7. How it works
92-
// is that you define a custom character for each icon, and treat them just as you would a regular icon. The height
93-
// of the widget is fixed, and the height field instead indicates the first custom character for the first icon.
94-
renderer.setFirstWidget(&connectedWidget);
95-
9675
// we can choose which way RGB items should present, either has HEX_HTML or DECIMAL
9776
Rgb32MenuItem::setRgbPrintMode(HEX_HTML);
9877

@@ -132,10 +111,6 @@ void setup() {
132111
// here we customize the LCD layout for one menu, to have two items per line.
133112
prepareLayout();
134113

135-
// and lastly we register a communication listener, it updates the title widget
136-
// that shows connectivity state on the right corner.
137-
menuConnectivityIoTMonitor.registerCommsNotification(onCommsChange);
138-
139114
// and finally, when the display times out, take over and draw a custom screen
140115
renderer.setResetCallback([] {
141116
onTakeOverDisplay(-1);
@@ -357,6 +332,6 @@ int CALLBACK_FUNCTION customHexEditorRtCall(RuntimeMenuItem* item, uint8_t row,
357332
}
358333
return true;
359334
}
335+
default: return textItemRenderFn(item, row, mode, buffer, bufferSize);
360336
}
361-
return textItemRenderFn(item, row, mode, buffer, bufferSize);
362337
}

examples/avr/keyboardEthernetShield/tcMenuLiquidCrystal.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void copyIntoBuffer(char* buffer, const char* source, int offset, int bufferLen)
8787

8888
void LiquidCrystalRenderer::drawMenuItem(GridPositionRowCacheEntry* entry, Coord where, Coord areaSize, const DrawingFlags& drawingFlags) {
8989
auto* theItem = entry->getMenuItem();
90-
theItem->setChanged(false);
90+
theItem->setChanged(displayNumber, false);
9191
char sz[21];
9292

9393
if(entry->getPosition().getJustification() == GridPosition::JUSTIFY_TITLE_LEFT_VALUE_RIGHT) {

src/MenuItems.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,15 @@ uint16_t MenuItem::getEepromPosition() const
110110
}
111111

112112
void MenuItem::setChanged(bool changed) {
113-
flags = flags | MENUITEM_ALL_CHANGE;
114-
if(isLocalOnly()) return;
115-
flags = flags | MENUITEM_ALL_REMOTES;
113+
if(changed) {
114+
flags = flags | MENUITEM_ALL_CHANGE;
115+
} else {
116+
flags = flags & (~MENUITEM_ALL_CHANGE);
117+
}
118+
119+
if(isLocalOnly() || !changed) return;
120+
121+
setSendRemoteNeededAll();
116122
}
117123

118124
// on avr boards we store all info structures in progmem, so we need this code to

src/MenuItems.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,6 @@ enum Flags : uint8_t {
200200
MENUITEM_CHANGED = 0,
201201
/** the menu has changed and needs drawing by the renderer 1 */
202202
MENUITEM_CHANGED_1 = 1,
203-
/** the menu has changed and needs drawing by the renderer 2 */
204-
MENUITEM_CHANGED_2 = 2,
205203
/** the menu cannot be changed by the renderer or remote, it can be changed by calling the setter. */
206204
MENUITEM_READONLY = 3,
207205
/** the menu must not be sent remotely, and is only available via the local renderer */
@@ -366,8 +364,11 @@ class MenuItem {
366364

367365
bool isInfoProgMem() const { return bitRead(flags, MENUITEM_INFO_STRUCT_PGM); }
368366

369-
/** set the item to be changed, this lets the renderer know it needs painting */
367+
/** set the item to be changed to all renderers, and when changed is true all remotes as well. When clearing
368+
* changed flag prefer to use the numbered version below. */
370369
void setChanged(bool changed);
370+
/** set the item to be changed, this lets a renderer know it needs painting */
371+
void setChanged(int num, bool changed) { bitWrite(flags, (num & 3), changed); }
371372
/** returns the changed state of the item */
372373
bool isChanged(int num = 0) const { return bitRead(flags, (num & 3)); }
373374
/** returns if the menu item needs to be sent remotely */

src/graphics/BaseGraphicalRenderer.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ void BaseGraphicalRenderer::render() {
4848
uint8_t BaseGraphicalRenderer::setActiveItem(MenuItem *item) {
4949
auto ret = BaseMenuRenderer::setActiveItem(item);
5050

51-
if(item->getMenuType() == MENUTYPE_RUNTIME_LIST) {
51+
// if we're drawing a list, clear out the drawing location, lists handled differently
52+
if(menuMgr.getCurrentMenu()->getMenuType() == MENUTYPE_RUNTIME_LIST) {
5253
drawingLocation = CachedDrawingLocation();
5354
return 0;
5455
}
@@ -58,19 +59,22 @@ uint8_t BaseGraphicalRenderer::setActiveItem(MenuItem *item) {
5859
uint16_t totalHeight = calculateHeightTo(activeIndex, rootItem);
5960
int startRow = 0;
6061
uint16_t adjustedHeight = height + (isLastRowExactFit() ? 0 : 1);
62+
serdebugF4("toth, activeidx, adj ", totalHeight, activeIndex, adjustedHeight);
6163

6264
auto startY = 0;
63-
if(titleMode == TITLE_ALWAYS) {
65+
if(titleMode == TITLE_ALWAYS && menuMgr.getRoot() == rootItem) {
6466
startRow++;
6567
startY = heightOfRow(0, true);
6668
adjustedHeight -= startY;
6769
totalHeight -= startY;
6870
}
71+
serdebugF4("sy, sr, adj ", startY, startRow, adjustedHeight);
6972

7073
while (totalHeight > adjustedHeight) {
7174
totalHeight -= heightOfRow(startRow, true);
7275
startRow++;
7376
}
77+
serdebugF3("sr, th", startRow, totalHeight);
7478

7579
// the screen has moved, we must completely redraw the area, and we need a clear first.
7680
if(drawingLocation.getCurrentOffset() != startRow) {
@@ -197,7 +201,7 @@ bool BaseGraphicalRenderer::drawTheMenuItems(int startRow, int startY, bool draw
197201

198202
if (drawEveryLine || item->isChanged(displayNumber)) {
199203
serlogF4(SER_TCMENU_DEBUG, "draw item (pos,id,chg)", i, item->getId(), item->isChanged(displayNumber));
200-
item->setChanged(false);
204+
item->setChanged(displayNumber, false);
201205
taskManager.yieldForMicros(0);
202206
if(itemCfg->getPosition().getGridSize() > 1) {
203207
int colWidth = int(width) / itemCfg->getPosition().getGridSize();
@@ -261,7 +265,7 @@ void BaseGraphicalRenderer::renderList() {
261265

262266
// reset the list item to a normal list again.
263267
runList->asParent();
264-
runList->setChanged(false);
268+
runList->setChanged(displayNumber, false);
265269
setTitleOnDisplay(true);
266270
}
267271

src/graphics/GraphicsDeviceRenderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ namespace tcgfx {
5454

5555
void GraphicsDeviceRenderer::drawMenuItem(GridPositionRowCacheEntry *entry, Coord where, Coord areaSize, const DrawingFlags& drawingFlags) {
5656
redrawNeeded = true;
57-
entry->getMenuItem()->setChanged(false);
57+
entry->getMenuItem()->setChanged(displayNumber, false);
5858

5959
// if it's in a multi grid layout, put a small gap at the start of each one.
6060
if(entry->getPosition().getGridSize() > 1) {

0 commit comments

Comments
 (0)