Skip to content

Commit b9dd09b

Browse files
committed
Bodmer/TFT_eSPI
experimental support for TFT_eSPI https://github.com/Bodmer/TFT_eSPI
1 parent 823a32a commit b9dd09b

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

examples/adafruitGfx/eTFT/TFT_eSPI/TFT_eSPI.ino

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ www.r-site.net
1212
#include <TFT_eSPI.h>
1313

1414
#include <menu.h>
15-
#include <menuIO/serialIn.h>
16-
#include <menuIO/serialOut.h>
15+
#include <menuIO/serialIO.h>
1716
#include <menuIO/TFT_eSPIOut.h>
17+
// #include <menuIO/chainStream.h>
1818

1919
using namespace Menu;
2020

21-
TFT_eSPI gfx = TFT_eSPI();
21+
TFT_eSPI gfx;
2222

2323
result doAlert(eventMask e, prompt &item);
2424

@@ -120,23 +120,30 @@ const colorDef<uint16_t> colors[] MEMMODE={
120120
{{(uint16_t)White,(uint16_t)Yellow},{(uint16_t)Blue, (uint16_t)Red, (uint16_t)Red}},//titleColor
121121
};
122122

123+
#define MAX_DEPTH 4
124+
123125
serialIn serial(Serial);
124126

125-
MENU_INPUTS(in,&serial);
127+
//MENU_INPUTS(in,&serial);its single, no need to `chainStream`
126128

127-
TFT_eSPIOut gfxOut(gfx);
129+
//define serial output device
130+
idx_t serialTops[MAX_DEPTH]={0};
131+
serialOut outSerial(Serial,serialTops);
128132

129-
#define MAX_DEPTH 4
133+
#define GFX_WIDTH 128
134+
#define GFX_HEIGHT 64
135+
#define fontW 6
136+
#define fontH 9
130137

131-
menuOut* constMEM outputs[] MEMMODE={&outSerial,&gfxOut};//list of output devices
138+
constMEM panel panels[] MEMMODE = {{0, 0, GFX_WIDTH / fontW, GFX_HEIGHT / fontH}};
139+
navNode* nodes[sizeof(panels) / sizeof(panel)]; //navNodes to store navigation status
140+
panelsList pList(panels, nodes, 1); //a list of panels and nodes
141+
idx_t eSpiTops[MAX_DEPTH]={0};
142+
TFT_eSPIOut eSpiOut(gfx,colors,eSpiTops,pList,fontW,fontH+1);
143+
menuOut* constMEM outputs[] MEMMODE={&outSerial,&eSpiOut};//list of output devices
132144
outputsList out(outputs,sizeof(outputs)/sizeof(menuOut*));//outputs list controller
133145

134-
// MENU_OUTPUTS(out,MAX_DEPTH
135-
// ,ADAGFX_OUT(gfx,colors,6*textScale,9*textScale,{0,0,14,8},{14,0,14,8})
136-
// ,SERIAL_OUT(Serial)
137-
// );
138-
139-
NAVROOT(nav,mainMenu,MAX_DEPTH,in,out);
146+
NAVROOT(nav,mainMenu,MAX_DEPTH,serial,out);
140147

141148
//when menu is suspended
142149
result idle(menuOut& o,idleEvent e) {
@@ -162,19 +169,10 @@ void setup() {
162169
//outGfx.usePreview=true;//reserve one panel for preview?
163170
//nav.showTitle=false;//show menu title?
164171

165-
//pinMode(encBtn, INPUT_PULLUP);
166-
#ifdef USE_CLICK_ENCODER
167-
Timer1.initialize(1000);
168-
Timer1.attachInterrupt(timerIsr);
169-
#else
170-
encButton.begin();
171-
encoder.begin();
172-
#endif
173-
174172
SPI.begin();
175173
// gfx.initR(INITR_BLACKTAB);
176174
gfx.setRotation(3);
177-
gfx.setTextSize(textScale);//test scalling
175+
// gfx.setTextSize(textScale);//test scalling
178176
gfx.setTextWrap(false);
179177
gfx.fillScreen(Black);
180178
gfx.setTextColor(Red,Black);

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=ArduinoMenu library
2-
version=4.16.2
2+
version=4.17.0
33
author=Rui Azevedo, [email protected]
44
maintainer=neu-rah, [email protected]
55
sentence=Generic menu/interactivity system

src/menuIO/TFT_eSPIOut.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Use graphics screens (adafruit library based) as menu output
1010
www.r-site.net
1111
1212
***/
13+
#pragma once
14+
1315
#ifndef RSITE_ARDUINOP_MENU_TFT_ESPI
1416
#define RSITE_ARDUINOP_MENU_TFT_ESPI
1517
#include <TFT_eSPI.h>

0 commit comments

Comments
 (0)