Skip to content

Commit 85f5782

Browse files
author
dave
committed
rebuild examples before release.
1 parent 20a3aff commit 85f5782

File tree

4 files changed

+51
-28
lines changed

4 files changed

+51
-28
lines changed

examples/esp/esp32SimHub/esp32SimHub.emf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,11 @@
449449
"latestValue": "TOUCH_HVOLT_ATTEN_1V",
450450
"subsystem": "INPUT"
451451
},
452+
{
453+
"name": "TP_THRESHOLD_DETECTION",
454+
"latestValue": "TOUCH_TRIGGER_BELOW",
455+
"subsystem": "INPUT"
456+
},
452457
{
453458
"name": "UP_SENSOR",
454459
"latestValue": "5",
@@ -539,5 +544,6 @@
539544
},
540545
"packageNamespace": "",
541546
"appIsModular": false
542-
}
547+
},
548+
"stringLists": []
543549
}

examples/esp/esp32SimHub/generated/esp32SimHub_menu.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ TcMenuRemoteServer remoteServer(applicationInfo);
2121
Adafruit_ILI9341 gfx(22, 17, 16);
2222
AdafruitDrawable gfxDrawable(&gfx, 40);
2323
GraphicsDeviceRenderer renderer(30, applicationInfo.name, &gfxDrawable);
24-
ESP32TouchKeysAbstraction esp32Touch(300, TOUCH_HVOLT_2V7, TOUCH_LVOLT_0V5, TOUCH_HVOLT_ATTEN_1V);
24+
ESP32TouchKeysAbstraction esp32Touch(800, TOUCH_HVOLT_2V7, TOUCH_LVOLT_0V5, TOUCH_HVOLT_ATTEN_1V);
2525
SimHubRemoteConnection simhubConnection(&Serial, 3);
2626

2727
// Global Menu Item declarations
2828
const PROGMEM AnyMenuInfo minfoEngineV836S = { "V8 3.6S", 20, 0xffff, 0, onEngineHasChanged };
29-
ActionMenuItem menuEngineV836S(&minfoEngineV836S, NULL, INFO_LOCATION_PGM);
29+
ActionMenuItem menuEngineV836S(&minfoEngineV836S, nullptr, INFO_LOCATION_PGM);
3030
const PROGMEM AnyMenuInfo minfoEngineV630T = { "V6 3.0T", 19, 0xffff, 0, onEngineHasChanged };
3131
ActionMenuItem menuEngineV630T(&minfoEngineV630T, &menuEngineV836S, INFO_LOCATION_PGM);
3232
const PROGMEM AnyMenuInfo minfoEngineI420T = { "I4 2.0T", 18, 0xffff, 0, onEngineHasChanged };
@@ -35,7 +35,7 @@ const PROGMEM AnyMenuInfo minfoCardsI416T = { "I4 1.6T", 17, 0xffff, 0, onEngine
3535
ActionMenuItem menuCardsI416T(&minfoCardsI416T, &menuEngineI420T, INFO_LOCATION_PGM);
3636
const PROGMEM SubMenuInfo minfoEngine = { "Engine", 16, 0xffff, 0, NO_CALLBACK };
3737
BackMenuItem menuBackEngine(&minfoEngine, &menuCardsI416T, INFO_LOCATION_PGM);
38-
SubMenuItem menuEngine(&minfoEngine, &menuBackEngine, NULL, INFO_LOCATION_PGM);
38+
SubMenuItem menuEngine(&minfoEngine, &menuBackEngine, nullptr, INFO_LOCATION_PGM);
3939
const PROGMEM AnyMenuInfo minfoShowDashboard = { "Show dashboard", 9, 0xffff, 0, onShowDash };
4040
ActionMenuItem menuShowDashboard(&minfoShowDashboard, &menuEngine, INFO_LOCATION_PGM);
4141
const PROGMEM AnalogMenuInfo minfoLap = { "Lap", 10, 0xffff, 999, NO_CALLBACK, 0, 1, "" };
@@ -46,12 +46,12 @@ const char enumStrDashboard_2[] PROGMEM = "Custom";
4646
const char* const enumStrDashboard[] PROGMEM = { enumStrDashboard_0, enumStrDashboard_1, enumStrDashboard_2 };
4747
const PROGMEM EnumMenuInfo minfoDashboard = { "Dashboard", 8, 0xffff, 2, onDashChanged, enumStrDashboard };
4848
EnumMenuItem menuDashboard(&minfoDashboard, 0, &menuLap, INFO_LOCATION_PGM);
49-
RENDERING_CALLBACK_NAME_INVOKE(fnSettingsNewLargeNumberRtCall, largeNumItemRenderFn, "New Large Number", -1, NO_CALLBACK)
50-
EditableLargeNumberMenuItem menuSettingsNewLargeNumber(fnSettingsNewLargeNumberRtCall, LargeFixedNumber(4, 1, 0U, 0U, false), 15, true, NULL);
49+
const PROGMEM AnyMenuInfo minfoSettingsNewLargeNumber = { "New Large Number", 15, 0xffff, 0, NO_CALLBACK };
50+
EditableLargeNumberMenuItem menuSettingsNewLargeNumber(&minfoSettingsNewLargeNumber, LargeFixedNumber(4, 1, 0U, 0U, false), true, nullptr, INFO_LOCATION_PGM);
5151
const PROGMEM char pgmStrSettingsIoTMonitorText[] = { "IoT Monitor" };
5252
RemoteMenuItem menuSettingsIoTMonitor(pgmStrSettingsIoTMonitorText, 14, &menuSettingsNewLargeNumber);
53-
RENDERING_CALLBACK_NAME_INVOKE(fnSettingsLargeTestRtCall, largeNumItemRenderFn, "LargeTest", -1, NO_CALLBACK)
54-
EditableLargeNumberMenuItem menuSettingsLargeTest(fnSettingsLargeTestRtCall, LargeFixedNumber(12, 4, 0U, 0U, false), 13, true, &menuSettingsIoTMonitor);
53+
const PROGMEM AnyMenuInfo minfoSettingsLargeTest = { "LargeTest", 13, 0xffff, 0, NO_CALLBACK };
54+
EditableLargeNumberMenuItem menuSettingsLargeTest(&minfoSettingsLargeTest, LargeFixedNumber(12, 4, 0U, 0U, false), true, &menuSettingsIoTMonitor, INFO_LOCATION_PGM);
5555
const PROGMEM BooleanMenuInfo minfoSettingsOverboost = { "Overboost", 12, 0xffff, 1, NO_CALLBACK, NAMING_ON_OFF };
5656
BooleanMenuItem menuSettingsOverboost(&minfoSettingsOverboost, false, &menuSettingsLargeTest, INFO_LOCATION_PGM);
5757
const PROGMEM AnyMenuInfo minfoSettingsShowDialogs = { "Show Dialogs", 11, 0xffff, 0, onShowDialogs };
@@ -65,8 +65,8 @@ const PROGMEM BooleanMenuInfo minfoSimHubLink = { "SimHub Link", 3, 0xffff, 1, o
6565
BooleanMenuItem menuSimHubLink(&minfoSimHubLink, false, &menuSettings, INFO_LOCATION_PGM);
6666
const PROGMEM AnalogMenuInfo minfoTyreTemp = { "Tyre Temp", 7, 0xffff, 255, NO_CALLBACK, 0, 1, "C" };
6767
AnalogMenuItem menuTyreTemp(&minfoTyreTemp, 0, &menuSimHubLink, INFO_LOCATION_PGM);
68-
RENDERING_CALLBACK_NAME_INVOKE(fnGearRtCall, textItemRenderFn, "Gear", -1, NO_CALLBACK)
69-
TextMenuItem menuGear(fnGearRtCall, "", 6, 2, &menuTyreTemp);
68+
const PROGMEM AnyMenuInfo minfoGear = { "Gear", 6, 0xffff, 0, NO_CALLBACK };
69+
TextMenuItem menuGear(&minfoGear, "", 2, &menuTyreTemp, INFO_LOCATION_PGM);
7070
const PROGMEM AnalogMenuInfo minfoRPM = { "RPM", 2, 0xffff, 32000, NO_CALLBACK, 0, 1, "" };
7171
AnalogMenuItem menuRPM(&minfoRPM, 0, &menuGear, INFO_LOCATION_PGM);
7272
const PROGMEM AnalogMenuInfo minfoSpeed = { "Speed", 1, 0xffff, 1000, NO_CALLBACK, 0, 1, "" };
@@ -84,7 +84,8 @@ void setupMenu() {
8484
gfx.begin();
8585
gfx.setRotation(1);
8686
renderer.setUpdatesPerSecond(5);
87-
switches.init(&esp32Touch, SWITCHES_POLL_EVERYTHING, true);
87+
esp32Touch.setTouchTriggerMode(TOUCH_TRIGGER_BELOW);
88+
switches.init(&esp32Touch, SWITCHES_POLL_EVERYTHING, false);
8889
menuMgr.initFor4WayJoystick(&renderer, &menuSpeed, 7, 5, 2, 6, -1, 35);
8990
esp32Touch.ensureInterruptRegistered();
9091
remoteServer.addConnection(&simhubConnection);

examples/esp/esp32SimHub/generated/tcMenuAdaFruitGfx.cpp

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,34 @@ void AdafruitDrawable::drawPolygon(const Coord points[], int numPoints, bool fil
9898
}
9999
}
100100

101+
void AdafruitDrawable::computeBaselineIfNeeded(const GFXfont* font) {
102+
// we cache the last baseline, if the font is unchanged, don't calculate again
103+
if(computedFont == font && computedBaseline > 0) return;
104+
105+
// we need to work out the biggest glyph and maximum extent beyond the baseline, we use 4 chars 'Agj(' for this
106+
const char sz[] = "Agj(";
107+
int height = 0;
108+
int bl = 0;
109+
const char* current = sz;
110+
auto fontLast = pgm_read_word(&font->last);
111+
auto fontFirst = pgm_read_word(&font->first);
112+
while(*current && (*current < fontLast)) {
113+
size_t glIdx = *current - fontFirst;
114+
auto allGlyphs = (GFXglyph*)pgm_read_ptr(&font->glyph);
115+
int glyphHeight = int(pgm_read_byte(&allGlyphs[glIdx].height));
116+
if (glyphHeight > height) height = glyphHeight;
117+
auto yOffset = int8_t(pgm_read_byte(&allGlyphs[glIdx].yOffset));
118+
bl += glyphHeight + yOffset;
119+
current++;
120+
}
121+
computedFont = font;
122+
computedBaseline = bl / 4;
123+
computedHeight = height;
124+
}
101125

102126
Coord AdafruitDrawable::internalTextExtents(const void *f, int mag, const char *text, int *baseline) {
127+
if(mag == 0) mag = 1; // never allow 0 magnification
128+
103129
graphics->setFont(static_cast<const GFXfont *>(f));
104130
graphics->setTextSize(mag);
105131
auto* font = (GFXfont *) f;
@@ -113,23 +139,9 @@ Coord AdafruitDrawable::internalTextExtents(const void *f, int mag, const char *
113139
return Coord(w, h);
114140
}
115141
else {
116-
// we need to work out the biggest glyph and maximum extent beyond the baseline, we use 'Ay(' for this
117-
const char sz[] = "AgyjK(";
118-
int height = 0;
119-
int bl = 0;
120-
const char* current = sz;
121-
auto fontLast = pgm_read_word(&font->last);
122-
auto fontFirst = pgm_read_word(&font->first);
123-
while(*current && (*current < fontLast)) {
124-
size_t glIdx = *current - fontFirst;
125-
auto allGlyphs = (GFXglyph*)pgm_read_ptr(&font->glyph);
126-
unsigned char glyphHeight = pgm_read_byte(&allGlyphs[glIdx].height);
127-
if (glyphHeight > height) height = glyphHeight;
128-
bl = glyphHeight + (signed char)pgm_read_byte(&allGlyphs[glIdx].yOffset);
129-
current++;
130-
}
131-
if(baseline) *baseline = bl;
132-
return Coord((int)w, height);
142+
computeBaselineIfNeeded(font);
143+
if(baseline) *baseline = (computedBaseline * mag);
144+
return Coord(int(w), (computedHeight * mag));
133145
}
134146
}
135147

examples/esp/esp32SimHub/generated/tcMenuAdaFruitGfx.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ class AdafruitDrawable : public DeviceDrawable {
156156
private:
157157
Adafruit_GFX* graphics;
158158
AdafruitCanvasDrawable2bpp* canvasDrawable;
159+
const GFXfont* computedFont = nullptr;
160+
int16_t computedBaseline = 0;
161+
int16_t computedHeight = 0;
159162
protected:
160163
int spriteHeight = 0;
161164
public:
@@ -180,6 +183,7 @@ class AdafruitDrawable : public DeviceDrawable {
180183
void drawPixel(uint16_t x, uint16_t y) override;
181184
Adafruit_GFX* getGfx() { return graphics; }
182185
protected:
186+
void computeBaselineIfNeeded(const GFXfont* font);
183187
explicit AdafruitDrawable() : graphics(nullptr), canvasDrawable(nullptr), spriteHeight(0) {}
184188
void setGraphics(Adafruit_GFX* gfx) { graphics = gfx; }
185189

0 commit comments

Comments
 (0)