Skip to content

Commit

Permalink
#234 incorporate logging library new determination. Example updates
Browse files Browse the repository at this point in the history
  • Loading branch information
davetcc committed Sep 15, 2024
1 parent 2bb3408 commit b6419cd
Show file tree
Hide file tree
Showing 17 changed files with 207 additions and 152 deletions.
70 changes: 70 additions & 0 deletions examples/esp/espCapTouchTft/ThemeCoolBlueModernBuilder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* Cool blue modern theme by tcMenu organisation. This is part of the standard themes shipped with TcMenu.
* This file will not be updated by the designer, you can edit.
* See https://www.thecoderscorner.com/products/arduino-libraries/tc-menu/themes/rendering-with-themes-icons-grids/
*/

#ifndef THEME_COOL_BLUE
#define THEME_COOL_BLUE

#include <graphics/TcThemeBuilder.h>

const color_t coolBlueTitlePalette[] = {RGB(0,0,0), RGB(20,132,255), RGB(192,192,192), RGB(64, 64, 64)};
const color_t coolBlueItemPalette[] = {RGB(255, 255, 255), RGB(0,64,135), RGB(20,133,255), RGB(31,100,178)};
const color_t coolBlueActionPalette[] = {RGB(255, 255, 255), RGB(0,45,120), RGB(20,133,255), RGB(31,100,178)};

#define ACTION_BORDER_WIDTH 0
#define USE_SLIDER_FOR_ANALOG true

/**
* This is one of the stock themes, you can modify it to meet your requirements, and it will not be updated by tcMenu
* Designer unless you delete it. This sets up the fonts, spacing and padding for all items.
* @param gr the graphical renderer
* @param itemFont the font for items
* @param titleFont the font for titles
* @param needEditingIcons if editing icons are needed
*/
void installCoolBlueModernTheme(GraphicsDeviceRenderer& gr, const MenuFontDef& itemFont, const MenuFontDef& titleFont,
bool needEditingIcons, BaseGraphicalRenderer::TitleMode titleMode, bool useUnicode) {

TcThemeBuilder themeBuilder(gr);

themeBuilder.dimensionsFromRenderer()
.withSelectedColors(RGB(31, 88, 100), RGB(255, 255, 255))
.withItemPadding(MenuPadding(4, 3, 4, 3))
.withTitlePadding(MenuPadding(4, 3, 4, 3))
.withRenderingSettings(titleMode, USE_SLIDER_FOR_ANALOG)
.withPalette(coolBlueItemPalette)
.withNativeFont(itemFont.fontData, itemFont.fontMag)
.withSpacing(2);

if(needEditingIcons) {
themeBuilder.withStandardMedResCursorIcons();
}

if(useUnicode) {
themeBuilder.enableTcUnicode();
}

themeBuilder.defaultItemProperties()
.withJustification(GridPosition::JUSTIFY_TITLE_LEFT_VALUE_RIGHT)
.apply();

themeBuilder.defaultTitleProperties()
.withJustification(GridPosition::JUSTIFY_CENTER_WITH_VALUE)
.withNativeFont(titleFont.fontData, titleFont.fontMag)
.withPalette(coolBlueTitlePalette)
.withSpacing(3)
.apply();


themeBuilder.defaultActionProperties()
.withJustification(GridPosition::JUSTIFY_CENTER_WITH_VALUE)
.withPalette(coolBlueActionPalette)
.withBorder(MenuBorder(ACTION_BORDER_WIDTH))
.apply();

themeBuilder.apply();
}

#endif //THEME_COOL_BLUE
72 changes: 0 additions & 72 deletions examples/esp/espCapTouchTft/ThemeDarkModeTraditionalBuilder.h

This file was deleted.

12 changes: 11 additions & 1 deletion examples/esp/espCapTouchTft/espCapTouchTft.emf
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
"lastRemoteUuids": [
"2c101fec-1f7d-4ff3-8d2b-992ad41e7fcb"
],
"lastThemeUuid": "2F1EAB1E-0469-42C8-A222-BE2DF96D6D81",
"lastThemeUuid": "1947F585-9D36-448C-8A80-B425686107BD",
"applicationUUID": "a32450f4-91fc-4747-9e6f-6317dd9e2309",
"applicationName": "espCapTouchTft",
"lastProperties": [
Expand Down Expand Up @@ -312,6 +312,11 @@
"latestValue": "num:,4",
"subsystem": "THEME"
},
{
"name": "BORDER_FOR_ACTIONS",
"latestValue": "0",
"subsystem": "THEME"
},
{
"name": "TITLE_SHOW_MODE",
"latestValue": "TITLE_ALWAYS",
Expand All @@ -322,6 +327,11 @@
"latestValue": "false",
"subsystem": "THEME"
},
{
"name": "USE_SLIDER_ANALOG",
"latestValue": "true",
"subsystem": "THEME"
},
{
"name": "NEED_EDITING_ICONS",
"latestValue": "true",
Expand Down
6 changes: 3 additions & 3 deletions examples/esp/espCapTouchTft/espCapTouchTft_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
use elsewhere.
*/

// Generated for Arduino ESP32 by TcMenu 4.3.1-SNAPSHOT on 2024-08-31T09:58:46.844277900Z.
// Generated for Arduino ESP32 by TcMenu 4.3.1 on 2024-09-08T11:36:32.065655600Z.

#include <tcMenu.h>
#include "espCapTouchTft_menu.h"
#include "ThemeDarkModeTraditionalBuilder.h"
#include "ThemeCoolBlueModernBuilder.h"

// Global variable declarations
const PROGMEM ConnectorLocalInfo applicationInfo = { "espCapTouchTft", "a32450f4-91fc-4747-9e6f-6317dd9e2309" };
Expand Down Expand Up @@ -61,6 +61,6 @@ void setupMenu() {
touchInterrogator.init();
touchScreen.start();
menuMgr.initWithoutInput(&renderer, &menuPercentage);
installDarkModeTraditionalTheme(renderer, MenuFontDef(nullptr, 2), MenuFontDef(nullptr, 4), true, BaseGraphicalRenderer::TITLE_ALWAYS, false);
installCoolBlueModernTheme(renderer, MenuFontDef(nullptr, 2), MenuFontDef(nullptr, 4), true, BaseGraphicalRenderer::TITLE_ALWAYS, false);
}

25 changes: 12 additions & 13 deletions examples/mbed/stm32OledEncoder/ScreenSaverCustomDrawing.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define TCMENUEXAMPLE_SCREENSAVERCUSTOMDRAWING_H

#include "generated/stm32OledEncoder_menu.h"
#include <Fonts/FreeSans9pt7b.h>
#include <Fonts/OpenSansRegular8pt.h>
/**
* Here we implement the custom drawing class so that we can register for drawing and reset events with it.
* When the display times out the reset method is called, where in this case we take over the display. Then
Expand Down Expand Up @@ -34,9 +34,8 @@ class ScreenSaverCustomDrawing : public CustomDrawing {
offsetX = 16;
offsetY = 16;

gfx.clearDisplay();
gfx.setFont(&FreeSans9pt7b);
gfx.setTextSize(1);
gfx->clearDisplay();
gfx->setFont(OpenSansRegular8pt);
}

/**
Expand All @@ -55,22 +54,22 @@ class ScreenSaverCustomDrawing : public CustomDrawing {
offsetY = rand() % 25;
}

gfx.clearDisplay();
gfx->clearDisplay();

gfx.setCursor(offsetX, offsetY + 12);
gfx.print("Mbed demo");
gfx->setCursor(offsetX, offsetY + 12);
gfx->print("Mbed demo");

gfx.setFont(nullptr);
gfx.setCursor(5 + offsetX, 20 + offsetY);
gfx->setFont(OpenSansRegular8pt);
gfx->setCursor(5 + offsetX, 20 + offsetY);
char sz[32];
menuRTCDate.copyValue(sz, sizeof sz);
gfx.print(sz);
gfx->print(sz);

gfx.setCursor(5 + offsetX, 32 + offsetY);
gfx->setCursor(5 + offsetX, 32 + offsetY);
menuRTCTime.copyValue(sz, sizeof sz);
gfx.print(sz);
gfx->print(sz);

gfx.display();
gfx->display();
renderTickCount++;
}

Expand Down
34 changes: 0 additions & 34 deletions examples/mbed/stm32OledEncoder/ThemeMonoInverse.h

This file was deleted.

60 changes: 60 additions & 0 deletions examples/mbed/stm32OledEncoder/ThemeMonoInverseBuilder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#ifndef TCMENU_THEME_MONO_INVERSE
#define TCMENU_THEME_MONO_INVERSE

#include <graphics/TcThemeBuilder.h>

color_t defaultItemPaletteMono[] = {1, 0, 1, 1};
color_t defaultTitlePaletteMono[] = {0, 1, 0, 0};

#define TITLE_PADDING 2
#define TITLE_SPACING 2

/**
* This is one of the stock themes, you can modify it to meet your requirements, and it will not be updated by tcMenu
* Designer unless you delete it. This sets up the fonts, spacing and padding for all items.
* @param gr the graphical renderer
* @param itemFont the font for items
* @param titleFont the font for titles
* @param needEditingIcons if editing icons are needed
*/
void installMonoInverseTitleTheme(GraphicsDeviceRenderer& gr, const MenuFontDef& itemFont, const MenuFontDef& titleFont,
bool needEditingIcons, BaseGraphicalRenderer::TitleMode titleMode, bool useUnicode) {

// See https://tcmenu.github.io/documentation/arduino-libraries/tc-menu/themes/rendering-with-themes-icons-grids/
TcThemeBuilder themeBuilder(gr);
themeBuilder.withSelectedColors(0, 2)
.dimensionsFromRenderer()
.withItemPadding(MenuPadding(1))
.withRenderingSettings(titleMode, false)
.withPalette(defaultItemPaletteMono)
.withNativeFont(itemFont.fontData, itemFont.fontMag)
.withSpacing(1);

if(needEditingIcons) {
themeBuilder.withStandardLowResCursorIcons();
}

if(useUnicode) {
themeBuilder.enableTcUnicode();
}

themeBuilder.defaultTitleProperties()
.withNativeFont(titleFont.fontData, titleFont.fontMag)
.withPalette(defaultTitlePaletteMono)
.withPadding(MenuPadding(TITLE_PADDING))
.withJustification(tcgfx::GridPosition::JUSTIFY_TITLE_LEFT_WITH_VALUE)
.withSpacing(TITLE_SPACING)
.apply();

themeBuilder.defaultActionProperties()
.withJustification(tcgfx::GridPosition::JUSTIFY_TITLE_LEFT_WITH_VALUE)
.apply();

themeBuilder.defaultItemProperties()
.withJustification(tcgfx::GridPosition::JUSTIFY_TITLE_LEFT_VALUE_RIGHT)
.apply();

themeBuilder.apply();
}

#endif //TCMENU_THEME_MONO_INVERSE
Loading

0 comments on commit b6419cd

Please sign in to comment.