![](/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@2:6e609a28fa80, 2015-07-06 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Mon Jul 06 09:15:33 2015 +0000
- Revision:
- 2:6e609a28fa80
- Parent:
- 1:6c838e71e330
- Child:
- 3:fe2f8abf2120
3
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 | 1:6c838e71e330 | 4 | // 2015/06/09, Copyright (c) 2015 MIKAMI, Naoki |
MikamiUitOpen | 0:e1b05c7eb023 | 5 | //------------------------------------------------------------ |
MikamiUitOpen | 0:e1b05c7eb023 | 6 | |
MikamiUitOpen | 0:e1b05c7eb023 | 7 | #include "mbed.h" |
MikamiUitOpen | 0:e1b05c7eb023 | 8 | #include "AQM1602.hpp" |
MikamiUitOpen | 1:6c838e71e330 | 9 | |
MikamiUitOpen | 0:e1b05c7eb023 | 10 | using namespace Mikami; |
MikamiUitOpen | 0:e1b05c7eb023 | 11 | |
MikamiUitOpen | 0:e1b05c7eb023 | 12 | Aqm1602 lcd_; // Default, OK |
MikamiUitOpen | 0:e1b05c7eb023 | 13 | //Aqm1602 lcd_(D14, D15); // OK |
MikamiUitOpen | 0:e1b05c7eb023 | 14 | //Aqm1602 lcd_(D14, D15, 200000); // OK |
MikamiUitOpen | 0:e1b05c7eb023 | 15 | //Aqm1602 lcd_(D14, D15, 200000, true, true); // OK |
MikamiUitOpen | 0:e1b05c7eb023 | 16 | //Aqm1602 lcd_(PB_3, PB_10); // OK |
MikamiUitOpen | 0:e1b05c7eb023 | 17 | //Aqm1602 lcd_(PC_9, PA_8); // OK |
MikamiUitOpen | 0:e1b05c7eb023 | 18 | //Aqm1602 lcd_(PB_4, PA_8); // OK |
MikamiUitOpen | 0:e1b05c7eb023 | 19 | |
MikamiUitOpen | 0:e1b05c7eb023 | 20 | Ticker timer_; |
MikamiUitOpen | 0:e1b05c7eb023 | 21 | DigitalIn uButton_(USER_BUTTON); |
MikamiUitOpen | 0:e1b05c7eb023 | 22 | |
MikamiUitOpen | 0:e1b05c7eb023 | 23 | // Display 0, 1, 2, ..... |
MikamiUitOpen | 0:e1b05c7eb023 | 24 | void TimerIsr() |
MikamiUitOpen | 0:e1b05c7eb023 | 25 | { |
MikamiUitOpen | 0:e1b05c7eb023 | 26 | static int k = 0; |
MikamiUitOpen | 0:e1b05c7eb023 | 27 | char str[10]; |
MikamiUitOpen | 0:e1b05c7eb023 | 28 | sprintf(str, "%d", k++); |
MikamiUitOpen | 0:e1b05c7eb023 | 29 | lcd_.WriteStringXY(str, 0, 1); |
MikamiUitOpen | 0:e1b05c7eb023 | 30 | } |
MikamiUitOpen | 0:e1b05c7eb023 | 31 | |
MikamiUitOpen | 0:e1b05c7eb023 | 32 | void WaitButton() |
MikamiUitOpen | 0:e1b05c7eb023 | 33 | { |
MikamiUitOpen | 1:6c838e71e330 | 34 | lcd_.WriteStringXY("Push blue button", 0, 1); |
MikamiUitOpen | 0:e1b05c7eb023 | 35 | while (uButton_ == 1) {} |
MikamiUitOpen | 1:6c838e71e330 | 36 | lcd_.ClearLine(1); |
MikamiUitOpen | 1:6c838e71e330 | 37 | wait(0.5); |
MikamiUitOpen | 0:e1b05c7eb023 | 38 | } |
MikamiUitOpen | 0:e1b05c7eb023 | 39 | |
MikamiUitOpen | 0:e1b05c7eb023 | 40 | int main() |
MikamiUitOpen | 0:e1b05c7eb023 | 41 | { |
MikamiUitOpen | 2:6e609a28fa80 | 42 | if (lcd_.IsConnected()) printf("\r\nConnected"); |
MikamiUitOpen | 2:6e609a28fa80 | 43 | else printf("\r\nDisconnected"); |
MikamiUitOpen | 0:e1b05c7eb023 | 44 | lcd_.Clear(); |
MikamiUitOpen | 0:e1b05c7eb023 | 45 | lcd_.WriteString("Hello!"); |
MikamiUitOpen | 0:e1b05c7eb023 | 46 | WaitButton(); // Waiting, push blue user button |
MikamiUitOpen | 0:e1b05c7eb023 | 47 | lcd_.WriteStringXY("0123456789ABCDEF", 0, 0); |
MikamiUitOpen | 0:e1b05c7eb023 | 48 | WaitButton(); // Waiting, push blue user button |
MikamiUitOpen | 0:e1b05c7eb023 | 49 | lcd_.ClearLine(0); |
MikamiUitOpen | 0:e1b05c7eb023 | 50 | WaitButton(); // Waiting, push blue user button |
MikamiUitOpen | 1:6c838e71e330 | 51 | string str = "AQM1602"; |
MikamiUitOpen | 1:6c838e71e330 | 52 | lcd_.WriteStringXY(str+"XA-RN-GBW", 0, 0); |
MikamiUitOpen | 0:e1b05c7eb023 | 53 | TimerIsr(); |
MikamiUitOpen | 0:e1b05c7eb023 | 54 | timer_.attach(&TimerIsr, 1); |
MikamiUitOpen | 0:e1b05c7eb023 | 55 | |
MikamiUitOpen | 0:e1b05c7eb023 | 56 | while (true) {} |
MikamiUitOpen | 0:e1b05c7eb023 | 57 | } |