Skip to content

Commit 0b10d43

Browse files
version 1.7.1
1 parent 177f4b6 commit 0b10d43

File tree

12 files changed

+419
-251
lines changed

12 files changed

+419
-251
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ SRCS = $(wildcard $(SRC)/*.cpp)
2626
OBJS = $(patsubst $(SRC)%.cpp, $(OBJ)/%.o, $(SRCS))
2727

2828
CXX=g++
29-
CCFLAGS= -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -Iinclude/
29+
CCFLAGS= -march=native -mtune=native -mcpu=native -Iinclude/
3030
LDFLAGS= -lbcm2835
3131

3232
# make

README.md

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* [Bitmaps](#bitmaps)
1616
* [User Adjustments](#user-adjustments)
1717
* [Notes and Issues](#notes-and-issues)
18-
* [Compilation problems](#compilation-problems)
18+
1919

2020
## Overview
2121

@@ -36,13 +36,14 @@
3636

3737
* This is a port of my [Arduino library](https://github.com/gavinlyonsrepo/ERM19264_UC1609)
3838
More details there as well as link to the API(There are some differences between this port and Arduino library most notably use of glyph fonts)
39-
40-
* Development Toolchain ::
41-
1. Raspberry PI 3 model b,
42-
2. C++ complier g++ (Raspbian 8.3.0-6)
43-
3. Raspbian 10 buster OS, 32 bit.
44-
4. bcm2835 Library 1.71 (Dependency)
45-
39+
40+
* Development Tool chain.
41+
1. Raspberry PI 3 model b
42+
2. C++, g++ (Debian 12.2.0)
43+
3. Raspbian , Debian 12 bookworm OS, , 64 bit.
44+
4. kernel : aarch64 Linux 6.1.0-rpi7-rpi-v8
45+
5. bcm2835 Library 1.73 dependency. Provides low level I2C bus, delays and GPIO control.
46+
4647
## Output
4748

4849
Output Screenshots, From left to right top to bottom.
@@ -59,25 +60,23 @@ Output Screenshots, From left to right top to bottom.
5960
## Installation
6061

6162

62-
1. Make sure SPI bus is enabled on your raspberry PI
63-
64-
2. Install the dependency bcm2835 Library if not installed (at time of writing latest version is 1.68.)
63+
1. Install the dependency bcm2835 Library if not installed (at time of writing latest version is 1.73)
6564
* The bcm2835 library is a dependency and provides SPI bus, delays and GPIO control.
6665
* Install the C libraries of bcm2835, [Installation instructions here](http://www.airspayce.com/mikem/bcm2835/)
6766

68-
3. Download the ERM19264_UC1609_RPI library
67+
2. Download the ERM19264_UC1609_RPI library
6968
* Open a Terminal in a folder where you want to download,build & test library
7069
* Run following command to download from github.
7170

7271
```sh
73-
curl -sL https://github.com/gavinlyonsrepo/ERM19264_UC1609_RPI/archive/1.7.tar.gz | tar xz
72+
curl -sL https://github.com/gavinlyonsrepo/ERM19264_UC1609_RPI/archive/1.7.1.tar.gz | tar xz
7473
```
7574

76-
4. Run "make" to run the makefile to install library, it will be
75+
3. Run "make" to run the makefile to install library, it will be
7776
installed to usr/lib and usr/include
7877

7978
```sh
80-
cd ERM19264_UC1609_RPI-1.7
79+
cd ERM19264_UC1609_RPI-1.7.1
8180
make
8281
sudo make install
8382
```
@@ -97,7 +96,9 @@ make run
9796
```
9897

9998
2. There are seven examples files to try out.
100-
To decide which one the makefile builds simply edit "SRC" variable at top of the makefile in examples folder. In the "User SRC directory Option Section". Pick an example "SRC" directory path and ONE ONLY. Comment out the rest and repeat step 1.
99+
To decide which one the makefile builds simply edit "SRC" variable at top of the makefile in examples folder.
100+
In the "User SRC directory Option Section". Pick an example "SRC" directory path and ONE ONLY.
101+
Comment out the rest and repeat step 1.
101102

102103

103104
## Hardware
@@ -112,18 +113,23 @@ There are 3 different colours in range, Parts used purchased from [ebay](https:/
112113
2. ERM19264FS-5 V3 LCD Display UC1609C controller , black on white
113114
3. ERM19264DNS-5 V3 LCD Display UC1609C controller white on black
114115

115-
The UC1609 controller chip is a 3.3V device but the ERM LCD module has a "662k" 3.3V regulator at back.
116-
So the ERM LCD module will run at 5V as well if this is present.
117-
It was always run it at 3.3V during testing.
118-
116+
Wiring Diagram from supplier showing connection to RPI.
119117

120118
![ ERM19264 ](https://github.com/gavinlyonsrepo/ERM19264_UC1609_RPI/blob/main/extras/image/wiring.png)
121119

120+
This wiring Diagram from the manufacturer showing hardware setup connected to an ~8051 MCU, showing both 3.3 volt and 5 volt systems.
121+
Note status of J1 PCB jumper.
122+
123+
![ ERM192642 ](https://github.com/gavinlyonsrepo/ERM19264_UC1609/blob/main/extras/image/connect.jpg)
124+
122125
## Software
123126

124127
### SPI
125128

126-
Hardware and software SPI. Two different class constructors. User can pick the relevant constructor, see examples files. Hardware SPI is recommended, far faster and more reliable but Software SPI allows for more flexible GPIO selection. When running Software SPI it may be necessary on very high frequency MCU's to change the UC1609_HIGHFREQ_DELAY define, It is a microsecond delay by default it is at 0.
129+
Hardware and software SPI. Two different class constructors. User can pick the relevant constructor,
130+
see examples files. Hardware SPI is recommended, far faster and more reliable but Software SPI allows
131+
for more flexible GPIO selection. When running Software SPI it may be necessary on very high
132+
frequency MCU's to change the LCD_HighFreqDelaySet method, It is a microsecond delay by default it is at 0.
127133

128134
The SPI settings are in LCDSPIon function.
129135
Speed is currently at BCM2835_SPI_CLOCK_DIVIDER_64.
@@ -166,7 +172,6 @@ The glyph-fonts use 3 special functions: setFontGlyph drawCharGlyph drawTextGlyp
166172
They cannot currently use the print class, also cannot be inverted.
167173
Inverting only works with the standard fonts because the characters are a uniform size. It's not a sensible thing to do with proportionally-spaced fonts with glyphs of varying sizes and that may overlap.
168174

169-
170175
### Bitmaps
171176

172177
There is a few different ways of displaying bitmaps,
@@ -203,9 +208,3 @@ It is also possible for user to change LCD bias , Temperature coefficient, fram
203208

204209
## Notes and Issues
205210

206-
### Compilation problems
207-
208-
Note the toolchain used in overview section, If you have trouble compiling on other
209-
platforms or OS. For example 64-bit OS, user may need to remove or edit
210-
some of the CCFLAGS in root directory Makefile to allow for Compilation, if you see them throwing errors
211-
See [pull request on SSD1306 project](https://github.com/gavinlyonsrepo/SSD1306_OLED_RPI/pull/2) for details

examples/src/BITMAP/main.cpp

Lines changed: 62 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// URL: https://github.com/gavinlyonsrepo/ERM19264_UC1609_RPI
66
// *****************************
77

8-
98
#include <bcm2835.h>
109
#include <time.h>
1110
#include <stdio.h>
@@ -25,25 +24,58 @@ const uint8_t RAMaddressCtrl = 0x02; // RAM address control: Range 0-7, optional
2524
ERM19264_UC1609 myLCD(myLCDwidth ,myLCDheight, RST, CD) ;
2625

2726
// =============== Function prototype ================
28-
void setup(void);
29-
void myLoop(void);
30-
void EndTest(void);
27+
3128
void Test1(void);
3229
void Test2(void);
3330
void Test3(void);
3431
void Test4(void);
3532
void Test5(void);
33+
bool setup(void);
34+
void myLoop(void);
35+
void EndTest(void);
3636

3737
// ======================= Main ===================
3838
int main(int argc, char **argv)
3939
{
40-
if(!bcm2835_init()){return -1;}
41-
42-
setup();
40+
if(!setup()) {return -1;}
4341
myLoop();
4442
EndTest();
43+
4544
return 0;
4645
}
46+
// ======================= End of main ===================
47+
48+
// ===================== Function Space =====================
49+
bool setup() {
50+
printf("LCD Test Begin\r\n");
51+
// Check if Bcm28235 lib installed and print version.
52+
if(!bcm2835_init())
53+
{
54+
printf("Error 1201: init bcm2835 library , Is it installed ?\r\n");
55+
return false;
56+
}else
57+
{
58+
printf("bcm2835 library Version Number :: %u\r\n",bcm2835_version());
59+
bcm2835_delay(100);
60+
}
61+
62+
if(!myLCD.LCDbegin(RAMaddressCtrl, LCDcontrast, SPICLK_FREQ , SPI_CE_PIN)) // initialize the LCD
63+
{
64+
printf("Error 1202: bcm2835_spi_begin :Cannot start spi, Running as root?\n");
65+
return false;
66+
}
67+
printf("ERM19264 Library version number :: %u \r\n", myLCD.LCDLibVerNumGet());
68+
myLCD.LCDFillScreen(0x33); // display splash screen bars, optional for effect
69+
bcm2835_delay(1500);
70+
return true;
71+
}
72+
73+
void EndTest()
74+
{
75+
myLCD.LCDPowerDown();
76+
bcm2835_close(); // Close library, deallocating allocated memory & closing /dev/mem
77+
printf("LCD End\r\n");
78+
}
4779

4880
//192x64px bitmap,'UC1609' SW used to make https://javl.github.io/image2cpp/ vertical addressing
4981
uint8_t fullScreenBuffer[1537] = {
@@ -166,15 +198,6 @@ const uint8_t BatIcon[16] =
166198
0xfe, 0x02, 0x92, 0x0a, 0x54, 0x2a, 0x38, 0xaa, 0x12, 0xaa, 0x12, 0xaa, 0x12, 0xaa, 0x12, 0xaa
167199
};
168200

169-
void setup()
170-
{
171-
printf("LCD Begin\r\n");
172-
bcm2835_delay(50);
173-
myLCD.LCDbegin(RAMaddressCtrl , LCDcontrast, SPICLK_FREQ , SPI_CE_PIN); // initialize the LCD
174-
myLCD.LCDFillScreen(0xFF); // Clears screen with 1's (i.e fills it)
175-
bcm2835_delay(2000);
176-
}
177-
178201
void myLoop()
179202
{
180203
Test1(); // Method (1) LCD bitmap method
@@ -184,17 +207,11 @@ void myLoop()
184207
Test5(); // Method (5) Drawbitmap to buffer method, horizontal addressing
185208
}
186209

187-
void EndTest()
188-
{
189-
myLCD.LCDPowerDown();
190-
bcm2835_close(); // Close library & /dev/mem, deallocating any allocated memory
191-
printf("LCD End\r\n");
192-
}
193-
194210

195211
void Test1(void)
196212
{
197213
// Method (1) LCD bitmap method , writes data directly to screen
214+
printf("Test1: LCDBitmap method , Full screen\n");
198215
myLCD.LCDBitmap(0, 0 , myLCDwidth, myLCDheight, fullScreenBuffer);
199216
bcm2835_delay(5000);
200217
myLCD.LCDFillScreen(0x00);
@@ -205,6 +222,7 @@ void Test2(void)
205222
// Method (2) LCD buffer method, writes data directly to screen
206223
// This function is called internally by LCDupdate to print buffer
207224
// to screen but can be called externally as well as shown.
225+
printf("Test2: LCDBuffer method , Two icons\n");
208226
myLCD.LCDBuffer(0, 0, 16, 8, (uint8_t*)SignalIcon);
209227
myLCD.LCDBuffer(176, 0, 16, 8, (uint8_t*)BatIcon);
210228
bcm2835_delay(5000);
@@ -213,17 +231,29 @@ void Test2(void)
213231

214232
void Test3(void)
215233
{
234+
printf("Test3: LCDupdate method , full screen\n");
216235
myLCD.LCDbufferScreen = (uint8_t*) &fullScreenBuffer;
236+
if(myLCD.LCDbufferScreen== nullptr) // check if pointer is still = null
237+
{
238+
printf("Error 1203 :: Problem assigning buffer pointer\r\n");
239+
exit(-1);
240+
}
217241
myLCD.LCDupdate();
218242
bcm2835_delay(5000);
219243
myLCD.LCDFillScreen(0x00);
220244
}
221245

222246
void Test4(void)
223247
{
248+
printf("Test4:setDrawBitmapAddr method , 2 icons Data Vertical addressed \n");
224249
myLCD.LCDbufferScreen = (uint8_t*) &fullScreenBuffer;
250+
if(myLCD.LCDbufferScreen== nullptr) // check if pointer is still = null
251+
{
252+
printf("Error 1204 :: Problem assigning buffer pointer\r\n");
253+
exit(-1);
254+
}
225255
myLCD.LCDclearBuffer(); // Clear buffer
226-
myLCD.setDrawBitmapAddr(true); // for Bitmap Data Vertical addressed
256+
myLCD.setDrawBitmapAddr(true); // for Bitmap Data Vertical addressed
227257
myLCD.drawBitmap(0, 5, SignalIcon, 16, 8, FOREGROUND, BACKGROUND);
228258
myLCD.drawBitmap(150, 5, BatIcon, 16, 8 , FOREGROUND, BACKGROUND);
229259

@@ -233,10 +263,15 @@ void Test4(void)
233263

234264
void Test5(void)
235265
{
266+
printf("Test5:setDrawBitmapAddr method , 3 icons Data Horizontal addressed \n");
236267
myLCD.LCDbufferScreen = (uint8_t*) &fullScreenBuffer;
237-
myLCD.LCDclearBuffer(); // Clear active buffer
238-
239-
myLCD.setDrawBitmapAddr(false); // for Bitmap Data Horziontal addressed
268+
if(myLCD.LCDbufferScreen== nullptr) // check if pointer is still = null
269+
{
270+
printf("Error 1205 :: Problem assigning buffer pointer\r\n");
271+
exit(-1);
272+
}
273+
myLCD.LCDclearBuffer(); // Clear active buffer
274+
myLCD.setDrawBitmapAddr(false); // for Bitmap Data Horizontal addressed
240275
myLCD.drawBitmap(10, 25, SignalIconHa, 16, 8, FOREGROUND, BACKGROUND);
241276
myLCD.drawBitmap(100, 20, SignalIconHa, 16, 8, BACKGROUND, FOREGROUND);
242277
myLCD.drawBitmap(60, 20, SignalIconHa, 16, 8, BACKGROUND, FOREGROUND);

examples/src/FONTS_GLYPH/main.cpp

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,15 @@ ERM19264_UC1609 myLCD(myLCDwidth ,myLCDheight, RST, CD );
3535
#define MY_TEST_DELAY1 bcm2835_delay(1000)
3636

3737
// =============== Function prototype ================
38-
void setup(void);
38+
bool setup(void);
3939
void myTest(void);
4040
void EndTest(void);
4141
void testReset(void);
4242

4343
// ======================= Main ===================
4444
int main(int argc, char **argv)
4545
{
46-
if(!bcm2835_init()) {return -1;}
47-
48-
setup();
46+
if(!setup()) {return -1;}
4947
myTest();
5048
EndTest();
5149

@@ -55,18 +53,34 @@ int main(int argc, char **argv)
5553

5654

5755
// ===================== Function Space =====================
58-
void setup() {
59-
bcm2835_delay(50);
60-
printf("LCD Begin\r\n");
61-
myLCD.LCDbegin(RAMaddressCtrl, LCDcontrast, SPICLK_FREQ , SPI_CE_PIN); // initialize the LCD
62-
myLCD.LCDFillScreen(0x33); // splash screen bars
56+
bool setup() {
57+
printf("LCD Test Begin\r\n");
58+
// Check if Bcm28235 lib installed and print version.
59+
if(!bcm2835_init())
60+
{
61+
printf("Error 1201: init bcm2835 library , Is it installed ?\r\n");
62+
return false;
63+
}else
64+
{
65+
printf("bcm2835 library Version Number :: %u\r\n",bcm2835_version());
66+
bcm2835_delay(100);
67+
}
68+
69+
if(!myLCD.LCDbegin(RAMaddressCtrl, LCDcontrast, SPICLK_FREQ , SPI_CE_PIN)) // initialize the LCD
70+
{
71+
printf("Error 1202: bcm2835_spi_begin :Cannot start spi, Running as root?\n");
72+
return false;
73+
}
74+
printf("ERM19264 Library version number :: %u \r\n", myLCD.LCDLibVerNumGet());
75+
myLCD.LCDFillScreen(0x33); // display splash screen bars, optional for effect
6376
bcm2835_delay(1500);
77+
return true;
6478
}
6579

6680
void EndTest()
6781
{
6882
myLCD.LCDPowerDown();
69-
bcm2835_close(); // Close the library
83+
bcm2835_close(); // Close library, deallocating allocated memory & closing /dev/mem
7084
printf("LCD End\r\n");
7185
}
7286

@@ -75,6 +89,12 @@ void myTest() {
7589
// define a buffer to cover whole screen
7690
uint8_t screenBuffer[myLCDwidth * (myLCDheight/8)];
7791
myLCD.LCDbufferScreen = (uint8_t*) &screenBuffer;
92+
if(myLCD.LCDbufferScreen== nullptr) // check if pointer is still = null
93+
{
94+
printf("Error 1203 :: Problem assigning buffer pointer\r\n");
95+
exit(-1);
96+
}
97+
7898
myLCD.LCDclearBuffer(); // Clear buffer
7999

80100
// Test 1 Font FreeSans12pt7b
@@ -97,7 +117,7 @@ void myTest() {
97117
myLCD.drawCharGlyph(10, 62, '!', FOREGROUND, 1);
98118
testReset();
99119

100-
// Test 4 Font FreeSErif18pt7b
120+
// Test 4 Font FreeSerif18pt7b
101121
txt = "Free Serif 18pt7b";
102122
myLCD.setFontGlyph(&FreeSerif18pt7b);
103123
myLCD.drawTextGlyph(0, 26, txt, FOREGROUND, 1);

0 commit comments

Comments
 (0)