0,0 → 1,1969 |
/***************************************************************************** |
* 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" |
|
|
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; |
uint8_t Pre; |
uint16_t Pre16; |
char EditString[21]; |
uint8_t bt_name_len; |
|
|
//-------------------------------------------------------------- |
#define ITEMS_PKT 9 |
|
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"}, |
{"MK LowBat Warnung","MK LowBat warning","MK LowBat Attent", "MK LowBat waarsch"}, |
{"Anzeige \x1d","Display \x1d","d'affichage \x1d","tonen \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"}, |
{"PKT-Akku \x1d","PKT-Accu \x1d","PKT-Accu \x1d","PKT-Accu \x1d"}, |
{"PKT Update ","PKT Update ","PKT Mise à jour ","PKT Update "}, |
{"Debug PKT ","Debug PKT ","Debug PKT ","Debug PKT "}, |
{"EEProm Reset ","EEProm Reset ","EEProm Réinitiali","EEProm Reset "}, |
}; |
|
#define ITEMS_LCD 7 |
|
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","Infor. o.de start"}, |
{"Sprache ","language ","Langue ","taal "}, |
{"Licht aus nach...","light off after ","Lumière au bout ","Lichten uit voor "}, |
{"Helligkeit ","brightness ","luminosité ","helderheid "}, |
{"Kontrast ","contrast ","contraste ","contrast "}, |
{"Normal/Invers ","normal/inverted ","Normal / inversé ","Normal/inverted "}, |
{"Orientierung ","orientation ","orientation ","orientatie "}, |
|
}; |
|
#define ITEMS_WI 8 |
|
prog_char param_menuitems_wi[ITEMS_WI][NUM_LANG][18]= // zeilen,zeichen+1 |
// German, English, French, Dutch |
{ |
{"Modul eingebaut? ","module built in? ","Module installé ","module geïnstall?"}, |
{"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 "}, |
{"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 installé ","module geïnstall?"}, |
{"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"}, |
}; |
|
//-------------------------------------------------------------- |
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); |
// 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); |
} |
|
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); |
} |
|
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); |
// 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); |
} |
|
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); |
} |
|
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 ||HWVERSION1_3W |
//-------------------------------------------------------------- |
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 |
//-------------------------------------------------------------- |
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; |
} |
} |
|
|
//-------------------------------------------------------------- |
uint8_t Edit_StartInfo(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; |
// 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; |
// 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; |
// 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; |
// 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_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); |
// 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); |
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; |
BeepTime = 200; |
BeepMuster = 0x0080; |
} |
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; |
BeepTime = 200; |
BeepMuster = 0x0080; |
} |
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); |
|
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); |
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); |
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; |
BeepTime = 200; |
BeepMuster = 0x0080; |
} |
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; |
BeepTime = 200; |
BeepMuster = 0x0080; |
} |
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; |
|
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) |
MK_LowBat = Edit_Int10th_Value(MK_LowBat,33,247,LOWBAT); |
|
if((val + Offset) == 3) |
Display_Setup(); |
|
if((val + Offset) == 4) |
{ |
#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(); |
} |
|
else |
Wi_Setup(); |
#else |
Show_Error_HW12(); |
#endif |
} |
|
if((val + Offset) == 5) |
{ |
#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) == 6) |
#ifdef HWVERSION3_9 |
Accu_Setup(); |
#else |
Show_Error_HW12(); |
#endif |
if((val + Offset) == 7) |
Update_PKT(); |
|
if((val + Offset) == 8) |
Debug = Edit_Int_Value(Debug,0,1,DEBUGPKT); |
|
if((val + Offset) == 9) |
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_StartInfo(PKT_StartInfo,0,2,DISPLAY2); |
|
if((val + Offset) == 2) |
DisplayLanguage = Edit_Language(DisplayLanguage,0,3,DISPLAY3); |
// Edit_Language(DisplayLanguage,0,3,DISPLAY3); |
|
if((val + Offset) == 3) |
DisplayTimeout = Edit_Int_Value(DisplayTimeout,0,254,DISPLAY4); |
|
if((val + Offset) == 4) |
LCD_Helligkeit = Edit_DisplayHelligkeit(LCD_Helligkeit,0,100,DISPLAY5); |
if (edit == 1) |
if(!LCD_Change) |
LCD_Change =1; |
|
if((val + Offset) == 5) |
LCD_Kontrast = Edit_DisplayKontrast(LCD_Kontrast,0,63,DISPLAY6); |
if (edit == 1) |
if(!LCD_Change) |
LCD_Change =1; |
|
if((val + Offset) == 6) |
{ |
LCD_DisplayMode = Edit_DisplayMode(LCD_DisplayMode,0,4,DISPLAY7); |
if (edit == 1) |
if(!LCD_Change) |
LCD_Change =1; |
} |
|
if((val + Offset) == 7) |
{ |
LCD_Orientation = Edit_Orientation(LCD_Orientation,0,4,DISPLAY8); |
if (edit == 1) |
if(!LCD_Change) |
LCD_Change =1; |
} |
|
|
|
|
} |
} |
|
#if defined HWVERSION3_9 ||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(); |
// WriteParameter(); |
// } |
|
return; |
} |
else |
|
if (edit == 1) |
{ |
if (UseWi==true) InitWi232(); |
WriteParameter(); |
} |
|
|
|
|
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,WINETWG); |
|
} |
|
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) |
InitWi232(); |
|
if((val + Offset) == 8) |
Port_USB2CFG_Wi(); |
} |
} |
#endif |
|
#ifdef HWVERSION3_9 |
//-------------------------------------------------------------- |
// |
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; |
} |
} |
|
|
////-------------------------------------------------------------- |
//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; |
// } |
// } |
//} |
|
|
//-------------------------------------------------------------- |
// |
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,BT1); |
|
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; |
BeepTime = 1000; |
BeepMuster = 0x0040; |
} |
} |
|
if((val + Offset) == 5) |
Port_FC2CFG_BT(); |
|
|
} |
} |
|
//-------------------------------------------------------------- |
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); |
// 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); |
|
} |
|
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); |
} |
|
if (get_key_press (1 << KEY_ENTER)) |
return Value; |
show_Lipo(); |
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(); |
} |
|
} |
} |
|
|
#endif |