Several examples run on only mbed-os5.13.0 (not 5.14.0)

Dependencies:   BD_SD_DISCO_F769NI BSP_DISCO_F769NI LCD_DISCO_F769NI TS_DISCO_F769NI USBHost_F769NI

Revision:
3:35ac9ee7d2d6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zz_common/opening.cpp	Wed Aug 07 05:39:01 2019 +0000
@@ -0,0 +1,168 @@
+/*
+ * Mbed function
+ *
+ *      Created:    July      30th, 2019
+ *      Revised:    July      30th, 2019
+ */
+
+#include "select_program.h"
+#if defined(NIOI_SENSOR)
+
+//  Include --------------------------------------------------------------------
+#include "mbed.h"
+#include "TS_DISCO_F769NI.h"
+#include "LCD_DISCO_F769NI.h"
+#include "FATFileSystem.h"
+#include "SDBlockDeviceDISCOF769NI.h"
+#include "button.hpp"
+#include "button_group.hpp"
+
+//  Definition -----------------------------------------------------------------
+using namespace Mikami;
+#define DATETIME_20190701 1561939200 // passed seconds from 1970/1/1 to 2019/7/1
+#define FOREVER 0x7fffffff
+
+#define DEBUG  0
+
+#if DEBUG
+#define DBG(...)    pc.printf(__VA_ARGS__)
+#else
+#define DBG(...)    {;}
+#endif
+
+//  Constructor ----------------------------------------------------------------
+extern Serial pc;
+extern SDBlockDeviceDISCOF769NI bd;
+extern FATFileSystem fs;
+extern LCD_DISCO_F769NI lcd;
+extern TS_DISCO_F769NI ts;
+
+//  RAM ------------------------------------------------------------------------
+extern bool flag_opening_done;
+
+//  ROM / Constant data --------------------------------------------------------
+
+//  Function prototypes --------------------------------------------------------
+extern void task_opening_action(void const *args);
+extern void drawImage(const char * name, uint16_t x, uint16_t y);
+//extern void draw_bitmap(uint8_t *Name_BMP, uint32_t Xpos, uint32_t Ypos);
+//extern void BSP_LCD_DrawBitmap(uint32_t Xpos, uint32_t Ypos, uint8_t *pbmp);
+extern void time_enter_mode(void);
+
+//------------------------------------------------------------------------------
+//  Control Program
+//------------------------------------------------------------------------------
+void task_opening_action(void const *args)
+{
+    time_t seconds;
+    Timer   t;
+
+    pc.printf("\x1b[2J\x1b[H %s\r\n %s %s (UTC)\r\n",
+              __FILE__, __DATE__, __TIME__);
+    pc.printf(" MBED_VERSION=%d.%d.%d\r\n",
+              MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION);
+    // allocate memory to contain the whole file:
+    char *buf = (char*) malloc (64);
+    lcd.Clear(LCD_COLOR_WHITE);
+    DBG("line:%d\r\n", __LINE__);
+    //Mounting SD-based filesystem
+    int error = fs.mount(&bd);
+    DBG("line:%d\r\n", __LINE__);
+    if (error != 0) {
+        pc.printf("retrun error/Failure. %d\r\n", error);
+    }
+    //Drawing BMP file from SD-card
+    drawImage("/fs/bmp/ty_big0.bmp", 16, 200);
+    DBG("line:%d\r\n", __LINE__);
+    t.reset();
+    t.start();
+    seconds = time(NULL);
+    while (seconds < DATETIME_20190701) {
+        lcd.SetTextColor(LCD_COLOR_BLUE);
+        lcd.DisplayStringAt(
+            0,
+            400,
+            (uint8_t *)"Current time is NOT correct!!",
+            CENTER_MODE);
+        lcd.DisplayStringAt(
+            0,
+            420,
+            (uint8_t *)"Plese enter the time from PC VCOM terminal.",
+            CENTER_MODE);
+        strftime(buf, 50, " %B %d,'%y, %H:%M:%S\r\n", localtime(&seconds));
+        pc.printf("[Time] %s", buf);
+        pc.printf("Current time is NOT correct.");
+        pc.printf("Please enter current date and time.\r\n");
+        time_enter_mode();
+        seconds = time(NULL);
+    }
+    strftime(buf, 50, " %B %d,'%y, %H:%M:%S\r\n", localtime(&seconds));
+    pc.printf("[Time] %s", buf);
+    uint32_t time_show = t.read();
+    if (time_show < 1999) {
+        ThisThread::sleep_for(4000 - time_show);
+    }
+    lcd.Clear(LCD_COLOR_WHITE);
+    DBG("line:%d\r\n", __LINE__);
+    //Drawing BMP file from SD-card
+    drawImage("/fs/bmp/ty.bmp", 600, 6);
+    drawImage("/fs/bmp/nioi_title_1_line.bmp", 20,100);
+
+    uint32_t backColor = 0xFF006A6C;            // teal green
+    uint32_t inActive = backColor & 0xE0FFFFFF; // color for inactive button
+
+    const string strButton[2] = {"Start measurement", "Show time"};
+    ButtonGroup bGroup(lcd, ts, 465, 280, 320, 90,
+                       LCD_COLOR_BLUE, backColor,
+                       2, strButton, 0, 15, 1, Font24);
+    DBG("line:%d\r\n", __LINE__);
+
+    int32_t num = -1;
+    // select color pattern and display
+    while (num == -1) {
+        bGroup.GetTouchedNumber(num);
+    }
+    DBG("num:%d\r\n", num);
+    if (num == 1) {
+        lcd.Clear(LCD_COLOR_WHITE);
+        drawImage("/fs/bmp/minion480x272_new.bmp", 150, 110);
+        Button btn(lcd, ts, 605, 10, 180, 80,
+                   LCD_COLOR_BLUE, LCD_COLOR_WHITE, "Finish", Font24);
+        DBG("line:%d\r\n", __LINE__);
+        lcd.SetTextColor(LCD_COLOR_BLACK);
+        while(true) {
+            seconds = time(NULL);
+            strftime(buf, 50, "  %B %d,'%y, %H:%M:%S  ",
+                     localtime(&seconds));
+            lcd.DisplayStringAt(
+                0, 420,
+                (uint8_t *)"                                                 ",
+                CENTER_MODE);
+            lcd.DisplayStringAt(0, 420,(uint8_t *)buf, CENTER_MODE);
+            if (btn.Touched()) {
+                DBG("line:%d\r\n", __LINE__);
+                break;
+            }
+            if (pc.readable()) {
+                char c = pc.getc();
+                time_enter_mode();
+                seconds = time(NULL);
+            }
+            while (seconds == time(NULL)) {
+                ThisThread::sleep_for(100);
+            }
+
+        }
+    }
+    lcd.Clear(LCD_COLOR_BLUE);
+    t.stop();
+    //Free allocated memory
+    free (buf);
+    ThisThread::sleep_for(10);
+    flag_opening_done = true;
+    while(true) {
+        ThisThread::sleep_for(FOREVER);
+    }
+}
+
+#endif
\ No newline at end of file