0,0 → 1,180 |
/***************************************************************************** |
* Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* Copyright (C) 2011 Christian "Cebra" Brandtner, brandtner@brandtner.net * |
* Copyright (C) 2011 Harald Bongartz * |
* * |
* 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. * |
* * |
* * |
* Credits to: * |
* Holger Buss & Ingo Busker from mikrokopter.de for the MK project + SVN * |
* http://www.mikrokopter.de * |
* Gregor "killagreg" Stobrawa for his version of the MK code * |
* Thomas Kaiser "thkais" for the original project. See * |
* http://www.ft-fanpage.de/mikrokopter/ * |
* http://forum.mikrokopter.de/topic-4061-1.html * |
* Claas Anders "CaScAdE" Rathje for providing the font and his C-OSD code * |
* http://www.mylifesucks.de/oss/c-osd/ * |
* Harald Bongartz "HaraldB" for providing his Ideas and Code for usibility* |
*****************************************************************************/ |
|
|
#include "cpu.h" |
#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 "messages.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 (); |
// lcd_printp_at (0, 7, PSTR(KEY_LINE_3), 0); |
lcd_puts_at(0, 7, strGet(KEYLINE3), 0); |
if (current_hardware == NC) |
{ |
lcd_printp_at (0, 0, PSTR(" Navi-Ctrl Display "), 2); |
lcd_printp_at (19, 7, PSTR("FC"), 0); |
} |
else |
{ |
if (hardware == FC) |
{ |
lcd_printp_at (0, 0, PSTR(" Display "), 2); |
lcd_printp_at (19, 7, PSTR(" "), 0); |
} |
else |
{ |
lcd_printp_at (0, 0, PSTR(" Flight-Ctrl Display "), 2); |
lcd_printp_at (19, 7, PSTR("NC"), 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_printp_at (0, 0, PSTR(" Navi-Ctrl Display "), 2); |
lcd_printp_at (19, 7, PSTR("FC"), 0); |
current_hardware = NC; |
} |
else |
{ |
lcd_printp_at (0, 0, PSTR(" Display "), 2); |
lcd_printp_at (19, 7, PSTR(" "), 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) || get_key_long_rpt_sp ((1 << KEY_MINUS), 2)) |
{ |
cmd = 0xfe; // next page |
//SendOutData('h', ADDRESS_ANY, 1, &cmd, 1); |
//cmd = 0; |
} |
else if (get_key_press (1 << KEY_PLUS) || get_key_long_rpt_sp ((1 << KEY_PLUS), 2)) |
{ |
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_printp_at (0, 0, PSTR(" Flight-Ctrl Display "), 2); |
lcd_printp_at (19, 7, PSTR("NC"), 0); |
} |
else |
{ |
SwitchToNC(); |
|
//timer = TIMEOUT; |
lcd_printp_at (0, 0, PSTR(" Navi-Ctrl Display "), 2); |
lcd_printp_at (19, 7, PSTR("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("Fehler: Keine Daten"), 0); |
|
timer = 100; |
while (timer > 0); |
} |
SwitchToNC(); |
} |