![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
I2C 接続の LCD AQM1602XA-RN-GBW 用のライブラリの使用例. Demo program of library for LCD 1602XA-RN-GBW connected using I2C interface.
Dependencies: mbed UIT_AQM1602
main.cpp@6:3dcecef3aa21, 2016-11-22 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Tue Nov 22 02:05:59 2016 +0000
- Revision:
- 6:3dcecef3aa21
- Parent:
- 5:d63f1c2d8027
- Child:
- 7:3b3317e5f14e
7
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 0:e1b05c7eb023 | 1 | //------------------------------------------------------------ |
MikamiUitOpen | 0:e1b05c7eb023 | 2 | // Test program for LCD AQM1602XA-RN-GBW using I2C interface |
MikamiUitOpen | 0:e1b05c7eb023 | 3 | // Pullup resistors for SDA and SCL: 10 kΩ |
MikamiUitOpen | 6:3dcecef3aa21 | 4 | // 2016/11/22, Copyright (c) 2016 MIKAMI, Naoki |
MikamiUitOpen | 0:e1b05c7eb023 | 5 | //------------------------------------------------------------ |
MikamiUitOpen | 0:e1b05c7eb023 | 6 | |
MikamiUitOpen | 0:e1b05c7eb023 | 7 | #include "AQM1602.hpp" |
MikamiUitOpen | 1:6c838e71e330 | 8 | |
MikamiUitOpen | 0:e1b05c7eb023 | 9 | using namespace Mikami; |
MikamiUitOpen | 0:e1b05c7eb023 | 10 | |
MikamiUitOpen | 4:291e82d910d0 | 11 | Aqm1602 lcd_; // Default, OK |
MikamiUitOpen | 4:291e82d910d0 | 12 | //Aqm1602 lcd_(D14, D15); // OK |
MikamiUitOpen | 4:291e82d910d0 | 13 | //Aqm1602 lcd_(D14, D15, 200000); // OK |
MikamiUitOpen | 4:291e82d910d0 | 14 | //Aqm1602 lcd_(D14, D15, 200000, true, true); // OK |
MikamiUitOpen | 4:291e82d910d0 | 15 | //Aqm1602 lcd_(PB_3, PB_10); // OK |
MikamiUitOpen | 4:291e82d910d0 | 16 | //Aqm1602 lcd_(PC_9, PA_8); // OK |
MikamiUitOpen | 4:291e82d910d0 | 17 | //Aqm1602 lcd_(PB_4, PA_8); // OK |
MikamiUitOpen | 4:291e82d910d0 | 18 | //I2C i2cObj_(D14, D15); |
MikamiUitOpen | 4:291e82d910d0 | 19 | //Aqm1602 lcd_(i2cObj_); // OK |
MikamiUitOpen | 4:291e82d910d0 | 20 | |
MikamiUitOpen | 4:291e82d910d0 | 21 | // Following: for LPC1114 |
MikamiUitOpen | 4:291e82d910d0 | 22 | //Aqm1602 lcd_(dp5, dp27); // OK |
MikamiUitOpen | 4:291e82d910d0 | 23 | //I2C i2cObj_(dp5, dp27); |
MikamiUitOpen | 4:291e82d910d0 | 24 | //Aqm1602 lcd_(i2cObj_); // OK |
MikamiUitOpen | 4:291e82d910d0 | 25 | |
MikamiUitOpen | 4:291e82d910d0 | 26 | // Following: for LPC1768 |
MikamiUitOpen | 4:291e82d910d0 | 27 | //Aqm1602 lcd_(p9, p10); // OK |
MikamiUitOpen | 0:e1b05c7eb023 | 28 | |
MikamiUitOpen | 5:d63f1c2d8027 | 29 | #if defined(STM32F4) || defined(STM32L0) || defined(__STM32F3xx_H) |
MikamiUitOpen | 5:d63f1c2d8027 | 30 | #define NUCLEO_F4_L0_F3 |
MikamiUitOpen | 5:d63f1c2d8027 | 31 | #endif |
MikamiUitOpen | 5:d63f1c2d8027 | 32 | |
MikamiUitOpen | 0:e1b05c7eb023 | 33 | Ticker timer_; |
MikamiUitOpen | 5:d63f1c2d8027 | 34 | #ifdef NUCLEO_F4_L0_F3 |
MikamiUitOpen | 0:e1b05c7eb023 | 35 | DigitalIn uButton_(USER_BUTTON); |
MikamiUitOpen | 4:291e82d910d0 | 36 | #endif |
MikamiUitOpen | 0:e1b05c7eb023 | 37 | |
MikamiUitOpen | 0:e1b05c7eb023 | 38 | // Display 0, 1, 2, ..... |
MikamiUitOpen | 5:d63f1c2d8027 | 39 | // Each version is available |
MikamiUitOpen | 0:e1b05c7eb023 | 40 | void TimerIsr() |
MikamiUitOpen | 0:e1b05c7eb023 | 41 | { |
MikamiUitOpen | 0:e1b05c7eb023 | 42 | static int k = 0; |
MikamiUitOpen | 5:d63f1c2d8027 | 43 | |
MikamiUitOpen | 5:d63f1c2d8027 | 44 | // Using WriteValueXY() and float version |
MikamiUitOpen | 5:d63f1c2d8027 | 45 | lcd_.WriteValueXY("%5.1f", (float)(k++/10.0f), 0, 1); |
MikamiUitOpen | 5:d63f1c2d8027 | 46 | /* |
MikamiUitOpen | 5:d63f1c2d8027 | 47 | // Using WriteValue() and int version |
MikamiUitOpen | 5:d63f1c2d8027 | 48 | lcd_.SetXY(0, 1); |
MikamiUitOpen | 5:d63f1c2d8027 | 49 | lcd_.WriteValue("%d", k++/10); |
MikamiUitOpen | 5:d63f1c2d8027 | 50 | */ |
MikamiUitOpen | 0:e1b05c7eb023 | 51 | } |
MikamiUitOpen | 0:e1b05c7eb023 | 52 | |
MikamiUitOpen | 0:e1b05c7eb023 | 53 | void WaitButton() |
MikamiUitOpen | 0:e1b05c7eb023 | 54 | { |
MikamiUitOpen | 5:d63f1c2d8027 | 55 | #ifdef NUCLEO_F4_L0_F3 |
MikamiUitOpen | 1:6c838e71e330 | 56 | lcd_.WriteStringXY("Push blue button", 0, 1); |
MikamiUitOpen | 0:e1b05c7eb023 | 57 | while (uButton_ == 1) {} |
MikamiUitOpen | 4:291e82d910d0 | 58 | #else |
MikamiUitOpen | 5:d63f1c2d8027 | 59 | wait(1); |
MikamiUitOpen | 4:291e82d910d0 | 60 | #endif |
MikamiUitOpen | 1:6c838e71e330 | 61 | lcd_.ClearLine(1); |
MikamiUitOpen | 1:6c838e71e330 | 62 | wait(0.5); |
MikamiUitOpen | 0:e1b05c7eb023 | 63 | } |
MikamiUitOpen | 0:e1b05c7eb023 | 64 | |
MikamiUitOpen | 0:e1b05c7eb023 | 65 | int main() |
MikamiUitOpen | 0:e1b05c7eb023 | 66 | { |
MikamiUitOpen | 6:3dcecef3aa21 | 67 | if (lcd_.IsConnected()) printf("\r\nConnected\r\n"); |
MikamiUitOpen | 6:3dcecef3aa21 | 68 | else printf("\r\nDisconnected\r\n"); |
MikamiUitOpen | 3:fe2f8abf2120 | 69 | |
MikamiUitOpen | 0:e1b05c7eb023 | 70 | lcd_.Clear(); |
MikamiUitOpen | 0:e1b05c7eb023 | 71 | lcd_.WriteString("Hello!"); |
MikamiUitOpen | 0:e1b05c7eb023 | 72 | WaitButton(); // Waiting, push blue user button |
MikamiUitOpen | 0:e1b05c7eb023 | 73 | lcd_.WriteStringXY("0123456789ABCDEF", 0, 0); |
MikamiUitOpen | 0:e1b05c7eb023 | 74 | WaitButton(); // Waiting, push blue user button |
MikamiUitOpen | 0:e1b05c7eb023 | 75 | lcd_.ClearLine(0); |
MikamiUitOpen | 0:e1b05c7eb023 | 76 | WaitButton(); // Waiting, push blue user button |
MikamiUitOpen | 1:6c838e71e330 | 77 | string str = "AQM1602"; |
MikamiUitOpen | 1:6c838e71e330 | 78 | lcd_.WriteStringXY(str+"XA-RN-GBW", 0, 0); |
MikamiUitOpen | 0:e1b05c7eb023 | 79 | TimerIsr(); |
MikamiUitOpen | 5:d63f1c2d8027 | 80 | timer_.attach(&TimerIsr, 0.1f); |
MikamiUitOpen | 0:e1b05c7eb023 | 81 | |
MikamiUitOpen | 0:e1b05c7eb023 | 82 | while (true) {} |
MikamiUitOpen | 0:e1b05c7eb023 | 83 | } |
MikamiUitOpen | 5:d63f1c2d8027 | 84 |