Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1734 | - | 1 | /***************************************************************************** |
2 | * Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
||
3 | * Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
||
4 | * Copyright (C) 2011 Christian "Cebra" Brandtner, brandtner@brandtner.net * |
||
5 | * Copyright (C) 2011 Harald Bongartz * |
||
6 | * * |
||
7 | * This program is free software; you can redistribute it and/or modify * |
||
8 | * it under the terms of the GNU General Public License as published by * |
||
9 | * the Free Software Foundation; either version 2 of the License. * |
||
10 | * * |
||
11 | * This program is distributed in the hope that it will be useful, * |
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
||
14 | * GNU General Public License for more details. * |
||
15 | * * |
||
16 | * You should have received a copy of the GNU General Public License * |
||
17 | * along with this program; if not, write to the * |
||
18 | * Free Software Foundation, Inc., * |
||
19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
||
20 | * * |
||
21 | * * |
||
22 | * Credits to: * |
||
23 | * Holger Buss & Ingo Busker from mikrokopter.de for the MK project + SVN * |
||
24 | * http://www.mikrokopter.de * |
||
25 | * Gregor "killagreg" Stobrawa for his version of the MK code * |
||
26 | * Thomas Kaiser "thkais" for the original project. See * |
||
27 | * http://www.ft-fanpage.de/mikrokopter/ * |
||
28 | * http://forum.mikrokopter.de/topic-4061-1.html * |
||
29 | * Claas Anders "CaScAdE" Rathje for providing the font and his C-OSD code * |
||
30 | * http://www.mylifesucks.de/oss/c-osd/ * |
||
31 | * Harald Bongartz "HaraldB" for providing his Ideas and Code for usibility* |
||
32 | *****************************************************************************/ |
||
33 | |||
34 | |||
35 | #include "cpu.h" |
||
36 | #include <avr/io.h> |
||
37 | #include <avr/pgmspace.h> |
||
38 | #include <util/delay.h> |
||
39 | |||
40 | #include "main.h" |
||
41 | #include "lcd.h" |
||
42 | #include "usart.h" |
||
43 | #include "timer.h" |
||
44 | #include "messages.h" |
||
45 | |||
46 | #include "mk-data-structs.h" |
||
47 | |||
48 | #define TIMEOUT 500 // 5 sec |
||
49 | |||
50 | |||
51 | void display_data (void) |
||
52 | { |
||
53 | uint8_t cmd; |
||
54 | uint8_t flag = 0;; |
||
55 | |||
56 | mode = 'H'; |
||
57 | |||
58 | lcd_cls (); |
||
59 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_3), 0); |
||
60 | lcd_puts_at(0, 7, strGet(KEYLINE3), 0); |
||
61 | if (current_hardware == NC) |
||
62 | { |
||
63 | lcd_printp_at (0, 0, PSTR(" Navi-Ctrl Display "), 2); |
||
64 | lcd_printp_at (19, 7, PSTR("FC"), 0); |
||
65 | } |
||
66 | else |
||
67 | { |
||
68 | if (hardware == FC) |
||
69 | { |
||
70 | lcd_printp_at (0, 0, PSTR(" Display "), 2); |
||
71 | lcd_printp_at (19, 7, PSTR(" "), 0); |
||
72 | } |
||
73 | else |
||
74 | { |
||
75 | lcd_printp_at (0, 0, PSTR(" Flight-Ctrl Display "), 2); |
||
76 | lcd_printp_at (19, 7, PSTR("NC"), 0); |
||
77 | } |
||
78 | } |
||
79 | |||
80 | rxd_buffer_locked = FALSE; |
||
81 | timer = TIMEOUT; |
||
82 | cmd = 0xfc; // Home = first page |
||
83 | |||
84 | do |
||
85 | { |
||
86 | SendOutData('h', ADDRESS_ANY, 1, &cmd, 1); |
||
87 | cmd = 0xff; |
||
88 | //LED6_TOGGLE; |
||
89 | _delay_ms (250); |
||
90 | |||
91 | if (rxd_buffer_locked) |
||
92 | { |
||
93 | Decode64 (); |
||
94 | flag = 1; |
||
95 | |||
96 | if (!hardware) |
||
97 | { // hardware was not detected at startup |
||
98 | hardware = rxd_buffer[1] - 'a'; |
||
99 | if (hardware == NC) |
||
100 | { |
||
101 | lcd_printp_at (0, 0, PSTR(" Navi-Ctrl Display "), 2); |
||
102 | lcd_printp_at (19, 7, PSTR("FC"), 0); |
||
103 | current_hardware = NC; |
||
104 | } |
||
105 | else |
||
106 | { |
||
107 | lcd_printp_at (0, 0, PSTR(" Display "), 2); |
||
108 | lcd_printp_at (19, 7, PSTR(" "), 0); |
||
109 | current_hardware = FC; |
||
110 | } |
||
111 | } |
||
112 | |||
113 | #if 0 |
||
114 | rxd_buffer[24] = 0; |
||
115 | |||
116 | lcd_print_at (0, rxd_buffer[3] + 1, (uint8_t *) &rxd_buffer[4], 0); |
||
117 | #else |
||
118 | rxd_buffer[83] = 0; |
||
119 | |||
120 | print_display_at (0, 2, (uint8_t *) &rxd_buffer[3]); |
||
121 | #endif |
||
122 | |||
123 | rxd_buffer_locked = FALSE; |
||
124 | timer = TIMEOUT; |
||
125 | } |
||
126 | |||
127 | if (get_key_press (1 << KEY_MINUS) || get_key_long_rpt_sp ((1 << KEY_MINUS), 2)) |
||
128 | { |
||
129 | cmd = 0xfe; // next page |
||
130 | //SendOutData('h', ADDRESS_ANY, 1, &cmd, 1); |
||
131 | //cmd = 0; |
||
132 | } |
||
133 | else if (get_key_press (1 << KEY_PLUS) || get_key_long_rpt_sp ((1 << KEY_PLUS), 2)) |
||
134 | { |
||
135 | cmd = 0xfd; // previous page |
||
136 | //SendOutData('h', ADDRESS_ANY, 1, &cmd, 1); |
||
137 | //cmd = 0; |
||
138 | } |
||
139 | else if ((hardware == NC) && get_key_press (1 << KEY_ENTER)) |
||
140 | { |
||
141 | if (current_hardware == NC) |
||
142 | { |
||
143 | SwitchToFC(); |
||
144 | |||
145 | //timer = TIMEOUT; |
||
146 | lcd_printp_at (0, 0, PSTR(" Flight-Ctrl Display "), 2); |
||
147 | lcd_printp_at (19, 7, PSTR("NC"), 0); |
||
148 | } |
||
149 | else |
||
150 | { |
||
151 | SwitchToNC(); |
||
152 | |||
153 | //timer = TIMEOUT; |
||
154 | lcd_printp_at (0, 0, PSTR(" Navi-Ctrl Display "), 2); |
||
155 | lcd_printp_at (19, 7, PSTR("FC"), 0); |
||
156 | } |
||
157 | cmd = 0xfc; // Home = first page |
||
158 | //SendOutData('h', ADDRESS_ANY, 1, &cmd, 1); |
||
159 | //cmd = 0; |
||
160 | } |
||
161 | } |
||
162 | while (!get_key_press (1 << KEY_ESC) && timer); |
||
163 | get_key_press(KEY_ALL); |
||
164 | |||
165 | mode = 0; |
||
166 | rxd_buffer_locked = FALSE; |
||
167 | |||
168 | if (!timer) |
||
169 | { // timeout occured |
||
170 | if (flag) |
||
171 | { |
||
172 | lcd_cls (); |
||
173 | } |
||
174 | lcd_printp_at (0, 2, PSTR("Fehler: Keine Daten"), 0); |
||
175 | |||
176 | timer = 100; |
||
177 | while (timer > 0); |
||
178 | } |
||
179 | SwitchToNC(); |
||
180 | } |