DigitalSignal_Lab

Dependencies:   LCD_DISCO_F746NG BSP_DISCO_F746NG Graphics

Revision:
2:447f54400c21
Parent:
0:612209585c31
Child:
3:297f513b26fe
--- a/main.cpp	Sat Aug 24 17:18:04 2019 +0000
+++ b/main.cpp	Sun Aug 25 00:45:05 2019 +0700
@@ -1,36 +1,36 @@
-#include "mbed.h"
+/* mbed Microcontroller Library
+ * Copyright (c) 2018 ARM Limited
+ * SPDX-License-Identifier: Apache-2.0
+ */
 
-/*------------------------------------------------------------------------------
-Before to use this example, ensure that you an hyperterminal installed on your
-computer. More info here: https://developer.mbed.org/handbook/Terminals
-
-The default serial comm port uses the SERIAL_TX and SERIAL_RX pins (see their
-definition in the PinNames.h file).
-
-The default serial configuration in this case is 9600 bauds, 8-bit data, no parity
+#include "mbed.h"
+#include "stats_report.h"
+#include "Graphics/RK043FN48H.h"
 
-If you want to change the baudrate for example, you have to redeclare the
-serial object in your code:
 
-Serial pc(SERIAL_TX, SERIAL_RX);
+DigitalOut led1(LED1);
+RK043FN48H display;
 
-Then, you can modify the baudrate and print like this:
 
-pc.baud(115200);
-pc.printf("Hello World !\n");
-------------------------------------------------------------------------------*/
+#define SLEEP_TIME                  500 // (msec)
+#define PRINT_AFTER_N_LOOPS         20
 
-DigitalOut led(LED1);
-
+// main() runs in its own thread in the OS
 int main()
 {
-    int i = 1;
-
-    printf("Hello World !\n");
+    SystemReport sys_state( SLEEP_TIME * PRINT_AFTER_N_LOOPS /* Loop delay time in ms */);
 
-    while(1) {
-        wait(1); // 1 second
-        led = !led; // Toggle LED
-        printf("This program runs since %d seconds.\n", i++);
+    int count = 0;
+    while (true) {
+        // Blink LED and wait 0.5 seconds
+        led1 = !led1;
+        wait_ms(SLEEP_TIME);
+
+        if ((0 == count) || (PRINT_AFTER_N_LOOPS == count)) {
+            // Following the main thread wait, report on the current system status
+            sys_state.report_state();
+            count = 0;
+        }
+        ++count;
     }
 }