Skip to content

Commit f3a3c31

Browse files
Version 2.5.0
1 parent 90a40ce commit f3a3c31

49 files changed

Lines changed: 4038 additions & 1432 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
0. A C++ Library to connect electronic displays to linux based single board computers.
3232
1. Dynamic install-able Linux C++ library.
33-
2. 16 fonts included, new Fonts can easily be added by user
33+
2. 16 fonts included, new fonts can easily be added by user
3434
3. Common graphics + print class included
3535
4. Dependency: [lgpio C Library](https://abyz.me.uk/lg/lgpio.html), Provides SPI,I2C, and GPIO control.
3636
5. Mutiple displays supported, see supported-devices, new components can be added.
@@ -56,14 +56,14 @@ sudo make install
5656
* Run following command to download latest release from github.
5757

5858
```sh
59-
curl -sL https://github.com/gavinlyonsrepo/Display_Lib_RPI/archive/2.4.2.tar.gz | tar xz
59+
curl -sL https://github.com/gavinlyonsrepo/Display_Lib_RPI/archive/2.5.0.tar.gz | tar xz
6060
```
6161

6262
3. Install library : Run 'make' and 'sudo make install' to run the makefile to build and then install library.
6363
* It will be installed to usr/local/lib and usr/local/include by default.
6464

6565
```sh
66-
cd Display_Lib_RPI-2.4.2
66+
cd Display_Lib_RPI-2.5.0
6767
make
6868
sudo make install
6969
```
@@ -98,6 +98,7 @@ make run
9898
| ST7789 |16 bit Colour Graphic TFT LCD|SPI HW & SW| [Readme](extra/doc/st7789/README.md)|
9999
| ST7735 |16 bit Colour Graphic TFT LCD|SPI HW & SW| [Readme](extra/doc/st7735/README.md)|
100100
| GC9A01A |16 bit Colour Graphic TFT LCD|SPI HW & SW| [Readme](extra/doc/gc9a01a/README.md)|
101+
| GC9D01N |16 bit Colour Graphic TFT LCD|SPI HW & SW| [Readme](extra/doc/gd901n/README.md)|
101102
| SSD1331 |16 bit Colour Graphic OLED|SPI HW & SW| [Readme](extra/doc/ssd1331/README.md)|
102103
| ERM19264 UC1609|Bi colour Graphic LCD|SPI HW & SW| [Readme](extra/doc/erm19264/README.md) |
103104
| PCD8544|Bi colour Graphic LCD|SPI HW & SW| [Readme](extra/doc/nokia5110/README.md) |

examples/Makefile

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# Display 13 = ILI9341 TFT LCD SPI
2121
# Display 14 = SSD1331 OLED SPI
2222
# Display 15 = GC9A01A TFT LCD SPI
23+
# Display 16 = GC9D01N TFT LCD SPI
2324
# ==================================
2425

2526
# ***********************************************
@@ -95,18 +96,15 @@
9596

9697
# =============== ST7735 TFT LCD SPI =============
9798
#SRC=st7735/hello_world
98-
#SRC=st7735/hello_world_swspi
99-
#SRC=st7735/hello_world_128x160
10099
#SRC=st7735/text_graphics_functions
101100
#SRC=st7735/bitmap_tests
102-
#SRC=st7735/framerate_test
103101
#SRC=st7735/demos
102+
#SRC=st7735/framerate_test
104103
#SRC=st7735/advanced_screen_buffer_mode
105104
#=================================================
106105

107106
# =============== ST7789 TFT LCD SPI =============
108107
#SRC=st7789/hello_world
109-
#SRC=st7789/hello_world_swspi
110108
#SRC=st7789/bitmap_tests
111109
#SRC=st7789/text_graphics_functions
112110
#SRC=st7789/framerate_test
@@ -119,26 +117,27 @@
119117
#SRC=ili9341/text_graphics_functions
120118
#SRC=ili9341/demos
121119
#SRC=ili9341/touch_screen
122-
#SRC=ili9341/hello_world_swspi
123120
#SRC=ili9341/read_diagnostic_swspi
124121
#=================================================
125122

126123
# =============== SSD1331 TFT LCD SPI ============
127124
#SRC=ssd1331/hello_world
128-
#SRC=ssd1331/hello_world_swspi
129-
#SRC=ssd1331/bitmap_tests
130-
#SRC=ssd1331/text_graphics_functions
125+
#SRC=ssd1331/tests
131126
#SRC=ssd1331/demos
132127
#=================================================
133128

134-
# =============== GC9A01A TFT LCD SPI =============
129+
# =============== GC9A01A TFT LCD SPI ============
135130
#SRC=gc9a01/hello_world
136-
#SRC=gc9a01/hello_world_swspi
137-
#SRC=gc9a01/bitmap_tests
138-
#SRC=gc9a01/text_graphics_functions
131+
#SRC=gc9a01/tests
139132
#SRC=gc9a01/demos
140133
#=================================================
141134

135+
# =============== GC9D01N TFT LCD SPI ============
136+
#SRC=gc9d01/hello_world
137+
#SRC=gc9d01/tests
138+
#SRC=gc9d01/demos
139+
#=================================================
140+
142141
# =========== XPT2046 touchscreen basic test =====
143142
#SRC=xpt2046/xpt_test
144143
#=================================================

examples/gc9a01/bitmap_tests/main.cpp

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@
1414
*/
1515

1616
// Section :: libraries
17-
#include <ctime> // for test301
1817
#include <iostream> // cout
1918
#include "Bitmap_test_data.hpp" // Data for test 301-302
2019
#include "GC9A01_TFT_LCD_RDL.hpp"
21-
22-
/// @cond
20+
21+
/// @cond
2322

2423
// Section :: Defines
2524
// Test timing related defines
@@ -47,12 +46,11 @@ int HWSPI_FLAGS = 0; // last 2 LSB bits define SPI mode, see readme, mode 0 for
4746
// Section :: Function Headers
4847
uint8_t Setup(void); // setup + user options
4948
void Test300(void); // Sprite
50-
void Test301(void); // "clock demo" icons, small bi-color bitmaps
49+
void Test301(void); // icons, small bi-color bitmaps
5150
void Test302(void); // 2 color bitmap
5251
void Test303(void); // 24 color bitmap
5352
void Test304(void); // 16 color bitmap
5453
void Test305(void); // 16 color bitmap (from data)
55-
std::string UTC_string(void); // for clock demo
5654
void EndTests(void);
5755

5856
// Section :: MAIN loop
@@ -299,15 +297,6 @@ void Test304(void)
299297
} // end of test
300298

301299

302-
//Return UTC time as a std:.string with format "yyyy-mm-dd hh:mm:ss".
303-
std::string UTC_string()
304-
{
305-
std::time_t time = std::time({});
306-
char timeString[std::size("yyyy-mm-dd hh:mm:ss UTC")];
307-
std::strftime(std::data(timeString), std::size(timeString), "%F %T UTC", std::gmtime(&time));
308-
return timeString;
309-
}
310-
311300
// bitmap 16 colour , Data from array as opposed to file system, When creating data flip image upside down
312301
void Test305(void)
313302
{
@@ -341,5 +330,5 @@ void EndTests(void)
341330

342331

343332
// *************** EOF ****************
344-
345-
/// @endcond
333+
334+
/// @endcond

examples/gc9a01/demos/main.cpp

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,32 @@
1616
#include <iostream> // cout cin
1717
#include <algorithm> // For std::clamp
1818
#include <limits> // menu limits
19-
#include <csignal> //catch user Ctrl+C
2019
#include <termios.h>
2120
#include <unistd.h>
2221
#include <fcntl.h>
2322
#include <sys/select.h>
23+
24+
#include <atomic> // Ctrl + C exit
25+
#include <csignal> // Ctrl + C exit
26+
#include <thread> // Ctrl + C exit
27+
2428
#include "GC9A01_TFT_LCD_RDL.hpp"
2529

2630
/// @cond
2731

2832
// Section :: Globals
2933
GC9A01_TFT myTFT;
30-
int8_t RST_TFT = 25;
31-
int8_t DC_TFT = 24;
32-
int GPIO_CHIP_DEVICE = 0;
3334
uint16_t TFT_WIDTH = 240;// Screen width in pixels
3435
uint16_t TFT_HEIGHT = 240; // Screen height in pixels
35-
int HWSPI_DEVICE = 0; // A SPI device, >= 0. which SPI interface to use
36-
int HWSPI_CHANNEL = 0; // A SPI channel, >= 0. Which Chip enable pin to use
37-
int HWSPI_SPEED = 24000000; // The speed of serial communication in bits per second.
38-
int HWSPI_FLAGS = 0; // last 2 LSB bits define SPI mode, see readme, mode 0 for this device
36+
std::atomic<bool> stopRequested{false}; // Stop signal , Ctrl + c etc
3937

4038
// Section :: Function Headers
4139
uint8_t SetupHWSPI(void); // setup + user options for hardware SPI
42-
std::string UTC_string(void);
43-
void signal_callback_handler(int signum);
4440
void displayMenu(void);
4541
void EndTests(void);
42+
void handleSignal(int){
43+
stopRequested = true; // for CtrL +C
44+
}
4645

4746
// === Demo 1 & 2 ===
4847
void gaugeDemo(uint16_t countLimit = 50); // demo1
@@ -55,6 +54,7 @@ void rotaryMenuDemo(void);
5554
int getchar_timeout(int timeout_ms);
5655
// === Demo 4 ===
5756
void analogClockDemo(uint16_t countLimit = 50);
57+
std::string UTC_string(void);
5858
// === Demo 5 ===
5959
void volumeKnobDemo(void);
6060

@@ -63,8 +63,10 @@ int main()
6363
{
6464
if(SetupHWSPI() != 0) return -1; //Hardware SPI
6565
int choice;
66-
signal(SIGINT, signal_callback_handler); //Ctrl+ c
66+
std::signal(SIGINT, handleSignal); // for user press Ctrl+C
67+
std::signal(SIGTERM, handleSignal);// for kill command
6768
do {
69+
if (stopRequested) break;
6870
displayMenu();
6971
std::cin >> choice;
7072
// Check if input is valid
@@ -90,6 +92,8 @@ int main()
9092
std::cout << std::endl;
9193
} while (choice != 6);
9294

95+
if (stopRequested)
96+
std::cout << "Ctrl+C pressed" << std::endl;
9397
EndTests();
9498
return 0;
9599
}
@@ -100,7 +104,14 @@ int main()
100104
// Hardware SPI setup
101105
uint8_t SetupHWSPI(void)
102106
{
103-
std::cout << "TFT Start Test " << std::endl;
107+
int8_t RST_TFT = 25;
108+
int8_t DC_TFT = 24;
109+
int GPIO_CHIP_DEVICE = 0;
110+
int HWSPI_DEVICE = 0; // A SPI device, >= 0. which SPI interface to use
111+
int HWSPI_CHANNEL = 0; // A SPI channel, >= 0. Which Chip enable pin to use
112+
int HWSPI_SPEED = 24000000; // The speed of serial communication in bits per second.
113+
int HWSPI_FLAGS = 0; // last 2 LSB bits define SPI mode, see readme, mode 0 for this device
114+
std::cout << "TFT Start Demo, Ctrl+c to quit " << std::endl;
104115
// ** USER OPTION 1 GPIO HW SPI **
105116
myTFT.TFTSetupGPIO(RST_TFT, DC_TFT);
106117
//*********************************************
@@ -145,13 +156,6 @@ std::string UTC_string()
145156
return timeString;
146157
}
147158

148-
// Terminate program on ctrl + C
149-
void signal_callback_handler(int signum)
150-
{
151-
EndTests();
152-
exit(signum);
153-
}
154-
155159
// === Demo 1 & 2 ===
156160

157161
void gaugeDemo(uint16_t countLimit) // Demo 1
@@ -189,6 +193,7 @@ void gaugeDemo(uint16_t countLimit) // Demo 1
189193
}
190194
sprintf(buffer, "%03d", currentValue);
191195
myTFT.print(buffer);
196+
if (stopRequested) break; // for Ctrl + C pressed?
192197
}
193198
myTFT.fillScreen(myTFT.RDLC_BLACK);
194199
std::cout << "Gauge Demo Over " << std::endl;
@@ -239,6 +244,7 @@ void arcGauge(uint16_t countLimit) // demo 2
239244
myTFT.print(" Value :: ");
240245
sprintf(buffer, "%03d", currentValue);
241246
myTFT.print(buffer);
247+
if (stopRequested) break; // for Ctrl + C pressed?
242248
}
243249
myTFT.fillScreen(myTFT.RDLC_BLACK);
244250
std::cout << "Arc Gauge Demo Over" << std::endl;
@@ -423,7 +429,7 @@ void rotaryMenuDemo()
423429
drawItem(oldSelected, false);
424430
// Draw new pointer and node
425431
drawItem(selected, true);
426-
drawointer(selected, myTFT.RDLC_YELLOW);
432+
drawPointer(selected, myTFT.RDLC_YELLOW);
427433
// Draw updated label below the new selection
428434
myTFT.setFont(font_mega);
429435
myTFT.setTextColor(myTFT.RDLC_RED, myTFT.RDLC_YELLOW);
@@ -432,6 +438,7 @@ void rotaryMenuDemo()
432438
buf[sizeof(buf) - 1] = '\0';
433439
myTFT.writeCharString(centerX - 50, centerY + radius + 35, buf);
434440
myTFT.setFont(font_default);
441+
if (stopRequested) break; // for Ctrl + C pressed?
435442
}
436443
}
437444
myTFT.fillScreen(myTFT.RDLC_BLACK);
@@ -489,6 +496,7 @@ void analogClockDemo(uint16_t countLimit)
489496
myTFT.drawLine(centerX, centerY, xSecond, ySecond, myTFT.RDLC_YELLOW);
490497
lastSecond = second;
491498
countLimit--;
499+
if (stopRequested) break; // for Ctrl + C pressed?
492500
}
493501
delayMilliSecRDL(10);
494502
std::cout<< utcTime << "\r" << std::flush;
@@ -511,6 +519,7 @@ void volumeKnobDemo(void)
511519
bool running = true;
512520
while (running)
513521
{
522+
if (stopRequested) break; // for Ctrl + C pressed?
514523
char c = getchar_timeout(1000);
515524
switch (c)
516525
{

0 commit comments

Comments
 (0)