Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 1733 → Rev 1734

/Transportables_Koptertool/branch/PKT_V363a_V088n_MartinR/setup.c
0,0 → 1,2939
/*****************************************************************************
* 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/interrupt.h>
#include <avr/pgmspace.h>
#include <string.h>
#include <util/delay.h>
#include "main.h"
#include "setup.h"
#include "lcd.h"
#include "eeprom.h"
#include "timer.h"
#include "menu.h"
#include "Wi232.h"
#include "bluetooth.h"
#include "connect.h"
#include "lipo.h"
#include "messages.h"
#include "eeprom.h"
#include "tracking.h"
#include "bluetooth.h"
#include "uart1.h"
 
 
 
uint8_t spalte;
uint8_t mmode;
uint8_t edit;
uint8_t LCD_Orientation;
uint8_t edit = 0;
uint8_t LCD_Change = 0;
uint8_t PKT_Change = 0;
uint16_t Pre;
uint16_t Pre16;
char EditString[21];
uint8_t bt_name_len;
uint8_t length_tmp;
 
//--------------------------------------------------------------
#define ITEMS_PKT 12
 
prog_char param_menuitems_pkt[ITEMS_PKT][NUM_LANG][18]= // zeilen,zeichen+1
// German, English, French, Dutch
{
{"Verbindung zum MK","connection to MK "," connexion a MK " ,"Aansluiting op MK"},
{"Anzeige \x1d","Display \x1d","d'affichage \x1d","Display \x1d"},
{"Wi.232 \x1d","Wi.232 \x1d","Wi.232 \x1d","Wi.232 \x1d"},
{"BTM-222 \x1d","BTM-222 \x1d","BTM-222 \x1d","BTM-222 \x1d"},
{"Antennen Track. \x1d","antenna tracking\x1d","antenna tracking\x1d","antenna tracking\x1d"},
{"OSD Anzeige \x1d","OSD screen \x1d","OSD screen \x1d","OSD screen \x1d"},
{"GPS \x1d","GPS \x1d","GPS \x1d","GPS \x1d"},
{"Follow Me \x1d","Follow Me \x1d","Follow Me \x1d","Follow Me \x1d"},
{"PKT-Akku \x1d","PKT-Accu \x1d","PKT-Accu \x1d","PKT-Accu \x1d"},
{"PKT Update ","PKT Update ","PKT Mise a jour ","PKT Update "},
{"Debug PKT ","Debug PKT ","Debug PKT ","Debug PKT "},
{"EEProm Reset ","EEProm Reset ","EEProm Reinitiali","EEProm Reset "},
};
 
#define ITEMS_LCD 8
 
prog_char param_menuitems_lcd[ITEMS_LCD][NUM_LANG][18]= // zeilen,zeichen+1
// German, English, French, Dutch
{
{"Infos beim Start ","info at startup ","Infor. sur lancer","info bij opstart "},
{"OSD Empfangsausf.","OSD receive Error","OSD receive Error","OSD receive Error"},
{"Sprache ","language ","Langue ","taal "},
{"Licht aus nach...","light off after ","Lumiere au bout ","licht uit na "},
{"Helligkeit ","brightness ","luminosite ","helderheid "},
{"Kontrast ","contrast ","contraste ","contrast "},
{"Normal/Invers ","normal/inverted ","Normal / inverse ","Normal/inverted "},
{"Orientierung ","orientation ","orientation ","orientatie "},
 
};
 
#define ITEMS_WI 9
 
prog_char param_menuitems_wi[ITEMS_WI][NUM_LANG][18]= // zeilen,zeichen+1
// German, English, French, Dutch
{
{"Modul eingebaut? ","module built in? ","Module installe ","Module geinstal.?"},
{"TX/RX Kanal ","TX/RX Channel ","TX/RX Channel ","TX/RX Channel "},
{"NetW. Gruppe ","NetW. Group ","NetW. Group ","NetW. Group "},
{"NetW. Mode ","NetW. Mode ","NetW. Mode ","NetW. Mode "},
{"TX Timeout ","TX Timeout ","TX Timeout ","TX Timeout "},
{"TX MTU ","TX MTU ","TX MTU ","TX MTU "},
{"Baudrate Wi232/BT","Baudrate Wi232/BT","Baudrate Wi232/BT","Baudrate Wi232/BT"},
{"Initialisieren ","initialize ","initialiser ","Initialize "},
{"Konfig. mit PC ","config. with PC ","Config. avec PC ","Config. met PC "},
};
 
 
#define ITEMS_BT 5
 
prog_char param_menuitems_bt[ITEMS_BT][NUM_LANG][18]= // zeilen,zeichen+1
// German, English, French, Dutch
{
{"Modul eingebaut? ","module built in? ","Module installe ","module geinstall?"},
{"Name ","name ","Nom ","Naam "},
{"Pin ","pin ","Pin ","Pin "},
{"Initialisieren ","initialize ","initialiser ","Initialize "},
{"Konfig. mit PC ","config. with PC ","Config. avec PC ","Config. met PC "},
};
 
#define ITEMS_Accu 2
 
prog_char param_menuitems_Accu[ITEMS_Accu][NUM_LANG][18]= // zeilen,zeichen+1
// German, English, French, Dutch
{
{"PKT-Akkutyp ","PKT-Accutyp ","PKT-Type de batt.","PKT-batterij type"},
{"PKT Akku Messung ","PKT AccuMeasure ","batt. de mesure ","PKT batt. meting "},
};
 
#define ITEMS_GPS 6
 
prog_char param_menuitems_GPS[ITEMS_GPS][NUM_LANG][18]= // zeilen,zeichen+1
// German, English, French, Dutch
{
{"wähle GPS Maus ","select GPS mouse ","select GPS mouse ","select GPS mouse "},
{"Suche GPS Maus ","search GPS mouse ","search GPS mouse ","search GPS mouse "},
{"GPS Maus Typ ","GPS mouse typ ","GPS mouse typ ","GPS mouse typ "},
{"GPS Maus aktiv? ","GPS mouse activ? ","GPS mouse activ? ","GPS mouse activ? "},
{"Zeige GPS Device ","show GPS device ","show GPS device ","show GPS device "},
{"GPS Daten ","GPS data ","GPS data ","GPS data "},
 
};
 
#define ITEMS_FOLLOWME 3
 
prog_char param_menuitems_FOLLOWME[ITEMS_GPS][NUM_LANG][18]= // zeilen,zeichen+1
// German, English, French, Dutch
{
{"FollowMe Refresh","FollowMe Refresh","FollowMe Refresh","FollowMe Refresh"},
{"FollowMe Speed ","FollowMe Speed ","FollowMe Speed ","FollowMe Speed "},
{"Toleranz Radius ","Tolerance Radius","Tolerance Radius","Tolerance Radius"},
 
 
};
 
 
 
#define ITEMS_OSD 10
 
prog_char param_menuitems_OSD[ITEMS_OSD][NUM_LANG][18]= // zeilen,zeichen+1
// German, English, French, Dutch
{
{"OSD Anzeige Var. ","OSD screenmode ","OSD screenmode ","OSD screenmode "},
{"OUT1/2 Format ","OUT1/2 format ","OUT1/2 format ","OUT1/2 format "},
{"OUT1/2 Polarität ","OUT1/2 polarity ","OUT1/2 polarity ","OUT1/2 polarity "},
{"Navi Daten an SV2","Navi data to SV2 ","Navi data to SV2 ","Navi data to SV2 "},
{"Max. Sinkrate m/s","max fallspeed m/s","max fallspeed m/s","max fallspeed m/s"},
{"Variometer Beep ","Variometer beep ","Variometer beep ","Variometer beep "},
{"Home aus MK Sicht","home from MK view","home from MK view","home from MK view"},
{"MK LowBat Warnung","MK LowBat warning","MK LowBat Attent ","MK LoBat alarm "},
{"MK mAh Warnung","MK mAh warning ","MK mAh Attent ","MK mAh alarm "},
{"MK Volt Balken","MK volt bargraph ","MK volt bargraph ","MK volt bargraph "},
};
 
//--------------------------------------------------------------
void Show_Error_HW12(void)
{
lcd_cls();
lcd_printp_at (0,3,PSTR(" Mit Hardware 1.x "), 2);
lcd_printp_at (0,4,PSTR(" nicht möglich "), 2);
_delay_ms(1000);
 
}
 
 
//--------------------------------------------------------------
uint8_t Edit_Int10th_Value(uint8_t Value, uint8_t min, uint8_t max,uint8_t Text)
{
Pre = Value;
lcd_cls();
// lcd_printp_at (0, 2, Text, 0);
lcd_puts_at(0, 2, strGet(Text), 0);
write_ndigit_number_u_10th (16, 2,Value, 3, 0,0);
// lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0);
lcd_puts_at(0, 7, strGet(KEYLINE2), 0);
 
do
{
if ((get_key_press (1 << KEY_PLUS) || get_key_long_rpt_sp ((1 << KEY_PLUS), 3)) && (Value < max))
{
edit = 1;
Value++;
write_ndigit_number_u_10th (16, 2,Value, 3, 0,0);
}
 
if ((get_key_press (1 << KEY_MINUS) || get_key_long_rpt_sp ((1 << KEY_MINUS), 3)) && (Value > min))
{
edit = 1;
Value--;
write_ndigit_number_u_10th (16, 2,Value, 3, 0,0);
}
 
if (get_key_press (1 << KEY_ENTER))
return Value;
 
}
while (!get_key_press (1 << KEY_ESC));
{
get_key_press(KEY_ALL);
edit = 0;
return Pre;
}
}
 
 
//--------------------------------------------------------------
uint8_t Edit_Int_Value(uint8_t Value, uint8_t min, uint8_t max,uint8_t Text)
{
lcd_cls();
// lcd_printp_at (0, 2, Text, 0);
lcd_puts_at(0, 2, strGet(Text), 0);
Pre = Value;
write_ndigit_number_u (16, 2, Value, 3, 0,0);
// lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0);
lcd_puts_at(0, 7, strGet(KEYLINE2), 0);
 
do
{
if ((get_key_press (1 << KEY_PLUS) || get_key_long_rpt_sp ((1 << KEY_PLUS), 2)) && (Value < max))
{
edit = 1;
Value++;
write_ndigit_number_u (16, 2,Value, 3, 0,0);
}
 
if ((get_key_press (1 << KEY_MINUS) || get_key_long_rpt_sp ((1 << KEY_MINUS), 2)) && (Value > min))
{
edit = 1;
Value--;
write_ndigit_number_u (16, 2,Value, 3, 0,0);
}
 
if (get_key_press (1 << KEY_ENTER))
return Value;
 
}
while (!get_key_press (1 << KEY_ESC));
{
get_key_press(KEY_ALL);
edit = 0;
return Pre;
}
}
//--------------------------------------------------------------
uint16_t Edit_Int16_Value(uint16_t Value, uint16_t min, uint16_t max,uint8_t Text)
{
lcd_cls();
// lcd_printp_at (0, 2, Text, 0);
lcd_puts_at(0, 2, strGet(Text), 0);
Pre = Value;
write_ndigit_number_u (16, 2, Value, 5, 0,0);
// lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0);
lcd_puts_at(0, 7, strGet(KEYLINE2), 0);
 
do
{
if ((get_key_press (1 << KEY_PLUS) || get_key_long_rpt_sp ((1 << KEY_PLUS), 3)) && (Value < max))
{
edit = 1;
Value++;
write_ndigit_number_u (16, 2,Value, 5, 0,0);
}
 
if ((get_key_press (1 << KEY_MINUS) || get_key_long_rpt_sp ((1 << KEY_MINUS), 3)) && (Value > min))
{
edit = 1;
Value--;
write_ndigit_number_u (16, 2,Value, 5, 0,0);
}
 
if (get_key_press (1 << KEY_ENTER))
return Value;
 
}
while (!get_key_press (1 << KEY_ESC));
{
get_key_press(KEY_ALL);
edit = 0;
return Pre;
}
}
#if defined HWVERSION3_9
//--------------------------------------------------------------
uint8_t ChangeWi_SV2(uint8_t Value)
{
Pre = Value;
lcd_cls();
// lcd_printp_at (0, 1, PSTR("Verbinde das PKT mit"), 0);
// lcd_printp_at (0, 2, PSTR("dem MK über:"), 0);
lcd_puts_at(0, 1, strGet(CONNECT1), 0);
lcd_puts_at(0, 2, strGet(CONNECT2), 0);
 
if(UseWi == false)
{
// lcd_printp_at (0, 0, PSTR("Verbinde das PKT mit "), 0);
// lcd_printp_at (0, 1, PSTR("dem MK über: Kabel, "), 0);
// lcd_printp_at (0, 2, PSTR("da kein Wi.232 Modul "), 0);
// lcd_printp_at (0, 3, PSTR("eingebaut ist. "), 0);
// lcd_printp_at (0, 4, PSTR("Wenn doch, dann bitte"), 0);
// lcd_printp_at (0, 5, PSTR("das Modul zuerst im "), 0);
// lcd_printp_at (0, 6, PSTR("Setupmenü aktivieren."), 0);
lcd_puts_at(0, 1, strGet(CONNECT1), 0);
lcd_puts_at(0, 2, strGet(CONNECT4), 0);
lcd_puts_at(0, 1, strGet(CONNECT5), 0);
lcd_puts_at(0, 2, strGet(CONNECT6), 0);
lcd_puts_at(0, 1, strGet(CONNECT7), 0);
lcd_puts_at(0, 2, strGet(CONNECT8), 0);
lcd_puts_at(0, 1, strGet(CONNECT9), 0);
 
 
// lcd_printp_at (12, 7, PSTR("Ende"), 0);
lcd_puts_at(12, 7, strGet(ENDE), 0);
while (!get_key_press (1 << KEY_ESC));
get_key_press(KEY_ALL);
edit = 0;
return Pre;
}
else
{
switch (Value)
{
case 0x0 :lcd_printp_at (14, 2, PSTR("Wi232"), 0);
break;
case 0x1 : lcd_puts_at(14, 2, strGet(KABEL), 0);
 
//lcd_printp_at (14, 2, PSTR("Kabel"), 0);
 
break;
break;
}
// lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0);
lcd_puts_at(0, 7, strGet(KEYLINE2), 0);
 
do
{
if(UseWi == true)
{
if ((get_key_press (1 << KEY_PLUS)) && (Value == 0))
{
edit = 1;
Value = 1;
// lcd_printp_at (14, 2, PSTR("Kabel"), 0);
lcd_puts_at(14, 2, strGet(KABEL), 0);
Change_Output(Uart02FC);
}
 
if ((get_key_press (1 << KEY_MINUS)) && (Value == 1))
{
edit = 1;
Value = 0;
lcd_printp_at (14, 2, PSTR("Wi232"), 0);
Change_Output(Uart02Wi);
}
 
if (get_key_press (1 << KEY_ENTER))
{
// lcd_printp_at (0, 4, PSTR("Sie müssen das PKT"), 0);
// lcd_printp_at (0, 5, PSTR("jetzt neu starten!"), 0);
lcd_puts_at(0, 4, strGet(CONNECT10), 0);
lcd_puts_at(0, 5, strGet(CONNECT11), 0);
lcd_cls_line (0, 7, 18);
while (!get_key_press (1 << KEY_ENTER));
return Value;
}
}
}
while (!get_key_press (1 << KEY_ESC));
}
get_key_press(KEY_ALL);
edit = 0;
return Pre;
}
#endif
 
#if defined HWVERSION3_9 || defined HWVERSION1_3W
 
//--------------------------------------------------------------
uint8_t Edit_Wi_NetMode_Value(uint8_t Value)
{
Pre = Value;
lcd_cls();
// lcd_printp_at (0, 2, PSTR("Wi NetW. Mode:"), 0);
lcd_puts_at(0, 2, strGet(WINETWM), 0);
 
switch (Value)
{
case 0x0 :lcd_puts_at(15, 2, strGet(SLAVE), 0);//lcd_printp_at (15, 2, PSTR("Slave "), 0);
break;
case 0x1 :lcd_puts_at(15, 2, strGet(NORMAL), 0);//lcd_printp_at (15, 2, PSTR("Normal"), 0);
break;
break;
}
 
// lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0);
lcd_puts_at(0, 7, strGet(KEYLINE2), 0);
 
do
{
if ((get_key_press (1 << KEY_PLUS)) && (Value == 0))
{
edit = 1;
Value = NetMode_Normal;
// lcd_printp_at (15, 2, PSTR("Normal"), 0);
lcd_puts_at(15, 2, strGet(NORMAL), 0);
 
}
 
if ((get_key_press (1 << KEY_MINUS)) && (Value == 1))
{
edit = 1;
Value = NetMode_Slave;
// lcd_printp_at (15, 2, PSTR("Slave "), 0);
lcd_puts_at(15, 2, strGet(SLAVE), 0);
}
 
if (get_key_press (1 << KEY_ENTER))
return Value;
 
}
while (!get_key_press (1 << KEY_ESC));
{
get_key_press(KEY_ALL);
edit = 0;
return Pre;
}
}
#endif
 
//--------------------------------------------------------------
uint8_t Edit_OnOff(uint8_t Value, uint8_t min, uint8_t max,uint8_t Text)
 
{
Pre = Value;
lcd_cls();
// lcd_printp_at (0, 2,Text, 0);
lcd_puts_at(0, 2, strGet(Text), 0);
 
switch (Value)
{
case false :lcd_puts_at(17, 2, strGet(OFF), 0);//lcd_printp_at (17, 2, PSTR("Aus"), 0);
break;
case true :lcd_puts_at(17, 2, strGet(ON), 0);//cd_printp_at (17, 2, PSTR("Ein"), 0);
break;
break;
}
 
// lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0);
lcd_puts_at(0, 7, strGet(KEYLINE2), 0);
 
do
{
if ((get_key_press (1 << KEY_PLUS)) && (Value == 0))
{
Value = 1;
edit =1;
// lcd_printp_at (17, 2, PSTR("Ein"), 0);
lcd_puts_at(17, 2, strGet(ON), 0);
}
 
if ((get_key_press (1 << KEY_MINUS)) && (Value == 1))
{
Value = 0;
edit =1;
// lcd_printp_at (17, 2, PSTR("Aus"), 0);
lcd_puts_at(17, 2, strGet(OFF), 0);
}
 
if (get_key_press (1 << KEY_ENTER))
{
// edit = 1;
//
// PKT_StartInfo = Value;
// WriteParameter();
 
return Value;
}
}
 
while (!get_key_press (1 << KEY_ESC));
{
get_key_press(KEY_ALL);
edit = 0;
// PKT_StartInfo = Pre;
return Pre;
}
 
}
 
//--------------------------------------------------------------
uint8_t Edit_YesNo(uint8_t Value, uint8_t min, uint8_t max,uint8_t Text)
 
{
Pre = Value;
lcd_cls();
// lcd_printp_at (0, 2,Text, 0);
lcd_puts_at(0, 2, strGet(Text), 0);
 
switch (Value)
{
case false :lcd_puts_at(17, 2, strGet(NOO), 0);//lcd_printp_at (17, 2, PSTR("Aus"), 0);
break;
case true :lcd_puts_at(17, 2, strGet(YES), 0);//cd_printp_at (17, 2, PSTR("Ein"), 0);
break;
break;
}
 
// lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0);
lcd_puts_at(0, 7, strGet(KEYLINE2), 0);
 
do
{
if ((get_key_press (1 << KEY_PLUS)) && (Value == 0))
{
Value = 1;
edit = 1;
// lcd_printp_at (17, 2, PSTR("Ein"), 0);
lcd_puts_at(17, 2, strGet(YES), 0);
}
 
if ((get_key_press (1 << KEY_MINUS)) && (Value == 1))
{
Value = 0;
edit = 1;
// lcd_printp_at (17, 2, PSTR("Aus"), 0);
lcd_puts_at(17, 2, strGet(NOO), 0);
}
 
if (get_key_press (1 << KEY_ENTER))
{
// edit = 1;
 
// PKT_StartInfo = Value;
// WriteParameter();
 
return Value;
}
}
 
while (!get_key_press (1 << KEY_ESC));
{
get_key_press(KEY_ALL);
edit = 0;
// PKT_StartInfo = Pre;
return Pre;
}
 
}
 
//--------------------------------------------------------------
//uint8_t Edit_Baudrate(uint8_t Value, uint8_t min, uint8_t max,const char *Text)
uint8_t Edit_Baudrate(uint8_t Value, uint8_t min, uint8_t max,uint8_t Text)
{
Pre = Value;
lcd_cls();
lcd_puts_at(0, 2,strGet(Text), 0);
switch (Value)
{
case 0x0 : lcd_printp_at(15, 2, PSTR("2400 "), 0);
break;
case 0x1 : lcd_printp_at(15, 2, PSTR("9600 "), 0);
break;
case 0x2 : lcd_printp_at(15, 2, PSTR("19200 "), 0);
break;
case 0x3 : lcd_printp_at(15, 2, PSTR("38400 "), 0);
break;
case 0x4 : lcd_printp_at(15, 2, PSTR("57600 "), 0);
break;
case 0x5 : lcd_printp_at(15, 2, PSTR("115200"), 0);
break;
break;
}
 
lcd_puts_at(0, 7, strGet(KEYLINE2), 0);
 
do
{
if ((get_key_press (1 << KEY_PLUS)) && (Value < max))
{
edit = 1;
Value++;
//baudrate = Value;
switch (Value)
{
case 0x0 : lcd_printp_at(15, 2, PSTR("2400 "), 0);
break;
case 0x1 : lcd_printp_at(15, 2, PSTR("9600 "), 0);
break;
case 0x2 : lcd_printp_at(15, 2, PSTR("19200 "), 0);
break;
case 0x3 : lcd_printp_at(15, 2, PSTR("38400 "), 0);
break;
case 0x4 : lcd_printp_at(15, 2, PSTR("57600 "), 0);
break;
case 0x5 : lcd_printp_at(15, 2, PSTR("115200"), 0);
break;
break;
}
}
 
if ((get_key_press (1 << KEY_MINUS)) && (Value > min))
{
edit = 1;
Value--;
//Baudrate = Value;
switch (Value)
{
case 0x0 : lcd_printp_at(15, 2, PSTR("2400 "), 0);
break;
case 0x1 : lcd_printp_at(15, 2, PSTR("9600 "), 0);
break;
case 0x2 : lcd_printp_at(15, 2, PSTR("19200 "), 0);
break;
case 0x3 : lcd_printp_at(15, 2, PSTR("38400 "), 0);
break;
case 0x4 : lcd_printp_at(15, 2, PSTR("57600 "), 0);
break;
case 0x5 : lcd_printp_at(15, 2, PSTR("115200"), 0);
break;
break;
}
}
 
if (get_key_press (1 << KEY_ENTER))
return Value;
 
}
 
while (!get_key_press (1 << KEY_ESC));
{
get_key_press(KEY_ALL);
edit = 0;
return Pre;
}
}
 
//--------------------------------------------------------------
//uint8_t Edit_Language(uint8_t Value, uint8_t min, uint8_t max,const char *Text)
uint8_t Edit_Language(uint8_t Value, uint8_t min, uint8_t max,uint8_t Text)
{
Pre = Value;
lcd_cls();
// lcd_printp_at (0, 2, Text, 0);
lcd_puts_at(0, 2,strGet(Text), 0);
switch (Value)
{
case
0x0 : lcd_puts_at(10, 2, strGet(DEUTSCH), 0);//lcd_printp_at (14, 2, PSTR("Deutsch"), 0);
break;
case 0x1 : lcd_puts_at(10, 2, strGet(ENGLISCH), 0);//lcd_printp_at (14, 2, PSTR("English"), 0);
break;
case 0x2 : lcd_puts_at(10, 2, strGet(FRANCE), 0);//lcd_printp_at (14, 2, PSTR("France "), 0);
break;
case 0x3 : lcd_puts_at(10, 2, strGet(NETHERL), 0);//lcd_printp_at (14, 2, PSTR("Netherl"), 0);
break;
break;
}
 
// lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0);
lcd_puts_at(0, 7, strGet(KEYLINE2), 0);
 
do
{
if ((get_key_press (1 << KEY_PLUS)) && (Value < max))
{
edit = 1;
Value++;
//DisplayLanguage = Value;
switch (Value)
{
case 0x0 : lcd_puts_at(10, 2, strGet(DEUTSCH), 0);//lcd_printp_at (14, 2, PSTR("Deutsch"), 0);
break;
case 0x1 : lcd_puts_at(10, 2, strGet(ENGLISCH), 0);//lcd_printp_at (14, 2, PSTR("English"), 0);
break;
case 0x2 : lcd_puts_at(10, 2, strGet(FRANCE), 0);//lcd_printp_at (14, 2, PSTR("France "), 0);
break;
case 0x3 : lcd_puts_at(10, 2, strGet(NETHERL), 0);//lcd_printp_at (14, 2, PSTR("Netherl"), 0);
break;
break;
}
}
 
if ((get_key_press (1 << KEY_MINUS)) && (Value > min))
{
edit = 1;
Value--;
//DisplayLanguage = Value;
switch (Value)
{
case 0x0 : lcd_puts_at(10, 2, strGet(DEUTSCH), 0);//lcd_printp_at (14, 2, PSTR("Deutsch"), 0);
break;
case 0x1 : lcd_puts_at(10, 2, strGet(ENGLISCH), 0);//lcd_printp_at (14, 2, PSTR("English"), 0);
break;
case 0x2 : lcd_puts_at(10, 2, strGet(FRANCE), 0);//lcd_printp_at (14, 2, PSTR("France "), 0);
break;
case 0x3 : lcd_puts_at(10, 2, strGet(NETHERL), 0);//lcd_printp_at (14, 2, PSTR("Netherl"), 0);
break;
break;
}
}
 
if (get_key_press (1 << KEY_ENTER))
return Value;
 
}
 
while (!get_key_press (1 << KEY_ESC));
{
get_key_press(KEY_ALL);
edit = 0;
return Pre;
}
}
 
 
//--------------------------------------------------------------
uint8_t Edit_Orientation(uint8_t Value, uint8_t min, uint8_t max,uint8_t Text)
{
Pre = Value;
lcd_cls();
// lcd_printp_at (0, 2, Text, 0);
lcd_puts_at(0, 2, strGet(Text), 0);
 
switch (Value)
{
case 0x0 :lcd_puts_at(14, 2, strGet(NORMAL), 0);//lcd_printp_at (14, 2, PSTR("Normal "), 0);
break;
case 0x4 :lcd_puts_at(14, 2, strGet(REVERSE), 0);//lcd_printp_at (14, 2, PSTR("Reverse"), 0);
break;
break;
}
 
// lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0);
lcd_puts_at(0, 7, strGet(KEYLINE2), 0);
 
do
{
if ((get_key_press (1 << KEY_PLUS)) && (Value == 0))
{
Value=4;
// lcd_printp_at (14, 2, PSTR("Reverse"), 0);
lcd_puts_at(14, 2, strGet(REVERSE), 0);
}
 
if ((get_key_press (1 << KEY_MINUS)) && (Value == 4))
{
Value = 0;
// lcd_printp_at (14, 2, PSTR("Normal "), 0);
lcd_puts_at(14, 2, strGet(NORMAL), 0);
}
 
if (get_key_press (1 << KEY_ENTER))
{
edit = 1;
cli();
clr_A0 ();
 
if (Value == 0)
{
send_byte (0xA1); // normal
send_byte (0xC0); // normal
}
else
{
send_byte (0xA0); // reverse
send_byte (0xC8); // reverse
}
set_A0 ();
sei();
LCD_Orientation = Value;
WriteParameter();
return Value;
}
}
 
while (!get_key_press (1 << KEY_ESC));
{
get_key_press(KEY_ALL);
edit = 0;
return Pre;
}
}
 
 
//--------------------------------------------------------------
uint8_t Edit_DisplayMode(uint8_t Value, uint8_t min, uint8_t max,uint8_t Text)
{
Pre = Value;
lcd_cls();
//lcd_printp_at (0, 2, Text, 0);
lcd_puts_at(0, 2, strGet(Text), 0);
 
switch (Value)
{
case 0x0 :lcd_puts_at(14, 2, strGet(NORMAL), 0);//lcd_printp_at (14, 2, PSTR("Normal "), 0);
break;
case 0x4 :lcd_puts_at(14, 2, strGet(REVERSE), 0);//lcd_printp_at (14, 2, PSTR("Reverse"), 0);
break;
break;
}
 
// lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0);
lcd_puts_at(0, 7, strGet(KEYLINE2), 0);
 
do
{
if ((get_key_press (1 << KEY_PLUS)) && (Value == 0))
{
Value=4;
// lcd_printp_at (14, 2, PSTR("Inverse"), 0);
lcd_puts_at(14, 2, strGet(REVERSE), 0);
}
 
if ((get_key_press (1 << KEY_MINUS)) && (Value == 4))
{
Value=0;
// lcd_printp_at (14, 2, PSTR("Normal "), 0);
lcd_puts_at(14, 2, strGet(NORMAL), 0);
}
 
if (get_key_press (1 << KEY_ENTER))
{
edit = 1;
cli();
clr_A0 ();
 
if (Value == 0)
send_byte (0xA6); // normal
else
send_byte (0xA7); // inverse
 
set_A0 ();
sei();
LCD_DisplayMode = Value;
WriteParameter();
 
return Value;
}
}
 
while (!get_key_press (1 << KEY_ESC));
{
get_key_press(KEY_ALL);
edit = 0;
LCD_DisplayMode = Pre;
return Pre;
}
}
 
 
//--------------------------------------------------------------
uint8_t Edit_DisplayKontrast(uint8_t Value, uint8_t min, uint8_t max,uint8_t Text)
{
Pre = Value;
lcd_cls();
// lcd_printp_at (0, 2, Text, 0);
lcd_puts_at(0, 2, strGet(Text), 0);
write_ndigit_number_u (16, 2, Value, 3, 0,0);
// lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0);
lcd_puts_at(0, 7, strGet(KEYLINE2), 0);
 
do
{
write_ndigit_number_u (16, 2,Value, 3, 0,0);
lcd_frect ((8*0), (8*4), (Value * (16*8) / 64), 6, 1);
 
if ((get_key_press (1 << KEY_PLUS) || get_key_long_rpt_sp ((1 << KEY_PLUS), 2)) && (Value < max))
{
Value++;
 
if (Value >= max)
{
Value = max;
set_beep ( 200, 0x0080, BeepNormal);
}
else
{
cli();
clr_A0 ();
send_byte (0x81);
send_byte (Value); // Daten zum LCD senden
set_A0 ();
sei();
}
}
 
if ((get_key_press (1 << KEY_MINUS) || get_key_long_rpt_sp ((1 << KEY_MINUS), 2)) && (Value > min))
{
lcd_frect (((Value - 1) * (16*8) / 64), (8*4), (16*8), 6, 0);
Value--;
 
if (Value == min)
{
Value = min;
set_beep ( 200, 0x0080, BeepNormal);
}
else
{
// edit = 1;
cli();
clr_A0 ();
send_byte (0x81);
send_byte (Value); // Daten zum LCD senden
set_A0 ();
sei();
}
}
write_ndigit_number_u (16, 2,Value, 3, 0,0);
 
if (get_key_press (1 << KEY_ENTER))
{
edit = 1;
LCD_Kontrast = Value;
WriteParameter();
return Value;
}
}
 
while (!get_key_press (1 << KEY_ESC));
{
get_key_press(KEY_ALL);
cli();
clr_A0 ();
send_byte (0x81);
send_byte (Pre); // Daten zum LCD senden
set_A0 ();
sei();
edit = 0;
LCD_Kontrast = Pre;
WriteParameter();
return Pre;
}
}
 
 
//--------------------------------------------------------------
uint8_t Edit_DisplayHelligkeit(uint8_t Value, uint8_t min, uint8_t max, uint8_t Text)
{
float ValCorr = 2.55; // (Value * ValCorr) maximal 255
Pre = Value;
OCR2A = Value * ValCorr;
 
lcd_cls();
// lcd_printp_at (0, 2, Text, 0);
lcd_puts_at(0, 2, strGet(Text), 0);
write_ndigit_number_u (16, 2, Value, 3, 0,0);
lcd_printp_at (17, 2, PSTR("%"), 0);
// lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0);
lcd_puts_at(0, 7, strGet(KEYLINE2), 0);
 
do
{
write_ndigit_number_u (16, 2,Value, 3, 0,0);
lcd_frect ((8*0), (8*4), (Value * (16*8) / 100), 6, 1);
 
if ((get_key_press (1 << KEY_PLUS) || get_key_long_rpt_sp ((1 << KEY_PLUS), 3)) && (Value < max))
{
Value++;
 
if (Value >= max)
{
Value = max;
set_beep ( 200, 0x0080, BeepNormal);
}
else
OCR2A = Value * ValCorr;
 
}
 
if ((get_key_press (1 << KEY_MINUS) || get_key_long_rpt_sp ((1 << KEY_MINUS), 3)) && (Value > min))
{
lcd_frect (((Value - 1) * (16*8) / 100), (8*4), (16*8), 6, 0);
Value--;
 
if (Value == min)
{
Value = min;
set_beep ( 200, 0x0080, BeepNormal);
}
else
OCR2A = Value * ValCorr;
 
}
 
if (get_key_press (1 << KEY_ENTER))
{
edit = 1;
OCR2A = Value * ValCorr;
LCD_Helligkeit = Value;
WriteParameter();
return Value;
}
}
 
while (!get_key_press (1 << KEY_ESC));
{
get_key_press(KEY_ALL);
edit = 0;
OCR2A = Pre * ValCorr;
LCD_Helligkeit = Pre;
WriteParameter();
return Pre;
}
}
 
 
//--------------------------------------------------------------
void Reset_EEprom(void)
{
lcd_cls();
get_key_press(KEY_ALL);
// lcd_printp_at (0, 2, PSTR(" EEProm wirklich"), 0);
// lcd_printp_at (0, 3, PSTR(" löschen?"), 0);
// lcd_printp_at (12, 7, PSTR("Ende OK"), 0);
lcd_puts_at(0, 2, strGet(EEPROM1), 0);
lcd_puts_at(0, 3, strGet(EEPROM2), 0);
lcd_puts_at(12, 7, strGet(ENDOK), 0);
 
 
do
{
 
if (get_key_press (1 << KEY_ENTER))
{
Delete_EEPROM();
return;
}
}
while (!get_key_press (1 << KEY_ESC));
get_key_press(KEY_ALL);
}
 
 
//--------------------------------------------------------------
void PKT_Setup (void)
{
uint8_t ii = 0;
uint8_t Offset = 0;
uint8_t size = 0;
size = ITEMS_PKT;
uint8_t dmode = 0;
uint8_t target_pos = 1;
uint8_t val;
 
lcd_cls ();
mmode = 0;
edit= 0;
val = 0;
 
while(1)
{
lcd_cls ();
lcd_printp_at (0, 0, PSTR(" PKT-Setup "), 2);
// lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0);
lcd_puts_at(0, 7, strGet(KEYLINE1), 0);
 
while(1)
{
ii = 0;
 
if(Offset > 0)
lcd_printp_at(1,1, PSTR("\x12"), 0);
 
for(ii = 0;ii < 6 ; ii++)
{
if((ii+Offset) < size)
lcd_printp_at(3,ii+1,param_menuitems_pkt[ii+Offset][DisplayLanguage], 0);
 
if((ii == 5)&&(ii+Offset < (size-1)))
lcd_printp_at(1,6, PSTR("\x13"), 0);
 
}
 
if(dmode == 0)
{
if(Offset == 0)
{
if(size > 6)
val = menu_choose2 (1, 5, target_pos,0,1);
else
val = menu_choose2 (1, size, target_pos,0,0);
 
}
else
val = menu_choose2 (2, 5, target_pos,1,1);
 
}
 
if(dmode == 1)
{
if(Offset+7 > size)
val = menu_choose2 (2, 6, target_pos,1,0);
else
val = menu_choose2 (2, 5, target_pos,1,1);
 
}
 
if(val == 254)
{
Offset++;
dmode = 1;
target_pos = 5;
}
else if(val == 253)
{
Offset--;
dmode = 0;
target_pos = 2;
}
else if(val == 255)
{ // Ende mit ESC, speichern
if (edit == 1)
{
WriteParameter();
return;
}
return;
}
else
break;
}
target_pos = val;
 
//
// {"Verbindung zum MK","connection to MK "," connexion a MK " ,"Aansluiting op MK"},
// {"MK LowBat Warnung","MK LowBat warning","MK LowBat Attent", "MK LoBat alarm "},
// {"Anzeige \x1d","Display \x1d","d'affichage \x1d","Display \x1d"},
// {"Wi.232 \x1d","Wi.232 \x1d","Wi.232 \x1d","Wi.232 \x1d"},
// {"BTM-222 \x1d","BTM-222 \x1d","BTM-222 \x1d","BTM-222 \x1d"},
// {"Antennen Track. \x1d","antenna tracking\x1d","antenna tracking\x1d","antenna tracking\x1d"},
// {"OSD \x1d","OSD \x1d","OSD \x1d","OSD \x1d"},
// {"GPS \x1d","GPS \x1d","GPS \x1d","GPS \x1d"},
// "Follow Me \x1d"
// {"PKT-Akku \x1d","PKT-Accu \x1d","PKT-Accu \x1d","PKT-Accu \x1d"},
// {"PKT Update ","PKT Update ","PKT Mise a jour ","PKT Update "},
// {"Debug PKT ","Debug PKT ","Debug PKT ","Debug PKT "},
// {"EEProm Reset ","EEProm Reset ","EEProm Reinitiali","EEProm Reset "},
 
 
 
if((val + Offset) == 1)
{
#ifdef HWVERSION3_9
U02SV2 = ChangeWi_SV2(U02SV2);
 
if (edit == 1)
PKT_Change = 1;
 
#else
Show_Error_HW12();
#endif
}
 
 
if((val + Offset) == 2)
Display_Setup();
 
if((val + Offset) == 3)
{
#if defined HWVERSION3_9 || defined HWVERSION1_2W || defined HWVERSION1_3W
if(UseWi == false)
// Wi_Use();
{
UseWi = Edit_YesNo(UseWi,0,1,WI2321);
if (edit==1)
if (UseWi== true) InitWi232(PKT_Baudrate);
}
 
else
Wi_Setup();
#else
Show_Error_HW12();
#endif
}
 
if((val + Offset) == 4)
{
#ifdef HWVERSION3_9
if(UseBT == 0)
{
UseBT = Edit_YesNo(UseBT,0,1,BT1);
if (edit==1)
if (UseBT == 1)
{
if (bt_init()) BTIsSet = true; else BTIsSet = false;
WriteParameter();
}
}
else
BT_Setup();
#else
Show_Error_HW12();
#endif
}
 
if((val + Offset) == 5)
{
 
}
if((val + Offset) == 6)
{
OSD_Setup();
}
#ifdef HWVERSION3_9
if((val + Offset) == 7)
GPS_Setup();
 
if((val + Offset) == 8)
FollowMe_Setup();
 
 
 
if((val + Offset) == 9)
 
Accu_Setup();
#else
Show_Error_HW12();
#endif
if((val + Offset) == 10)
Update_PKT();
 
if((val + Offset) == 11)
Debug = Edit_Int_Value(Debug,0,1,DEBUGPKT);
 
if((val + Offset) == 12)
Reset_EEprom();
 
}
}
 
 
//--------------------------------------------------------------
void Display_Setup (void)
{
uint8_t ii = 0;
uint8_t Offset = 0;
uint8_t size = 0;
size = ITEMS_LCD;
uint8_t dmode = 0;
uint8_t target_pos = 1;
uint8_t val;
 
lcd_cls ();
mmode = 0;
edit= 0;
LCD_Change = 0;
val = 0;
 
while(1)
{
lcd_cls ();
// lcd_printp_at (0, 0, PSTR(" Display Setup "), 2);
lcd_puts_at(0, 0, strGet(DISPLAY1), 2);
// lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0);
lcd_puts_at(0, 7, strGet(KEYLINE1), 0);
 
while(1)
{
ii = 0;
 
if(Offset > 0)
lcd_printp_at(1, 1, PSTR("\x12"), 0);
 
for(ii = 0; ii < 6 ; ii++)
{
if((ii + Offset) < size)
lcd_printp_at(3, ii + 1, param_menuitems_lcd[ii + Offset][DisplayLanguage], 0);
 
if((ii == 5)&&(ii+Offset < (size - 1)))
lcd_printp_at(1,6, PSTR("\x13"), 0);
 
}
 
if(dmode == 0)
{
if(Offset == 0)
{
if(size > 6)
val = menu_choose2 (1, 5, target_pos,0,1);
else
val = menu_choose2 (1, size, target_pos,0,0);
 
}
else
val = menu_choose2 (2, 5, target_pos,1,1);
 
}
 
if(dmode == 1)
{
if(Offset + 7 > size)
val = menu_choose2 (2, 6, target_pos,1,0);
else
val = menu_choose2 (2, 5, target_pos,1,1);
 
}
 
if(val == 254)
{
Offset++;
dmode = 1;
target_pos = 5;
}
else if(val == 253)
{
Offset--;
dmode = 0;
target_pos = 2;
}
else if(val == 255)
{ // Ende mit ESC, speichern
if (edit == 1)
{
WriteParameter();
return;
}
return;
}
else
break;
}
target_pos = val;
 
if((val + Offset) == 1)
PKT_StartInfo = Edit_OnOff(PKT_StartInfo,0,2,DISPLAY2);
if((val + Offset) == 2)
OSD_RCErrorbeep = Edit_OnOff(OSD_RCErrorbeep,0,2,DISPLAY9);
 
if((val + Offset) == 3)
DisplayLanguage = Edit_Language(DisplayLanguage,0,3,DISPLAY3);
// Edit_Language(DisplayLanguage,0,3,DISPLAY3);
 
if((val + Offset) == 4)
DisplayTimeout = Edit_Int_Value(DisplayTimeout,0,254,DISPLAY4);
 
if((val + Offset) == 5)
LCD_Helligkeit = Edit_DisplayHelligkeit(LCD_Helligkeit,0,100,DISPLAY5);
if (edit == 1)
if(!LCD_Change)
LCD_Change =1;
 
if((val + Offset) == 6)
LCD_Kontrast = Edit_DisplayKontrast(LCD_Kontrast,0,63,DISPLAY6);
if (edit == 1)
if(!LCD_Change)
LCD_Change =1;
 
if((val + Offset) == 7)
{
LCD_DisplayMode = Edit_DisplayMode(LCD_DisplayMode,0,4,DISPLAY7);
if (edit == 1)
if(!LCD_Change)
LCD_Change =1;
}
 
if((val + Offset) == 8)
{
LCD_Orientation = Edit_Orientation(LCD_Orientation,0,4,DISPLAY8);
if (edit == 1)
if(!LCD_Change)
LCD_Change =1;
}
 
 
 
 
}
}
 
#if defined HWVERSION3_9 || defined HWVERSION1_3W
////--------------------------------------------------------------
//void Wi_Use (void)
//{
// Pre = UseWi;
//
// lcd_cls ();
//
// lcd_cls ();
//// lcd_printp_at (0, 0, PSTR(" Wi.232 Setup "), 2);
//// lcd_printp_at (0, 2, PSTR("Ist ein Wi.232-Modul "), 0);
//// lcd_printp_at (0, 4, PSTR("eingebaut?"), 0);
// lcd_puts_at(0, 0, strGet(WI2321), 2);
// lcd_puts_at(0, 2, strGet(WI2322), 0);
// lcd_puts_at(0, 4, strGet(WI2323), 0);
//// lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0);
// lcd_puts_at(0, 7, strGet(KEYLINE2), 0);
//
// while(1)
// {
// if(UseWi == false)
//// lcd_printp_at (12, 4, PSTR("Nein"), 0);
// lcd_puts_at(12, 4, strGet(NOO), 0);
// else
// //lcd_printp_at (12, 4, PSTR("Ja "), 0);
// lcd_puts_at(12, 4, strGet(YES), 0);
//
// if(get_key_press (1 << KEY_MINUS))
// {
// UseWi = false;
// edit = 1;
// }
//
// if(get_key_press (1 << KEY_PLUS))
// {
// UseWi = true;
// edit = 1;
// }
//
// if(get_key_short (1 << KEY_ENTER))
// {
//// WiIsSet = false;
//// WriteParameter();
//// if(UseWi == true)
//// Wi_Setup();
// return;
// }
//
// if (get_key_press (1 << KEY_ESC))
// {
// get_key_press(KEY_ALL);
// UseWi = Pre;
// return;
// }
// }
//}
 
 
//--------------------------------------------------------------
void Wi_Setup (void)
{
uint8_t ii = 0;
uint8_t Offset = 0;
uint8_t size = 0;
size = ITEMS_WI;
uint8_t dmode = 0;
uint8_t target_pos = 1;
uint8_t val = 0;
 
mmode = 0;
edit = 0;
// WiIsSet = true;
 
lcd_cls ();
 
while(1)
{
lcd_cls ();
lcd_printp_at (0, 0, PSTR(" Wi.232 Setup "), 2);
// lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0);
lcd_puts_at(0, 7, strGet(KEYLINE1), 0);
 
while(1)
{
ii = 0;
 
if(Offset > 0)
lcd_printp_at(1, 1, PSTR("\x12"), 0);
 
for(ii = 0; ii < 6; ii++)
{
if((ii + Offset) < size)
lcd_printp_at(3, ii+1, param_menuitems_wi[ii+Offset][DisplayLanguage], 0);
 
if((ii == 5)&&(ii + Offset < (size - 1)))
lcd_printp_at(1, 6, PSTR("\x13"), 0);
 
}
 
if(dmode == 0)
{
if(Offset == 0)
{
if(size > 6)
val = menu_choose2 (1, 5, target_pos,0,1);
else
val = menu_choose2 (1, size, target_pos,0,0);
 
}
else
val = menu_choose2 (2, 5, target_pos,1,1);
 
}
 
if(dmode == 1)
{
if(Offset + 7 > size)
val = menu_choose2 (2, 6, target_pos, 1, 0);
else
val = menu_choose2 (2, 5, target_pos, 1, 1);
 
}
 
if(val == 254)
{
Offset++;
dmode = 1;
target_pos = 5;
}
else if(val == 253)
{
Offset--;
dmode = 0;
target_pos = 2;
}
else if(val == 255)
{ // Ende mit ESC, speichern
if (edit == 1)
{
if (UseWi==true) InitWi232(PKT_Baudrate);
WriteParameter();
}
 
return;
}
else
 
break;
}
target_pos = val;
 
if((val + Offset) == 1)
{
UseWi = Edit_YesNo(UseWi,0,1,WI2321);
}
 
if((val + Offset) == 2)
{
WiTXRXChannel = Edit_Int_Value(WiTXRXChannel, 0, 5,WITXRX);
 
}
 
if((val + Offset) == 3)
{
WiNetworkGroup = Edit_Int_Value(WiNetworkGroup, 0, 127, WINETWG);
 
 
}
 
if((val + Offset) == 4)
{
WiNetworkMode = Edit_Wi_NetMode_Value(WiNetworkMode);
 
 
}
 
if((val + Offset) == 5)
{
WiTXTO = Edit_Int_Value(WiTXTO,0,127,WITIMEOUT);
 
 
}
 
if((val + Offset) == 6)
{
WiUartMTU = Edit_Int_Value(WiUartMTU,0,127,WIUART);
 
 
}
 
if((val + Offset) == 7)
{
PKT_Baudrate = Edit_Baudrate(PKT_Baudrate,0,5,PKT_BAUDRATE);
New_Baudrate = PKT_Baudrate;
//TODO: //if (edit==1) bt_init();
}
 
 
 
if((val + Offset) == 8)
InitWi232(PKT_Baudrate);
#if defined HWVERSION3_9
if((val + Offset) == 9)
Port_USB2CFG_Wi();
#endif
}
}
#endif
 
#ifdef HWVERSION3_9
//--------------------------------------------------------------
//17.6.12 gelöschtCB, geändert durch HaraldB
//uint8_t Edit_String(const char *data, const uint8_t length, uint8_t type, const char *Text)
//{
// uint8_t y = 1;
// uint8_t x = 1;
// uint8_t I = 0;
//
// lcd_cls();
// lcd_printp_at (0, 0, Text, 2);
//
// for (uint8_t i = 0; i < length; i++)
// {
// lcd_putc (y++, 3, data[i], 0);
// lcd_printp_at (y++, 3, PSTR(" "), 0);
//
// EditString[i] = data[i];
// }
//
// lcd_rect ((x*6)-3, (8*3)-2, 10, 10, 1);
// lcd_printp_at (0, 6, PSTR(" C"), 0);
// lcd_printp_at (0, 7, PSTR(" \x17 \x16 \x19 OK"), 0);
//
// do
// {
// if (type == 1) // Name
// {
// for (uint8_t i = bt_name_length; i > 0; i--)
// {
// if (EditString[i - 1] != ' ')
// {
// bt_name_len = i;
// break;
// }
// }
//
// if ((get_key_press (1 << KEY_PLUS) || get_key_long_rpt_sp ((1 << KEY_PLUS), 2)) && EditString[I] < 'z')
// {
// EditString[I]++;
//
// if (EditString[I] >= 0x00 && EditString[I] < ' ')
// EditString[I] = ' ';
//
// if (EditString[I] > ' ' && EditString[I] < '0')
// EditString[I] = '0';
//
// if (EditString[I] > '9' && EditString[I] < 'A')
// EditString[I] = 'A';
//
// if (EditString[I] > 'Z' && EditString[I] < 'a')
// EditString[I] = 'a';
//
// lcd_putc (x, 3, EditString[I], 0);
// edit = 1;
// }
//
// if ((get_key_press (1 << KEY_MINUS) || get_key_long_rpt_sp ((1 << KEY_MINUS), 2)) && EditString[I] > ' ')
// {
// EditString[I]--;
//
// if (EditString[I] < 'a' && EditString[I] > 'Z')
// EditString[I] = 'Z';
//
// if (EditString[I] < 'A' && EditString[I] > '9')
// EditString[I] = '9';
//
// if (EditString[I] < '0' && EditString[I] > ' ')
// EditString[I] = ' ';
//
// lcd_putc (x, 3, EditString[I], 0);
// edit = 1;
// }
// }
// else if (type == 2) // PIN
// {
// if ((get_key_press (1 << KEY_PLUS) || get_key_long_rpt_sp ((1 << KEY_PLUS), 1)) && (EditString[I] < '9'))
// {
// EditString[I]++;
// lcd_putc (x, 3, EditString[I], 0);
// edit = 1;
// }
//
// if ((get_key_press (1 << KEY_MINUS) || get_key_long_rpt_sp ((1 << KEY_MINUS), 1)) && (EditString[I] > '0'))
// {
// EditString[I]--;
// lcd_putc (x, 3, EditString[I], 0);
// edit = 1;
// }
// }
//
// if (get_key_long (1 << KEY_ESC))
// {
// EditString[I] = ' '; // Zeichen l�schen
// lcd_putc (x, 3, EditString[I], 0);
// edit = 1;
// }
//
// if (get_key_short (1 << KEY_ESC))
// {
// if ((x / 2) + 2 > bt_name_length)
// {
// lcd_rect ((x*6)-3, (8*3)-2, 10, 10, 0);
// x = 1;
// lcd_rect ((x*6)-3, (8*3)-2, 10, 10, 1);
// I = 0;
// }
// else
// {
// lcd_rect ((x*6)-3, (8*3)-2, 10, 10, 0);
// x++;
// x++;
// lcd_rect ((x*6)-3, (8*3)-2, 10, 10, 1);
// I++; //Zeiger auf Zeichen
// }
// }
// }
// while (!get_key_press (1 << KEY_ENTER));
// {
// get_key_press(KEY_ALL);
// return 1;
// }
//}
 
uint8_t Edit_String(const char *data, const uint8_t length, uint8_t type, const char *Text)
{
uint8_t y = 1;
uint8_t x = 1;
uint8_t I = 0;
 
lcd_cls();
lcd_printp_at (0, 0, Text, 2);
 
for (uint8_t i = 0; i < length; i++)
{
lcd_putc (y++, 3, data[i], 0);
lcd_printp_at (y++, 3, PSTR(" "), 0);
 
EditString[i] = data[i];
}
 
lcd_rect ((x*6)-3, (8*3)-2, 10, 10, 1);
lcd_printp_at (0, 6, PSTR(" C"), 0);
lcd_printp_at (0, 7, PSTR(" \x17 \x16 \x19 OK"), 0);
 
do
{
if (type == 1) // Name
{
for (uint8_t i = bt_name_length; i > 0; i--)
{
if (EditString[i - 1] != ' ')
{
bt_name_len = i;
break;
}
}
 
if ((get_key_press (1 << KEY_PLUS) || get_key_long_rpt_sp ((1 << KEY_PLUS), 2)) && EditString[I] < 'z')
{
EditString[I]++;
 
//if (EditString[I] >= 0x00 && EditString[I] < ' ') // MartinR: Compilerwarnung
if (EditString[I] < ' ') // MartinR: geändert
EditString[I] = ' ';
 
if (EditString[I] > ' ' && EditString[I] < '0')
EditString[I] = '0';
 
if (EditString[I] > '9' && EditString[I] < 'A')
EditString[I] = 'A';
 
if (EditString[I] > 'Z' && EditString[I] < 'a')
EditString[I] = 'a';
 
lcd_putc (x, 3, EditString[I], 0);
edit = 1;
}
 
if ((get_key_press (1 << KEY_MINUS) || get_key_long_rpt_sp ((1 << KEY_MINUS), 2)) && EditString[I] > ' ')
{
EditString[I]--;
 
if (EditString[I] < 'a' && EditString[I] > 'Z')
EditString[I] = 'Z';
 
if (EditString[I] < 'A' && EditString[I] > '9')
EditString[I] = '9';
 
if (EditString[I] < '0' && EditString[I] > ' ')
EditString[I] = ' ';
 
lcd_putc (x, 3, EditString[I], 0);
edit = 1;
}
}
else if (type == 2) // PIN
{
if ((get_key_press (1 << KEY_PLUS) || get_key_long_rpt_sp ((1 << KEY_PLUS), 1)) && (EditString[I] < '9'))
{
EditString[I]++;
 
//if (EditString[I] >= 0x00 && EditString[I] < ' ') // MartinR: Compilerwarnung
if (EditString[I] < ' ') // MartinR: geändert
EditString[I] = ' ';
if (EditString[I] > ' ' && EditString[I] < '0')
EditString[I] = '0';
 
lcd_putc (x, 3, EditString[I], 0);
edit = 1;
}
 
if ((get_key_press (1 << KEY_MINUS) || get_key_long_rpt_sp ((1 << KEY_MINUS), 1)) && (EditString[I] > '0'))
{
EditString[I]--;
 
if (EditString[I] < 'A' && EditString[I] > '9')
EditString[I] = '9';
 
lcd_putc (x, 3, EditString[I], 0);
edit = 1;
}
}
 
if (get_key_long (1 << KEY_ESC))
{
if (type == 1) // Name
EditString[I] = ' '; // Zeichen l�schen
else if (type == 2) // Pin
EditString[I] = '0'; // Zeichen setzen
lcd_putc (x, 3, EditString[I], 0);
edit = 1;
}
 
if (get_key_short (1 << KEY_ESC))
{
if (type == 1)
length_tmp = bt_name_length;
else if (type == 2)
length_tmp = bt_pin_length;
 
if ((x / 2) + 2 > length_tmp)
{
lcd_rect ((x*6)-3, (8*3)-2, 10, 10, 0);
x = 1;
lcd_rect ((x*6)-3, (8*3)-2, 10, 10, 1);
I = 0;
}
else
{
lcd_rect ((x*6)-3, (8*3)-2, 10, 10, 0);
x++;
x++;
lcd_rect ((x*6)-3, (8*3)-2, 10, 10, 1);
I++; //Zeiger auf Zeichen
}
}
}
while (!get_key_press (1 << KEY_ENTER));
{
return 1;
}
}
////--------------------------------------------------------------
//void BT_Use (void)
//{
// Pre = UseBT;
//
// lcd_cls ();
//
// lcd_cls ();
//// lcd_printp_at (0, 0, PSTR(" BTM-222 Setup "), 2);
//// lcd_printp_at (0, 2, PSTR("Ist ein BTM-222-Modul"), 0);
//// lcd_printp_at (0, 4, PSTR("eingebaut?"), 0);
// lcd_puts_at(0, 0, strGet(BT1), 2);
// lcd_puts_at(0, 2, strGet(BT2), 0);
// lcd_puts_at(0, 4, strGet(BT3), 0);
//// lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0);
// lcd_puts_at(0, 7, strGet(KEYLINE2), 0);
//
// while(1)
// {
// if(UseBT == false)
//// lcd_printp_at (12, 4, PSTR("Nein"), 0);
// lcd_puts_at(12, 4, strGet(NOO), 0);
// else
//// lcd_printp_at (12, 4, PSTR("Ja "), 0);
// lcd_puts_at(12, 4, strGet(YES), 0);
// if(get_key_press (1 << KEY_MINUS))
// UseBT = false;
//
// if(get_key_press (1 << KEY_PLUS))
// UseBT = true;
//
// if(get_key_short (1 << KEY_ENTER))
// {
//// BTIsSet = false;
// WriteParameter();
// if(UseBT == true)
// BT_Setup();
// return;
// }
//
// if (get_key_press (1 << KEY_ESC))
// {
// get_key_press(KEY_ALL);
// UseBT = Pre;
// return;
// }
// }
//}
#ifdef HWVERSION3_9
void BT_SelectDevice (void)
{
uint8_t ii = 0;
uint8_t Offset = 0;
uint8_t size = 0;
size = bt_devicecount;
uint8_t dmode = 0;
uint8_t target_pos = 1;
uint8_t val = 0;
 
mmode = 0;
edit = 0;
 
 
lcd_cls ();
 
while(1)
{
lcd_cls ();
lcd_printp_at (0, 0, PSTR(" BT select Device "), 2);
// lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0);
lcd_puts_at(0, 7, strGet(KEYLINE1), 0);
 
while(1)
{
ii = 0;
 
if(Offset > 0)
lcd_printp_at(1, 1, PSTR("\x12"), 0);
 
for(ii = 0; ii < 6; ii++)
{
if((ii + Offset) < size)
{
if (strncmp (device_list[ii + Offset].mac, gps_UsedMac, 14) == 0)
{
lcd_puts_at(3, ii+1, device_list[ii + Offset].DevName, 2);
}
else
{
lcd_puts_at(3, ii+1, device_list[ii + Offset].DevName, 0);
}
}
 
if((ii == 5)&&(ii + Offset < (size - 1)))
lcd_printp_at(1, 6, PSTR("\x13"), 0);
 
}
 
if(dmode == 0)
{
if(Offset == 0)
{
if(size > 6)
val = menu_choose2 (1, 5, target_pos,0,1);
else
val = menu_choose2 (1, size, target_pos,0,0);
 
}
else
val = menu_choose2 (2, 5, target_pos,1,1);
 
}
 
if(dmode == 1)
{
if(Offset + 7 > size)
val = menu_choose2 (2, 6, target_pos, 1, 0);
else
val = menu_choose2 (2, 5, target_pos, 1, 1);
 
}
 
if(val == 254)
{
Offset++;
dmode = 1;
target_pos = 5;
}
else if(val == 253)
{
Offset--;
dmode = 0;
target_pos = 2;
}
else if(val == 255)
{ // Ende mit ESC, speichern
if (edit == 1)
{
WriteParameter();
}
 
return;
}
else
 
break;
}
target_pos = val;
 
if(val > 0 )
{
for(uint8_t i = 0; i < 14; i++)
{
gps_UsedMac[i] = device_list[val-1].mac[i];
}
for(uint8_t i = 0; i < 20; i++)
{
gps_UsedDevName[i] = device_list[val-1].DevName[i];
}
edit = 1;
}
}
}
#endif
 
//--------------------------------------------------------------
//
void BT_Setup (void)
{
uint8_t ii = 0;
uint8_t Offset = 0;
uint8_t size = 0;
size = ITEMS_BT;
uint8_t dmode = 0;
uint8_t target_pos = 1;
uint8_t val;
char string[20];
 
mmode = 0;
edit = 0;
val = 0;
// BTIsSet = true;
 
lcd_cls ();
 
while(1)
{
lcd_cls ();
// lcd_printp_at (0, 0, PSTR(" BTM-222 Setup "), 2);
lcd_puts_at(0, 0, strGet(BT1), 2);
// lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0);
lcd_puts_at(0, 7, strGet(KEYLINE1), 0);
 
while(1)
{
ii = 0;
 
if(Offset > 0)
lcd_printp_at(1,1, PSTR("\x12"), 0);
 
for(ii = 0; ii < 6; ii++)
{
if((ii + Offset) < size)
lcd_printp_at(3, ii + 1, param_menuitems_bt[ii+Offset][DisplayLanguage], 0);
 
if((ii == 5) && (ii + Offset < (size - 1)))
lcd_printp_at(1,6, PSTR("\x13"), 0);
 
}
 
if(dmode == 0)
{
if(Offset == 0)
{
if(size > 6)
val = menu_choose2 (1, 5, target_pos, 0, 1);
else
val = menu_choose2 (1, size, target_pos, 0, 0);
 
}
else
val = menu_choose2 (2, 5, target_pos, 1, 1);
 
}
 
if(dmode == 1)
{
if(Offset + 7 > size)
val = menu_choose2 (2, 6, target_pos, 1, 0);
else
val = menu_choose2 (2, 5, target_pos, 1, 1);
}
 
if(val == 254)
{
Offset++;
dmode = 1;
target_pos = 5;
}
else if(val == 253)
{
Offset--;
dmode = 0;
target_pos = 2;
}
else if(val == 255)
{ // Ende mit ESC, speichern
// if (edit == 1)
// {
// if (UseBT == 1);
// if (bt_init()) BTIsSet = true; else BTIsSet = false;
// WriteParameter();
// return;
// }
return;
}
else
 
if (edit == 1)
{
if (UseBT == 1);
if (bt_init()) BTIsSet = true; else BTIsSet = false;
WriteParameter();
return;
}
 
 
 
 
break;
}
 
target_pos = val;
if((val + Offset) == 1)
// BT_Use();
UseBT = Edit_YesNo(UseBT,0,1,BT4);
 
if((val + Offset) == 2)
{
for (uint8_t i = 0; i < bt_name_length; i++)
{
string[i] = bt_name[i];
}
string[bt_name_length] = 0;
Edit_String(string, bt_name_length, 1, PSTR(" Bluetooth Name "));
if (edit == 1)
{
for (uint8_t i = 0; i < bt_name_len; i++)
{
bt_name[i] = EditString[i];
WriteParameter();
}
 
if (bt_name_len < 10)
{
for (uint8_t i = bt_name_len; i < 10; i++)
{
bt_name[i] = ' ';
WriteParameter();
}
}
}
}
 
if((val + Offset) == 3)
{
for (uint8_t i = 0; i < bt_pin_length; i++)
{
string[i] = bt_pin[i];
}
string[bt_pin_length] = 0;
Edit_String(string, bt_pin_length, 2, PSTR(" Bluetooth Pin "));
if (edit == 1)
{
for (uint8_t i = 0; i < bt_pin_length; i++)
{
bt_pin[i] = EditString[i];
WriteParameter();
}
}
}
 
if((val + Offset) == 4)
{
// if (edit == 1)
// if(BTIsSet)
// BTIsSet = false;
 
if (bt_init() == true)
{
lcd_printp_at (0, 3, PSTR("BT Init ok"), 0);
WriteBTInitFlag();
}
else
{
lcd_printp_at (0, 3, PSTR("BT Init Error"), 0);
BTIsSet = false;
set_beep ( 1000, 0x0040, BeepNormal);
 
}
}
 
if((val + Offset) == 5)
Port_FC2CFG_BT();
 
 
}
}
 
 
void GPS_Setup (void)
{
uint8_t ii = 0;
uint8_t Offset = 0;
uint8_t size = 0;
size = ITEMS_GPS;
uint8_t dmode = 0;
uint8_t target_pos = 1;
uint8_t val;
uint8_t BT_WhasOn = 0;
 
mmode = 0;
edit = 0;
val = 0;
lcd_cls ();
 
while(1)
{
lcd_cls ();
// lcd_printp_at (0, 0, PSTR(" PKT Accu Setup "), 2);
lcd_puts_at(0, 0, strGet(GPS1), 2);
// lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0);
lcd_puts_at(0, 7, strGet(KEYLINE1), 0);
 
while(1)
{
ii = 0;
 
if(Offset > 0)
lcd_printp_at(1,1, PSTR("\x12"), 0);
 
for(ii = 0; ii < 6; ii++)
{
if((ii + Offset) < size)
lcd_printp_at(3, ii + 1, param_menuitems_GPS[ii+Offset][DisplayLanguage], 0);
 
if((ii == 5) && (ii + Offset < (size - 1)))
lcd_printp_at(1,6, PSTR("\x13"), 0);
 
}
 
if(dmode == 0)
{
if(Offset == 0)
{
if(size > 6)
val = menu_choose2 (1, 5, target_pos, 0, 1);
else
val = menu_choose2 (1, size, target_pos, 0, 0);
 
}
else
val = menu_choose2 (2, 5, target_pos, 1, 1);
 
}
 
if(dmode == 1)
{
if(Offset + 7 > size)
val = menu_choose2 (2, 6, target_pos, 1, 0);
else
val = menu_choose2 (2, 5, target_pos, 1, 1);
}
 
if(val == 254)
{
Offset++;
dmode = 1;
target_pos = 5;
}
else if(val == 253)
{
Offset--;
dmode = 0;
target_pos = 2;
}
else if(val == 255)
{ // Ende mit ESC, speichern
if (edit == 1)
{
// WriteParameter();
if (BT_WhasOn)
{
set_BTOn();
// bt_set_mode(SLAVE);
bt_init();
set_BTOff();
}
 
return;
}
return;
}
else
break;
}
 
target_pos = val;
//
// {"Suche GPS Maus ","search GPS mouse ","search GPS mouse ","search GPS mouse "},
// {"GPS Maus Typ ","GPS mouse typ ","GPS mouse typ ","GPS mouse typ "},
// {"GPS Maus aktiv? ","GPS mouse activ? ","GPS mouse activ? ","GPS mouse activ? "},
// {"Zeige GPS Device ","show GPS device ","show GPS device ","show GPS device "},
//
 
if((val + Offset) == 1)
{
if (bt_devicecount ==0)
{
lcd_cls ();
lcd_printp_at (0, 0, PSTR("wähle BT Device"), 0);
set_BTOn();
BT_WhasOn = true;
// _delay_ms(2000);
bt_downlink_init();
bt_searchDevice();
set_BTOff();
BT_SelectDevice();
}
else
BT_SelectDevice();
// if (edit == 1) WriteParameter();
}
 
if((val + Offset) == 2)
{
lcd_cls ();
lcd_printp_at (0, 0, PSTR("suche BT Device"), 0);
set_BTOn();
// _delay_ms(2000);
BT_WhasOn = true;
bt_downlink_init();
bt_searchDevice();
set_BTOff();
BT_SelectDevice();
}
if((val + Offset) == 4)
{
gps_UseGPS = Edit_YesNo(gps_UseGPS,0,1,GPS3);
if (edit == 1) WriteParameter();
}
 
if((val + Offset) == 5)
{
lcd_cls ();
lcd_puts_at(0, 0, strGet(GPS2), 2);
lcd_puts_at(18, 7, strGet(OK), 0);
lcd_printp_at (0, 1, PSTR("Device:"), 0);
lcd_printp_at (0, 4, PSTR("MAC:"), 0);
 
lcd_puts_at (0, 2,gps_UsedDevName, 0);
 
for(uint8_t i = 0; i < 12; i++)
{
lcd_putc (i, 5, gps_UsedMac[i],0);
}
 
while (!get_key_press (1 << KEY_ENTER));
 
}
 
 
if((val + Offset) == 6)
{
lcd_cls ();
lcd_puts_at(18, 7, strGet(OK), 0);
lcd_puts_at (0, 0,gps_UsedDevName, 2);
set_BTOn();
BT_WhasOn = true;
if (BTIsSlave==true)
{
bt_downlink_init();
}
if (bt_connect(gps_UsedMac))
{
lcd_printp_at (0, 1, PSTR("connected"), 0);
receiveNMEA = true;
}
if (receiveNMEA)
{
lcd_printp_at (0, 3, PSTR(" Latitude Longitude"), 2);
do
{
// if (!bt_receiveNMEA()) break;
//// Tracking_NMEA();
 
write_ndigit_number_u (1, 4, (uint16_t)(NMEAlatitude/10000000), 2, 0,0);
lcd_printp_at (3, 4, PSTR("."), 0);
write_ndigit_number_u (4, 4, (uint16_t)((NMEAlatitude/1000) % 10000), 4, 1,0);
write_ndigit_number_u (8, 4, (uint16_t)((NMEAlatitude/10) % 100), 2, 1,0);
 
 
write_ndigit_number_u (12, 4, (uint16_t)(NMEAlongitude/10000000), 2, 0,0);
lcd_printp_at (14, 4, PSTR("."), 0);
write_ndigit_number_u (15, 4, (uint16_t)((NMEAlongitude/1000) % 10000), 4, 1,0);
write_ndigit_number_u (19, 4, (uint16_t)((NMEAlongitude/10) % 100), 2, 1,0);
lcd_printp_at (0, 2, PSTR("GPS Time: "), 0);
lcd_puts_at (10, 2, NMEATime, 0);
lcd_printp_at (0, 6, PSTR(" Satellite: "), 0);
write_ndigit_number_u (13, 6, NMEAsatsInUse, 2, 1,0);
// lcd_printp_at (0, 2, PSTR(" BT RX Error: "), 0);
// write_ndigit_number_u (13, 2, bt_rxerror, 3, 1);
 
}
 
while (!get_key_press (1 << KEY_ENTER));
 
lcd_cls_line(0,1,21);
lcd_cls_line(0,2,21);
lcd_cls_line(0,3,21);
lcd_cls_line(0,4,21);
lcd_cls_line(0,5,21);
lcd_cls_line(0,6,21);
lcd_printp_at (0, 3, PSTR("GPS trennen"), 0);
}
else
{
lcd_printp_at (0, 1, PSTR("Error at connecting"), 0);
while (!get_key_press (1 << KEY_ENTER));
}
receiveNMEA = false;
if (!bt_disconnect()) lcd_printp_at (0, 3, PSTR("Fehler beim Trennen"), 0);
 
set_BTOff();
 
}
 
 
}
}
 
 
 
 
//--------------------------------------------------------------
uint8_t Edit_PKT_Accu(uint8_t Value, uint8_t min, uint8_t max)
{
Pre = Value;
lcd_cls();
// lcd_printp_at (0, 2, Text, 0);
lcd_puts_at(0, 2, strGet(LIPO2), 0);
switch (Value)
{
case false :lcd_printp_at (15, 2, PSTR("LiIo"), 0);
break;
case true :lcd_printp_at (15, 2, PSTR("LiPo"), 0);
break;
break;
}
 
// lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0);
lcd_puts_at(0, 7, strGet(KEYLINE2), 0);
 
do
{
if ((get_key_press (1 << KEY_PLUS)) && (Value == 0))
{
Value = 1;
lcd_printp_at (15, 2, PSTR("LiPo"), 0);
}
 
if ((get_key_press (1 << KEY_MINUS)) && (Value == 1))
{
Value = 0;
lcd_printp_at (15, 2, PSTR("LiIo"), 0);
}
 
if (get_key_press (1 << KEY_ENTER))
{
edit = 1;
 
PKT_Accutyp = Value;
// WriteParameter();
 
return Value;
}
}
 
while (!get_key_press (1 << KEY_ESC));
{
get_key_press(KEY_ALL);
edit = 0;
PKT_Accutyp = Pre;
return Pre;
}
 
}
 
//--------------------------------------------------------------
uint16_t Edit_LipoOffset(uint16_t Value, uint16_t min, uint16_t max)
{
lcd_cls();
// lcd_printp_at (0, 2, Text, 0);
lcd_puts_at(0, 2, strGet(LIPO3), 0);
lcd_puts_at(0, 5, strGet(LIPO5), 0);
lcd_puts_at(0, 6, strGet(LIPO6), 0);
// lcd_printp_at (0, 3, PSTR("Offset verstellen bis"), 0);
// lcd_printp_at (0, 4, PSTR("die Spannung passt"), 0);
Pre16 = Value;
write_ndigit_number_u (16, 2, Value, 4, 0,0);
// lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0);
lcd_puts_at(0, 7, strGet(KEYLINE2), 0);
 
do
{
if ((get_key_press (1 << KEY_PLUS) || get_key_long_rpt_sp ((1 << KEY_PLUS), 2)) && (Value < max-10))
{
edit = 1;
Value = Value +10;
Lipo_UOffset = Value;
write_ndigit_number_u (16, 2,Value, 4, 0,0);
 
}
 
if ((get_key_press (1 << KEY_MINUS) || get_key_long_rpt_sp ((1 << KEY_MINUS), 2)) && (Value > min))
{
edit = 1;
Value=Value -10;
Lipo_UOffset = Value;
write_ndigit_number_u (16, 2,Value, 4, 0,0);
}
 
if (get_key_press (1 << KEY_ENTER))
return Value;
#ifndef ohne_Lipo // MartinR
show_Lipo();
#endif
write_ndigit_number_u_100th(8, 3, volt_avg, 0, 0);
lcd_printp_at(3, 3, PSTR("Volt"), 0);
 
}
while (!get_key_press (1 << KEY_ESC));
{
get_key_press(KEY_ALL);
edit = 0;
Lipo_UOffset = Pre16;
return Pre16;
}
}
 
//--------------------------------------------------------------
void Accu_Setup (void)
{
uint8_t ii = 0;
uint8_t Offset = 0;
uint8_t size = 0;
size = ITEMS_Accu;
uint8_t dmode = 0;
uint8_t target_pos = 1;
uint8_t val;
 
mmode = 0;
edit = 0;
val = 0;
lcd_cls ();
 
while(1)
{
lcd_cls ();
// lcd_printp_at (0, 0, PSTR(" PKT Accu Setup "), 2);
lcd_puts_at(0, 0, strGet(LIPO1), 2);
// lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0);
lcd_puts_at(0, 7, strGet(KEYLINE1), 0);
 
while(1)
{
ii = 0;
 
if(Offset > 0)
lcd_printp_at(1,1, PSTR("\x12"), 0);
 
for(ii = 0; ii < 6; ii++)
{
if((ii + Offset) < size)
lcd_printp_at(3, ii + 1, param_menuitems_Accu[ii+Offset][DisplayLanguage], 0);
 
if((ii == 5) && (ii + Offset < (size - 1)))
lcd_printp_at(1,6, PSTR("\x13"), 0);
 
}
 
if(dmode == 0)
{
if(Offset == 0)
{
if(size > 6)
val = menu_choose2 (1, 5, target_pos, 0, 1);
else
val = menu_choose2 (1, size, target_pos, 0, 0);
 
}
else
val = menu_choose2 (2, 5, target_pos, 1, 1);
 
}
 
if(dmode == 1)
{
if(Offset + 7 > size)
val = menu_choose2 (2, 6, target_pos, 1, 0);
else
val = menu_choose2 (2, 5, target_pos, 1, 1);
}
 
if(val == 254)
{
Offset++;
dmode = 1;
target_pos = 5;
}
else if(val == 253)
{
Offset--;
dmode = 0;
target_pos = 2;
}
else if(val == 255)
{ // Ende mit ESC, speichern
if (edit == 1)
{
WriteParameter();
 
return;
}
return;
}
else
break;
}
 
target_pos = val;
if((val + Offset) == 1)
{
PKT_Accutyp= Edit_PKT_Accu(PKT_Accutyp,0,1);
if (edit == 1) WriteParameter();
}
 
if((val + Offset) == 2)
{
Lipo_UOffset = Edit_LipoOffset(Lipo_UOffset,0,9999);
if (edit == 1) WriteParameter();
}
 
}
}
 
 
//--------------------------------------------------------------
uint8_t Edit_LED_Form (uint8_t Value, uint8_t min, uint8_t max, uint8_t Text)
{
Pre = Value;
lcd_cls();
lcd_puts_at(0, 2, strGet(Text), 0);
 
switch (Value)
{
case 0x1:
lcd_circle (14 * 6 + 5, 2 * 8 + 3, 3, 1); // kreis
 
lcd_fcircle (16 * 6 + 5, 2 * 8 + 3, 3, 0); // löschen
lcd_circle (16 * 6 + 5, 2 * 8 + 3, 3, 1); // kreis
lcd_fcircle (16 * 6 + 5, 2 * 8 + 3, 1, 1); // plus
break;
case 0x3 :
lcd_circle (14 * 6 + 5, 2 * 8 + 3, 3, 1); // kreis
 
lcd_fcircle (16 * 6 + 5, 2 * 8 + 3, 3, 1); // schwarz
break;
break;
}
 
lcd_puts_at(0, 7, strGet(KEYLINE2), 0);
 
do
{
if ((get_key_press (1 << KEY_PLUS)) && (Value == 1))
{
Value = 3;
lcd_circle (14 * 6 + 5, 2 * 8 + 3, 3, 1); // kreis
 
lcd_fcircle (16 * 6 + 5, 2 * 8 + 3, 3, 1); // schwarz
}
 
if ((get_key_press (1 << KEY_MINUS)) && (Value == 3))
{
Value = 1;
lcd_circle (14 * 6 + 5, 2 * 8 + 3, 3, 1); // kreis
 
lcd_fcircle (16 * 6 + 5, 2 * 8 + 3, 3, 0); // löschen
lcd_circle (16 * 6 + 5, 2 * 8 + 3, 3, 1); // kreis
lcd_fcircle (16 * 6 + 5, 2 * 8 + 3, 1, 1); // plus
}
 
if (get_key_press (1 << KEY_ENTER))
{
edit = 1;
OSD_LEDform = Value;
WriteParameter();
 
return Value;
}
}
 
while (!get_key_press (1 << KEY_ESC));
{
get_key_press(KEY_ALL);
edit = 0;
OSD_LEDform = Pre;
return Pre;
}
}
 
 
//--------------------------------------------------------------
void OSD_Setup (void)
{
uint8_t ii = 0;
uint8_t Offset = 0;
uint8_t size = 0;
size = ITEMS_OSD;
uint8_t dmode = 0;
uint8_t target_pos = 1;
uint8_t val;
 
mmode = 0;
edit = 0;
val = 0;
lcd_cls ();
 
while(1)
{
lcd_cls ();
lcd_puts_at(0, 0, strGet(OSD_Screen), 2);
lcd_puts_at(0, 7, strGet(KEYLINE1), 0);
 
while(1)
{
ii = 0;
 
if(Offset > 0)
lcd_printp_at(1,1, PSTR("\x12"), 0);
 
for(ii = 0; ii < 6; ii++)
{
if((ii + Offset) < size)
lcd_printp_at(3, ii + 1, param_menuitems_OSD[ii+Offset][DisplayLanguage], 0);
 
if((ii == 5) && (ii + Offset < (size - 1)))
lcd_printp_at(1,6, PSTR("\x13"), 0);
 
}
 
if(dmode == 0)
{
if(Offset == 0)
{
if(size > 6)
val = menu_choose2 (1, 5, target_pos, 0, 1);
else
val = menu_choose2 (1, size, target_pos, 0, 0);
 
}
else
val = menu_choose2 (2, 5, target_pos, 1, 1);
 
}
 
if(dmode == 1)
{
if(Offset + 7 > size)
val = menu_choose2 (2, 6, target_pos, 1, 0);
else
val = menu_choose2 (2, 5, target_pos, 1, 1);
}
 
if(val == 254)
{
Offset++;
dmode = 1;
target_pos = 5;
}
else if(val == 253)
{
Offset--;
dmode = 0;
target_pos = 2;
}
else if(val == 255)
{ // Ende mit ESC, speichern
if (edit == 1)
{
WriteParameter();
 
return;
}
return;
}
else
break;
}
 
target_pos = val;
if((val + Offset) == 1) OSD_ScreenMode = Edit_Int_Value(OSD_ScreenMode, 0, 2, OSD_SCREENMODE);
if((val + Offset) == 2) OSD_LEDform = Edit_LED_Form(OSD_LEDform, 1, 3, OSD_LED_Form);
if((val + Offset) == 3) OSD_InvertOut = Edit_YesNo(OSD_InvertOut, 0, 1, OSD_Invert_Out);
if((val + Offset) == 4) OSD_SendOSD = Edit_YesNo(OSD_SendOSD, 0, 1, OSD_Send_OSD);
if((val + Offset) == 5) OSD_Fallspeed = Edit_Int10th_Value(OSD_Fallspeed,0,247,FALLSPEED);
if((val + Offset) == 6) OSD_VarioBeep = Edit_YesNo(OSD_VarioBeep,0,1,OSD_VARIOBEEP);
if((val + Offset) == 7) OSD_HomeMKView = Edit_YesNo(OSD_HomeMKView,0,1,OSD_HOMEMKVIEW);
if((val + Offset) == 8) MK_LowBat = Edit_Int10th_Value(MK_LowBat,32,247,LOWBAT);
if((val + Offset) == 9) OSD_mAh_Warning = Edit_Int16_Value(OSD_mAh_Warning,0,30000,OSD_MAHWARNING);
if((val + Offset) == 10)OSD_LipoBar = Edit_YesNo(OSD_LipoBar, 0, 1, OSD_LIPOBAR);
 
 
}
}
//--------------------------------------------------------------
void FollowMe_Setup (void)
{
uint8_t ii = 0;
uint8_t Offset = 0;
uint8_t size = 0;
size = ITEMS_FOLLOWME;
uint8_t dmode = 0;
uint8_t target_pos = 1;
uint8_t val;
 
mmode = 0;
edit = 0;
val = 0;
lcd_cls ();
 
while(1)
{
lcd_cls ();
lcd_puts_at(0, 0, strGet(FOLLOWME_0), 2);
lcd_puts_at(0, 7, strGet(KEYLINE1), 0);
 
while(1)
{
ii = 0;
 
if(Offset > 0)
lcd_printp_at(1,1, PSTR("\x12"), 0);
 
for(ii = 0; ii < 6; ii++)
{
if((ii + Offset) < size)
lcd_printp_at(3, ii + 1, param_menuitems_FOLLOWME[ii+Offset][DisplayLanguage], 0);
 
if((ii == 5) && (ii + Offset < (size - 1)))
lcd_printp_at(1,6, PSTR("\x13"), 0);
 
}
 
if(dmode == 0)
{
if(Offset == 0)
{
if(size > 6)
val = menu_choose2 (1, 5, target_pos, 0, 1);
else
val = menu_choose2 (1, size, target_pos, 0, 0);
 
}
else
val = menu_choose2 (2, 5, target_pos, 1, 1);
 
}
 
if(dmode == 1)
{
if(Offset + 7 > size)
val = menu_choose2 (2, 6, target_pos, 1, 0);
else
val = menu_choose2 (2, 5, target_pos, 1, 1);
}
 
if(val == 254)
{
Offset++;
dmode = 1;
target_pos = 5;
}
else if(val == 253)
{
Offset--;
dmode = 0;
target_pos = 2;
}
else if(val == 255)
{ // Ende mit ESC, speichern
if (edit == 1)
{
WriteParameter();
 
return;
}
return;
}
else
break;
}
 
target_pos = val;
if((val + Offset) == 1) FM_Refresh = Edit_Int16_Value(FM_Refresh, 250, 60000, FOLLOWME_1);
if((val + Offset) == 2) FM_Speed = Edit_Int16_Value(FM_Speed, 0, 100, FOLLOWME_2);
if((val + Offset) == 3) FM_Radius = Edit_Int16_Value(FM_Radius, 1,20, FOLLOWME_3);
 
}
}
 
#endif