Skip to content

Commit fac1bdb

Browse files
committed
Tested with STM32, example added, Readme updated
1 parent d06fbc2 commit fac1bdb

File tree

5 files changed

+190
-46
lines changed

5 files changed

+190
-46
lines changed

NKKSmartDisplayLCD.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ GNU General Public License, check license.txt for more information
99
All text above must be included in any redistribution
1010
*********************************************************************/
1111
/*********************************************************************
12-
2021-02-25
13-
Version: v01 , initial version
12+
2021-03-04
13+
Version: v01.0.1 , tested with STM32
1414
Status: Works OK
1515
1616
Key Features:
@@ -28,7 +28,8 @@ Key Features:
2828
- Can be used with Adafruit GFX Graphics core which does all the circles, text and fonts,
2929
rectangles, etc. You can get it from https://github.com/adafruit/Adafruit-GFX-Library.
3030
See /examples folder for implementation examples.
31-
- Tested with hardware SPI for Arduino Pro Mini board
31+
- Tested with hardware SPI for Arduino Pro Mini board
32+
- Tested with Maple Mini board and Arduino STM32 core (https://github.com/rogerclarkmelbourne/Arduino_STM32)
3233
- Tested with NKK IS15EBFP4RGB-09YN LCD 64 x 32 Pushbutton, shall work with these models as well:
3334
S15DBFP4RGB
3435
IS15DBFP4RGB-09YN

NKKSmartDisplayLCD.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ GNU General Public License, check license.txt for more information
99
All text above must be included in any redistribution
1010
*********************************************************************/
1111
/*********************************************************************
12-
2021-02-25
13-
Version: v01 , initial version
12+
2021-03-04
13+
Version: v01.0.1 , tested with STM32
1414
Status: Works OK
1515
1616
Key Features:
@@ -28,7 +28,8 @@ Key Features:
2828
- Can be used with Adafruit GFX Graphics core which does all the circles, text and fonts,
2929
rectangles, etc. You can get it from https://github.com/adafruit/Adafruit-GFX-Library.
3030
See /examples folder for implementation examples.
31-
- Tested with hardware SPI for Arduino Pro Mini board
31+
- Tested with hardware SPI for Arduino Pro Mini board
32+
- Tested with Maple Mini board and Arduino STM32 core (https://github.com/rogerclarkmelbourne/Arduino_STM32)
3233
- Tested with NKK IS15EBFP4RGB-09YN LCD 64 x 32 Pushbutton, shall work with these models as well:
3334
S15DBFP4RGB
3435
IS15DBFP4RGB-09YN

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ It has been designed and tested for NKK IS15EBFP4RGB-09YN LCD 64 x 32 Pushbutton
99
IS01DBFRGB
1010
IS15EBFP4RGB
1111
IS15ESBFP4RGB
12+
IS15EBFP4RGB-09YN
1213
IS01EBFRGB
1314

1415
With minimal changes in configuration settings it shall support other LCD resolutions if required.
1516

1617
The library supports:
1718
1. Two image formats:
18-
- Normal GFX (first pixel is top left corner, represented by bit0 in the first byte)
19+
- Normal GFX (first pixel is top left corner, represented by bit0 in the first byte)
1920
- Native NKK (first pixel is top right corner, represented by bit7 in the first byte, as per NKK specs)
2021
2. Landscape (64x32) and Portrait (32x64) display configurations
2122
3. Two formats for background colour - three bytes RGB format and native NKK format (RRGGBBxx)
@@ -56,7 +57,7 @@ The library supports:
5657

5758
*display()* method is also used for integration with Adafruit_GFX library.
5859

59-
7. Use other NKK_SmartDisplayLCD library methods like *clearImageBufferGFX()*, *invertImageBufferGFX()* etc to manage content of the image bugger you use.
60+
7. Use other NKK_SmartDisplayLCD library methods like *clearImageBufferGFX()*, *invertImageBufferGFX()* etc to manage content of the image buffer you use.
6061

6162
8. Use Adafruit_GFX_Ext object to access to Adafruit_GFX library methods like *setCursor()*, *print()*, *drawPixel()*, *fillRect()* etc to build
6263
or adjust your image in the *imageBufferGFX[]* image buffer. Do not forget to call *display()* method to transfer your image to the NKK device
@@ -66,8 +67,12 @@ See the examples and descriptions of the library functions provided in the code
6667

6768
6869
## Known Limitations:
69-
Requres a native SPI object (like Arduino one) which handles SPI communications. With a mimimal changes to the library (an update to the class constructor) it can use a separate SPI handler such as https://github.com/adafruit/Adafruit_BusIO
70+
Requires a native SPI object (like Arduino one) which handles SPI communications. With a mimimal changes to the library (an update to the class constructor) it can use a separate SPI handler such as https://github.com/adafruit/Adafruit_BusIO
7071

72+
## Hardware:
73+
Tested with
74+
- Arduino Pro Mini
75+
- Maple Mini board (STM32F103CBT6) and Arduino STM32 core (https://github.com/rogerclarkmelbourne/Arduino_STM32)
7176

7277
## Repository Contents:
7378
/documentation - Image Builder (MS Excel file), NKK LCD 64x32 SmartDisplay application notes
@@ -109,7 +114,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
109114

110115
See the GNU General Public License for more details.
111116

112-
## Donation
117+
## Donation:
113118
If this project help you reduce your time to develop, you can give me a cup of coffee :)
114119

115-
[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/donate/?business=ifhone777-hub%40yahoo.com&currency_code=AUD)
120+
[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/donate/?business=ifhone777-hub%40yahoo.com&currency_code=USD)

README.txt

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,82 @@
1+
12
## Overview:
23
This is a library for **NKK LCD 64x32 SmartDisplay** (https://www.nkkswitches.com/smartdisplay/)
34
It has been designed and tested for NKK IS15EBFP4RGB-09YN LCD 64 x 32 Pushbutton and shall work with these models as well:
5+
46
S15DBFP4RGB
57
IS15DBFP4RGB-09YN
68
S15DSBFP4RGB
79
IS01DBFRGB
810
IS15EBFP4RGB
911
IS15ESBFP4RGB
12+
IS15EBFP4RGB-09YN
1013
IS01EBFRGB
1114

12-
With minimal changes in configuration settings it shall suppot other LCD resolutions if required.
15+
With minimal changes in configuration settings it shall support other LCD resolutions if required.
1316

1417
The library supports:
15-
1. Two image formats:
16-
-Normal GFX (first pixel is top left corner, represented by bit0 in the first byte)
17-
-Native NKK (first pixel is top right corner, represented by bit7 in the first byte, as per NKK specs)
18-
2. Landscape (64x32) and Portrait (32x64) display configurations
19-
3. Two formats for background colour - three bytes RGB format and native NKK format (RRGGBBxx)
20-
4. A rotation of an image by 180 degrees to accommodate different possible footprints of an NKK device on your pcb.
18+
1. Two image formats:
19+
- Normal GFX (first pixel is top left corner, represented by bit0 in the first byte)
20+
- Native NKK (first pixel is top right corner, represented by bit7 in the first byte, as per NKK specs)
21+
2. Landscape (64x32) and Portrait (32x64) display configurations
22+
3. Two formats for background colour - three bytes RGB format and native NKK format (RRGGBBxx)
23+
4. A rotation of an image by 180 degrees to accommodate different possible footprints of an NKK device on your pcb.
2124

2225
## Library usage:
23-
1. Create a NKK_SmartDisplayLCD object. At this step specify:
24-
w: The NKK LCD screen width in pixels. Maximum w is 256 and Maximum w*h/8 = 65535 for this library code.
25-
h: The NKK LCD screen height in pixels Maximum h is 256 and Maximum w*h/8 = 65535 for this library code.
26-
isRotate180: A flag to indicate that the picture need to be rotated by 180 degrees to accommodate different possible footprints of an NKK device on your pcb. Applied just before the picture is uploaded to the NKK device by the *display()* or *display_NKK()* functions.
27-
cspin: Slave Select(Chip Select) signal (to allow use more than one NKK device with their own SS signals).
28-
freqSPI: SPI frequency, Hz.
29-
pointer: A reference (pointer) to native SPI object which handles SPI communications.
30-
31-
2. Execute *begin()* method. That would start SPI interface and reset the NKK device.
26+
1. Create a NKK_SmartDisplayLCD object. At this step specify:
27+
- w: The NKK LCD screen width in pixels. Maximum w is 256 and Maximum w x h/8 = 65535 for this library code.
28+
- h: The NKK LCD screen height in pixels Maximum h is 256 and Maximum w x h/8 = 65535 for this library code.
29+
- isRotate180: A flag to indicate that the picture need to be rotated by 180 degrees to accommodate different possible footprints of an NKK device on your pcb. Applied just before the picture is uploaded to the NKK device by the *display()* or *display_NKK()* functions.
30+
- cspin: Slave Select(Chip Select) signal (to allow use more than one NKK device with their own SS signals).
31+
- freqSPI: SPI frequency, Hz.
32+
- pointer: A reference (pointer) to native SPI object which handles SPI communications.
3233

33-
3. Set required background colour and brightness:
34-
- By using library methods that would communicate directly to the NKK device:
34+
2. Execute *begin()* method. That would start SPI interface and reset the NKK device.
35+
36+
3. Set required background colour and brightness:
37+
- By using library methods that would communicate directly to the NKK device:
3538
```C++
3639
setColourNKK(byte data); // set as per NKK specs (RRGGBBxx)
3740
setColourRGB(byte R, byte G, byte B); // RGB get converted to the closest colour as per NKK specs (64 colours available)
3841
setBrightness(byte data); //set as per NKK specs (BBBxxxxx)
3942
```
40-
- By setting library variables *bkgColour* and *bkgBrightnes* which will be used when the *display()* and *display_NKK()* methods are called
43+
- By setting library variables *bkgColour* and *bkgBrightnes* which will be used when the *display()* and *display_NKK()* methods are called
4144

42-
4. Set an image in a GFX or NKK format to library variables *imageBufferGFX[]* and *imageBufferNKK[]*. No need to set both.
45+
4. Set an image in a GFX or NKK format to library variables *imageBufferGFX[]* and *imageBufferNKK[]*. No need to set both.
4346
You can use an NKK Bitmap bilder (MS Excel file) in the */documentation* folder to build an image in GFX or NKK formats, landscape or portrait.
44-
45-
5. Use *drawPixel(x,y,color)* to set a pixel in the *imageBufferGFX[]*. X and Y are pixel coordunates, starting from 0. For this monochrome
47+
48+
5. Use *drawPixel(x,y,color)* to set a pixel in the *imageBufferGFX[]*. X and Y are pixel coordunates, starting from 0. For this monochrome
4649
LCD display *color* can be any value, it will be converted either 0 or 1 in the library. This method is also used for integration with Adafruit_GFX library (https://github.com/adafruit/Adafruit-GFX-Library).
4750

48-
6. Execute *display()* or *display_NKK()* methods which will do the following:
51+
6. Execute *display()* or *display_NKK()* methods which will do the following:
4952
- upload an image to the NKK device from *imageBufferGFX[]* or *imageBufferNKK[]* and make the image visible.
50-
*display()* will use *imageBufferGFX[]* as a source and will overwrite *imageBufferNKK[]*.
51-
*display_NKK()* use *imageBufferNKK[]* as a source and does NOT change *imageBufferGFX[]*.
53+
*display()* will use *imageBufferGFX[]* as a source and will overwrite *imageBufferNKK[]*.
54+
*display_NKK()* use *imageBufferNKK[]* as a source and does NOT change *imageBufferGFX[]*.
5255
AND
5356
- set NKK device background colour and brightness as per library's variables *bkgColour* and *bkgBrightnes*.
5457

5558
*display()* method is also used for integration with Adafruit_GFX library.
5659

57-
7. Use other NKK_SmartDisplayLCD library methods like *clearImageBufferGFX()*, *invertImageBufferGFX()* etc to manage content of the image bugger you use.
60+
7. Use other NKK_SmartDisplayLCD library methods like *clearImageBufferGFX()*, *invertImageBufferGFX()* etc to manage content of the image buffer you use.
5861

59-
8. Use Adafruit_GFX_Ext object to access to Adafruit_GFX library methods like *setCursor()*, *print()*, *drawPixel()*, *fillRect()* etc to build
62+
8. Use Adafruit_GFX_Ext object to access to Adafruit_GFX library methods like *setCursor()*, *print()*, *drawPixel()*, *fillRect()* etc to build
6063
or adjust your image in the *imageBufferGFX[]* image buffer. Do not forget to call *display()* method to transfer your image to the NKK device
6164
and make it visible.
6265

6366
See the examples and descriptions of the library functions provided in the code for more details.
6467

6568

6669
## Known Limitations:
67-
Requres a native SPI object (like Arduino one) which handles SPI communications.
68-
With a mimimal changes to the library (an update to the class constructor) it can use
69-
a separate SPI handler such as https://github.com/adafruit/Adafruit_BusIO
70+
Requires a native SPI object (like Arduino one) which handles SPI communications. With a mimimal changes to the library (an update to the class constructor) it can use a separate SPI handler such as https://github.com/adafruit/Adafruit_BusIO
7071

72+
## Hardware:
73+
Tested with
74+
- Arduino Pro Mini
75+
- Maple Mini board (STM32F103CBT6) and Arduino STM32 core (https://github.com/rogerclarkmelbourne/Arduino_STM32)
7176

7277
## Repository Contents:
73-
*/documentation* - Image Builder (MS Excel file), NKK LCD 64x32 SmartDisplay application notes
74-
*/examples* - examples on how the libraries can be used
78+
/documentation - Image Builder (MS Excel file), NKK LCD 64x32 SmartDisplay application notes
79+
/examples - examples on how the libraries can be used
7580

7681

7782
## License:
@@ -107,6 +112,4 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
107112
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
108113
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
109114

110-
See the GNU General Public License for more details.
111-
112-
115+
See the GNU General Public License for more details.
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
/*********************************************************************
2+
This file is a part of a library for NKK LCD 64x32 SmartDisplay
3+
4+
Copyright (c) 2021, IFH
5+
All rights reserved.
6+
7+
GNU General Public License, check license.txt for more information
8+
All text above must be included in any redistribution
9+
*********************************************************************/
10+
/*
11+
NKK Smart Display LCD 64*32 test code using library NKK_SmartDisplayLCD
12+
13+
example 02- NKK as a library,
14+
using Maple Mini hardware (http://docs.leaflabs.com/static.leaflabs.com/pub/leaflabs/maple-docs/0.0.12/hardware/maple-mini.html)
15+
and Arduino STM32 core (https://github.com/rogerclarkmelbourne/Arduino_STM32)
16+
17+
Status: works ok
18+
19+
20+
// hardware setup for Maple Mini
21+
//Use SPI_2 as it is 5v tolerant
22+
// Maple Mini SS (NCS) <--> PB12 D31 pin no 31 -> NKK SS (Signal is managed by NKK library to allow running several NKK devices with their own SS pins)
23+
// Maple Mini SCK (CLK) <--> PB13 D30 pin no 30 -> NKK SCK (Clock for serial communication, maximum 8 MHZ)
24+
// Maple Mini MISO (SPI) <--> PB14 D29 pin no 29 -> NKK SDO (This is not required for NKK devices - no data output back from the NKK device)
25+
// Maple Mini MOSI (SDO) <--> PB15 D28 pin no 15 -> NKK SDI
26+
27+
//Please note that STM32F103CBT6 is 3.3v and NKK LCD 64x32 SmartDisplay is 5v. While direct connection without a level shifter works with that example,
28+
//such hardware setup is at your own risk.
29+
*/
30+
31+
#include <SPI.h>
32+
#include <NKKSmartDisplayLCD.h>
33+
34+
//Setup SPI
35+
#define SPIDEVICE_CS 31 //note this is for the SPI setup only. Actual SS signal is managed by NKK library to allow running several NKK devices with their own SS pins.
36+
SPIClass SPI_2(2); //Create an instance of the SPI Class called SPI_2 that uses the 2nd SPI Port
37+
38+
//Setup images
39+
//Note: for simplisity we do not use PROGMEM
40+
//"TEST 1" text with a corner white triangle *
41+
byte imgTest1[] =
42+
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,127,131,131,241,252,0,5,0,8,4,64,16,32,0,4,128,8,0,64,16,32,0,4,64,8,0,64,16,32,0,4,0,8,0,64,16,32,0,4,0,8,0,128,16,32,0,4,0,8,1,0,240,32,0,4,0,8,2,0,16,32,0,4,0,8,4,0,16,32,0,4,0,8,4,0,16,32,128,4,0,8,4,0,16,32,192,4,0,8,4,64,16,32,160,63,128,8,3,131,240,32,144,0,0,0,0,0,0,0,136,0,0,0,0,0,0,0,132,0,0,0,0,0,0,0,130,0,0,0,0,0,0,0,129,0,0,0,0,0,0,0,128,128,0,0,0,0,0,0,128,64,0,0,0,0,0,0,128,32,0,0,0,0,0,0,128,16,0,0,0,0,0,0,128,8,0,0,0,0,0,0,128,4,0,0,0,0,0,0,128,2,0,0,0,0,0,0,128,1,0,0,0,0,0,0,255,255,128,0,0,0,0,0
43+
};
44+
45+
// Test GFX - landscape
46+
byte imgGFX1[] =
47+
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,252,241,131,131,127,0,0,0,32,16,64,4,8,0,0,0,32,16,64,0,8,224,125,17,32,16,64,0,8,16,4,10,32,16,64,0,8,16,4,4,32,16,128,0,8,144,61,4,32,240,0,1,8,16,5,4,32,16,0,2,8,16,5,10,32,16,0,4,8,224,4,17,32,16,0,4,8,0,0,0,32,16,0,4,8,0,0,128,32,16,64,4,8,0,0,192,32,240,131,3,8,0,0,160,0,0,0,0,0,0,0,144,0,0,0,0,0,0,0,136,0,0,0,0,0,0,0,132,0,0,0,0,0,0,0,130,0,0,0,0,0,0,0,129,0,0,0,0,0,0,128,128,0,0,0,0,0,0,64,129,0,0,0,0,0,0,32,130,0,0,0,0,0,0,16,132,0,0,0,0,0,0,8,136,0,0,0,0,0,0,4,144,0,0,0,0,0,0,2,160,0,0,0,0,0,0,1,192,0,0,0,0,0,128,255,255
48+
};
49+
50+
// Test GFX - portrait
51+
byte imgGFX2[] =
52+
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,248,253,152,31,248,253,164,31,96,12,6,6,96,12,6,6,96,12,6,6,96,12,4,6,96,60,8,6,96,12,16,6,96,12,32,6,96,12,96,6,96,12,96,6,96,12,96,6,96,252,36,6,96,252,24,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,247,69,0,64,16,40,0,64,16,16,0,64,246,16,0,64,20,16,0,64,20,40,0,128,19,68,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,64,0,0,0,32,0,0,0,16,0,0,0,8,32,0,0,4,112,0,0,2,168,0,0,1,36,1,128,0,32,0,64,0,32,0,32,0,32,0,16,0,32,0,8,0,32,0,20,0,32,0,34,0,32,0,65,0,32,128,128,0,32,64,0,1,32,32,0,2,0,16,0,4,0,8,0,8,0,4,0,16,0,2,0,32,0,1,0,64,128,0,0,128
53+
};
54+
55+
56+
// Initialise NKK device
57+
//Landscape
58+
NKK_SmartDisplayLCD NKK = NKK_SmartDisplayLCD(64,32,0,SPIDEVICE_CS,1000000,&SPI_2);
59+
//Portrait,with 180 rotation
60+
//NKK_SmartDisplayLCD NKK = NKK_SmartDisplayLCD(32,64,1,SPIDEVICE_CS,1000000);
61+
62+
63+
64+
void setup() {
65+
pinMode(SPIDEVICE_CS, OUTPUT);
66+
67+
//==============================
68+
Serial.begin(9600);
69+
//Serial.begin(115200);
70+
//The program will wait for serial to be ready up to 10 sec then it will continue anyway
71+
for (int i=1; i<=10; i++){
72+
delay(1000);
73+
if (Serial){
74+
break;
75+
}
76+
}
77+
Serial.println("Setup() started ");
78+
//===============================
79+
80+
81+
//start SPI interface
82+
SPI_2.begin();
83+
84+
// start NKK device
85+
NKK.begin();
86+
87+
}
88+
89+
90+
void loop() {
91+
92+
93+
NKK.reset();
94+
95+
//test NKK colours
96+
NKK.setColourNKK(255); //White
97+
NKK.setBrightness(255);
98+
delay (1000);
99+
NKK.setColourNKK(195); //Red
100+
delay (1000);
101+
NKK.setColourNKK(51); //Green
102+
delay (1000);
103+
NKK.setColourNKK(15); //Blue
104+
delay (1000);
105+
NKK.setColourNKK(255); //White
106+
delay (1000);
107+
108+
//test NKK image transfer
109+
for(uint16_t i=0; i<256; i++)
110+
{
111+
NKK.imageBufferNKK[i] = imgTest1[i];
112+
}
113+
NKK.display_NKK();
114+
delay (2000);
115+
116+
117+
//test RGB colour
118+
NKK.setColourRGB(255,255,0); // set Yellow
119+
//delay (1000);
120+
121+
// test GFX image transfer
122+
for(uint16_t i=0; i<256; i++)
123+
{
124+
NKK.imageBufferGFX[i] = imgGFX1[i];
125+
126+
}
127+
NKK.display();
128+
delay (2000);
129+
130+
131+
132+
}// End of the Loop
133+
134+

0 commit comments

Comments
 (0)