I2C 接続の LCD AQM1602XA-RN-GBW 用のライブラリの使用例. Demo program of library for LCD 1602XA-RN-GBW connected using I2C interface.
Dependencies: mbed UIT_AQM1602
main.cpp
- Committer:
- MikamiUitOpen
- Date:
- 2016-11-22
- Revision:
- 6:3dcecef3aa21
- Parent:
- 5:d63f1c2d8027
- Child:
- 7:3b3317e5f14e
File content as of revision 6:3dcecef3aa21:
//------------------------------------------------------------ // Test program for LCD AQM1602XA-RN-GBW using I2C interface // Pullup resistors for SDA and SCL: 10 kΩ // 2016/11/22, Copyright (c) 2016 MIKAMI, Naoki //------------------------------------------------------------ #include "AQM1602.hpp" using namespace Mikami; Aqm1602 lcd_; // Default, OK //Aqm1602 lcd_(D14, D15); // OK //Aqm1602 lcd_(D14, D15, 200000); // OK //Aqm1602 lcd_(D14, D15, 200000, true, true); // OK //Aqm1602 lcd_(PB_3, PB_10); // OK //Aqm1602 lcd_(PC_9, PA_8); // OK //Aqm1602 lcd_(PB_4, PA_8); // OK //I2C i2cObj_(D14, D15); //Aqm1602 lcd_(i2cObj_); // OK // Following: for LPC1114 //Aqm1602 lcd_(dp5, dp27); // OK //I2C i2cObj_(dp5, dp27); //Aqm1602 lcd_(i2cObj_); // OK // Following: for LPC1768 //Aqm1602 lcd_(p9, p10); // OK #if defined(STM32F4) || defined(STM32L0) || defined(__STM32F3xx_H) #define NUCLEO_F4_L0_F3 #endif Ticker timer_; #ifdef NUCLEO_F4_L0_F3 DigitalIn uButton_(USER_BUTTON); #endif // Display 0, 1, 2, ..... // Each version is available void TimerIsr() { static int k = 0; // 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); while (uButton_ == 1) {} #else wait(1); #endif lcd_.ClearLine(1); wait(0.5); } int main() { if (lcd_.IsConnected()) printf("\r\nConnected\r\n"); else printf("\r\nDisconnected\r\n"); lcd_.Clear(); lcd_.WriteString("Hello!"); WaitButton(); // Waiting, push blue user button lcd_.WriteStringXY("0123456789ABCDEF", 0, 0); WaitButton(); // Waiting, push blue user button lcd_.ClearLine(0); WaitButton(); // Waiting, push blue user button string str = "AQM1602"; lcd_.WriteStringXY(str+"XA-RN-GBW", 0, 0); TimerIsr(); timer_.attach(&TimerIsr, 0.1f); while (true) {} }