0,0 → 1,155 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* * |
* This program is free software; you can redistribute it and/or modify * |
* it under the terms of the GNU General Public License as published by * |
* the Free Software Foundation; either version 2 of the License. * |
* * |
* This program is distributed in the hope that it will be useful, * |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
* GNU General Public License for more details. * |
* * |
* You should have received a copy of the GNU General Public License * |
* along with this program; if not, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
|
#include <avr/io.h> |
#include <avr/pgmspace.h> |
#include <util/delay.h> |
|
#include "main.h" |
#include "lcd.h" |
#include "usart.h" |
#include "timer.h" |
|
#include "mk-data-structs.h" |
|
#define TIMEOUT 500 // 5 sec |
|
void display_data (void) |
{ |
uint8_t cmd; |
uint8_t flag = 0;; |
|
mode = 'H'; |
|
lcd_cls (); |
if (current_hardware == NC) |
{ |
lcd_printpns_at (0, 7, PSTR(" \x1c \x1d Exit FC"), 0); |
} |
else |
{ |
if (hardware == FC) |
{ |
lcd_printpns_at (0, 7, PSTR(" \x1c \x1d Exit"), 0); |
} |
else |
{ |
lcd_printpns_at (0, 7, PSTR(" \x1c \x1d Exit NC"), 0); |
} |
} |
lcd_printp_at (0, 0, PSTR("Display"), 0); |
|
rxd_buffer_locked = FALSE; |
timer = TIMEOUT; |
cmd = 0xfc; // Home = first page |
|
do |
{ |
SendOutData('h', ADDRESS_ANY, 1, &cmd, 1); |
cmd = 0xff; |
//LED6_TOGGLE; |
_delay_ms (250); |
|
if (rxd_buffer_locked) |
{ |
Decode64 (); |
flag = 1; |
|
if (!hardware) |
{ // hardware was not detected at startup |
hardware = rxd_buffer[1] - 'a'; |
if (hardware == NC) |
{ |
lcd_printpns_at (0, 7, PSTR(" \x1c \x1d Exit FC"), 0); |
current_hardware = NC; |
} |
else |
{ |
lcd_printpns_at (0, 7, PSTR(" \x1c \x1d Exit"), 0); |
current_hardware = FC; |
} |
} |
|
#if 0 |
rxd_buffer[24] = 0; |
|
lcd_print_at (0, rxd_buffer[3] + 1, (uint8_t *) &rxd_buffer[4], 0); |
#else |
rxd_buffer[83] = 0; |
|
print_display_at (0, 2, (uint8_t *) &rxd_buffer[3]); |
#endif |
|
rxd_buffer_locked = FALSE; |
timer = TIMEOUT; |
} |
|
if (get_key_press (1 << KEY_MINUS)) |
{ |
cmd = 0xfe; // next page |
//SendOutData('h', ADDRESS_ANY, 1, &cmd, 1); |
//cmd = 0; |
} |
else if (get_key_press (1 << KEY_PLUS)) |
{ |
cmd = 0xfd; // previous page |
//SendOutData('h', ADDRESS_ANY, 1, &cmd, 1); |
//cmd = 0; |
} |
else if ((hardware == NC) && get_key_press (1 << KEY_ENTER)) |
{ |
if (current_hardware == NC) |
{ |
SwitchToFC(); |
|
//timer = TIMEOUT; |
lcd_printpns_at (0, 7, PSTR(" \x1c \x1d Exit NC"), 0); |
} |
else |
{ |
SwitchToNC(); |
|
//timer = TIMEOUT; |
lcd_printpns_at (0, 7, PSTR(" \x1c \x1d Exit FC"), 0); |
} |
cmd = 0xfc; // Home = first page |
//SendOutData('h', ADDRESS_ANY, 1, &cmd, 1); |
//cmd = 0; |
} |
} |
while (!get_key_press (1 << KEY_ESC) && timer); |
|
get_key_press(KEY_ALL); |
|
mode = 0; |
rxd_buffer_locked = FALSE; |
|
if (!timer) |
{ // timeout occured |
if (flag) |
{ |
lcd_cls (); |
} |
lcd_printp_at (0, 2, PSTR("ERROR: no data"), 0); |
|
timer = 100; |
while (timer > 0); |
} |
SwitchToNC(); |
} |