Barometer program : Data Logger function includes Barometer & temperature (BMP180), Humidity & temp. (RHT03), Sunshine (Cds), RTC(M41T62) data. : Logging data saves into EEPROM (AT24C1024) using ring buffer function.

Dependencies:   AT24C1024 RHT03 TextLCD BMP180 M41T62

Fork of mbed_blinky by Mbed

Please see https://mbed.org/users/kenjiArai/notebook/mbed-lpc1114fn28-barometer-with-data-logging/#

Files at this revision

API Documentation at this revision

Comitter:
kenjiArai
Date:
Sat Aug 08 07:01:19 2020 +0000
Parent:
17:f81a6c9e5f7b
Commit message:
change to mbed-os-6.2.0 but not work this revision

Changed in this revision

AT24C1024.lib Show annotated file Show diff for this revision Revisions of this file
BMP180.lib Show annotated file Show diff for this revision Revisions of this file
M41T62.lib Show annotated file Show diff for this revision Revisions of this file
TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
dt_log.h 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
mbed.bld Show diff for this revision Revisions of this file
mbed_app.json Show annotated file Show diff for this revision Revisions of this file
mon.cpp Show annotated file Show diff for this revision Revisions of this file
mon_hw.cpp Show annotated file Show diff for this revision Revisions of this file
mon_hw_config.h Show annotated file Show diff for this revision Revisions of this file
redirect_stdio/redirect_stdio.cpp Show annotated file Show diff for this revision Revisions of this file
redirect_stdio/redirect_stdio.h Show annotated file Show diff for this revision Revisions of this file
diff -r f81a6c9e5f7b -r b3a27f681171 AT24C1024.lib
--- a/AT24C1024.lib	Thu Jul 03 23:07:13 2014 +0000
+++ b/AT24C1024.lib	Sat Aug 08 07:01:19 2020 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/kenjiArai/code/AT24C1024/#05012e75c050
+http://mbed.org/users/kenjiArai/code/AT24C1024/#1c6bba12f698
diff -r f81a6c9e5f7b -r b3a27f681171 BMP180.lib
--- a/BMP180.lib	Thu Jul 03 23:07:13 2014 +0000
+++ b/BMP180.lib	Sat Aug 08 07:01:19 2020 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/kenjiArai/code/BMP180/#20e0c6b19c24
+http://mbed.org/users/kenjiArai/code/BMP180/#37fed112956c
diff -r f81a6c9e5f7b -r b3a27f681171 M41T62.lib
--- a/M41T62.lib	Thu Jul 03 23:07:13 2014 +0000
+++ b/M41T62.lib	Sat Aug 08 07:01:19 2020 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/kenjiArai/code/M41T62/#c58da9ec9ae3
+http://mbed.org/users/kenjiArai/code/M41T62/#0bf0f681fb69
diff -r f81a6c9e5f7b -r b3a27f681171 TextLCD.lib
--- a/TextLCD.lib	Thu Jul 03 23:07:13 2014 +0000
+++ b/TextLCD.lib	Sat Aug 08 07:01:19 2020 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/kenjiArai/code/TextLCD/#986538f94abe
+http://mbed.org/users/kenjiArai/code/TextLCD/#f8e67a681560
diff -r f81a6c9e5f7b -r b3a27f681171 dt_log.h
--- a/dt_log.h	Thu Jul 03 23:07:13 2014 +0000
+++ b/dt_log.h	Sat Aug 08 07:01:19 2020 +0000
@@ -2,23 +2,17 @@
  * mbed Application program for the mbed LPC1114FN28
  * Data Logging 
  *
- * Copyright (c) 2013,'14 Kenji Arai / JH1PJL
- *  http://www.page.sannet.ne.jp/kenjia/index.html
- *  http://mbed.org/users/kenjiArai/
+ * Copyright (c) 2013,'14,'20 Kenji Arai / JH1PJL
+ *  http://www7b.biglobe.ne.jp/~kenjia/
+ *  https://os.mbed.com/users/kenjiArai/
  *      Created: June      16th, 2013
- *      Revised: July       3rd, 2014
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
- * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *      Revised: August     8th, 2020
  */
 
 #ifndef _DT_LOG_H_
 #define _DT_LOG_H_
 
-//  Definition  -----------------------------------------------------------------------------------
+//  Definition  ----------------------------------------------------------------
 // Buffer size
 #define EEP_SIZE    128 * 1024  // 1Mbits = 128 KBytes
 #define PKT_SIZE    16          // Packet size
@@ -34,7 +28,7 @@
 #define RING_TAIL   (BLK_NO - RING_TOP -1)
 #define BLK_SIZE    16
 
-//  Function prototypes ---------------------------------------------------------------------------
+//  Function prototypes --------------------------------------------------------
 void dtlog_data_pack(void);
 void dtlog_one_write(void);
 uint16_t dtlog_buf_occupation(void);
diff -r f81a6c9e5f7b -r b3a27f681171 main.cpp
--- a/main.cpp	Thu Jul 03 23:07:13 2014 +0000
+++ b/main.cpp	Sat Aug 08 07:01:19 2020 +0000
@@ -1,26 +1,20 @@
 /*
  * mbed Application program for the mbed LPC1114FN28
- * Barometer program for only for LPC1114FN28  
+ * Barometer program for only for LPC1114FN28
  *
- * Copyright (c) 2014 Kenji Arai / JH1PJL
- *  http://www.page.sannet.ne.jp/kenjia/index.html
- *  http://mbed.org/users/kenjiArai/
+ * Copyright (c) 2014,'20 Kenji Arai / JH1PJL
+ *  http://www7b.biglobe.ne.jp/~kenjia/
+ *  https://os.mbed.com/users/kenjiArai/
  *      Created: May       21st, 2014
- *      Revised: July       3rd, 2014
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
- * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *      Revised: August     8th, 2020
  */
 /*
  * Function
- *  measure atmospheric pressure and temprerature using Bosch BMP180 pressure sensor
+ *  measure atmospheric pressure and temprerature using Bosch BMP180 sensor
  *  show measured data on AQM0802A LCD and logging such data in EEPROM
  */
 
-//  Include ---------------------------------------------------------------------------------------
+//  Include --------------------------------------------------------------------
 #include "mbed.h"
 #include "BMP180.h"             // Own lib. / Pressure sensor             
 #include "RHT03.h"              // Std. lib./ Humidity sensor
@@ -28,7 +22,7 @@
 #include "m41t62_rtc.h"         // Own lib. / RTC control
 #include "dt_log.h"
 
-//  Definition ------------------------------------------------------------------------------------
+//  Definition -----------------------------------------------------------------
 #define USE_MON                 1
 #define USE_BARO                0
 
@@ -47,12 +41,12 @@
 #define CDS_TBL_SIZE            13
 
 // Waiting time
-#define STATE_CHANGE_TIME       3
+#define STATE_CHANGE_TIME       3000000 // 3sec
 #define TIME_INTERVAL           600     // 10 minutes
 
 typedef enum {CDS = 0, VREF, VOL} ADC_Select;
 
-//  Object ----------------------------------------------------------------------------------------
+//  Object ---------------------------------------------------------------------
 Timeout     to;                // wake-up from sleep()
 I2C         i2c(dp5,dp27);      // SDA, SCL
 DigitalOut  myled0(dp28);       // LED for Debug
@@ -69,10 +63,10 @@
 M41T62      m41t62(i2c);        // STmicro RTC(M41T62)
 TextLCD_I2C_N i2clcd(&i2c, 0x7c, TextLCD::LCD8x2);  // LCD(Akizuki AQM0802A)
 
-//  Function prototypes ---------------------------------------------------------------------------
+//  Function prototypes --------------------------------------------------------
 extern int mon( void);          // only use for debug purpose
 
-//  RAM -------------------------------------------------------------------------------------------
+//  RAM ------------------------------------------------------------------------
 int flag;
 
 //  ADC
@@ -93,240 +87,277 @@
 // EEPROM
 //extern xEeprom_ptr log_inf;
 
-//  ROM / Constant data ---------------------------------------------------------------------------
+//  ROM / Constant data --------------------------------------------------------
 // Cds GL5528 (Dark Resistance 1 Mohm type) SENBA OPTICAL & ELECTRONIC CO.,LTD.
 //      Table value referrence: http://homepage3.nifty.com/skomo/f35/hp35_20.htm
-const float lux_cds[CDS_TBL_SIZE][2] =
-    {{50,21194},{100,8356},{200,3294},{400,1299},{800,512},{1600,202},{3200,79.6},{6400,31.4},
-    {12800,12.4},{25600,4.88},{51200,1.92},{102400,0.758},{409600,0.118}};
+const float lux_cds[CDS_TBL_SIZE][2] = {
+    {50,21194},{100,8356},{200,3294},{400,1299},{800,512},{1600,202},
+    {3200,79.6},{6400,31.4},{12800,12.4},{25600,4.88},{51200,1.92},
+    {102400,0.758},{409600,0.118}
+};
 
 // LCD screen data
-enum Screen{
+enum Screen {
     SCRN_Clear=0, SCRN_Opening, SCRN_Goto_mon, SCRN_Backto_normal
 };
-//                        Clear       Opening      Goto_mon     Backto_normal 
+//                        Clear       Opening      Goto_mon     Backto_normal
 char scrn_1st[4][10] = { "        ", "LPC1114F",  "GOTO MON",  "Back to"};
 char scrn_2nd[4][10] = { "        ", " JH1PJL ",  " 9600BPS",  " Normal"};
 
 // Disply on LCD
-enum Disp_num{
+enum Disp_num {
     DSP_INIT=0, DSP_BARO, DSP_HUMD, DSP_LUX, DSP_TIME, DSP_LOG, DSP_RTURN
 };
 
 // loop time = STATE_CHANGE_TIME * 20 = 3 * 20 = 60 sec (current)
-// rule 1) DSP_INIT is top position, 2)DSP_RTURN is end position, 3) Total number 20
+// rule 1) DSP_INIT is top position
+//      2) DSP_RTURN is end position
+//      3) Total number 20
 const uint8_t lcd_disp_tbl[20]
 //         1,        2,        3,        4,        5,
- = {DSP_INIT, DSP_BARO, DSP_BARO, DSP_BARO, DSP_TIME,
-//         6,        7,        8,        9,       10, 
-    DSP_TIME, DSP_HUMD, DSP_HUMD,  DSP_LUX,  DSP_LUX,
+    = {DSP_INIT, DSP_BARO, DSP_BARO, DSP_BARO, DSP_TIME,
+//         6,        7,        8,        9,       10,
+       DSP_TIME, DSP_HUMD, DSP_HUMD,  DSP_LUX,  DSP_LUX,
 //        11,       12,       13,       14,       15,
-    DSP_BARO, DSP_BARO, DSP_TIME, DSP_TIME, DSP_HUMD,
-//        16,      17,        18,       19,        20 
-    DSP_HUMD, DSP_LUX,   DSP_LUX,  DSP_LOG, DSP_RTURN};
- 
-//-------------------------------------------------------------------------------------------------
+       DSP_BARO, DSP_BARO, DSP_TIME, DSP_TIME, DSP_HUMD,
+//        16,      17,        18,       19,        20
+       DSP_HUMD, DSP_LUX,   DSP_LUX,  DSP_LOG, DSP_RTURN
+      };
+
+//------------------------------------------------------------------------------
 //  Control Program
-//-------------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
 // Normalize ADC data
-void adc_normalize (ADC_Select n){
-int i;
-float x1,y1,dx;
+void adc_normalize (ADC_Select n)
+{
+    int i;
+    float x1,y1,dx;
 
-    switch (n){
-    case CDS:
-        // v_adc = Rfix / (Rcds + Rfix) ->  Rcds = ( Rfix / v_adc ) - Rfix 
-        r_cds = (R_FIX / av_cds) - R_FIX;
-        // CDS resistance to Lux conversion using convertion table (luc_cds[][])
-        for (i =0; i < CDS_TBL_SIZE; i++){  // search table
-            if ( r_cds <= lux_cds[i][0]){ break; }
-        }
-        // Check table position
-        if (i == 0){    lux = lux_cds[0][1];    break;
-        } else if ( i == CDS_TBL_SIZE ){
-            if ( r_cds <= lux_cds[i][0] ){
-                lux = lux_cds[i-1][1];
+    switch (n) {
+        case CDS:
+            // v_adc = Rfix / (Rcds + Rfix) ->  Rcds = ( Rfix / v_adc ) - Rfix
+            r_cds = (R_FIX / av_cds) - R_FIX;
+            // CDS resistance to Lux conversion using convertion table(luc_cds)
+            for (i =0; i < CDS_TBL_SIZE; i++) { // search table
+                if ( r_cds <= lux_cds[i][0]) {
+                    break;
+                }
+            }
+            // Check table position
+            if (i == 0) {
+                lux = lux_cds[0][1];
                 break;
+            } else if ( i == CDS_TBL_SIZE ) {
+                if ( r_cds <= lux_cds[i][0] ) {
+                    lux = lux_cds[i-1][1];
+                    break;
+                }
             }
-        }
-        //  Linear interpolation
-        y1 = lux_cds[i-1][1] - lux_cds[i][1];
-        x1 = lux_cds[i][0] - lux_cds[i-1][0];
-        dx = r_cds - lux_cds[i-1][0];
-        lux = lux_cds[i-1][1] - ((dx/x1) * y1);
-        break;
-    case VREF:  //  vref = VREF_VOLT / VCC -> VCC = VREF_VOLT / vref
-        cal_vcc = VREF_VOLT / vref;
-        break;
-    case VOL:   // Vol center = 1.00 (actual 100)
-        nor_vol = (uint32_t)(av_vol * 200) + VOL_OFFSET;
-        break;
+            //  Linear interpolation
+            y1 = lux_cds[i-1][1] - lux_cds[i][1];
+            x1 = lux_cds[i][0] - lux_cds[i-1][0];
+            dx = r_cds - lux_cds[i-1][0];
+            lux = lux_cds[i-1][1] - ((dx/x1) * y1);
+            break;
+        case VREF:  //  vref = VREF_VOLT / VCC -> VCC = VREF_VOLT / vref
+            cal_vcc = VREF_VOLT / vref;
+            break;
+        case VOL:   // Vol center = 1.00 (actual 100)
+            nor_vol = (uint32_t)(av_vol * 200) + VOL_OFFSET;
+            break;
     }
 }
 
 //  Read adc data and averaging
-void adc_all_read (void){
-    if (av_cds == 0){   av_cds = cds.read();
-    } else {            av_cds = av_cds *0.5 + cds.read() * 0.5;
+void adc_all_read (void)
+{
+    if (av_cds == 0) {
+        av_cds = cds.read();
+    } else {
+        av_cds = av_cds *0.5 + cds.read() * 0.5;
     }
-    if (av_vref == 0){  av_vref = vref.read();
-    } else {            av_vref = av_vref *0.9 + vref.read() * 0.1;
+    if (av_vref == 0) {
+        av_vref = vref.read();
+    } else {
+        av_vref = av_vref *0.9 + vref.read() * 0.1;
     }
-    if (av_vol == 0){   av_vol = vol.read();
-    } else {            av_vol = av_vol *0.2 + vol.read() * 0.8;
-    } 
+    if (av_vol == 0) {
+        av_vol = vol.read();
+    } else {
+        av_vol = av_vol *0.2 + vol.read() * 0.8;
+    }
 }
 
 // Read Humidity sensor data
-void hum_RHT03_read (void){
-    while (true){   // wait data
-        if ( humtemp.readData() == RHT_ERROR_NONE ){ break; }
+void hum_RHT03_read (void)
+{
+    while (true) {  // wait data
+        if ( humtemp.readData() == RHT_ERROR_NONE ) {
+            break;
+        }
     }
-    if (humidity_temp == 0){humidity_temp = humtemp.getTemperatureC();
-    } else {                humidity_temp = humidity_temp * 0.9 + humtemp.getTemperatureC() * 0.1;
+    if (humidity_temp == 0) {
+        humidity_temp = humtemp.getTemperatureC();
+    } else {
+        humidity_temp = humidity_temp * 0.9 + humtemp.getTemperatureC() * 0.1;
     }
-    if ( humidity == 0 ){   humidity = humtemp.getHumidity();
-    } else {                humidity = humidity * 0.9 + humtemp.getHumidity() * 0.1;
+    if ( humidity == 0 ) {
+        humidity = humtemp.getHumidity();
+    } else {
+        humidity = humidity * 0.9 + humtemp.getHumidity() * 0.1;
     }
 }
 
-void set_lcd_screen(int n){
+void set_lcd_screen(int n)
+{
     i2clcd.locate(0, 0);
     i2clcd.printf("%s", scrn_1st[n]);
     i2clcd.locate(0, 1);
     i2clcd.printf("%s", scrn_2nd[n]);
 }
 
-//-------------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
 // Application program
-//-------------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
 // Nothing is done but just wake-up from sleep condition
-void wakeup() {
+void wakeup()
+{
     flag = 1;
     myled1 = !myled1;
 }
 
 // Measure pressure and show it on LCD
-void conv_and_disp(void) {
-tm t;
-time_t seconds = 0;
-time_t old_seconds = 0;
-uint32_t step = 0, dt;
-uint8_t num;
+void conv_and_disp(void)
+{
+    tm t;
+    time_t seconds = 0;
+    time_t old_seconds = 0;
+    uint32_t step = 0, dt;
+    uint8_t num;
 
     while (true) {          // infinit loop for measure and display
         // Call wakeup()function after specific time
-        to.attach(&wakeup, STATE_CHANGE_TIME);    // this is for wake-up
-//---- State Control ----
+        // this is for wake-up
+        to.attach(callback(&wakeup), chrono::milliseconds(STATE_CHANGE_TIME));
+        //---- State Control ----
         num = lcd_disp_tbl[step++];
-        switch (num){
-    //  ---------- Initialize data ----------------------------------------------------------------
-        case DSP_INIT:
-            av_cds = 0;
-            av_vref = 0;
-            av_vol = 0;
-            humidity_temp = 0;
-            humidity = 0;
-            // RTC
-            m41t62.set_sq_wave(RTC_SQW_NONE);
-            m41t62.read_rtc_std(&t);
-            old_seconds = mktime(&t); 
-            break;
-    //  ---------- Cds Sensor, Vref, Volume -------------------------------------------------------
-        case DSP_LUX:
-            // Power on / Analog sensor
-            analog_pwr = 1;
-            vref_pwr = 1;
-            wait(0.2);
-            adc_all_read();
-            // Power off / Analog sensor
-            analog_pwr = 0; 
-            // Normalize
-            adc_normalize(CDS);
-            adc_normalize(VREF);
-            adc_normalize(VOL);
-            set_lcd_screen(SCRN_Clear);
-            i2clcd.locate(0, 0);    // 1st line top
-            //             12345678
-            i2clcd.printf("L:%.1f", lux);
-            i2clcd.locate(0, 1);    // 2nd line top
-            i2clcd.printf("V:%.3f", cal_vcc);
-            break;
-    //  ---------- Barometer Sensor / BMP180 ------------------------------------------------------
-        case DSP_BARO:
-            bmp180.normalize();
-            baro = bmp180.read_pressure();
-            baro_temp = bmp180.read_temperature();
-            set_lcd_screen(SCRN_Clear);
-            i2clcd.locate(0, 0);    // 1st line top
-            i2clcd.printf("P:%.1f", baro);
-            i2clcd.locate(0, 1);    // 2nd line top
-            i2clcd.printf("T:%\+-6.1f", baro_temp);
-            break;
-    //  ---------- Humidity Sensor / RHT03 --------------------------------------------------------
-        case DSP_HUMD:
-            hum_RHT03_read();       // Read Humidity data then avaraging
-            set_lcd_screen(SCRN_Clear);
-            i2clcd.locate(0, 0);    // 1st line top
-            i2clcd.printf("H:%.1f", humidity);
-            i2clcd.locate(0, 1);    // 2nd line top
-            i2clcd.printf("T:%\+-6.1f", humidity_temp);
-            break;
-    //  ---------- RTC ----------------------------------------------------------------------------
-        case DSP_TIME:
-            m41t62.read_rtc_std(&t);
-            seconds = mktime(&t);
-            set_lcd_screen(SCRN_Clear);
-            i2clcd.locate(0, 0);    // 1st line top
-            i2clcd.printf("%02d/%02d/%02d", t.tm_year % 100, t.tm_mon + 1, t.tm_mday);
-            i2clcd.locate(0, 1);    // 2nd line top
-            i2clcd.printf("%02d:%02d:%02d", t.tm_hour, t.tm_min, t.tm_sec);
-            break;
-    //  ---------- EEPROM Logging -----------------------------------------------------------------
-        case DSP_LOG:
-            if (seconds >= old_seconds + TIME_INTERVAL){
-                // Data Logging action
-                old_seconds += TIME_INTERVAL;
-                dtlog_data_pack();  // Get EEPROM resource
-                dtlog_one_write();  // Write data to EEPROM
-                dt = (uint32_t)dtlog_buf_occupation();
-                dt = (dt * 1000)/ BLK_NO;
-            }     
-            set_lcd_screen(SCRN_Clear);
-            i2clcd.locate(0, 0);    // 1st line top
-            i2clcd.printf("Logging");
-            i2clcd.locate(0, 1);    // 2nd line top
-            i2clcd.printf("%d.%01d%%", dt / 10, dt % 10);
-            break;
-    //  ---------- return (loop) ------------------------------------------------------------------
-        case DSP_RTURN:
-        default:
-            //  <State> State change 
-            step = 1;   // if something wrong, go to reset condition
+        switch (num) {
+            //  ---------- Initialize data -------------------------------------
+            case DSP_INIT:
+                av_cds = 0;
+                av_vref = 0;
+                av_vol = 0;
+                humidity_temp = 0;
+                humidity = 0;
+                // RTC
+                m41t62.set_sq_wave(RTC_SQW_NONE);
+                m41t62.read_rtc_std(&t);
+                old_seconds = mktime(&t);
+                break;
+            //  ---------- Cds Sensor, Vref, Volume ----------------------------
+            case DSP_LUX:
+                // Power on / Analog sensor
+                analog_pwr = 1;
+                vref_pwr = 1;
+                ThisThread::sleep_for(200ms);
+                adc_all_read();
+                // Power off / Analog sensor
+                analog_pwr = 0;
+                // Normalize
+                adc_normalize(CDS);
+                adc_normalize(VREF);
+                adc_normalize(VOL);
+                set_lcd_screen(SCRN_Clear);
+                i2clcd.locate(0, 0);    // 1st line top
+                //             12345678
+                i2clcd.printf("L:%.1f", lux);
+                i2clcd.locate(0, 1);    // 2nd line top
+                i2clcd.printf("V:%.3f", cal_vcc);
+                break;
+            //  ---------- Barometer Sensor / BMP180 ---------------------------
+            case DSP_BARO:
+                bmp180.normalize();
+                baro = bmp180.read_pressure();
+                baro_temp = bmp180.read_temperature();
+                set_lcd_screen(SCRN_Clear);
+                i2clcd.locate(0, 0);    // 1st line top
+                i2clcd.printf("P:%.1f", baro);
+                i2clcd.locate(0, 1);    // 2nd line top
+                i2clcd.printf("T:%+6.1f", baro_temp);
+                break;
+            //  ---------- Humidity Sensor / RHT03 -----------------------------
+            case DSP_HUMD:
+                hum_RHT03_read();       // Read Humidity data then avaraging
+                set_lcd_screen(SCRN_Clear);
+                i2clcd.locate(0, 0);    // 1st line top
+                i2clcd.printf("H:%.1f", humidity);
+                i2clcd.locate(0, 1);    // 2nd line top
+                i2clcd.printf("T:%+6.1f", humidity_temp);
+                break;
+            //  ---------- RTC -------------------------------------------------
+            case DSP_TIME:
+                m41t62.read_rtc_std(&t);
+                seconds = mktime(&t);
+                set_lcd_screen(SCRN_Clear);
+                i2clcd.locate(0, 0);    // 1st line top
+                i2clcd.printf("%02d/%02d/%02d",
+                              t.tm_year % 100, t.tm_mon + 1, t.tm_mday);
+                i2clcd.locate(0, 1);    // 2nd line top
+                i2clcd.printf("%02d:%02d:%02d", t.tm_hour, t.tm_min, t.tm_sec);
+                break;
+            //  ---------- EEPROM Logging --------------------------------------
+            case DSP_LOG:
+                if (seconds >= old_seconds + TIME_INTERVAL) {
+                    // Data Logging action
+                    old_seconds += TIME_INTERVAL;
+                    dtlog_data_pack();  // Get EEPROM resource
+                    dtlog_one_write();  // Write data to EEPROM
+                    dt = (uint32_t)dtlog_buf_occupation();
+                    dt = (dt * 1000)/ BLK_NO;
+                }
+                set_lcd_screen(SCRN_Clear);
+                i2clcd.locate(0, 0);    // 1st line top
+                i2clcd.printf("Logging");
+                i2clcd.locate(0, 1);    // 2nd line top
+                i2clcd.printf("%d.%01d%%", dt / 10, dt % 10);
+                break;
+            //  ---------- return (loop) ---------------------------------------
+            case DSP_RTURN:
+            default:
+                //  <State> State change
+                step = 1;   // if something wrong, go to reset condition
         }
-    //  ---------- back to top --------------------------------------------------------------------
+        //  ---------- back to top ---------------------------------------------
         myled0 = !myled0;
-        while (flag == 0){ wait(0.01);}
-        wait(0.1);
+        while (flag == 0) {
+            ThisThread::sleep_for(10ms);
+        }
+        ThisThread::sleep_for(100ms);
         myled1 = !myled1;
         flag = 0;
     }
 }
 
 // Application program starts here
-int main() {
+int main()
+{
     flag = 0;
     i2clcd.setContrast(25);
     set_lcd_screen(SCRN_Opening);
-    if (sw_chng == 0){  // SW ON
-    //--  Enter Monitor Mode  --
-        myled1 = 1;     wait(0.5);
-        myled1 = 0;     wait(0.5);
-        myled1 = 1;     wait(0.5);
-        if (sw_chng == 0){  // Still SW ON
-            myled1 = 0;     wait(0.5);
-            myled1 = 1;     wait(0.5);
-            if (sw_mode == 0){ // SW ON
+    if (sw_chng == 0) { // SW ON
+        //--  Enter Monitor Mode  --
+        myled1 = 1;
+        ThisThread::sleep_for(500ms);
+        myled1 = 0;
+        ThisThread::sleep_for(500ms);
+        myled1 = 1;
+        ThisThread::sleep_for(500ms);
+        if (sw_chng == 0) { // Still SW ON
+            myled1 = 0;
+            ThisThread::sleep_for(500ms);
+            myled1 = 1;
+            ThisThread::sleep_for(500ms);
+            if (sw_mode == 0) { // SW ON
                 set_lcd_screen(SCRN_Clear);
                 set_lcd_screen(SCRN_Goto_mon);
                 myled1 = 0;
diff -r f81a6c9e5f7b -r b3a27f681171 mbed-os.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Sat Aug 08 07:01:19 2020 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#a2ada74770f043aff3e61e29d164a8e78274fcd4
diff -r f81a6c9e5f7b -r b3a27f681171 mbed.bld
--- a/mbed.bld	Thu Jul 03 23:07:13 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/024bf7f99721
\ No newline at end of file
diff -r f81a6c9e5f7b -r b3a27f681171 mbed_app.json
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_app.json	Sat Aug 08 07:01:19 2020 +0000
@@ -0,0 +1,8 @@
+{
+    "requires": ["bare-metal"],
+    "target_overrides": {
+        "*": {
+            "target.printf_lib": "std"
+        }
+    }
+}
diff -r f81a6c9e5f7b -r b3a27f681171 mon.cpp
--- a/mon.cpp	Thu Jul 03 23:07:13 2014 +0000
+++ b/mon.cpp	Sat Aug 08 07:01:19 2020 +0000
@@ -1,44 +1,37 @@
 /*
  * mbed Application program
- * Data logging & Monitor program for only LPC1114FN28 
+ * Data logging & Monitor program for only LPC1114FN28
  *
- *  Copyright (c) 2010-2014 Kenji Arai / JH1PJL
- *  http://www.page.sannet.ne.jp/kenjia/index.html
- *  http://mbed.org/users/kenjiArai/
- *      Created:  May  	    15th, 2010
- *		Spareted: June		25th, 2014		mon() & mon_hw()
- *      Revised: July        3rd, 2014
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
- * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * Copyright (c) 2010,'14,'20 Kenji Arai / JH1PJL
+ *  http://www7b.biglobe.ne.jp/~kenjia/
+ *  https://os.mbed.com/users/kenjiArai/
+ *      Created:  May  	   15th, 2010
+ *		Spareted: June	   25th, 2014		mon() & mon_hw()
+ *      Revised: August     8th, 2020
  */
 
-//  Include ---------------------------------------------------------------------------------------
+//  Include --------------------------------------------------------------------
 #include "mbed.h"
 #include "m41t62_rtc.h"			// Own lib. / RTC control
 #include "AT24C1024.h"			// Own lib. / EEPROM control
 #include "dt_log.h"
-
-//  Object ----------------------------------------------------------------------------------------
-Serial pc(dp16,dp15);
-extern I2C    xi2c(dp5,dp27);	// SDA, SCL
-extern M41T62 xm41t62(xi2c);	// STmicro RTC(M41T62)
-AT24C1024   at24c1024(xi2c);    // Atmel 1Mbit EE-PROM 
+#include "redirect_stdio.h"
 
-//  Definition ------------------------------------------------------------------------------------
-#define BAUD(x)         		pc.baud(x)
-#define GETC(x)         		pc.getc(x)
-#define PUTC(x)					pc.putc(x)
-#define PRINTF(...)     		pc.printf(__VA_ARGS__)
-#define READABLE(x)     		pc.readable(x)
+//  Object ---------------------------------------------------------------------
+extern I2C    xi2c;						// SDA, SCL
+extern M41T62 xm41t62;					// STmicro RTC(M41T62)
+AT24C1024     at24c1024(dp5,dp27);    	// Atmel 1Mbit EE-PROM
+
+//  Definition -----------------------------------------------------------------
+#define GETC(x)         		getc(x)
+#define PUTC(x)					putc(x)
+#define PRINTF(...)     		printf(__VA_ARGS__)
+#define READABLE(x)     		readable(x)
 
 // EEPROM
 #define EEP_TOP					0x0
 
-//  RAM -------------------------------------------------------------------------------------------
+//  RAM ------------------------------------------------------------------------
 char linebuf[64];
 int buf_size = sizeof(linebuf);
 
@@ -50,25 +43,25 @@
     uint16_t    tail;
 } ring_t;
 
-union _inf{
-	uint8_t buf_pointer[PTR_SIZE];
-	ring_t log_inf;
-}inf;
+union _inf {
+    uint8_t buf_pointer[PTR_SIZE];
+    ring_t log_inf;
+} inf;
 
 typedef struct {
-	uint32_t	time;
-	uint16_t	vcc;
-	uint16_t	baro;
-	int16_t		b_temp;
-	uint16_t	humi;
-	int16_t		h_temp;
-	uint16_t	lux;
-}one_log;		// 16 bytes total
+    uint32_t	time;
+    uint16_t	vcc;
+    uint16_t	baro;
+    int16_t		b_temp;
+    uint16_t	humi;
+    int16_t		h_temp;
+    uint16_t	lux;
+} one_log;		// 16 bytes total
 
-union _one{
-	uint8_t bf[PKT_SIZE];
-	one_log lg;
-}one;
+union _one {
+    uint8_t bf[PKT_SIZE];
+    one_log lg;
+} one;
 
 extern float baro;
 extern float baro_temp;
@@ -78,36 +71,54 @@
 extern float humidity_temp;
 extern float lux;
 
-//  ROM / Constant data ---------------------------------------------------------------------------
-static char *const mon_msg = "Monitor for mbed system, created on "__DATE__"";
+//  ROM / Constant data --------------------------------------------------------
+static const char *const mon_msg =
+    "Monitor for mbed system, created on " __DATE__ "";
 
-//                      $, 2014/6/29,12:43:16,3.293,1004.5,+29.3,45.8,+29.2,1234,*
-char *const log_head = "$,YYYY/MM/DD,HH:MM:SS,Vcc  ,Press ,Temp ,Humi,Temp ,Lux  ,*";
-char *const msg_emty = "Data empty";
-char *const msg_end  = "\r\nreach to end";
+const char *const log_head =
+//   $, 2014/6/29,12:43:16,3.293,1004.5,+29.3,45.8,+29.2,1234,*
+    "$,YYYY/MM/DD,HH:MM:SS,Vcc  ,Press ,Temp ,Humi,Temp ,Lux  ,*";
+const char *const msg_emty = "Data empty";
+const char *const msg_end  = "\r\nreach to end";
 
-//  Function prototypes ---------------------------------------------------------------------------
-extern void mon_hw(void);
+//  Function prototypes --------------------------------------------------------
+//extern void mon_hw(void);		// ROM& RAM limitation
 
-//-------------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
 //  Control Program
-//-------------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
 //  Put \r\n
-void put_rn ( void ){	PUTC('\r');		PUTC('\n');}
+void put_rn ( void )
+{
+    PUTC('\r');
+    PUTC('\n');
+}
 
 //  Put \r
-void put_r ( void ){	PUTC('\r');}
+void put_r ( void )
+{
+    PUTC('\r');
+}
 
 // Put ", "
-void put_lin ( void ){	PRINTF(", ");}
+void put_lin ( void )
+{
+    PRINTF(", ");
+}
 
 // Put space n
-void put_spc( uint8_t n){	for(;n > 0; n--){ PUTC(' '); }}
+void put_spc( uint8_t n)
+{
+    for(; n > 0; n--) {
+        PUTC(' ');
+    }
+}
 
 //  Change string -> integer
-int xatoi (char **str, unsigned long *res){
-unsigned long val;
-unsigned char c, radix, s = 0;
+int xatoi (char **str, unsigned long *res)
+{
+    unsigned long val;
+    unsigned char c, radix, s = 0;
 
     while ((c = **str) == ' ') (*str)++;
     if (c == '-') {
@@ -116,7 +127,10 @@
     }
     if (c == '0') {
         c = *(++(*str));
-        if (c <= ' ') {	*res = 0;	return 1; }
+        if (c <= ' ') {
+            *res = 0;
+            return 1;
+        }
         if (c == 'x') {
             radix = 16;
             c = *(++(*str));
@@ -125,12 +139,17 @@
                 radix = 2;
                 c = *(++(*str));
             } else {
-                if ((c >= '0')&&(c <= '9')){	radix = 8;
-                }	else {   return 0;}
+                if ((c >= '0')&&(c <= '9')) {
+                    radix = 8;
+                }	else {
+                    return 0;
+                }
             }
         }
     } else {
-        if ((c < '1')||(c > '9')){	return 0;}
+        if ((c < '1')||(c > '9')) {
+            return 0;
+        }
         radix = 10;
     }
     val = 0;
@@ -150,24 +169,25 @@
     return 1;
 }
 
-//-------------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
 // Data Logging / Save into EEPROM
-//-------------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
 /*
     head = H, tail =T
 	state 1:	H=1(RING_TOP),T=1(RING_TOP)	-> just after Clear command
-	state 2:	H=1,T=n		-> n = 2 to RING_TAIL-1 (not filled yet)	
+	state 2:	H=1,T=n		-> n = 2 to RING_TAIL-1 (not filled yet)
 	state 3:	H=1,T=RING_TAIL	-> need to check!!!! (just filled)
 	state 4:	H=2,T=1(RING_TOP) -> start ringed state
 	state 5:	H=n,T=n-1	-> n = 2 to RING_TAIL-1 (ringed)
 	state 6:	H=RING_TAIL,T=RING_TAIL-1 -> need to check!!!!!
 	state 7:	H=1(RING_TOP),T=RING_TAIL -> need to check!!!!!
-	state 8:	same as "state 5"	
+	state 8:	same as "state 5"
 		-> Need to check state 3,6,7
 */
 //  Make one data packet data structure
-void dtlog_data_pack(void){
-struct tm t;
+void dtlog_data_pack(void)
+{
+    struct tm t;
 
     xm41t62.read_rtc_std(&t);
     one.lg.time = mktime(&t);
@@ -180,235 +200,256 @@
 }
 
 //  Print one packet as normalized data
-void print_one_block_data(void){
-struct tm *t;
-time_t seconds;
-uint16_t dt0;
-int16_t dt1;
+void print_one_block_data(void)
+{
+    struct tm *t;
+    time_t seconds;
+    uint16_t dt0;
+    int16_t dt1;
 
     put_rn();
     PUTC( '$' );
     //--- Time
     seconds = one.lg.time;
     t = localtime(&seconds);
-	PRINTF(",%04d/%02d/%02d,%02d:%02d:%02d,",
-			t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
-	//--- Vcc
-	dt0 = one.lg.vcc;
-	PRINTF("%01d.%03d,", dt0/1000, dt0%1000);
-	//--- Pressure
-	dt0 = one.lg.baro;
-	PRINTF("%04d.%01d,", dt0/10, dt0%10 );
-	//--- Temp.
-	dt1 = one.lg.b_temp;
-	PRINTF("%\+-03d.%01d,", dt1/10, abs(dt1)%10 );
-	//--- Humidity	   
-	dt0 = one.lg.humi;
-	PRINTF("%02d.%01d,", dt0/10, dt0%10 );
-	//--- Temp.
-	dt1 = one.lg.h_temp;
-	PRINTF("%\+-03d.%01d,", dt1/10, abs(dt1)%10 );
-	//--- Lux
-	dt0 = one.lg.lux;
-	PRINTF("%05d,*", dt0);
+    PRINTF(",%04d/%02d/%02d,%02d:%02d:%02d,",
+           t->tm_year + 1900, t->tm_mon + 1,
+           t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
+    //--- Vcc
+    dt0 = one.lg.vcc;
+    PRINTF("%01d.%03d,", dt0/1000, dt0%1000);
+    //--- Pressure
+    dt0 = one.lg.baro;
+    PRINTF("%04d.%01d,", dt0/10, dt0%10 );
+    //--- Temp.
+    dt1 = one.lg.b_temp;
+    PRINTF("%+03d.%01d,", dt1/10, abs(dt1)%10 );
+    //--- Humidity
+    dt0 = one.lg.humi;
+    PRINTF("%02d.%01d,", dt0/10, dt0%10 );
+    //--- Temp.
+    dt1 = one.lg.h_temp;
+    PRINTF("%+03d.%01d,", dt1/10, abs(dt1)%10 );
+    //--- Lux
+    dt0 = one.lg.lux;
+    PRINTF("%05d,*", dt0);
 }
 
 // Read buffer pointer
-static void dtlog_pointer_read(void){
-uint8_t i;
-uint8_t *addr;
+static void dtlog_pointer_read(void)
+{
+    uint8_t i;
+    uint8_t *addr;
 
     /* Read EEPROM and save to buf_pointer[] */
-    for ( i = 0; i < PTR_SIZE; i++ ){
+    for ( i = 0; i < PTR_SIZE; i++ ) {
         addr = (uint8_t *)(EEP_TOP + i);
         inf.buf_pointer[i]  = at24c1024.read((int)addr);
-        wait(0.002);
+        ThisThread::sleep_for(2ms);
     }
 // PRINTF("head %d, Tail %d\r\n", inf.log_inf.head, inf.log_inf.tail);
 }
 
 //  Write one packet
-void dtlog_one_write(void){
-uint8_t i;
-uint8_t *addr;
+void dtlog_one_write(void)
+{
+    uint8_t i;
+    uint8_t *addr;
 
     // Read EEPROM buffer pointer to RAM
-    for ( i = 0; i < PTR_SIZE; i++ ){
+    for ( i = 0; i < PTR_SIZE; i++ ) {
         addr = (uint8_t *)(EEP_TOP + i);
         inf.buf_pointer[i]  = at24c1024.read((int)addr);
-        wait(0.002);
+        ThisThread::sleep_for(2ms);
     }
- //PRINTF("head %d, Tail %d\r\n", inf.log_inf.head, inf.log_inf.tail);
+//PRINTF("head %d, Tail %d\r\n", inf.log_inf.head, inf.log_inf.tail);
     // Write data_pack[] into  EEPROM
-    for (i = 0; i < PKT_SIZE; i++){
-        addr = (uint8_t *)(EEP_TOP + (inf.log_inf.tail * PTR_SIZE) + i); 
+    for (i = 0; i < PKT_SIZE; i++) {
+        addr = (uint8_t *)(EEP_TOP + (inf.log_inf.tail * PTR_SIZE) + i);
         at24c1024.write((int)addr, one.bf[i]);
-        wait(0.008);
+        ThisThread::sleep_for(8ms);
     }
     // Increment buffer pointer in RAM
-    if (inf.log_inf.head == RING_TOP){	// check state 1,2,3
-    	if (inf.log_inf.tail == RING_TAIL){	// check state 3
-			inf.log_inf.tail = RING_TOP;		// set state 4
-			inf.log_inf.head = 2;				// missing one oldest data
-		} else {
-			inf.log_inf.tail++;					// set state 2
-		}
+    if (inf.log_inf.head == RING_TOP) {	// check state 1,2,3
+        if (inf.log_inf.tail == RING_TAIL) {	// check state 3
+            inf.log_inf.tail = RING_TOP;		// set state 4
+            inf.log_inf.head = 2;				// missing one oldest data
+        } else {
+            inf.log_inf.tail++;					// set state 2
+        }
     } else {	// check state 4,5,6,7
-    	if (inf.log_inf.head == RING_TAIL){ // check state 6
-    		inf.log_inf.head = RING_TOP; 	// set state 7
-    		inf.log_inf.tail = RING_TAIL;
-    	} else if (inf.log_inf.tail == inf.log_inf.head - 1){ // check state 4,5
-			++inf.log_inf.tail;		// continue state 5
-			++inf.log_inf.head;
-		}
+        if (inf.log_inf.head == RING_TAIL) { // check state 6
+            inf.log_inf.head = RING_TOP; 	// set state 7
+            inf.log_inf.tail = RING_TAIL;
+            // check state 4,5
+        } else if (inf.log_inf.tail == inf.log_inf.head - 1) {
+            ++inf.log_inf.tail;		// continue state 5
+            ++inf.log_inf.head;
+        }
     }
-    // Write buffer pointer into EEPROM  
-    for (i = 0; i < PTR_SIZE; i++){
-        addr = (uint8_t *)(EEP_TOP + i);    
+    // Write buffer pointer into EEPROM
+    for (i = 0; i < PTR_SIZE; i++) {
+        addr = (uint8_t *)(EEP_TOP + i);
         at24c1024.write((int)addr, inf.buf_pointer[i]);
-        wait(0.008);
-    } 
+        ThisThread::sleep_for(8ms);
+    }
 }
 
 // Read some block from buffer
-void dtlog_block_read(int16_t *pt, uint16_t n){
-uint8_t i;
-uint8_t *addr;
-uint16_t num;
+void dtlog_block_read(int16_t *pt, uint16_t n)
+{
+    uint8_t i;
+    uint8_t *addr;
+    uint16_t num;
 
     dtlog_pointer_read();
-    if (inf.log_inf.tail == inf.log_inf.head){ // Check pointer
+    if (inf.log_inf.tail == inf.log_inf.head) { // Check pointer
         PRINTF(msg_emty);
         put_rn();
         return;
     }
-	PRINTF("Head:%d, Tail:%d, Start pointer:%d, Number of data:%d\r\n",
-			inf.log_inf.head, inf.log_inf.tail, *pt, n);
+    PRINTF("Head:%d, Tail:%d, Start pointer:%d, Number of data:%d\r\n",
+           inf.log_inf.head, inf.log_inf.tail, *pt, n);
     PRINTF( log_head );
-    for (num = 0; num < n; num++){
+    for (num = 0; num < n; num++) {
         /* Read EEPROM and save to data_pack[] */
-        for (i = 0; i < PKT_SIZE; i++){
+        for (i = 0; i < PKT_SIZE; i++) {
             addr = (uint8_t *)(EEP_TOP + (*pt * PTR_SIZE) + i);
             one.bf[i]  =at24c1024.read((int)addr);
-            wait(0.002);
+            ThisThread::sleep_for(2ms);
         }
         print_one_block_data();
-        if (READABLE()){	GETC(); break;}
-        wait(0.001);
-	    if (inf.log_inf.head == RING_TOP){	// check state 1,2,3
-	        *pt += 1;
-	        if (*pt >= inf.log_inf.tail){ // check state 2,3
-	        	PRINTF(msg_end);
-            	break;
+        if (READABLE()) {
+            GETC();
+            break;
+        }
+        ThisThread::sleep_for(1ms);
+        if (inf.log_inf.head == RING_TOP) {	// check state 1,2,3
+            *pt += 1;
+            if (*pt >= inf.log_inf.tail) { // check state 2,3
+                PRINTF(msg_end);
+                break;
             }
-	    } else {	// state 4,5,6,7
-	    	if (inf.log_inf.head == RING_TAIL){ // check state 6
-	    		if (inf.log_inf.tail == RING_TAIL -1){ // check state 6
-	    			if (*pt == RING_TAIL){ // same as  :pt += 1
-	    				*pt = RING_TOP;
-	    			} else { // next read
-				    	*pt += 1;
-				        if (*pt >= inf.log_inf.tail){
-				        	PRINTF(msg_end);
-			            	break;
-		            	}
-		            }
-	    		}
-	    	} else if (inf.log_inf.tail == inf.log_inf.head - 1){ // check state 5
-		    	*pt += 1;
-		    	if (*pt > RING_TAIL){ // same as  :pt += 1
-		    		*pt = RING_TOP;
-		    	} else if (*pt == inf.log_inf.tail){ // reach to end
-		        	PRINTF(msg_end);
-	            	break;
-            	}
-			}
-	    }
+        } else {	// state 4,5,6,7
+            if (inf.log_inf.head == RING_TAIL) { // check state 6
+                if (inf.log_inf.tail == RING_TAIL -1) { // check state 6
+                    if (*pt == RING_TAIL) { // same as  :pt += 1
+                        *pt = RING_TOP;
+                    } else { // next read
+                        *pt += 1;
+                        if (*pt >= inf.log_inf.tail) {
+                            PRINTF(msg_end);
+                            break;
+                        }
+                    }
+                }
+                // check state 5
+            } else if (inf.log_inf.tail == inf.log_inf.head - 1) {
+                *pt += 1;
+                if (*pt > RING_TAIL) { // same as  :pt += 1
+                    *pt = RING_TOP;
+                } else if (*pt == inf.log_inf.tail) { // reach to end
+                    PRINTF(msg_end);
+                    break;
+                }
+            }
+        }
     }
     put_rn();
 }
 
 //  Clear all buffer
-void dtlog_clear_all_buff(void){
-uint8_t i;
-uint8_t *addr;
+void dtlog_clear_all_buff(void)
+{
+    uint8_t i;
+    uint8_t *addr;
 
     /* Set initial data */
-	inf.log_inf.head = inf.log_inf.tail = RING_TOP;  
+    inf.log_inf.head = inf.log_inf.tail = RING_TOP;
     /* Write buffer pointer */
-    for (i = 0; i < PTR_SIZE; i++){
+    for (i = 0; i < PTR_SIZE; i++) {
         addr = (uint8_t *)(EEP_TOP + i);
         at24c1024.write((int)addr, inf.buf_pointer[i]);
-        wait(0.008);
+        ThisThread::sleep_for(8ms);
     }
 }
 
 // EEPROM buffer occupation
-uint16_t dtlog_buf_occupation(void){
-uint16_t i = 0;
-uint16_t dt = 0;
-uint8_t *addr;
+uint16_t dtlog_buf_occupation(void)
+{
+    uint16_t i = 0;
+    uint16_t dt = 0;
+    uint8_t *addr;
 
     // Read EEPROM buffer pointer to RAM
-    for ( i = 0; i < PTR_SIZE; i++ ){
+    for ( i = 0; i < PTR_SIZE; i++ ) {
         addr = (uint8_t *)(EEP_TOP + i);
         inf.buf_pointer[i]  = at24c1024.read((int)addr);
-        wait(0.002);
+        ThisThread::sleep_for(2ms);
     }
     // check buffer pointer
-    if (inf.log_inf.head == inf.log_inf.tail){
+    if (inf.log_inf.head == inf.log_inf.tail) {
         PRINTF(msg_emty);
         put_rn();
         return 0;
     }
-    if (inf.log_inf.head == RING_TOP){	// check state 1,2,3
-    	dt = inf.log_inf.tail - inf.log_inf.head;
+    if (inf.log_inf.head == RING_TOP) {	// check state 1,2,3
+        dt = inf.log_inf.tail - inf.log_inf.head;
     } else {	// state 4,5,6,7
-    	if (inf.log_inf.head == RING_TAIL){	// check state 6
-    		if (inf.log_inf.tail == RING_TAIL - 1){	// check state 6
-			    dt = inf.log_inf.tail - RING_TOP + 1;
-    		}
-    	} else if (inf.log_inf.tail == inf.log_inf.head - 1){ // check state 4,5
-			dt = RING_TAIL;
-		} else {	// error
-		    dt = 0;
-		}
+        if (inf.log_inf.head == RING_TAIL) {	// check state 6
+            if (inf.log_inf.tail == RING_TAIL - 1) {	// check state 6
+                dt = inf.log_inf.tail - RING_TOP + 1;
+            }
+            // check state 4,5
+        } else if (inf.log_inf.tail == inf.log_inf.head - 1) {
+            dt = RING_TAIL;
+        } else {	// error
+            dt = 0;
+        }
     }
     return dt;
 }
 
 //  Read block number
-void dtlog_num_of_block(void){
-uint16_t dt;
+void dtlog_num_of_block(void)
+{
+    uint16_t dt;
 
-	dt = dtlog_buf_occupation();
-	if (dt == 0){
-		PRINTF(msg_emty);
+    dt = dtlog_buf_occupation();
+    if (dt == 0) {
+        PRINTF(msg_emty);
     } else {
-	    PRINTF("Number of data = %d", dt);    
-	    put_rn();
-	    dt = (uint16_t)(((uint32_t)dt * 1000 )/ (BLK_NO - 2));
-	    PRINTF("EEPROM Occupation = %d.%01d%%", dt / 10, dt % 10);
+        PRINTF("Number of data = %d", dt);
+        put_rn();
+        dt = (uint16_t)(((uint32_t)dt * 1000 )/ (BLK_NO - 2));
+        PRINTF("EEPROM Occupation = %d.%01d%%", dt / 10, dt % 10);
     }
     put_rn();
 }
 
-//-------------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
 //	Monitor
-//-------------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
 //  Help Massage
-void msg_hlp (void){
-    PRINTF(mon_msg);						put_rn();
-    PRINTF("d - Data logger");				put_rn();
-    PRINTF("t - Check and set RTC");		put_rn();
-    PRINTF("x - Goto HW monitor");			put_rn();
-    PRINTF("q - Return to main");			put_rn();
+void msg_hlp (void)
+{
+    PRINTF(mon_msg);
+    put_rn();
+    PRINTF("d - Data logger");
+    put_rn();
+    PRINTF("t - Check and set RTC");
+    put_rn();
+    PRINTF("x - Goto HW monitor");
+    put_rn();
+    PRINTF("q - Return to main");
+    put_rn();
 }
 
 //  Get key input data
-void get_line (char *buff, int len){
-char c;
-int idx = 0;
+void get_line (char *buff, int len)
+{
+    char c;
+    int idx = 0;
 
     for (;;) {
         c = GETC();
@@ -434,40 +475,42 @@
 
 
 // RTC related subroutines
-void chk_and_set_time(char *ptr){
-unsigned long p1;
-struct tm t;
+void chk_and_set_time(char *ptr)
+{
+    unsigned long p1;
+    struct tm t;
 
-	if (xatoi(&ptr, &p1)){
-		t.tm_year		= (uint8_t)p1 + 100;
-		PRINTF("Year:%d ",p1);
-		xatoi( &ptr, &p1 );
-		t.tm_mon		= (uint8_t)p1 - 1;
-		PRINTF("Month:%d ",p1);
-		xatoi( &ptr, &p1 );
-		t.tm_mday		= (uint8_t)p1;
-		PRINTF("Day:%d ",p1);
-		xatoi( &ptr, &p1 );
-		t.tm_hour		= (uint8_t)p1;
-		PRINTF("Hour:%d ",p1);
-		xatoi( &ptr, &p1 );
-		t.tm_min    	= (uint8_t)p1;
-		PRINTF("Min:%d ",p1);
-		xatoi( &ptr, &p1 );
-		t.tm_sec 		= (uint8_t)p1;
-		PRINTF("Sec: %d \r\n",p1);
-		xm41t62.write_rtc_std(&t);
-	}
+    if (xatoi(&ptr, &p1)) {
+        t.tm_year		= (uint8_t)p1 + 100;
+        PRINTF("Year:%d ",(int)p1);
+        xatoi( &ptr, &p1 );
+        t.tm_mon		= (uint8_t)p1 - 1;
+        PRINTF("Month:%d ",(int)p1);
+        xatoi( &ptr, &p1 );
+        t.tm_mday		= (uint8_t)p1;
+        PRINTF("Day:%d ",(int)p1);
+        xatoi( &ptr, &p1 );
+        t.tm_hour		= (uint8_t)p1;
+        PRINTF("Hour:%d ",(int)p1);
+        xatoi( &ptr, &p1 );
+        t.tm_min    	= (uint8_t)p1;
+        PRINTF("Min:%d ",(int)p1);
+        xatoi( &ptr, &p1 );
+        t.tm_sec 		= (uint8_t)p1;
+        PRINTF("Sec: %d \r\n",(int)p1);
+        xm41t62.write_rtc_std(&t);
+    }
     xm41t62.read_rtc_std(&t);
     // Show Time with several example
     // ex.1
     PRINTF("Date: %04d/%02d/%02d, %02d:%02d:%02d\r\n",
-    		t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec);
+           t.tm_year + 1900, t.tm_mon + 1,
+           t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec);
 #if 0
-time_t seconds;
-char buf[40];
-	
-	seconds = mktime(&t);
+    time_t seconds;
+    char buf[40];
+
+    seconds = mktime(&t);
     // ex.2
     strftime(buf, 40, "%x %X", localtime(&seconds));
     PRINTF("Date: %s\r\n", buf);
@@ -481,95 +524,111 @@
 }
 
 //	Data Logger / Check status and Output data
-static void data_logger(char *ptr){
-char c;
-unsigned long dt;
-uint16_t n;
-char *const Msg  = "Data Logger Mode, ?[Help]";
+static void data_logger(char *ptr)
+{
+    char c;
+    unsigned long dt;
+    uint16_t n;
+    const char * Msg  = "Data Logger Mode, ?[Help]";
 
-	PRINTF(Msg);
-	put_rn();
-	/* Get EEPROM resource */
-	dtlog_pointer_read();
-	dt = inf.log_inf.head;
-	while (1){
-		/* Get EEPROM resource */
-		dtlog_pointer_read();
-		PRINTF("DL>");
+    PRINTF("%s", Msg);
+    put_rn();
+    /* Get EEPROM resource */
+    dtlog_pointer_read();
+    dt = inf.log_inf.head;
+    while (1) {
+        /* Get EEPROM resource */
+        dtlog_pointer_read();
+        PRINTF("DL>");
         ptr = linebuf;
         get_line(ptr, buf_size);
-		switch (*ptr++) {
-			case 'a' :
-				put_r();
-				read_pointer = inf.log_inf.head;
-				n = dtlog_buf_occupation();
-				dtlog_block_read(&read_pointer, n);
-				break;
-			case 'c' :	// Clear data
-				put_r();
-				PRINTF("Delete all data?");
-				put_rn();
-				PRINTF("Enter y/n (n-cancel)");
-				put_rn();
-				c = GETC();
-				PUTC(c);
-				put_rn();
-				if (c == 'y'){
-					PRINTF("Cleared all logging data");
-					dtlog_clear_all_buff();
-				} else {
-					PRINTF("Canceled");
-				}
-				put_rn();
-				break;
-			case 'd' :	// d <pointer> [<count>] - Dump buffer
-				put_r();
-				if (xatoi(&ptr, &dt)){	read_pointer = (uint16_t)dt;
-				} else {				read_pointer = inf.log_inf.head; }	
-				if (xatoi(&ptr, &dt)){	n = (uint8_t)dt;				
-				} else {				n = BLK_SIZE; }
-				if (read_pointer == 0){ read_pointer = 1;}
-				dtlog_block_read(&read_pointer, n);
-				break;
-			case 0x0d :	// CR
-				put_r();
-				dtlog_block_read(&read_pointer, BLK_SIZE);
-				break;
-			case 'b' :	// Back
-				put_r();
-				read_pointer -= (BLK_SIZE * 2);
-				if (read_pointer <= 0){ read_pointer = 1;}
-				dtlog_block_read(&read_pointer, n);
-				break;
-			case 'n' :
-			case 's' :	// Status
-				put_r();
-				dtlog_num_of_block();
-				break;
-			case 'q' :	// exit
-				linebuf[0] = 0;
-				return;
-			case '?' :
-				put_r();
-			    PRINTF("d - <pointer> [<count>] Dump one block data");	put_rn();
-			    PRINTF("a - Dump all log data");		put_rn();
-			    PRINTF("c - Clear log data");			put_rn();
-			    PRINTF("s - Logger status");			put_rn();
-			    PRINTF("q - Exit DL mode");				put_rn();  
-				break;
-			default:
-				PUTC('?');
-				put_rn();
-				break;
-		}
-	}
+        switch (*ptr++) {
+            case 'a' :
+                put_r();
+                read_pointer = inf.log_inf.head;
+                n = dtlog_buf_occupation();
+                dtlog_block_read(&read_pointer, n);
+                break;
+            case 'c' :	// Clear data
+                put_r();
+                PRINTF("Delete all data?");
+                put_rn();
+                PRINTF("Enter y/n (n-cancel)");
+                put_rn();
+                c = GETC();
+                PUTC(c);
+                put_rn();
+                if (c == 'y') {
+                    PRINTF("Cleared all logging data");
+                    dtlog_clear_all_buff();
+                } else {
+                    PRINTF("Canceled");
+                }
+                put_rn();
+                break;
+            case 'd' :	// d <pointer> [<count>] - Dump buffer
+                put_r();
+                if (xatoi(&ptr, &dt)) {
+                    read_pointer = (uint16_t)dt;
+                } else {
+                    read_pointer = inf.log_inf.head;
+                }
+                if (xatoi(&ptr, &dt)) {
+                    n = (uint8_t)dt;
+                } else {
+                    n = BLK_SIZE;
+                }
+                if (read_pointer == 0) {
+                    read_pointer = 1;
+                }
+                dtlog_block_read(&read_pointer, n);
+                break;
+            case 0x0d :	// CR
+                put_r();
+                dtlog_block_read(&read_pointer, BLK_SIZE);
+                break;
+            case 'b' :	// Back
+                put_r();
+                read_pointer -= (BLK_SIZE * 2);
+                if (read_pointer <= 0) {
+                    read_pointer = 1;
+                }
+                dtlog_block_read(&read_pointer, n);
+                break;
+            case 'n' :
+            case 's' :	// Status
+                put_r();
+                dtlog_num_of_block();
+                break;
+            case 'q' :	// exit
+                linebuf[0] = 0;
+                return;
+            case '?' :
+                put_r();
+                PRINTF("d - <pointer> [<count>] Dump one block data");
+                put_rn();
+                PRINTF("a - Dump all log data");
+                put_rn();
+                PRINTF("c - Clear log data");
+                put_rn();
+                PRINTF("s - Logger status");
+                put_rn();
+                PRINTF("q - Exit DL mode");
+                put_rn();
+                break;
+            default:
+                PUTC('?');
+                put_rn();
+                break;
+        }
+    }
 }
 
-// ---------- Program starts here! ---------------------------------------------------------------
-int mon(void) {
-char *ptr;
+// ---------- Program starts here! ---------------------------------------------
+int mon(void)
+{
+    char *ptr;
 
-    BAUD(9600);
     put_rn();
     put_rn();
     PRINTF("%s [Help:'?' key]", mon_msg);
@@ -580,41 +639,43 @@
         ptr = linebuf;
         get_line(ptr, sizeof(linebuf));
         switch (*ptr++) {
-    //---------------------------------------------------------------------------------
-    //  check and set RTC
-    //---------------------------------------------------------------------------------
-        case 't' :
-        	put_r(); 
-            chk_and_set_time(ptr);               
-            break;
-    //---------------------------------------------------------------------------------
-    //  check EEPROM status
-    //---------------------------------------------------------------------------------
-        case 'd' :
-        	put_r(); 
-            data_logger(ptr);               
-            break;
-    //---------------------------------------------------------------------------------
-    //  help
-    //---------------------------------------------------------------------------------
-        case '?' :
-        	put_r(); 
-            msg_hlp();                 
-            break;
-    //---------------------------------------------------------------------------------
-    //  Go to special command
-    //---------------------------------------------------------------------------------
-        case 'x' :    // 
-            mon_hw();
-            PRINTF("->Came back monitor\r\n");            
-            break;
-    //---------------------------------------------------------------------------------
-    //  Go back to main()
-    //---------------------------------------------------------------------------------
-        case 'q' :        // Quit
-            PRINTF("\rReturn to main\r\n");
-            PRINTF("cannot control anymore from here\r\n");
-            return 0;
+            //------------------------------------------------------------------
+            //  check and set RTC
+            //------------------------------------------------------------------
+            case 't' :
+                put_r();
+                chk_and_set_time(ptr);
+                break;
+            //------------------------------------------------------------------
+            //  check EEPROM status
+            //------------------------------------------------------------------
+            case 'd' :
+                put_r();
+                data_logger(ptr);
+                break;
+            //------------------------------------------------------------------
+            //  help
+            //------------------------------------------------------------------
+            case '?' :
+                put_r();
+                msg_hlp();
+                break;
+            //------------------------------------------------------------------
+            //  Go to special command
+            //------------------------------------------------------------------
+            case 'x' :    //
+                PRINTF("->ROM & RAM size limitation. ");
+                PRINTF("-> Cannot impliment the function\r\n");
+                //mon_hw();
+                PRINTF("->Came back monitor\r\n");
+                break;
+            //------------------------------------------------------------------
+            //  Go back to main()
+            //------------------------------------------------------------------
+            case 'q' :        // Quit
+                PRINTF("\rReturn to main\r\n");
+                PRINTF("cannot control anymore from here\r\n");
+                return 0;
         }
     }
 }
diff -r f81a6c9e5f7b -r b3a27f681171 mon_hw.cpp
--- a/mon_hw.cpp	Thu Jul 03 23:07:13 2014 +0000
+++ b/mon_hw.cpp	Sat Aug 08 07:01:19 2020 +0000
@@ -1,19 +1,17 @@
+#if 0
+//??????????????????????????????????????????????????????????????????????????????
+// Due to ROM & RAM size limitation
+//??????????????????????????????????????????????????????????????????????????????
+
 /*
  * mbed Application program for the mbed LPC1114FN28
  * Monitor program Ver.2 for only LPC1114FN28 
  *
- *  Copyright (c) 2010-2014 Kenji Arai / JH1PJL
- *  http://www.page.sannet.ne.jp/kenjia/index.html
- *  http://mbed.org/users/kenjiArai/
- *      Created:  May  	    15th, 2010
- *		Spareted: June		25th, 2014		mon() & mon_hw()
- *      Revised: July       3rd, 2014
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
- * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * Copyright (c) 2014,'20 Kenji Arai / JH1PJL
+ *  http://www7b.biglobe.ne.jp/~kenjia/
+ *  https://os.mbed.com/users/kenjiArai/
+ *      Created: June       1st, 2014
+ *      Revised: August     8th, 2020
  */
 /*
  * Function
@@ -26,11 +24,11 @@
 #include "mbed.h"
 #include "AT24C1024.h"		// Own lib. / EEPROM control
 #include "mon_hw_config.h"
+#include "redirect_stdio.h"
 
 //  Object ----------------------------------------------------------------------------------------
-extern Serial pcx(dp16,dp15);
-extern I2C    xxi2c(dp5,dp27);			// SDA, SCL
-extern AT24C1024   xat24c1024(xxi2c);	// Atmel 1Mbit EE-PROM
+extern I2C    xxi2c;			// SDA, SCL
+extern AT24C1024   xat24c1024;	// Atmel 1Mbit EE-PROM
 
 //  Definition ------------------------------------------------------------------------------------
 // Define clocks
@@ -53,11 +51,10 @@
 #define IO_ALL				0
 #define IO_I2C				1
 
-#define BAUD(x)         	pcx.baud(x)
-#define GETC(x)         	pcx.getc(x)
-#define PUTC(x)				pcx.putc(x)
-#define PRINTF(...)     	pcx.printf(__VA_ARGS__)
-#define READABLE(x)     	pcx.readable(x)
+#define GETC(x)         	getc(x)
+#define PUTC(x)				putc(x)
+#define PRINTF(...)     	printf(__VA_ARGS__)
+#define READABLE(x)     	readable(x)
 
 typedef struct {
     unsigned long mstr;
@@ -95,11 +92,11 @@
     { 0x50000000, 0x501fffff }             // IO area
 };
 
-static char *const rmsg0 = "FLASH    ";
-static char *const rmsg1 = "SRAM     ";
-static char *const rmsg2 = "BOOT ROM ";
-static char *const rmsg3 = "IO       ";
-static char *const rmsg4 = "IO       ";
+static const char *const rmsg0 = "FLASH    ";
+static const char *const rmsg1 = "SRAM     ";
+static const char *const rmsg2 = "BOOT ROM ";
+static const char *const rmsg3 = "IO       ";
+static const char *const rmsg4 = "IO       ";
 #endif  // USE_MEM
 
 #if USE_EEP
@@ -113,7 +110,7 @@
 #endif
 
 //  ROM / Constant data ---------------------------------------------------------------------------
-static char *const mon_msg_hw = "HW monitor only for mbed LPC1114FN28";
+static const char *const mon_msg_hw = "HW monitor only for mbed LPC1114FN28";
 
 //  Function prototypes ---------------------------------------------------------------------------
 extern char linebuf[];
@@ -183,25 +180,25 @@
 	put_rn();
 }
 
-char *const imsg2 = "-->Control Reg.";
-char *const imsg3 = "-->Status Reg.";
-char *const imsg4 = "-->Data Reg.";
-//static char *const imsg5 = "-->Baud rate Reg.";
-//static char *const imsg6 = "-->Own address Reg.";
-char *const imsg7 = "-->Clock control Reg.";
-//static char *const imsg8 = "-->TRISE Reg.";
+const char *const imsg2 = "-->Control Reg.";
+const char *const imsg3 = "-->Status Reg.";
+const char *const imsg4 = "-->Data Reg.";
+//static const char *const imsg5 = "-->Baud rate Reg.";
+//static const char *const imsg6 = "-->Own address Reg.";
+const char   *const imsg7 = "-->Clock control Reg.";
+//static const char *const imsg8 = "-->TRISE Reg.";
 
-static char *const io_port_name0 = "PIO0_";
-static char *const io_port_name1 = "PIO1_";
-static char *const iomsg0 = "Func->select ";
-static char *const iomsg1 = "IO";
-static char *const iomsg2 = "Reserved";
-static char *const iomsg30 = "B0_MAT";
-static char *const iomsg31 = "B1_MAT";
-static char *const iomsg4 = "Std/F-md I2C";
-static char *const iomsg5 = "func. R";
-static char *const iomsg6 = "D-Mode";
-static char *const iomsg7 = "A-Mode";
+static const char *const io_port_name0 = "PIO0_";
+static const char *const io_port_name1 = "PIO1_";
+static const char *const iomsg0 = "Func->select ";
+static const char *const iomsg1 = "IO";
+static const char *const iomsg2 = "Reserved";
+static const char *const iomsg30 = "B0_MAT";
+static const char *const iomsg31 = "B1_MAT";
+static const char *const iomsg4 = "Std/F-md I2C";
+static const char *const iomsg5 = "func. R";
+static const char *const iomsg6 = "D-Mode";
+static const char *const iomsg7 = "A-Mode";
 
 //  Show 16bit register contents
 void reg_print(uint16_t size, uint16_t reg){
@@ -802,22 +799,22 @@
         put_rn();
     }   
     m2 = (m1 >> 20) & 0x0f;
-    PRINTF("Variant:%x", m2);
+    PRINTF("Variant:%x", (int)m2);
     put_rn();
     m2 = m1 & 0x7;
-    PRINTF("Revision:%x", m2);
+    PRINTF("Revision:%x", (int)m2);
     put_rn();
 }
 
 //  Calculate CPU System Clock Frequency /refrence: system_LPCxx.c
-static char *const fmsg0 = "Internal RC Oscillator";
-static char *const fmsg1 = "Xtal Osc Clock";
-static char *const fmsg2 = "Watch dog Osc Clock";
-static char *const fmsg3 = "with PLL";
-static char *const fmsg4 = "System Clock =";
-static char *const fmsg5 = "PLL Post divider ratio =";
-static char *const fmsg6 = "feedback devider =";
-static char *const fmsg7 = "NO Clock ?!";
+static const char *const fmsg0 = "Internal RC Oscillator";
+static const char *const fmsg1 = "Xtal Osc Clock";
+static const char *const fmsg2 = "Watch dog Osc Clock";
+static const char *const fmsg3 = "with PLL";
+static const char *const fmsg4 = "System Clock =";
+static const char *const fmsg5 = "PLL Post divider ratio =";
+static const char *const fmsg6 = "feedback devider =";
+static const char *const fmsg7 = "NO Clock ?!";
 
 void get_freq_w_print (void){	// Get Core Clock Frequency
 uint32_t wdt_osc = 0, pll_fct0 = 0, pll_fct1 = 0;
@@ -882,7 +879,7 @@
                 pll_fct0 = (LPC_SYSCON->SYSPLLCTRL & 0x01F) + 1;
                 pll_fct1 = (LPC_SYSCON->SYSPLLCTRL & 0x060) >> 5UL;
                 SystemCoreClock = __IRC_OSC_CLK *  pll_fct0;
-                PRINTF("Use Internal RC = %dHz", __IRC_OSC_CLK);
+                PRINTF("Use Internal RC = %dHz", (int)__IRC_OSC_CLK);
                 put_rn();
                 PRINTF("%s %s = %dHz", fmsg0, fmsg3, SystemCoreClock);
                 put_rn();
@@ -897,7 +894,7 @@
                 pll_fct0 = (LPC_SYSCON->SYSPLLCTRL & 0x01F) + 1;
                 pll_fct1 = (LPC_SYSCON->SYSPLLCTRL & 0x060) >> 5UL;
                 SystemCoreClock = __SYS_OSC_CLK * pll_fct0;
-                PRINTF("Use XTAL = %dHz", __XTAL);
+                PRINTF("Use XTAL = %dHz", (int)__XTAL);
                 put_rn();
                 PRINTF("%s %s = %dHz", fmsg1, fmsg3, SystemCoreClock);
                 put_rn();
@@ -1382,8 +1379,9 @@
 ){
 uint32_t i;
 uint8_t	eep[16];
-
-	PRINTF("%08lx ", addr);			// address
+	//?????????????????????????????????????????????????????????????????????????
+	#warning "?????"
+	PRINTF("%08x ", (int)addr);		// address
 	for (i = 0; i < len; i++) {		// Hexdecimal dump
 		eep[i] = xat24c1024.read(addr++);
 		PRINTF(" %02x", eep[i]);
@@ -1509,7 +1507,7 @@
 				if (xatoi(&ptr, &p2)) { // 2nd parameter is given
 					do {
 						xat24c1024.write((uint16_t)p1, (uint8_t)p2);
-						wait(0.01);
+						ThisThread::sleep_for(10ms);
 						dt = xat24c1024.read((uint16_t)p1);
 						if (dt != (uint8_t)p2){
 							PRINTF("?\r\n");
@@ -1519,7 +1517,7 @@
 					break;
 				}
 				for (;;) {// 2nd parameter is not given (interactive mode)
-					PRINTF("%08x 0x%02x-", p1, *(BYTE*)p1);
+					PRINTF("%08x 0x%02x-", (int)p1, *(BYTE*)p1);
 					ptr = linebuf;
 	        		get_line(ptr, buf_size);
 					if (*ptr == '.'){ break;}
@@ -1527,7 +1525,7 @@
 					if ((BYTE)*ptr >= ' ') {
 						if (!xatoi(&ptr, &p2)){ continue;}
 						xat24c1024.write((uint16_t)p1, (uint8_t)p2);
-						wait(0.01);
+						ThisThread::sleep_for(10ms);
 						dt = xat24c1024.read((uint16_t)p1);
 						if (dt != (uint8_t)p2){
 							PRINTF("?\r\n");
@@ -1539,7 +1537,9 @@
 			case 's' :
 				PRINTF("AT24C1024B");
 				put_rn();
-				PRINTF("EEPROM  0x%08lx to 0x%08lx", eepmem_range[0], eepmem_range[1]);
+	//?????????????????????????????????????????????????????????????????????????
+	#warning "?????"
+				PRINTF("EEPROM  0x%08lx to 0x%08lx", (int)eepmem_range[0], (int)eepmem_range[1]);
 				put_rn();
 				break;
 			case '?' :
@@ -1804,3 +1804,5 @@
         }
     }
 }
+
+#endif
\ No newline at end of file
diff -r f81a6c9e5f7b -r b3a27f681171 mon_hw_config.h
--- a/mon_hw_config.h	Thu Jul 03 23:07:13 2014 +0000
+++ b/mon_hw_config.h	Sat Aug 08 07:01:19 2020 +0000
@@ -1,17 +1,16 @@
+#if 0
+//??????????????????????????????????????????????????????????????????????????????
+// Due to ROM & RAM size limitation
+//??????????????????????????????????????????????????????????????????????????????
+
 /*
  * mbed Headder file for the mbed LPC1114FN28 
  *
- *  Copyright (c) 2014 Kenji Arai / JH1PJL
- *  http://www.page.sannet.ne.jp/kenjia/index.html
- *  http://mbed.org/users/kenjiArai/
+ * Copyright (c) 2014,'20 Kenji Arai / JH1PJL
+ *  http://www7b.biglobe.ne.jp/~kenjia/
+ *  https://os.mbed.com/users/kenjiArai/
  *      Created: June       1st, 2014
- *      Revised: July       3rd, 2014
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
- * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *      Revised: August     8th, 2020
  */
 
 #ifndef _MON_HW_CONF_H_
@@ -28,3 +27,5 @@
 #define     USE_EEP             1
 
 #endif  // _MON_HW_CONF_H_
+
+#endif
\ No newline at end of file
diff -r f81a6c9e5f7b -r b3a27f681171 redirect_stdio/redirect_stdio.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/redirect_stdio/redirect_stdio.cpp	Sat Aug 08 07:01:19 2020 +0000
@@ -0,0 +1,21 @@
+/*
+ * mbed Application program
+ *      Redirect Standard Input/Output
+ *
+ * Copyright (c) 2020 Kenji Arai / JH1PJL
+ *  http://www7b.biglobe.ne.jp/~kenjia/
+ *  https://os.mbed.com/users/kenjiArai/
+ *      Created: August     7th, 2020
+ *      Revised: August     7th, 2020
+ */
+
+#include "mbed.h"
+
+// Create a BufferedSerial object to be used by the system I/O retarget code
+BufferedSerial pc(USBTX, USBRX, 9600);
+
+//  the system I/O retarget
+FileHandle *mbed::mbed_override_console(int fd)
+{
+    return &pc;
+}
diff -r f81a6c9e5f7b -r b3a27f681171 redirect_stdio/redirect_stdio.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/redirect_stdio/redirect_stdio.h	Sat Aug 08 07:01:19 2020 +0000
@@ -0,0 +1,36 @@
+/*
+ * mbed Application program
+ *      Redirect Standard Input/Output
+ *
+ * Copyright (c) 2020 Kenji Arai / JH1PJL
+ *  http://www7b.biglobe.ne.jp/~kenjia/
+ *  https://os.mbed.com/users/kenjiArai/
+ *      Created: August     7th, 2020
+ *      Revised: August     7th, 2020
+ */
+
+extern BufferedSerial pc;
+
+FileHandle *mbed::mbed_override_console(int fd);
+
+inline uint8_t readable(void)
+{
+    return pc.readable();
+}
+
+inline void putc(uint8_t c)
+{
+    char dt = c;
+    pc.write(&dt, 1);
+}
+
+inline uint8_t getc(void)
+{
+    int c = getchar();
+    return (uint8_t)c;
+}
+
+inline void puts_wo_cr(char *bf, uint32_t len)
+{
+    pc.write(bf, len);
+}