Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
730 | woggle | 1 | /***************************************************************************** |
2 | * Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
||
3 | * * |
||
4 | * This program is free software; you can redistribute it and/or modify * |
||
5 | * it under the terms of the GNU General Public License as published by * |
||
6 | * the Free Software Foundation; either version 2 of the License. * |
||
7 | * * |
||
8 | * This program is distributed in the hope that it will be useful, * |
||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
||
11 | * GNU General Public License for more details. * |
||
12 | * * |
||
13 | * You should have received a copy of the GNU General Public License * |
||
14 | * along with this program; if not, write to the * |
||
15 | * Free Software Foundation, Inc., * |
||
16 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
||
17 | * * |
||
18 | *****************************************************************************/ |
||
19 | |||
20 | #include <avr/io.h> |
||
21 | #include <avr/pgmspace.h> |
||
22 | #include <util/delay.h> |
||
23 | |||
24 | #include "main.h" |
||
25 | #include "lcd.h" |
||
26 | #include "usart.h" |
||
27 | #include "timer.h" |
||
28 | |||
29 | #include "mk-data-structs.h" |
||
30 | |||
31 | #define TIMEOUT 500 // 5 sec |
||
32 | |||
33 | void display_data (void) |
||
34 | { |
||
35 | uint8_t cmd; |
||
36 | uint8_t flag = 0;; |
||
37 | |||
38 | mode = 'H'; |
||
39 | |||
40 | lcd_cls (); |
||
41 | if (current_hardware == NC) |
||
42 | { |
||
43 | lcd_printpns_at (0, 7, PSTR(" \x1c \x1d Exit FC"), 0); |
||
44 | } |
||
45 | else |
||
46 | { |
||
47 | if (hardware == FC) |
||
48 | { |
||
49 | lcd_printpns_at (0, 7, PSTR(" \x1c \x1d Exit"), 0); |
||
50 | } |
||
51 | else |
||
52 | { |
||
53 | lcd_printpns_at (0, 7, PSTR(" \x1c \x1d Exit NC"), 0); |
||
54 | } |
||
55 | } |
||
56 | lcd_printp_at (0, 0, PSTR("Display"), 0); |
||
57 | |||
58 | rxd_buffer_locked = FALSE; |
||
59 | timer = TIMEOUT; |
||
60 | cmd = 0xfc; // Home = first page |
||
61 | |||
62 | do |
||
63 | { |
||
64 | SendOutData('h', ADDRESS_ANY, 1, &cmd, 1); |
||
65 | cmd = 0xff; |
||
66 | //LED6_TOGGLE; |
||
67 | _delay_ms (250); |
||
68 | |||
69 | if (rxd_buffer_locked) |
||
70 | { |
||
71 | Decode64 (); |
||
72 | flag = 1; |
||
73 | |||
74 | if (!hardware) |
||
75 | { // hardware was not detected at startup |
||
76 | hardware = rxd_buffer[1] - 'a'; |
||
77 | if (hardware == NC) |
||
78 | { |
||
79 | lcd_printpns_at (0, 7, PSTR(" \x1c \x1d Exit FC"), 0); |
||
80 | current_hardware = NC; |
||
81 | } |
||
82 | else |
||
83 | { |
||
84 | lcd_printpns_at (0, 7, PSTR(" \x1c \x1d Exit"), 0); |
||
85 | current_hardware = FC; |
||
86 | } |
||
87 | } |
||
88 | |||
89 | #if 0 |
||
90 | rxd_buffer[24] = 0; |
||
91 | |||
92 | lcd_print_at (0, rxd_buffer[3] + 1, (uint8_t *) &rxd_buffer[4], 0); |
||
93 | #else |
||
94 | rxd_buffer[83] = 0; |
||
95 | |||
96 | print_display_at (0, 2, (uint8_t *) &rxd_buffer[3]); |
||
97 | #endif |
||
98 | |||
99 | rxd_buffer_locked = FALSE; |
||
100 | timer = TIMEOUT; |
||
101 | } |
||
102 | |||
103 | if (get_key_press (1 << KEY_MINUS)) |
||
104 | { |
||
105 | cmd = 0xfe; // next page |
||
106 | LED1_TOGGLE; |
||
107 | //SendOutData('h', ADDRESS_ANY, 1, &cmd, 1); |
||
108 | //cmd = 0; |
||
109 | } |
||
110 | else if (get_key_press (1 << KEY_PLUS)) |
||
111 | { |
||
112 | cmd = 0xfd; // previous page |
||
113 | LED2_TOGGLE; |
||
114 | //SendOutData('h', ADDRESS_ANY, 1, &cmd, 1); |
||
115 | //cmd = 0; |
||
116 | } |
||
117 | else if ((hardware == NC) && get_key_press (1 << KEY_ENTER)) |
||
118 | { |
||
119 | if (current_hardware == NC) |
||
120 | { |
||
121 | SwitchToFC(); |
||
122 | |||
123 | //timer = TIMEOUT; |
||
124 | lcd_printpns_at (0, 7, PSTR(" \x1c \x1d Exit NC"), 0); |
||
125 | LED3_TOGGLE; |
||
126 | } |
||
127 | else |
||
128 | { |
||
129 | SwitchToNC(); |
||
130 | |||
131 | //timer = TIMEOUT; |
||
132 | lcd_printpns_at (0, 7, PSTR(" \x1c \x1d Exit FC"), 0); |
||
133 | LED4_TOGGLE; |
||
134 | } |
||
135 | cmd = 0xfc; // Home = first page |
||
136 | //SendOutData('h', ADDRESS_ANY, 1, &cmd, 1); |
||
137 | //cmd = 0; |
||
138 | } |
||
139 | } |
||
140 | while (!get_key_press (1 << KEY_ESC) && timer); |
||
141 | |||
142 | get_key_press(KEY_ALL); |
||
143 | |||
144 | mode = 0; |
||
145 | rxd_buffer_locked = FALSE; |
||
146 | |||
147 | if (!timer) |
||
148 | { // timeout occured |
||
149 | if (flag) |
||
150 | { |
||
151 | lcd_cls (); |
||
152 | } |
||
153 | lcd_printp_at (0, 2, PSTR("ERROR: no data"), 0); |
||
154 | |||
155 | timer = 100; |
||
156 | while (timer > 0); |
||
157 | } |
||
158 | LED_ALL_OFF; |
||
159 | } |