The ST NUCLEO L4342KC and Digilent Pmod OLEDrgb tested. Be aware of the correct revision of the OS and correct versions of the display driver libraries!

Dependencies:   Adafruit_SSD1331_Mbed Adafruit-GFX

Files at this revision

API Documentation at this revision

Comitter:
timo_k2
Date:
Sat Aug 29 08:26:56 2020 +0000
Commit message:
The purpose of this project is to teach the students the development process and test that the hardware the ST NUCLEO-L432KC and the Digilent Pmod OLEDrgb work just fine. Be aware of correct revision of the OS and correct versions of the libraries!

Changed in this revision

.gitignore Show annotated file Show diff for this revision Revisions of this file
Adafruit-GFX.lib Show annotated file Show diff for this revision Revisions of this file
Adafruit_SSD1331_Mbed.lib Show annotated file Show diff for this revision Revisions of this file
CONTRIBUTING.md Show annotated file Show diff for this revision Revisions of this file
README.md Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
resources/official_armmbed_example_badge.png Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r adc62c00bb85 .gitignore
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.gitignore	Sat Aug 29 08:26:56 2020 +0000
@@ -0,0 +1,4 @@
+.build
+.mbed
+projectfiles
+*.py*
diff -r 000000000000 -r adc62c00bb85 Adafruit-GFX.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Adafruit-GFX.lib	Sat Aug 29 08:26:56 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/EIC_mbed/code/Adafruit-GFX/#ca74c390a0de
diff -r 000000000000 -r adc62c00bb85 Adafruit_SSD1331_Mbed.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Adafruit_SSD1331_Mbed.lib	Sat Aug 29 08:26:56 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mjromeijn/code/Adafruit_SSD1331_Mbed/#e8e869596683
diff -r 000000000000 -r adc62c00bb85 CONTRIBUTING.md
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CONTRIBUTING.md	Sat Aug 29 08:26:56 2020 +0000
@@ -0,0 +1,5 @@
+# Contributing to Mbed OS
+
+Mbed OS is an open-source, device software platform for the Internet of Things. Contributions are an important part of the platform, and our goal is to make it as simple as possible to become a contributor.
+
+To encourage productive collaboration, as well as robust, consistent and maintainable code, we have a set of guidelines for [contributing to Mbed OS](https://os.mbed.com/docs/mbed-os/latest/contributing/index.html).
diff -r 000000000000 -r adc62c00bb85 README.md
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.md	Sat Aug 29 08:26:56 2020 +0000
@@ -0,0 +1,13 @@
+![](./resources/official_armmbed_example_badge.png)
+# Built started by importing the Blinky Mbed OS example
+[Mbed boards](https://os.mbed.com/platforms/).
+
+The code is developed for the hardware NUCLEO-L432KC and Digilent Pmod OLEDrgb.
+The purpose is to make students to test that the development process works fine
+and the hardware as well.
+
+### License and contributions
+
+The software is provided under Apache-2.0 license. Contributions to this project are accepted under the same license. Please see contributing.md for more info.
+
+This project contains code from other projects. The original license text is included in those source files. They must comply with our license guide.
diff -r 000000000000 -r adc62c00bb85 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Aug 29 08:26:56 2020 +0000
@@ -0,0 +1,160 @@
+/* mbed Microcontroller Library
+ * Copyright (c) 2019 ARM Limited
+ * SPDX-License-Identifier: Apache-2.0
+************************************************************************
+*
+* Commissioning test for the L432KC and the Pmod small OLED display
+*
+*************************************************************************
+* Description: McLab10_OLEDrgb_L432KC
+* "Test module Pmod Digilent Lextronic" will be displayed on OLEDrgb module
+* with different size and colors..... and later the variable values.
+*
+* Material
+* 1. ST L432KC  ( or some other micro controller board with SPI communication )
+* 2. Digilent Pmod OLEDrgb  and the libraries
+* Adafruit_SSD1331_Mbed
+* Adafruit-GFX
+* These libraries can be found with search on the page 
+* https://www.mbed.com/en/platform/mbed-os/
+* Please connect L432KC - Pmod_OLEDrgb with lines:
+* L432KC D13 - OLED 4 SCK   hardware defined for the SPI
+* L432KC D11 - OLED 2 MOSI  hardware definef for the SPI
+* L432KC D9  - OLED 1 CS   or any other free
+* L432KC D10 - OLED 7 DC   or any other free
+* L432KC D6  - OLED 8 RES   or any other free
+*  VCC     - OLED 9 VCCEN  Enable - VCC
+*  VCC     - OLED10 PMODEN  Pmod Enable - VCC
+*  GND     - OLED 5 Ground
+*  VCC     - OLED 6 Power supply 3,3 V
+* 
+*************************************************************************
+* Compiles OK, works with hardware with operating system revision 6691:cf4f12a 
+* Compiles OK, DOESN'T WORK with hardware with op sys revision 7088:3ab72c7 
+* Timo Karppinen 28.08.2020
+**************************************************************/
+
+#include "mbed.h"
+#include "Adafruit_SSD1331.h"   // By using the Adafruit SSD1331 library and Adafruit GFX library
+#include "Adafruit_GFX.h"       // we will get similar code than in Arduino-boards working.
+                                // There are other SSD1331 libraries, too. 
+                                // https://os.mbed.com/search/?q=ssd1331  
+                                // The tested are:
+                                // Adafruit_SSD1331_Mbed by Marijn Romeijn
+                                // Adafruit_GFX by Team_EIC                  
+// PmodOLEDrgb
+Adafruit_SSD1331 OLED(D9, D6, D10, D11, NC, D13); // cs, res, dc, mosi, (nc), sck  
+
+//DigitalOut LED(LED1);     // LED1, LED2, LED3 and LED4 are the D13 PB_3 pin in this board and 
+                            //can not be used because of the SPI
+DigitalOut VCCEN(D3);
+DigitalOut PMODEN(D5);
+
+// Definition of colours on the OLED display
+#define Black 0x0000
+#define Blue 0x001F
+#define Red 0xF800
+#define Green 0x07E0
+#define Cyan 0x07FF
+#define Magenta 0xF81F
+#define Yellow 0xFFE0
+#define White 0xFFFF
+
+float stepsScaledF = 0;       // 32 bit floating point
+void getSTEPS();
+
+char Time[50],Date[50];
+void getTime();
+int first = 0;
+
+int main()
+{
+  // Showing with a LED that program has started
+        //    LED = 0;
+        VCCEN = 1;    // if you did not connect VCCEN permanently to Vcc
+        PMODEN = 1;   // if you did not connect PMODEN permanently to Vcc
+        ThisThread::sleep_for(2000);
+        //    LED = 1;
+        ThisThread::sleep_for(2000);
+        //  LED = 0;
+  // Initalize the PmodOLEDrgb    
+        OLED.begin(); // initialization of display object
+        
+        OLED.clearScreen();   
+
+    while (true) {
+        while(first < 3)
+            {
+                first += 1; 
+                OLED.fillScreen(Black); // background screen in black
+                OLED.setTextColor(Cyan); // colour of text in cyan
+                OLED.setCursor(0,0); // cursor is in x=0 and y=15
+                OLED.printf("Test module Pmod"); // display text
+                ThisThread::sleep_for(500); // wait 500 ms
+                OLED.setCursor(0,15); // cursor is in x=0 and y=15
+                OLED.setTextSize(2); // size of text
+                OLED.setTextColor(Red); // text in red colour
+                OLED.printf("DIGILENT"); // display text
+                OLED.setCursor(20,40); // cursor is in x=20 and y=40
+                OLED.setTextSize(1); // size of text
+                OLED.setTextColor(Green); // text in green colour
+                OLED.printf("LEXTRONIC"); // display text
+                OLED.drawFastHLine(1, 60, OLED.width()-1, Blue); //blue line x=1, width-1 and y=60
+                ThisThread::sleep_for(2000); // wait 2 s
+                OLED.fillScreen(Black); // background display in black (erase display)
+                OLED.fillRoundRect(5, 5, 30, 40, 1, Blue); // French flag bleu blanc rouge
+                OLED.fillRoundRect(35, 5, 30, 40, 1, White);
+                OLED.fillRoundRect(65, 5, 30, 40, 1, Red);
+                OLED.fillCircle(90, 55, 5, Yellow); // yellow circle with radius=5 in x=90 and y=55
+                ThisThread::sleep_for(2000); // wait 2 s
+            }
+
+        getTime();
+        OLED.clearScreen();
+        OLED.fillScreen(Black); // background screen in black
+        OLED.setTextColor(Cyan); // colour of text in cyan
+        ThisThread::sleep_for(300);
+        OLED.setCursor(0,0); // cursor is in x=0 and y=0
+        OLED.printf("Rec '%s' \n",Time);
+        
+        getSTEPS(); 
+        OLED.printf("value = '%0.1f' \n",stepsScaledF);
+
+        if (stepsScaledF > 2.00)
+        { 
+            OLED.setTextColor(Yellow);
+            OLED.printf("Be aware of reaching the limit");
+            OLED.fillRoundRect(10, 35, 50, 3 , 1, Yellow);
+        }
+        OLED.setCursor(0,40); // cursor is in x=0 and y=0
+        OLED.printf("Wait a moment !");
+        OLED.drawFastHLine(1, 60, OLED.width()-1, Blue); // blue line x=1 to screen width-1 and y=60
+        printf("printed on OLED");
+        
+        ThisThread::sleep_for(3000);
+}
+}
+
+void getTime()
+{    
+    time_t seconds = time(NULL);   //  https://os.mbed.com/docs/mbed-os/v6.2/apis/time.html
+    strftime(Time,40,"%H:%M:%S", localtime(&seconds));
+    strftime(Date,40,"%d-%b-%Y", localtime(&seconds));
+    printf("Recorded '%s' \r\n",Time);
+}
+
+void getSTEPS()
+{
+    static int count; 
+   
+    count = count + 100;
+    if (count > 4095){
+        count = 0;
+        }
+    
+    stepsScaledF = (float(count))*(float(2.50)/4095); // The value 2.50 is 64 bit double precision floating point of type double.
+                                                // Conversions to 32 bit floating point of type float.
+    printf("Counter value '%d' \r\n",count);
+    printf("Scaled output  '%0.1f' \r\n",stepsScaledF);
+    ThisThread::sleep_for(100);
+}
\ No newline at end of file
diff -r 000000000000 -r adc62c00bb85 mbed-os.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Sat Aug 29 08:26:56 2020 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#cf4f12a123c05fcae83fc56d76442015cb8a39e9
diff -r 000000000000 -r adc62c00bb85 resources/official_armmbed_example_badge.png
Binary file resources/official_armmbed_example_badge.png has changed