1
1
#include " displayDriver.h"
2
2
3
3
#ifdef T_HMI_DISPLAY
4
-
4
+ #include < FS.h>
5
+ #include < xpt2046.h> // https://github.com/liangyingy/arduino_xpt2046_library
5
6
#include < TFT_eSPI.h>
6
7
#include < TFT_eTouch.h>
7
8
#include " media/images_320_170.h"
11
12
#include " version.h"
12
13
#include " monitor.h"
13
14
#include " OpenFontRender.h"
14
-
15
+ #ifdef TOUCH_ENABLE
16
+ #include " TouchHandler.h"
17
+ #endif
15
18
#include < Arduino.h>
16
19
#include < esp_adc_cal.h>
17
20
@@ -22,15 +25,22 @@ OpenFontRender render;
22
25
TFT_eSPI tft = TFT_eSPI(); // Invoke library, pins defined in User_Setup.h
23
26
TFT_eSprite background = TFT_eSprite(&tft); // Invoke library sprite
24
27
28
+ #ifdef TOUCH_ENABLE
29
+ TouchHandler touchHandler = TouchHandler(tft, ETOUCH_CS, TOUCH_IRQ, SPI);
30
+ #endif
25
31
26
- SPIClass hSPI (HSPI);
27
- // TFT_eTouch<TFT_eSPI> touch(tft, ETOUCH_CS, 0xFF, hSPI);
28
32
bool showbtcprice = false ;
29
33
34
+ unsigned int lowerScreen = 1 ;
35
+
36
+ extern void switchToNextScreen ();
30
37
extern monitor_data mMonitor ;
31
38
extern pool_data pData;
32
39
extern DisplayDriver *currentDisplayDriver;
33
40
41
+ void toggleBottomScreen () { lowerScreen = 3 - lowerScreen; }
42
+
43
+
34
44
uint32_t readAdcVoltage (int pin) {
35
45
esp_adc_cal_characteristics_t adc_chars;
36
46
@@ -70,20 +80,21 @@ void t_hmiDisplay_Init(void)
70
80
Serial.println (" Initialise error" );
71
81
return ;
72
82
}
73
- /* XXX - Pass for first version
83
+
84
+ #ifdef TOUCH_ENABLE
74
85
Serial.println (F (" Initialize the touch screen" ));
75
- hSPI.begin(TOUCH_CLK, TOUCH_MISO, TOUCH_MOSI, ETOUCH_CS);
76
- TFT_eTouchBase::Calibation calibation = { 233, 3785, 3731, 120, 2 };
77
- touch.setCalibration(calibation);
78
- */
86
+ touchHandler.begin (HEIGHT, WIDTH);
87
+ touchHandler.setScreenSwitchCallback (switchToNextScreen);
88
+ touchHandler.setScreenSwitchAltCallback (toggleBottomScreen);
89
+ #endif
90
+
79
91
Serial.println (F (" Turn on the LCD backlight" ));
80
92
pinMode (LED_PIN, OUTPUT);
81
93
pinMode (BK_LIGHT_PIN, OUTPUT);
82
94
digitalWrite (BK_LIGHT_PIN, BK_LIGHT_LEVEL);
83
95
pData.bestDifficulty = " 0" ;
84
96
pData.workersHash = " 0" ;
85
97
pData.workersCount = 0 ;
86
-
87
98
}
88
99
89
100
void t_hmiDisplay_AlternateScreenState (void )
@@ -188,7 +199,11 @@ void t_hmiDisplay_MinerScreen(unsigned long mElapsed)
188
199
render.setFontSize (10 );
189
200
render.rdrawString (data.currentTime .c_str (), 286 , 1 , TFT_BLACK);
190
201
191
- printPoolData ();
202
+ if (lowerScreen == 1 )
203
+ printPoolData ();
204
+ else
205
+ printMemPoolFees (mElapsed );
206
+
192
207
// Push prepared background to screen
193
208
background.pushSprite (0 , 0 );
194
209
}
@@ -226,7 +241,10 @@ void t_hmiDisplay_ClockScreen(unsigned long mElapsed)
226
241
background.setTextColor (0xDEDB , TFT_BLACK);
227
242
228
243
background.drawString (data.currentTime .c_str (), 130 , 50 , GFXFF);
229
- printMemPoolFees (mElapsed );
244
+ if (lowerScreen == 1 )
245
+ printMemPoolFees (mElapsed );
246
+ else
247
+ printPoolData ();
230
248
// Push prepared background to screen
231
249
background.pushSprite (0 , 0 );
232
250
}
@@ -286,7 +304,11 @@ void t_hmiDisplay_GlobalHashScreen(unsigned long mElapsed)
286
304
background.setTextColor (TFT_BLACK);
287
305
background.drawString (data.remainingBlocks .c_str (), 72 , 159 , FONT2);
288
306
289
- printMemPoolFees (mElapsed );
307
+ if (lowerScreen == 1 )
308
+ printMemPoolFees (mElapsed );
309
+ else
310
+ printPoolData ();
311
+
290
312
// Push prepared background to screen
291
313
background.pushSprite (0 , 0 );
292
314
}
@@ -326,7 +348,10 @@ void t_hmiDisplay_BTCprice(unsigned long mElapsed)
326
348
background.setTextSize (1 );
327
349
background.setTextColor (0xDEDB , TFT_BLACK);
328
350
background.drawString (data.btcPrice .c_str (), 300 , 58 , GFXFF);
329
- printPoolData ();
351
+ if (lowerScreen == 1 )
352
+ printPoolData ();
353
+ else
354
+ printMemPoolFees (mElapsed );
330
355
// Push prepared background to screen
331
356
background.pushSprite (0 , 0 );
332
357
}
0 commit comments