Hi all,
I'm working on a set of gauges for my car. I have an LCD display (the 1.28" Waveshare one) that I'm planning on using for displaying oil temperature and pressure, and I'm using an Arduino Uno to control it.
I've got 2 problems. I'll open a separate post for the second one. The first problem is that my LCD display suddenly stopped working with the Adafruit_GC9A01A.h library. I have some strange symptoms:
The display was showing my graphic perfectly fine to begin with. I had been making tweaks to my code to get the graphics I wanted. Then I uploaded the code once more after changing a comment (I know it was unnecessary, but I did it) and the screen went blank, with the backlight still on.
The display works perfectly fine with the GUI_Paint.h test code that waveshare provides on their website. It displays everything perfectly, exactly as it did when I first got the display.
When I tested that out, I then uploaded my original display code back to the Arduino, and it faded to blank. The backlight stayed on, but the screen was all blank. I had tried this previously a couple of times, and the screen went black with the backlight on every time. However this time, the waveshare example graphic is flashing on the screen once about every 10 seconds, and then it goes blank again.
Here are my connections:
They seem fairly standard from what I've been seeing on similar projects online.
Here is the example code from Waveshare that works on my display:
#include <SPI.h>
#include "LCD_Driver.h"
#include "GUI_Paint.h"
#include "image.h"
void setup()
{
Config_Init();
LCD_Init();
LCD_SetBacklight(1000);
Paint_NewImage(LCD_WIDTH, LCD_HEIGHT, 0, BLACK);
Paint_Clear(BLACK);
Paint_DrawCircle(120,120, 120, BLUE ,DOT_PIXEL_2X2,DRAW_FILL_EMPTY);
Paint_DrawLine (120, 0, 120, 12,GREEN ,DOT_PIXEL_4X4,LINE_STYLE_SOLID);
Paint_DrawLine (120, 228, 120, 240,GREEN ,DOT_PIXEL_4X4,LINE_STYLE_SOLID);
Paint_DrawLine (0, 120, 12, 120,GREEN ,DOT_PIXEL_4X4,LINE_STYLE_SOLID);
Paint_DrawLine (228, 120, 240, 120,GREEN ,DOT_PIXEL_4X4,LINE_STYLE_SOLID);
Paint_DrawImage(gImage_70X70, 85, 25, 70, 70);
Paint_DrawString_CN(56,140, "微雪电子", &Font24CN,BLACK, WHITE);
Paint_DrawString_EN(123, 123, "WAVESHARE",&Font16, BLACK, GREEN);
Paint_DrawLine (120, 120, 70, 70,YELLOW ,DOT_PIXEL_3X3,LINE_STYLE_SOLID);
Paint_DrawLine (120, 120, 176, 64,BLUE ,DOT_PIXEL_3X3,LINE_STYLE_SOLID);
Paint_DrawLine (120, 120, 120, 210,RED ,DOT_PIXEL_2X2,LINE_STYLE_SOLID);
}
void loop()
{
}
/*********************************************************************************************************
END FILE
*********************************************************************************************************/
Here is the code that I made to display the gauge graphics:
#include "SPI.h"
//#include <TFT.h> // Arduino LCD library
#include "Adafruit_GC9A01A.h"
// Define pins for display interface. You'll probably need to edit this for
// your own needs:
// Pinout when using Seed Round Display for XIAO in combination with
// Seeed XIAO RP2040. Other (non-RP2040) XIAO boards, any Adafruit Qt Py
// boards, and other GC9A01A display breakouts will require different pins.
// ALL OTHER BOARDS - EDIT AS NEEDED
// Other RP2040-based boards might not have "D" pin defines as shown above
// and will use GPIO bit numbers. On non-RP2040 boards, you can usually use
// pin numbers silkscreened on the board.
#define TFT_DC 7
#define TFT_CS 10
// If display breakout has a backlight control pin, that can be defined here
// as TFT_BL. On some breakouts it's not needed, backlight is always on.
// Display constructor for primary hardware SPI connection -- the specific
// pins used for writing to the display are unique to each board and are not
// negotiable. "Soft" SPI (using any pins) is an option but performance is
// reduced; it's rarely used, see header file for syntax if needed.
Adafruit_GC9A01A tft(TFT_CS, TFT_DC);
//define variables for "graphic"
//x variables
#define x1 75
#define x2 x1+4
#define x3 x2+17
#define x4 x3+14
#define x5 x4+6
#define x6 x5+6
#define x7 x6+6
#define x8 x7+6
#define x9 x8+9
#define x10 x9+20
#define x11 x10+6
#define x12 x11+3
//y variables
#define y1 15
#define y2 y1+5
#define y3 y2+5
#define y4 y3+1
#define y5 y4+3
#define y6 y5+4
#define y7 y6+4
#define y8 y7+15
void setup() {
// put your setup code here, to run once:
tft.begin(); //required to start executing tft commands
tft.fillScreen(GC9A01A_BLACK); //reset screen to black prior to starting readout
//graphic, pain in the ass because can't load images.
//manually defined all the lines and fills needed
//line definition
tft.drawLine(x4, y2, x6, y2, 0xDA80); //point 1 to 3
tft.drawLine(x4, y2-1, x6, y2-1, 0xDA80); //fill
tft.drawLine(x4, y2+1, x6, y2+1, 0xDA80); //fill
tft.drawLine(x5, y2, x5, y5, 0xDA80); //point 2 to 4
tft.drawLine(x5+1, y2, x5+1, y5, 0xDA80); //fill
tft.drawLine(x5-1, y2, x5-1, y5, 0xDA80); //fill
tft.drawLine(x7, y5, x3, y5, 0xDA80); //point 5 to 15
tft.drawLine(x7, y5+1, x3, y5+1, 0xDA80); //fill
tft.drawLine(x7, y5-1, x3, y5-1, 0xDA80); //fill
tft.drawLine(x7, y5, x8, y6, 0xDA80); //point 5 to 6
tft.drawLine(x7+1, y5, x8+1, y6, 0xDA80); //fill
tft.drawLine(x7-1, y5, x8-1, y6, 0xDA80); //fill
tft.drawLine(x7, y5+1, x8, y6+1, 0xDA80); //fill
tft.drawLine(x7, y5-1, x8, y6-1, 0xDA80); //fill
tft.drawLine(x8, y6, x10, y3, 0xDA80); //point 6 to 7
tft.drawLine(x8-1, y6, x10-1, y3, 0xDA80); //fill
tft.drawLine(x8+1, y6, x10+1, y3, 0xDA80); //fill
tft.drawLine(x8, y6-1, x10, y3-1, 0xDA80); //fill
tft.drawLine(x8, y6+1, x10, y3+1, 0xDA80); //fill
tft.drawLine(x10, y3, x11, y5, 0xDA80); //point 7 to 8
tft.drawLine(x10-1, y3, x11-1, y5, 0xDA80); //fill
tft.drawLine(x10+1, y3, x11+1, y5, 0xDA80); //fill
tft.drawLine(x10, y3-1, x11, y5-1, 0xDA80); //fill
tft.drawLine(x10, y3+1, x11, y5+1, 0xDA80); //fill
tft.drawLine(x10, y3, x9, y8, 0xDA80); //point 7 to 9
tft.drawLine(x10-1, y3, x9-1, y8, 0xDA80); //fill
tft.drawLine(x10+1, y3, x9+1, y8, 0xDA80); //fill
tft.drawLine(x10, y3-1, x9, y8-1, 0xDA80); //fill
tft.drawLine(x10, y3+1, x9, y8+1, 0xDA80); //fill
tft.drawLine(x9, y8, x3, y8, 0xDA80); //point 9 to 10
tft.drawLine(x9-1, y8, x3-1, y8, 0xDA80); //fill
tft.drawLine(x9+1, y8, x3+1, y8, 0xDA80); //fill
tft.drawLine(x9, y8-1, x3, y8-1, 0xDA80); //fill
tft.drawLine(x9, y8+1, x3, y8+1, 0xDA80); //fill
tft.drawLine(x3, y8, x3, y3, 0xDA80); //point 10 to 14
tft.drawLine(x3-1, y8, x3-1, y3, 0xDA80); //fill
tft.drawLine(x3+1, y8, x3+1, y3, 0xDA80); //fill
tft.drawLine(x3, y7, x1, y4, 0xDA80); //point 11 to 12
tft.drawLine(x3-1, y7, x1-1, y4, 0xDA80); //fill
tft.drawLine(x3+1, y7, x1+1, y4, 0xDA80); //fill
tft.drawLine(x3, y7-1, x1, y4-1, 0xDA80); //fill
tft.drawLine(x3, y7+1, x1, y4+1, 0xDA80); //fill
tft.drawLine(x1, y4, x2, y1, 0xDA80); //point 12 to 13
tft.drawLine(x1-1, y4, x2-1, y1, 0xDA80); //fill
tft.drawLine(x1+1, y4, x2+1, y1, 0xDA80); //fill
tft.drawLine(x1, y4-1, x2, y1-1, 0xDA80); //fill
tft.drawLine(x1, y4+1, x2, y1+1, 0xDA80); //fill
tft.drawLine(x2, y1, x3, y3, 0xDA80); //point 13 to 14
tft.drawLine(x2-1, y1, x3-1, y3, 0xDA80); //fill
tft.drawLine(x2+1, y1, x3+1, y3, 0xDA80); //fill
tft.drawLine(x2, y1-1, x3, y3-1, 0xDA80); //fill
tft.drawLine(x2, y1+1, x3, y3+1, 0xDA80); //fill
//droplet
tft.fillTriangle(x11+1, y7-2, x10+5, y7 + 5, x12, y7+5, 0xDA80); //triangle filled
tft.fillCircle(x10+5+2, y7+5, 2,0xDA80); //circle filled
//split lines
//under oil can
tft.drawFastHLine(0, y8+9, 240, 0xDA80);
tft.drawFastHLine(0, y8+10, 240, 0xDA80);
tft.drawFastHLine(0, y8+11, 240, 0xDA80);
//over JSB
tft.drawFastHLine(0, 240-(y8+9), 240, 0xDA80);
tft.drawFastHLine(0, 240-(y8+10), 240, 0xDA80);
tft.drawFastHLine(0, 240-(y8+11), 240, 0xDA80);
//JSB label
tft.setTextSize(4);
//tft.setTextColor(0x75C8);
tft.setTextColor(0x9929);
tft.setCursor(87, 195);
tft.println("JSB");
//dividing F and PSI
tft.drawLine(240-x1, y8+9, x1, 240-(y8+10), 0xDA80);
tft.drawLine(240-x1-1, y8+9, x1-1, 240-(y8+10), 0xDA80); //fill
tft.drawLine(240-x1+1, y8+9, x1+1, 240-(y8+10), 0xDA80); //fill
tft.drawLine(240-x1, y8+9, x1, 240-(y8+10)-1, 0xDA80); //fill
tft.drawLine(240-x1, y8+9+1, x1, 240-(y8+10)+1, 0xDA80); //fill
//labeling F
tft.setCursor(x4-4, y8+25);
tft.setTextColor(0x75C8);
tft.setTextSize(4);
tft.println("F");
tft.drawCircle(x4-12, y8+29, 3,0x75C8);
tft.drawCircle(x4-12, y8+29, 4,0x75C8);
//labeling PSI
tft.setCursor(x4-4, 240-(y8+33));
tft.setTextColor(0x75C8);
tft.setTextSize(2);
tft.println("PSI");
//data display initialization
//test number display F
tft.setCursor(15, 105);
tft.setTextColor(0x75C8);
tft.setTextSize(4);
tft.print(250);
//test number display PSI
tft.setCursor(160, 106);
tft.setTextColor(0x75C8);
tft.setTextSize(4);
tft.print(75);
}
void loop() {
// put your main code here, to run repeatedly:
}
This is my first post, so please let me know if I missed something. TIA