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:
- 2017-07-22
- Revision:
- 8:ac09e00d2903
- Parent:
- 7:3b3317e5f14e
- Child:
- 9:3ccc730c6f1b
File content as of revision 8:ac09e00d2903:
//---------------------------------------------------------------- // Demo program for LCD AQM1602XA-RN-GBW using I2C interface // Pullup resistors for SDA and SCL: 10 kΩ // Use mbed Rev.129 for Nucleo-F401/446/746 and DISCO-F746 // // mbed Rev.130 以降で起こる,割り込み処理での動作不良を修正した // Aqm1602 クラスを使用 // DISCO-F746 では動作不良は修正できないようだ // // 2017/07/22, Copyright (c) 2017 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 Ticker timer_; #ifdef STM_USER_BUTTON DigitalIn uButton_(USER_BUTTON); #endif void TimerIsr() { static int k = 0; lcd_.WriteValueXY("%5.1f", (float)(k++/10.0f), 0, 1); } void WaitButton() { #ifdef STM_USER_BUTTON lcd_.WriteStringXY("Push blue button", 0, 1); #ifdef STM32F7 while (uButton_ == 0) {} #else while (uButton_ == 1) {} #endif #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) {} }