I2C 接続の LCD AQM1602XA-RN-GBW 用のライブラリの使用例. Demo program of library for LCD 1602XA-RN-GBW connected using I2C interface.

Dependencies:   mbed UIT_AQM1602

Revision:
5:d63f1c2d8027
Parent:
4:291e82d910d0
Child:
6:3dcecef3aa21
--- a/main.cpp	Thu Jan 14 05:57:02 2016 +0000
+++ b/main.cpp	Fri Apr 01 04:27:40 2016 +0000
@@ -1,7 +1,7 @@
 //------------------------------------------------------------
 // Test program for LCD AQM1602XA-RN-GBW using I2C interface
 //      Pullup resistors for SDA and SCL: 10 kΩ
-// 2016/01/14, Copyright (c) 2015 MIKAMI, Naoki
+// 2016/04/01, Copyright (c) 2016 MIKAMI, Naoki
 //------------------------------------------------------------
 
 #include "AQM1602.hpp"
@@ -26,27 +26,37 @@
 // Following: for LPC1768
 //Aqm1602 lcd_(p9, p10);    // OK
 
+#if defined(STM32F4) || defined(STM32L0) || defined(__STM32F3xx_H)
+#define NUCLEO_F4_L0_F3
+#endif
+
 Ticker timer_;
-#if defined(STM32F4) || defined(STM32L0) || defined(__STM32F3xx_H)
+#ifdef NUCLEO_F4_L0_F3
 DigitalIn uButton_(USER_BUTTON);
 #endif
 
 // Display 0, 1, 2, .....
+// Each version is available
 void TimerIsr()
 {
     static int k = 0;
-    char str[10];
-    sprintf(str, "%d", k++);
-    lcd_.WriteStringXY(str, 0, 1);
+
+    // Using WriteValueXY() and float version
+    lcd_.WriteValueXY("%5.1f", (float)(k++/10.0f), 0, 1);
+/*
+    // Using WriteValue() and int version
+    lcd_.SetXY(0, 1);
+    lcd_.WriteValue("%d", k++/10);
+*/
 }
 
 void WaitButton()
 {
+#ifdef NUCLEO_F4_L0_F3
     lcd_.WriteStringXY("Push blue button", 0, 1);
-#if defined(STM32F4) || defined(STM32L0) || defined(__STM32F3xx_H)
     while (uButton_ == 1) {}
 #else
-    wait(2);
+    wait(1);
 #endif
     lcd_.ClearLine(1);
     wait(0.5);
@@ -67,7 +77,8 @@
     string str = "AQM1602";
     lcd_.WriteStringXY(str+"XA-RN-GBW", 0, 0);
     TimerIsr();
-    timer_.attach(&TimerIsr, 1);
+    timer_.attach(&TimerIsr, 0.1f);
 
     while (true) {}
 }
+