The alternative example sketch for six different boat gauges came about due to an issue with original code.
Which I also came across and reported it under original project here.
The solution boils down to removing reliance on the needle bounding box coordinates which are pre-populate in the setup()
method:
while (a != 44) {
x[i] = r * cos(rad * a) + sx;
y[i] = r * sin(rad * a) + sy;
x2[i] = (r - 20) * cos(rad * a) + sx;
y2[i] = (r - 20) * sin(rad * a) + sy;
i++;
a++;
// reset "a" on overflow
if (a == 360) {
a = 0;
}
- For live demonstration visit [https://www.youtube.com/watch?v=y_H7HM0oyoo]
- For original code visit VolosR/BoatGauges
- For original code with comments visit iiminov/BoatGauges
- Install ESP32 boards library guide from randomnerdtutorials
- Install TFT_eSPI library by Bodmer through Library Manager (Sketch > Include Library > Manage Libraries or Ctrl+Shift+l)
Open ..\Documents\Arduino\libraries\TFT_eSPI\User_Setup.h
and comment out line 44:
//#define ILI9341_DRIVER
On line 64 uncomment GC9A01 driver:
#define GC9A01_DRIVER
Open ..\Documents\Arduino\libraries\TFT_eSPI\User_Setup_Select.h
and comment out line 24:
//#include <User_Setups/Setup1_ILI9341.h>
On line 105 uncomment GC9A01 setup:
#include <User_Setups/Setup200_GC9A01.h>
Open ..\Documents\Arduino\libraries\TFT_eSPI\User_Setups\Setup200_GC9A01.h
and update pin assignments:
#define TFT_MISO 5
#define TFT_MOSI 2
#define TFT_SCLK 15 // Clock pin
#define TFT_CS 17 // Chip select control pin
#define TFT_DC 16 // Data Command control pin
#define TFT_RST 4 // Reset pin (could connect to Arduino RESET pin)
Image is courtesy of WOKWI.com and some MS Paint work
ESP32 GC9A01
3V3 VCC
GND GND
D15 SCL
D2 SDA
D4 RES
RX2 DC
TX2 CS
D5 BLK