/Transportables_Koptertool/PKT/GPL_PKT_V3_85f/mk/mkbase.c |
---|
0,0 → 1,825 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
//############################################################################ |
//# HISTORY mkbase.c |
//# |
//# 21.06.2014 OG |
//# - chg: searchMK() schaltet am Ende wieder auf die NC um sofern diese |
//# vorhanden ist |
//# |
//# 19.05.2014 OG |
//# - chg: MKVersion_Setting_print() umgestellt auf strGet(STR_ERROR) fuer |
//# Multi-Sprachenunterstuetzung |
//# |
//# 14.05.2014 OG |
//# - chg: include "paramset.h" geaendert auf "../mksettings/paramset.h" |
//# |
//# 13.05.2014 OG |
//# - chg: MK_Info() - del: MKINFO_AUTO_REFRESH (nicht mehr unterstuetzt) |
//# - chg: MK_Setting_write() - del: unused variable 'lsetting' |
//# |
//# 17.04.2014 OG |
//# - chg: MK_Setting_load - Ansprechverhalten verbessert wenn Windows |
//# Mikrokoptertool aktiv ist |
//# |
//# 29.03.2014 OG |
//# - del: MK_Show_LastGPS_Position() -> jetzt: OSDDATA_ShowLastGPSPosition()/osddata.c |
//# |
//# 28.03.2014 OG |
//# - add: MK_Show_LastGPS_Position() - ehemals in main.c |
//# |
//# 24.03.2014 OG |
//# - chg: searchMK(): doppeltes MK_SwitchToNC() um evtl. vorhandene NC |
//# zuverlaessiger zu erkennen |
//# - fix: searchMK(): RetVal initialisiert |
//# - chg: Default-Anzeigezeit von MK_Info() in searchMK() auf 5 Sek. reduziert |
//# |
//# 21.02.2014 OG |
//# - fix: MKVersion_Setting_print() Anzeige der Settings-Nummer gekuerzt |
//# |
//# 20.02.2014 OG |
//#- chg: searchMK() auf aktuelle Version von PKT_TitlePKTVersion() angepasst |
//# |
//# 20.02.2014 OG |
//# - chg: MKVersion_Setting_print() um ein paar Bytes zu sparen |
//# - chg: MK_Info() um ein paar Bytes zu sparen |
//# |
//# 16.02.2014 OG |
//# - add: MK_SwitchToNC(), MK_SwitchToFC(), MK_SwitchToMAG(), MK_SwitchToGPS() |
//# - add: MK_Setting_write(), MK_Setting_change() |
//# - chg: umbenannt: MK_load_setting() zu MK_Setting_load() |
//# |
//# 13.02.2014 OG |
//# - add: MKVersion_Cmp() (Anleitung bei der Funktion beachten!) |
//# - del: WrongFCVersion |
//# |
//# 12.02.2014 OG |
//# - chg: verschiedene Verbesserungen an MK_Info(), MK_load_settings(), searckMK() |
//# |
//# 10.02.2014 OG |
//# - add: MKVersion_Setting_print() |
//# |
//# 09.02.2014 OG |
//# - add: MK_Info() |
//# |
//# 08.02.2014 OG |
//# - chg: searckMK() Anpassung an MKVersion |
//# - chg: MK_load_setting() Anpassung an MKVersion und Parameter geaendert |
//# - add: MKVersion_Init(), MKVersion_print_at() |
//# |
//# 03.02.2014 OG |
//# - chg: Titelanzeige in searchMK() umgestellt auf PKT_ShowTitlePKTVersion() |
//# - chg: kleine Aenderung in der Anzeige "für FC..." in searchMK() |
//# |
//# 29.01.2014 OG |
//# - Ausgliederungen aus main.c: MK_load_setting(), searchMK() |
//############################################################################ |
#include "../cpu.h" |
#include <avr/io.h> |
#include <inttypes.h> |
#include <stdlib.h> |
#include <avr/pgmspace.h> |
#include <util/delay.h> |
#include <string.h> |
#include <util/atomic.h> |
#include <avr/wdt.h> |
#include <avr/eeprom.h> |
//#include "../lipo/lipo.h" |
#include "../main.h" |
#include "../lipo/lipo.h" |
#include "../lcd/lcd.h" |
#include "../uart/usart.h" |
#include "../uart/uart1.h" |
#include "../mk-data-structs.h" |
//#include "../menu.h" |
#include "../timer/timer.h" |
#include "../eeprom/eeprom.h" |
#include "../messages.h" |
#include "../utils/scrollbox.h" |
#include "../utils/xutils.h" |
#include "../pkt/pkt.h" |
#include "../mksettings/paramset.h" |
#include "mkbase.h" |
//---------------------------- |
// MK-Versionsinformationen |
// global verfuegbar |
//---------------------------- |
MKVersion_t MKVersion; |
uint8_t cmd; |
//############################################################################################# |
//# 1. MKVersion |
//############################################################################################# |
//-------------------------------------------------------------- |
// MKVersion_Init() |
// |
// initialisiert MKVersion auf 0 |
//-------------------------------------------------------------- |
void MKVersion_Init( void ) |
{ |
memset( &MKVersion, 0, sizeof(MKVersion_t) ); |
} |
//-------------------------------------------------------------- |
// value = MKVersion_Cmp( FC/NCver, SWMajor,SWMinor,SWPatch ) |
// |
// Vergleicht eine uebergebene FC/NC-Version mit der vom MK |
// ermittelten Version |
// |
// Parameter: |
// |
// FC/NCver: MKVersion.FCVer oder MKVersion.NCVer |
// |
// SWMajor,SWMinor,SWPatch: siehe nachfolgendes... |
// |
//--- |
// Beispiel aus osd.c/OSD_MK_GetData(): |
// |
// v = MKVersion_Cmp( MKVersion.NCVer, 0,30,'g' ); // pruefe auf NC-Version "0.30g" |
// |
// if( v && (v >= GIVEN_VERSION) ) // wenn aktuelle NC-Version >= "0.30g"... |
// { ... |
// |
// Sowas geht auch: |
// |
// if( v && (v == GIVEN_VERSION) ) // nur wenn aktuelle NC-Version == "0.30g"... |
// |
// oder: |
// |
// if( v && (v < GIVEN_VERSION) ) // nur wenn aktuelle NC-Version kleiner als "0.30g"... |
// |
//--- |
// Warum "if( v && ..." ? |
// |
// Wenn das PKT keine FC/NC-Version ermitteln konnte, und somit kein |
// Vergleich moeglich ist, gibt MKVersion_Cmp() false (=0) zurueck! |
//-------------------------------------------------------------- |
uint8_t MKVersion_Cmp( Version_t ver, unsigned char SWMajor, unsigned char SWMinor, unsigned char SWPatch ) |
{ |
SWPatch = SWPatch -'a'; |
if( ver.SWMajor > 0 || ver.SWMinor > 0 ) // NC/FC Version erkannt? |
{ |
if( (ver.SWMajor == SWMajor) && (ver.SWMinor == SWMinor) && (ver.SWPatch == SWPatch) ) |
return VERSION_EQUAL; // ==2 |
if( ver.SWMajor != SWMajor ) |
{ |
if( ver.SWMajor < SWMajor ) |
return VERSION_LOWER; // ==1 |
else |
return VERSION_GREATER; // ==3 |
} |
if( ver.SWMinor != SWMinor ) |
{ |
if( ver.SWMinor < SWMinor ) |
return VERSION_LOWER; // ==1 |
else |
return VERSION_GREATER; // ==3 |
} |
if( ver.SWPatch < SWPatch ) |
return VERSION_LOWER; // ==1 |
else |
return VERSION_GREATER; // ==3 |
} |
return VERSION_NO; // ==0 |
} |
//-------------------------------------------------------------- |
// MKVersion_print_at() |
// |
// zeigt die aktuelle FC, NC Version auf dem LCD an |
// |
// Parameter: |
// what: NC, FC, |
//-------------------------------------------------------------- |
void MKVersion_print_at( uint8_t x, uint8_t y, uint8_t what, uint8_t drawmode, int8_t xoffs, int8_t yoffs ) |
{ |
const char *mask = PSTR("%1u.%02u%c"); |
const char *nostr = PSTR("-----"); |
switch(what) |
{ |
case FC: if( MKVersion.FCVer.SWMajor > 0 || MKVersion.FCVer.SWMinor > 0 ) |
lcdx_printf_at_P( x, y, drawmode, xoffs, yoffs, mask, MKVersion.FCVer.SWMajor, MKVersion.FCVer.SWMinor, MKVersion.FCVer.SWPatch+'a' ); |
else |
lcdx_printp_at( x,y, nostr, drawmode, xoffs, yoffs); |
break; |
case NC: if( (MKVersion.NCVer.SWMajor != 0) || (MKVersion.NCVer.SWMinor != 0) ) |
lcdx_printf_at_P( x, y, drawmode, xoffs, yoffs, PSTR("%1u.%02u%c"), MKVersion.NCVer.SWMajor, MKVersion.NCVer.SWMinor, MKVersion.NCVer.SWPatch+'a' ); |
else |
lcdx_printp_at( x,y, nostr, drawmode, xoffs, yoffs); |
break; |
} |
} |
//-------------------------------------------------------------- |
// MKVersion_Setting_print( y, drawmode, xoffs,yoffs) |
// |
// Zeigt das aktuelle MK-Setting aus MKVersion zentriert in der |
// Zeile y auf dem PKT-Screen an |
//-------------------------------------------------------------- |
void MKVersion_Setting_print( uint8_t y, uint8_t drawmode, uint8_t xoffs, uint8_t yoffs ) |
{ |
char buffer[18]; // String Buffer fuer eine Zeile |
if( MKVersion.mksetting == 0 ) |
xsnprintf_P( buffer, 18, PSTR("* %S *"), strGet(STR_ERROR) ); // FC Setting konnte NICHT gelesen werden |
else if( MKVersion.mksetting != 0 && MKVersion.paramsetOK ) // FC-Setting wurde gelesen... |
xsnprintf_P( buffer, 18, PSTR("%u %s"), MKVersion.mksetting, MKVersion.mksettingName ); // ... passende FC-Reversion -> Nummer und Name anzeigen |
else |
xsnprintf_P( buffer, 18, PSTR("%u"), MKVersion.mksetting ); // ... aber FALSCHE FC-Version -> nicht den Namen anzeigen (nur die Nummer) |
lcdx_print_center( y, (unsigned char *)buffer, drawmode, xoffs,yoffs); // Ausgabe Setting-Name (zentriert) |
} |
//############################################################################################# |
//# 2. Sonstiges - MK-Suche, Settings laden, MK-Info |
//############################################################################################# |
#define SWITCH_DELAY 25 // alt 50 |
//-------------------------------------------------------------- |
//-------------------------------------------------------------- |
void MK_SwitchToNC( void ) |
{ |
// switch to NC |
USART_putc (0x1b); |
USART_putc (0x1b); |
USART_putc (0x55); |
USART_putc (0xaa); |
USART_putc (0x00); |
current_hardware = NC; |
_delay_ms( SWITCH_DELAY ); |
} |
//-------------------------------------------------------------- |
//-------------------------------------------------------------- |
void MK_SwitchToFC( void ) |
{ |
// switch to FC |
cmd = 0x00; // 0 = FC, 1 = MK3MAG, 2 = MKGPS |
SendOutData('u', ADDRESS_NC, 1, &cmd, 1); |
current_hardware = FC; |
_delay_ms( SWITCH_DELAY ); |
} |
//-------------------------------------------------------------- |
//-------------------------------------------------------------- |
void MK_SwitchToMAG( void ) |
{ |
// switch to MK3MAG |
cmd = 0x01; // 0 = FC, 1 = MK3MAG, 2 = MKGPS |
SendOutData('u', ADDRESS_NC, 1, &cmd, 1); |
current_hardware = MK3MAG; |
_delay_ms( SWITCH_DELAY ); |
} |
//-------------------------------------------------------------- |
//-------------------------------------------------------------- |
void MK_SwitchToGPS( void ) |
{ |
// switch to MKGPS |
cmd = 0x02; // 0 = FC, 1 = MK3MAG, 2 = MKGPS |
SendOutData('u', ADDRESS_NC, 1, &cmd, 1); |
current_hardware = MKGPS; |
_delay_ms( SWITCH_DELAY ); |
} |
//-------------------------------------------------------------- |
// ret = MK_Setting_load( lsetting, &mk_param_struct, showerror) |
// |
// holt MK-Settings - es wird auf die FC umgeschaltet! |
//-------------------------------------------------------------- |
uint8_t MK_Setting_load( uint8_t lsetting, uint8_t timeout ) |
{ |
// timeout = 15 bis 20 ist meist ein guter Wert |
//MK_SwitchToFC(); |
mode = 'Q'; // Settings Request |
rxd_buffer_locked = FALSE; |
while( !rxd_buffer_locked && timeout ) |
{ |
MK_SwitchToFC(); |
SendOutData( 'q', ADDRESS_FC, 1, &lsetting, 1); // lsetting == 0xff -> aktuelles MK-Setting laden |
timer2 = 25; // timer ist ggf. belegt von MK_Info() -> versuchen wir es mit timer2.... |
while( timer2 > 0 && !rxd_buffer_locked ); |
timeout--; |
} |
mode = 0; |
// Initialisierungen |
paramsetInit(0); |
if( rxd_buffer_locked ) |
{ |
Decode64(); |
paramsetInit( (unsigned char *) pRxData ); // fuellt u.a. auch MKVersion.paramsetRevision |
} |
return MKVersion.mksetting; // wird von paramsetInit() gesetzt/initialisert |
} |
//-------------------------------------------------------------- |
//-------------------------------------------------------------- |
uint8_t MK_Setting_write( uint8_t wsetting, uint8_t timeout) |
{ |
//uint8_t timeout = 50; |
uint8_t setting; |
if( !MKVersion.paramsetOK ) |
{ |
return 0; // Error |
} |
//MK_SwitchToFC(); // ? |
setting = 0; |
mode = 'S'; // Settings |
rxd_buffer_locked = FALSE; |
while( !rxd_buffer_locked && timeout && !setting) |
{ |
SendOutData( 's', ADDRESS_FC, 2, &wsetting, 1, (pRxData+1), paramsetSize() ); // pRxData+1 = die mk_datastruct beginnt bei +1; bei 0 ist die Settingsnummer |
timer2 = 70; |
while( timer2 > 0 && !rxd_buffer_locked ); |
timeout--; |
if( rxd_buffer_locked ) |
{ |
Decode64(); |
setting = *pRxData; |
if( !setting ) |
rxd_buffer_locked = FALSE; |
} |
} |
setting = MK_Setting_load( 0xff, 15); // damit pRxData & MKVersion initialisiert sind |
return setting; |
} |
//-------------------------------------------------------------- |
//-------------------------------------------------------------- |
uint8_t MK_Setting_change( uint8_t setting ) |
{ |
uint8_t lsetting = 0; |
uint8_t wsetting = 0; |
lsetting = MK_Setting_load( setting, 20); |
if( lsetting == setting ) |
{ |
wsetting = MK_Setting_write( setting, 50); |
} |
/* |
//-------------------- |
// DEBUG... |
//-------------------- |
lcd_printf_at_P( 0, 1, MNORMAL, PSTR("load : %1u (req:%1u)"), lsetting, setting ); |
lcd_printf_at_P( 0, 2, MNORMAL, PSTR("write: %1u "), wsetting ); |
if( (setting != lsetting) || (setting != wsetting) ) |
set_beep( 1000, 0x0f0f, BeepNormal ); // Error |
timer2 = 500; while( timer2 > 0 ); |
*/ |
return wsetting; // 0 = Fehler; oder 1..5 = geschriebenes Setting |
} |
//-------------------------------------------------------------- |
// ok = searchMK( showMKInfo ) |
// |
// Parameter: |
// showMKInfo: true/false |
//-------------------------------------------------------------- |
uint8_t searchMK( uint8_t showMKInfo ) |
{ |
uint8_t timeout; |
//uint8_t setting; // aktuelles FC-Setting (1..5) |
uint8_t RetVal = false; |
uint8_t redraw = true; |
uint8_t searchbar_y; |
uint8_t searchbar_w = 0; |
MKVersion_Init(); |
//---------------- |
// Switch to NC |
//---------------- |
MK_SwitchToNC(); |
_delay_ms(50); // 24.03.2014 OG: manchmal wurde nicht auf eine vorhandene NC umgeschaltet |
MK_SwitchToNC(); // evtl. wird das durch doppeltes Senden verbessert |
//--------------------------------------- |
// MK-Suchscreen - Versionsabfrage NC |
//--------------------------------------- |
mode = 'V'; |
rxd_buffer_locked = FALSE; |
timeout = 50; |
//searchbar_y = 5*8-1; |
searchbar_y = 5*8+2; |
while( !rxd_buffer_locked ) |
{ |
//------------------------ |
// MK Suchscreen anzeigen |
//------------------------ |
if( redraw ) |
{ |
PKT_TitlePKT(); // Titel mit PKT-Version anzeigen (mit Lipo-Anzeige) |
lcdx_printp_center( 2, strGet(STR_PKT), MNORMAL, 0,2); // "PKT" |
lcdx_printp_at( 0, 3, strGet(START_SEARCHFC), MNORMAL, 0,8); // "suche Mikrokopter..." |
lcd_printp_at(12, 7, strGet(ENDE), MNORMAL); // Keyline |
lcd_rect ( 0, searchbar_y , 126, 8, 1); // Rahmen fuer Bar-Anzeige |
searchbar_w = 2; |
redraw = false; |
} |
//------------------------ |
// PKT-LiPo Anzeige |
//------------------------ |
show_Lipo(); |
//------------------------ |
// MK Datenanfrage |
//------------------------ |
SendOutData( 'v', ADDRESS_ANY, 0); // Versions-Anfrage an MK senden |
timer = 16; // kurze Verögerung fuer Datenanfrage und Fortschrittsbalken |
while( timer > 0 ); |
//------------------------ |
// Fortschrittsbalken |
//------------------------ |
lcd_frect( 2, searchbar_y+2, searchbar_w, 4, 1); // Fortschrittsbalken zeichnen... |
searchbar_w += 2; |
if( searchbar_w >= 125 ) |
{ |
searchbar_w = 0; |
lcd_frect( 2, searchbar_y+2, 123, 4, 0); |
} |
//------------------------ |
// Tasten abfragen |
//------------------------ |
if( get_key_press(1 << KEY_ESC) ) |
{ |
hardware = NO; |
return false; |
} |
//------------------------------------------ |
// Pruefe PKT-Update oder andere PKT-Aktion |
//------------------------------------------ |
if( PKT_CtrlHook() ) // Update vom Updatetool angefordert? |
{ |
redraw = true; |
} |
} |
//-------------------------- |
// MK gefunden? |
//-------------------------- |
if( rxd_buffer_locked ) |
{ |
Decode64(); |
//--- |
// TODO OG: testen mit entsprechendem Hardware Setup des MK's! |
//--- |
if( (rxd_buffer[1] - 'a') == ADDRESS_FC ) |
{ |
hardware = FC; |
current_hardware = hardware; |
MKVersion.isFC = true; |
RetVal = true; |
memcpy( &MKVersion.FCVer, (Version_t *) (pRxData), sizeof(Version_t) ); |
} |
if( (rxd_buffer[1] - 'a') == ADDRESS_NC ) |
{ |
hardware = NC; |
current_hardware = hardware; |
MKVersion.isNC = true; |
RetVal = true; |
memcpy( &MKVersion.NCVer, (Version_t *) (pRxData), sizeof(Version_t) ); |
} |
//-------------------------- |
// jetzt: Version der FC abfragen |
//-------------------------- |
if( hardware == NC ) |
{ |
MK_SwitchToFC(); |
mode = 'V'; |
rxd_buffer_locked = FALSE; |
timeout = 40; |
while( !rxd_buffer_locked && timeout) |
{ |
SendOutData( 'v', ADDRESS_FC, 0); |
timer = 20; |
while( timer > 0 ); |
timeout--; |
} |
//-------------------------- |
// FC gefunden! |
// -> Version kopieren |
//-------------------------- |
if( rxd_buffer_locked ) |
{ |
Decode64(); |
MKVersion.isFC = true; |
memcpy( &MKVersion.FCVer, (Version_t *) (pRxData), sizeof(Version_t) ); |
} |
} |
} // end: if( rxd_buffer_locked ) |
//--------------------------------------- |
// FC EEprom Version / Struktur pruefen |
//--------------------------------------- |
MK_Setting_load( 0xff, 15 ); // 0xff == aktuelles Parameterset holen; 15 == timeout; Ergebnisse in MKVersion |
mode = 0; |
rxd_buffer_locked = FALSE; |
if( MKVersion.isNC ) |
{ |
MK_SwitchToNC(); // wieder auf NC umschalten als default |
} |
if( MKVersion.paramsetOK ) // FC Revision OK? |
{ |
set_beep( 25, 0xffff, BeepNormal ); // kurzer Beep (FC-Revision ok) |
if( showMKInfo ) MK_Info( 500, true ); // Anzeige von MK_Info() max. 5 Sekunden (mit Settings-Refresh) |
} |
else // FC Revision nicht unterstuetzt... |
{ |
set_beep( 1000, 0xffff, BeepNormal ); // langer Error-Beep (FC-Revision nicht unterstuetzt) |
if( showMKInfo ) MK_Info( 1600, true ); // Anzeige von MK_Info() max. 16 Sekunden (mit Settings-Refresh) |
} |
//timer = 50; |
//while (timer > 0); |
get_key_press(KEY_ALL); |
return RetVal; |
} // searchMK() |
//-------------------------------------------------------------- |
// chg = MK_Info( displaytimeout, refreshSettings ) |
// |
// Parameter: |
// displaytimeout : 0 = kein autom. Timeout |
// n = Anzeige verschwindet automatisch nach n Zeit |
// (bei z.B. n=600 nach 6 Sekunden) |
// |
// refreshSettings: true/false |
// true = in bestimmten Zeitintervallen (RELOAD_SETTING_TIME) |
// wird MK_Setting_load() durchgeführt um ggf. einen Kopterwechsel |
// automatisch zu erkennen. |
// Dazu muss MKINFO_AUTO_REFRESH in main.h eingeschaltet sein! |
// |
// Rueckgabe: |
// hardwarechange: true/false |
//-------------------------------------------------------------- |
uint8_t MK_Info( uint16_t displaytimeout, uint8_t refreshSettings ) |
{ |
uint8_t redraw; |
uint8_t old_isFC; |
uint8_t old_isNC; |
old_isFC = MKVersion.isFC; |
old_isNC = MKVersion.isNC; |
//displaytimeout = 0; |
if( displaytimeout ) |
timer = displaytimeout; |
#define RELOAD_SETTING_TIME 350 // alle 0.35 sec neue Settings vom MK laden |
timer_get_tidata = RELOAD_SETTING_TIME; // ich brauche weitere timer... und bediene mich jetzt mal bei einem osd-timer |
// (timer2 ist belegt von MK_Setting_load) |
//get_key_press(KEY_ALL); |
redraw = true; |
while( true ) |
{ |
//------------------------------------------ |
// Screen neu zeichnen |
//------------------------------------------ |
if( redraw ) |
{ |
if( redraw != 2 ) |
lcd_cls(); |
show_Lipo(); // LiPo direkt anzeigen damit es nicht flackert |
lcd_frect( 0, 0, 101, 8, 1); // Headline: Box fill Black mit Platz fuer PKT-LiPo rechts |
lcdx_printp_at( 1, 0, PSTR("MK Info"), MINVERS, 0,0); // Titel |
if( MKVersion.isFC || MKVersion.isNC ) // MK gefunden... |
{ |
lcd_frect_round( 0, 30, 127, 22, 1, R2); // Fill: Anzeigebereich der Settings in Schwarz |
//-------------------- |
// FC-Version |
//-------------------- |
lcdx_printp_at( 0, 2, PSTR("FC:") , MNORMAL, 4,-5); |
MKVersion_print_at( 4, 2, FC , MNORMAL, 2,-5); |
//-------------------- |
// FC-Revision |
//-------------------- |
lcdx_printp_at( 12, 2, PSTR("Rev:"), MNORMAL, 5,-5); |
lcdx_printf_at_P( 17, 2, MNORMAL, 2,-5, PSTR("%03u"), MKVersion.paramsetRevision ); |
if( !MKVersion.paramsetOK ) |
lcdx_printp_at( 11, 3, PSTR(" Rev-ERR!"), MINVERS, 5,-4); // Fehler FC-Revision (nicht vom PKT unterstuetzt) |
else |
lcd_frect( 11*6+5, 3*8-4, 9*6, 8, 0); // ggf. Fehleranzeige loeschen (nach refreshSettings) |
//-------------------- |
// NC-Version |
//-------------------- |
lcdx_printp_at( 0, 3, PSTR("NC:") , MNORMAL, 4,-3); |
MKVersion_print_at( 4, 3, NC , MNORMAL, 2,-3); |
//-------------------- |
// aktuelles Setting |
//-------------------- |
lcdx_printp_center( 4, PSTR("MK Setting"), MINVERS, 0,1); // "MK Setting" (zentriert) |
//lcdx_printp_at( 5, 4, PSTR("MK Setting"), MINVERS, 4,1); |
MKVersion_Setting_print( 5, MINVERS, 0,3); |
} |
else // else: if( MKVersion.isFC || MKVersion.isNC ) // KEINEN MK gefunden... |
{ |
//PKT_Message_P( *text, error, timeout, beep, clearscreen ) |
PKT_Message_P( strGet(NOMKFOUND), false, 0, true, false ); // FEHLER! nodata (max. 8 Sekunden anzeigen) |
} // end: if( MKVersion.isFC || MKVersion.isNC ) |
//lcd_printp_at( 19, 7, strGet(OK), MNORMAL); // Keyline |
lcd_printp_at(12, 7, strGet(ENDE), MNORMAL); // Keyline |
if( displaytimeout == 0 ) |
lcd_printp_at( 0, 7, PSTR("Refresh"), MNORMAL); // Keyline: Refresh |
redraw = false; |
} // end: if( redraw ) |
//------------------------------------------ |
// PKT-LiPo Anzeige |
//------------------------------------------ |
show_Lipo(); |
//------------------------ |
// Tasten abfragen |
//------------------------ |
if( get_key_press(1 << KEY_MINUS) && (displaytimeout == 0) ) |
{ |
searchMK( false ); // false = zeige nicht MK_Info() an |
redraw = true; |
} |
if( get_key_short(1 << KEY_ESC) ) |
{ |
break; |
} |
//------------------------------------------ |
// Pruefe PKT-Update oder andere PKT-Aktion |
//------------------------------------------ |
if( PKT_CtrlHook() ) // Update vom Updatetool angefordert? |
{ |
redraw = true; |
} |
//------------------------------------------ |
// displaytimeout? |
//------------------------------------------ |
if( displaytimeout && !timer ) |
{ |
break; |
} |
} // end: while( true ) |
get_key_press(KEY_ALL); |
return( (old_isFC != MKVersion.isFC) || (old_isNC != MKVersion.isNC) ); |
} // MK_Info() |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/PKT/GPL_PKT_V3_85f/mk/mkbase.h |
---|
0,0 → 1,143 |
/***************************************************************************** |
* Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* Copyright (C) 2012 Christian "Cebra" Brandtner, brandtner@brandtner.net * |
* Copyright (C) 2012 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* |
*****************************************************************************/ |
//############################################################################ |
//# HISTORY mkbase.h |
//# |
//# 14.05.2014 OG |
//# - chg: include "paramset.h" geaendert auf "../mksettings/paramset.h" |
//# |
//# 29.03.2014 OG |
//# - del: MK_Show_LastGPS_Position() -> jetzt: OSDDATA_ShowLastGPSPosition()/osddata.c |
//# |
//# 28.03.2014 OG |
//# - add: MK_Show_LastGPS_Position() - ehemals in main.c |
//# |
//# 16.02.2014 OG |
//# - add: MK_SwitchToNC(), MK_SwitchToFC(), MK_SwitchToMAG(), MK_SwitchToGPS() |
//# - add: MK_Setting_write(), MK_Setting_change() |
//# - chg: umbenannt: MK_load_setting() zu MK_Setting_load() |
//# |
//# 13.02.2014 OG |
//# - add: MKVersion_Cmp() |
//# - add: defines zu VERSION... fuer MKVersion_Cmp() |
//# - del: WrongFCVersion |
//# |
//# 10.02.2014 OG |
//# - add: MKVersion_Setting_print() |
//# |
//# 09.02.2014 OG |
//# - add: MK_Info() |
//# - add: MKVersion_print_at |
//# |
//# 08.02.2014 OG |
//# - chg: MK_load_setting() Parameter geaendert |
//# - add: extern MKVersion_t MKVersion |
//# |
//# 29.01.2014 OG |
//# - Ausgliederungen aus main.c |
//############################################################################ |
#ifndef _MKBASE_H |
#define _MKBASE_H |
//#include "../mksettings/paramset.h" |
#include "../mk-data-structs.h" |
//------------------------------------- |
//------------------------------------- |
typedef struct |
{ |
unsigned char isFC; // true / false - FC vorhanden? -> wird gesetzt durch searchMK() |
unsigned char isNC; // true / false - NC vorhanden? -> wird gesetzt durch searchMK() |
Version_t FCVer; // -> wird gesetzt durch searchMK() |
Version_t NCVer; // -> wird gesetzt durch searchMK() |
unsigned char paramsetOK; // true wenn Revision in paramset.c vorhanden und initialisiert -> wird gesetzt druch paramsetInit()/paramset.c |
unsigned char paramsetRevision; // Revision FC-Parameterset -> wird gesetzt druch paramsetInit()/paramset.c |
uint8_t mksetting; // -> wird gesetzt druch paramsetInit()/paramset.c |
unsigned char mksettingName[13]; // -> wird gesetzt druch paramsetInit()/paramset.c |
} MKVersion_t; |
//------------------------------------- |
// zur Orientierung: Version_t |
//------------------------------------- |
//typedef struct |
//{ |
// unsigned char SWMajor; |
// unsigned char SWMinor; |
// unsigned char ProtoMajor; |
// unsigned char ProtoMinor; |
// unsigned char SWPatch; |
// unsigned char HardwareError[5]; |
//} __attribute__((packed)) Version_t; |
//---------------------------- |
// MK-Versionsinformationen |
// global verfuegbar |
//---------------------------- |
extern MKVersion_t MKVersion; |
//------------------------------------------------------ |
// defines fuer den Versionsvergleich von FC/NC |
// siehe: MKVersion_Cmp()... (mkbase.c) |
//------------------------------------------------------ |
#define GIVEN_VERSION 2 // das macht die Sache leserlicher fuer resultierenden Ergebnisse! => siehe Anmerkungen: MKVersion_Cmp() ! |
#define VERSION_NO 0 |
#define VERSION_LOWER 1 |
#define VERSION_EQUAL 2 |
#define VERSION_GREATER 3 |
void MKVersion_Init( void ); |
void MKVersion_print_at( uint8_t x, uint8_t y, uint8_t what, uint8_t drawmode, int8_t xoffs, int8_t yoffs ); |
void MKVersion_Setting_print( uint8_t y, uint8_t drawmode, uint8_t xoffs, uint8_t yoffs ); |
uint8_t MKVersion_Cmp( Version_t ver, unsigned char SWMajor, unsigned char SWMinor, unsigned char SWPatch ); |
void MK_SwitchToNC( void ); |
void MK_SwitchToFC( void ); |
void MK_SwitchToMAG( void ); |
void MK_SwitchToGPS( void ); |
uint8_t MK_Setting_load( uint8_t lsetting, uint8_t timeout ); |
uint8_t MK_Setting_write( uint8_t wsetting, uint8_t timeout); |
uint8_t MK_Setting_change( uint8_t setting ); |
uint8_t MK_Info( uint16_t displaytimeout, uint8_t refreshSettings ); |
uint8_t searchMK( uint8_t showMKInfo ); |
#endif // end: #ifndef _MKBASE_H |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/PKT/GPL_PKT_V3_85f/mk/mkdebugdata.c |
---|
0,0 → 1,416 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
//############################################################################ |
//# HISTORY mkdebugdata.c |
//# |
//# 04.06.2014 OG |
//# komplett neues Layout |
//# - chg: MK_DebugData(), GetAnalogNames() umgestellt auf PKT_Message_Datenverlust() |
//# - chg: GetAnalogNames() Timeout reduziert |
//# - add: #include "../lipo/lipo.h" |
//# - add: #include "../pkt/pkt.h" |
//# - add: #include <stdbool.h> |
//# |
//# 29.01.2014 OG |
//# - chg: ehemals display_debug() jetzt MK_DebugData() |
//# - chg: ehemals 'debug.c' jetzt 'mk/mkdebugdata.c' |
//# |
//# 03.04.2013 OG |
//# - chg: define 'analognames' zu define 'USE_MKDEBUGDATA' |
//# - add: Benutzer kann GetAnalogNames() via KEY_ESC abbrechen |
//# - chg: Screen-Layout GetAnalogNames() |
//# - chg: SwitchToNC/FC Reihenfolge |
//# |
//# 27.03.2013 OG |
//# - chg: auf malloc umgestellt |
//# - fix: diverse Anzeigefehler |
//# - chg: teilweise redunten Code entfernt |
//############################################################################ |
#include "../cpu.h" |
#include <avr/io.h> |
#include <stdlib.h> |
#include <avr/pgmspace.h> |
#include <util/delay.h> |
#include <stdbool.h> |
#include <string.h> |
#include "../main.h" |
#ifdef USE_MKDEBUGDATA |
#include "../lcd/lcd.h" |
#include "../pkt/pkt.h" |
#include "../lipo/lipo.h" |
#include "../uart/usart.h" |
#include "mkdebugdata.h" |
#include "../timer/timer.h" |
#include "../messages.h" |
#include "../mk-data-structs.h" |
//-------------------------------------------------------------- |
#define PAGELINES 5 // Anzahl der Zeilen pro Anzeigescreens |
#define XOFFS 4 |
#define YOFFS 12 |
#define TIMEOUT 200 // 2 sec |
#define ANALOGTIME 20 // 200 ms |
#define MKDD_ANALOGNAME_SIZE 2*32*17 // MALLOC: 32 names, 16 characters + 1 0x00 |
// WARNING: this work for NC & FC only |
// if current_hardware == MK3MAG or MKGPS the access is outside of the array... |
//uint8_t AnalogNames[2][32][16 + 1]; // 32 names, 16 characters + 1 0x00 |
uint8_t *AnalogNames; // MALLOC: MKDD_ANALOGNAME_SIZE - 32 names, 16 characters + 1 0x00 |
uint8_t AnalogNamesRead[2] = {0,0}; |
static const char strFC[] PROGMEM = "FC"; |
static const char strNC[] PROGMEM = "NC"; |
//-------------------------------------------------------------- |
// Speicher wieder freigeben |
//-------------------------------------------------------------- |
void MKDD_MemFree( void ) |
{ |
free( AnalogNames ); |
} |
//-------------------------------------------------------------- |
//-------------------------------------------------------------- |
void showTitle( void ) |
{ |
lcdx_printf_at_P( 0, 0, MINVERS, 0,0, PSTR(" %2S %16S"), (current_hardware==FC ? strFC : strNC), strGet(STR_DATA) ); // Titelzeile |
show_Lipo(); |
} |
//-------------------------------------------------------------- |
// lOk = GetAnalogNames() |
// |
// Return: |
// true = OK |
// false = User-Abort (KEY_ESC) |
//-------------------------------------------------------------- |
uint8_t GetAnalogNames( void ) |
{ |
uint8_t i = AnalogNamesRead[current_hardware - 1]; |
uint8_t t = 0; |
uint8_t lOk = TRUE; |
int8_t yoffs = -2; // yoffs der Progress-Bar |
lcd_cls (); |
showTitle(); // Titel |
lcdx_printf_center_P( 3, MNORMAL, 0,0, PSTR("%S %S %S"), strGet(STR_READING), (current_hardware==FC ? strFC : strNC), strGet(STR_LABELS) ); |
lcd_rect_round( 13, 40+yoffs, 102, 6, 1, R1); // Rahmen fuer Progress |
lcd_printp_at(12, 7, strGet(ENDE), MNORMAL); // Keyline |
mode = 'A'; // read Names |
_delay_ms(200); |
rxd_buffer_locked = FALSE; |
timer = ANALOGTIME; |
while( (i < 32) && lOk ) |
{ |
SendOutData ('a', ADDRESS_ANY, 1, &i, 1); |
while( !rxd_buffer_locked && timer && lOk) |
lOk = !get_key_press (1 << KEY_ESC); |
if( timer ) |
{ |
Decode64 (); |
if( i == *pRxData ) |
{ |
lcd_frect( 16, 42+yoffs, (i+1)*3, 2, 1); // Progress |
memcpy( (uint8_t *) (AnalogNames+((current_hardware-1)*32*17)+(i*17)), (uint8_t *) pRxData + 1, 16); |
*(AnalogNames+((current_hardware-1)*32*17)+(i*17)+16) = 0; |
i++; |
t = 0; |
} |
else |
{ |
_delay_ms(100); |
} |
timer = ANALOGTIME; |
rxd_buffer_locked = FALSE; |
} |
else if( lOk ) |
{ // timeout occured |
t++; |
timer = ANALOGTIME; |
if( t >= 15 ) // timeout? |
{ |
//PKT_Message_Datenverlust( timeout, beep) |
PKT_Message_Datenverlust( 500, true); // 500 = 5 Sekunden |
break; |
} |
} |
else |
{ |
lOk = !get_key_press( 1 << KEY_ESC ); |
} |
} |
if(lOk) AnalogNamesRead[current_hardware - 1] = i; |
//_delay_ms(4000); // DEBUG |
return lOk; |
} |
//-------------------------------------------------------------- |
//-------------------------------------------------------------- |
void showLabels( uint8_t page) |
{ |
uint8_t i = 0; |
for( i = 0; i < PAGELINES; i++ ) |
{ |
if( (i + (page * PAGELINES)) >= 32 ) |
{ |
//lcdx_cls_rowwidth( y, width, mode, xoffs, yoffs ) |
lcdx_cls_rowwidth( i, 20, MNORMAL, XOFFS,YOFFS ); |
} |
else |
{ |
lcdx_print_at( 0, i, AnalogNames+((current_hardware-1)*32*17)+(i + page * PAGELINES)*17, MNORMAL, XOFFS,YOFFS); |
} |
} |
} |
//-------------------------------------------------------------- |
// |
//-------------------------------------------------------------- |
void MK_DebugData(void) |
{ |
uint8_t tmp_dat; |
uint8_t i = 0; |
uint8_t page = 0; |
uint8_t pagemax = (32/PAGELINES); |
uint8_t redraw = 2; |
DebugData_t *DebugData; |
// alloc ram |
AnalogNames = malloc( MKDD_ANALOGNAME_SIZE ); |
if( !AnalogNames ) |
{ |
Show_PKTError_NoRAM(); |
return; |
} |
memset( AnalogNames, 0, MKDD_ANALOGNAME_SIZE ); // init: AnalogNames |
AnalogNamesRead[0] = 0; |
AnalogNamesRead[1] = 0; |
SwitchToFC(); |
timer = TIMEOUT; |
if( AnalogNamesRead[current_hardware - 1] < 32 ) |
{ |
if( !GetAnalogNames() ) |
{ |
MKDD_MemFree(); |
return; |
} |
} |
if( !timer ) |
{ |
MKDD_MemFree(); |
return; |
} |
mode = 'D'; // Debug Data |
rxd_buffer_locked = FALSE; |
timer = TIMEOUT; |
timer1 = 0; |
tmp_dat = 10; |
SendOutData( 'd', ADDRESS_ANY, 1, &tmp_dat, 1); |
abo_timer = ABO_TIMEOUT; |
do |
{ |
//------------------------------------------ |
//------------------------------------------ |
if( redraw ) |
{ |
if( redraw==2 ) lcd_cls(); |
showTitle(); // Titelzeile |
lcd_rect_round( 0, (1*8)+1, 127, (6*8)-4, 1, R2); // Rahmen fuer 5 Zeilen Display |
showLabels( page ); |
lcd_printp_at( 0, 7, strGet(KEYLINE3), 0); |
lcd_write_number_u_at (5, 7, page + 1); |
lcd_printp_at( (current_hardware==FC ? 3 : 19), 7, strFC, 0); |
lcd_printp_at( (current_hardware==FC ? 19 : 3), 7, strNC, 0); |
redraw = false; |
} |
if( rxd_buffer_locked ) |
{ |
Decode64(); |
DebugData = (DebugData_t *) pRxData; |
if( !timer1 ) |
{ |
for( i = 0; i < PAGELINES && (i + (page * PAGELINES)) < 32; i++) |
{ |
writex_ndigit_number_s( 21-6, i, DebugData->Analog[i + page * PAGELINES], 5, 0, MNORMAL, XOFFS,YOFFS); |
} |
timer1 = 25; // Anzeigeverzoegerung damit es nicht flackert |
} |
rxd_buffer_locked = FALSE; |
timer = TIMEOUT; |
} |
if( !abo_timer ) |
{ // renew abo every ... sec |
tmp_dat = 10; |
SendOutData( 'd', ADDRESS_ANY, 1, &tmp_dat, 1); |
abo_timer = ABO_TIMEOUT; |
} |
//------------------------------------------ |
// PKT LiPo anzeigen |
//------------------------------------------ |
show_Lipo(); |
//------------------------------------------ |
// Pruefe PKT Update oder andere PKT-Aktion |
//------------------------------------------ |
if( PKT_CtrlHook() ) // Update vom Updatetool angefordert? |
{ |
redraw = 2; |
timer = TIMEOUT; |
} |
//------------------------------------------ |
// Tasten |
//------------------------------------------ |
if( get_key_press(1 << KEY_MINUS) ) |
{ |
page--; |
if( page > pagemax ) page = pagemax; |
redraw = true; |
} |
if( get_key_press(1 << KEY_PLUS) ) |
{ |
page++; |
if( page > pagemax ) page = 0; |
redraw = true; |
} |
if( (hardware == NC) && get_key_press (1 << KEY_ENTER) ) |
{ |
if( current_hardware == NC ) SwitchToFC(); |
else SwitchToNC(); |
if( AnalogNamesRead[current_hardware - 1] < 32 ) |
{ |
if( !GetAnalogNames() ) |
{ |
MKDD_MemFree(); |
return; |
} |
} |
mode = 'D'; // Debug Data |
rxd_buffer_locked = FALSE; |
timer = TIMEOUT; |
tmp_dat = 10; |
SendOutData ('d', ADDRESS_ANY, 1, &tmp_dat, 1); |
//page = 0; |
redraw = true; |
} |
} |
while (!get_key_press(1 << KEY_ESC) && timer); // Taste: Ende oder Timeout |
clear_key_all(); |
tmp_dat = 0; |
SendOutData ('d', ADDRESS_ANY, 1, &tmp_dat, 1); // Request Debugdata abschalten |
mode = 0; |
rxd_buffer_locked = FALSE; |
if( !timer ) |
{ // timeout occured |
//PKT_Message_Datenverlust( timeout, beep) |
PKT_Message_Datenverlust( 500, true); // 500 = 5 Sekunden |
} |
//SwitchToNC(); |
// free ram |
MKDD_MemFree(); |
} |
#endif // end: #ifdef USE_MKDEBUGDATA |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/PKT/GPL_PKT_V3_85f/mk/mkdebugdata.h |
---|
0,0 → 1,51 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
//############################################################################ |
//# HISTORY mkdebugdata.h |
//# |
//# 29.01.2014 OG |
//# - chg: ehemals display_debug() jetzt MK_DebugData() |
//# - chg: ehemals 'debug.h' jetzt 'mk/mkdebugdata.h' |
//# - add: Source-History ergaenzt |
//############################################################################ |
#ifndef _MKDEBUGDATA_H |
#define _MKDEBUGDATA_H |
extern uint8_t AnalogNamesRead[2]; |
void MK_DebugData(void); |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/PKT/GPL_PKT_V3_85f/mk/mkdisplay.c |
---|
0,0 → 1,267 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
//############################################################################ |
//# HISTORY mkdisplay.c |
//# |
//# |
//# 05.04.2015 Cebra |
//# - chg: SendOutData( 'h', ADDRESS_ANY, 2, &cmd, 1, 0x00 ,1) ergänzt um 2. Parameter wegen Fehlfunktion mit NC 2.09h |
//# |
//# 04.06.2014 OG |
//# - chg: MK_Display() umgestellt auf PKT_Message_Datenverlust() |
//# |
//# 31.05.2014 OG |
//# - chg: MK_Display() - umgestellt auf PKT_KeylineUpDown() |
//# |
//# 28.04.2014 OG |
//# - chg: MK_Display() - leichte Optimierung der Display-Ausgabe um ein paar |
//# Bytes Code zu sparen |
//# |
//# 09.04.2014 OG - vervollstaendigte Steuerung des MK-Display's |
//# - chg: die Tasten fuer 'Ende' und NC/FC-Umschaltung muessen jetzt lange |
//# gedruekckt werden (get_key_long) - keine Beschriftung mehr dafuer |
//# vorhanden da die Beschriftung jetzt hoch/runter zeigt! |
//# (aber 'Ende' ist da wo es immer im PKT ist) |
//# - add: Unterstuetzung der hoch/runter Tasten |
//# - chg: diverse Aenderungen bei der Kommunkation und Einbindung aktueller |
//# Funktionen von mkbase.c |
//# |
//# 29.01.2014 OG |
//# - chg: ehemals display_data() jetzt MK_display() |
//# - chg: ehemals 'display.c' jetzt 'mk/mkdisplay.c' |
//# |
//# 25.01.2014 OG |
//# - optisches Facelift |
//# - PKT_CtrlHook() eingeklinkt |
//# - Versionshistorie hinzugefuegt |
//############################################################################ |
#include "../cpu.h" |
#include <avr/io.h> |
#include <avr/pgmspace.h> |
#include <util/delay.h> |
#include <stdbool.h> |
#include "../main.h" |
#include "../lcd/lcd.h" |
#include "../uart/usart.h" |
#include "../timer/timer.h" |
#include "../messages.h" |
#include "../lipo/lipo.h" |
#include "../pkt/pkt.h" |
#include "../mk-data-structs.h" |
#include "mkbase.h" |
#include "mkdisplay.h" |
#define TIMEOUT 500 // 5 sec |
uint8_t ACC_Display=false; |
//-------------------------------------------------------------- |
//-------------------------------------------------------------- |
void MK_Display(void) |
{ |
uint8_t cmd; |
uint8_t redraw = true; |
uint8_t exit = false; |
mode = 'H'; |
rxd_buffer_locked = FALSE; |
timer = TIMEOUT; |
// cmd = 0xfc; // Home = first page |
cmd = 0xff; // aktuelle Seite |
redraw = true; |
MK_SwitchToFC(); // add 31.3.2014 Cebra, definierter Zustand |
if (ACC_Display==true) |
{ |
cmd = 0x06; |
SendOutData( 'l', ADDRESS_ANY, 1, &cmd,1); |
cmd = 0xff; |
if( rxd_buffer_locked ) |
{ |
Decode64 (); |
//------------------------------------------ |
// RX-Buffer freigeben |
//------------------------------------------ |
rxd_buffer_locked = FALSE; |
timer = TIMEOUT; |
} // end: if( rxd_buffer_locked ) |
// _delay_ms(250); |
} |
do |
{ |
//------------------------------------------ |
// Screen neu zeichnen |
//------------------------------------------ |
if( redraw ) |
{ |
ShowTitle_P( ( current_hardware == NC ? PSTR("NC") : PSTR("FC") ), true ); |
lcd_printp_at( 4, 0, PSTR("Display"), MINVERS); |
lcd_rect_round( 0, 2*7-3, 127, 5*7+3+3, 1, R2); // Rahmen |
lcdx_printp_at( 2, 7, PSTR("\x18 \x19"), MNORMAL, 0,0); // Keyline: Links / Rechts |
PKT_KeylineUpDown( 18, 13, 0,0); // Keyline: Down / Up |
redraw = false; |
} |
show_Lipo(); |
SendOutData( 'h', ADDRESS_ANY, 2, &cmd, 1, 0x00 ,1); // 05.04.2015 Cebra, 2.er Parameter wg NC 2.09i |
cmd = 0xff; |
_delay_ms(250); |
if( rxd_buffer_locked ) |
{ |
Decode64 (); |
//------------------------------------------ |
// Ausgabe auf PKT-Anzeige |
// 4 Zeilen a 20 Zeichen |
// (Anzeige von unten nach oben) |
//------------------------------------------ |
rxd_buffer[83] = 0; |
lcdx_print_at( 0,5, (uint8_t *) &rxd_buffer[3+60], MNORMAL, 5,2); |
rxd_buffer[63] = 0; |
lcdx_print_at( 0,4, (uint8_t *) &rxd_buffer[3+40], MNORMAL, 5,1); |
rxd_buffer[43] = 0; |
lcdx_print_at( 0,3, (uint8_t *) &rxd_buffer[3+20], MNORMAL, 5,0); |
rxd_buffer[23] = 0; |
lcdx_print_at( 0,2, (uint8_t *) &rxd_buffer[3+ 0], MNORMAL, 5,-1); |
//------------------------------------------ |
// RX-Buffer freigeben |
//------------------------------------------ |
rxd_buffer_locked = FALSE; |
timer = TIMEOUT; |
} // end: if( rxd_buffer_locked ) |
//------------------------------------------ |
// Pruefe PKT Update oder andere PKT-Aktion |
//------------------------------------------ |
if( PKT_CtrlHook() ) // Update vom Updatetool angefordert? |
{ |
redraw = true; |
} |
if( get_key_press(1 << KEY_MINUS) || get_key_long_rpt_sp((1 << KEY_MINUS),2) ) |
{ |
cmd = 0xfe; // key: rechts (next page) |
} |
if( get_key_press(1 << KEY_PLUS) || get_key_long_rpt_sp((1 << KEY_PLUS),2) ) |
{ |
cmd = 0xfd; // key: links (previous page) |
} |
if( get_key_short(1 << KEY_ESC) ) |
{ |
cmd = 0xfb; // key: runter |
} |
if( get_key_short(1 << KEY_ENTER) ) |
{ |
cmd = 0xf7; // key: hoch |
} |
if( (hardware == NC) && get_key_long(1 << KEY_ENTER) ) |
{ |
set_beep( 25, 0xffff, BeepNormal ); // kurzer Bestaetigungs-Beep |
if( current_hardware == NC ) |
{ |
MK_SwitchToFC(); |
redraw = true; |
} |
else |
{ |
MK_SwitchToNC(); |
MK_SwitchToNC(); |
redraw = true; |
} |
// cmd = 0xff; |
timer2 = 50; |
while( timer2 > 0 ); |
} |
if( get_key_long(1 << KEY_ESC) ) |
{ |
set_beep( 25, 0xffff, BeepNormal ); // kurzer Bestaetigungs-Beep |
exit = true; |
} |
} |
while( (!exit) && timer ); |
mode = 0; |
rxd_buffer_locked = FALSE; |
//------------------------------------------ |
// Timeout? |
//------------------------------------------ |
if( !timer ) |
{ // timeout occured |
//PKT_Message_Datenverlust( timeout, beep) |
PKT_Message_Datenverlust( 500, true); // 500 = 5 Sekunden |
} |
clear_key_all(); |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/PKT/GPL_PKT_V3_85f/mk/mkdisplay.h |
---|
0,0 → 1,53 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
//############################################################################ |
//# HISTORY mkdisplay.h |
//# |
//# 29.01.2014 OG |
//# - chg: ehemals display_data() jetzt MK_display() |
//# - chg: ehemals 'display.h' jetzt 'mk/mkdisplay.h' |
//# - add: Source-History ergaenzt |
//############################################################################ |
#ifndef _DISPLAY_H |
#define _DISPLAY_H |
extern uint8_t ACC_Display; |
void MK_Display(void); |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/PKT/GPL_PKT_V3_85f/mk/mkgpsinfo.c |
---|
0,0 → 1,425 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
//############################################################################ |
//# HISTORY mkgpsinfo.c |
//# |
//# 04.06.2014 OG |
//# - chg: MK_Gps_Info() umgestellt auf PKT_Message_Datenverlust() |
//# |
//# 14.05.2014 OG |
//# - chg: Code-Redesign; neues Screen-Layout; Code-Reduzierung; |
//# Anpassungen an neue PKT-Funktionen |
//# - chg: umbenannt von 'gps.c' zu 'mkgpsinfo.c' |
//# - chg: gps() ist jetzt MK_Gps_Info() |
//# - add: Source-Historie ergaenzt |
//############################################################################ |
#include <avr/io.h> |
#include <inttypes.h> |
#include <stdlib.h> |
#include <avr/pgmspace.h> |
#include <stdbool.h> |
#include <util/delay.h> |
#include "../main.h" |
#include "../lcd/lcd.h" |
#include "../timer/timer.h" |
#include "../uart/usart.h" |
#include "../lipo/lipo.h" |
#include "../pkt/pkt.h" |
#include "../mk/mkbase.h" |
#include "../messages.h" |
//############################################################## |
//############################################################## |
//#define DEBUG_MKGPS // erweiterte Anzeigen zum debuggen |
#define GPSTIMEOUT 300 // 3 Sekunden |
#define UBX_BUFFER_SIZE 100 // 100 Byte Buffer fuer GPS-Daten |
uint8_t ck_a = 0; |
uint8_t ck_b = 0; |
union long_union |
{ |
uint32_t dword; |
uint8_t byte[4]; |
} longUnion; |
union int_union |
{ |
uint16_t dword; |
uint8_t byte[2]; |
} intUnion; |
//############################################################## |
//############################################################## |
//-------------------------------------------------------------- |
//-------------------------------------------------------------- |
uint32_t join_4_bytes(uint8_t Buffer[]) |
{ |
longUnion.byte[0] = *Buffer; |
longUnion.byte[1] = *(Buffer+1); |
longUnion.byte[2] = *(Buffer+2); |
longUnion.byte[3] = *(Buffer+3); |
return (longUnion.dword); |
} |
//-------------------------------------------------------------- |
//-------------------------------------------------------------- |
void checksum(uint8_t data) |
{ |
ck_a += data; |
ck_b += ck_a; |
} |
//-------------------------------------------------------------- |
//-------------------------------------------------------------- |
void MK_Gps_Info( void ) |
{ |
uint8_t UBX_buffer[UBX_BUFFER_SIZE]; |
uint8_t UBX_payload_counter = 0; |
uint8_t UBX_class = 0; |
uint8_t UBX_id = 0; |
uint8_t UBX_ck_a = 0; |
uint8_t data = 0; |
uint8_t length = 0; |
uint8_t state = 0; |
uint8_t redraw = true; |
uint8_t refresh = false; |
uint8_t yoffs = 1; // Anzeige-Verschiebung: der obere Bereich |
uint8_t yoffs2 = 4; // Anzeige-Verschiebung: GPS-Koordinaten |
int16_t v_16; // tmp-Variable |
int32_t v_32; // tmp-Variable |
#ifdef DEBUG_MKGPS |
uint8_t maxlen = 0; |
#endif |
MK_SwitchToNC(); // Anmerkung OG: warum auch immer es besser ist erst auf die NC |
MK_SwitchToGPS(); // umzuschalten... es laeuft so scheinbar zuverlaessiger |
MK_SwitchToGPS(); |
timer_mk_timeout = GPSTIMEOUT; |
do |
{ |
//------------------------ |
// REDRAW |
//------------------------ |
if( redraw ) |
{ |
ShowTitle_P( PSTR("MK GPS Info"), true); |
lcdx_printp_at( 0,1, PSTR("Fix:"), MNORMAL, 0,yoffs ); |
lcdx_printp_at( 0,2, PSTR("Sat:"), MNORMAL, 0,yoffs ); |
lcdx_printp_at( 0,3, PSTR("Alt:"), MNORMAL, 0,yoffs ); |
lcdx_printp_at( 9,1, PSTR("PDOP:"), MNORMAL, 3,yoffs ); |
lcdx_printp_at( 9,2, PSTR("Accu:"), MNORMAL, 3,yoffs ); |
lcdx_printp_at( 9,3, PSTR("Sped:"), MNORMAL, 3,yoffs ); |
lcd_frect( 0, (4*7)+4+yoffs2, 127, 7, 1); // GPS: Rect: Invers |
lcdx_printp_at(1, 3, strGet(START_LASTPOS1), MINVERS, 0,8+yoffs2); // GPS: "Breitengr Längengr" |
lcd_rect( 0, (3*8)+7+yoffs2, 127, (2*8)+4, 1); // GPS: Rahmen |
lcdx_printp_at(12,7, strGet(ENDE), MNORMAL, 0,1); // KEYLINE |
redraw = false; |
} |
//------------------------ |
// REFRESH |
//------------------------ |
if( refresh ) |
{ |
if((UBX_class == 1) && (UBX_id == 6)) // GPS: SVINFO |
{ |
//-------------- |
// GPS Status |
//-------------- |
switch( UBX_buffer[10] ) |
{ |
case 4: |
case 3: lcdx_printp_at( 5, 1, PSTR("3D"), MNORMAL, 1,yoffs); break; |
case 2: lcdx_printp_at( 5, 1, PSTR("2D"), MNORMAL, 1,yoffs); break; |
default: lcdx_printp_at( 5, 1, PSTR("no"), MNORMAL, 1,yoffs); |
} |
// GPS ok => ein Haken wird angezeigt |
if( (UBX_buffer[11] & 1) == 1 ) lcdx_putc( 7, 1, SYMBOL_CHECK, MNORMAL, 3,yoffs ); |
else lcdx_putc( 7, 1, ' ', MNORMAL, 3,yoffs ); |
//--- |
// Anzeige von "D" - evtl. DGPS (Differential GPS)? |
// aktuell nicht mehr unterstuetzt da kein Platz auf dem Screen |
//--- |
//if( (UBX_buffer[11] & 3) == 3 ) lcd_printp_at (10,0, PSTR("D"), 0); |
//else lcd_printp_at (10,0, PSTR(" "), 0); |
//-------------- |
// Sat |
//-------------- |
lcdx_printf_at_P( 5, 2, MNORMAL, 0,yoffs, PSTR("%2u"), UBX_buffer[47] ); |
//-------------- |
// PDOP |
//-------------- |
v_16 = UBX_buffer[44]+UBX_buffer[45]*255; |
lcdx_printf_at_P( 15, 1, MNORMAL, 0,yoffs, PSTR("%2.2d"), v_16 ); |
//-------------- |
// Accuracy |
//-------------- |
v_32 = (int32_t)join_4_bytes(&UBX_buffer[24]); |
lcdx_printf_at_P( 15, 2, MNORMAL, 0,yoffs, PSTR("%2.2ldm"), v_32 ); |
} |
if((UBX_class == 1) && (UBX_id == 18)) // GPS: VELNED |
{ |
//-------------- |
// Speed |
//-------------- |
v_16 = (int16_t)((join_4_bytes(&UBX_buffer[20])*60*60)/100000); |
lcdx_printf_at_P( 15, 3, MNORMAL, 0,yoffs, PSTR("%3dkmH"), v_16 ); |
//uint16_t speed = (uint16_t)((join_4_bytes(&UBX_buffer[20])*60*60)/100000); |
//write_ndigit_number_u (11, 4, speed, 3, 0,0); |
//lcd_printp_at (15,4, PSTR("km/h"), 0); |
} |
if((UBX_class == 1) && (UBX_id == 2)) // GPS: POSLLH |
{ |
//-------------- |
// Altitude |
//-------------- |
v_16 = (int16_t)(join_4_bytes(&UBX_buffer[16])/1000); |
//v_16 = v_16 + 3000; |
lcdx_printf_at_P( 4, 3, MNORMAL, 1,yoffs, PSTR("%4d"), v_16 ); |
//uint16_t height = (uint16_t)(join_4_bytes(&UBX_buffer[16])/1000); |
//write_ndigit_number_u (11, 7, height, 4, 0,0); |
//lcd_printp_at(16,7, PSTR("m"), 0); |
//-------------- |
// Breitengrad - Lat (51.) |
//-------------- |
v_32 = join_4_bytes(&UBX_buffer[8]); |
writex_gpspos( 1, 4, v_32 , MNORMAL, 0,10+yoffs2); // Anzeige: Breitengrad |
//write_ndigit_number_u ( 0, 7, (uint16_t)(lat/10000000), 2, 0,0); |
//lcd_printp_at ( 2, 7, PSTR("."), 0); |
//write_ndigit_number_u ( 3, 7, (uint16_t)((lat/1000) % 10000), 4, 1,0); |
//write_ndigit_number_u ( 7, 7, (uint16_t)((lat/10) % 100), 2, 1,0); |
//-------------- |
// Laengengrad - Long (7.) |
//-------------- |
v_32 = join_4_bytes(&UBX_buffer[4]); |
writex_gpspos( 12, 4, v_32, MNORMAL, -1,10+yoffs2); // Anzeige: Laengengrad |
//write_ndigit_number_u (10, 7, (uint16_t)(lon/10000000), 2, 0,0); |
//lcd_printp_at (12, 7, PSTR("."), 0); |
//write_ndigit_number_u (13, 7, (uint16_t)((lon/1000) % 10000), 4, 1,0); |
//write_ndigit_number_u (17, 7, (uint16_t)((lon/10) % 100), 2, 1,0); |
} |
//------------------------ |
// PKT-LiPo Anzeige |
//------------------------ |
show_Lipo(); |
refresh = false; |
} // end: if( refresh ) |
//-------------------------- |
// PROCESS DATA |
//-------------------------- |
if( uart_getc_nb( &data ) ) |
{ |
switch( state ) |
{ |
case 0: if( data == 0xB5 ) // GPS: init 1 |
{ |
UBX_payload_counter = 0; |
UBX_id = 0; |
UBX_class = 0; |
ck_a = 0; |
ck_b = 0; |
state++; |
} |
break; |
case 1: if( data == 0x62 ) // GPS: init 2 |
state++; |
else |
state = 0; |
break; |
case 2: if( data != 1 ) // GPS: class |
state = 0; |
else |
{ |
checksum(data); |
UBX_class = data; |
state++; |
} |
break; |
case 3: if( (data != 48) // GPS: id |
&&(data != 6 ) |
&&(data != 18) |
&&(data != 2 )) |
{ |
state = 0; |
} |
else |
{ |
UBX_id = data; |
checksum(data); |
state++; |
} |
break; |
case 4: if( data >= UBX_BUFFER_SIZE ) // GPS: length lo |
state = 0; |
else |
{ |
checksum(data); |
length = data; |
state++; |
} |
#ifdef DEBUG_MKGPS |
// DEBUG - Anzeige der Paketgroesse |
if( data > maxlen ) |
{ |
// groesstes gemessenes Paket lag bei 181 |
// ob man das Paket braucht ist eine andere Frage |
maxlen = data; |
lcdx_printf_at_P( 1, 7, MNORMAL, 0,1, PSTR("%3u"), maxlen ); |
set_beep( 25, 0xffff, BeepNormal ); // kurzer Beep |
} |
#endif |
break; |
case 5: if( data != 0 ) // GPS: length hi |
state = 0; |
else |
{ |
checksum(data); |
state++; |
} |
break; |
case 6: UBX_buffer[UBX_payload_counter] = data; // GPS: data |
checksum(data); |
UBX_payload_counter++; |
length--; |
if( length == 0 ) |
{ |
state++; |
}; |
break; |
case 7: state++; // GPS: check lo |
UBX_ck_a = data; |
break; |
case 8: state = 0; // GPS: check hi |
if((UBX_ck_a == ck_a) && (data == ck_b)) |
{ |
timer_mk_timeout = GPSTIMEOUT; |
refresh = true; |
} |
} // end: switch( state ) |
} // end: if( uart_getc_nb(&data) ) |
//------------------------------------------ |
// Pruefe PKT-Update oder andere PKT-Aktion |
//------------------------------------------ |
/* |
// funktioniert hier nicht - warum auch immer |
if( PKT_CtrlHook() ) // Update vom Updatetool angefordert? |
{ |
redraw = true; |
} |
*/ |
} while( !get_key_press(1 << KEY_ESC) && timer_mk_timeout ); |
//-------------------------- |
// in den Timeout gelaufen? |
//-------------------------- |
if( !timer_mk_timeout ) |
{ |
//PKT_Message_Datenverlust( timeout, beep) |
PKT_Message_Datenverlust( 500, true); // 500 = 5 Sekunden |
} |
clear_key_all(); |
SwitchToNC(); |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/PKT/GPL_PKT_V3_85f/mk/mkgpsinfo.h |
---|
0,0 → 1,50 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
//############################################################################ |
//# HISTORY mkgpsinfo.h |
//# |
//# 14.05.2014 OG |
//# - chg: umbenannt von 'gps.h' zu 'mkgpsinfo.h' |
//# - chg: gps() ist jetzt MK_Gps_Info() |
//# - add: Source-Historie ergaenzt |
//############################################################################ |
#ifndef _GPS_H |
#define _GPS_H |
void MK_Gps_Info( void ); |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/PKT/GPL_PKT_V3_85f/mk/. |
---|
Property changes: |
Added: svn:ignore |
+_old_source |