DISCO-F746NG_LCD_demo
Dependencies: BSP_DISCO_F746NG LCD_DISCO_F746NG mbed
main.cpp@0:f5f54c7509b4, 2016-02-22 (annotated)
- Committer:
- dj444
- Date:
- Mon Feb 22 17:22:42 2016 +0000
- Revision:
- 0:f5f54c7509b4
x
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dj444 | 0:f5f54c7509b4 | 1 | #include "mbed.h" |
dj444 | 0:f5f54c7509b4 | 2 | #include "LCD_DISCO_F746NG.h" |
dj444 | 0:f5f54c7509b4 | 3 | |
dj444 | 0:f5f54c7509b4 | 4 | LCD_DISCO_F746NG lcd; |
dj444 | 0:f5f54c7509b4 | 5 | DigitalOut LCD_D5(D5); |
dj444 | 0:f5f54c7509b4 | 6 | |
dj444 | 0:f5f54c7509b4 | 7 | |
dj444 | 0:f5f54c7509b4 | 8 | AnalogIn input0(A0); |
dj444 | 0:f5f54c7509b4 | 9 | AnalogIn input1(A1); |
dj444 | 0:f5f54c7509b4 | 10 | AnalogIn input2(A2); |
dj444 | 0:f5f54c7509b4 | 11 | AnalogIn input3(A3); |
dj444 | 0:f5f54c7509b4 | 12 | AnalogIn input4(A4); |
dj444 | 0:f5f54c7509b4 | 13 | AnalogIn input5(A5); |
dj444 | 0:f5f54c7509b4 | 14 | |
dj444 | 0:f5f54c7509b4 | 15 | // drawHomeScreen - Custom Function |
dj444 | 0:f5f54c7509b4 | 16 | void drawHomeScreen() { |
dj444 | 0:f5f54c7509b4 | 17 | lcd.Clear(LCD_COLOR_GREEN); |
dj444 | 0:f5f54c7509b4 | 18 | |
dj444 | 0:f5f54c7509b4 | 19 | lcd.DisplayStringAt(0, LINE(1), (uint8_t *)"MBED EXAMPLE", CENTER_MODE); |
dj444 | 0:f5f54c7509b4 | 20 | lcd.DisplayStringAt(0, LINE(6), (uint8_t *)"HOME SCREEN", RIGHT_MODE); |
dj444 | 0:f5f54c7509b4 | 21 | } |
dj444 | 0:f5f54c7509b4 | 22 | |
dj444 | 0:f5f54c7509b4 | 23 | // drawAnalogScreen - Custom Function |
dj444 | 0:f5f54c7509b4 | 24 | void drawAnalogScreen() { |
dj444 | 0:f5f54c7509b4 | 25 | lcd.Clear(LCD_COLOR_BLUE); |
dj444 | 0:f5f54c7509b4 | 26 | |
dj444 | 0:f5f54c7509b4 | 27 | lcd.DisplayStringAt(0, LINE(1), (uint8_t *)"A0", LEFT_MODE); |
dj444 | 0:f5f54c7509b4 | 28 | lcd.DisplayStringAt(0, LINE(2), (uint8_t *)"A1", LEFT_MODE); |
dj444 | 0:f5f54c7509b4 | 29 | lcd.DisplayStringAt(0, LINE(3), (uint8_t *)"A2", LEFT_MODE); |
dj444 | 0:f5f54c7509b4 | 30 | lcd.DisplayStringAt(0, LINE(4), (uint8_t *)"A3", LEFT_MODE); |
dj444 | 0:f5f54c7509b4 | 31 | lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"A4", LEFT_MODE); |
dj444 | 0:f5f54c7509b4 | 32 | lcd.DisplayStringAt(0, LINE(6), (uint8_t *)"A5", LEFT_MODE); |
dj444 | 0:f5f54c7509b4 | 33 | |
dj444 | 0:f5f54c7509b4 | 34 | lcd.DisplayStringAt(0, LINE(8), (uint8_t *)"ANALOG SCREEN", RIGHT_MODE); |
dj444 | 0:f5f54c7509b4 | 35 | } |
dj444 | 0:f5f54c7509b4 | 36 | |
dj444 | 0:f5f54c7509b4 | 37 | |
dj444 | 0:f5f54c7509b4 | 38 | |
dj444 | 0:f5f54c7509b4 | 39 | int main() |
dj444 | 0:f5f54c7509b4 | 40 | { |
dj444 | 0:f5f54c7509b4 | 41 | char currentPage, selectedUnit; |
dj444 | 0:f5f54c7509b4 | 42 | drawHomeScreen(); |
dj444 | 0:f5f54c7509b4 | 43 | wait(2); |
dj444 | 0:f5f54c7509b4 | 44 | drawAnalogScreen(); |
dj444 | 0:f5f54c7509b4 | 45 | |
dj444 | 0:f5f54c7509b4 | 46 | while(1) |
dj444 | 0:f5f54c7509b4 | 47 | { |
dj444 | 0:f5f54c7509b4 | 48 | |
dj444 | 0:f5f54c7509b4 | 49 | LCD_D5 = 1; |
dj444 | 0:f5f54c7509b4 | 50 | |
dj444 | 0:f5f54c7509b4 | 51 | lcd.SetBackColor(LCD_COLOR_RED); |
dj444 | 0:f5f54c7509b4 | 52 | lcd.SetTextColor(LCD_COLOR_WHITE); |
dj444 | 0:f5f54c7509b4 | 53 | //lcd.Clear(LCD_COLOR_BLUE); |
dj444 | 0:f5f54c7509b4 | 54 | |
dj444 | 0:f5f54c7509b4 | 55 | double meas0 = (5*input0.read_u16())/(double)65535; |
dj444 | 0:f5f54c7509b4 | 56 | char strarray0[50]; |
dj444 | 0:f5f54c7509b4 | 57 | sprintf(strarray0, " %f ", meas0); |
dj444 | 0:f5f54c7509b4 | 58 | |
dj444 | 0:f5f54c7509b4 | 59 | uint16_t meas1 = input1.read_u16(); |
dj444 | 0:f5f54c7509b4 | 60 | char strarray1[50]; |
dj444 | 0:f5f54c7509b4 | 61 | sprintf(strarray1, " %d ", meas1); |
dj444 | 0:f5f54c7509b4 | 62 | |
dj444 | 0:f5f54c7509b4 | 63 | uint16_t meas2 = input2.read_u16(); |
dj444 | 0:f5f54c7509b4 | 64 | char strarray2[50]; |
dj444 | 0:f5f54c7509b4 | 65 | sprintf(strarray2, " %d ", meas2); |
dj444 | 0:f5f54c7509b4 | 66 | |
dj444 | 0:f5f54c7509b4 | 67 | uint16_t meas3 = input3.read_u16(); |
dj444 | 0:f5f54c7509b4 | 68 | char strarray3[50]; |
dj444 | 0:f5f54c7509b4 | 69 | sprintf(strarray3, " %d ", meas3); |
dj444 | 0:f5f54c7509b4 | 70 | |
dj444 | 0:f5f54c7509b4 | 71 | uint16_t meas4 = input4.read_u16(); |
dj444 | 0:f5f54c7509b4 | 72 | char strarray4[50]; |
dj444 | 0:f5f54c7509b4 | 73 | sprintf(strarray4, " %d ", meas4); |
dj444 | 0:f5f54c7509b4 | 74 | |
dj444 | 0:f5f54c7509b4 | 75 | uint16_t meas5 = input5.read_u16(); |
dj444 | 0:f5f54c7509b4 | 76 | char strarray5[50]; |
dj444 | 0:f5f54c7509b4 | 77 | sprintf(strarray5, " %d ", meas5); |
dj444 | 0:f5f54c7509b4 | 78 | |
dj444 | 0:f5f54c7509b4 | 79 | |
dj444 | 0:f5f54c7509b4 | 80 | |
dj444 | 0:f5f54c7509b4 | 81 | lcd.DisplayStringAt(0, LINE(1), (uint8_t *)strarray0, RIGHT_MODE); |
dj444 | 0:f5f54c7509b4 | 82 | lcd.DisplayStringAt(0, LINE(2), (uint8_t *)strarray1, CENTER_MODE); |
dj444 | 0:f5f54c7509b4 | 83 | lcd.DisplayStringAt(0, LINE(3), (uint8_t *)strarray2, CENTER_MODE); |
dj444 | 0:f5f54c7509b4 | 84 | lcd.DisplayStringAt(0, LINE(4), (uint8_t *)strarray3, CENTER_MODE); |
dj444 | 0:f5f54c7509b4 | 85 | lcd.DisplayStringAt(0, LINE(5), (uint8_t *)strarray4, CENTER_MODE); |
dj444 | 0:f5f54c7509b4 | 86 | lcd.DisplayStringAt(0, LINE(6), (uint8_t *)strarray5, CENTER_MODE); |
dj444 | 0:f5f54c7509b4 | 87 | |
dj444 | 0:f5f54c7509b4 | 88 | |
dj444 | 0:f5f54c7509b4 | 89 | //lcd.Clear(LCD_COLOR_BLUE); |
dj444 | 0:f5f54c7509b4 | 90 | //lcd.SetTextColor(LCD_COLOR_BROWN); |
dj444 | 0:f5f54c7509b4 | 91 | //lcd.DrawCircle(200, 200, meas0/10); |
dj444 | 0:f5f54c7509b4 | 92 | |
dj444 | 0:f5f54c7509b4 | 93 | wait(0.160f); |
dj444 | 0:f5f54c7509b4 | 94 | } |
dj444 | 0:f5f54c7509b4 | 95 | |
dj444 | 0:f5f54c7509b4 | 96 | lcd.Clear(LCD_COLOR_GREEN); |
dj444 | 0:f5f54c7509b4 | 97 | lcd.SetTextColor(LCD_COLOR_BLUE); |
dj444 | 0:f5f54c7509b4 | 98 | lcd.DrawRect(10, 20, 50, 50); |
dj444 | 0:f5f54c7509b4 | 99 | wait(0.1); |
dj444 | 0:f5f54c7509b4 | 100 | lcd.SetTextColor(LCD_COLOR_BROWN); |
dj444 | 0:f5f54c7509b4 | 101 | lcd.DrawCircle(80, 80, 50); |
dj444 | 0:f5f54c7509b4 | 102 | wait(0.1); |
dj444 | 0:f5f54c7509b4 | 103 | lcd.SetTextColor(LCD_COLOR_YELLOW); |
dj444 | 0:f5f54c7509b4 | 104 | lcd.DrawEllipse(150, 150, 50, 100); |
dj444 | 0:f5f54c7509b4 | 105 | wait(0.1); |
dj444 | 0:f5f54c7509b4 | 106 | lcd.SetTextColor(LCD_COLOR_RED); |
dj444 | 0:f5f54c7509b4 | 107 | lcd.FillCircle(200, 200, 40); |
dj444 | 0:f5f54c7509b4 | 108 | wait(1); |
dj444 | 0:f5f54c7509b4 | 109 | |
dj444 | 0:f5f54c7509b4 | 110 | lcd.SetBackColor(LCD_COLOR_ORANGE); |
dj444 | 0:f5f54c7509b4 | 111 | lcd.SetTextColor(LCD_COLOR_CYAN); |
dj444 | 0:f5f54c7509b4 | 112 | lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"HAVE FUN !!!", CENTER_MODE); |
dj444 | 0:f5f54c7509b4 | 113 | wait(1); |
dj444 | 0:f5f54c7509b4 | 114 | |
dj444 | 0:f5f54c7509b4 | 115 | // pin5 = !pin5; |
dj444 | 0:f5f54c7509b4 | 116 | |
dj444 | 0:f5f54c7509b4 | 117 | } |