![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
ftf lab0 project
main.cpp@0:2ecfcfac19a9, 2016-11-04 (annotated)
- Committer:
- uLipe
- Date:
- Fri Nov 04 23:57:36 2016 +0000
- Revision:
- 0:2ecfcfac19a9
first working version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
uLipe | 0:2ecfcfac19a9 | 1 | /** |
uLipe | 0:2ecfcfac19a9 | 2 | * @brief NXP FTF LAB0 - Prints a greeting message on GLCD |
uLipe | 0:2ecfcfac19a9 | 3 | */ |
uLipe | 0:2ecfcfac19a9 | 4 | |
uLipe | 0:2ecfcfac19a9 | 5 | |
uLipe | 0:2ecfcfac19a9 | 6 | #include "mbed.h" |
uLipe | 0:2ecfcfac19a9 | 7 | #include "ST7567.h" |
uLipe | 0:2ecfcfac19a9 | 8 | |
uLipe | 0:2ecfcfac19a9 | 9 | /* LCD screen dimensions */ |
uLipe | 0:2ecfcfac19a9 | 10 | #define LCD_HEIGHT 64 |
uLipe | 0:2ecfcfac19a9 | 11 | #define LCD_WIDTH 128 |
uLipe | 0:2ecfcfac19a9 | 12 | |
uLipe | 0:2ecfcfac19a9 | 13 | /* LCD font dimensions */ |
uLipe | 0:2ecfcfac19a9 | 14 | #define FONT_HEIGHT 10 |
uLipe | 0:2ecfcfac19a9 | 15 | #define FONT_WIDTH 5 |
uLipe | 0:2ecfcfac19a9 | 16 | |
uLipe | 0:2ecfcfac19a9 | 17 | |
uLipe | 0:2ecfcfac19a9 | 18 | /** Instance a on board GLCD object */ |
uLipe | 0:2ecfcfac19a9 | 19 | ST7567 glcd(D11, D13, D12, D9, D10); |
uLipe | 0:2ecfcfac19a9 | 20 | |
uLipe | 0:2ecfcfac19a9 | 21 | /** |
uLipe | 0:2ecfcfac19a9 | 22 | * @brief main application loop |
uLipe | 0:2ecfcfac19a9 | 23 | */ |
uLipe | 0:2ecfcfac19a9 | 24 | int main(void) |
uLipe | 0:2ecfcfac19a9 | 25 | { |
uLipe | 0:2ecfcfac19a9 | 26 | const char msg[] = {"Welcome to NXP FTF !\0"}; |
uLipe | 0:2ecfcfac19a9 | 27 | |
uLipe | 0:2ecfcfac19a9 | 28 | /* setup our on-board glcd */ |
uLipe | 0:2ecfcfac19a9 | 29 | glcd.set_contrast(0x35); |
uLipe | 0:2ecfcfac19a9 | 30 | glcd.cls(); |
uLipe | 0:2ecfcfac19a9 | 31 | |
uLipe | 0:2ecfcfac19a9 | 32 | /* Center the LCD cursor based on message size*/ |
uLipe | 0:2ecfcfac19a9 | 33 | glcd.locate(LCD_WIDTH - (sizeof(msg) * FONT_WIDTH), |
uLipe | 0:2ecfcfac19a9 | 34 | (LCD_HEIGHT - FONT_HEIGHT) / 2); |
uLipe | 0:2ecfcfac19a9 | 35 | |
uLipe | 0:2ecfcfac19a9 | 36 | /* prints a welcome message */ |
uLipe | 0:2ecfcfac19a9 | 37 | glcd.printf(msg); |
uLipe | 0:2ecfcfac19a9 | 38 | |
uLipe | 0:2ecfcfac19a9 | 39 | return 0; |
uLipe | 0:2ecfcfac19a9 | 40 | } |