Rev 58 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
58 | killagreg | 1 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 | // + Copyright (c) 04.2007 Holger Buss |
||
3 | // + only for non-profit use |
||
4 | // + www.MikroKopter.com |
||
5 | // + see the File "License.txt" for further Informations |
||
6 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
7 | |||
8 | #include <stdlib.h> |
||
9 | #include <inttypes.h> |
||
10 | #include "menu.h" |
||
11 | #include "uart.h" |
||
12 | #include "printf_P.h" |
||
13 | #include "analog.h" |
||
14 | #include "main.h" |
||
15 | |||
16 | |||
17 | uint8_t MaxMenuItem = 2; |
||
18 | uint8_t MenuItem = 0; |
||
19 | uint8_t RemoteKeys = 0; |
||
20 | |||
21 | #define KEY1 0x01 |
||
22 | #define KEY2 0x02 |
||
23 | #define KEY3 0x04 |
||
24 | #define KEY4 0x08 |
||
25 | #define KEY5 0x10 |
||
26 | |||
27 | |||
28 | int8_t DisplayBuff[DISPLAYBUFFSIZE] = "Hello World"; |
||
29 | uint8_t DispPtr = 0; |
||
30 | |||
31 | |||
32 | /************************************/ |
||
33 | /* Clear LCD Buffer */ |
||
34 | /************************************/ |
||
35 | void LCD_Clear(void) |
||
36 | { |
||
37 | uint8_t i; |
||
38 | for( i = 0; i < DISPLAYBUFFSIZE; i++) DisplayBuff[i] = ' '; |
||
39 | } |
||
40 | |||
41 | |||
42 | /************************************/ |
||
43 | /* Update Menu on LCD */ |
||
44 | /************************************/ |
||
45 | // Display with 20 characters in 4 lines |
||
46 | void LCD_PrintMenu(void) |
||
47 | { |
||
48 | if(RemoteKeys & KEY1) |
||
49 | { |
||
50 | if(MenuItem) MenuItem--; |
||
51 | else MenuItem = MaxMenuItem; |
||
52 | } |
||
53 | if(RemoteKeys & KEY2) |
||
54 | { |
||
55 | if(MenuItem == MaxMenuItem) MenuItem = 0; |
||
56 | else MenuItem++; |
||
57 | } |
||
58 | if((RemoteKeys & KEY1) && (RemoteKeys & KEY2)) MenuItem = 0; |
||
59 | |||
60 | LCD_Clear(); |
||
61 | |||
62 | if(MenuItem > MaxMenuItem) MenuItem = MaxMenuItem; |
||
63 | // print menu item number in the upper right corner |
||
64 | if(MenuItem < 10) |
||
65 | { |
||
66 | LCD_printfxy(17,0,"[%i]",MenuItem); |
||
67 | } |
||
68 | else |
||
69 | { |
||
70 | LCD_printfxy(16,0,"[%i]",MenuItem); |
||
71 | } |
||
72 | |||
73 | switch(MenuItem) |
||
74 | { |
||
75 | case 0:// Version Info Menu Item |
||
76 | LCD_printfxy(0,0,"++ MK3MAG ++ "); |
||
77 | LCD_printfxy(0,1," V %d.%d%c", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH + 'a'); |
||
78 | if(AccPresent) |
||
79 | { |
||
80 | LCD_printfxy(0,2, " ACC Support "); |
||
81 | } |
||
82 | else |
||
83 | { |
||
84 | LCD_printfxy(0,2, " "); |
||
85 | } |
||
86 | LCD_printfxy(0,3,"(c) Buss, Busker "); |
||
87 | break; |
||
88 | |||
89 | case 1: // Magnet readings |
||
60 | holgerb | 90 | LCD_printfxy(0,0,"Magnet Sensors: "); |
58 | killagreg | 91 | LCD_printfxy(0,1,"X:%+4d ", MagX); |
92 | LCD_printfxy(0,2,"Y:%+4d ", MagY); |
||
93 | LCD_printfxy(0,3,"Z:%+4d ", MagZ); |
||
94 | break; |
||
95 | |||
96 | default: |
||
97 | MaxMenuItem = MenuItem - 1; |
||
98 | MenuItem = 0; |
||
99 | break; |
||
100 | } |
||
101 | RemoteKeys = 0; |
||
102 | } |