RTOS example - multiplex display on a 4-digit 7-segment LED tube driven by two 74HC595 shift registers. Hardware: NUCLEO_F446RE board with Arduino Multifunction Shield. The ShiftOut Library by Ollie Milton was applied.

Dependencies:   mbed mbed-rtos ShiftOut

Files at this revision

API Documentation at this revision

Comitter:
cspista
Date:
Thu Feb 24 07:52:29 2022 +0000
Commit message:
RTOS example - multiplex display on a four digit, 7-segment display. ; Hardware: NUCLEO-F446RE board and Arduino Multifunctional Shield (3461B type 7-segment LED display driven by two 74HC595 shift registers).

Changed in this revision

ShiftOut.lib 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-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 2ae7b6b39e93 ShiftOut.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ShiftOut.lib	Thu Feb 24 07:52:29 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/ollie8/code/ShiftOut/#7333dc6fca5c
diff -r 000000000000 -r 2ae7b6b39e93 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Feb 24 07:52:29 2022 +0000
@@ -0,0 +1,40 @@
+#include "mbed.h"
+#include "rtos.h"
+#include "ShiftOut.h" // Ollie Milton, https://os.mbed.com/users/ollie8/code/ShiftOut/
+uint8_t segment_data[4] = {0xFF, 0xFF, 0xFF, 0xFF}; // A frissítendő szegmenskép
+/* Számjegyek (0 – 9) szegmensképe, negatív logikával */
+const uint8_t SEGMENT_MAP[]= {0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
+/* Számjegy (1 - 4) kiválasztó jelek */
+const uint8_t SEGMENT_SELECT[] = {0x01, 0x02, 0x04, 0x08};
+
+Thread thread;
+DigitalOut buzzer(D3);
+
+void led2_thread()
+{
+    ShiftOut display(D7, D8, D4);   // clk=D7, data=D8, latch=D4)
+    while (true) {
+        for(int i = 0; i<4; i++) {
+            display.write(segment_data[i]);
+            display.write(SEGMENT_SELECT[i]);
+            Thread::wait(2);
+        }
+    }
+}
+
+int main()
+{
+    int n =0;
+    buzzer = true;
+    thread.start(led2_thread);
+
+    while (true) {
+        segment_data[0] = SEGMENT_MAP[(n/1000) %10];
+        segment_data[1] = SEGMENT_MAP[(n/100) % 10];
+        segment_data[2] = SEGMENT_MAP[(n/10) % 10];
+        segment_data[3] = SEGMENT_MAP[n % 10];
+        n = n+1;
+        buzzer = (n%100) != 0;
+        Thread::wait(250);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 2ae7b6b39e93 mbed-rtos.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Thu Feb 24 07:52:29 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed-rtos/#5713cbbdb706
diff -r 000000000000 -r 2ae7b6b39e93 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Feb 24 07:52:29 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file