![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
This program supports the following boards: ARCHPRO,TARGET_K64F,STM32F401xE,STM32F030,LPC1549,KL25Z
Fork of LCD_Shield-KL25Z by
main.cpp@3:8905b5780e24, 2014-09-12 (annotated)
- Committer:
- xshige
- Date:
- Fri Sep 12 02:42:34 2014 +0000
- Revision:
- 3:8905b5780e24
- Parent:
- 2:796f7d90beac
This program supports the following boards: ARCHPRO,TARGET_K64F,STM32F401xE,STM32F030,LPC1549,KL25Z;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MRSa | 0:ca0a38f28cbe | 1 | #include "mbed.h" |
MRSa | 0:ca0a38f28cbe | 2 | #include "TextLCD.h" |
MRSa | 0:ca0a38f28cbe | 3 | |
MRSa | 0:ca0a38f28cbe | 4 | DigitalOut myled(LED1); |
MRSa | 0:ca0a38f28cbe | 5 | |
xshige | 3:8905b5780e24 | 6 | //#define ARCHPRO |
xshige | 3:8905b5780e24 | 7 | |
xshige | 3:8905b5780e24 | 8 | #if 0 |
xshige | 3:8905b5780e24 | 9 | // template |
xshige | 3:8905b5780e24 | 10 | // LCD (RS, EN, D4, D5, D6, D7) |
xshige | 3:8905b5780e24 | 11 | TextLCD lcd(D8, D9, D4, D6, D6, D7); // LCD Shield for Arduino (DFR00009) |
xshige | 3:8905b5780e24 | 12 | AnalogIn button(A0); // board button |
xshige | 3:8905b5780e24 | 13 | PwmOut backlight(D10); |
xshige | 3:8905b5780e24 | 14 | #endif |
xshige | 3:8905b5780e24 | 15 | #ifdef ARCHPRO |
xshige | 3:8905b5780e24 | 16 | // LCD (RS, E, D4, D5, D6, D7) |
xshige | 3:8905b5780e24 | 17 | TextLCD lcd(P0_0, P0_1, P2_2, P2_3, P2_4, P2_5); // LCD Shield for Arduino (DFR00009) |
xshige | 3:8905b5780e24 | 18 | AnalogIn button(P0_23); // board button |
xshige | 3:8905b5780e24 | 19 | //PwmOut backlight(P0_6); |
xshige | 3:8905b5780e24 | 20 | DigitalOut backlight(P0_6); |
xshige | 3:8905b5780e24 | 21 | #endif |
xshige | 3:8905b5780e24 | 22 | #ifdef TARGET_K64F |
xshige | 3:8905b5780e24 | 23 | // *** IMPORTANT NOTE *** |
xshige | 3:8905b5780e24 | 24 | // to make it work correctly, you should supply directly(Not via PC USB) power to *K64F_USB* connecter. |
xshige | 3:8905b5780e24 | 25 | // ********************** |
xshige | 3:8905b5780e24 | 26 | // LCD (RS, E, D4, D5, D6, D7) |
xshige | 3:8905b5780e24 | 27 | TextLCD lcd( PTA0, PTC4, PTB23, PTA2, PTC2, PTC3); // LCD Shield for Arduino (DFR00009) |
xshige | 3:8905b5780e24 | 28 | AnalogIn button(PTB2); // board button |
xshige | 3:8905b5780e24 | 29 | //PwmOut backlight(PTD0); |
xshige | 3:8905b5780e24 | 30 | DigitalOut backlight(PTD0); |
xshige | 3:8905b5780e24 | 31 | #endif |
xshige | 3:8905b5780e24 | 32 | #ifdef STM32F401xE |
xshige | 3:8905b5780e24 | 33 | // LCD (RS, E, D4, D5, D6, D7) |
xshige | 3:8905b5780e24 | 34 | TextLCD lcd(PA_9, PC_7, PB_5, PB_4, PB_10, PA_8); // LCD Shield for Arduino (DFR00009) |
xshige | 3:8905b5780e24 | 35 | AnalogIn button(PA_0); // board button |
xshige | 3:8905b5780e24 | 36 | PwmOut backlight(PB_6); |
xshige | 3:8905b5780e24 | 37 | #endif |
xshige | 3:8905b5780e24 | 38 | #ifdef STM32F030 |
xshige | 3:8905b5780e24 | 39 | // LCD (RS, E, D4, D5, D6, D7) |
xshige | 3:8905b5780e24 | 40 | TextLCD lcd(PA_9, PC_7, PB_5, PB_4, PB_10, PA_8); // LCD Shield for Arduino (DFR00009) |
xshige | 3:8905b5780e24 | 41 | AnalogIn button(PA_0); // board button |
xshige | 3:8905b5780e24 | 42 | PwmOut backlight(PB_6); |
xshige | 3:8905b5780e24 | 43 | #endif |
xshige | 3:8905b5780e24 | 44 | #ifdef TARGET_LPC1549 |
xshige | 3:8905b5780e24 | 45 | // LCD (RS, E, D4, D5, D6, D7) |
xshige | 3:8905b5780e24 | 46 | TextLCD lcd(P0_24, P1_0, P0_10, P0_16, P1_3, P0_0); // LCD Shield for Arduino (DFR00009) |
xshige | 3:8905b5780e24 | 47 | AnalogIn button(P0_8); // board button |
xshige | 3:8905b5780e24 | 48 | PwmOut backlight(P0_27); |
xshige | 3:8905b5780e24 | 49 | #endif |
MRSa | 0:ca0a38f28cbe | 50 | #ifdef TARGET_KL25Z |
MRSa | 0:ca0a38f28cbe | 51 | // LCD (RS, E, D4, D5, D6, D7) |
MRSa | 0:ca0a38f28cbe | 52 | TextLCD lcd(PTA13, PTD5, PTA4, PTA5, PTC8, PTC9); // LCD Shield for Arduino (DFR00009) |
MRSa | 0:ca0a38f28cbe | 53 | AnalogIn button(PTB0); // board button |
MRSa | 1:c04ae2fc1a27 | 54 | PwmOut backlight(PTD0); |
MRSa | 0:ca0a38f28cbe | 55 | #endif |
MRSa | 0:ca0a38f28cbe | 56 | |
MRSa | 0:ca0a38f28cbe | 57 | /*** |
MRSa | 0:ca0a38f28cbe | 58 | * --------------------------------------------- |
MRSa | 0:ca0a38f28cbe | 59 | * Arduino LCD KeyPad Shield (SKU: DFR0009) |
MRSa | 0:ca0a38f28cbe | 60 | * --------------------------------------------- |
MRSa | 0:ca0a38f28cbe | 61 | * - Button : a0 -> PTB0 |
MRSa | 0:ca0a38f28cbe | 62 | * right : < 0.15 |
MRSa | 0:ca0a38f28cbe | 63 | * up : < 0.35 |
MRSa | 0:ca0a38f28cbe | 64 | * down : < 0.65 |
MRSa | 0:ca0a38f28cbe | 65 | * left : < 0.99 |
MRSa | 0:ca0a38f28cbe | 66 | * select : ??? |
MRSa | 0:ca0a38f28cbe | 67 | * --------------------------------------------- |
MRSa | 0:ca0a38f28cbe | 68 | * - DB4 : d4 -> pta4 |
MRSa | 0:ca0a38f28cbe | 69 | * - DB5 : d5 -> pta5 |
MRSa | 0:ca0a38f28cbe | 70 | * - DB6 : d6 -> ptc8 |
MRSa | 0:ca0a38f28cbe | 71 | * - DB7 : d7 -> ptc9 |
MRSa | 0:ca0a38f28cbe | 72 | * - RS : d8 -> pta13 |
MRSa | 0:ca0a38f28cbe | 73 | * - Enable : d9 -> ptd5 |
MRSa | 2:796f7d90beac | 74 | * - Backlight Control : d10 -> ptd0 |
MRSa | 0:ca0a38f28cbe | 75 | * --------------------------------------------- |
MRSa | 0:ca0a38f28cbe | 76 | * - http://www.dfrobot.com/wiki/index.php/Arduino_LCD_KeyPad_Shield_(SKU:_DFR0009) |
MRSa | 0:ca0a38f28cbe | 77 | * - http://www.dfrobot.com/index.php?route=product/product&keyword=DFR0009&category_id=0&description=1&model=1&product_id=51 |
MRSa | 0:ca0a38f28cbe | 78 | * - http://www.amazon.co.jp/dp/B00ACCN148 |
MRSa | 0:ca0a38f28cbe | 79 | * - http://akizukidenshi.com/catalog/g/gM-07029/ |
MRSa | 0:ca0a38f28cbe | 80 | ***/ |
MRSa | 0:ca0a38f28cbe | 81 | |
MRSa | 0:ca0a38f28cbe | 82 | int main() |
MRSa | 0:ca0a38f28cbe | 83 | { |
MRSa | 0:ca0a38f28cbe | 84 | int count = 0; |
xshige | 3:8905b5780e24 | 85 | //#ifdef TARGET_KL25Z |
MRSa | 1:c04ae2fc1a27 | 86 | backlight = 1; // ON: 1, OFF: 0 |
MRSa | 0:ca0a38f28cbe | 87 | lcd.cls(); |
MRSa | 0:ca0a38f28cbe | 88 | lcd.printf("HELLO"); |
MRSa | 2:796f7d90beac | 89 | wait(0.5); |
xshige | 3:8905b5780e24 | 90 | //#endif |
MRSa | 0:ca0a38f28cbe | 91 | while (1) |
MRSa | 0:ca0a38f28cbe | 92 | { |
MRSa | 0:ca0a38f28cbe | 93 | myled = (myled == 1) ? 0 : 1; |
MRSa | 0:ca0a38f28cbe | 94 | count = count + 1; |
MRSa | 0:ca0a38f28cbe | 95 | |
xshige | 3:8905b5780e24 | 96 | //#ifdef TARGET_KL25Z |
MRSa | 0:ca0a38f28cbe | 97 | // READ BUTTON VALUE |
MRSa | 0:ca0a38f28cbe | 98 | unsigned long value = button.read_u16(); |
MRSa | 0:ca0a38f28cbe | 99 | |
MRSa | 0:ca0a38f28cbe | 100 | // LCD OUTPUT |
MRSa | 0:ca0a38f28cbe | 101 | lcd.cls(); |
MRSa | 0:ca0a38f28cbe | 102 | lcd.locate(0,0); |
MRSa | 0:ca0a38f28cbe | 103 | lcd.printf("%d", count); // loop counter |
MRSa | 0:ca0a38f28cbe | 104 | |
MRSa | 0:ca0a38f28cbe | 105 | lcd.locate(0,1); |
MRSa | 0:ca0a38f28cbe | 106 | lcd.printf("BUTTON : %04x", value); // button value |
xshige | 3:8905b5780e24 | 107 | //lcd.printf("BUTTON : %02x", value>>8); // button value |
xshige | 3:8905b5780e24 | 108 | //#endif |
MRSa | 2:796f7d90beac | 109 | wait(0.2); |
MRSa | 0:ca0a38f28cbe | 110 | } |
MRSa | 0:ca0a38f28cbe | 111 | } |