Blame |
Last modification |
View Log
| RSS feed
/*****************************************************************************
* 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 <stdlib.h>
#include <stdbool.h>
#include <util/delay.h>
#include "main.h"
#include "setup.h"
#include "lcd.h"
#include "menu.h"
#include "servo.h"
#include "motortest.h"
#include "eeprom.h"
#include "timer.h"
#include "connect.h"
#ifdef HWVERSION3_9
#include "HAL_HW3_9.h"
#endif
#ifdef HWVERSION1_3
#include "HAL_HW1_3.h"
#endif
//#include "voltmeter.h"
#include "lipo.h"
#include "messages.h"
//--------------------------------------------------------------
#define ITEMS_PKT 6
prog_char tools_menuitems_pkt[ITEMS_PKT][NUM_LANG][18]= // zeilen,zeichen+1
// German, English, French, Netherlands
{
{"Motor Tester ","Motor Tester ","Motor Tester ","Motor Tester "},
{"Servo Tester ","Servo Tester ","Servo Tester ","Servo Tester "},
{"PC BT > Kopter ","PC BT > Kopter ","PC BT > Kopter ","PC BT > Kopter "},
{"PC USB > Kopter ","PC USB > Kopter ","PC USB > Kopter ","PC USB > Kopter "},
{"PKT Setup \x1d","PKT Setup \x1d","PKT Setup \x1d","PKT Setup \x1d"},
{"PKT Version ","PKT Version ","PKT Version ","PKT Version "},
};
//--------------------------------------------------------------
void PKT_Tools (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;
val = 0;
while(1)
{
lcd_cls ();
lcd_printp_at (0, 0, PSTR(" PKT-Tools "), 2);
// lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0);
lcd_puts_at(0, 7, strGet(KEYLINE1), 0);
while(2)
{
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,tools_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)
{
return;
}
else
{
break;
}
}
target_pos = val;
if((val+Offset) == 1 )
motor_test(FC_Mode);
if((val+Offset) == 2 )
servo_test();
#ifdef HWVERSION3_9
if(U02SV2 == 0)
{
if((val+Offset) == 3 )
Port_BT2Wi();
if((val+Offset) == 4 )
Port_USB2Wi();
}
else if(U02SV2 == 1)
{
if((val+Offset) == 3 )
Port_BT2FC();
if((val+Offset) == 4 )
Port_USB2FC();
}
#else
if((val+Offset) == 3 )
Show_Error_HW();
if((val+Offset) == 4 )
Show_Error_HW();
#endif
if((val+Offset) == 5)
PKT_Setup();
if((val+Offset) == 6)
Show_Version();
}
}
//--------------------------------------------------------------
//
void PC_Fast_Connect (void)
{
uint8_t value = 1;
while(1)
{
lcd_cls();
// lcd_printp_at (0, 0, PSTR(" PC-Quick-Verbindung "), 2);
lcd_puts_at(0, 8, strGet(TOOLS1), 2);
lcd_printp_at (3, 3, PSTR("PC BT > Kopter"), 0);
lcd_printp_at (3, 4, PSTR("PC USB > Kopter"), 0);
// lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0);
lcd_puts_at(0, 7, strGet(KEYLINE1), 0);
// lcd_puts_at(0, 7, strGet(KEYLINE1), 0);
while(2)
{
if(value == 1)
{
lcd_printp_at (1, 3, PSTR("\x1d"), 0);
lcd_printp_at (1, 4, PSTR(" "), 0);
}
else
{
lcd_printp_at (1, 3, PSTR(" "), 0);
lcd_printp_at (1, 4, PSTR("\x1d"), 0);
}
if(get_key_press (1 << KEY_MINUS))
value = 1;
if(get_key_press (1 << KEY_PLUS))
value = 2;
if(get_key_short (1 << KEY_ENTER))
{
#ifdef HWVERSION3_9
if(U02SV2 == 0)
{
if(value == 1)
Port_BT2Wi();
if(value == 2)
Port_USB2Wi();
}
else if(U02SV2 == 1)
{
if(value == 1)
Port_BT2FC();
if(value == 2)
Port_USB2FC();
}
#else
if(value == 1)
Show_Error_HW();
if(value == 2)
Show_Error_HW();
#endif
break;
}
if(get_key_press (1 << KEY_ESC))
{
get_key_press(KEY_ALL);
return;
}
}
}
}
void Test_HB (void) // bleibt für Tests
{
// ADC_Init();
//
// uint16_t volt_avg = 0;
//// uint64_t volt_tmp = 0;
// uint16_t Balken = 0;
lcd_cls();
lcd_printp_at(12, 7, PSTR("Ende"), 0);
// lcd_rect(104, 0, 23, 8, 1); // Rahmen
do
{
//
//
if(samples>4095)
{
// write_ndigit_number_u(0, 4, accumulator, 5, 0);
oversampled();
volt_avg = Vin;
}
// // write_ndigit_number_u(0, 3, samples, 5, 0);
//
//// write_ndigit_number_u(0, 1, Vin, 5, 0);
// _delay_ms(50);
show_Lipo();
write_ndigit_number_u_100th(5, 5, volt_avg, 0, 0);
lcd_printp_at(10, 5, PSTR("Volt"), 0);
//
//
//
write_ndigit_number_u(0, 6, Lipo_UOffset, 5, 0);
// write_ndigit_number_u(15, 6, WarnCount, 4, 0);
//// write_ndigit_number_u(10, 5, Vcorr, 4, 0);
if (get_key_press (1 << KEY_PLUS) | get_key_long_rpt_sp ((1 << KEY_PLUS), 3))
{
Lipo_UOffset = Lipo_UOffset +10;
}
if (get_key_press (1 << KEY_MINUS) | get_key_long_rpt_sp ((1 << KEY_MINUS),3))
{
Lipo_UOffset = Lipo_UOffset -10;
}
//
}
while(!get_key_press (1 << KEY_ESC));
get_key_press(KEY_ALL);
return;
}