/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/CHANGE.LOG |
---|
0,0 → 1,92 |
/**************************************************************************** |
* Copyright (C) 2011 by Christian "cebra" Brandtner * |
* brandtner@brandtner.net * |
* * |
* 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. * |
****************************************************************************/ |
!!Vor dem Kompilieren in der main.h die Hardwareversion einstellen!! |
24.1.2012 V3.5.8d Cebra |
Fehlerpiepen beim Empfangsausfall im OSD Screen ist im Setup schaltbar |
23.2.2012 V3.5.8c Cebra |
Sprachunterstützung verbessert |
Letzte Postion in OSD verbessert, bei Datenverlust automatisches Reconnect |
Akkuanzeige im MK-USB Betrieb. |
7.1.2012 V3.5.8 Cebra |
Languagesupport für die Menüs eingebaut, 4 Sprachen sind möglich, z.Z. Deutsch und Englisch in den Menüs und zusätzlich Französisch im Parametermenü. |
Ein paar Änderungen im Bereich Setup Wi232 und BTM222 |
30.12.2011 V3.5.7a Cebra |
Moduleinit wurde nicht immer gespeichert, dadurch Init der Module beim Start obwohl nicht notwendig. |
Bluetooth wird beim ersten Betätigen der Einschalttaste aktiviert um USB auszuschalten, damit der angeschlossene PC erstmal ruhig bleibt. |
30.12.2011 V3.5.7 Cebra |
PKT Setup für Akkutyp und Spannungsmessung |
28.12.2011 V3.5.6a Cebra |
Lipo Spannungsmessung eingebaut |
26.10.2011 V3.5.3 Cebra |
Fehler bei der Bluetoothinitialisierung beseitigt |
25.8.2011 V3.4.4Cebra |
Initsequenzen für Wi232 und BT erfolgen nur wenn sich was ändert oder sie neu sind. |
Lipowarnung verbessert |
Lastposition in OSD wird gespeichern wenn Verbindung zum MK verlorengegenagen ist |
Beim Start von PKT wird sie angezeigt. |
14.08.2011 V3.4.3 Cebra |
Anpassungen an neue Hardware, Bluetooth, Wi232, interne seriell Switche, PKT Lipowarnung |
30.7.2011 V3.4.1 Cebra |
Abschalten des PKT über Menütaste |
29.7.2011 V3.4.0 Cebra |
Summeranschaltung für HW1.2 angepasst, ist jetzt Summer an GND und Pin 25 |
Vorbereitungen für neue Hardware 3.9 |
25.7.2011 V3.3.4 |
BL-Controller(0-12) Test with CSV-Output over USB (HW1.2 Uart0, HW>1.2 Uart1=USB) |
Setupmenu Wi232 Parameter Uart Timeout, Uart MTU |
15.7.2011 V3.2.3 |
HW1.3 |
Beim Rücksprung aus der Wi Konfig fällt die rechte Led der Beleuchtung aus. |
(PGM des Wi allerdings noch nicht angeschlossen!) |
nur durch Hardwareänderung lösbar PD6 Pin für Wi232 |
Die Pfeile am Display im Setup PMK Menue sind noch <- -> statt oben und unten. |
1.7.2011 cebra |
Bugfixes: Summer(PC7) bei Unterspannung, Setup Wi232, Kosmetik |
27.6.2011 cebra |
PKT Setup überarbeitet, Setupmenü ist jetzt erweiterbar, Quick and Dirty war nix ;-) |
26.6.2011 cebra |
Das EEprom des PKT wird beim Starten geprüft ob es schon initialisiert ist. |
Falls nicht werden Defaultwerte gesetzt. |
Displayausrichtung kann im Setupmenü geändert werden |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/HAL_HW1_2.c |
---|
0,0 → 1,132 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
// *Hardwareabhängige Definitionen und Prozeduren |
// * Hardware Leiterplatte V1.2 sebseb7 |
#ifndef HAL_HW1_2_C_ |
#define HAL_HW1_2_C_ |
#include "cpu.h" |
#include <inttypes.h> |
#include <avr/io.h> |
#include <avr/interrupt.h> |
#include <avr/pgmspace.h> |
#include <avr/eeprom.h> |
#include <util/delay.h> |
#include "main.h" |
#if defined HWVERSION1_2W || defined HWVERSION1_2 |
#include "usart.h" |
#include "uart1.h" |
#include "lcd.h" |
#include "display.h" |
#include "timer.h" |
#include "eeprom.h" |
#include "Wi232.h" |
#include "twimaster.h" |
void InitHWPorts(void) /* Initialisierung der Hardware für die jeweilige Leiterplattenversion */ |
{ |
// enable pull ups for the 4 keys |
PORTA |= (1<<PORTA4)|(1<<PORTA5)|(1<<PORTA6)|(1<<PORTA7); |
DDRC |= (1<<DDC0)|(1<<DDC1)|(1<<DDC6)|(1<<DDC5)|(1<<DDC7); |
DDRD |= (1<<DDD7); |
DDRB = 0xFF; |
set_LED1(); |
set_D_LIGHT(); |
Timer0_Init (); |
Timer1_Init (); // pwm |
Timer2_Init (); // Displaybeleuchtung |
LCD_Init (0); |
BeepTime = 500; |
BeepMuster = 0x0080; |
// _delay_ms(250); |
clr_LED1(); |
Display_on = 1; |
USART_Init (UART_BAUD_SELECT(USART_BAUD,F_CPU)); |
// I2C_Init(1); |
sei (); |
ReadParameter (); |
LCD_Init (1); |
OCR2A =LCD_Helligkeit*2.55; |
#ifdef HWVERSION1_2W |
if (WiIsSet==false) |
InitWi232(); /* wenn Wi232 nicht initialisiert ist, dann jetzt tun*/ |
else |
{ |
discoverWi232(); /* Wi232 suchen*/ |
_delay_ms(1000); |
} |
#endif |
} |
void set_D_LIGHT(void) /* Displaybeleuchtung ein*/ |
{ |
PORTC &= ~(1<<PORTC0); |
PORTC &= ~(1<<PORTC1); |
PORTD &= ~(1<<PORTD7); |
} |
void clr_D_LIGHT(void) /* Displaybeleuchtung aus*/ |
{ |
PORTC |= (1<<PORTC0); |
PORTC |= (1<<PORTC1); |
PORTD |= (1<<PORTD7); |
} |
#endif |
#endif /* HAL_HW3_2_C_ */ |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/HAL_HW1_2.h |
---|
0,0 → 1,99 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
// * Hardwareabhängige Definitionen und Prozeduren |
// * Hardware Leiterplatte V1.2 sebseb7 |
/* Belegung der Ports*/ |
/*Hardware 1.2 sebseb7 Portbelegung |
Servo PD4 Pin 13 |
Servo PD5 Pin 14 |
Displaybeleuchtung PD7 Pin 16 LED an + |
Displaybeleuchtung PC0 Pin 10 LED an + |
Displaybeleuchtung PC1 Pin 20 LED an + |
Summer PC6 Pin 25 Summer an GND |
Wi232 PC7 Pin 26 Wi232 CMD Pin |
*/ |
#ifndef HAL_HW1_2_H_ |
#define HAL_HW1_2_H_ |
#define set_cs() (PORTB |= (1 << PB4)) // Display |
#define clr_cs() (PORTB &= ~(1 << PB4)) |
#define set_reset() (PORTB |= (1 << PB2)) |
#define clr_reset() (PORTB &= ~(1 << PB2)) |
#define set_A0() (PORTB |= (1 << PB3)) // Data |
#define clr_A0() (PORTB &= ~(1 << PB3)) // Command |
#define set_scl() (PORTB |= (1 << PB7)) |
#define clr_scl() (PORTB &= ~(1 << PB7)) |
#define set_si() (PORTB |= (1 << PB5)) |
#define clr_si() (PORTB &= ~(1 << PB5)) |
#define set_LED1() (PORTC &= ~(1 << PC3)) // Leds |
#define clr_LED1() (PORTC |= (1 << PC3)) |
#define set_LED2() (PORTC &= ~(1 << PC2)) |
#define clr_LED2() (PORTC |= (1 << PC2)) |
#define set_LED3() (PORTB &= ~(1 << PB1)) |
#define clr_LED3() (PORTB |= (1 << PB1)) |
#define set_LED4() (PORTB &= ~(1 << PB0)) |
#define clr_LED4() (PORTB |= (1 << PB0)) |
#define clr_BEEP() (PORTC &= ~(1 << PC6)) //Summer |
#define set_BEEP() (PORTC |= (1 << PC6)) |
#define set_WI232CMD() (PORTC &= ~(1 << PC7)) |
#define clr_WI232CMD() (PORTC |= (1 << PC7)) |
#define KEY_PIN PINA |
#define KEY_ENTER PA7 |
#define KEY_ESC PA6 |
#define KEY_PLUS PA5 |
#define KEY_MINUS PA4 |
void set_D_LIGHT(void); /* Displaybeleuchtung ein*/ |
void clr_D_LIGHT(void); /* Displaybeleuchtung aus*/ |
void InitHWPorts(void); |
#endif /* HAL_HW1_2_H_ */ |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/HAL_HW1_3.c |
---|
0,0 → 1,137 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
// *Hardwareabhängige Definitionen und Prozeduren |
// * Hardware Leiterplatte V1.3 sebseb7 |
// * USB,LED |
#ifndef HAL_HW1_3_C_ |
#define HAL_HW1_3_C_ |
#include "cpu.h" |
#include <inttypes.h> |
#include <avr/io.h> |
#include <avr/interrupt.h> |
#include <avr/pgmspace.h> |
#include <avr/eeprom.h> |
#include <util/delay.h> |
#include "main.h" |
#if defined HWVERSION1_3W || defined HWVERSION1_3 |
#include "lcd.h" |
#include "usart.h" |
#include "uart1.h" |
#include "display.h" |
#include "timer.h" |
#include "eeprom.h" |
#include "Wi232.h" |
#include "twimaster.h" |
void InitHWPorts(void) /* Initialisierung der Hardware für die jeweilige Leiterplattenversion */ |
{ |
// enable pull ups for the 4 keys |
PORTA |= (1<<PORTA4)|(1<<PORTA5)|(1<<PORTA6)|(1<<PORTA7); |
DDRD |= (1<<DDD7)|(1<<DDD6); |
DDRC |= (1<<DDC2)|(1<<DDC3)|(1<<DDC6)|(1<<DDC5)|(1<<DDC7); /* Leds,Summer*/ |
DDRB = 0xFF; |
set_LED1(); |
BeepTime = 500; |
BeepMuster = 0x0080; |
set_D_LIGHT(); |
clr_WI232CMD(); |
_delay_ms(250); |
clr_LED1(); |
Display_on = 1; |
LCD_Init (0); |
USART_Init (UART_BAUD_SELECT(USART_BAUD,F_CPU)); |
uart1_init (UART_BAUD_SELECT(USART_BAUD,F_CPU)); /* USB*/ |
uart1_putc('R'); |
// I2C_Init(1); |
Timer0_Init (); |
Timer1_Init (); // pwm |
Timer2_Init (); // Displaybeleuchtung |
sei (); |
ReadParameter (); |
LCD_Init (1); |
OCR2A =LCD_Helligkeit*2.55; |
// InitWi232(); |
#ifdef HWVERSION1_3W |
if (WiIsSet==false) |
InitWi232(); /* wenn Wi232 nicht initialisiert ist, dann jetzt tun*/ |
else |
{ |
discoverWi232(); /* Wi232 suchen*/ |
_delay_ms(1000); |
} |
#endif |
} |
void set_D_LIGHT(void) /* Displaybeleuchtung ein*/ |
{ |
PORTD &= ~(1<<PORTD6); |
PORTC &= ~(1<<PORTC2); |
PORTD &= ~(1<<PORTD7); |
} |
void clr_D_LIGHT(void) /* Displaybeleuchtung aus*/ |
{ |
PORTD |= (1<<PORTD6); |
PORTD |= (1<<PORTD7); |
PORTC |= (1<<PORTC2); |
} |
#endif |
#endif /* HAL_HW1_3_C_ */ |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/HAL_HW1_3.h |
---|
0,0 → 1,108 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
// * Hardwareabhängige Definitionen und Prozeduren |
// * Hardware Leiterplatte V1.3 sebseb7 |
// * USB,LED |
/*Hardware 1.3.1 Portbelegung |
Servo PD4 Pin 13 |
Servo PD5 Pin 14 |
Bootlader LED PC3 Pin 22 LED an GND |
Summer PC6 Pin 25 Summer an GND |
Displaybeleuchtung PD6 Pin 15 LED an + |
Displaybeleuchtung PD7 Pin 16 LED an + |
Displaybeleuchtung PC2 Pin 21 LED an + |
Wi232 PC7 Pin 26 Wi232 CMD Pin |
*/ |
#ifndef HAL_HW1_3_H_ |
#define HAL_HW1_3_H_ |
#define set_cs() (PORTB |= (1 << PB4)) // Display |
#define clr_cs() (PORTB &= ~(1 << PB4)) |
#define set_reset() (PORTB |= (1 << PB2)) |
#define clr_reset() (PORTB &= ~(1 << PB2)) |
#define set_A0() (PORTB |= (1 << PB3)) // Data |
#define clr_A0() (PORTB &= ~(1 << PB3)) // Command |
#define set_scl() (PORTB |= (1 << PB7)) |
#define clr_scl() (PORTB &= ~(1 << PB7)) |
#define set_si() (PORTB |= (1 << PB5)) |
#define clr_si() (PORTB &= ~(1 << PB5)) |
#define clr_LED1() (PORTC &= ~(1 << PC3)) // Leds |
#define set_LED1() (PORTC |= (1 << PC3)) |
#define set_LED2() (PORTC &= ~(1 << PC2)) |
#define clr_LED2() (PORTC |= (1 << PC2)) |
#define set_LED3() (PORTB &= ~(1 << PB1)) |
#define clr_LED3() (PORTB |= (1 << PB1)) |
#define set_LED4() (PORTB &= ~(1 << PB0)) |
#define clr_LED4() (PORTB |= (1 << PB0)) |
#define clr_BEEP() (PORTC &= ~(1 << PC6)) //Summer |
#define set_BEEP() (PORTC |= (1 << PC6)) |
#define set_WI232CMD() (PORTC &= ~(1 << PC7)) |
#define clr_WI232CMD() (PORTC |= (1 << PC7)) |
#define KEY_PIN PINA |
#define KEY_ENTER PA7 |
#define KEY_ESC PA6 |
#define KEY_PLUS PA5 |
#define KEY_MINUS PA4 |
void set_D_LIGHT(void); /* Displaybeleuchtung ein*/ |
void clr_D_LIGHT(void); /* Displaybeleuchtung aus*/ |
void InitHWPorts(void); |
void Port_USB2FC(void); |
#endif /* HAL_HW1_3_H_ */ |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/HAL_HW3_1.c |
---|
0,0 → 1,122 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
// *Hardwareabhängige Definitionen und Prozeduren |
// * Hardware Leiterplatte V3.2 Cebra |
// * USB,Wi232,LED |
#ifndef HAL_HW3_2_C_ |
#define HAL_HW3_2_C_ |
#include "cpu.h" |
#include <inttypes.h> |
#include <avr/io.h> |
#include <avr/interrupt.h> |
#include <avr/pgmspace.h> |
#include <avr/eeprom.h> |
#include <util/delay.h> |
#include "main.h" |
#ifdef HWVERSION3_1 |
#include "lcd.h" |
#include "usart.h" |
#include "uart1.h" |
#include "display.h" |
#include "timer.h" |
#include "eeprom.h" |
#include "Wi232.h" |
#include "twimaster.h" |
void InitHWPorts(void) /* Initialisierung der Hardware für die jeweilige Leiterplattenversion */ |
{ |
// enable pull ups for the 4 keys |
PORTA |= (1<<PORTA4)|(1<<PORTA5)|(1<<PORTA6)|(1<<PORTA7); |
DDRD |= (1<<DDD7)|(1<<DDD6); |
DDRC |= (1<<DDC2)|(1<<DDC3)|(1<<DDC7); /* Leds,Summer*/ |
DDRB = 0xFF; |
set_LED1(); |
set_LED2(); |
set_LED3(); |
set_LED4(); |
BeepTime = 500; |
BeepMuster = 0x0080; |
set_D_LIGHT(); |
clr_WI232CMD(); |
_delay_ms(250); |
clr_LED1(); |
clr_LED2(); |
clr_LED3(); |
clr_LED4(); |
Display_on = 1; |
LCD_Init (); |
USART_Init (UART_BAUD_SELECT(USART_BAUD,F_CPU)); |
uart1_init (UART_BAUD_SELECT(USART_BAUD,F_CPU)); /* USB*/ |
uart1_putc('R'); |
I2C_Init(1); |
Timer0_Init (); |
Timer1_Init (); // pwm |
// TIMER2_Init(); //PWM Displaybeleuchtung |
sei (); |
ReadParameter (); |
LCD_Init (); |
InitWi232(); |
} |
#endif |
#endif /* HAL_HW3_2_C_ */ |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/HAL_HW3_1.h |
---|
0,0 → 1,108 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
// * Hardwareabhängige Definitionen und Prozeduren |
// * Hardware Leiterplatte V3.2 Cebra |
// * USB,Wi232,LED |
/* Hardware 3.1 Portbelegung |
Servo PD4 Pin 13 |
Servo PD5 Pin 14 |
Wi.232 CMD PD6 Pin 15 aktiv low |
Displaybeleuchtung PD7 Pin 16 LED an + |
I2C PC0 Pin 19 |
I2C PC1 Pin 20 |
LED2 PC2 Pin 21 LED an + |
LED1 PC3 Pin 22 LED an + |
Summer PC6 Pin 25 Summer an + |
LED3 PB1 Pin 41 LED an + |
LED4 PB0 Pin 40 LED an + |
*/ |
#ifndef HAL_HW3_2_H_ |
#define HAL_HW3_2_H_ |
#define set_cs() (PORTB |= (1 << PB4)) // Display |
#define clr_cs() (PORTB &= ~(1 << PB4)) |
#define set_reset() (PORTB |= (1 << PB2)) |
#define clr_reset() (PORTB &= ~(1 << PB2)) |
#define set_A0() (PORTB |= (1 << PB3)) // Data |
#define clr_A0() (PORTB &= ~(1 << PB3)) // Command |
#define set_scl() (PORTB |= (1 << PB7)) |
#define clr_scl() (PORTB &= ~(1 << PB7)) |
#define set_si() (PORTB |= (1 << PB5)) |
#define clr_si() (PORTB &= ~(1 << PB5)) |
#define set_LED1() (PORTC &= ~(1 << PC3)) // Leds |
#define clr_LED1() (PORTC |= (1 << PC3)) |
#define set_LED2() (PORTC &= ~(1 << PC2)) |
#define clr_LED2() (PORTC |= (1 << PC2)) |
#define set_LED3() (PORTB &= ~(1 << PB1)) |
#define clr_LED3() (PORTB |= (1 << PB1)) |
#define set_LED4() (PORTB &= ~(1 << PB0)) |
#define clr_LED4() (PORTB |= (1 << PB0)) |
#define set_BEEP() (PORTC &= ~(1 << PC6)) //Summer |
#define clr_BEEP() (PORTC |= (1 << PC6)) |
#define set_D_LIGHT() (PORTD |= (1 << PD7)) // Displaybeleuchtung |
#define clr_D_LIGHT() (PORTD &= ~(1 << PD7)) |
#define set_WI232CMD() (PORTD &= ~(1 << PD6)) |
#define clr_WI232CMD() (PORTD |= (1 << PD6)) |
#define KEY_PIN PINA |
//#if defined HWVERSION1_2 || defined HWVERSION1_3 || defined HWVERSION3_2 |
//#define KEY_ENTER PA7 |
//#define KEY_ESC PA6 |
//#define KEY_PLUS PA5 |
//#define KEY_MINUS PA4 |
//#endif |
/*in der Hardwareversion sind die Tasten im Layout verdreht*/ |
#define KEY_ENTER PA4 |
#define KEY_ESC PA5 |
#define KEY_PLUS PA6 |
#define KEY_MINUS PA7 |
void InitHWPorts(void); |
#endif /* HAL_HW3_2_H_ */ |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/HAL_HW3_9.c |
---|
0,0 → 1,196 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
#ifndef HAL_HW3_9_C_ |
#define HAL_HW3_9_C_ |
#include "cpu.h" |
#include <inttypes.h> |
#include <avr/io.h> |
#include <avr/interrupt.h> |
#include <avr/pgmspace.h> |
#include <avr/eeprom.h> |
#include <util/delay.h> |
#include <stdbool.h> |
#include "main.h" |
#if defined HWVERSION3_9 |
#include "messages.h" |
#include "lcd.h" |
#include "usart.h" |
#include "uart1.h" |
#include "display.h" |
#include "timer.h" |
#include "eeprom.h" |
#include "Wi232.h" |
#include "twimaster.h" |
#include "uart1.h" |
#include "bluetooth.h" |
#include "error.h" |
#include "connect.h" |
#include "lipo.h" |
#include "setup.h" |
volatile uint8_t USBBT; |
volatile uint8_t U02SV2; |
//-------------------------------------------------------------- |
void InitHWPorts(void) // Initialisierung der Hardware für die jeweilige Leiterplattenversion |
{ |
PORTA |= (1<<PORTA4)|(1<<PORTA5)|(1<<PORTA6)|(1<<PORTA7); // Enable Pull Up for the 4 keys |
DDRA &= ~(1<<DDA4); // Eingang: A4 auf Low setzen (Power On) |
DDRB = 0xFF; // Alles Ausgänge |
PORTC |= (1<<PORTC4)|(1<<PORTC7); // Enable Pull Up for LBO + Summer |
DDRC |= (1<<DDC2)|(1<<DDC3)|(1<<DDC5)|(1<<DDC6)|(1<<DDC7); // Ausgang: Led2,Rs232Switch,Summer |
DDRC &= ~(1<<DDC4); // Eingang: LowBat LTC1308 |
set_BTOn(); // Erstmal USB dektivieren, damit beim versehentlichen Einschalten USB im PC ruhig bleibt |
PORTD |= (1<<PORTD6); // Wi232-CMD auf High schalten |
DDRD |= (1<<DDD4)|(1<<DDD5)|(1<<DDD6)|(1<<DDD7); // Ausgang: PiepserTest, Servo, Wi232-CMD und Beleuchtung |
set_V_On(); // Spannung mit T3 halten |
Timer0_Init (); // system |
Timer1_Init (); // pwm |
Timer2_Init (); // display |
Display_on = 1; |
USART_Init (UART_BAUD_SELECT(USART_BAUD,F_CPU)); |
uart1_init (UART_BAUD_SELECT(USART_BAUD,F_CPU)); // USB |
I2C_Init(1); |
sei (); |
LCD_Init (0); // muss vor "ReadParameter" stehen |
ReadParameter (); // Aktuelle Werte aus EEProm auslesen |
if (DisplayLanguage > NUM_LANG) // Beim ersten Start Sprache abfragen |
{ DisplayLanguage = 1; |
DisplayLanguage = Edit_Language(DisplayLanguage,0,3,DISPLAY3); |
WriteParameter(); |
} |
OCR2A = LCD_Helligkeit * 2.55; |
LCD_Init (1); |
BeepTime = 200; |
BeepMuster = 0x0080; |
ADC_Init(); // ADC für Lipomessung |
// Power On Delay |
// lcd_printp_at (2,2,PSTR("Taste 1 Sekunde"), 0); |
// lcd_printp_at (2,3,PSTR("lang festhalten."), 0); |
lcd_puts_at(0, 2, strGet(BOOT1), 0); |
lcd_puts_at(0, 3, strGet(BOOT2), 0); |
_delay_ms(800); |
if (PINA & (1<<PINA7)) // Spannung eingeschaltet lassen |
clr_V_On(); |
_delay_ms(100); |
BeepTime = 500; |
BeepMuster = 0x0080; |
get_key_press(KEY_ALL); |
lcd_cls(); |
if ((UseWi == true) && (WiIsSet == false)) |
{ |
InitWi232(); // wenn Wi232 nicht initialisiert ist, dann jetzt tun |
} |
lcd_cls(); |
set_USBOn(); // USB erstmal wieder einschalten |
if ((UseBT == true) && (BTIsSet == false)) |
{ |
bt_init(); |
set_USBOn(); |
} |
lcd_cls(); |
if ((UseWi == true) && (U02SV2 == 0)) |
{ |
Change_Output(Uart02Wi); // Verbindung zu Wi232 herstellen |
if (PKT_StartInfo == true) |
{ |
// lcd_printp_at (0, 0, PSTR("Verbindung zum MK ist"), 0); |
// lcd_printp_at (0, 1, PSTR("auf Wi232 eingestellt"), 0); |
lcd_puts_at(0, 0, strGet(BOOT_WI1), 0); |
lcd_puts_at(0, 1, strGet(BOOT_WI2), 0); |
_delay_ms(2000); |
} |
} |
else |
{ |
Change_Output(Uart02FC); // Verbindung zu SV" (Kabel) herstellen |
if (PKT_StartInfo == true) |
{ |
// lcd_printp_at (0, 0, PSTR("Verbindung zum MK ist"), 0); |
// lcd_printp_at (0, 1, PSTR("auf Kabel eingestellt"), 0); |
lcd_puts_at(0, 0, strGet(BOOT_WI1), 0); |
lcd_puts_at(0, 1, strGet(BOOT_SV), 0); |
_delay_ms(2000); |
} |
} |
lcd_cls(); |
} |
void set_D_LIGHT(void) /* Displaybeleuchtung ein*/ |
{ |
// PWM einschalten |
TCCR2A |= (1 << WGM21) | (1 << WGM20) | (1 << COM2A1); |
TCCR2B |= (1 << CS20); |
} |
void clr_D_LIGHT(void) /* Displaybeleuchtung aus*/ |
{ |
// PWM ausschalten |
TCCR2A = 0; |
TCCR2B = 0; |
} |
#endif |
#endif // HAL_HW3_9_C_ |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/HAL_HW3_9.h |
---|
0,0 → 1,139 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
#ifndef HAL_HW3_9_H_ |
#define HAL_HW3_9_H_ |
//#define PIEPSER_NERVT // Summer zu Testzwecken ganz Ausschalten |
// Hardware 3.9 Portbelegung |
#define KEY_PIN PINA // Port A als Input |
#define Touch0 PA0 // Pin 37 |
#define Touch1 PA1 // Pin 36 |
#define Touch2 PA2 // Pin 35 |
#define Touch3 PA3 // Pin 34 |
#define Key1 PA4 // Pin 33 |
#define Key2 PA5 // Pin 32 |
#define Key3 PA6 // Pin 31 |
#define Key4 PA7 // Pin 30 |
#define USB2Wi PB0 // Pin 40 aktiv low > IC5 |
#define VoltageHold PB1 // Pin 41 High = Spannung T3 halten |
#define Display_Reset PB2 // Pin 42 |
#define Display_A0 PB3 // Pin 43 |
#define Display_CS PB4 // Pin 44 |
#define Display_SI PB5 // Pin 1 |
#define LED1 PB6 // Pin 2 Low = LED1 (nicht benutzbar wegen SCL |
#define Display_SCL PB7 // Pin 3 |
#define I2C_SCL PC0 // Pin 19 SCL |
#define I2C_CDA PC1 // Pin 20 SDA |
#define USB2FC PC2 // Pin 21 aktiv low > IC5 |
#define USB_BT PC3 // Pin 22 high = USB, Low = Bluetooth, LED2 |
#define LowBat PC4 // Pin 23 Low Bat Warning Lipo PKT,Input |
#define Uart02Wi PC5 // Pin 24 aktiv Low > IC4 |
#define Uart02FC PC6 // Pin 25 aktiv Low > IC4 |
#define Summer PC7 // Pin 26 Low = Summer |
#define Uart0RxD PD0 // Pin 9 über IC4 =Wi | SV2 |
#define Uart0TxD PD1 // Pin 10 über IC4 =Wi | SV2 |
#define Uart1RxD PD2 // Pin 11 direkt = USB, BTM, über IC5 = Wi | SV2 |
#define Uart1TxD PD3 // Pin 12 direkt = USB, BTM, über IC5 = Wi | SV2 |
#define PiepserTest PD4 // Pin 13 CTC für Piepser |
#define Servo PD5 // Pin 14 PWM für Servo |
#define Wi232_CMD PD6 // Pin 15 aktiv Low = Wi232 CMD |
#define Displaybeleuchtung PD7 // Pin 16 High = Display-LED |
#define KEY_ENTER Key1 |
#define KEY_ESC Key2 |
#define KEY_PLUS Key3 |
#define KEY_MINUS Key4 |
// |= schaltet Ausgang auf HIGH |
// &= ~ schaltet Ausgang auf LOW |
#define set_reset() (PORTB |= (1 << Display_Reset)) |
#define clr_reset() (PORTB &= ~(1 << Display_Reset)) |
#define set_A0() (PORTB |= (1 << Display_A0)) |
#define clr_A0() (PORTB &= ~(1 << Display_A0)) |
#define set_cs() (PORTB |= (1 << Display_CS)) |
#define clr_cs() (PORTB &= ~(1 << Display_CS)) |
#define set_si() (PORTB |= (1 << Display_SI)) |
#define clr_si() (PORTB &= ~(1 << Display_SI)) |
#define set_scl() (PORTB |= (1 << Display_SCL)) |
#define clr_scl() (PORTB &= ~(1 << Display_SCL)) |
#define set_BTOn() (PORTC &= ~(1 << USB_BT)) // Bluetooth ein |
#define set_USBOn() (PORTC |= (1 << USB_BT)) // USB ein |
#define clr_V_On() (PORTB &= ~(1 << VoltageHold)) // Spannung mit T3 halten |
#define set_V_On() (PORTB |= (1 << VoltageHold)) |
#define set_USB2FC() (PORTC &= ~(1 << USB2FC)) // USB mit FC-Kabel verbinden |
#define clr_USB2FC() (PORTC |= (1 << USB2FC)) |
#define set_USB2Wi() (PORTB &= ~(1 << USB2Wi)) // USB mit Wi232 verbinden |
#define clr_USB2Wi() (PORTB |= (1 << USB2Wi)) |
#define set_Uart02FC() (PORTC &= ~(1 << Uart02FC)) // Uart0 mit FC-Kabel verbinden |
#define clr_Uart02FC() (PORTC |= (1 << Uart02FC)) |
#define set_Uart02Wi() (PORTC &= ~(1 << Uart02Wi)) // Uart0 mit Wi232 verbinden |
#define clr_Uart02Wi() (PORTC |= (1 << Uart02Wi)) |
#define set_BEEP() (PORTC &= ~(1 << Summer)) // Summer |
#define clr_BEEP() (PORTC |= (1 << Summer)) |
#define set_WI232CMD() (PORTD &= ~(1 << Wi232_CMD)) // Wi232 Programmierpin |
#define clr_WI232CMD() (PORTD |= (1 << Wi232_CMD)) |
void set_D_LIGHT(void); /* Displaybeleuchtung ein*/ |
void clr_D_LIGHT(void); /* Displaybeleuchtung aus */ |
void InitHWPorts(void); |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/TODO.txt |
---|
0,0 → 1,12 |
24.8.2011 Cebra |
Waypointlisten speichern und zum MK übertragen |
Menüs überarbeiten um die Varianten der Schnittstellen einfacher handhaben zu können |
Touchsreen entfällt, bring keine wirklichen Vorteile, kostet nur viel Speicher |
22.7.2011 Cebra |
HArdwareplatine mit Stick und Schalter zum Steuern der seriellen Kanäle. |
22.6.2011 Cebra |
- erl. I2C Motortest für BL-Controller |
- erl. zur Zeit sind durch einen Layoutfehler noch die Tasten vertauscht, in timer.h zu ändern |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/Wi232.c |
---|
0,0 → 1,562 |
/***************************************************************************** |
* Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* Copyright (C) 2011 Christian "Cebra" Brandtner, brandtner@brandtner.net * |
* Copyright (C) 2011 Harald Bongartz * |
* * |
* This program is free software; you can redistribute it and/or modify * |
* it under the terms of the GNU General Public License as published by * |
* the Free Software Foundation; either version 2 of the License. * |
* * |
* This program is distributed in the hope that it will be useful, * |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
* GNU General Public License for more details. * |
* * |
* You should have received a copy of the GNU General Public License * |
* along with this program; if not, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
* * |
* Credits to: * |
* Holger Buss & Ingo Busker from mikrokopter.de for the MK project + SVN * |
* http://www.mikrokopter.de * |
* Gregor "killagreg" Stobrawa for his version of the MK code * |
* Thomas Kaiser "thkais" for the original project. See * |
* http://www.ft-fanpage.de/mikrokopter/ * |
* http://forum.mikrokopter.de/topic-4061-1.html * |
* Claas Anders "CaScAdE" Rathje for providing the font and his C-OSD code * |
* http://www.mylifesucks.de/oss/c-osd/ * |
* Harald Bongartz "HaraldB" for providing his Ideas and Code for usibility* |
*****************************************************************************/ |
#include "cpu.h" |
#include <avr/io.h> |
#include <avr/pgmspace.h> |
#include <util/delay.h> |
#include <stdlib.h> |
#include <string.h> |
#include "lcd.h" |
#include "usart.h" |
#include "uart1.h" |
#include "main.h" |
#include "Wi232.h" |
#include "timer.h" |
#include "eeprom.h" |
#if defined HWVERSION1_3W || defined HWVERSION3_9 |
uint8_t Wi232_hardware = 0; |
uint8_t InitErr=0; |
/************************************************************************* |
Function: discoverWI232() |
Purpose: check if Wi232 available |
Returns: Version or 0 = timeout |
**************************************************************************/ |
void discoverWi232(void) |
{ |
int16_t RegisterWi232; |
SwitchToWi232(); /* Serielle Kanäle Wi232 mit USB verbinden*/ |
set_WI232CMD(); |
_delay_ms(200); |
USART_Init( UART_BAUD_SELECT(57600,F_CPU) ); /* erstmal mit 57600 versuchen*/ |
lcd_printpns_at (0, 0, PSTR("search Wi.232 Modul"),0); |
lcd_printpns_at (0, 1, PSTR("with 57600 Baud "),0); |
RegisterWi232 = ReadWi232(regDiscover); |
Wi232_hardware = 1; |
if (RegisterWi232 == 0) |
{ |
USART_Init( UART_BAUD_SELECT(2400,F_CPU) ); /* neues Modul mit 2400 suchen*/ |
lcd_printpns_at (0, 1, PSTR("with 2400 Baud "),0); |
RegisterWi232 = ReadWi232(regDiscover); |
Wi232_hardware = 2; |
} |
if (RegisterWi232 == 0) |
{ |
lcd_cls(); |
lcd_printpns_at (0, 0, PSTR("no Wi.232 found "),0); |
Wi232_hardware = 0; |
} |
if (RegisterWi232 == 0xFF) |
{ |
lcd_cls(); |
lcd_printpns_at (0, 0, PSTR("Wi.232 Sytaxerror "),0); |
BeepTime = 1000; |
BeepMuster = 0x0040; |
_delay_ms(2000); |
} |
if (RegisterWi232 != 0) |
{ |
lcd_cls(); |
if (Wi232_hardware ==1) |
lcd_printpns_at (0, 0, PSTR("Wi.232 found 57600"),0); |
if (Wi232_hardware ==2) // bei 2400 Baud |
{ |
WiIsSet= false; //wenn hier 2400 gefunden wurde ist Wi232 nicht initialisiert |
lcd_printpns_at (0, 0, PSTR("Wi.232 found 2400"),0); |
if (WriteWi232(regNVDATARATE,Wi232_57600)!=0) /* NV-Ram auf 57600 setzen*/ |
{ |
lcd_printpns_at (0, 1, PSTR("Error set NV-RAM"),0); |
BeepTime = 1000; |
BeepMuster = 0x0040; |
_delay_ms(2000); |
} |
else |
{ |
_delay_ms(1000); |
lcd_printpns_at (0, 1, PSTR("NV-RAM set to 57600"),0); |
lcd_printpns_at (0, 2, PSTR("ok "),0); |
_delay_ms(2000); |
} |
if (WriteWi232(regDATARATE,Wi232_57600)!=0) /* Ram auf 57600 setzen*/ |
{ |
lcd_printpns_at (0, 3, PSTR("Error set RAM "),0); |
BeepTime = 1000; |
BeepMuster = 0x0040; |
_delay_ms(2000); |
} |
else |
{ |
_delay_ms(1000); |
lcd_printpns_at (0, 1, PSTR("RAM set to 57600 "),0); |
lcd_printpns_at (0, 2, PSTR("ok "),0); |
_delay_ms(2000); |
} |
USART_Init( UART_BAUD_SELECT(57600,F_CPU) ); |
} |
lcd_cls_line (0,1,21); |
lcd_printpns_at (0, 1, PSTR("Version:"),0); |
lcd_print_hex_at(9,1,RegisterWi232,0); |
} |
clr_WI232CMD(); |
} |
/************************************************************************* |
Function: InitWI232() |
Purpose: set Wi232Register for Mikrokopter |
Returns: 0 = ACK, FF = NAK |
**************************************************************************/ |
void InitWi232(void) |
{ |
uint8_t i = 0; |
Change_Output(Uart02Wi); // Verbindung zu Wi232 herstellen |
discoverWi232(); // Check if Wi232 available |
if (Wi232_hardware != 0) |
{ |
lcd_printpns_at (0, 2, PSTR("Init Wi232 wait...."),0); |
set_WI232CMD(); |
_delay_ms(200); |
SwitchToWi232(); /* Serielle Kanäle Wi232 mit USB verbinden*/ |
USART_Init( UART_BAUD_SELECT(57600,F_CPU) ); /* erstmal mit 57600 versuchen*/ |
if (WriteWi232(regNETGRP,126)!=0) /*damit Wi232 nix mehr vom Kopter schickt erstmal Networkgroup ins Nirwana setzen */ |
lcd_printpns_at (i++,4,PSTR("."),0); |
// InitErr =12; |
// Grund: |
//If RF packets are received while the CMD line is active, |
//they are still processed and presented to the module’s UART for transmission. |
// wenn sich ein EEPROM-Wert ändert wird auch das Ram beschrieben damit die Änderung sofort wirksam wird |
if (WriteWi232(regNVTXCHANNEL,WiTXRXChannel)!=0) |
InitErrorWi232(1); /*TX Channel*/ |
lcd_printpns_at (i++,4,PSTR("."),0); |
if (WriteWi232(regTXCHANNEL,WiTXRXChannel)!=0) |
InitErrorWi232(2);/*TX Channel*/ |
lcd_printpns_at (i++,4,PSTR("."),0); |
if (WriteWi232(regNVRXCHANNEL,WiTXRXChannel)!=0) |
InitErrorWi232(3);/* RX Channel*/ |
lcd_printpns_at (i++,4,PSTR("."),0); |
if (WriteWi232(regRXCHANNEL,WiTXRXChannel)!=0) |
InitErrorWi232(4);/* RX Channel*/ |
lcd_printpns_at (i++,4,PSTR("."),0); |
if (WriteWi232(regNVSLPMODE ,Sleep_Awake)!=0) |
InitErrorWi232(5);/* Sleepmode*/ |
lcd_printpns_at (i++,4,PSTR("."),0); |
if (WriteWi232(regNVPWRMODE,WbModeP15)!=0) |
InitErrorWi232(6);/* Transceiver Mode/Powermode */ |
lcd_printpns_at (i++,4,PSTR("."),0); |
if (WriteWi232(regNVTXTO,WiTXTO)!=0) |
InitErrorWi232(7);/* UART Timeout */ |
lcd_printpns_at (i++,4,PSTR("."),0); |
if (WriteWi232(regTXTO,WiTXTO)!=0) |
InitErrorWi232(8);/* UART Timeout */ |
lcd_printpns_at (i++,4,PSTR("."),0); |
if (WriteWi232(regNVUARTMTU,WiUartMTU)!=0) |
InitErrorWi232(9);/* UART Buffer*/ |
lcd_printpns_at (i++,4,PSTR("."),0); |
if (WriteWi232(regUARTMTU,WiUartMTU)!=0) |
InitErrorWi232(10);/* UART Buffer*/ |
lcd_printpns_at (i++,4,PSTR("."),0); |
if (WriteWi232(regNVNETMODE,WiNetworkMode)!=0) |
InitErrorWi232(11);/* Networkmode*/ |
lcd_printpns_at (i++,4,PSTR("."),0); |
if (WriteWi232(regNETMODE,WiNetworkMode)!=0) |
InitErrorWi232(12);/* Networkmode*/ |
lcd_printpns_at (i++,4,PSTR("."),0); |
if (WriteWi232(regNVUSECRC ,CRC_Enable)!=0) |
InitErrorWi232(13);/* CRC*/ |
lcd_printpns_at (i++,4,PSTR("."),0); |
if (WriteWi232(regNVCSMAMODE,CSMA_En)!=0) |
InitErrorWi232(14);/* CSMA*/ |
lcd_printpns_at (i++,4,PSTR("."),0); |
if (WriteWi232(regNVDATARATE,Wi232_57600)!=0) |
InitErrorWi232(15);/* Baudrate*/ |
lcd_printpns_at (i++,4,PSTR("."),0); |
if (WriteWi232(regDATARATE,Wi232_57600)!=0) |
InitErrorWi232(16);/* Baudrate*/ |
lcd_printpns_at (i++,4,PSTR("."),0); |
if (WriteWi232(regNVNETGRP,WiNetworkGroup)!=0) |
InitErrorWi232(17);/* Networkgroup */ |
lcd_printpns_at (i++,4,PSTR("."),0); |
if (WriteWi232(regNETGRP,WiNetworkGroup)!=0) |
InitErrorWi232(18);/* Networkgroup */ |
lcd_printpns_at (i++,4,PSTR("."),0); |
clr_WI232CMD(); |
if (InitErr !=0) |
{ |
lcd_printpns_at (0, 2, PSTR("Wi232 InitError "),0); |
lcd_print_hex(InitErr,0); |
BeepTime = 1000; |
BeepMuster = 0x0040; |
_delay_ms(2000); |
} |
else |
{ |
lcd_printpns_at (0, 2, PSTR("Wi232 Init ok...."),0); |
WriteWiInitFlag(); // Init merken |
} |
USART_Init (UART_BAUD_SELECT(57600,F_CPU)); |
_delay_ms(2000); |
} |
} |
/************************************************************************* |
Function: InitErrorWI232() |
Purpose: Show Wi232 Error, Value |
Returns: |
**************************************************************************/ |
void InitErrorWi232(uint8_t Error) |
{ |
lcd_printpns_at (0, 3, PSTR("Wi232 InitError "),0); |
lcd_print_hex(Error,0); |
InitErr=Error; |
BeepTime = 500; |
BeepMuster = 0x0040; |
_delay_ms(500); |
} |
/************************************************************************* |
Function: WriteWI232() |
Purpose: set Register to Wi232, Register, Value |
Returns: 0 = ACK, FF = NAK |
ACHTUNG nur für Value <0x80 |
**************************************************************************/ |
int16_t WriteWi232(uint8_t Wi232Register, uint8_t RegisterValue) |
{ |
uint8_t timeout=10; |
uint8_t tc=0; |
unsigned int v; |
USART_putc(0xff); |
USART_putc(0x02); |
USART_putc(Wi232Register); |
USART_putc(RegisterValue); |
// lcd_print_hex(Wi232Register,0); |
// lcd_print_hex(RegisterValue,0); |
do |
{ |
v = USART_getc(); /*ACK erwartet*/ |
_delay_ms(100); |
tc ++; |
} |
while (v==0 && tc!=timeout); |
// lcd_print_hex(v,0); |
if (v != 0x06) |
{ |
lcd_printpns_at (0, 2, PSTR("Wi.232 NAK"),0); |
BeepTime = 1000; |
BeepMuster = 0x0040; |
_delay_ms(2000); |
return 0xFF; |
} |
if (v==0x06) |
return 0; |
return 0xFF; |
} |
/************************************************************************* |
Function: ReadWI232() |
Purpose: send Readcommand to Wi232, |
Returns: Registervalue, 0 = timeout 0xFF = Syntaxerror |
**************************************************************************/ |
int16_t ReadWi232(uint16_t Wi232Register) |
{ |
uint8_t timeout=10; |
uint8_t tc=0; |
unsigned int v; |
v = USART_getc(); /*Zeichen löschen*/ |
USART_putc(0xff); |
USART_putc(0x02); |
USART_putc(0xfe); |
USART_putc(Wi232Register); |
_delay_ms(50); |
// lcd_printpns_at (0, 2, PSTR("read Wi232"),0); |
do |
{ |
v = USART_getc(); /*ACK erwartet*/ |
_delay_ms(100); |
tc ++; |
} |
while (v==0 && tc!=timeout); |
if (tc == timeout) |
return 0; /* Timeout*/ |
if (v != 0x06) |
return 0xFF; /* Syntaxerror*/ |
lcd_print_hex(v,0); |
v = USART_getc(); /*Register*/ |
// lcd_print_hex(v,0); |
v = USART_getc(); /*Value*/ |
// lcd_print_hex(v,0); |
return v; |
} |
/************************************************************************* |
Function: EscapeString() |
Purpose: |
Returns: |
Quelle: Radiotronix Wi.232 Manual |
**************************************************************************/ |
int EscapeString(char *src, char src_len, char *dest) |
{ |
// The following function copies and encodes the first |
// src_len characters from *src into *dest. This |
// encoding is necessary for Wi.232 command formats. |
// The resulting string is null terminated. The size |
// of this string is the function return value. |
// --------------------------------------------------- |
uint8_t src_idx, dest_idx; |
// Save space for the command header and size bytes |
// ------------------------------------------------ |
dest_idx = 2; |
// Loop through source string and copy/encode |
// ------------------------------------------ |
for (src_idx = 0; src_idx < src_len; src_idx++) |
{ |
if (src[src_idx] > 127) |
{ |
dest[dest_idx++] = 0xFE; |
} |
dest[dest_idx++] = (src[src_idx] & 0x7F); |
} |
// Add null terminator |
// ------------------- |
dest[dest_idx] = 0; |
// Add command header |
// ------------------ |
dest[0] = 0xFF; |
dest[1] = dest_idx-2; |
// Return escape string size |
// ------------------------- |
return dest_idx; |
} |
//#if defined HWVERSION1_3W || defined HWVERSION3_9 |
/************************************************************************* |
Function: Wi232USB() |
Purpose: Connect Wi232 Programmmode to PKT USB, |
Returns: |
**************************************************************************/ |
void Wi232_USB(void) |
{ |
unsigned int c0,c1; |
if (Wi232_hardware==1) |
{ |
// USART_Init (UART_BAUD_SELECT(57600,F_CPU)); |
// uart1_init( UART_BAUD_SELECT(57600,F_CPU) ); |
// USART_Init (UART_BAUD_SELECT(2400,F_CPU)); |
// uart1_init( UART_BAUD_SELECT(2400,F_CPU) ); |
} |
if (Wi232_hardware==2) |
{ |
USART_Init (UART_BAUD_SELECT(2400,F_CPU)); |
uart1_init( UART_BAUD_SELECT(2400,F_CPU) ); |
} |
lcd_cls (); |
// SwitchToWi232(); /* Serielle Kanäle Wi232 mit USB verbinden*/ |
set_WI232CMD(); |
lcd_printpns_at (0, 0, PSTR("Wi.232 Konfiguration "),0); |
lcd_printpns_at (0, 1, PSTR("PC mit USB verbinden"),0); |
lcd_printpns_at (0, 2, PSTR("Wi.232"),0); |
lcd_printpns_at (0, 3, PSTR("Programm starten"),0); |
lcd_printpns_at (17, 7, PSTR("Exit"),0); |
c1 = 0; |
for(;;) |
{ |
c0 = uart1_getc(); /* from USB*/ |
if ( c0 & UART_NO_DATA ) |
{ |
c1 = USART_getc(); |
if (c1 == 0) |
{} |
else |
{ |
// lcd_print_hex(c1,0); |
uart1_putc (c1); /*to USB*/; |
} |
} |
else |
{ |
USART_putc(c0 ); /* to Wi232*/ |
// lcd_print_hex(c0,0); |
// _delay_ms(1); |
} |
if ((get_key_press (1 << KEY_ENTER))) |
{ |
clr_WI232CMD(); |
// uart1_init( UART_BAUD_SELECT(57600,F_CPU) ); |
// USART_Init( UART_BAUD_SELECT(57600,F_CPU) ); |
// SwitchToFC(); |
return; |
} |
} |
} |
/************************************************************************* |
Function: Wi232_FC() |
Purpose: Connect Wi232 to PKT USB, Transparent |
Returns: |
**************************************************************************/ |
void Wi232_FC(void) |
{ |
unsigned int c0,c1; |
USART_Init (UART_BAUD_SELECT(57600,F_CPU)); |
uart1_init( UART_BAUD_SELECT(57600,F_CPU) ); |
// USART_Init (UART_BAUD_SELECT(2400,F_CPU)); |
// uart1_init( UART_BAUD_SELECT(2400,F_CPU) ); |
lcd_cls (); |
// SwitchToWi232(); /* Serielle Kanäle Wi232 mit USB verbinden*/ |
lcd_printpns_at (0, 0, PSTR("Wi.232 to FC "),0); |
lcd_printpns_at (0, 1, PSTR("PC mit USB verbinden"),0); |
lcd_printpns_at (0, 2, PSTR("und Mikrokoptertool"),0); |
lcd_printpns_at (0, 3, PSTR("starten"),0); |
lcd_printpns_at (17, 7, PSTR("Exit"),0); |
c1 = 0; |
for(;;) |
{ |
c0 = uart1_getc(); /* from USB*/ |
if ( c0 & UART_NO_DATA ) |
{ |
c1 = USART_getc(); |
if (c1 == 0) |
{} |
else |
{ |
// lcd_print_hex(c1,0); |
uart1_putc (c1); /*to USB*/; |
} |
} |
else |
{ |
USART_putc(c0 ); /* to Wi232*/ |
// lcd_print_hex(c0,0); |
// _delay_ms(1); |
} |
if ((get_key_press (1 << KEY_ENTER))) |
{ |
return; |
} |
} |
} |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/Wi232.h |
---|
0,0 → 1,177 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
#ifndef WI232_H_ |
#define WI232_H_ |
void discoverWi232(void); |
void InitWi232(void); |
int16_t WriteWi232(uint8_t Wi232Register, uint8_t RegisterValue); |
int16_t ReadWi232(uint16_t Wi232Register); |
void InitErrorWi232(uint8_t Error); |
extern uint8_t Wi232_hardware; |
// Non-volatile Registers |
// Name Address Description Default |
#define regNVTXCHANNEL 0x00 // Transmit channel setting ## 0 ## |
#define regNVRXCHANNEL 0x01 // Receive channel setting ## 0 ## |
#define regNVPWRMODE 0x02 // Operating mode settings ## +13 dBm widebandmode ## |
#define regNVDATARATE 0x03 // UART data rate ## 2400bps ## |
#define regNVNETMODE 0x04 // Network mode (Normal/Slave) ## Normal ## |
#define regNVTXTO 0x05 // Transmit wait timeout ## ~16ms ## |
#define regNVNETGRP 0x06 // Network group ID ## 0x00 ## |
#define regNVUSECRC 0x08 // Enable/Disable CRC ## Enabled ## |
#define regNVUARTMTU 0x09 // Minimum transmission unit. ## 64 bytes ## |
#define regNVSHOWVER 0x0A // Enable/Disable start-up message ## Enabled ## |
#define regNVCSMAMODE 0x0B // Enable/Disable CSMA ## Enabled ## |
#define regNVSLPMODE 0x0D // Power state of module ## Awake ## |
#define regNVACKONWAKE 0x0E // Send ACK character to host on wake |
// Non-volatile Read Only Registers |
// Name Address Description |
#define regMAC0 0x22 // These registers form the unique 48-bit MAC address. |
#define regMAC1 0x23 // MAC |
#define regMAC2 0x24 // MAC |
#define regOUI0 0x25 // MAC |
#define regOUI1 0x26 // MAC |
#define regOUI2 0x27 // MAC |
#define regDiscover 0x78 // Versionsregister |
// Volatile Read/Write Registers |
// Name Address Description |
#define regTXCHANNEL 0x4B // Transmit channel setting |
#define regRXCHANNEL 0x4C // Receive channel setting |
#define regPWRMODE 0x4D // Operating mode settings |
#define regDATARATE 0x4E // UART data rate |
#define regNETMODE 0x4F // Network mode (Normal or Slave) |
#define regTXTO 0x50 // Transmit wait timeout |
#define regNETGRP 0x51 // Network group ID |
#define regUSECRC 0x53 // Enable/Disable CRC |
#define regUARTMTU 0x54 // Minimum transmission unit. |
#define regSHOWVER 0x55 // Enable/Disable start-up message |
#define regCSMAMODE 0x56 // Enable/disable CSMA |
#define regSLPMODE 0x58 // Power state of module |
#define regACKONWAKE 0x59 // Send ACK character to host on wake |
// Wideband Channels |
// regNVTXCHAN (0x00) regTXCHAN (0x4B) |
// Channel Number Frequency |
#define wChan0 0x00 // 868.300 MHz |
#define wChan1 0x01 // 868.95 MHz ## MK ## |
// Narrowband Channels |
// regNVRXCHAN (0x01) regRXCHAN (0x4C) |
// Channel Number Frequency |
#define nChan0 0x00 // 868.225 MHz |
#define nChan1 0x01 // 868.375 MHz ## MK ## |
#define nChan2 0x02 // 868.850 MHz |
#define nChan3 0x03 // 869.050 MHz |
#define nChan4 0x04 // 869.525 MHz |
#define nChan5 0x05 // 869.850 MHz |
// Power Mode |
// regNVPWRMODE (0x02) regPWRMODE (0x4D) |
// PM1 PM1 PM0 Mode |
#define NbModeN0 0x00 // 0 0 0 Narrowband Mode 0dBm power setting (typical) |
#define WbModeP5 0x01 // 0 0 1 Wideband Mode +5dBm power setting (typical) |
#define WbModeP10 0x02 // 0 1 0 Wideband Mode +10dBm power setting (typical) |
#define WbModeP15 0x03 // 0 1 1 Wideband Mode +15dBm power setting (typical) ## MK ## |
#define WbModeN0 0x04 // 1 0 0 Wideband Mode 0dBm power setting (typical) |
#define NbModeP5 0x05 // 1 0 1 Narrowband Mode +5dBm power setting (typical) |
#define NbModeP10 0x06 // 1 1 0 Narrowband Mode +10dBm power setting (typical) |
#define NbModeP15 0x07 // 1 1 1 Narrowband Mode +15dBm power setting (typical) |
// Wi232 UART Baudrate |
// regNVDATARATE (0x03) regDATARATE (0x4E) |
// Baud Rate BR2 BR1 BR0 |
#define Wi232_2400 0x00 // 0 0 0* (default 2400) |
#define Wi232_9600 0x01 // 0 0 1 |
#define Wi232_19200 0x02 // 0 1 0 |
#define Wi232_38400 0x03 // 0 1 1 |
#define Wi232_57600 0x04 // 1 0 0 ## MK ## |
#define Wi232_115200 0x05 // 1 0 1 |
#define Wi232_10400 0x06 // 1 1 0 |
#define Wi232_31250 0x07 // 1 1 1 |
// NetworkMode |
// regNVNETMODE (0x04) regNETMODE (0x4F) |
#define NetMode_Slave 0x00 // Slavemode |
#define NetMode_Normal 0x01 // Normalmode (default) |
// Transmit Wait Timeout |
// regNVTXTO (0x05) regTXTO (0x50) |
#define TWaitTimeFull 0x00 // full Buffer required |
#define TWaitTime16 0x10 // 16 ms Delay (default) |
// Network Group |
// regNVNETGRP (0x06) regNETGRP (0x51) |
#define NetWorkGroup 66 // default = 0, valid 0-127 ## MK = 66 ## |
// CRC Control |
// regNVUSECRC (0x08) regUSECRC (0x53) |
#define CRC_Disable 0x00 // no CRC check |
#define CRC_Enable 0x01 // CRC check (default) |
// UART minimum transmission unit |
// regNVUARTMTU (0x09) regUARTMTU (0x54) |
#define UartMTU64 64 // default=64, valid 1-144 |
// Verbose mode |
// regNVSHOWVER (0x0A) |
#define ShowVers_Dis 0x00 // do not show Startupmessage ## MK = 66 ## |
#define ShowVers_En 0x01 // show Startupmessage (default) |
// CSMA enable |
// regNVCSMAMODE (0x0B) regCSMAMODE (0x56) |
#define CSMA_Dis 0x00 // disable CSMA Carrier-sense multiple access |
#define CSMA_En 0x01 // enable CSMA (default) |
// Sleep control |
// regNVSLPMODE (0x0D) regSLPMODE (0x58) |
#define Sleep_Awake 0x00 // Sleepmode = Awake (default) |
#define Sleep 0x01 // Sleepmode = Sleep |
#define Sleep_Stby 0x02 // Sleepmode = Standby |
// ACK on Wake |
// regNVACKONWAKE (0x0D) regACKONWAKE (0x59) |
#define ACKwake_Dis 0x00 // disable ACK on Wake |
#define ACKwake_En 0x01 // enable ACK on Wake (default) |
#endif // WI232_H_ |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/bluetooth.c |
---|
0,0 → 1,876 |
/** |
* source for the Bluetooth driver |
* @file bluetooth.c |
* @author Linus Lotz<lotz@in.tum.de> |
* @author Salomon Sickert |
*/ |
#include "cpu.h" |
#include <string.h> |
#include <util/delay.h> |
#include "bluetooth.h" |
#include "main.h" |
#ifdef HWVERSION3_9 |
#include "uart1.h" |
#include "usart.h" |
#include "fifo.h" |
#include "error.h" |
#include "lcd.h" |
#include "eeprom.h" |
#include "error.h" |
#include "setup.h" |
//#define SaveMem |
// |
// Baudrate for the UART-connection to the BTM-222 on SQUIRREL |
// |
#define SQUIRREL |
#ifdef SQUIRREL |
#define UART_BAUD_RATE 19200 |
#endif |
#ifdef NUT |
#define UART_BAUD_RATE 19200 |
#endif |
typedef enum { |
BT_RAW, |
BT_DATA, |
BT_CMD, |
BT_NOECHO, |
BT_NOANSWER |
} communication_mode_t; |
#define BT_CMD_TIMEOUT_MS 2000 |
typedef enum { |
BT_TEST, // AT |
BT_CONNECT, // ATA |
BT_DISCONNECT, // ATH |
BT_CLEAR_ADDRESS, // ATD0 |
BT_SET_ADDRESS, // ATD=_____ |
BT_FIND_DEVICES, // ATF? |
BT_DISABLE_AUTOCONNECT, // ATO1 |
BT_SET_MASTER, // ATR0 |
BT_SET_SLAVE, // ATR1 |
BT_SET_PIN, // ATP=1234 |
BT_SET_57600, // ATL4 Baudrate 57600 |
BT_SET_NOANSWER, // ATQ1 Rückmeldungen aus |
BT_SET_NOECHO, // ATE0 ECHO deaktivieren |
BT_SET_ANSWER, // ATQ0 Rückmeldungen |
BT_SET_ECHO, // ATE1 ECHO aktivieren |
BT_SET_DEFAULT, // Defaultwerte setzen |
BT_SET_NAME, // Devicename |
BT_SET_DISPWRDOWN // disable auto Powerdown |
} bt_cmd_t; |
#ifdef SQUIRREL |
#define IN_FIFO_SIZE 100 |
#endif |
#ifdef NUT |
#define IN_FIFO_SIZE 65 |
#endif |
static uint8_t bt_buffer[IN_FIFO_SIZE]; |
static fifo_t in_fifo; |
static bt_mode_t bt_mode = BLUETOOTH_SLAVE; |
static communication_mode_t comm_mode = BT_CMD; |
uint8_t i = 0; |
uint8_t NoEcho = 0; |
uint8_t NoAnswer = 0; |
// Set a timeout of Y ms and a Conditon X, which have to be true while timeout |
#define while_timeout(X, Y) for(uint16_t __timeout = 0; __timeout++ <= Y && (X); Delay_MS(Y ? 1 : 0)) |
//-------------------------------------------------------------- |
void Delay_MS(int count) |
{ |
for (int i = 0; i < count; i++) |
_delay_ms(1); |
} |
//-------------------------------------------------------------- |
static void uart_receive(void) |
{ |
unsigned int uart_data; |
while (!fifo_is_full(&in_fifo)) |
{ |
uart_data = uart1_getc(); |
// USART_puts("."); |
switch (uart_data & 0xFF00) { |
// Framing Error detected, i.e no stop bit detected |
case UART_FRAME_ERROR: |
#ifdef DEBUG |
warn_pgm(PSTR("FRM ERR")); |
#endif |
return; |
// Overrun, a character already presend in the UART UDR register was |
// not read by the interrupt handler before the next character arrived, |
// one or more received characters have been dropped |
// |
case UART_OVERRUN_ERROR: |
#ifdef DEBUG |
warn_pgm(PSTR("OVR ERR")); |
#endif |
return; |
// We are not reading the receive buffer fast enough, |
// one or more received character have been dropped |
// |
case UART_BUFFER_OVERFLOW: |
#ifdef DEBUG |
warn_pgm(PSTR("BUF ERR")); |
#endif |
return; |
// UART Inputbuffer empty, nothing to do |
case UART_NO_DATA: |
return; |
default: |
{ |
fifo_write(&in_fifo, uart_data); |
// USART_putc(uart_data); |
} |
} |
} |
#ifdef DEBUG |
warn_pgm(PSTR("FIFO OVR ERR")); |
#endif |
} |
//-------------------------------------------------------------- |
static void uart_send(const char *data, const uint8_t length) |
{ |
#ifdef DEBUG |
debug_pgm(PSTR("bt_uart_send")); |
#endif |
char echo; |
lcd_printp_at (i++, 1, PSTR("."), 0); |
for (uint8_t i = 0; i < length; i++) |
{ |
#ifdef DEBUG |
USART_putc((data[i])); //test |
#endif |
// debug_pgm(PSTR("bt_init_S")); |
if (uart1_putc(data[i]) == 0) |
{ |
#ifdef DEBUG |
warn_pgm(PSTR("UART: Remote not ready")); |
#endif |
return; |
} |
if (comm_mode == BT_RAW) |
_delay_ms(50); |
if (comm_mode == BT_DATA) |
_delay_ms(1); |
if (comm_mode == BT_NOECHO) |
_delay_ms(1); |
if (comm_mode == BT_CMD) |
{ |
uint8_t x = 0; |
for (; x < 3; x++) |
{ |
// // while_timeout(X, Y) for(uint16_t __timeout = 0; __timeout++ <= Y && (X); _delay_ms(Y ? 1 : 0)) |
// while_timeout(fifo_is_empty(&in_fifo), 200) |
for(uint16_t __timeout = 0; __timeout++ <= 200 && (fifo_is_empty(&in_fifo)); _delay_ms(200 ? 1 : 0)) |
{ |
uart_receive(); |
} |
fifo_read(&in_fifo, &echo); |
if (echo != data[i]) { |
if (uart1_putc(data[i]) == 0) |
{ |
warn_pgm(PSTR ("UART: Remote not ready")); |
return; |
} |
} |
else |
break; |
} |
if (x == 3) |
{ |
error_putc(data[i]); |
error_pgm(PSTR("BT: WRONG ECHO")); |
} |
} |
} |
} |
//-------------------------------------------------------------- |
static uint16_t send_cmd(const bt_cmd_t command, const char *data) |
{ |
_delay_ms(500); // org 500 300 zu wenig |
char full_command[20]; // Maximum command size |
switch (command) |
{ |
case BT_SET_PIN: |
strcpy_P(full_command, PSTR("ATP=")); |
for (uint8_t i = 0; i < bt_pin_length; i++) |
{ |
full_command[i+4] = bt_pin[i]; |
} |
full_command[(bt_pin_length+4)] =0; |
break; |
case BT_SET_DEFAULT: |
strcpy_P(full_command, PSTR("ATZ0")); |
break; |
case BT_SET_57600: |
strcpy_P(full_command, PSTR("ATL4")); |
break; |
case BT_SET_NOANSWER: |
strcpy_P(full_command, PSTR("ATQ1")); |
break; |
case BT_SET_NOECHO: |
strcpy_P(full_command, PSTR("ATE0")); |
break; |
case BT_SET_ANSWER: |
strcpy_P(full_command, PSTR("ATQ0")); |
break; |
case BT_SET_ECHO: |
strcpy_P(full_command, PSTR("ATE1")); |
break; |
case BT_TEST: |
strcpy_P(full_command, PSTR("AT")); |
break; |
case BT_CONNECT: |
strcpy_P(full_command, PSTR("ATA")); |
break; |
case BT_DISCONNECT: |
strcpy_P(full_command, PSTR("ATH")); |
break; |
case BT_CLEAR_ADDRESS: |
strcpy_P(full_command, PSTR("ATD0")); |
break; |
case BT_SET_ADDRESS: |
strcpy_P(full_command, PSTR("ATD=")); |
memcpy((full_command + strlen(full_command)), data, 12); |
full_command[16] = 0; |
break; |
case BT_FIND_DEVICES: |
strcpy_P(full_command, PSTR("ATF?")); |
break; |
case BT_DISABLE_AUTOCONNECT: |
strcpy_P(full_command, PSTR("ATO1")); |
break; |
case BT_SET_MASTER: |
strcpy_P(full_command, PSTR("ATR0")); |
break; |
case BT_SET_SLAVE: |
strcpy_P(full_command, PSTR("ATR1")); |
break; |
case BT_SET_NAME: |
strcpy_P(full_command, PSTR("ATN=")); |
for (uint8_t i = 0; i < bt_name_len; i++) |
{ |
full_command[i + 4] = bt_name[i]; |
} |
full_command[(bt_name_len + 4)] = 0; |
break; |
case BT_SET_DISPWRDOWN: |
strcpy_P(full_command, PSTR("ATS1")); |
break; |
default: |
warn_pgm(PSTR("CMD UNK")); |
return false; |
} |
strcat_P(full_command, PSTR("\r")); |
// throw away your television |
uart_receive(); |
fifo_clear(&in_fifo); |
// debug_pgm(PSTR("bt_init3")); |
// send command |
uart_send(full_command, strlen(full_command)); |
if (command== BT_SET_ECHO) |
return true; |
if (command== BT_SET_ANSWER) |
return true; |
// get response |
while_timeout(true, BT_CMD_TIMEOUT_MS) |
{ |
uart_receive(); |
if (fifo_strstr_pgm(&in_fifo, PSTR("OK\r\n"))) |
{ |
info_pgm(PSTR("CMD SEND: OK")); |
return true; |
} |
if (fifo_strstr_pgm(&in_fifo, PSTR("ERROR\r\n"))) |
{ |
#ifdef DEBUG |
info_pgm(PSTR("CMD SEND: Error")); |
#endif |
return false; |
} |
} |
#ifdef DEBUG |
if (command != BT_TEST) |
warn_pgm(PSTR("CMD SEND: TIMEOUT")); |
#endif |
return false; |
} |
//-------------------------------------------------------------- |
void test(void) |
{ |
comm_mode = BT_RAW; |
for (uint8_t i = 0; i < 3; i++) |
if (send_cmd(BT_TEST, NULL)) |
break; |
comm_mode = BT_CMD; |
} |
#ifndef SaveMem |
//-------------------------------------------------------------- |
static void clean_line(void) |
{ |
while_timeout(true, 50) |
uart_receive(); |
fifo_strstr_pgm(&in_fifo, PSTR("\r\n")); |
} |
static communication_mode_t update_comm_mode(uint16_t timeout_ms) |
{ |
while_timeout(true, timeout_ms) |
{ |
uart_receive(); |
if (fifo_strstr_pgm(&in_fifo, PSTR("DISCONNECT"))) |
{ |
clean_line(); |
test(); |
comm_mode = BT_CMD; |
return comm_mode; |
} |
if (fifo_strstr_pgm(&in_fifo, PSTR("CONNECT"))) |
{ |
_delay_ms(100); //don't delete this, else there will be no success!!!!!!!!! |
comm_mode = BT_DATA; |
return comm_mode; |
} |
if (fifo_strstr_pgm (&in_fifo, PSTR("Time out,Fail to connect!"))) |
{ |
clean_line(); |
#ifdef DEBUG |
debug_pgm(PSTR("CONNECT FAILED")); |
#endif |
test(); |
comm_mode = BT_CMD; |
return comm_mode; |
} |
} |
return comm_mode; |
} |
#endif |
//-------------------------------------------------------------- |
uint16_t bt_init(void) |
{ |
uint8_t init_error = false; |
uint8_t BT_found = 0; |
i = 0; |
set_BTOn(); |
lcd_cls(); |
lcd_printp_at (0, 0, PSTR("BT initialisieren.."), 0); |
_delay_ms(200); |
for (uint8_t z = (bt_name_length); z > 0; z--) |
{ |
if (bt_name[z - 1] != ' ') |
{ |
bt_name_len = z; |
break; |
} |
} |
uart1_init(UART_BAUD_SELECT(57600, F_CPU)); |
fifo_init(&in_fifo, bt_buffer, IN_FIFO_SIZE); |
_delay_ms(100); |
// debug_pgm(PSTR("bt_init")); |
uart_receive(); |
// debug_pgm(PSTR("bt_init1")); |
fifo_clear(&in_fifo); |
send_cmd(BT_TEST, NULL); |
comm_mode = BT_NOECHO; |
send_cmd(BT_SET_ECHO, NULL); |
send_cmd(BT_SET_ANSWER, NULL); |
// debug_pgm(PSTR("bt_init2")); |
#ifdef DEBUG |
debug_pgm(PSTR("Check with 57600")); |
#endif |
// send_cmd(BT_TEST, NULL); // Schrott löschen |
if (send_cmd(BT_TEST, NULL)) // Test mit 57600 |
{ |
#ifdef DEBUG |
debug_pgm(PSTR("BT found 57600 Baud")); |
#endif |
BT_found = 1; |
} |
if (BT_found == 0) |
{ |
#ifdef DEBUG |
debug_pgm(PSTR("Check with 19200")); |
#endif |
uart1_init(UART_BAUD_SELECT(19200, F_CPU));// Test mit 19200 |
_delay_ms(100); |
send_cmd(BT_TEST, NULL); // Schrott löschen |
send_cmd(BT_SET_ANSWER, NULL); |
send_cmd(BT_SET_ECHO, NULL); |
if (send_cmd(BT_TEST, NULL)) |
{ |
debug_pgm(PSTR("19200 OK")); |
if (send_cmd(BT_TEST, NULL)) |
{ |
#ifdef DEBUG |
debug_pgm(PSTR("BT found 19200 Baud")); |
#endif |
BT_found = 2; |
} |
} |
} |
if (BT_found == 0) |
{ |
#ifdef DEBUG |
debug_pgm(PSTR("Check with 9600")); |
#endif |
uart1_init(UART_BAUD_SELECT(9600, F_CPU));//test mit 9600 |
_delay_ms(100); |
send_cmd(BT_TEST, NULL); |
send_cmd(BT_SET_ANSWER, NULL); |
send_cmd(BT_SET_ECHO, NULL); |
if (send_cmd(BT_TEST, NULL)); |
{ |
#ifdef DEBUG |
debug_pgm(PSTR("9600 OK")); |
#endif |
if (send_cmd(BT_TEST, NULL)) |
{ |
#ifdef DEBUG |
debug_pgm(PSTR("BT found 9600 Baud")); |
#endif |
BT_found = 3; |
} |
} |
} |
if (BT_found > 0) |
{ |
/* Set comm_mode to CMD */ |
comm_mode = BT_CMD; |
// test(); |
/* Set BTM Baudrate */ |
if (!(send_cmd(BT_SET_57600, NULL))) |
init_error = true; |
uart1_init(UART_BAUD_SELECT(57600, F_CPU)); |
_delay_ms(100); |
// test(); |
/* Clear remote address */ |
if(!(send_cmd(BT_CLEAR_ADDRESS, NULL))) |
init_error = true; |
// test(); |
/* Set BTM to SLAVE */ |
if (!(send_cmd(BT_SET_SLAVE, NULL))) |
init_error = true; |
// test(); |
/* Set BTM PIN */ |
if(!(send_cmd(BT_SET_PIN, NULL))) |
init_error = true; |
// test(); |
/* Set BTM Name */ |
if(!(send_cmd(BT_SET_NAME, NULL))) |
init_error = true; |
_delay_ms(300); |
// test(); |
if(!(send_cmd(BT_SET_DISPWRDOWN, NULL))) |
init_error = true; |
// test(); |
/* Set BTM Echo aus */ |
send_cmd(BT_SET_NOECHO, NULL); |
// test(); |
comm_mode = BT_NOECHO; |
/* Set BTM Answer aus */ |
send_cmd(BT_SET_NOANSWER, NULL); |
// test(); |
bt_mode = BLUETOOTH_SLAVE; |
set_USBOn(); |
if (!init_error) |
{ |
WriteBTInitFlag(); // Init merken |
return true; |
} |
else |
return false; |
} |
else |
{ |
set_USBOn(); |
return false; |
} |
} |
#ifndef SaveMem |
//-------------------------------------------------------------- |
uint16_t bt_set_mode(const bt_mode_t mode) |
{ |
if (update_comm_mode(0) == BT_DATA) |
return false; |
if (mode == bt_mode) |
return true; |
if (mode == BLUETOOTH_MASTER) |
if (send_cmd(BT_SET_MASTER, NULL)) |
{ |
bt_mode = BLUETOOTH_MASTER; |
test(); |
send_cmd(BT_DISABLE_AUTOCONNECT, NULL); |
} |
if (mode == BLUETOOTH_SLAVE) |
if (send_cmd(BT_SET_SLAVE, NULL)) |
{ |
bt_mode = BLUETOOTH_SLAVE; |
} |
test(); |
return mode == bt_mode; |
} |
//-------------------------------------------------------------- |
uint16_t bt_receive(void *data, uint8_t length, uint16_t timeout_ms) |
{ |
uint8_t rec_length = 0; |
uint8_t i = 0; |
// while_timeout(true, timeout_ms); |
for(uint16_t __timeout = 0; __timeout++ <= true && (timeout_ms); _delay_ms(true ? 1 : 0)) |
{ |
if (i == length) |
return true; |
uart_receive(); |
if (fifo_is_empty(&in_fifo)) |
continue; |
if (update_comm_mode(0) != BT_DATA) |
{ |
#ifdef DEBUG |
debug_pgm(PSTR("not connected")); |
#endif |
return false; |
} |
// We have a connection |
if (timeout_ms == 0) |
timeout_ms += 2000; |
if (fifo_is_empty(&in_fifo)) |
continue; |
// Find starting point of packet |
if (!rec_length) |
{ |
fifo_read(&in_fifo, (char *)&rec_length); |
if (rec_length != length) |
{ |
rec_length = 0; |
} |
else |
{ |
// You've got mail! |
timeout_ms += 2000; |
} |
} |
else |
{ |
fifo_read(&in_fifo, (char *)data + i); |
i++; |
} |
} |
return false; |
} |
#endif |
#ifndef SaveMem |
//-------------------------------------------------------------- |
uint16_t bt_send(void *data, const uint8_t length) |
{ |
if (update_comm_mode(0) == BT_CMD) |
return false; |
uart_send((const char *)&length, 1); |
uart_send((char *)data, length); |
return (update_comm_mode(0) == BT_DATA); |
} |
#ifdef SQUIRREL |
//-------------------------------------------------------------- |
uint16_t bt_connect(const char *address) |
{ |
// Maybe we already disconnected??? |
if (BT_DATA == update_comm_mode(0)) |
{ |
#ifdef DEBUG |
debug_pgm(PSTR("We are still connected...")); |
#endif |
return false; |
} |
test(); |
if (!send_cmd(BT_DISABLE_AUTOCONNECT, address)) |
return false; |
test(); |
#ifdef DEBUG |
debug_pgm (PSTR ("SET_ADD")); |
#endif |
if (!send_cmd(BT_SET_ADDRESS, address)) |
return false; |
test(); |
#ifdef DEBUG |
debug_pgm (PSTR ("CONNECT")); |
#endif |
if (!send_cmd(BT_CONNECT, NULL)) |
return false; |
#ifdef DEBUG |
debug_pgm (PSTR ("WAIT FOR COMM")); |
#endif |
return (BT_DATA == update_comm_mode(60000)); |
} |
//-------------------------------------------------------------- |
uint16_t bt_disconnect(void) |
{ |
/* Bluetooth reseten */ |
// set_bit(PORTC.DIR, 4); |
// set_bit(PORTC.OUT, 4); |
_delay_ms(500); |
// clear_bit(PORTC.OUT, 4); |
// return bt_init(); |
#if 1 |
if (BT_CMD == update_comm_mode(0)) |
{ |
fifo_clear(&in_fifo); |
return true; |
} |
// Switch to online cmd mode |
for (uint8_t i = 0; i < 4; i++) |
{ |
const char plus = '+'; |
uart_send(&plus, 1); |
_delay_ms(1500); |
} |
//comm_mode = BT_CMD; |
if (!send_cmd(BT_DISCONNECT, NULL)) |
return false; |
test(); |
if (!send_cmd(BT_CLEAR_ADDRESS, NULL)) |
return false; |
test(); |
if (BT_CMD == update_comm_mode(10000)) |
{ |
fifo_clear(&in_fifo); |
return true; |
} |
#ifdef DEBUG |
debug_pgm(PSTR("Still in DATA??")); |
#endif |
return false; |
#endif |
} |
//-------------------------------------------------------------- |
void copy_address(const char *src, char *dst) |
{ |
uint8_t off = 0; |
for (uint8_t i = 0; i < 14; i++) |
{ |
if (src[i + off] == '-') |
off++; |
dst[i] = src[i + off]; |
} |
} |
//-------------------------------------------------------------- |
uint16_t bt_discover(char result[8][12]) |
// 14.8.2011 ist noch nicht getestet, wird für PKT auch nicht benötigt, Cebra |
{ |
// update_callback(20); |
test(); |
if (!bt_set_mode(BLUETOOTH_MASTER)) |
return false; |
if (!send_cmd(BT_FIND_DEVICES, NULL)) |
return false; |
char buffer[255]; //oversized, but who cares? |
char *bufferhead = buffer; |
uint8_t pos = 0; |
uint16_t Timeout = 20000; |
uint8_t pos1 = 0; |
do |
{ |
uart_receive(); |
Timeout--; |
pos1++; |
_delay_ms(1); |
} |
while ((Timeout > 0) ||(!fifo_strstr_pgm(&in_fifo, PSTR("Inquiry Results:\r\n")))); |
// byte_to_hex(Timeout); |
assert_pgm((!fifo_strstr_pgm(&in_fifo, PSTR("Inquiry Results:\r\n"))),PSTR("INQ Result false")); |
info_pgm (PSTR ("Rec1")); |
for (uint16_t i = 0; i < 60000; i++) |
{ |
//if ((i % 1000) == 0) |
//update_callback(40 + i / 1000); |
uart_receive(); |
// lcd_printp(".", 0); |
_delay_ms(1); |
} |
info_pgm (PSTR ("Rec2")); |
//update_callback(100); |
while (!fifo_is_empty(&in_fifo)) |
{ |
// Get next line |
while (!fifo_cmp_pgm(&in_fifo, PSTR("\r\n"))) |
{ |
fifo_read(&in_fifo, bufferhead); |
bufferhead++; |
} |
// terminate string |
*bufferhead = 0; |
//reset bufferhead |
bufferhead = buffer; |
if (strlen(buffer) == 0) |
continue; //the empty line before end of inquiry |
if (strstr_P(buffer, PSTR("Inquiry End"))) |
{ |
fifo_clear(&in_fifo); |
test(); |
return true; |
} |
if (strncmp_P(PSTR("0012"), &buffer[21], 4)) |
{ |
copy_address(&buffer[21], result[pos]); |
pos++; |
} |
} |
return false; |
} |
#endif |
#endif |
#endif /* SQUIRREL */ |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/bluetooth.h |
---|
0,0 → 1,127 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
#ifndef _BLUETOOTH_H_ |
#define _BLUETOOTH_H_ |
#include <avr/io.h> |
//#include <common.h> |
#define SQUIRREL |
#define NUTS_LIST 16 |
#define EXTENSIONS_LIST 16 |
//void InitBT(void); |
typedef struct _device_info device_info; |
// device info struct, holds mac , class and extensions + values of a device |
struct _device_info |
{ |
char mac[12]; |
uint8_t class; |
uint8_t extension_types[EXTENSIONS_LIST]; |
uint16_t values_cache[EXTENSIONS_LIST]; |
}; |
extern device_info device_list[NUTS_LIST]; |
#define valid(num) (num < NUTS_LIST && (device_list[num].mac[0] != 0 || device_list[num].mac[1] != 0 || device_list[num].mac[2] != 0 || device_list[num].mac[3] != 0 || device_list[num].mac[4] != 0 || device_list[num].mac[5] != 0 || device_list[num].mac[6] != 0 || device_list[num].mac[7] != 0 || device_list[num].mac[8] != 0 || device_list[num].mac[9] != 0 || device_list[num].mac[10] != 0 || device_list[num].mac[11] != 0)) |
// Bluetooth mode ENUM |
typedef enum |
{ |
BLUETOOTH_MASTER, // < Master Mode (to create outgoinng connections). |
BLUETOOTH_SLAVE // < Slave Mode (to wait for incoming connections). |
} bt_mode_t; |
// init bluetooth driver |
// @return always true |
// |
//extern uint16_t bt_init (void (*upate_percentage) (uint16_t)); |
extern uint16_t bt_init (void); |
// Set the Bluetooth mode |
// @param mode bt_mode_t Bluetooth Mode ENUM (BLUETOOTH_MASTER or BLUETOOTH_SLAVE) |
// @return true if mode change was succesful, false if not |
// |
extern uint16_t bt_set_mode (const bt_mode_t mode); |
// recieve data over bluetooth |
// @param data pointer to memory for data storage |
// @param length value of length after call holds the actual recived data length |
// @param timeout_ms timeout in ms after the recive function aborts and returns with false |
// @return false if recived length > length parameter or it timeouted, true otherwise |
// |
extern uint16_t bt_receive (void * data, uint8_t length, uint16_t timeout_ms); |
// send data over bluetooth |
// @param data pointer to the data to send |
// @param length length of the data to be send |
// @return true if sendingn was successful, false otherwise |
// |
extern uint16_t bt_send (void * data, const uint8_t length); |
// squirrelt only functions |
#ifdef SQUIRREL |
// open bluetoot connection (only one at a time possible) |
// @param address connection is opened to this device mac address |
// @return true if connection was established, false otherwise |
// |
extern uint16_t bt_connect (const char *address); |
// closes bluetooth connection |
// @return false if failed, true otherwise |
// |
extern uint16_t bt_disconnect (void); |
// discover bluetooth devices |
// @param result in a 2 dimensional array first index are devicecs (max 8) second is mac address string |
// @param update_callback to inform of progress (in % from 0 to 100) |
// @return true if successful, false if error occured |
// |
extern uint16_t bt_discover (char result[8][12]); |
//extern uint16_t bt_discover (char result[8][12], void (*update_callback)(const uint16_t progress)); |
#endif // SQUIRREL |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/connect.c |
---|
0,0 → 1,394 |
/***************************************************************************** |
* 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/pgmspace.h> |
#include "lcd.h" |
#include "timer.h" |
#include "eeprom.h" |
#include "messages.h" |
#include "lipo.h" |
#if defined HWVERSION1_3W || defined HWVERSION3_9 |
//-------------------------------------------------------------- |
void Change_Output(uint8_t UartMode) // Schaltet die Rx/Tx Richtungen |
{ |
// hiermit werden die 74HTC125 (IC5) Gatter geschaltet |
clr_USB2FC(); // PC2 aus |
clr_USB2Wi(); // PB0 aus |
clr_Uart02FC(); // PC6 aus |
clr_Uart02Wi(); // PC5 aus |
switch (UartMode) |
{ |
case USB2FC: |
UCSR1B &= ~(1<<RXEN1); |
UCSR1B &= ~(1<<TXEN1); |
UCSR1B &= ~(1<<RXCIE1); |
DDRD &= ~(1<<DDD2); // Pins auf Eingang setzen |
DDRD &= ~(1<<DDD3); |
PORTD &= ~(1<<PD2); // Pullup aus |
PORTD &= ~(1<<PD3); |
set_USB2FC(); |
break; |
case Uart02Wi: |
set_Uart02Wi(); |
break; |
case Uart02FC: |
set_Uart02FC(); |
break; |
case USB2Wi: |
UCSR1B &= ~(1<<RXEN1); |
UCSR1B &= ~(1<<TXEN1); |
UCSR1B &= ~(1<<RXCIE1); |
DDRD &= ~(1<<DDD2); // Pins auf Eingang setzen |
DDRD &= ~(1<<DDD3); |
PORTD &= ~(1<<PD2); // Pullup aus |
PORTD &= ~(1<<PD3); |
set_USB2Wi(); |
break; |
} |
} |
//-------------------------------------------------------------- |
// Function: BT2FC() |
// Purpose: Connect BT direct to FC-Kabel (SV2 as MKUSB) |
// Returns: |
//-------------------------------------------------------------- |
void Port_BT2FC(void) |
{ |
lcd_cls (); |
if(UseBT == true) |
{ |
// lcd_printp_at (0, 0, PSTR(" MK-USB Funktion "), 2); |
lcd_puts_at(0, 0, strGet(CONNECT14), 2); |
// lcd_printp_at (0, 1, PSTR(" BT --> Kabel an FC "), 2); |
lcd_puts_at(0, 1, strGet(CONNECT15), 0); |
// lcd_printp_at (0, 3, PSTR("PC mit BT verb."), 0); |
lcd_puts_at(0, 3, strGet(CONNECT16), 0); |
// lcd_printp_at (0, 4, PSTR("PKT-Kabel an FC"), 0); |
lcd_puts_at(0, 4, strGet(CONNECT17), 0); |
// lcd_printp_at (0, 5, PSTR("MK-Tool starten"), 0); |
// lcd_printp_at (12, 7, PSTR("Esc"), 0); |
lcd_puts_at(0, 5, strGet(CONNECT23), 0); |
lcd_puts_at(12, 7, strGet(ESC), 0); |
set_BTOn(); |
Change_Output(USB2FC); |
do |
{ |
show_Lipo(); |
} |
while(!get_key_press (1 << KEY_ESC)); |
get_key_press(KEY_ALL); |
if (U02SV2 == 1) |
Change_Output(Uart02FC); |
else |
Change_Output(Uart02Wi); |
set_USBOn(); |
return; |
} |
else |
{ |
// lcd_printp_at (0, 0, PSTR("Es ist kein BTM-222 "), 0); |
// lcd_printp_at (0, 1, PSTR("Modul eingebaut! "), 0); |
// lcd_printp_at (0, 3, PSTR("Wenn doch, dann bitte"), 0); |
// lcd_printp_at (0, 4, PSTR("das Modul zuerst im "), 0); |
// lcd_printp_at (0, 5, PSTR("Setupmenü aktivieren."), 0); |
lcd_puts_at(0, 1, strGet(CONNECT12), 0); |
lcd_puts_at(0, 1, strGet(CONNECT13), 0); |
lcd_puts_at(0, 2, strGet(CONNECT7), 0); |
lcd_puts_at(0, 3, strGet(CONNECT8), 0); |
lcd_puts_at(0, 4, strGet(CONNECT9), 0); |
lcd_puts_at(12, 7, strGet(ENDE), 0); |
// lcd_printp_at (12, 7, PSTR("Ende"), 0); |
while(!get_key_press (1 << KEY_ESC)); |
get_key_press(KEY_ALL); |
return; |
} |
} |
//-------------------------------------------------------------- |
// Function: BT2Wi() |
// Purpose: Connect BT direct to Wi.232 |
// Returns: |
//-------------------------------------------------------------- |
void Port_BT2Wi(void) |
{ |
lcd_cls (); |
// if((UseBT == true) && (UseWi == true))6.1.2012 CB Abfrage entfernt, damit die Funktion auch ohne Module geht |
{ |
// lcd_printp_at (0, 0, PSTR(" MK-USB Funktion "), 2); |
lcd_puts_at(0, 0, strGet(CONNECT14), 2); |
// lcd_printp_at (0, 1, PSTR(" BT --> Wi.232 "), 2); |
lcd_puts_at(0, 1, strGet(CONNECT18), 2); |
// lcd_printp_at (0, 3, PSTR("PC mit BT verbinden "), 0); |
lcd_puts_at(0, 3, strGet(CONNECT16), 0); |
// lcd_printp_at (0, 4, PSTR("Wi.232 an FC "), 0); |
lcd_puts_at(0, 4, strGet(CONNECT19), 0); |
// lcd_printp_at (0, 5, PSTR("MK-Tool starten "), 0); |
lcd_puts_at(0, 5, strGet(CONNECT23), 0); |
// lcd_printp_at (12, 7, PSTR("Esc"), 0); |
lcd_puts_at(12, 7, strGet(ESC), 0); |
set_BTOn(); |
Change_Output(USB2Wi); |
do |
{ |
show_Lipo(); |
} |
while(!get_key_press (1 << KEY_ESC)); |
get_key_press(KEY_ALL); |
if (U02SV2 == 1) |
Change_Output(Uart02FC); |
else |
Change_Output(Uart02Wi); |
set_USBOn(); |
return; |
} |
// else |
// { |
//// lcd_printp_at (0, 0, PSTR("Es ist kein BTM-222 "), 0); |
//// lcd_printp_at (0, 1, PSTR("Modul eingebaut! "), 0); |
//// lcd_printp_at (0, 3, PSTR("Wenn doch, dann bitte"), 0); |
//// lcd_printp_at (0, 4, PSTR("das Modul zuerst im "), 0); |
//// lcd_printp_at (0, 5, PSTR("Setupmenü aktivieren."), 0); |
// |
// lcd_puts_at(0, 0, strGet(CONNECT12), 0); |
// lcd_puts_at(0, 1, strGet(CONNECT13), 0); |
// lcd_puts_at(0, 2, strGet(CONNECT7), 0); |
// lcd_puts_at(0, 3, strGet(CONNECT8), 0); |
// lcd_puts_at(0, 4, strGet(CONNECT9), 0); |
// lcd_puts_at(12, 7, strGet(ENDE), 0); |
//// lcd_printp_at (12, 7, PSTR("Ende"), 0); |
// |
// while(!get_key_press (1 << KEY_ESC)); |
// get_key_press(KEY_ALL); |
// |
// return; |
// } |
} |
//-------------------------------------------------------------- |
// Function: FC2CFG_BT() |
// Purpose: Connect FC (Tx1 Pin3, Rx1 Pin4) direct to BT |
// Returns: |
//-------------------------------------------------------------- |
void Port_FC2CFG_BT(void) |
{ |
lcd_cls (); |
lcd_printp_at (0, 0, PSTR("BTM-222 Konfigurieren"), 2); |
lcd_printp_at (0, 1, PSTR("FC > MK-USB > BTM-222"), 2); |
lcd_printp_at (0, 3, PSTR("MK-USB an PC anschl. "), 0); |
lcd_printp_at (0, 4, PSTR("Zwischen MK-USB und "), 0); |
lcd_printp_at (0, 5, PSTR("PKT ein gekreuztes "), 0); |
lcd_printp_at (0, 6, PSTR("Kabel anschliessen. "), 0); |
lcd_puts_at(12, 7, strGet(ESC), 0); |
// lcd_printp_at (12, 7, PSTR("Esc"), 0); |
set_BTOn(); |
Change_Output(USB2FC); |
while(!get_key_press (1 << KEY_ESC)); |
get_key_press(KEY_ALL); |
if (U02SV2 == 1) |
Change_Output(Uart02FC); |
else |
Change_Output(Uart02Wi); |
set_USBOn(); |
return; |
} |
//-------------------------------------------------------------- |
// Function: USB2FC() |
// Purpose: Connect USB direct to FC-Kabel (SV2 as MKUSB) |
// Returns: |
//-------------------------------------------------------------- |
void Port_USB2FC(void) |
{ |
lcd_cls (); |
// lcd_printp_at (0, 0, PSTR(" MK-USB Funktion "), 2); |
lcd_puts_at(0, 0, strGet(CONNECT14), 2); |
// lcd_printp_at (0, 1, PSTR(" USB --> Kabel an FC "), 2); |
lcd_puts_at(0, 1, strGet(CONNECT20), 0); |
// lcd_printp_at (0, 3, PSTR("PC mit USB verbinden "), 0); |
lcd_puts_at(0, 3, strGet(CONNECT21), 0); |
// lcd_printp_at (0, 4, PSTR("PKT-Kabel an FC "), 0); |
lcd_puts_at(0, 4, strGet(CONNECT17), 0); |
// lcd_printp_at (0, 5, PSTR("MK-Tool starten "), 0); |
// lcd_printp_at (12, 7, PSTR("Esc"), 0); |
lcd_puts_at(0, 5, strGet(CONNECT23), 0); |
lcd_puts_at(12, 7, strGet(ESC), 0); |
Change_Output(USB2FC); |
do |
{ |
show_Lipo(); |
} |
while(!get_key_press (1 << KEY_ESC)); |
get_key_press(KEY_ALL); |
if (U02SV2 == 1) |
Change_Output(Uart02FC); |
else |
Change_Output(Uart02Wi); |
return; |
} |
//-------------------------------------------------------------- |
// Function: USB2Wi() |
// Purpose: Connect USB direct to Wi.232 |
// Returns: |
//-------------------------------------------------------------- |
void Port_USB2Wi(void) |
{ |
lcd_cls (); |
// if(UseWi == true) // 6.1.2012 CB Abfrage entfernt, damit die Funktion auch ohne Module geht |
{ |
// lcd_printp_at (0, 0, PSTR(" MK-USB Funktion "), 2); |
lcd_puts_at(0, 0, strGet(CONNECT14), 2); |
// lcd_printp_at (0, 1, PSTR(" USB --> Wi.232 "), 2); |
lcd_puts_at(0, 1, strGet(CONNECT22), 2); |
// lcd_printp_at (0, 3, PSTR("PC mit USB verbinden "), 0); |
lcd_puts_at(0, 3, strGet(CONNECT21), 0); |
// lcd_printp_at (0, 4, PSTR("Wi.232 an FC "), 0); |
lcd_puts_at(0, 4, strGet(CONNECT19), 0); |
// lcd_printp_at (0, 5, PSTR("MK-Tool starten "), 0); |
lcd_puts_at(0, 5, strGet(CONNECT23), 0); |
lcd_puts_at(12, 7, strGet(ESC), 0); |
// lcd_printp_at (12, 7, PSTR("Esc"), 0); |
Change_Output(USB2Wi); |
do |
{ |
show_Lipo(); |
} |
while(!get_key_press (1 << KEY_ESC)); |
get_key_press(KEY_ALL); |
if (U02SV2 == 1) |
Change_Output(Uart02FC); |
else |
Change_Output(Uart02Wi); |
return; |
} |
// else |
// { |
//// lcd_printp_at (0, 0, PSTR("Es ist kein Wi.232 "), 0); |
//// lcd_printp_at (0, 1, PSTR("Modul eingebaut! "), 0); |
//// lcd_printp_at (0, 3, PSTR("Wenn doch, dann bitte"), 0); |
//// lcd_printp_at (0, 4, PSTR("das Modul zuerst im "), 0); |
//// lcd_printp_at (0, 5, PSTR("Setupmenü aktivieren."), 0); |
//// lcd_printp_at (12, 7, PSTR("Ende"), 0); |
// lcd_puts_at(0, 0, strGet(CONNECT5), 0); |
// lcd_puts_at(0, 1, strGet(CONNECT6), 0); |
// lcd_puts_at(0, 2, strGet(CONNECT7), 0); |
// lcd_puts_at(0, 3, strGet(CONNECT8), 0); |
// lcd_puts_at(0, 4, strGet(CONNECT9), 0); |
// lcd_puts_at(12, 7, strGet(ENDE), 0); |
// while(!get_key_press (1 << KEY_ESC)); |
// get_key_press(KEY_ALL); |
// |
// return; |
// } |
} |
//-------------------------------------------------------------- |
// Function: USB2CFG_Wi() |
// Purpose: Connect USB direct to Wi.232 in Progmode |
// Returns: |
//-------------------------------------------------------------- |
void Port_USB2CFG_Wi(void) |
{ |
lcd_cls (); |
// lcd_printp_at (0, 0, PSTR(" Wi.232 Konfigurieren"), 2); |
lcd_puts_at(0, 0, strGet(CONNECT24), 2); |
// lcd_printp_at (0, 1, PSTR(" USB --> Wi.232 "), 2); |
lcd_puts_at(0, 1, strGet(CONNECT22), 2); |
// lcd_printp_at (0, 3, PSTR("PC mit USB verbinden."), 0); |
lcd_puts_at(0, 3, strGet(CONNECT21), 0); |
lcd_printp_at (0, 4, PSTR("Radiotronix Wi.232DTS"), 0); |
lcd_printp_at (0, 5, PSTR("Evaluation (868MHz) "), 0); |
// lcd_printp_at (0, 6, PSTR("Programm starten. "), 0); |
lcd_puts_at(0, 6, strGet(CONNECT25), 0); |
lcd_puts_at(12, 7, strGet(ESC), 0); |
// lcd_printp_at (12, 7, PSTR("Esc"), 0); |
Change_Output(USB2Wi); |
set_WI232CMD(); // Port D6 = CMD |
while(!get_key_press (1 << KEY_ESC)); |
get_key_press(KEY_ALL); |
clr_WI232CMD(); // Port D6 = CMD |
if (U02SV2 == 1) |
Change_Output(Uart02FC); |
else |
Change_Output(Uart02Wi); |
return; |
} |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/connect.h |
---|
0,0 → 1,48 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
#ifndef _CONNECT_H |
#define _CONNECT_H |
void Change_Output(uint8_t UartMode); |
void Port_BT2Wi(void); |
void Port_BT2FC(void); |
void Port_FC2CFG_BT(void); |
void Port_USB2FC(void); |
void Port_USB2Wi(void); |
void Port_USB2CFG_Wi(void); |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/cpu.h |
---|
0,0 → 1,41 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
#ifndef _CPU_H |
#define _CPU_H |
// Quarz Frequenz in Hz |
#define F_CPU 20000000UL |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/debug.c |
---|
0,0 → 1,370 |
/***************************************************************************** |
* Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* Copyright (C) 2011 Christian "Cebra" Brandtner, brandtner@brandtner.net * |
* Copyright (C) 2011 Harald Bongartz * |
* * |
* This program is free software; you can redistribute it and/or modify * |
* it under the terms of the GNU General Public License as published by * |
* the Free Software Foundation; either version 2 of the License. * |
* * |
* This program is distributed in the hope that it will be useful, * |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
* GNU General Public License for more details. * |
* * |
* You should have received a copy of the GNU General Public License * |
* along with this program; if not, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
* * |
* Credits to: * |
* Holger Buss & Ingo Busker from mikrokopter.de for the MK project + SVN * |
* http://www.mikrokopter.de * |
* Gregor "killagreg" Stobrawa for his version of the MK code * |
* Thomas Kaiser "thkais" for the original project. See * |
* http://www.ft-fanpage.de/mikrokopter/ * |
* http://forum.mikrokopter.de/topic-4061-1.html * |
* Claas Anders "CaScAdE" Rathje for providing the font and his C-OSD code * |
* http://www.mylifesucks.de/oss/c-osd/ * |
* Harald Bongartz "HaraldB" for providing his Ideas and Code for usibility* |
*****************************************************************************/ |
#include "cpu.h" |
#include <avr/io.h> |
#include <avr/pgmspace.h> |
#include <util/delay.h> |
#include <string.h> |
#include "main.h" |
//#include "menu.h" |
#include "lcd.h" |
#include "usart.h" |
#include "debug.h" |
#include "timer.h" |
#include "messages.h" |
#include "mk-data-structs.h" |
#define TIMEOUT 200 // 2 sec |
#define ANALOGTIME 20 // 200 ms |
// WARNING: this work for NC & FC only |
// if current_hardware == MK3MAG or MKGPS the access is outside of the array... |
uint8_t AnalogNames[2][32][16 + 1]; // 32 names, 16 characters + 1 0x00 |
uint8_t AnalogNamesRead[2] = {0,0}; |
//-------------------------------------------------------------- |
// |
void GetAnalogNames (void) |
{ |
uint8_t i = AnalogNamesRead[current_hardware - 1]; |
uint8_t t = 0; |
lcd_cls (); |
lcd_printp_at (0, 3, PSTR("Reading"), 0); |
lcd_printp_at (0, 4, PSTR("Analog Names: "), 0); |
mode = 'A'; // read Names |
_delay_ms(200); |
rxd_buffer_locked = FALSE; |
timer = ANALOGTIME; |
while (i < 32) |
{ |
SendOutData ('a', ADDRESS_ANY, 1, &i, 1); |
while (!rxd_buffer_locked && timer); |
if (timer) |
{ |
Decode64 (); |
if (i == *pRxData) |
{ |
write_ndigit_number_u(14, 4, i, 2, 0); |
memcpy (AnalogNames[current_hardware - 1][*pRxData], (uint8_t *) pRxData + 1, 16); |
AnalogNames[current_hardware - 1][*pRxData][16] = 0; |
i++; |
t = 0; |
} |
else |
{ |
_delay_ms (100); |
} |
timer = ANALOGTIME; |
rxd_buffer_locked = FALSE; |
} |
else |
{ // timeout occured |
t++; |
timer = ANALOGTIME; |
if (t >= 50) |
{ |
lcd_printp_at (0, 2, PSTR("ERROR: no data"), 0); |
timer = 100; |
while (timer > 0); |
break; |
} |
} |
} |
AnalogNamesRead[current_hardware - 1] = i; |
#if 0 |
if (timer) |
{ |
for (page = 0; page < 5; page++) |
{ |
for (i = 0; i < 7; i++) |
{ |
lcd_print_at (0, i, AnalogNames[current_hardware - 1][i + page * 7], 0); |
} |
while (!get_key_press (1 << KEY_ESC)); // ESC |
get_key_press(KEY_ALL); |
} |
} |
//return; |
#endif |
} |
//-------------------------------------------------------------- |
// |
void display_debug (void) |
{ |
uint8_t i = 0; |
uint8_t tmp_dat; |
uint8_t page = 0; |
DebugData_t *DebugData; |
lcd_cls (); |
timer = TIMEOUT; |
if (AnalogNamesRead[current_hardware - 1] < 32) |
{ |
GetAnalogNames (); |
} |
if (!timer) |
{ |
return; |
} |
mode = 'D'; // Debug Data |
rxd_buffer_locked = FALSE; |
timer = TIMEOUT; |
tmp_dat = 10; |
SendOutData ('d', ADDRESS_ANY, 1, &tmp_dat, 1); |
abo_timer = ABO_TIMEOUT; |
for (i = 0; i < 7; i++) |
{ |
lcd_print_at (0, i, AnalogNames[current_hardware - 1][i + page * 7], 0); |
if (page == 4 && i > 3) |
{ |
for (i = 4; i < 7; i++) // Linie 4, 5, 6 loeschen |
{ |
lcd_cls_line (0, i, 21); |
} |
i = 7; |
} |
} |
do |
{ |
if (rxd_buffer_locked) |
{ |
Decode64 (); |
DebugData = (DebugData_t *) pRxData; |
// lcd_printp_at (0, 7, PSTR(KEY_LINE_3), 0); |
lcd_puts_at(0, 7, strGet(KEYLINE3), 0); |
lcd_write_number_u_at (5, 7, page + 1); |
switch (current_hardware) |
{ |
case FC: |
lcd_printp_at (3, 7, PSTR("FC"), 0); |
lcd_printp_at (19, 7, PSTR("NC"), 0); |
break; |
case NC: |
lcd_printp_at (3, 7, PSTR("NC"), 0); |
lcd_printp_at (19, 7, PSTR("FC"), 0); |
break; |
default: |
lcd_printp_at (19, 7, PSTR("?"), 0); |
break; |
} |
for (i = 0; i < 7; i++) |
{ |
//lcd_print_at (0, i, AnalogNames[i + page * 7], 0); |
uint8_t size =0; |
if( DebugData->Analog[i + page * 7] < -9999) |
{ |
size = 6; |
} |
else if ( DebugData->Analog[i + page * 7] < -999) |
{ |
size = 5; |
} |
else if ( DebugData->Analog[i + page * 7] < -99) |
{ |
size = 4; |
} |
else if ( DebugData->Analog[i + page * 7] < 999) |
{ |
size = 3; |
} |
else if ( DebugData->Analog[i + page * 7] < 9999) |
{ |
size = 4; |
} |
else |
{ |
size = 5; |
} |
write_ndigit_number_s (21-size, i, DebugData->Analog[i + page * 7], size, 0); |
if (page == 4 && i > 3) |
{ |
for (i = 4; i < 7; i++) // Linie 4, 5, 6 loeschen |
{ |
lcd_cls_line (0, i, 21); |
} |
i = 7; |
} |
} |
timer = TIMEOUT; |
rxd_buffer_locked = FALSE; |
} |
if (!abo_timer) |
{ // renew abo every 3 sec |
// request OSD Data from NC every 100ms |
// RS232_request_mk_data (1, 'o', 100); |
tmp_dat = 10; |
SendOutData ('d', ADDRESS_ANY, 1, &tmp_dat, 1); |
abo_timer = ABO_TIMEOUT; |
} |
if (get_key_press (1 << KEY_MINUS)) |
{ |
page--; |
if (page > 4) |
{ |
page = 4; |
} |
lcd_cls (); |
for (i = 0; i < 7; i++) |
{ |
lcd_print_at (0, i, AnalogNames[current_hardware - 1][i + page * 7], 0); |
if (page == 4 && i > 3) |
{ |
for (i = 4; i < 7; i++) // Linie 4, 5, 6 loeschen |
{ |
lcd_cls_line (0, i, 21); |
} |
i = 7; |
} |
} |
} |
else if (get_key_press (1 << KEY_PLUS)) |
{ |
page++; |
if (page > 4) |
{ |
page = 0; |
} |
lcd_cls (); |
for (i = 0; i < 7; i++) |
{ |
lcd_print_at (0, i, AnalogNames[current_hardware - 1][i + page * 7], 0); |
if (page == 4 && i > 3) |
{ |
for (i = 4; i < 7; i++) // Linie 4, 5, 6 loeschen |
{ |
lcd_cls_line (0, i, 21); |
} |
i = 7; |
} |
} |
} |
if ((hardware == NC) && get_key_press (1 << KEY_ENTER)) |
{ |
tmp_dat = 0; |
SendOutData ('d', ADDRESS_ANY, 1, &tmp_dat, 1); |
_delay_ms (200); |
if (current_hardware == NC) |
{ |
SwitchToFC(); |
timer = TIMEOUT; |
} |
else |
{ |
SwitchToNC(); |
timer = TIMEOUT; |
} |
_delay_ms (200); |
if (AnalogNamesRead[current_hardware - 1] < 32) |
{ |
GetAnalogNames (); |
} |
mode = 'D'; // Debug Data |
rxd_buffer_locked = FALSE; |
timer = TIMEOUT; |
tmp_dat = 10; |
SendOutData ('d', ADDRESS_ANY, 1, &tmp_dat, 1); |
lcd_cls (); |
page = 0; |
for (i = 0; i < 7; i++) |
{ |
lcd_print_at (0, i, AnalogNames[current_hardware - 1][i + page * 7], 0); |
if (page == 4 && i > 3) |
{ |
for (i = 4; i < 7; i++) // Linie 4, 5, 6 loeschen |
{ |
lcd_cls_line (0, i, 21); |
} |
i = 7; |
} |
} |
} |
} |
while (!get_key_press (1 << KEY_ESC) && timer); // ESC |
get_key_press(KEY_ALL); |
tmp_dat = 0; |
SendOutData ('d', ADDRESS_ANY, 1, &tmp_dat, 1); |
mode = 0; |
rxd_buffer_locked = FALSE; |
if (!timer) |
{ // timeout occured |
lcd_cls (); |
lcd_printp_at (0, 2, PSTR("ERROR: no data"), 0); |
timer = 100; |
while (timer > 0); |
} |
SwitchToNC(); |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/debug.h |
---|
0,0 → 1,42 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
#ifndef _DEBUG_H |
#define _DEBUG_H |
extern uint8_t AnalogNamesRead[2]; |
void display_debug(void); |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/display.c |
---|
0,0 → 1,180 |
/***************************************************************************** |
* Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* Copyright (C) 2011 Christian "Cebra" Brandtner, brandtner@brandtner.net * |
* Copyright (C) 2011 Harald Bongartz * |
* * |
* This program is free software; you can redistribute it and/or modify * |
* it under the terms of the GNU General Public License as published by * |
* the Free Software Foundation; either version 2 of the License. * |
* * |
* This program is distributed in the hope that it will be useful, * |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
* GNU General Public License for more details. * |
* * |
* You should have received a copy of the GNU General Public License * |
* along with this program; if not, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
* * |
* Credits to: * |
* Holger Buss & Ingo Busker from mikrokopter.de for the MK project + SVN * |
* http://www.mikrokopter.de * |
* Gregor "killagreg" Stobrawa for his version of the MK code * |
* Thomas Kaiser "thkais" for the original project. See * |
* http://www.ft-fanpage.de/mikrokopter/ * |
* http://forum.mikrokopter.de/topic-4061-1.html * |
* Claas Anders "CaScAdE" Rathje for providing the font and his C-OSD code * |
* http://www.mylifesucks.de/oss/c-osd/ * |
* Harald Bongartz "HaraldB" for providing his Ideas and Code for usibility* |
*****************************************************************************/ |
#include "cpu.h" |
#include <avr/io.h> |
#include <avr/pgmspace.h> |
#include <util/delay.h> |
#include "main.h" |
#include "lcd.h" |
#include "usart.h" |
#include "timer.h" |
#include "messages.h" |
#include "mk-data-structs.h" |
#define TIMEOUT 500 // 5 sec |
void display_data (void) |
{ |
uint8_t cmd; |
uint8_t flag = 0;; |
mode = 'H'; |
lcd_cls (); |
// lcd_printp_at (0, 7, PSTR(KEY_LINE_3), 0); |
lcd_puts_at(0, 7, strGet(KEYLINE3), 0); |
if (current_hardware == NC) |
{ |
lcd_printp_at (0, 0, PSTR(" Navi-Ctrl Display "), 2); |
lcd_printp_at (19, 7, PSTR("FC"), 0); |
} |
else |
{ |
if (hardware == FC) |
{ |
lcd_printp_at (0, 0, PSTR(" Display "), 2); |
lcd_printp_at (19, 7, PSTR(" "), 0); |
} |
else |
{ |
lcd_printp_at (0, 0, PSTR(" Flight-Ctrl Display "), 2); |
lcd_printp_at (19, 7, PSTR("NC"), 0); |
} |
} |
rxd_buffer_locked = FALSE; |
timer = TIMEOUT; |
cmd = 0xfc; // Home = first page |
do |
{ |
SendOutData('h', ADDRESS_ANY, 1, &cmd, 1); |
cmd = 0xff; |
//LED6_TOGGLE; |
_delay_ms (250); |
if (rxd_buffer_locked) |
{ |
Decode64 (); |
flag = 1; |
if (!hardware) |
{ // hardware was not detected at startup |
hardware = rxd_buffer[1] - 'a'; |
if (hardware == NC) |
{ |
lcd_printp_at (0, 0, PSTR(" Navi-Ctrl Display "), 2); |
lcd_printp_at (19, 7, PSTR("FC"), 0); |
current_hardware = NC; |
} |
else |
{ |
lcd_printp_at (0, 0, PSTR(" Display "), 2); |
lcd_printp_at (19, 7, PSTR(" "), 0); |
current_hardware = FC; |
} |
} |
#if 0 |
rxd_buffer[24] = 0; |
lcd_print_at (0, rxd_buffer[3] + 1, (uint8_t *) &rxd_buffer[4], 0); |
#else |
rxd_buffer[83] = 0; |
print_display_at (0, 2, (uint8_t *) &rxd_buffer[3]); |
#endif |
rxd_buffer_locked = FALSE; |
timer = TIMEOUT; |
} |
if (get_key_press (1 << KEY_MINUS) || get_key_long_rpt_sp ((1 << KEY_MINUS), 2)) |
{ |
cmd = 0xfe; // next page |
//SendOutData('h', ADDRESS_ANY, 1, &cmd, 1); |
//cmd = 0; |
} |
else if (get_key_press (1 << KEY_PLUS) || get_key_long_rpt_sp ((1 << KEY_PLUS), 2)) |
{ |
cmd = 0xfd; // previous page |
//SendOutData('h', ADDRESS_ANY, 1, &cmd, 1); |
//cmd = 0; |
} |
else if ((hardware == NC) && get_key_press (1 << KEY_ENTER)) |
{ |
if (current_hardware == NC) |
{ |
SwitchToFC(); |
//timer = TIMEOUT; |
lcd_printp_at (0, 0, PSTR(" Flight-Ctrl Display "), 2); |
lcd_printp_at (19, 7, PSTR("NC"), 0); |
} |
else |
{ |
SwitchToNC(); |
//timer = TIMEOUT; |
lcd_printp_at (0, 0, PSTR(" Navi-Ctrl Display "), 2); |
lcd_printp_at (19, 7, PSTR("FC"), 0); |
} |
cmd = 0xfc; // Home = first page |
//SendOutData('h', ADDRESS_ANY, 1, &cmd, 1); |
//cmd = 0; |
} |
} |
while (!get_key_press (1 << KEY_ESC) && timer); |
get_key_press(KEY_ALL); |
mode = 0; |
rxd_buffer_locked = FALSE; |
if (!timer) |
{ // timeout occured |
if (flag) |
{ |
lcd_cls (); |
} |
lcd_printp_at (0, 2, PSTR("Fehler: Keine Daten"), 0); |
timer = 100; |
while (timer > 0); |
} |
SwitchToNC(); |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/display.h |
---|
0,0 → 1,42 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
#ifndef _DISPLAY_H |
#define _DISPLAY_H |
void display_data (void); |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/eeprom.c |
---|
0,0 → 1,356 |
/***************************************************************************** |
* Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* Copyright (C) 2011 Christian "Cebra" Brandtner, brandtner@brandtner.net * |
* Copyright (C) 2011 Harald Bongartz * |
* * |
* This program is free software; you can redistribute it and/or modify * |
* it under the terms of the GNU General Public License as published by * |
* the Free Software Foundation; either version 2 of the License. * |
* * |
* This program is distributed in the hope that it will be useful, * |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
* GNU General Public License for more details. * |
* * |
* You should have received a copy of the GNU General Public License * |
* along with this program; if not, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
* * |
* Credits to: * |
* Holger Buss & Ingo Busker from mikrokopter.de for the MK project + SVN * |
* http://www.mikrokopter.de * |
* Gregor "killagreg" Stobrawa for his version of the MK code * |
* Thomas Kaiser "thkais" for the original project. See * |
* http://www.ft-fanpage.de/mikrokopter/ * |
* http://forum.mikrokopter.de/topic-4061-1.html * |
* Claas Anders "CaScAdE" Rathje for providing the font and his C-OSD code * |
* http://www.mylifesucks.de/oss/c-osd/ * |
* Harald Bongartz "HaraldB" for providing his Ideas and Code for usibility* |
*****************************************************************************/ |
#include "cpu.h" |
#include <avr/io.h> |
#include <avr/pgmspace.h> |
#include <util/delay.h> |
#include <stdlib.h> |
#include <string.h> |
#include <avr/eeprom.h> |
#include <stdbool.h> |
#include <avr/wdt.h> |
#include "lcd.h" |
#include "main.h" |
#include "timer.h" |
#include "eeprom.h" |
#include "Wi232.h" |
#include "mk-data-structs.h" |
#include "connect.h" |
//-------------------------------------------------------------- |
// |
uint8_t EE_LowBat EEMEM = 137; // 13,7V |
uint8_t EE_DisplayTimeout EEMEM = 0; // Display immer an |
uint8_t EE_DisplayLanguage EEMEM = 254; // Default ungesetzt |
uint8_t EE_WiTXRXChannel EEMEM = 1; // Kanal 1 MK Standard |
uint8_t EE_WiNetworkGroup EEMEM = 66; // Gruppe 66 MK Standard |
uint8_t EE_WiNetworkMode EEMEM = NetMode_Normal; // MK Standard; |
uint8_t EE_WiTXTO EEMEM = TWaitTime16; // MK Standard |
uint8_t EE_WiUartMTU EEMEM = UartMTU64; // MK Standard |
uint8_t EE_LCD_Orientation EEMEM = 0; // normale Ansicht |
uint8_t EE_LCD_DisplayMode EEMEM = 0; // Normal |
uint8_t EE_LCD_Kontrast EEMEM = 27; // Kontrast normal |
uint8_t EE_LCD_Helligkeit EEMEM = 100; // Helligkeit in %gkeit in % |
uint8_t EE_USBBT EEMEM = 0; // USB Betrieb |
uint8_t EE_U02SV2 EEMEM = 1; // SV2 (Kabel) Standard |
uint8_t EE_Debug EEMEM = 0; // kein Debug |
uint8_t EE_UseWi EEMEM = true; // Wi.232 eingebaut? |
uint8_t EE_UseBT EEMEM = true; // BT-222 eingebaut? |
uint8_t EE_WiIsSet EEMEM = false; // Flag für die Initialisierung Wi232 |
uint8_t EE_BTIsSet EEMEM = false; // Flag für die Initialisierung Bluetooth |
uint8_t EE_PKT_IdleBeep EEMEM = 0; // kein Piepsen bei Inaktivität |
uint8_t EE_PKT_StartInfo EEMEM = true; // Startinformationen anzeigen |
uint16_t EE_Lipo_UOffset EEMEM = 0; // Offset für die Lipospannugsmessung |
uint8_t EE_PKT_Accutyp EEMEM = true; // True = Lipo, False = LiON |
uint8_t EEMEM EE_BTPin[bt_pin_length + 1]; |
uint8_t EEMEM EE_BTName[bt_name_length + 1]; |
uint32_t EE_LastLongitude EEMEM = 0; |
uint32_t EE_LastLatitude EEMEM = 0; |
WPListDirectory EEWPDirectory[NumberOfWPLists] EEMEM; |
WayPoints EEWayPointList[NumberOfWaypoints] EEMEM; |
uint8_t EE_PKTVersion EEMEM = EEpromVersion; |
volatile uint8_t DisplayTimeout; |
volatile uint8_t DisplayLanguage; |
volatile uint8_t WiTXRXChannel; |
volatile uint8_t WiNetworkGroup; |
volatile uint8_t WiNetworkMode; |
volatile uint8_t WiTXTO; |
volatile uint8_t WiUartMTU; |
volatile uint8_t LCD_ORIENTATION; |
volatile uint8_t LCD_DisplayMode; |
volatile uint8_t LCD_Kontrast; |
volatile uint8_t LCD_Helligkeit; |
volatile uint8_t USBBT; |
volatile uint8_t U02SV2; |
volatile uint8_t Debug; |
volatile uint8_t UseWi; // Wi232 wird genutzt |
volatile uint8_t UseBT; // BT wird genutzt |
volatile uint8_t WiIsSet; // Wi232 ist initialisiert |
volatile uint8_t BTIsSet; // BT ist initialisiert |
char bt_pin[bt_pin_length + 1]; // BT Pinnummer |
char bt_name[bt_name_length + 1]; // BT Name |
volatile uint32_t LastLongitude; // Letzte Position |
volatile uint32_t LastLatitude; |
volatile uint8_t PKT_IdleBeep; |
volatile uint8_t PKT_StartInfo; |
volatile uint16_t Lipo_UOffset; // Offset für die Lipospannugsmessung |
volatile uint8_t PKT_Accutyp; // verwendeter Akkutyp |
volatile WayPoints PKTWayPoint; // Waypointdaten für einen Waypoint |
volatile WPListDirectory PKTWayPointDirectory; // Inhaltsverzeichnis der Listen |
//-------------------------------------------------------------- |
// |
void WriteWiInitFlag(void) |
{ |
WiIsSet = true; |
eeprom_write_byte(&EE_WiIsSet, WiIsSet); |
} |
//-------------------------------------------------------------- |
// |
void WriteBTInitFlag(void) |
{ |
BTIsSet = true; |
eeprom_write_byte(&EE_BTIsSet, BTIsSet); |
} |
//-------------------------------------------------------------- |
// |
void ReadLastPosition(void) |
{ |
LastLongitude = eeprom_read_dword(&EE_LastLongitude); |
LastLatitude = eeprom_read_dword(&EE_LastLatitude); |
} |
//-------------------------------------------------------------- |
// |
void WriteLastPosition(uint32_t ELongitude,uint32_t ELatitude) |
{ |
eeprom_write_dword(&EE_LastLongitude,ELongitude); |
eeprom_write_dword(&EE_LastLatitude,ELatitude); |
} |
//-------------------------------------------------------------- |
// |
void ReadParameter (void) |
{ |
if (eeprom_read_byte(&EE_PKTVersion) == EEpromVersion) |
{ |
MK_LowBat = eeprom_read_byte (&EE_LowBat); |
DisplayTimeout = eeprom_read_byte (&EE_DisplayTimeout); |
DisplayLanguage = eeprom_read_byte (&EE_DisplayLanguage); |
WiTXRXChannel = eeprom_read_byte (&EE_WiTXRXChannel); |
WiNetworkGroup = eeprom_read_byte (&EE_WiNetworkGroup); |
WiNetworkMode = eeprom_read_byte (&EE_WiNetworkMode); |
WiTXTO = eeprom_read_byte (&EE_WiTXTO); |
WiUartMTU = eeprom_read_byte (&EE_WiUartMTU); |
LCD_ORIENTATION = eeprom_read_byte (&EE_LCD_Orientation); |
LCD_DisplayMode = eeprom_read_byte (&EE_LCD_DisplayMode); |
LCD_Kontrast = eeprom_read_byte (&EE_LCD_Kontrast); |
LCD_Helligkeit = eeprom_read_byte (&EE_LCD_Helligkeit); |
USBBT = eeprom_read_byte (&EE_USBBT); |
U02SV2 = eeprom_read_byte (&EE_U02SV2); |
Debug = eeprom_read_byte (&EE_Debug); |
UseWi = eeprom_read_byte (&EE_UseWi); |
UseBT = eeprom_read_byte (&EE_UseBT); |
WiIsSet = eeprom_read_byte (&EE_WiIsSet); |
BTIsSet = eeprom_read_byte (&EE_BTIsSet); |
PKT_IdleBeep = eeprom_read_byte (&EE_PKT_IdleBeep); |
PKT_StartInfo = eeprom_read_byte (&EE_PKT_StartInfo); |
Lipo_UOffset = eeprom_read_word (&EE_Lipo_UOffset); |
PKT_Accutyp = eeprom_read_byte (&EE_PKT_Accutyp); |
eeprom_read_block ((void*)&bt_pin, (const void*)&EE_BTPin, bt_pin_length); |
eeprom_read_block ((void*)&bt_name, (const void*)&EE_BTName, bt_name_length); |
LastLongitude = eeprom_read_dword (&EE_LastLongitude); |
LastLatitude = eeprom_read_dword (&EE_LastLatitude); |
} |
else |
Delete_EEPROM(); |
} |
//-------------------------------------------------------------- |
void Delete_EEPROM(void) |
{ |
// EEPROM auf Default setzen |
lcd_cls(); |
lcd_printp_at (0, 0, PSTR(" EEPROM Parameter "), 2); |
lcd_printp_at (0, 1, PSTR("werden auf"), 0); |
lcd_printp_at (0, 2, PSTR("Standardwerte gesetzt"), 0); |
MK_LowBat = 137; // 13,7V |
DisplayTimeout = 0; // Display immer an |
DisplayLanguage = 1; // default englisch |
WiTXRXChannel = 1; // Kanal 1 MK Standard |
WiNetworkGroup = 66; // Gruppe 66 MK Standard |
WiNetworkMode = NetMode_Normal; // MK Standard |
WiTXTO = TWaitTime16; // MK Standard |
WiUartMTU = UartMTU64; // MK Standard |
LCD_ORIENTATION = 0; // normale Ansicht |
LCD_DisplayMode = 0; // Normal |
LCD_Kontrast = 20; // Kontrast normal |
LCD_Helligkeit = 100; // Helligkeit in % |
USBBT = 0; // USB Betrieb |
U02SV2 = 0; // SV2 (Kabel) Standard |
Debug = 0; // kein Debug |
UseWi = true; // Wi.232 eingebaut? |
UseBT = true; // BT-222 eingebaut? |
WiIsSet = false; // Flag für die Initialisierung Wi232 |
BTIsSet = false; // Flag für die Initialisierung Bluetooth |
PKT_IdleBeep = 0; // kein Piepsen bei Inaktivität |
PKT_StartInfo = true; // Startnformationen anzeigen |
PKT_Accutyp = true; // True = Lipo, False= LiON |
Lipo_UOffset = 6000; // Offset für PKT-Lipomessung |
LastLongitude = 88199720; |
LastLatitude = 522039630; |
eeprom_write_dword(&EE_LastLongitude,LastLongitude); |
eeprom_write_dword(&EE_LastLatitude,LastLatitude); |
strcpy_P(bt_pin, PSTR("1234")); |
eeprom_write_block ((const void*)&bt_pin, (void*)&EE_BTPin, bt_pin_length); |
strcpy_P(bt_name, PSTR("PKT Cebra ")); // Wenn Name kürzer als "bt_name_length" mit Leerzeichen auffüllen |
eeprom_write_block ((const void*)&bt_name, (void*)&EE_BTName, bt_name_length); |
eeprom_write_byte(&EE_WiIsSet,WiIsSet); |
eeprom_write_byte(&EE_BTIsSet,BTIsSet); |
eeprom_write_byte(&EE_PKTVersion,EEpromVersion); |
WriteParameter(); |
// lcd_printp_at (0, 4, PSTR("Waypoints loeschen"), 0); |
// EEWayPointList_Clear(); |
lcd_printp_at (0, 6, PSTR("!!Check Parameter!! "), 0); |
lcd_printp_at (18, 7, PSTR("OK"), 0); |
BeepTime = 200; |
BeepMuster = 0x0080; |
do{} |
while (!(get_key_short (1 << KEY_ENTER))); |
// _delay_ms(500); |
//#if defined HWVERSION3_9 |
// clr_V_On(); |
//#else |
// |
// wdt_enable( WDTO_250MS ); |
// while (1) |
// {;} |
//#endif |
} |
//-------------------------------------------------------------- |
// |
void WriteParameter (void) |
{ |
eeprom_write_byte (&EE_LowBat, MK_LowBat); |
eeprom_write_byte (&EE_DisplayTimeout, DisplayTimeout); |
eeprom_write_byte (&EE_DisplayLanguage, DisplayLanguage); |
eeprom_write_byte (&EE_WiTXRXChannel, WiTXRXChannel); |
eeprom_write_byte (&EE_WiNetworkGroup, WiNetworkGroup); |
eeprom_write_byte (&EE_WiNetworkMode, WiNetworkMode); |
eeprom_write_byte (&EE_WiTXTO, WiTXTO); |
eeprom_write_byte (&EE_WiUartMTU, WiUartMTU); |
eeprom_write_byte (&EE_LCD_Orientation, LCD_ORIENTATION); |
eeprom_write_byte (&EE_LCD_DisplayMode, LCD_DisplayMode); |
eeprom_write_byte (&EE_LCD_Kontrast, LCD_Kontrast); |
eeprom_write_byte (&EE_LCD_Helligkeit, LCD_Helligkeit); |
eeprom_write_byte (&EE_USBBT, USBBT); |
eeprom_write_byte (&EE_U02SV2, U02SV2); |
eeprom_write_byte (&EE_Debug, Debug); |
eeprom_write_byte (&EE_UseWi, UseWi); |
eeprom_write_byte (&EE_UseBT, UseBT); |
eeprom_write_byte (&EE_WiIsSet, WiIsSet); |
eeprom_write_byte (&EE_BTIsSet, BTIsSet); |
eeprom_write_byte (&EE_PKT_IdleBeep, PKT_IdleBeep); |
eeprom_write_byte (&EE_PKT_StartInfo, PKT_StartInfo); |
eeprom_write_word (&EE_Lipo_UOffset,Lipo_UOffset); |
eeprom_write_byte (&EE_PKT_Accutyp, PKT_Accutyp); |
eeprom_write_block ((const void*)&bt_pin, (void*)&EE_BTPin, bt_pin_length); |
eeprom_write_block ((const void*)&bt_name, (void*)&EE_BTName, bt_name_length); |
} |
//-------------------------------------------------------------- |
// |
void EEWayPointList_Clear(void) // löschen der Waypointliste im EEProm |
{ |
uint8_t i; |
PKTWayPoint.Waypoint.Position.Latitude = 0; |
PKTWayPoint.Waypoint.Position.Longitude = 0; |
PKTWayPoint.Waypoint.Position.Altitude = 0; |
PKTWayPoint.Waypoint.Heading = 361; |
for(i = 0; i < MAX_WPLIST_LEN; i++) |
{ |
PKTWayPointDirectory.WPList.WPDirectory[i] = 0; |
} |
for(i = 0; i < NumberOfWaypoints; i++) |
{ |
lcd_printp (PSTR("."), 0); |
eeprom_write_byte (&EEWayPointList[i].WPIndex, i); |
eeprom_write_byte (&EEWayPointList[i].Waypoint.Position.Status, INVALID); |
eeprom_write_block ((const void*)&PKTWayPoint.Waypoint.Position.Latitude, (void*)&EEWayPointList[i].Waypoint.Position.Latitude, sizeof(EEWayPointList[i].Waypoint.Position.Latitude)); |
eeprom_write_block ((const void*)&PKTWayPoint.Waypoint.Position.Longitude, (void*)&EEWayPointList[i].Waypoint.Position.Longitude, sizeof(EEWayPointList[i].Waypoint.Position.Longitude)); |
eeprom_write_block ((const void*)&PKTWayPoint.Waypoint.Position.Altitude, (void*)&EEWayPointList[i].Waypoint.Position.Altitude, sizeof(EEWayPointList[i].Waypoint.Position.Altitude)); |
eeprom_write_block ((const void*)&PKTWayPoint.Waypoint.Heading, (void*)&EEWayPointList[i].Waypoint.Heading, sizeof(EEWayPointList[i].Waypoint.Heading)); |
eeprom_write_byte (&EEWayPointList[i].Waypoint.ToleranceRadius, 0); // in meters, if the MK is within that range around the target, then the next target is triggered |
eeprom_write_byte (&EEWayPointList[i].Waypoint.HoldTime, 0); // in seconds, if the was once in the tolerance area around a WP, this time defines the delay before the next WP is triggered |
eeprom_write_byte (&EEWayPointList[i].Waypoint.Type, POINT_TYPE_INVALID); |
eeprom_write_byte (&EEWayPointList[i].Waypoint.Event_Flag, 0); // future implementation |
eeprom_write_byte (&EEWayPointList[i].Waypoint.AltitudeRate, 0); // no change of setpoint |
} |
for(i = 0; i < NumberOfWPLists; i++) |
{ |
lcd_printp (PSTR("."), 0); |
eeprom_write_byte (&EEWPDirectory[i].WPList.WPListnumber, i); |
eeprom_write_byte (&EEWPDirectory[i].WPList.WPListAktiv, false); |
eeprom_write_byte (&EEWPDirectory[i].WPList.POI_CAM_NICK_CTR, 0); |
eeprom_write_byte (&EEWPDirectory[i].WPList.UsePOI, 0); |
eeprom_write_block ((const void*)&PKTWayPointDirectory.WPList.WPDirectory, (void*)&EEWPDirectory[i].WPList.WPDirectory, sizeof(EEWPDirectory[i].WPList.WPDirectory)); |
} |
lcd_printp (PSTR("\r\n"), 0); |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/eeprom.h |
---|
0,0 → 1,148 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
#ifndef _EEPROM_H |
#define _EEPROM_H |
#include <stdbool.h> |
#include "mk-data-structs.h" |
#include "connect.h" |
//[General] |
//FileVersion = 2 |
//NumberOfWaypoints = 15 |
//UsePOI = 0 |
//POI_CAM_NICK_CTRL = 0 |
//[POI] |
//Altitude = 1 |
//Latitude = 46.7140763 |
//Longitude = 19.2507334 |
//[Waypoint1] |
//Latitude = 46.7145686 |
//Longitude = 19.2515702 |
//Radius = 10 |
//Altitude = 15 |
//ClimbRate = 0 |
//DelayTime = 4 |
//WP_Event_Channel_Value = 96 |
//Heading = 180 |
#define EEpromVersion 0x58 //Summe aus Soft.vers. ohne erste Ziffer zB 3.5.5 = 55 |
#define NumberOfWaypoints 55 //Anzahl der Waypoints in der EEPromliste |
#define NumberOfWPLists 5 //Anzahl WP Listen im PKT |
#define bt_pin_length 4 |
#define bt_name_length 10 |
#define POINT_TYPE_INVALID 255 |
#define POINT_TYPE_WP 0 |
#define POINT_TYPE_POI 1 |
#define INVALID 0x00 |
#define MAX_WPLIST_LEN 31 |
typedef struct |
{ |
uint8_t WPIndex; // Index in der EEpromliste |
Point_t Waypoint; // Waypoint |
} WayPoints; |
typedef struct |
{ |
uint8_t WPListnumber; // Nummer der WP Liste im PKT |
uint8_t WPListAktiv; // Liste aktiv |
uint8_t WPDirectory[31]; // Enthält die Indexe der Waypoints im EEPROM |
uint8_t UsePOI; |
uint8_t POI_CAM_NICK_CTR; |
} WPListHeader; |
typedef struct |
{ |
WPListHeader WPList; // Waypointliste im PKT |
} WPListDirectory; |
void ReadParameter (void); |
void WriteParameter (void); |
void ReadLastPosition(void); |
void WriteLastPosition(uint32_t ELongitude,uint32_t ELatitude); |
void WriteWiInitFlag(void); |
void WriteBTInitFlag(void); |
void Delete_EEPROM(void); |
void EEWayPointList_Clear(void); // l�schen der Waypointliste im EEProm |
uint8_t MK_LowBat; |
extern volatile uint8_t LCD_ORIENTATION; |
extern volatile uint8_t LCD_DisplayMode; |
extern volatile uint8_t LCD_Kontrast; |
extern volatile uint8_t LCD_Helligkeit; |
extern volatile uint8_t DisplayTimeout; |
extern volatile uint8_t DisplayLanguage; |
extern volatile uint8_t WiTXRXChannel; |
extern volatile uint8_t WiNetworkGroup; |
extern volatile uint8_t WiNetworkMode; |
extern volatile uint8_t WiTXTO; |
extern volatile uint8_t WiUartMTU; |
extern volatile uint8_t USBBT; |
extern volatile uint8_t U02SV2; |
extern volatile uint8_t Debug; |
extern volatile uint8_t UseWi; // Wi232 wird genutzt |
extern volatile uint8_t UseBT; // BT wird genutzt |
extern volatile uint8_t WiIsSet; // Wi232 ist initialisiert |
extern volatile uint8_t BTIsSet; // BT ist initialisiert |
extern char bt_pin[bt_pin_length + 1]; // BT Pinnummer |
extern char bt_name[bt_name_length + 1]; // BT Name |
extern volatile uint32_t LastLongitude; |
extern volatile uint32_t LastLatitude; |
extern volatile uint8_t PKT_IdleBeep; |
extern volatile uint8_t PKT_StartInfo; |
extern volatile uint16_t Lipo_UOffset; // Offset für die Lipospannugsmessung |
extern volatile uint8_t PKT_Accutyp; |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/error.c |
---|
0,0 → 1,206 |
/* |
___ ___ ___ ___ _____ |
/ /\ /__/\ / /\ /__/\ / /::\ |
/ /::\ | |::\ / /::\ \ \:\ / /:/\:\ |
/ /:/\:\ ___ ___ | |:|:\ / /:/\:\ \ \:\ / /:/ \:\ |
/ /:/~/::\ /__/\ / /\ __|__|:|\:\ / /:/ \:\ _____\__\:\ /__/:/ \__\:| |
/__/:/ /:/\:\ \ \:\ / /:/ /__/::::| \:\ /__/:/ \__\:\ /__/::::::::\ \ \:\ / /:/ |
\ \:\/:/__\/ \ \:\ /:/ \ \:\~~\__\/ \ \:\ / /:/ \ \:\~~\~~\/ \ \:\ /:/ |
\ \::/ \ \:\/:/ \ \:\ \ \:\ /:/ \ \:\ ~~~ \ \:\/:/ |
\ \:\ \ \::/ \ \:\ \ \:\/:/ \ \:\ \ \::/ |
\ \:\ \__\/ \ \:\ \ \::/ \ \:\ \__\/ |
\__\/ \__\/ \__\/ \__\/ |
___ ___ ___ ___ ___ ___ |
/ /\ / /\ /__/\ /__/\ / /\ /__/\ |
/ /:/ / /::\ | |::\ | |::\ / /::\ \ \:\ |
/ /:/ / /:/\:\ | |:|:\ | |:|:\ / /:/\:\ \ \:\ |
/ /:/ ___ / /:/ \:\ __|__|:|\:\ __|__|:|\:\ / /:/ \:\ _____\__\:\ |
/__/:/ / /\ /__/:/ \__\:\ /__/::::| \:\ /__/::::| \:\ /__/:/ \__\:\ /__/::::::::\ |
\ \:\ / /:/ \ \:\ / /:/ \ \:\~~\__\/ \ \:\~~\__\/ \ \:\ / /:/ \ \:\~~\~~\/ |
\ \:\ /:/ \ \:\ /:/ \ \:\ \ \:\ \ \:\ /:/ \ \:\ ~~~ |
\ \:\/:/ \ \:\/:/ \ \:\ \ \:\ \ \:\/:/ \ \:\ |
\ \::/ \ \::/ \ \:\ \ \:\ \ \::/ \ \:\ |
\__\/ \__\/ \__\/ \__\/ \__\/ \__\/ |
** |
* Error handling functions |
*/ |
#include <stdbool.h> |
//#include "ftdi.h" |
#include <avr/pgmspace.h> |
#include "error_driver.h" |
//-------------------------------------------------------------- |
inline void _send_msg(const char *msg) |
{ |
for (uint8_t i=0; i<255 && msg[i]!='\0'; i++) |
{ |
error_driver_write_c(msg[i]); |
} |
error_driver_write_c('\n'); |
} |
//-------------------------------------------------------------- |
void send_pgm(const prog_char *msg) |
{ |
uint8_t myByte; |
myByte = pgm_read_byte(msg); |
for(int i = 1; myByte != '\0'; i++) |
{ |
error_driver_write_c(myByte); |
myByte = pgm_read_byte(msg+i); |
} |
} |
#ifdef DEBUG |
//-------------------------------------------------------------- |
void error_init(void) |
{ |
error_driver_Init(); |
} |
//-------------------------------------------------------------- |
void error_putc(const char c) |
{ |
error_driver_write_c(c); |
} |
//-------------------------------------------------------------- |
void assert (bool condition, const char *msg) |
{ |
if (!condition) |
{ |
send_pgm(PSTR("ASS:")); |
_send_msg(msg); |
} |
} |
//-------------------------------------------------------------- |
void info (const char *msg) |
{ |
send_pgm(PSTR("INF:")); |
_send_msg(msg); |
} |
//-------------------------------------------------------------- |
void warn (const char *msg) |
{ |
send_pgm(PSTR("WARN:")); |
_send_msg(msg); |
} |
//-------------------------------------------------------------- |
void debug (const char *msg) |
{ |
send_pgm(PSTR("DBG:")); |
_send_msg(msg); |
} |
//-------------------------------------------------------------- |
void Error (const char *msg) |
{ |
send_pgm(PSTR("ERR:")); |
_send_msg(msg); |
} |
#endif |
#ifdef DEBUG |
//-------------------------------------------------------------- |
void assert_pgm(bool condition, const prog_char *msg) |
{ |
if (condition) { |
send_pgm(PSTR("ASS:")); |
send_pgm(msg); |
error_driver_write_c('\n'); |
} |
} |
//-------------------------------------------------------------- |
void info_pgm(const prog_char *msg) |
{ |
send_pgm(PSTR("INF:")); |
send_pgm(msg); |
error_driver_write_c('\n'); |
} |
//-------------------------------------------------------------- |
void warn_pgm(const prog_char *msg) |
{ |
send_pgm(PSTR("WARN:")); |
send_pgm(msg); |
error_driver_write_c('\n'); |
} |
//-------------------------------------------------------------- |
void error_pgm(const prog_char *msg) |
{ |
send_pgm(PSTR("ERR:")); |
send_pgm(msg); |
error_driver_write_c('\n'); |
} |
//-------------------------------------------------------------- |
void debug_pgm(const prog_char *msg) |
{ |
send_pgm(PSTR("DBG:")); |
send_pgm(msg); |
error_driver_write_c('\n'); |
} |
//-------------------------------------------------------------- |
void print_hex(uint8_t num) |
{ |
if (num<10) |
error_putc(num+48); |
else |
{ |
switch (num) |
{ |
case 10: |
error_putc('A'); break; |
case 11: |
error_putc('B'); break; |
case 12: |
error_putc('C'); break; |
case 13: |
error_putc('D'); break; |
case 14: |
error_putc('E'); break; |
case 15: |
error_putc('F'); break; |
default: |
error_putc('#'); break; |
} |
} |
} |
//-------------------------------------------------------------- |
void byte_to_hex(uint8_t byte) |
{ |
uint8_t b2 = (byte & 0x0F); |
uint8_t b1 = ((byte & 0xF0)>>4); |
print_hex(b1); |
print_hex(b2); |
} |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/error.h |
---|
0,0 → 1,75 |
/* |
___ ___ ___ ___ _____ |
/ /\ /__/\ / /\ /__/\ / /::\ |
/ /::\ | |::\ / /::\ \ \:\ / /:/\:\ |
/ /:/\:\ ___ ___ | |:|:\ / /:/\:\ \ \:\ / /:/ \:\ |
/ /:/~/::\ /__/\ / /\ __|__|:|\:\ / /:/ \:\ _____\__\:\ /__/:/ \__\:| |
/__/:/ /:/\:\ \ \:\ / /:/ /__/::::| \:\ /__/:/ \__\:\ /__/::::::::\ \ \:\ / /:/ |
\ \:\/:/__\/ \ \:\ /:/ \ \:\~~\__\/ \ \:\ / /:/ \ \:\~~\~~\/ \ \:\ /:/ |
\ \::/ \ \:\/:/ \ \:\ \ \:\ /:/ \ \:\ ~~~ \ \:\/:/ |
\ \:\ \ \::/ \ \:\ \ \:\/:/ \ \:\ \ \::/ |
\ \:\ \__\/ \ \:\ \ \::/ \ \:\ \__\/ |
\__\/ \__\/ \__\/ \__\/ |
___ ___ ___ ___ ___ ___ |
/ /\ / /\ /__/\ /__/\ / /\ /__/\ |
/ /:/ / /::\ | |::\ | |::\ / /::\ \ \:\ |
/ /:/ / /:/\:\ | |:|:\ | |:|:\ / /:/\:\ \ \:\ |
/ /:/ ___ / /:/ \:\ __|__|:|\:\ __|__|:|\:\ / /:/ \:\ _____\__\:\ |
/__/:/ / /\ /__/:/ \__\:\ /__/::::| \:\ /__/::::| \:\ /__/:/ \__\:\ /__/::::::::\ |
\ \:\ / /:/ \ \:\ / /:/ \ \:\~~\__\/ \ \:\~~\__\/ \ \:\ / /:/ \ \:\~~\~~\/ |
\ \:\ /:/ \ \:\ /:/ \ \:\ \ \:\ \ \:\ /:/ \ \:\ ~~~ |
\ \:\/:/ \ \:\/:/ \ \:\ \ \:\ \ \:\/:/ \ \:\ |
\ \::/ \ \::/ \ \:\ \ \:\ \ \::/ \ \:\ |
\__\/ \__\/ \__\/ \__\/ \__\/ \__\/ |
* |
* Error handling functions. |
*/ |
#ifndef __ERROR__ |
#define __ERROR__ |
#include <avr/pgmspace.h> |
#include <stdbool.h> |
#include "main.h" |
void error_init(void); |
void error_putc(const char c); |
void assert (bool condition, const char *msg); |
void info (const char *msg); |
void warn(const char *msg); |
void debug(const char *msg); |
void Error(const char *msg); |
void assert_pgm(bool condition, const prog_char *msg); |
void info_pgm (const prog_char *msg); |
void warn_pgm(const prog_char *msg); |
void debug_pgm(const prog_char *msg); |
void error_pgm(const prog_char *msg); |
void byte_to_hex(uint8_t byte); |
#else |
#define error_init() {} |
#define error_putc(c) {} |
#define assert(cond, msg) {} |
#define info(msg) {} |
#define warn(msg) {} |
#define debug(msg) {} |
#define error(msg) {} |
#define assert_pgm(cond, msg) {} |
#define info_pgm(msg) {} |
#define warn_pgm(msg) {} |
#define debug_pgm(msg) {} |
#define error_pgm(msg) {} |
#define byte_to_hex(byte) {} |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/error_driver.c |
---|
0,0 → 1,21 |
#include "cpu.h" |
#include "error_driver.h" |
#include "main.h" |
#ifdef DEBUG |
#include "usart.h" |
#include "uart1.h" |
void error_driver_write_c(uint8_t c) |
{ |
USART_putc(c); |
} |
void error_driver_Init(void) |
{ |
// USART_Init(UART_BAUD_SELECT(USART_BAUD,F_CPU)); |
} |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/error_driver.h |
---|
0,0 → 1,22 |
/* |
* Functions to write error message to FTDI or USART |
*/ |
#ifndef __ERROR_DRIVER__ |
#define __ERROR_DRIVER__ |
#include <avr/io.h> |
#include "main.h" |
#ifdef DEBUG |
extern void error_driver_write_c(uint8_t c); |
extern void error_driver_Init(void); |
#else |
#define error_driver_write_c(c) {} |
#define error_driver_init() {} |
#endif |
#endif //__ERROR_DRIVER__ |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/fifo.c |
---|
0,0 → 1,114 |
/** |
* a simple Fifo |
* @file fifo.c |
* @author Pascal Schnurr |
*/ |
#include "fifo.h" |
//-------------------------------------------------------------- |
void fifo_init (fifo_t * fifo, uint8_t * buffer, uint16_t size) |
{ |
fifo->size = size; |
fifo->buffer = buffer; |
fifo->head = 0; |
fifo->count = 0; |
} |
//-------------------------------------------------------------- |
bool fifo_is_empty (const fifo_t * fifo) |
{ |
return (fifo->count == 0); |
} |
//-------------------------------------------------------------- |
bool fifo_is_full (const fifo_t * fifo) |
{ |
return (fifo->size - fifo->count == 0); |
} |
//-------------------------------------------------------------- |
bool fifo_read (fifo_t * fifo, char *data) |
{ |
if (fifo_is_empty (fifo)) |
return false; |
uint8_t *head = fifo->buffer + fifo->head; |
*data = (char) * head; |
fifo->head = ( (fifo->head + 1) % fifo->size); |
fifo->count--; |
return true; |
} |
//-------------------------------------------------------------- |
bool fifo_write (fifo_t * fifo, const char data) |
{ |
if (fifo_is_full (fifo)) |
return false; |
uint8_t *end = fifo->buffer + ( (fifo->head + fifo->count) % fifo->size); |
*end = (uint8_t) data; |
fifo->count++; |
return true; |
} |
//-------------------------------------------------------------- |
bool fifo_clear (fifo_t * fifo) |
{ |
fifo->count = 0; |
fifo->head = 0; |
return true; |
} |
//-------------------------------------------------------------- |
static bool fifo_cmp_pgm_at (fifo_t * fifo, const prog_char * pgm, const uint16_t index) |
{ |
uint16_t i; |
uint8_t fifo_byte; |
uint8_t pgm_byte; |
for (i = 0; pgm_read_byte (pgm + i) != 0; i++) |
{ |
if (fifo->count <= (i + index)) |
return false; |
pgm_byte = pgm_read_byte (pgm + i); |
fifo_byte = * (fifo->buffer + ( (fifo->head + i + index) % fifo->size)); |
if (fifo_byte != pgm_byte) |
return false; |
} |
// We found the string, lets move the pointer |
fifo->head = ( (fifo->head + i + index) % fifo->size); |
fifo->count -= (i + index); |
return true; |
} |
//-------------------------------------------------------------- |
bool fifo_cmp_pgm (fifo_t * fifo, const prog_char * pgm) |
{ |
return fifo_cmp_pgm_at (fifo, pgm, 0); |
} |
//-------------------------------------------------------------- |
bool fifo_strstr_pgm (fifo_t * fifo, const prog_char * pgm) |
{ |
for (uint16_t i = 0; i < fifo->count; i++) |
{ |
if (fifo_cmp_pgm_at (fifo, pgm, i)) |
return true; |
} |
return false; |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/fifo.h |
---|
0,0 → 1,83 |
/** |
* a simple Fifo |
* @file fifo.h |
* @author Pascal Schnurr |
*/ |
#include <avr/pgmspace.h> |
#include <stdbool.h> |
#ifndef _FIFO_H_ |
#define _FIFO_H_ |
/** |
*fifo data structure all vital fifo information |
*/ |
typedef struct |
{ |
uint16_t count; /**< current number of elements */ |
uint16_t head; /**< position of the head element */ |
uint16_t size; /**< size equals max number of entrys*/ |
uint8_t* buffer; /**< pointer to memory area where the fifo is to be saved */ |
} fifo_t; |
/** \brief initialize of a fifo |
* sets all the information in your given fifo structure |
* @param fifo pointer to an allocated fifo_t structure |
* @param buffer pointer to an a allocated memory space for the fifo of size = sizeof(uint8_t) * size |
* @param size max number of entrys the fifo will hold |
*/ |
void fifo_init (fifo_t *fifo, uint8_t *buffer, uint16_t size); |
/** \brief checks if fifo is empty |
* @param fifo pointer to your initialized fifo_t structure |
* @return true if empty otherwise false |
*/ |
bool fifo_is_empty (const fifo_t *fifo); |
/** \brief checks if fifo is full |
* @param fifo pointer to your initialized fifo_t structure |
* @return true if full otherwise false |
*/ |
bool fifo_is_full (const fifo_t *fifo); |
/** \brief clears the fifo |
* resets your fifo structure to 0 elements |
* @param fifo pointer to your initialized fifo_t structure |
* @return always true (never fails) |
*/ |
bool fifo_clear (fifo_t *fifo); |
/** \brief reads head of fifo |
* reads the first element and removes it |
* @param fifo pointer to your initialized fifo_t structure |
* @return false if fifo is empty false otherwise |
*/ |
bool fifo_read (fifo_t *fifo, char *data); |
/** \brief inserts a char into the fifo |
* adds a char to the end of the fifo |
* @param fifo pointer to your initialized fifo_t structure |
* @param data the char data to be inserted |
* @return false if fifo is full true otherwise |
*/ |
bool fifo_write (fifo_t *fifo, const char data); |
/** \brief compares first elements with prog_char string |
* if pgm equals the first elements of the fifo these elements are removed |
* @param fifo pointer to your initialized fifo_t structure |
* @param pgm a prog_char string for comparison |
* @return true if pgm is equal to the first entrys in the fifo, false otherwise |
*/ |
bool fifo_cmp_pgm (fifo_t* fifo, const prog_char* pgm); |
/** \brief searches a string in the whole fifo |
* starts at the beginning and searches for the pgm string in the fifo, |
* if they are found previous entrys and the string are removed from the fifo |
* @param fifo pointer to your initialized fifo_t structure |
* @param pgm a prog_char with the search string |
* @return true if found, false otherwise |
*/ |
bool fifo_strstr_pgm (fifo_t *fifo, const prog_char *pgm); |
#endif /* _FIFO_H_ */ |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/font8x6.c |
---|
0,0 → 1,171 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* - font provided by Claas Anders "CaScAdE" Rathje * |
* - umlauts and special characters by Peter "woggle" Mack * |
* * |
* 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. * |
* * |
*****************************************************************************/ |
#include <avr/pgmspace.h> |
// one byte is a column |
// bit 7 is the bottom |
// |
// 123456 |
// L 1 | XXX | |
// O 2 |X X | |
// W 4 |X X | |
// 8 | XXX | |
// H 1 |X X | |
// I 2 |X X | |
// G 4 | XXX | |
// H 8 | | |
// |
// 0x36,0x49,0x49,0x49,0x36,0x00 |
// |
prog_uint8_t font8x6[128][6] = |
{ |
{ 0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 0 00 (not useable) |
{ 0x78,0x15,0x14,0x15,0x78,0x00 }, // ASCII - 1 01 'Ä' |
{ 0x20,0x55,0x54,0x55,0x78,0x00 }, // ASCII - 2 02 'ä' |
{ 0x38,0x45,0x44,0x45,0x38,0x00 }, // ASCII - 3 03 'Ö' |
{ 0x30,0x49,0x48,0x49,0x30,0x00 }, // ASCII - 4 04 'ö' |
{ 0x3c,0x41,0x40,0x41,0x3c,0x00 }, // ASCII - 5 05 'Ü' |
{ 0x38,0x41,0x40,0x21,0x78,0x00 }, // ASCII - 6 06 'ü' |
{ 0x7e,0x15,0x15,0x15,0x0a,0x00 }, // ASCII - 7 07 'ß' |
{ 0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 8 08 |
{ 0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 9 09 |
{ 0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 10 0A (not useable) |
{ 0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 11 0B |
{ 0x10,0x38,0x54,0x10,0x10,0x1e }, // ASCII - 12 0C Enter Symbol |
{ 0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 13 0D (not useable) |
{ 0x10,0x10,0x10,0x10,0x10,0x10 }, // ASCII - 14 0E hor. line |
{ 0x10,0x10,0x10,0x7c,0x10,0x10 }, // ASCII - 15 0F hor. line with tick mark |
{ 0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 16 10 |
{ 0x08,0x14,0x00,0x00,0x14,0x08 }, // ASCII - 17 11 <> Change |
{ 0x10,0x08,0x04,0x04,0x08,0x10 }, // ASCII - 18 12 /\ Up |
{ 0x08,0x10,0x20,0x20,0x10,0x08 }, // ASCII - 19 13 \/ Down |
{ 0x00,0x08,0x14,0x22,0x41,0x00 }, // ASCII - 20 14 < Left |
{ 0x00,0x41,0x22,0x14,0x08,0x00 }, // ASCII - 21 15 > Right |
{ 0x04,0x02,0x7f,0x02,0x04,0x00 }, // ASCII - 22 16 /|\ Arrow up |
{ 0x10,0x20,0x7f,0x20,0x10,0x00 }, // ASCII - 23 17 \|/ Arrow down |
{ 0x10,0x38,0x54,0x10,0x10,0x10 }, // ASCII - 24 18 <- Arrow left |
{ 0x10,0x10,0x10,0x54,0x38,0x10 }, // ASCII - 25 19 -> Arrow right |
{ 0x10,0x18,0x1c,0x1c,0x18,0x10 }, // ASCII - 26 1A ^ Triangle up |
{ 0x08,0x18,0x38,0x38,0x18,0x08 }, // ASCII - 27 1B v Triangle down |
{ 0x00,0x08,0x1c,0x3e,0x7f,0x00 }, // ASCII - 28 1C < Triangle left |
{ 0x00,0x7f,0x3e,0x1c,0x08,0x00 }, // ASCII - 29 1D > Triangle right |
{ 0x06,0x09,0x09,0x09,0x06,0x00 }, // ASCII - 30 1E '°' |
{ 0x06,0x49,0x7d,0x49,0x06,0x00 }, // ASCII - 31 1F Antenne |
{ 0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 32 20 ' ' |
{ 0x00,0x00,0x2f,0x00,0x00,0x00 }, // ASCII - 33 21 '!' |
{ 0x00,0x07,0x00,0x07,0x00,0x00 }, // ASCII - 34 22 '"' |
{ 0x14,0x7f,0x14,0x7f,0x14,0x00 }, // ASCII - 35 23 '#' |
{ 0x24,0x2a,0x6b,0x2a,0x12,0x00 }, // ASCII - 36 24 '$' |
{ 0x23,0x13,0x08,0x64,0x62,0x00 }, // ASCII - 37 25 '%' |
{ 0x36,0x49,0x55,0x22,0x50,0x00 }, // ASCII - 38 26 '&' |
{ 0x00,0x05,0x03,0x00,0x00,0x00 }, // ASCII - 39 27 ''' |
{ 0x00,0x1c,0x22,0x41,0x00,0x00 }, // ASCII - 40 28 '(' |
{ 0x00,0x41,0x22,0x1c,0x00,0x00 }, // ASCII - 41 29 ')' |
{ 0x14,0x08,0x3e,0x08,0x14,0x00 }, // ASCII - 42 2a '*' |
{ 0x08,0x08,0x3e,0x08,0x08,0x00 }, // ASCII - 43 2b '+' |
{ 0x00,0x50,0x30,0x00,0x00,0x00 }, // ASCII - 44 2c ',' |
{ 0x08,0x08,0x08,0x08,0x08,0x00 }, // ASCII - 45 2d '-' |
{ 0x00,0x60,0x60,0x00,0x00,0x00 }, // ASCII - 46 2e '.' |
{ 0x20,0x10,0x08,0x04,0x02,0x00 }, // ASCII - 47 2f '/' |
{ 0x3e,0x51,0x49,0x45,0x3e,0x00 }, // ASCII - 48 30 '0' |
{ 0x00,0x42,0x7f,0x40,0x00,0x00 }, // ASCII - 49 31 '1' |
{ 0x42,0x61,0x51,0x49,0x46,0x00 }, // ASCII - 50 32 '2' |
{ 0x21,0x41,0x45,0x4b,0x31,0x00 }, // ASCII - 51 33 '3' |
{ 0x18,0x14,0x12,0x7f,0x10,0x00 }, // ASCII - 52 34 '4' |
{ 0x27,0x45,0x45,0x45,0x39,0x00 }, // ASCII - 53 35 '5' |
{ 0x3c,0x4a,0x49,0x49,0x30,0x00 }, // ASCII - 54 36 '6' |
{ 0x03,0x01,0x71,0x09,0x07,0x00 }, // ASCII - 55 37 '7' |
{ 0x36,0x49,0x49,0x49,0x36,0x00 }, // ASCII - 56 38 '8' |
{ 0x06,0x49,0x49,0x29,0x1e,0x00 }, // ASCII - 57 39 '9' |
{ 0x00,0x36,0x36,0x00,0x00,0x00 }, // ASCII - 58 3a ':' |
{ 0x00,0x56,0x36,0x00,0x00,0x00 }, // ASCII - 59 3b ';' |
{ 0x08,0x14,0x22,0x41,0x00,0x00 }, // ASCII - 60 3c '<' |
{ 0x14,0x14,0x14,0x14,0x14,0x00 }, // ASCII - 61 3d '=' |
{ 0x00,0x41,0x22,0x14,0x08,0x00 }, // ASCII - 62 3e '>' |
{ 0x02,0x01,0x51,0x09,0x06,0x00 }, // ASCII - 63 3f '?' |
{ 0x32,0x49,0x79,0x41,0x3e,0x00 }, // ASCII - 64 40 '@' |
{ 0x7e,0x11,0x11,0x11,0x7e,0x00 }, // ASCII - 65 41 'A' |
{ 0x7f,0x49,0x49,0x49,0x36,0x00 }, // ASCII - 66 42 'B' |
{ 0x3e,0x41,0x41,0x41,0x22,0x00 }, // ASCII - 67 43 'C' |
{ 0x7f,0x41,0x41,0x22,0x1c,0x00 }, // ASCII - 68 44 'D' |
{ 0x7f,0x49,0x49,0x49,0x41,0x00 }, // ASCII - 69 45 'E' |
{ 0x7f,0x09,0x09,0x09,0x01,0x00 }, // ASCII - 70 46 'F' |
{ 0x3e,0x41,0x49,0x49,0x7a,0x00 }, // ASCII - 71 47 'G' |
{ 0x7f,0x08,0x08,0x08,0x7f,0x00 }, // ASCII - 72 48 'H' |
{ 0x00,0x41,0x7f,0x41,0x00,0x00 }, // ASCII - 73 49 'I' |
{ 0x20,0x40,0x41,0x3f,0x01,0x00 }, // ASCII - 74 4a 'J' |
{ 0x7f,0x08,0x14,0x22,0x41,0x00 }, // ASCII - 75 4b 'K' |
{ 0x7f,0x40,0x40,0x40,0x40,0x00 }, // ASCII - 76 4c 'L' |
{ 0x7f,0x02,0x0c,0x02,0x7f,0x00 }, // ASCII - 77 4d 'M' |
{ 0x7f,0x04,0x08,0x10,0x7f,0x00 }, // ASCII - 78 4e 'N' |
{ 0x3e,0x41,0x41,0x41,0x3e,0x00 }, // ASCII - 79 4f 'O' |
{ 0x7f,0x09,0x09,0x09,0x06,0x00 }, // ASCII - 80 50 'P' |
{ 0x3e,0x41,0x51,0x21,0x5e,0x00 }, // ASCII - 81 51 'Q' |
{ 0x7f,0x09,0x19,0x29,0x46,0x00 }, // ASCII - 82 52 'R' |
{ 0x46,0x49,0x49,0x49,0x31,0x00 }, // ASCII - 83 53 'S' |
{ 0x01,0x01,0x7f,0x01,0x01,0x00 }, // ASCII - 84 54 'T' |
{ 0x3f,0x40,0x40,0x40,0x3f,0x00 }, // ASCII - 85 55 'U' |
{ 0x1f,0x20,0x40,0x20,0x1f,0x00 }, // ASCII - 86 56 'V' |
{ 0x3f,0x40,0x38,0x40,0x3f,0x00 }, // ASCII - 87 57 'W' |
{ 0x63,0x14,0x08,0x14,0x63,0x00 }, // ASCII - 88 58 'X' |
{ 0x07,0x08,0x70,0x08,0x07,0x00 }, // ASCII - 89 59 'Y' |
{ 0x61,0x51,0x49,0x45,0x43,0x00 }, // ASCII - 90 5a 'Z' |
{ 0x7f,0x41,0x41,0x00,0x00,0x00 }, // ASCII - 91 5b '[' |
{ 0x02,0x04,0x08,0x10,0x20,0x00 }, // ASCII - 92 5c '\' |
{ 0x00,0x41,0x41,0x7f,0x00,0x00 }, // ASCII - 93 5d ']' |
{ 0x04,0x02,0x01,0x02,0x04,0x00 }, // ASCII - 94 5e '^' |
{ 0x40,0x40,0x40,0x40,0x40,0x00 }, // ASCII - 95 5f '_' |
{ 0x00,0x01,0x02,0x04,0x00,0x00 }, // ASCII - 96 60 '`' |
{ 0x20,0x54,0x54,0x54,0x78,0x00 }, // ASCII - 97 61 'a' |
{ 0x7f,0x48,0x44,0x44,0x38,0x00 }, // ASCII - 98 62 'b' |
{ 0x38,0x44,0x44,0x44,0x20,0x00 }, // ASCII - 99 63 'c' |
{ 0x38,0x44,0x44,0x48,0x7f,0x00 }, // ASCII - 100 64 'd' |
{ 0x38,0x54,0x54,0x54,0x18,0x00 }, // ASCII - 101 65 'e' |
{ 0x08,0x7e,0x09,0x01,0x02,0x00 }, // ASCII - 102 66 'f' |
{ 0x0c,0x52,0x52,0x52,0x3e,0x00 }, // ASCII - 103 67 'g' |
{ 0x7f,0x08,0x04,0x04,0x78,0x00 }, // ASCII - 104 68 'h' |
{ 0x00,0x44,0x7d,0x40,0x00,0x00 }, // ASCII - 105 69 'i' |
{ 0x20,0x40,0x44,0x3d,0x00,0x00 }, // ASCII - 106 6a 'j' |
{ 0x7f,0x10,0x28,0x44,0x00,0x00 }, // ASCII - 107 6b 'k' |
{ 0x00,0x41,0x7f,0x40,0x00,0x00 }, // ASCII - 108 6c 'l' |
{ 0x7c,0x04,0x18,0x04,0x78,0x00 }, // ASCII - 109 6d 'm' |
{ 0x7c,0x08,0x04,0x04,0x78,0x00 }, // ASCII - 110 6e 'n' |
{ 0x38,0x44,0x44,0x44,0x38,0x00 }, // ASCII - 111 6f 'o' |
{ 0x7c,0x14,0x14,0x14,0x08,0x00 }, // ASCII - 112 70 'p' |
{ 0x08,0x14,0x14,0x18,0x7c,0x00 }, // ASCII - 113 71 'q' |
{ 0x7c,0x08,0x04,0x04,0x08,0x00 }, // ASCII - 114 72 'r' |
{ 0x48,0x54,0x54,0x54,0x20,0x00 }, // ASCII - 115 73 's' |
{ 0x04,0x3f,0x44,0x40,0x20,0x00 }, // ASCII - 116 74 't' |
{ 0x3c,0x40,0x40,0x20,0x7c,0x00 }, // ASCII - 117 75 'u' |
{ 0x1c,0x20,0x40,0x20,0x1c,0x00 }, // ASCII - 118 76 'v' |
{ 0x3c,0x40,0x38,0x40,0x3c,0x00 }, // ASCII - 119 77 'w' |
{ 0x44,0x28,0x10,0x28,0x44,0x00 }, // ASCII - 120 78 'x' |
{ 0x0c,0x50,0x50,0x50,0x3c,0x00 }, // ASCII - 121 79 'y' |
{ 0x44,0x64,0x54,0x4c,0x44,0x00 }, // ASCII - 122 7a 'z' |
{ 0x00,0x08,0x36,0x41,0x00,0x00 }, // ASCII - 123 7b '{' |
{ 0x00,0x00,0x7f,0x00,0x00,0x00 }, // ASCII - 124 7c '|' |
{ 0x00,0x41,0x36,0x08,0x00,0x00 }, // ASCII - 125 7d '}' |
{ 0x08,0x08,0x2a,0x1c,0x08,0x00 }, // ASCII - 126 7e -> |
{ 0x08,0x1c,0x2a,0x08,0x08,0x00 }, // ASCII - 127 7f <- |
}; |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/font8x6.h |
---|
0,0 → 1,29 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* - font provided by Claas Anders "CaScAdE" Rathje * |
* - umlauts and special characters by Peter "woggle" Mack * |
* * |
* 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. * |
* * |
*****************************************************************************/ |
#ifndef _FONT8X6_H |
#define _FONT8X6_H |
#include <avr/pgmspace.h> |
extern prog_uint8_t font8x6[128][6]; |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/gps.c |
---|
0,0 → 1,364 |
/***************************************************************************** |
* 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 <avr/io.h> |
#include <inttypes.h> |
#include <stdlib.h> |
#include <avr/pgmspace.h> |
#include "main.h" |
#include "lcd.h" |
#include "timer.h" |
#include "usart.h" |
#define TIMEOUT 200 // 2 sec |
uint8_t ck_a = 0; |
uint8_t ck_b = 0; |
uint8_t UBX_class = 0; |
uint8_t UBX_id = 0; |
uint8_t UBX_buffer[250]; |
uint8_t UBX_payload_counter = 0; |
void checksum(uint8_t); |
void UBX_process(void); |
uint32_t join_4_bytes(uint8_t*); |
uint8_t display_mode = 0; |
//-------------------------------------------------------------- |
void gps(void) |
{ |
lcd_cls(); |
display_mode = 2; |
if (hardware == FC) |
{ |
lcd_printp_at(0, 3, PSTR("Nur mit NC !"), 0); |
timer = 100; |
while (timer > 0); |
return; |
} |
if(current_hardware != NC) |
SwitchToNC(); |
SwitchToGPS(); |
uint8_t mode = 0; |
// SendOutData ('d', ADDRESS_ANY, 1, &tmp_dat, 1); |
timer = TIMEOUT; |
uint8_t data = 0; |
uint8_t length = 0; |
uint8_t UBX_ck_a = 0; |
do |
{ |
// if (rxFlag == 1) |
if (uart_getc_nb(&data)) |
{ |
//rxFlag = 0; |
//data = rx_byte; |
timer = TIMEOUT; |
switch(mode) |
{ |
case 0: // init 1 |
if(data == 0xB5) |
{ |
UBX_payload_counter = 0; |
UBX_id = 0; |
UBX_class = 0; |
ck_a = 0; |
ck_b = 0; |
mode++; |
} |
break; |
case 1: // init 2 |
if(data == 0x62) |
mode++; |
else |
mode = 0; |
break; |
case 2: //class |
if(data != 1) |
mode = 0; |
else |
{ |
checksum(data); |
UBX_class = data; |
mode++; |
} |
break; |
case 3: // id |
if((data != 48)&&(data != 6)&&(data != 18)&&(data != 2)) |
mode = 0; |
else |
{ |
UBX_id = data; |
checksum(data); |
mode++; |
} |
break; |
case 4: // length lo |
if(data > 250) |
mode = 0; |
else |
{ |
checksum(data); |
length = data; |
mode++; |
} |
break; |
case 5: // length hi |
if(data != 0) |
mode = 0; |
else |
{ |
checksum(data); |
mode++; |
} |
break; |
case 6: // length hi |
length--; |
UBX_buffer[UBX_payload_counter] = data; |
checksum(data); |
UBX_payload_counter++; |
if(length==0) |
{ |
mode++; |
}; |
break; |
case 7: // check lo |
mode++; |
UBX_ck_a = data; |
break; |
case 8: // check hi |
mode=0; |
if((UBX_ck_a == ck_a) && (data == ck_b)) |
UBX_process(); |
} |
// write_ndigit_number_u (14, 0, data, 3, 0); |
} |
} |
while (!get_key_press (1 << KEY_ESC) && timer); |
get_key_press(KEY_ALL); |
SwitchToNC(); |
} |
//-------------------------------------------------------------- |
void UBX_process() |
{ |
if ((get_key_press (1 << KEY_MINUS))||(display_mode == 2)) |
{ |
if (display_mode != 1) |
{ |
lcd_cls(); |
lcd_printp_at (0,0, PSTR("Fix Type : "), 0); |
lcd_printp_at (0,1, PSTR("Sat : "), 0); |
lcd_printp_at (0,2, PSTR("Accuracy : "), 0); |
lcd_printp_at (0,3, PSTR("PDOP : "), 0); |
lcd_printp_at (0,4, PSTR("Speed : "), 0); |
lcd_printp_at (0,5, PSTR("Long : "), 0); |
lcd_printp_at (0,6, PSTR("Lat : "), 0); |
lcd_printp_at (0,7, PSTR("Alt : "), 0); |
} |
display_mode = 1; |
} |
if((UBX_class == 1) && (UBX_id == 48)&&(display_mode == 0)) |
{ |
uint8_t channels = UBX_buffer[4]; |
uint8_t i = 0; |
for(i = 0; i < channels; i++) |
{ |
if (i > 15) |
break; |
uint8_t line; |
uint8_t col; |
if (i > 7) |
{ |
line = i-7; |
col = 11; |
} |
else |
col = 0; line = i; |
write_ndigit_number_u (col, line, UBX_buffer[9 + 12*i], 3, 0); |
write_ndigit_number_u (col+4, line, UBX_buffer[12 + 12*i], 2, 0); |
if((UBX_buffer[10 + 12*i] & 3) == 3) |
lcd_printp_at (col+7,line, PSTR("O"), 0); |
else if((UBX_buffer[10 + 12*i] & 1) == 1) |
lcd_printp_at (col+7,line, PSTR("X"), 0); |
else if(UBX_buffer[11 + 12*i] > 4) |
lcd_printp_at (col+7,line, PSTR("x"), 0); |
else if(UBX_buffer[11 + 12*i] > 1) |
lcd_printp_at (col+7,line, PSTR("-"), 0); |
else |
lcd_printp_at (col+7,line, PSTR(" "), 0); |
} |
} |
if(display_mode == 1) |
{ |
if((UBX_class == 1) && (UBX_id == 6)) //SVINFO |
{ |
switch (UBX_buffer[10]) |
{ |
case 4: |
case 3: |
lcd_printp_at (11,0, PSTR("3D"), 0); |
break; |
case 2: |
lcd_printp_at (11,0, PSTR("2D"), 0); |
break; |
default: |
lcd_printp_at (11,0, PSTR("no"), 0); |
} |
if((UBX_buffer[11] & 3) == 3) |
lcd_printp_at (17,0, PSTR("D"), 0); |
else |
lcd_printp_at (17,0, PSTR(" "), 0); |
if((UBX_buffer[11] & 1) == 1) |
lcd_printp_at (14,0, PSTR("ok"), 0); |
else |
lcd_printp_at (14,0, PSTR(" "), 0); |
lcd_write_number_u_at (11, 1, UBX_buffer[47]); |
uint16_t acc = (uint16_t)join_4_bytes(&UBX_buffer[24]); |
write_ndigit_number_u (11, 2, acc, 5, 0); |
lcd_printp_at (17,2, PSTR("cm"), 0); |
uint16_t pdop = UBX_buffer[44]+UBX_buffer[45]*255; |
write_ndigit_number_u (11, 3, pdop/100, 2, 0); |
lcd_printp_at (13,3, PSTR("."), 0); |
write_ndigit_number_u (14, 3, (pdop % 100),2, 1); |
} |
if((UBX_class == 1) && (UBX_id == 18)) //VELNED |
{ |
uint16_t speed = (uint16_t)((join_4_bytes(&UBX_buffer[20])*60*60)/100000); |
write_ndigit_number_u (11, 4, speed, 3, 0); |
lcd_printp_at (15,4, PSTR("km/h"), 0); |
} |
if((UBX_class == 1) && (UBX_id == 2)) //POSLLH |
{ |
uint32_t lon = join_4_bytes(&UBX_buffer[4]); |
write_ndigit_number_u (10, 5, (uint16_t)(lon/10000000), 2, 0); |
lcd_printp_at (12,5, PSTR("."), 0); |
write_ndigit_number_u (13, 5, (uint16_t)((lon/1000) % 10000), 4, 1); |
write_ndigit_number_u (17, 5, (uint16_t)((lon/10) % 100), 2, 1); |
uint32_t lat = join_4_bytes(&UBX_buffer[8]); |
write_ndigit_number_u (10, 6, (uint16_t)(lat/10000000), 2, 0); |
lcd_printp_at (12,6, PSTR("."), 0); |
write_ndigit_number_u (13, 6, (uint16_t)((lat/1000) % 10000), 4, 1); |
write_ndigit_number_u (17, 6, (uint16_t)((lat/10) % 100), 2, 1); |
uint16_t height = (uint16_t)(join_4_bytes(&UBX_buffer[16])/1000); |
write_ndigit_number_u (11, 7, height, 4, 0); |
lcd_printp_at (16,7, PSTR("m"), 0); |
} |
} |
} |
//-------------------------------------------------------------- |
union long_union |
{ |
uint32_t dword; |
uint8_t byte[4]; |
} longUnion; |
//-------------------------------------------------------------- |
union int_union |
{ |
uint16_t dword; |
uint8_t byte[2]; |
} intUnion; |
//-------------------------------------------------------------- |
uint32_t join_4_bytes(uint8_t Buffer[]) |
{ |
longUnion.byte[0] = *Buffer; |
longUnion.byte[1] = *(Buffer+1); |
longUnion.byte[2] = *(Buffer+2); |
longUnion.byte[3] = *(Buffer+3); |
return (longUnion.dword); |
} |
//-------------------------------------------------------------- |
void checksum(uint8_t data) |
{ |
ck_a += data; |
ck_b += ck_a; |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/gps.h |
---|
0,0 → 1,40 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
#ifndef _GPS_H |
#define _GPS_H |
void gps (void); |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/joop_parameter_names.h |
---|
0,0 → 1,264 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
#define PAGES 14 |
#define PARAM_COUNT 144 |
#define PARAM_LENGTH 15 |
#define PARAM_NUM_LANG 4 |
// German Englisch Französisch Holländisch |
prog_char param_pages[PAGES][PARAM_NUM_LANG][PARAM_LENGTH]= // zeilen,zeichen+1 |
{ |
{"Kanäle ","Channel ","Canaux ","Kanaal "}, |
{"Konfiguration ","main ","Config ","Configuratie "}, |
{"Stick ","stick ","Manche ","Stick "}, |
{"Looping ","Looping ","Looping ","Looping "}, |
{"Höhe ","Altitude ","Altitude ","Hoogte "}, |
{"Kamera ","Camera ","Camera ","Camera "}, |
{"NaviCtrl ","NaviCtrl ","NaviCtrl ","NaviCtrl "}, |
{"Ausgänge ","Outputs ","Sorties ","Uitgangen "}, |
{"Verschiedenes ","Divers ","Divers ","Diversen "}, |
{"Gyro ","Gyro ","Gyro ","Gyro "}, |
{"Benutzer ","User ","Parametres ","Gebruiker "}, |
{"Achskopplung ","Coupl Axes ","Coupl Axes ","Koppeling Ass."}, |
{"Mixer-Setup ","Config Mix ","Config Mix ","Config. Mixer "}, |
{"Easy Setup ","Config Easy","Config Easy","Config. easy "}, |
}; |
//Namen |
prog_char param_names[PARAM_COUNT][PARAM_NUM_LANG][PARAM_LENGTH]= |
{ |
// group 0 (kanaele) 1-15 |
{"Gas ","Throttle ","Gaz ","Gas "}, |
{"Gier ","Gier ","Lacet ","Gier "}, |
{"Nick ","Nick ","Tangage ","Nick "}, |
{"Roll ","Roll ","Roulis ","Roll "}, |
{"Poti 1 ","Poti 1 ","Poti 1 ","Poti 1 "}, |
{"Poti 2 ","Poti 2 ","Poti 2 ","Poti 2 "}, |
{"Poti 3 ","Poti 3 ","Poti 3 ","Poti 3 "}, |
{"Poti 4 ","Poti 4 ","Poti 4 ","Poti 4 "}, |
{"Poti 5 ","Poti 5 ","Poti 5 ","Poti 5 "}, |
{"Poti 6 ","Poti 6 ","Poti 6 ","Poti 6 "}, |
{"Poti 7 ","Poti 7 ","Poti 7 ","Poti 7 "}, |
{"Poti 8 ","Poti 8 ","Poti 8 ","Poti 8 "}, |
{"Motor Sich.Sch","Mot.Safety Sw.","Mot.Safety Sw.","Mot.saf.schak."}, |
{"Erw. Sig. Pr. ","Enh. Sig.Check","Recep Renforce","Uitg.Sig.Check"}, |
{"Empfänger Typ ","Receiver Type ","Type Recepteur","Ontvang. Type "}, |
// group 1 (main) 16-23 |
{"Höhenregeler ","Ctrl Altitude ","Ctrl Altitude ","Ctrl Hoogte "}, |
{"GPS ","GPS ","GPS ","GPS "}, |
{"Kompass ","Compass ","Compas ","Kompas "}, |
{"KompFest Ausr.","CompOrient.Fix","Maintien Cap ","Kompas vast "}, |
{"Erw. Sig. Pr. ","Sens.RcvSigVal","Ctrl Ren Recep","ExtRec Signaal"}, |
{"Achs(e.)koppl.","Axis Couping ","Decouplage Axe","As koppeling }, |
{"Drehratenbegr.","RotRate limit.","Limit Vit. Rot","RotRate limit."}, |
{"Heading Hold ","Nick/Roll ","Orient. Fixe ","Koers vast "}, |
// group 2 (stick) 24-27 |
{"Nick/Roll P ","Nick/Roll P ","Roul/Tang P ","Nick/Roll P "}, |
{"Nick/Roll D ","Nick/Roll D ","Roul/Tang D ","Nick/Roll D "}, |
{"Gier P ","Gier P ","Lacet P ","Gier P "}, |
{"Externe Kontr.","Extern Ctrl ","Ctrl Externe ","Extern Control"}, |
// group3 : (looping) 28-36 |
{"Looping oben ","Looping up ","Looping Avant ","Looping omhoog"}, |
{"Looping unten ","Looping down ","Looping Arrier","Looping bened."}, |
{"Looping links ","Looping left ","Looping Gauche","Looping links "}, |
{"Looping rechts","Looping right ","Looping Droite","Looping rechts"}, |
{"Gas Limit ","Throttle Limit","Limite Gaz ","Gas Limiet "}, |
{"Ansprechschw. ","Seuil Reponse ","Seuil Reponse ","Drempelwaarde "}, |
{"Hysterese ","Hysteresis ","Hysteresis ","Hysterese "}, |
{"Umkehrp. Nick ","Nick Invers ","Invers Roulis ","Nick geinvert."}, |
{"Umkehrp. Roll ","Roll Invers ","Invers Tangage","Roll geinvert."}, |
// group 4 (hoehe) 37-50 |
{"Höhenregelung ","Altitude Ctrl ","Ctrl Altitude ","Hoogte Control"}, |
{"J:HBeg,N:Vario","Y:LimH,N:Vario","Y:LimH,N:Vario","Y:LimH,N:Vario"}, |
{"Schalter f. H.","Switch f. High","Swith Hauteur ","Schak. Hoogte "}, |
{"akust. Vario ","acoustic Vario","Vario Acoustic","Akoest. Vario "}, |
{"Sollhöhe ","Setpoint ","Hauteur Max ","Gewenste hoogt"}, |
{"Min. Gas ","min. throttle ","Gaz Min ","Minimaal gas "}, |
{"Höhe P ","Altitude P ","Altitude P ","Hoogte P "}, |
{"Luftdruck D ","Barometric D ","Pression D ","Barometr. D "}, |
{"Z-ACC ","ACC Z ","ACC Z ","ACC Z "}, |
{"Max. Höhe ","Max. High ","Max. High ","Max. hoogte "}, |
{"Verstärkung/R ","gain/rate ","Gain/Frequence","Verst./rate "}, |
{"Schwebegas +/-","hoover varia. ","Var Vol Stat ","hoover varia. "}, |
{"GPS Z ","GPS Z ","GPS Z ","GPS Z "}, |
{"Stick Neutr. P","stick neutr. P","Pos Neutre Man","stick neutr. P"}, |
// group 5 : (kamera) 51-66 |
{"Nick S. Anst. ","nick serv ctrl","Asserv Tangage","nick serv ctrl"}, |
{"Nick Kompens. ","nick compens. ","Comp Tangage ","nick compens. "}, |
{"Nick Umkehren ","nick inv. dir.","Inverser Roul ","nick inv.rich."}, |
{"Nick Servo min","nick servo min","Servo Min ","nick servo min"}, |
{"Nick Servo max","nick servo max","Servo Max ","nick servo max"}, |
{"Roll S. Anst. ","roll serv ctrl","Asserv Roulis ","roll serv ctrl"}, |
{"Roll Kompens. ","roll compens. ","Comp Tangage ","roll compens. "}, |
{"Roll Umkehren ","roll inv. dir.","Inverser Tang ","roll omkeren "}, |
{"Roll Servo min","roll servo min","Servo Min ","roll servo min"}, |
{"Roll Servo max","roll servo max","Servo Max ","roll servo max"}, |
{"Anst. Geschw. ","servo refresh ","Taux Refresh ","Servo refresh "}, |
{"Manuelle Gesch","manuell Speed ","Vitesse Man. ","Snelh.handbed."}, |
{"Cam Richtung ","Cam Orient ","Cam Orient ","Camera richt. "}, |
{"Servo 3 ","Servo 3 ","Servo 3 ","Servo 3 "}, |
{"Servo 4 ","Servo 4 ","Servo 4 ","Servo 4 "}, |
{"Servo 5 ","Servo 5 ","Servo 5 ","Servo 5 "}, |
// group 6 : (navictrl) 67-85 |
{"GPS ","enable GPS ","Activer GPS ","enable GPS "}, |
{"GPS Modus St. ","GPS mode contr","Def Mode GPS ","GPS mode contr"}, |
{"GPS Verstärk. ","GPS Gain ","Gain GPS ","GPS versterk. "}, |
{"GPS St. Schw. ","GPS stick thre","Seuil Manche ","GPS st. dremp."}, |
{"Min. Sat. ","Min. Sat. ","Nbre Min. Sat.","Min. Sat. "}, |
{"GPS-P ","GPS-P ","GPS-P ","GPS-P "}, |
{"GPS-I ","GPS-I ","GPS-I ","GPS-I "}, |
{"GPS-D ","GPS-D ","GPS-D ","GPS-D "}, |
{"P Limit ","Limit P ","Limite P ","Limiet P "}, |
{"I Limit ","Limit I ","Limite I ","Limiet I "}, |
{"D Limit ","Limit D ","Limite D ","Limiet D "}, |
{"GPS Acc ","GPS Acc ","Accel GPS ","GPS Acc "}, |
{"GPS Windkorr. ","GPS Wind Corr.","Correct Vent ","GPS Wind Corr."}, |
{"Bremswirkung ","Speed compens.","Compens Vit ","Remwerking "}, |
{"GPS max. Rad. ","GPS max.radius","Rayon GPS Max ","GPS max.radius"}, |
{"GPS Winkel Li.","GPS angl.limit","Limit Angl GPS","GPS hoek lim. "}, |
{"PH Login time ","PH login time ","Tps Memoris ","PH login tijd "}, |
{"Dynamic PH ","Dynamic PH ","Dynamic PH ","Dynamische PH "}, |
{"CH Höhe ","CH High ","CH High ","CH Hoogte "}, |
// group 7 : (ausgaenge) 86-95 |
{"LED1 Bitmaske ","Out1 Bitmask ","Bitmask S1 ","Uitg1 Bitpatr."}, |
{" Timing ","Out1 Timing ","Horloge S1 ","Uitg1 Timing "}, |
{" sofort an","Activ ","Actif ","Direct aan "}, |
{" n.m.Motor","Act. wi. Motor","Actif Au Repos","Akt. motor uit"}, |
{"LED2 Bitmaske ","Out2 Bitmask ","Bitmask S2 ","Uitg2 Bitpatr."}, |
{" Timing ","Out2 Timing ","Horloge S2 ","Uitg2 Timing "}, |
{" sofort an","Activ ","Actif ","Direct aan "}, |
{" n.m.Motor","Act. wi. Motor","Actif Au Repos","Akt. motor uit"}, |
{"LED1 Vmin.Warn","Out1 undervolt","Al Undervoltag","Uitg1 ondersp."}, |
{"LED2 Vmin.Warn","Out2 undervolt","Al Undervoltag","Uitg2 ondersp."}, |
// group 8 : (verschiedenes) 96-107 |
{"Min. Gas ","min. throttle ","Gaz Min. ","minimaal gas "}, |
{"Max. Gas ","max. throttle ","Gaz Max. ","maximaal gas "}, |
{"Kompasswirkung","compass effect","Effet compas ","Kompas effect "}, |
{"Carefree St. ","Carefree Ctrl ","Carefree Ctrl ","Carefree Ctrl "}, |
{"Teachable Care","Teachable Care","Teachable Care","Teachable Care"}, |
{"Unterspannung ","undervoltage ","Sous Tension ","Onderspanning "}, |
{"Volt Referenz ","Volt Referenz ","Tension Ref ","Ref. spanning "}, |
{"Not Gas Zeit ","Emerg.Thr.Time","Duree secours ","Nood gas tijd "}, |
{"Not Gas ","Emerg.Throttle","Gaz de secours","Nood gas "}, |
{"Fails. CH Time","Fails. CH Time","Fails. CH Time","Fails. CH Tijd"}, |
{"Compass Error ","Compass Error ","Compass Error ","Kompas Error "}, |
{"k.Summer o Sen","Compass Error ","Son Abs Emett ","Kompas Error "}, |
// group 9 : (gyro) 108-120 |
{"Gyro P ","Gyro P ","Gyro P ","Gyro P "}, |
{"Gyro I ","Gyro I ","Gyro I ","Gyro I "}, |
{"Gyro D ","Gyro D ","Gyro D ","Gyro D "}, |
{"Gier P ","Lacet P ","Lacet P ","Gier P "}, |
{"Gier I ","Lacet I ","Lacet I ","Gier I "}, |
{"Dynamische St.","dynamic stabi.","Stab Dynamique","Dynamis. stab."}, |
{"Drehratenbeg. ","RotRate limit.","Limit Dit Rota","Toerental lim."}, |
{"ACC/Gyro Fak. ","ACC/Gyro Fact ","ACC/Gyro Fact ","ACC/Gyro Fact "}, |
{"ACC/Gyro Komp.","Comp ACC/Gyro ","Comp ACC/Gyro ","Comp ACC/Gyro "}, |
{"Hauptregler I ","Main I ","Regul Princ I ","Hoofdregel. I "}, |
{"Drifkompensat.","drift Compens.","Compens Deriv ","Drift compens."}, |
{"Gyro stab. ","Gyro stability","Gyro Stability","Gyro stabilit."}, |
{"Motor smooth ","Motor smooth ","Motor Smooth ","Motor smooth "}, |
// group 10: (benutzer) 121-128 |
{"Parameter 1 ","Parameter 1 ","Parameter 1 ","Parameter 1 "}, |
{"Parameter 2 ","Parameter 2 ","Parameter 2 ","Parameter 2 "}, |
{"Parameter 3 ","Parameter 3 ","Parameter 3 ","Parameter 3 "}, |
{"Parameter 4 ","Parameter 4 ","Parameter 4 ","Parameter 4 "}, |
{"Parameter 5 ","Parameter 5 ","Parameter 5 ","Parameter 5 "}, |
{"Parameter 6 ","Parameter 6 ","Parameter 6 ","Parameter 6 "}, |
{"Parameter 7 ","Parameter 7 ","Parameter 7 ","Parameter 7 "}, |
{"Parameter 8 ","Parameter 8 ","Parameter 8 ","Parameter 8 "}, |
// group 11: (achskopplung) 129-132 |
{"Achs(e.)koppl.","(De)Coupl Axes","(De)Coupl Axes","As koppeling "}, |
{"Gier pos. Kopp","Retroac lacet ","Retroac Lacet ","Gier pos. kop."}, |
{"Nick/Roll Kopp","Retro roul/tan","Retro Roul/Tan","Nick/Roll kop."}, |
{"Gier Korrektur","Correct lacet ","Correct Lacet ","Gier correctie"}, |
// group 12: (mixer) 133 |
{"Orientierung ","Orientierung ","Orientation "}, |
// group 13 (easy) 134-144 |
{"Höhenregelung ","Altitude Ctrl ","Ctrl Altitude ","Hoogte Contr. "}, |
{"Sollhöhe ","Setpoint ","Hauteur Max ","Gewenst.hoogte"}, |
{"Stick Neutr. P","stick neutr. P","Pos Neutre Man","Stick neutr. P"}, |
{"GPS ","enable GPS ","Activer GPS ","Enable GPS "}, |
{"GPS Modus St. ","GPS mode contr","Def mode GPS ","GPS mode contr"}, |
{"Dynamic PH ","Dynamic PH ","Dynamic PH ","Dynamic PH "}, |
{"CH Höhe ","CH High ","CH High ","CH hoogte "}, |
{"Carefree St. ","Carefree Ctrl ","Carefree Ctrl ","Carefree Ctrl "}, |
{"Teachable Care","Teachable Care","Teachable Care","Teachable Care"}, |
{"Motor Sich.Sch","Mot.Safety Sw.","Mot.Safety Sw.","Mot.saf.schak."}, |
{"Orientierung ","Orientation ","Orientierung ","Orientatie "}, |
}; |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/lcd.c |
---|
0,0 → 1,1370 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* - original LCD control by Thomas "thkais" Kaiser * |
* - special number formating routines taken from C-OSD * |
* from Claas Anders "CaScAdE" Rathje * |
* - some extension, ellipse and circ_line by Peter "woggle" Mack * |
* * |
* 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. * |
* * |
*****************************************************************************/ |
#include "cpu.h" |
#include <avr/io.h> |
#include <avr/pgmspace.h> |
#include <util/delay.h> |
#include <stdlib.h> |
#include <string.h> |
#include <math.h> |
#include "font8x6.h" |
//#include "font8x8.h" |
#include "eeprom.h" |
#include "lcd.h" |
#include "HAL_HW3_9.h" |
#define DISP_W 128 |
#define DISP_H 64 |
#define DISP_BUFFER ((DISP_H * DISP_W) / 8) |
#define LINE_BUFFER (((DISP_H/8) * DISP_W) / 8) |
#define Jeti 0 // Jeti Routinen |
volatile uint8_t display_buffer[DISP_BUFFER]; // Display-Puffer, weil nicht zurückgelesen werden kann |
volatile uint8_t line_buffer[LINE_BUFFER]; // Zeilen-Puffer, weil nicht zurückgelesen werden kann |
volatile uint16_t display_buffer_pointer; // Pointer auf das aktuell übertragene Byte |
volatile uint8_t display_buffer_counter; // Hilfszähler zur Selektierung der Page |
volatile uint8_t display_page_counter; // aktuelle Page-Nummer |
volatile uint8_t display_mode; // Modus für State-Machine |
volatile uint8_t LCD_ORIENTATION; |
// DOG: 128 x 64 with 6x8 Font => 21 x 8 |
// MAX7456: 30 x 16 |
uint8_t lcd_xpos; |
uint8_t lcd_ypos; |
//----------------------------------------------------------- |
void send_byte (uint8_t data) |
{ |
clr_cs (); |
SPDR = data; |
while (!(SPSR & (1<<SPIF))); |
//SPSR = SPSR; |
set_cs (); |
} |
//----------------------------------------------------------- |
// * Writes one command byte |
// * cmd - the command byte |
// |
void lcd_command(uint8_t cmd) |
{ |
// LCD_SELECT(); |
// LCD_CMD(); |
// spi_write(cmd); |
// LCD_UNSELECT(); |
clr_cs (); |
SPDR = cmd; |
while (!(SPSR & (1<<SPIF))); |
//SPSR = SPSR; |
set_cs (); |
} |
//----------------------------------------------------------- |
void lcd_cls (void) |
{ |
uint16_t i, j; |
// memset (display_buffer, 0, 1024); |
for (i = 0; i < DISP_BUFFER; i++) |
display_buffer[i] = 0x00; |
for (i = 0; i < 8; i++) |
{ |
clr_A0 (); |
send_byte (0xB0 + i); //1011xxxx |
send_byte (0x10); //00010000 |
// send_byte(0x04); //00000100 gedreht plus 4 Byte |
// send_byte(0x00); //00000000 |
send_byte (LCD_ORIENTATION); //00000000 |
set_A0 (); |
for (j = 0; j < 128; j++) |
send_byte (0x00); |
} |
lcd_xpos = 0; |
lcd_ypos = 0; |
} |
//----------------------------------------------------------- |
void lcd_cls_line (uint8_t x, uint8_t y, uint8_t w) |
{ |
uint8_t lcd_width; |
uint8_t lcd_zpos; |
uint8_t i; |
uint8_t max = 21; |
lcd_width = w; |
lcd_xpos = x; |
lcd_ypos = y; |
if ((lcd_xpos + lcd_width) > max) |
lcd_width = max - lcd_xpos; |
lcd_zpos = lcd_xpos + lcd_width; |
for (i = lcd_xpos; i < lcd_zpos; i++) |
lcd_putc (i, lcd_ypos, 0x20, 0); |
} |
//----------------------------------------------------------- |
void wait_1ms (void) |
{ |
_delay_ms (1); |
} |
//----------------------------------------------------------- |
void wait_ms (uint16_t time) |
{ |
uint16_t i; |
for (i = 0; i < time; i++) |
wait_1ms (); |
} |
//----------------------------------------------------------- |
void LCD_Init (uint8_t LCD_Mode) // LCD_Mode 0= Default Mode 1= EEPROM-Parameter) |
{ |
lcd_xpos = 0; |
lcd_ypos = 0; |
// DDRB = 0xFF; |
// SPI max. speed |
// the DOGM128 lcd controller can work at 20 MHz |
SPCR = (1 << SPE) | (1 << MSTR) | (1 << CPHA) | (1 << CPOL); |
SPSR = (1 << SPI2X); |
set_cs (); |
clr_reset (); |
wait_ms (10); |
set_reset (); |
clr_cs (); |
clr_A0 (); |
send_byte (0x40); //Display start line = 0 |
if (LCD_Mode == 1) |
{ |
if (LCD_ORIENTATION == 0) |
{ |
send_byte (0xA1); // A1 normal A0 reverse(original) |
send_byte (0xC0); // C0 normal C8 reverse(original) |
} |
else |
{ |
send_byte (0xA0); // A1 normal A0 reverse(original) |
send_byte (0xC8); // C0 normal C8 reverse(original) |
} |
} |
else |
{ |
send_byte (0xA1); // A1 normal A0 reverse(original) |
send_byte (0xC0); // C0 normal C8 reverse(original) |
} |
if (LCD_Mode == 1) |
{ |
if (LCD_DisplayMode == 0) |
send_byte (0xA6); //Display normal, not mirrored |
else |
send_byte (0xA7); //Display reverse, not mirrored |
} |
else |
send_byte (0xA6); |
send_byte (0xA2); //Set bias 1/9 (Duty 1/65) |
send_byte (0x2F); //Booster, regulator and follower on |
send_byte (0xF8); //Set internal booster to 4x |
send_byte (0x00); //Set internal booster to 4x |
send_byte (0x27); //resistor ratio set |
if (LCD_Mode == 1) |
{ |
send_byte (0x81); //Electronic volume register set |
send_byte (LCD_Kontrast); //Electronic volume register set |
} |
else |
{ |
send_byte (0x81); |
send_byte (0x16); |
} |
send_byte (0xAC); //Cursor |
send_byte (0x00); //No Cursor |
send_byte (0xAF); //No indicator |
if (LCD_Mode == 1) |
{ |
// Helligkeit setzen |
OCR2A = LCD_Helligkeit * 2.55; |
} |
else |
{ |
OCR2A = 255; |
} |
lcd_cls (); |
} |
//----------------------------------------------------------- |
void set_adress (uint16_t adress, uint8_t data) |
{ |
uint8_t page; |
uint8_t column; |
page = adress >> 7; |
clr_A0 (); |
send_byte (0xB0 + page); |
column = (adress & 0x7F) + LCD_ORIENTATION; |
send_byte (0x10 + (column >> 4)); |
send_byte (column & 0x0F); |
set_A0 (); |
send_byte (data); |
} |
//----------------------------------------------------------- |
void scroll (void) |
{ |
uint16_t adress; |
for (adress = 0; adress < 896; adress++) |
{ |
display_buffer[adress] = display_buffer[adress + 128]; |
set_adress (adress, display_buffer[adress]); |
} |
for (adress = 896; adress < 1024; adress++) |
{ |
display_buffer[adress] = 0; |
set_adress (adress, 0); |
} |
} |
//----------------------------------------------------------- |
// sicher eine Zeile für die Statusanzeige |
void copy_line (uint8_t y) |
{ |
uint8_t i; |
uint16_t adress; |
adress = y * 128 + 0 * 6; |
adress &= 0x3FF; |
for (i = 0; i < 6*21; i++) |
{ |
line_buffer[i] = display_buffer[adress+i]; |
set_adress (adress + i, display_buffer[adress + i]); |
} |
} |
//----------------------------------------------------------- |
// holt gesicherte Zeile wieder zurück |
void paste_line (uint8_t y) |
{ |
uint8_t i; |
uint16_t adress; |
adress = y * 128 + 0 * 6; |
adress &= 0x3FF; |
for (i = 0; i < 6*21; i++) |
{ |
display_buffer[adress+i] =line_buffer[i]; |
set_adress (adress + i, display_buffer[adress + i]); |
} |
} |
//----------------------------------------------------------- |
void lcd_puts_at(uint8_t x, uint8_t y,const char *s, uint8_t mode ) |
{ |
while (*s) |
{ |
lcd_putc(x, y, *s++, mode); |
x++; |
} |
}/* lcd_puts */ |
//----------------------------------------------------------- |
void lcd_putc (uint8_t x, uint8_t y, uint8_t c, uint8_t mode) |
{ |
uint8_t ch; |
uint8_t i; |
uint16_t adress; |
if (mode == 2) |
lcd_frect ((x*6),(y*8),5,7,1); // invertierte Darstellung |
switch (c) |
{ // ISO 8859-1 |
case 0xc4: // Ä |
c = 0x01; |
break; |
case 0xe4: // ä |
c = 0x02; |
break; |
case 0xd6: // Ö |
c = 0x03; |
break; |
case 0xf6: // ö |
c = 0x04; |
break; |
case 0xdc: // Ü |
c = 0x05; |
break; |
case 0xfc: // ü |
c = 0x06; |
break; |
case 0xdf: // ß |
//c = 0x07; |
c = 0x1e; // ° (used by Jeti) |
break; |
} |
c &= 0x7f; |
adress = y * 128 + x * 6; |
adress &= 0x3FF; |
for (i = 0; i < 6; i++) |
{ |
ch = pgm_read_byte (&font8x6[0][0] + i + c * 6); |
switch (mode) |
{ |
case 0: |
display_buffer[adress+i] = ch; |
break; |
case 1: |
display_buffer[adress+i] |= ch; |
break; |
case 2: |
display_buffer[adress+i] ^= ch; |
break; |
case 3: |
display_buffer[adress+i] &= ch; |
break; |
case 4: |
display_buffer[adress+i] &= ~ch; |
break; |
} |
set_adress (adress + i, display_buffer[adress + i]); |
} |
} |
#if Jeti |
//----------------------------------------------------------- |
void lcd_putc_jeti (uint8_t x, uint8_t y, uint8_t c, uint8_t mode) |
{ |
uint8_t ch; |
uint8_t i; |
uint16_t adress; |
switch (c) |
{ |
case 0x7e: |
c = 0x1a; // -> |
break; |
case 0x7f: |
c = 0x1b; // <- |
break; |
case 0xdf: |
c = 0xf8; // ° |
break; |
} |
adress = y * 128 + x * 8; |
adress &= 0x3FF; |
for (i = 0; i < 8; i++) |
{ |
ch = pgm_read_byte (&font8x8[0][0] + i + c * 8); |
switch (mode) |
{ |
case 0: |
display_buffer[adress+i] = ch; |
break; |
case 1: |
display_buffer[adress+i] |= ch; |
break; |
case 2: |
display_buffer[adress+i] ^= ch; |
break; |
case 3: |
display_buffer[adress+i] &= ch; |
break; |
case 4: |
display_buffer[adress+i] &= ~ch; |
break; |
} |
set_adress (adress + i, display_buffer[adress + i]); |
} |
} |
//----------------------------------------------------------- |
void lcd_printpj (const char *text, uint8_t mode) |
{ |
while (pgm_read_byte(text)) |
{ |
switch (pgm_read_byte(text)) |
{ |
case 0x0D: |
lcd_xpos = 0; |
break; |
case 0x0A: |
new_line(); |
break; |
default: |
lcd_putc_jeti (lcd_xpos, lcd_ypos, pgm_read_byte(text), mode); |
lcd_xpos++; |
if (lcd_xpos > 20) |
{ |
lcd_xpos = 0; |
new_line (); |
} |
break; |
} |
text++; |
} |
} |
//----------------------------------------------------------- |
void lcd_printpj_at (uint8_t x, uint8_t y, const char *text, uint8_t mode) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcd_printpj (text, mode); |
} |
#endif |
//----------------------------------------------------------- |
void new_line (void) |
{ |
lcd_ypos++; |
if (lcd_ypos > 7) |
{ |
scroll (); |
lcd_ypos = 7; |
} |
} |
//----------------------------------------------------------- |
void lcd_printpns (const char *text, uint8_t mode) |
{ |
while (pgm_read_byte(text)) |
{ |
switch (pgm_read_byte(text)) |
{ |
case 0x0D: |
lcd_xpos = 0; |
break; |
case 0x0A: |
new_line(); |
break; |
default: |
lcd_putc (lcd_xpos, lcd_ypos, pgm_read_byte(text), mode); |
lcd_xpos++; |
if (lcd_xpos > 21) |
{ |
lcd_xpos = 0; |
// new_line (); |
} |
break; |
} |
text++; |
} |
} |
//----------------------------------------------------------- |
void lcd_printpns_at (uint8_t x, uint8_t y, const char *text, uint8_t mode) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcd_printpns (text, mode); |
} |
//----------------------------------------------------------- |
void lcd_printp (const char *text, uint8_t mode) |
{ |
while (pgm_read_byte(text)) |
{ |
switch (pgm_read_byte(text)) |
{ |
case 0x0D: |
lcd_xpos = 0; |
break; |
case 0x0A: |
new_line(); |
break; |
default: |
lcd_putc (lcd_xpos, lcd_ypos, pgm_read_byte(text), mode); |
lcd_xpos++; |
if (lcd_xpos > 21) |
{ |
lcd_xpos = 0; |
new_line (); |
} |
break; |
} |
text++; |
} |
} |
//----------------------------------------------------------- |
void lcd_printp_at (uint8_t x, uint8_t y, const char *text, uint8_t mode) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcd_printp (text, mode); |
} |
//----------------------------------------------------------- |
void lcd_print (uint8_t *text, uint8_t mode) |
{ |
while (*text) |
{ |
switch (*text) |
{ |
case 0x0D: |
lcd_xpos = 0; |
break; |
case 0x0A: |
new_line(); |
break; |
default: |
lcd_putc (lcd_xpos, lcd_ypos, *text, mode); |
lcd_xpos++; |
if (lcd_xpos > 21) |
{ |
lcd_xpos = 0; |
new_line (); |
} |
break; |
} |
text++; |
} |
} |
//----------------------------------------------------------- |
void lcd_print_at (uint8_t x, uint8_t y, uint8_t *text, uint8_t mode) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcd_print (text, mode); |
} |
//----------------------------------------------------------- |
void print_display (uint8_t *text) |
{ |
while (*text) |
{ |
lcd_putc (lcd_xpos, lcd_ypos, *text, 0); |
lcd_xpos++; |
if (lcd_xpos >= 20) |
{ |
lcd_xpos = 0; |
new_line (); |
} |
text++; |
} |
} |
//----------------------------------------------------------- |
void print_display_at (uint8_t x, uint8_t y, uint8_t *text) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
print_display (text); |
} |
//----------------------------------------------------------- |
// + Plot (set one Pixel) |
//----------------------------------------------------------- |
// mode: |
// 0=Clear, 1=Set, 2=XOR |
void lcd_plot (uint8_t xpos, uint8_t ypos, uint8_t mode) |
{ |
uint16_t adress; |
uint8_t mask; |
if ((xpos < DISP_W) && (ypos < DISP_H)) |
{ |
adress = (ypos / 8) * DISP_W + xpos; // adress = 0/8 * 128 + 0 = 0 |
mask = 1 << (ypos & 0x07); // mask = 1<<0 = 1 |
adress &= DISP_BUFFER - 1; |
switch (mode) |
{ |
case 0: |
display_buffer[adress] &= ~mask; |
break; |
case 1: |
display_buffer[adress] |= mask; |
break; |
case 2: |
display_buffer[adress] ^= mask; |
break; |
} |
set_adress (adress, display_buffer[adress]); |
} |
} |
//----------------------------------------------------------- |
// + Line (draws a line from x1,y1 to x2,y2 |
// + Based on Bresenham line-Algorithm |
// + found in the internet, modified by thkais 2007 |
//----------------------------------------------------------- |
void lcd_line (unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, uint8_t mode) |
{ |
int x, y, count, xs, ys, xm, ym; |
x = (int) x1; |
y = (int) y1; |
xs = (int) x2 - (int) x1; |
ys = (int) y2 - (int) y1; |
if (xs < 0) |
xm = -1; |
else |
if (xs > 0) |
xm = 1; |
else |
xm = 0; |
if (ys < 0) |
ym = -1; |
else |
if (ys > 0) |
ym = 1; |
else |
ym = 0; |
if (xs < 0) |
xs = -xs; |
if (ys < 0) |
ys = -ys; |
lcd_plot ((unsigned char) x, (unsigned char) y, mode); |
if (xs > ys) // Flat Line <45 degrees |
{ |
count = -(xs / 2); |
while (x != x2) |
{ |
count = count + ys; |
x = x + xm; |
if (count > 0) |
{ |
y = y + ym; |
count = count - xs; |
} |
lcd_plot ((unsigned char) x, (unsigned char) y, mode); |
} |
} |
else // Line >=45 degrees |
{ |
count =- (ys / 2); |
while (y != y2) |
{ |
count = count + xs; |
y = y + ym; |
if (count > 0) |
{ |
x = x + xm; |
count = count - ys; |
} |
lcd_plot ((unsigned char) x, (unsigned char) y, mode); |
} |
} |
} |
//----------------------------------------------------------- |
// + Filled rectangle |
// + x1, y1 = upper left corner |
//----------------------------------------------------------- |
void lcd_frect (uint8_t x1, uint8_t y1, uint8_t widthx, uint8_t widthy, uint8_t mode) |
{ |
uint16_t x2, y2; |
uint16_t i; |
if (x1 >= DISP_W) |
x1 = DISP_W - 1; |
if (y1 >= DISP_H) |
y1 = DISP_H - 1; |
x2 = x1 + widthx; |
y2 = y1 + widthy; |
if (x2 > DISP_W) |
x2 = DISP_W; |
if (y2 > DISP_H) |
y2 = DISP_H; |
for (i = y1; i <= y2; i++) |
{ |
lcd_line (x1, i, x2, i, mode); |
} |
} |
//----------------------------------------------------------- |
// + outline of rectangle |
// + x1, y1 = upper left corner |
//----------------------------------------------------------- |
void lcd_rect (uint8_t x1, uint8_t y1, uint8_t widthx, uint8_t widthy, uint8_t mode) |
{ |
uint16_t x2, y2; |
if (x1 >= DISP_W) |
x1 = DISP_W - 1; |
if (y1 >= DISP_H) |
y1 = DISP_H - 1; |
x2 = x1 + widthx; |
y2 = y1 + widthy; |
if (x2 > DISP_W) |
x2 = DISP_W; |
if (y2 > DISP_H) |
y2 = DISP_H; |
lcd_line (x1, y1, x2, y1, mode); |
lcd_line (x2, y1, x2, y2, mode); |
lcd_line (x2, y2, x1, y2, mode); |
lcd_line (x1, y2, x1, y1, mode); |
} |
//----------------------------------------------------------- |
// + outline of a circle |
// + Based on Bresenham-algorithm found in wikipedia |
// + modified by thkais (2007) |
//----------------------------------------------------------- |
void lcd_circle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode) |
{ |
int16_t f = 1 - radius; |
int16_t ddF_x = 0; |
int16_t ddF_y = -2 * radius; |
int16_t x = 0; |
int16_t y = radius; |
lcd_plot (x0, y0 + radius, mode); |
lcd_plot (x0, y0 - radius, mode); |
lcd_plot (x0 + radius, y0, mode); |
lcd_plot (x0 - radius, y0, mode); |
while (x < y) |
{ |
if (f >= 0) |
{ |
y --; |
ddF_y += 2; |
f += ddF_y; |
} |
x ++; |
ddF_x += 2; |
f += ddF_x + 1; |
lcd_plot (x0 + x, y0 + y, mode); |
lcd_plot (x0 - x, y0 + y, mode); |
lcd_plot (x0 + x, y0 - y, mode); |
lcd_plot (x0 - x, y0 - y, mode); |
lcd_plot (x0 + y, y0 + x, mode); |
lcd_plot (x0 - y, y0 + x, mode); |
lcd_plot (x0 + y, y0 - x, mode); |
lcd_plot (x0 - y, y0 - x, mode); |
} |
} |
//----------------------------------------------------------- |
// + filled Circle |
// + modified circle-algorithm thkais (2007) |
//----------------------------------------------------------- |
void lcd_fcircle (int16_t x0, int16_t y0, int16_t radius) |
{ |
int16_t f = 1 - radius; |
int16_t ddF_x = 0; |
int16_t ddF_y = -2 * radius; |
int16_t x = 0; |
int16_t y = radius; |
lcd_line (x0, y0 + radius, x0, y0 - radius, 1); |
lcd_line (x0 + radius, y0, x0 - radius, y0, 1); |
while (x < y) |
{ |
if (f >= 0) |
{ |
y--; |
ddF_y += 2; |
f += ddF_y; |
} |
x++; |
ddF_x += 2; |
f += ddF_x + 1; |
lcd_line (x0 + x, y0 + y, x0 - x, y0 + y, 1); |
lcd_line (x0 + x, y0 - y, x0 - x, y0 - y, 1); |
lcd_line (x0 + y, y0 + x, x0 - y, y0 + x, 1); |
lcd_line (x0 + y, y0 - x, x0 - y, y0 - x, 1); |
} |
} |
//----------------------------------------------------------- |
// |
void lcd_circ_line (uint8_t x, uint8_t y, uint8_t r, uint16_t deg, uint8_t mode) |
{ |
uint8_t xc, yc; |
double deg_rad; |
deg_rad = (deg * M_PI) / 180.0; |
yc = y - (uint8_t) round (cos (deg_rad) * (double) r); |
xc = x + (uint8_t) round (sin (deg_rad) * (double) r); |
lcd_line (x, y, xc, yc, mode); |
} |
//----------------------------------------------------------- |
// |
void lcd_ellipse_line (uint8_t x, uint8_t y, uint8_t rx, uint8_t ry, uint16_t deg, uint8_t mode) |
{ |
uint8_t xc, yc; |
double deg_rad; |
deg_rad = (deg * M_PI) / 180.0; |
yc = y - (uint8_t) round (cos (deg_rad) * (double) ry); |
xc = x + (uint8_t) round (sin (deg_rad) * (double) rx); |
lcd_line (x, y, xc, yc, mode); |
} |
//----------------------------------------------------------- |
// |
void lcd_ellipse (int16_t x0, int16_t y0, int16_t rx, int16_t ry, uint8_t mode) |
{ |
const int16_t rx2 = rx * rx; |
const int16_t ry2 = ry * ry; |
int16_t F = round (ry2 - rx2 * ry + 0.25 * rx2); |
int16_t ddF_x = 0; |
int16_t ddF_y = 2 * rx2 * ry; |
int16_t x = 0; |
int16_t y = ry; |
lcd_plot (x0, y0 + ry, mode); |
lcd_plot (x0, y0 - ry, mode); |
lcd_plot (x0 + rx, y0, mode); |
lcd_plot (x0 - rx, y0, mode); |
// while ( 2*ry2*x < 2*rx2*y ) { we can use ddF_x and ddF_y |
while (ddF_x < ddF_y) |
{ |
if(F >= 0) |
{ |
y -= 1; // south |
ddF_y -= 2 * rx2; |
F -= ddF_y; |
} |
x += 1; // east |
ddF_x += 2 * ry2; |
F += ddF_x + ry2; |
lcd_plot (x0 + x, y0 + y, mode); |
lcd_plot (x0 + x, y0 - y, mode); |
lcd_plot (x0 - x, y0 + y, mode); |
lcd_plot (x0 - x, y0 - y, mode); |
} |
F = round (ry2 * (x + 0.5) * (x + 0.5) + rx2 * (y - 1) * (y - 1) - rx2 * ry2); |
while(y > 0) |
{ |
if(F <= 0) |
{ |
x += 1; // east |
ddF_x += 2 * ry2; |
F += ddF_x; |
} |
y -= 1; // south |
ddF_y -= 2 * rx2; |
F += rx2 - ddF_y; |
lcd_plot (x0 + x, y0 + y, mode); |
lcd_plot (x0 + x, y0 - y, mode); |
lcd_plot (x0 - x, y0 + y, mode); |
lcd_plot (x0 - x, y0 - y, mode); |
} |
} |
//----------------------------------------------------------- |
// |
void lcd_ecircle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode) |
{ |
lcd_ellipse (x0, y0, radius + 3, radius, mode); |
} |
//----------------------------------------------------------- |
// |
void lcd_ecirc_line (uint8_t x, uint8_t y, uint8_t r, uint16_t deg, uint8_t mode) |
{ |
lcd_ellipse_line(x, y, r + 3, r, deg, mode); |
} |
//----------------------------------------------------------- |
// |
void lcd_view_font (uint8_t page) |
{ |
int x; |
int y; |
lcd_cls (); |
lcd_printp (PSTR(" 0123456789ABCDEF\r\n"), 0); |
lcd_printpns_at (0, 7, PSTR(" \x1a \x1b Exit"), 0); |
lcd_ypos = 2; |
for (y = page * 4 ; y < (page * 4 + 4); y++) |
{ |
if (y < 10) |
{ |
lcd_putc (0, lcd_ypos, '0' + y, 0); |
} |
else |
{ |
lcd_putc (0, lcd_ypos, 'A' + y - 10, 0); |
} |
lcd_xpos = 2; |
for (x = 0; x < 16; x++) |
{ |
lcd_putc (lcd_xpos, lcd_ypos, y * 16 + x, 0); |
lcd_xpos++; |
} |
lcd_ypos++; |
} |
} |
//----------------------------------------------------------- |
uint8_t hdigit (uint8_t d) |
{ |
if (d < 10) |
{ |
return '0' + d; |
} |
else |
{ |
return 'A' + d - 10; |
} |
} |
//----------------------------------------------------------- |
void lcd_print_hex_at (uint8_t x, uint8_t y, uint8_t h, uint8_t mode) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcd_putc (lcd_xpos++, lcd_ypos, hdigit (h >> 4), mode); |
lcd_putc (lcd_xpos, lcd_ypos, hdigit (h & 0x0f), mode); |
} |
//----------------------------------------------------------- |
void lcd_print_hex (uint8_t h, uint8_t mode) |
{ |
// lcd_xpos = x; |
// lcd_ypos = y; |
lcd_putc (lcd_xpos++, lcd_ypos, hdigit (h >> 4), mode); |
lcd_putc (lcd_xpos++, lcd_ypos, hdigit (h & 0x0f), mode); |
lcd_putc (lcd_xpos++, lcd_ypos, ' ', mode); |
} |
//----------------------------------------------------------- |
void lcd_write_number_u (uint8_t number) |
{ |
uint8_t num = 100; |
uint8_t started = 0; |
while (num > 0) |
{ |
uint8_t b = number / num; |
if (b > 0 || started || num == 1) |
{ |
lcd_putc (lcd_xpos++, lcd_ypos, '0' + b, 0); |
started = 1; |
} |
number -= b * num; |
num /= 10; |
} |
} |
//----------------------------------------------------------- |
void lcd_write_number_u_at (uint8_t x, uint8_t y, uint8_t number) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcd_write_number_u (number); |
} |
//----------------------------------------------------------- |
// Write only some digits of a unsigned <number> at <x>/<y> to MAX7456 display memory |
// <num> represents the largest multiple of 10 that will still be displayable as |
// the first digit, so num = 10 will be 0-99 and so on |
// <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
// |
void write_ndigit_number_u (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad) |
{ |
char s[7]; |
utoa(number, s, 10 ); |
uint8_t len = strlen(s); |
if (length < len) |
{ |
for (uint8_t i = 0; i < length; i++) |
{ |
lcd_putc (x++, y, '*', 0); |
} |
return; |
} |
for (uint8_t i = 0; i < length - len; i++) |
{ |
if (pad) |
{ |
lcd_putc (x++, y, '0', 0); |
} |
else |
{ |
lcd_putc (x++, y, ' ', 0); |
} |
} |
lcd_print_at(x, y, (uint8_t*)s, 0); |
} |
//----------------------------------------------------------- |
// Write only some digits of a signed <number> at <x>/<y> to MAX7456 display memory |
// <num> represents the largest multiple of 10 that will still be displayable as |
// the first digit, so num = 10 will be 0-99 and so on |
// <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
// |
void write_ndigit_number_s (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad) |
{ |
char s[7]; |
itoa(number, s, 10 ); |
uint8_t len = strlen(s); |
if (length < len) |
{ |
for (uint8_t i = 0; i < length; i++) |
{ |
lcd_putc (x++, y, '*', 0); |
} |
return; |
} |
for (uint8_t i = 0; i < length - len; i++) |
{ |
if (pad) |
{ |
lcd_putc (x++, y, '0', 0); |
} |
else |
{ |
lcd_putc (x++, y, ' ', 0); |
} |
} |
lcd_print_at(x, y, (uint8_t*)s, 0); |
} |
//----------------------------------------------------------- |
// Write only some digits of a unsigned <number> at <x>/<y> to MAX7456 display memory |
// as /10th of the value |
// <num> represents the largest multiple of 10 that will still be displayable as |
// the first digit, so num = 10 will be 0-99 and so on |
// <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
// |
void write_ndigit_number_u_10th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad) |
{ |
char s[7]; |
itoa(number, s, 10 ); |
uint8_t len = strlen(s); |
if (length < len) |
{ |
for (uint8_t i = 0; i < length; i++) |
{ |
lcd_putc (x++, y, '*', 0); |
} |
return; |
} |
for (uint8_t i = 0; i < length - len; i++) |
{ |
if (pad) |
{ |
lcd_putc (x++, y, '0', 0); |
} |
else |
{ |
lcd_putc (x++, y, ' ', 0); |
} |
} |
char rest = s[len - 1]; |
s[len - 1] = 0; |
if (len == 1) |
{ |
lcd_putc (x-1, y, '0', 0); |
} |
else if (len == 2 && s[0] == '-') |
{ |
lcd_putc (x-1, y, '-', 0); |
lcd_putc (x, y, '0', 0); |
} |
else |
{ |
lcd_print_at(x, y, (uint8_t*)s, 0); |
} |
x += len - 1; |
lcd_putc (x++, y, '.', 0); |
lcd_putc (x++, y, rest, 0); |
} |
//----------------------------------------------------------- |
void write_ndigit_number_u_100th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad) |
{ |
uint8_t num = 100; |
while (num > 0) |
{ |
uint8_t b = number / num; |
if ((num / 10) == 1) |
{ |
lcd_putc (x++, y, '.', 0); |
} |
lcd_putc (x++, y, '0' + b, 0); |
number -= b * num; |
num /= 10; |
} |
} |
//----------------------------------------------------------- |
// Write only some digits of a signed <number> at <x>/<y> to MAX7456 display memory |
// as /10th of the value |
// <num> represents the largest multiple of 10 that will still be displayable as |
// the first digit, so num = 10 will be 0-99 and so on |
// <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
// |
void write_ndigit_number_s_10th (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad) |
{ |
char s[7]; |
itoa (number, s, 10 ); |
uint8_t len = strlen(s); |
if (length < len) |
{ |
for (uint8_t i = 0; i < length; i++) |
{ |
lcd_putc (x++, y, '*', 0); |
} |
return; |
} |
for (uint8_t i = 0; i < length - len; i++) |
{ |
if (pad) |
{ |
lcd_putc (x++, y, '0', 0); |
} |
else |
{ |
lcd_putc (x++, y, ' ', 0); |
} |
} |
char rest = s[len - 1]; |
s[len - 1] = 0; |
if (len == 1) |
{ |
lcd_putc (x-1, y, '0', 0); |
} |
else if (len == 2 && s[0] == '-') |
{ |
lcd_putc (x-1, y, '-', 0); |
lcd_putc (x, y, '0', 0); |
} |
else |
{ |
lcd_print_at(x, y, (uint8_t*)s, 0); |
} |
x += len - 1; |
lcd_putc (x++, y, '.', 0); |
lcd_putc (x++, y, rest, 0); |
} |
//----------------------------------------------------------- |
// write <seconds> as human readable time at <x>/<y> to MAX7456 display mem |
// |
void write_time (uint8_t x, uint8_t y, uint16_t seconds) |
{ |
uint16_t min = seconds / 60; |
seconds -= min * 60; |
write_ndigit_number_u (x, y, min, 2, 0); |
lcd_putc (x + 2, y, ':', 0); |
write_ndigit_number_u (x + 3, y, seconds, 2, 1); |
} |
//----------------------------------------------------------- |
// wirte a <position> at <x>/<y> assuming it is a gps position for long-/latitude |
// |
void write_gps_pos (uint8_t x, uint8_t y, int32_t position) |
{ |
if (position < 0) |
{ |
position ^= ~0; |
position++; |
lcd_putc (x++, y, '-', 0); |
} |
else |
{ |
lcd_putc (x++, y, ' ', 0); |
} |
write_ndigit_number_u (x, y, (uint16_t) (position / (int32_t) 10000000), 3, 1); |
lcd_putc (x + 3, y, '.', 0); |
position = position - ((position / (int32_t) 10000000) * (int32_t) 10000000); |
write_ndigit_number_u (x + 4, y, (uint16_t) (position / (int32_t) 1000), 4, 1); |
position = position - ((uint16_t) (position / (int32_t) 1000) * (int32_t) 1000); |
write_ndigit_number_u (x + 8, y, (uint16_t) position, 3, 1); |
lcd_putc (x + 11, y, 0x1e, 0); // degree symbol |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/lcd.h |
---|
0,0 → 1,273 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* - original LCD control by Thomas "thkais" Kaiser * |
* - special number formating routines taken from C-OSD * |
* from Claas Anders "CaScAdE" Rathje * |
* - some extension, ellipse and circ_line by Peter "woggle" Mack * |
* Thanks to Oliver Schwaneberg for adding several functions to this library!* |
* * |
* Author: Jan Michel (jan at mueschelsoft dot de) * |
* License: GNU General Public License, version 3 * |
* Version: v0.93 September 2010 * |
* * |
* 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. * |
* * |
*****************************************************************************/ |
#ifndef _LCD_H |
#define _LCD_H |
/* |
//----------------------------------------------------------------------------- |
// Command Codes |
//----------------------------------------------------------------------------- |
//1: Display on/off |
#define LCD_DISPLAY_ON 0xAF //switch display on |
#define LCD_DISPLAY_OFF 0xAE //switch display off |
//2: display start line set (lower 6 bits select first line on lcd from 64 lines in memory) |
#define LCD_START_LINE 0x40 |
//3: Page address set (lower 4 bits select one of 8 pages) |
#define LCD_PAGE_ADDRESS 0xB0 |
//4: column address (lower 4 bits are upper / lower nibble of column address) |
#define LCD_COL_ADDRESS_MSB 0x10 |
#define LCD_COL_ADDRESS_LSB 0x00 //second part of column address |
//8: select orientation (black side of the display should be further away from viewer) |
#define LCD_BOTTOMVIEW 0xA1 //6 o'clock view |
#define LCD_TOPVIEW 0xA0 //12 o'clock view |
//9: select normal (white background, black pixels) or reverse (black background, white pixels) mode |
#define LCD_DISPLAY_POSITIVE 0xA6 //not inverted mode |
#define LCD_DISPLAY_INVERTED 0xA7 //inverted display |
//10: show memory content or switch all pixels on |
#define LCD_SHOW_NORMAL 0xA4 //show dram content |
#define LCD_SHOW_ALL_POINTS 0xA5 //show all points |
//11: lcd bias set |
#define LCD_BIAS_1_9 0xA2 |
#define LCD_BIAS_1_7 0xA3 |
//14: Reset Controller |
#define LCD_RESET_CMD 0xE2 |
//15: output mode select (turns display upside-down) |
#define LCD_SCAN_DIR_NORMAL 0xC0 //normal scan direction |
#define LCD_SCAN_DIR_REVERSE 0xC8 //reversed scan direction |
//16: power control set (lower 3 bits select operating mode) |
//Bit 0: Voltage follower on/off - Bit 1: Voltage regulator on/off - Bit 2: Booster circuit on/off |
#define LCD_POWER_CONTROL 0x28 //base command |
#define LCD_POWER_LOW_POWER 0x2F |
#define LCD_POWER_WIDE_RANGE 0x2F |
#define LCD_POWER_LOW_VOLTAGE 0x2B |
//17: voltage regulator resistor ratio set (lower 3 bits select ratio) |
//selects lcd voltage - 000 is low (~ -2V), 111 is high (~ - 10V), also depending on volume mode. Datasheet suggests 011 |
#define LCD_VOLTAGE 0x20 |
//18: Volume mode set (2-byte command, lower 6 bits in second word select value, datasheet suggests 0x1F) |
#define LCD_VOLUME_MODE_1 0x81 |
#define LCD_VOLUME_MODE_2 0x00 |
//#if DISPLAY_TYPE == 128 || DISPLAY_TYPE == 132 |
//19: static indicator (2-byte command), first on/off, then blinking mode |
#define LCD_INDICATOR_ON 0xAD //static indicator on |
#define LCD_INDICATOR_OFF 0xAC //static indicator off |
#define LCD_INDICATOR_MODE_OFF 0x00 |
#define LCD_INDICATOR_MODE_1HZ 0x01 |
#define LCD_INDICATOR_MODE_2HZ 0x10 |
#define LCD_INDICATOR_MODE_ON 0x11 |
//20: booster ratio set (2-byte command) |
#define LCD_BOOSTER_SET 0xF8 //set booster ratio |
#define LCD_BOOSTER_234 0x00 //2x-4x |
#define LCD_BOOSTER_5 0x01 //5x |
#define LCD_BOOSTER_6 0x03 //6x |
//#endif |
//22: NOP command |
#define LCD_NOP 0xE3 |
//#if DISPLAY_TYPE == 102 |
////25: advanced program control |
//#define LCD_ADV_PROG_CTRL 0xFA |
//#define LCD_ADV_PROG_CTRL2 0x10 |
//#endif |
//----------------------------------------------------------------------------- |
// Makros to execute commands |
//----------------------------------------------------------------------------- |
#define LCD_SWITCH_ON() lcd_command(LCD_DISPLAY_ON) |
#define LCD_SWITCH_OFF() lcd_command(LCD_DISPLAY_OFF) |
#define LCD_SET_FIRST_LINE(i) lcd_command(LCD_START_LINE | ((i) & 0x3F)) |
#define LCD_SET_PAGE_ADDR(i) lcd_command(LCD_PAGE_ADDRESS | ((i) & 0x0F)) |
#define LCD_SET_COLUMN_ADDR(i) lcd_command(LCD_COL_ADDRESS_MSB | ((i>>4) & 0x0F)); \ |
lcd_command(LCD_COL_ADDRESS_LSB | ((i) & 0x0F)) |
#define LCD_GOTO_ADDRESS(page,col); lcd_command(LCD_PAGE_ADDRESS | ((page) & 0x0F)); \ |
lcd_command(LCD_COL_ADDRESS_MSB | ((col>>4) & 0x0F)); \ |
lcd_command(LCD_COL_ADDRESS_LSB | ((col) & 0x0F)); |
#define LCD_SET_BOTTOM_VIEW() lcd_command(LCD_BOTTOMVIEW) |
#define LCD_SET_TOP_VIEW() lcd_command(LCD_TOPVIEW) |
#define LCD_SET_MODE_POSITIVE() lcd_command(LCD_DISPLAY_POSITIVE) |
#define LCD_SET_MODE_INVERTED() lcd_command(LCD_DISPLAY_INVERTED) |
#define LCD_SHOW_ALL_PIXELS_ON() lcd_command(LCD_SHOW_ALL_POINTS) |
#define LCD_SHOW_ALL_PIXELS_OFF() lcd_command(LCD_SHOW_NORMAL) |
#define LCD_SET_BIAS_RATIO_1_7() lcd_command(LCD_BIAS_1_7) |
#define LCD_SET_BIAS_RATIO_1_9() lcd_command(LCD_BIAS_1_9) |
#define LCD_SEND_RESET() lcd_command(LCD_RESET_CMD) |
#define LCD_ORIENTATION_NORMAL() lcd_command(LCD_SCAN_DIR_NORMAL) |
#define LCD_ORIENTATION_UPSIDEDOWN() lcd_command(LCD_SCAN_DIR_REVERSE) |
#define LCD_SET_POWER_CONTROL(i) lcd_command(LCD_POWER_CONTROL | ((i) & 0x07)) |
#define LCD_SET_LOW_POWER() lcd_command(LCD_POWER_LOW_POWER) |
#define LCD_SET_WIDE_RANGE() lcd_command(LCD_POWER_WIDE_RANGE) |
#define LCD_SET_LOW_VOLTAGE() lcd_command(LCD_POWER_LOW_VOLTAGE) |
#define LCD_SET_BIAS_VOLTAGE(i) lcd_command(LCD_VOLTAGE | ((i) & 0x07)) |
#define LCD_SET_VOLUME_MODE(i) lcd_command(LCD_VOLUME_MODE_1); \ |
lcd_command(LCD_VOLUME_MODE_2 | ((i) & 0x3F)) |
//#if DISPLAY_TYPE == 128 || DISPLAY_TYPE == 132 |
#define LCD_SET_INDICATOR_OFF() lcd_command(LCD_INDICATOR_OFF); \ |
lcd_command(LCD_INDICATOR_MODE_OFF) |
#define LCD_SET_INDICATOR_STATIC() lcd_command(LCD_INDICATOR_ON); \ |
lcd_command(LCD_INDICATOR_MODE_ON) |
#define LCD_SET_INDICATOR_1HZ() lcd_command(LCD_INDICATOR_ON); \ |
lcd_command(LCD_INDICATOR_MODE_1HZ) |
#define LCD_SET_INDICATOR_2HZ() lcd_command(LCD_INDICATOR_ON); \ |
lcd_command(LCD_INDICATOR_MODE_2HZ) |
#define LCD_SET_INDICATOR(i,j) lcd_command(LCD_INDICATOR_OFF | ((i) & 1)); \ |
lcd_command(((j) & 2)) |
#define LCD_SLEEP_MODE lcd_command(LCD_INDICATOR_OFF); \ |
lcd_command(LCD_DISPLAY_OFF); \ |
lcd_command(LCD_SHOW_ALL_POINTS) |
//#endif |
//#if DISPLAY_TYPE == 102 |
//#define LCD_TEMPCOMP_HIGH 0x80 |
//#define LCD_COLWRAP 0x02 |
//#define LCD_PAGEWRAP 0x01 |
//#define LCD_SET_ADV_PROG_CTRL(i) lcd_command(LCD_ADV_PROG_CTRL); |
// lcd_command(LCD_ADV_PROG_CTRL2 & i) |
//#endif |
*/ |
extern volatile uint8_t LCD_ORIENTATION; |
//#define LCD_LINES 8 |
//#define LCD_COLS 21 |
extern uint8_t lcd_xpos; |
extern uint8_t lcd_ypos; |
void lcd_command(uint8_t cmd); |
void send_byte (uint8_t data); |
void LCD_Init (uint8_t LCD_Mode); |
void lcd_puts_at(uint8_t x, uint8_t y,const char *s, uint8_t mode ); |
void lcd_putc (uint8_t x, uint8_t y, uint8_t c, uint8_t mode); |
void send_byte (uint8_t data); |
void lcd_print (uint8_t *text, uint8_t mode); |
void lcd_print_at (uint8_t x, uint8_t y, uint8_t *text, uint8_t mode); |
void lcd_printp (const char *text, uint8_t mode); |
void lcd_printp_at (uint8_t x, uint8_t y, const char *text, uint8_t mode); |
void lcd_printpns (const char *text, uint8_t mode); |
void lcd_printpns_at (uint8_t x, uint8_t y, const char *text, uint8_t mode); |
void lcd_cls (void); |
void lcd_cls_line (uint8_t x, uint8_t y, uint8_t w); |
void print_display (uint8_t *text); |
void print_display_at (uint8_t x, uint8_t y, uint8_t *text); |
void copy_line (uint8_t y); |
void paste_line (uint8_t y); |
// Jeti |
void lcd_putc_jeti (uint8_t x, uint8_t y, uint8_t c, uint8_t mode); |
void lcd_printpj (const char *text, uint8_t mode); |
void lcd_printpj_at (uint8_t x, uint8_t y, const char *text, uint8_t mode); |
void lcd_plot (uint8_t x, uint8_t y, uint8_t mode); |
void lcd_line (unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, uint8_t mode); |
void lcd_rect (uint8_t x1, uint8_t y1, uint8_t widthx, uint8_t widthy, uint8_t mode); |
void lcd_frect (uint8_t x1, uint8_t y1, uint8_t widthx, uint8_t widthy, uint8_t mode); |
void lcd_circle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode); |
void lcd_fcircle (int16_t x0, int16_t y0, int16_t radius); |
void lcd_circ_line (uint8_t x, uint8_t y, uint8_t r, uint16_t deg, uint8_t mode); |
void lcd_ellipse (int16_t x0, int16_t y0, int16_t rx, int16_t ry, uint8_t mode); |
void lcd_ellipse_line (uint8_t x, uint8_t y, uint8_t rx, uint8_t ry, uint16_t deg, uint8_t mode); |
void lcd_ecircle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode); |
void lcd_ecirc_line (uint8_t x, uint8_t y, uint8_t r, uint16_t deg, uint8_t mode); |
void lcd_view_font (uint8_t page); |
void lcd_print_hex_at (uint8_t x, uint8_t y, uint8_t h, uint8_t mode); |
void lcd_write_number_u (uint8_t number); |
void lcd_write_number_u_at (uint8_t x, uint8_t y, uint8_t number); |
void lcd_print_hex (uint8_t h, uint8_t mode); |
/** |
* Write only some digits of a unsigned <number> at <x>/<y> |
* <length> represents the length to rightbound the number |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_ndigit_number_u (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad); |
/** |
* Write only some digits of a signed <number> at <x>/<y> |
* <length> represents the length to rightbound the number |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_ndigit_number_s (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad); |
/** |
* Write only some digits of a unsigned <number> at <x>/<y> as /10th of the value |
* <length> represents the length to rightbound the number |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 00.7 instead of .7 |
*/ |
void write_ndigit_number_u_10th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad); |
/** |
* Write only some digits of a unsigned <number> at <x>/<y> as /100th of the value |
* <length> represents the length to rightbound the number |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 00.7 instead of .7 |
*/ |
void write_ndigit_number_u_100th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad); |
/** |
* Write only some digits of a signed <number> at <x>/<y> as /10th of the value |
* <length> represents the length to rightbound the number |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 00.7 instead of .7 |
*/ |
void write_ndigit_number_s_10th (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad); |
/** |
* write <seconds> as human readable time at <x>/<y> |
*/ |
void write_time (uint8_t x, uint8_t y, uint16_t seconds); |
/** |
* wirte a <position> at <x>/<y> assuming it is a gps position for long-/latitude |
*/ |
void write_gps_pos (uint8_t x, uint8_t y, int32_t position); |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/lipo.c |
---|
0,0 → 1,149 |
/***************************************************************************** |
* Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* based on the key handling by Peter Dannegger * |
* see www.mikrocontroller.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 <util/delay.h> |
#include <avr/interrupt.h> |
#include <inttypes.h> |
#include <stdlib.h> |
#include <avr/pgmspace.h> |
#include "lcd.h" |
#include "lipo.h" |
#include "eeprom.h" |
// Global variables |
double accumulator = 0; //!< Accumulated 10-bit samples |
double Vin = 0; //!< 16-bit float number result |
short temp = 0; //!< Temporary variable |
short samples = 0; //!< Number of conversions |
uint16_t volt_avg = 0; |
//! ADC interrupt routine |
ISR (ADC_vect) |
{ |
accumulator += ADCW; |
samples++; |
if(samples>4095) |
{ |
oversampled(); |
} |
} |
//-------------------------------------------------------------- |
// |
void ADC_Init (void) |
{ |
ADMUX = (0<<REFS1) | (1<<REFS0); // externe 5V Referenzspannung nutzen |
ADMUX = (ADMUX & ~(0x1F)) | (1 & 0x1F); // ADC1 verwenden |
ADCSRA = (1<<ADEN)|(1<<ADIE)|(1<<ADSC)|(1<<ADATE)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0); // Prescaler 128, Freilaufend, Interrupte frei |
} |
/*! Error compensation, Scaling 16-bit result, Rounding up |
, Calculate 16-bit result, Resets variables |
Quelle AVR121: Enhancing ADC resolution by versampling |
*/ |
void oversampled(void) |
{ |
cli(); |
accumulator += Lipo_UOffset; //5150 Offset error compensation |
// accumulator *= 0.9993; // Gain error compensation |
accumulator *= 0.9600; //0.9800 Gain error compensation |
temp=(int)accumulator%64; |
accumulator/=64; // Scaling the answer |
if(temp>=32) |
{ |
accumulator += 1; // Round up |
} |
// Vin = (accumulator/65536)*4.910; // Calculating 16-bit result |
Vin =accumulator/7.5; |
volt_avg = Vin; |
// write_ndigit_number_u(0, 3, Vin, 5, 0); |
// write_ndigit_number_u(0, 4, volt_avg, 5, 0); |
samples = 0; |
accumulator = 0; |
sei(); |
} |
void show_Lipo(void) |
{ |
uint16_t Balken = 0; |
lcd_rect(103,2,1,3,1); |
if (volt_avg < 320) |
{ |
Balken = 0; |
lcd_frect(106 + Balken-1, 2, 19-Balken, 3, 0); // löschen |
} |
if (PKT_Accutyp == true) //LiPO Akku |
{ |
lcd_rect(104, 0, 23, 7, 1); // Rahmen |
if (volt_avg >= 420) Balken = 19; |
if ((volt_avg > 320) && (volt_avg < 420)) Balken = (volt_avg-320)/5; |
lcd_frect(106 + Balken+1, 2, 19-Balken, 3, 0); // löschen |
} |
if (PKT_Accutyp == false) // LiON Akku |
{ |
lcd_rect(104, 0, 22, 7, 1); // Rahmen |
if (volt_avg >= 410) Balken = 18; |
if ((volt_avg > 320) && (volt_avg < 410)) Balken = ((volt_avg-320)/5); |
lcd_frect(106 + Balken+1, 2, 18-Balken, 3, 0); // löschen |
} |
if (Balken > 0) lcd_frect(106, 2, Balken, 3, 1); // Füllung |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/lipo.h |
---|
0,0 → 1,50 |
/***************************************************************************** |
* Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* based on the key handling by Peter Dannegger * |
* see www.mikrocontroller.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* |
*****************************************************************************/ |
#ifndef _LIPO_H |
#define _LIPO_H |
short samples; //!< Number of conversions |
double Vin; |
double accumulator; |
uint16_t volt_avg; |
void ADC_Init (void); |
void oversampled(void); |
void show_Lipo(void); |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/main.c |
---|
0,0 → 1,380 |
/***************************************************************************** |
* 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 <inttypes.h> |
#include <stdlib.h> |
#include <avr/pgmspace.h> |
#include <avr/wdt.h> |
#include <util/delay.h> |
#include <avr/eeprom.h> |
//************************************************************************************ |
// Watchdog integrieren und abschalten, wird für Bootloader benötigt |
// !!muss hier stehen bleiben!! |
//-------------------------------------------------------------- |
void wdt_init(void) __attribute__((naked)) __attribute__((section(".init1"))); |
//-------------------------------------------------------------- |
void wdt_init(void) |
{ |
MCUSR = 0; |
wdt_disable(); |
return; |
} |
//************************************************************************************ |
// erst ab hier weitere #includes |
#include "lipo.h" |
#include "main.h" |
#include "lcd.h" |
#include "usart.h" |
#include "uart1.h" |
#include "mk-data-structs.h" |
#include "parameter.h" |
#include "menu.h" |
#include "display.h" |
#include "timer.h" |
#include "eeprom.h" |
#include "Wi232.h" |
#include "twimaster.h" |
#include "messages.h" |
//#define MTEST 0 // Menu Test (skip FC/NC detection) |
Version_t *version; |
volatile uint8_t mode = 0; |
uint8_t hardware = 0; |
uint8_t current_hardware = 0; |
mk_param_struct_t *mk_param_struct; |
//-------------------------------------------------------------- |
int main (void) |
{ |
#ifndef DEBUG |
uint8_t timeout; |
uint8_t val =0; |
uint8_t spalte =0; |
#endif |
InitHWPorts(); // Hardwareanhängige Ports konfigurieren |
// dafür wird je nach Hardware die HAL_HWxxx verwendet |
// Define dazu in der main.h |
hardware = NO; |
current_hardware = 0; |
if (PKT_StartInfo == true) |
{ |
lcd_cls (); |
// lcd_printp_at (0,0,PSTR("Portables Kopter Tool"), 0); |
lcd_puts_at(0, 0, strGet(START_MSG1), 0); |
lcd_puts_at(0, 1, strGet(START_MSG2), 0); |
// lcd_printp_at (0,1,PSTR("für FC Ver "), 0); |
// lcd_printp_at (11,1,PSTR(FC_Version),0); |
// lcd_printp_at (0,3,PSTR("GNU GPL License"), 0); |
lcd_puts_at(0, 3, strGet(GNU_GPL), 0); |
#ifdef HWVERSION1_2 |
// lcd_printp_at (0,4,PSTR("Hardware 1.2"), 0); |
// lcd_printp_at (0,5,PSTR("ATmega 644"), 0); |
lcd_puts_at(0, 4, strGet(HW12), 0); |
lcd_puts_at(0, 5, strGet(ATMEGA644), 0); |
#endif |
#ifdef HWVERSION1_2W |
// lcd_printp_at (0,4,PSTR("Hardware 1.2W"), 0); |
// lcd_printp_at (0,5,PSTR("ATmega 644"), 0); |
lcd_puts_at(0, 4, strGet(HW12W), 0); |
lcd_puts_at(0, 5, strGet(ATMEGA644), 0); |
#endif |
#ifdef HWVERSION1_3 |
// lcd_printp_at (0,4,PSTR("Hardware 1.3"), 0); |
// lcd_printp_at (0,5,PSTR("ATmega 644P"), 0); |
lcd_puts_at(0, 4, strGet(HW13), 0); |
lcd_puts_at(0, 5, strGet(ATMEGA644P), 0); |
#endif |
#ifdef HWVERSION1_3W |
// lcd_printp_at (0,4,PSTR("Hardware 1.3W"), 0); |
// lcd_printp_at (0,5,PSTR("ATmega 644P"), 0); |
lcd_puts_at(0, 4, strGet(HW13W), 0); |
lcd_puts_at(0, 5, strGet(ATMEGA644P), 0); |
#endif |
#ifdef HWVERSION3_9 |
// lcd_printp_at (0,4,PSTR("Hardware 3.9"), 0); |
// lcd_printp_at (0,5,PSTR("ATmega 1284P"), 0); |
lcd_puts_at(0, 4, strGet(HW39), 0); |
lcd_puts_at(0, 5, strGet(ATMEGA1284P), 0); |
#endif |
_delay_ms(1500); |
} |
#ifndef DEBUG |
ReadLastPosition (); |
if (LastLongitude>0x00000000 && LastLatitude>0x00000000) |
{ |
lcd_cls (); |
// lcd_printp_at (0, 4, PSTR(" Letzte Position "), 2); |
// lcd_printp_at (0, 5, PSTR(" Breitengr Längengr "), 2); |
// lcd_printp_at (0, 7, PSTR("löschen weiter"), 0); |
lcd_puts_at(0, 0, strGet(START_LASTPOS), 2); |
lcd_puts_at(0, 1, strGet(START_LASTPOS3), 2); |
lcd_puts_at(0, 2, strGet(START_LASTPOS1), 2); |
lcd_puts_at(0, 7, strGet(START_LASTPOS2), 0); |
write_ndigit_number_u (1, 4, (uint16_t)(LastLatitude/10000000), 2, 0); |
lcd_printp_at (3, 4, PSTR("."), 0); |
write_ndigit_number_u (4, 4, (uint16_t)((LastLatitude/1000) % 10000), 4, 1); |
write_ndigit_number_u (8, 4, (uint16_t)((LastLatitude/10) % 100), 2, 1); |
write_ndigit_number_u (12, 4, (uint16_t)(LastLongitude/10000000), 2, 0); |
lcd_printp_at (14, 4, PSTR("."), 0); |
write_ndigit_number_u (15, 4, (uint16_t)((LastLongitude/1000) % 10000), 4, 1); |
write_ndigit_number_u (19, 4, (uint16_t)((LastLongitude/10) % 100), 2, 1); |
for (;;) |
{ |
if (get_key_press (1 << KEY_MINUS)) |
{ |
WriteLastPosition(0x00000000,0x00000000); // Löschen |
lcd_frect (0, (8*4), 128, 8, 0); // Zeile löschen (x, y, l, h, in Pixel) |
lcd_frect (0, (8*5), 128, 8, 0); |
// lcd_printp_at (0,5,PSTR(" gelöscht "), 0); |
lcd_puts_at(0, 5, strGet(START_LASTPOSDEL), 0); |
lcd_cls_line (0, 6, 21); |
lcd_cls_line (0, 7, 21); |
_delay_ms(1000); |
break; |
} |
if (get_key_press (1 << KEY_ENTER)) |
{ |
lcd_cls_line (0, 4, 21); |
lcd_cls_line (0, 5, 21); |
lcd_cls_line (0, 6, 21); |
lcd_cls_line (0, 7, 21); |
break; |
} |
} |
} |
#endif |
// switch to NC |
USART_putc (0x1b); |
USART_putc (0x1b); |
USART_putc (0x55); |
USART_putc (0xaa); |
USART_putc (0x00); |
mode = 'V'; |
#ifndef DEBUG |
do |
{ |
timeout = 50; |
lcd_cls(); |
// lcd_printp_at (0,4,PSTR("Suche FC..."), 0); |
// lcd_printp_at (12, 7, PSTR("Ende"), 0); |
lcd_puts_at(0, 4, strGet(START_SEARCHFC), 0); |
lcd_puts_at(12, 7, strGet(ENDE), 0); |
while (!rxd_buffer_locked && timeout) |
{ |
SendOutData('v', ADDRESS_ANY, 0); |
timer = 20; |
while (timer > 0); |
timeout--; |
if (spalte <= 20) |
{ |
lcd_printp_at (spalte,6,PSTR("?"),0); |
spalte++; |
} |
else |
{ |
lcd_cls_line (0,6,21); |
spalte=0; |
} |
if (get_key_press (1 << KEY_ESC)) |
{ |
get_key_press(KEY_ALL); |
for (;;) |
{ |
Debug = 0; |
hardware = NO; |
main_menu (); |
} |
} |
} |
if(timeout == 0) |
{ |
// lcd_printp_at (0,5,PSTR("FC nicht gefunden!"), 0); |
lcd_puts_at(0, 5, strGet(START_FCNOTFOUND), 0); |
timer = 90; |
while (timer > 0); |
} |
} |
while(timeout == 0); |
if (timeout != 0) |
Decode64 (); |
version = (Version_t *) pRxData; |
if (PKT_StartInfo == true) |
{ |
lcd_cls (); |
// lcd_printp (PSTR("PKT-Tool GNU GPL\r\n"), 0); |
// lcd_printp (PSTR("gefunden:\r\n\n"), 0); |
lcd_puts_at(0, 0, strGet(START_FCFOUND), 0); |
lcd_puts_at(0, 1, strGet(START_FCFOUND1), 0); |
} |
if ((rxd_buffer[1] - 'a') == ADDRESS_FC) |
{ |
if (PKT_StartInfo == true) |
{ |
// lcd_printp (PSTR("Flight-Ctrl\r\n"), 0); |
lcd_puts_at(0, 1, strGet(START_FCFOUND2), 0); |
} |
hardware = FC; |
current_hardware = hardware; |
} |
else if ((rxd_buffer[1] - 'a') == ADDRESS_NC) |
{ |
if (PKT_StartInfo == true) |
{ |
// lcd_printp (PSTR("Navi-Ctrl\r\n"), 0); |
lcd_puts_at(0, 1, strGet(START_FCFOUND3), 0); |
} |
hardware = NC; |
current_hardware = hardware; |
} |
if (PKT_StartInfo == true) |
{ |
// lcd_printp (PSTR("Version: "), 0); |
lcd_puts_at(0, 2, strGet(START_VERSIONCHECK), 0); |
lcd_write_number_u (version->SWMajor); |
lcd_printp (PSTR("."), 0); |
lcd_write_number_u (version->SWMinor); |
lcd_putc (lcd_xpos, lcd_ypos, version->SWPatch + 'a', 0); |
_delay_ms(1500); |
} |
SwitchToFC(); |
#else |
if (PKT_StartInfo == true) |
{ |
lcd_cls (); |
lcd_printp (PSTR("PKT-Test DEBUG\r\n"), 0); |
_delay_ms(1500); |
} |
#endif |
#ifndef DEBUG |
// EEprom Version / Struktur prüfen |
// val = load_setting(1); // Parameterset 1 holen |
val = load_setting(0xff); // aktuelles Parameterset holen |
if (mk_param_struct->Revision != EEProm_Version) |
{ |
lcd_cls (); |
lcd_printp_at (0, 0, PSTR("EEPromRev.:"), 0); |
lcd_write_number_u (EEProm_Version); |
lcd_puts_at(0, 1, strGet(START_VERSIONCHECK1), 0); |
// lcd_printp (PSTR(" erwartet\r\n"), 0); |
lcd_printp_at (0, 1, PSTR("EEPromRev.:"), 0); |
lcd_write_number_u (mk_param_struct->Revision); |
lcd_puts_at(0, 2, strGet(START_VERSIONCHECK2), 0); |
// lcd_printp (PSTR(" gefunden\r\n"), 0); |
// lcd_printp (PSTR("PKT-Tool nur mit\r\n"), 0); |
// lcd_printp (PSTR("FC Software "), 0); |
lcd_puts_at(0, 3, strGet(START_VERSIONCHECK3), 0); |
lcd_puts_at(0, 4, strGet(START_VERSIONCHECK4), 0); |
lcd_printp (PSTR(FC_Version),0); |
// lcd_printp (PSTR("\r\nkompatibel"), 0); |
lcd_puts_at(0, 5, strGet(START_VERSIONCHECK5), 0); |
hardware = NO; |
BeepTime = 1500; |
BeepMuster = 0x0040; |
_delay_ms(4000); |
} |
#endif |
mode = 0; |
rxd_buffer_locked = FALSE; |
timer = 50; |
while (timer > 0); |
for (;;) |
{ |
main_menu (); |
} |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/main.h |
---|
0,0 → 1,121 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
/** |
* @Author Cebra test test test test |
* |
* ${tags} |
*/ |
//** |
// * |
// * |
// * |
// |
/* |
* File name: $HeadURL: http://mikrokopter.de/mikrosvn/Projects/Transportables_Koptertool/branch/GPL_PKT_V3_5_8a_FC086/main.h $ |
* Revision: $Revision: 1496 $ |
* Last modified: $Date: 2012-01-15 21:31:25 +0100 (So, 15 Jan 2012) $ |
* Last modified by: $Author: $ |
* $Id: main.h 1496 2012-01-15 20:31:25Z $ |
*/ |
#ifndef _MAIN_H |
#define _MAIN_H |
// Version der Software |
#define PKTSWVersion "3.5.8c" // 1. SVN Version test |
//#define DEBUG |
// Fusebits für Hardware 1.2 D7 DC FC |
// Fusebits für Hardware 1.3 |
// Fusebits für Hardware 3.x D7 DC FC |
// avrdude -pm1284p -cavr109 -P/dev/ttyUSB1 -b115200 -V -Uflash:w:Dateiname.hex:a |
// hier die entsprechende Hardwareversion der Leiterplatte einstellen |
//#define HWVERSION1_2 // Hardware sebseb7 |
//#define HWVERSION1_2W // Hardware sebseb7 mit Wi232 Support |
//#define HWVERSION1_3 // Hardware sebseb7 |
//#define HWVERSION1_3W // Hardware sebseb7 mit Wi232 Support |
//#define HWVERSION3_1 // Test Hardware Cebra Juni 2011 |
#define HWVERSION3_9 // Hardware Cebra Oktober 2011 ATmega1284P |
#if defined HWVERSION1_2W || defined HWVERSION1_2 |
#include "HAL_HW1_2.h" |
#endif |
#if defined HWVERSION1_3W || defined HWVERSION1_3 |
#include "HAL_HW1_3.h" |
#endif |
#ifdef HWVERSION3_9 |
#include "HAL_HW3_9.h" |
#endif |
#define NO 0 |
#define NC 1 |
#define FC 2 |
#define MK3MAG 3 |
#define MKGPS 4 |
#define Wi232 5 |
#define ENABLE_PWM |
// Menueleiste am unteren Rand definieren |
// |
// 11 <> Change |
// |
// 12 /\ Up 13 \/ Down 14 < Left 15 > Right |
// |
// 16 /|\ Arrow up 17 \|/ Arrow down 18 <- Arrow left 19 -> Arrow right |
// |
// 1A ^ Triangle up 1B v Triangle down 1C < Triangle left 1D > Triangle right |
// |
// "01 234567 8901234567890" |
// "|O |||||O |||||O|||||O|" |
// |
//#define KEY_LINE_1 " \x1a \x1b Ende OK" |
//#define KEY_LINE_2 " \x18 \x19 Ende OK" |
//#define KEY_LINE_3 " \x18 \x19 Ende" |
extern volatile uint8_t mode; |
extern uint8_t hardware; |
extern uint8_t current_hardware; |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/menu.c |
---|
0,0 → 1,639 |
/***************************************************************************** |
* 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 <inttypes.h> |
#include <stdlib.h> |
#include <avr/pgmspace.h> |
#include <avr/wdt.h> |
#include <util/delay.h> |
#include "main.h" |
#include "lcd.h" |
#include "parameter.h" |
#include "menu.h" |
#include "messages.h" |
#include "display.h" |
#include "debug.h" |
#include "timer.h" |
#include "osd.h" |
#include "motortest.h" |
#include "gps.h" |
#include "eeprom.h" |
#include "setup.h" |
#include "uart1.h" |
#include "mk-data-structs.h" |
#include "Wi232.h" |
#include "servo.h" |
#include "tools.h" |
#include "connect.h" |
#include "lipo.h" |
#include "messages.h" |
#define ITEMS_NC 7 |
prog_char param_menuitems_nc[ITEMS_NC][NUM_LANG][18]= // zeilen,zeichen+1 |
// German, English, French, Netherlands |
{ |
{"OSD ","OSD ","OSD ","OSD "}, |
{"3D Lage ","3D angeles ","3D location ","3D locatie "}, |
{"MK Display ","MK Display ","MK Display ","MK Display "}, |
{"Parameter \x1d","Parameter \x1d","Parameter \x1d","Parameters \x1d"}, |
{"Debug Data ","Debug Data ","Debug Data ","Debug Data "}, |
{"GPS Info ","GPS Info ","GPS Info ","GPS Info "}, |
{"PKT Tools \x1d","PKT Tools \x1d","PKT Tools \x1d","PKT Tools \x1d"}, |
}; |
#define ITEMS_FC 4 |
prog_char param_menuitems_fc[ITEMS_FC][NUM_LANG][18]= // zeilen,zeichen+1 |
{ |
{"MK Display ","MK Display ","MK Display ","MK Display "}, |
{"Parameter \x1d","Parameter \x1d","Parameter \x1d","Parameter \x1d"}, |
{"Debug Data ","Debug Data ","Debug Data ","Debug Data "}, |
{"PKT Tools \x1d","PKT Tools \x1d","PKT Tools \x1d","PKT Tools \x1d"}, |
}; |
#define ITEMS_NO 6 |
prog_char param_menuitems_no[ITEMS_NO][NUM_LANG][18]= // zeilen,zeichen+1 |
{ |
{"BL-Ctrl. Tester ","BL-Ctrl. Tester ","BL-Ctrl. Tester ","BL-Ctrl. 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 Versie "}, |
}; |
#define ITEMS_CR 9 |
prog_char param_copyright[ITEMS_CR][22]= // zeilen,zeichen+1 |
{ |
" ", |
"(C) GNU GPL License ", |
" NO WARRANTY ", |
" ", |
"2008 Thomas Kaiser ", |
"2009-2010 Peter Mack ", |
"2010 Sebastian Boehm ", |
"2011 Chr. Brandtner &", |
" Harald Bongartz ", |
}; |
//-------------------------------------------------------------- |
// print cursor |
void menu_set_cursor (uint8_t before, uint8_t line, uint8_t pos) |
{ |
lcd_printp_at (pos, before, PSTR(" "), 0); |
lcd_printp_at (pos, line, PSTR("\x1d"), 0); |
} |
// F�r Seting-Auswahl ------------------------------------------ |
// |
uint8_t menu_choose (uint8_t min, uint8_t max, uint8_t pos, uint8_t start) |
{ |
uint8_t line = start; |
uint8_t before = start; |
uint8_t k; |
menu_set_cursor (line, line, pos); |
do |
{ |
if (get_key_press (1 << KEY_PLUS) | get_key_long_rpt_sp ((1 << KEY_PLUS), 1)) |
{ |
if (line < max) |
line ++; |
else |
line = max; |
// line = min; // Wenn wiederholen soll |
} |
if (get_key_press (1 << KEY_MINUS) | get_key_long_rpt_sp ((1 << KEY_MINUS), 1)) |
{ |
if (line > min) |
line --; |
else |
line = min; |
// line = max; // Wenn wiederholen soll |
} |
if (line != before) |
{ |
menu_set_cursor (before, line, pos); |
before = line; |
} |
} |
while (!(k = get_key_press ((1 << KEY_ENTER) | (1 << KEY_ESC)))); |
if (k & (1 << KEY_ESC)) |
line = 255; |
return line; |
} |
// F�r Setup und Parameter ------------------------------------------ |
// |
uint8_t menu_choose2 (uint8_t min, uint8_t max, uint8_t start, uint8_t return_at_start, uint8_t return_at_end) |
{ |
uint8_t pos = 1; |
uint8_t line = start; |
uint8_t before = start; |
uint8_t k; |
menu_set_cursor (line, line, pos); |
do |
{ |
if (get_key_press (1 << KEY_PLUS) | get_key_long_rpt_sp ((1 << KEY_PLUS), 1)) |
{ |
if (line < max) |
line ++; |
else |
{ |
if(return_at_end == 1) |
return 254; |
else |
line = max; |
// line = min; // Wenn wiederholen soll |
} |
} |
if (get_key_press (1 << KEY_MINUS) | get_key_long_rpt_sp ((1 << KEY_MINUS), 1)) |
{ |
if (line > min) |
line --; |
else |
{ |
if(return_at_start == 1) |
return 253; |
else |
line = min; |
// line = max; // Wenn wiederholen soll |
} |
} |
if (line != before) |
{ |
menu_set_cursor (before, line, pos); |
before = line; |
} |
} |
while (!(k = get_key_press ((1 << KEY_ENTER) | (1 << KEY_ESC)))); |
if (k & (1 << KEY_ESC)) |
line = 255; |
return line; |
} |
// F�r das Hauptmenue ------------------------------------------ |
// |
uint8_t menu_choose3 (uint8_t min, uint8_t max,uint8_t start, uint8_t return_at_start, uint8_t return_at_end) |
{ |
uint8_t pos = 1; |
uint8_t line = start; |
uint8_t before = start; |
menu_set_cursor (line, line, pos); |
do |
{ |
if (get_key_press (1 << KEY_PLUS) | get_key_long_rpt_sp ((1 << KEY_PLUS), 1)) |
{ |
if (line < max) |
line ++; |
else |
{ |
if(return_at_end == 1) |
return 254; |
else |
line = max; |
// line = min; // Wenn wiederholen soll |
} |
} |
if (get_key_press (1 << KEY_MINUS) | get_key_long_rpt_sp ((1 << KEY_MINUS), 1)) |
{ |
if (line > min) |
line --; |
else |
{ |
if(return_at_start == 1) |
return 253; |
else |
line = min; |
// line = max; // Wenn wiederholen soll |
} |
} |
if (get_key_long (1 << KEY_ESC)) |
{ |
get_key_press(KEY_ALL); |
return 250; |
} |
if(get_key_long (1 << KEY_ENTER)) |
{ |
get_key_press(KEY_ALL); |
return 251; |
} |
if (get_key_short (1 << KEY_ESC)) |
{ |
get_key_press(KEY_ALL); |
return 252; |
} |
if (line != before) |
{ |
menu_set_cursor (before, line, pos); |
before = line; |
} |
show_Lipo(); |
} |
while (!(get_key_short (1 << KEY_ENTER))); |
return line; |
} |
//-------------------------------------------------------------- |
// |
void main_menu (void) |
{ |
uint8_t ii = 0; |
uint8_t offset = 0; |
uint8_t size = 0; |
uint8_t Save_hardware = 0; |
uint8_t dmode = 0; |
uint8_t target_pos = 1; |
uint8_t val =0; |
Save_hardware = hardware; |
get_key_press(KEY_ALL); |
while(1) |
{ |
if (Debug==1) |
hardware = NC; |
if (Debug==0) |
hardware = Save_hardware; |
if(hardware == NO) |
size = ITEMS_NO ; |
if(hardware == NC) |
size = ITEMS_NC ; |
if(hardware == FC) |
size = ITEMS_FC ; |
lcd_cls (); |
lcd_printp_at (0, 0, PSTR("PKT-Tool FC "), 2); |
lcd_printp_at (12, 0, PSTR(FC_Version), 2); |
// lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
// lcd_printp_at (12, 7, PSTR("Aus "), 0); |
lcd_puts_at(12, 7, strGet(OFF), 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) |
{ |
if(hardware == NC) |
lcd_printp_at(3,ii+1,param_menuitems_nc[ii+offset][DisplayLanguage], 0); |
else if(hardware == FC) |
lcd_printp_at(3,ii+1,param_menuitems_fc[ii+offset][DisplayLanguage], 0); |
else |
lcd_printp_at(3,ii+1,param_menuitems_no[ii+offset][DisplayLanguage], 0); |
} |
if((ii == 5)&&(ii+offset < (size-1))) |
lcd_printp_at(1,6, PSTR("\x13"), 0); |
show_Lipo(); |
} |
if(dmode == 0) |
{ |
if(offset == 0) |
{ |
if(size > 6) |
val = menu_choose3 (1, 5, target_pos,0,1); //menu_choose3 (min, max, start, return_at_start, return_at_end) |
else |
val = menu_choose3 (1, size, target_pos,0,0); |
} |
else |
val = menu_choose3 (2, 5, target_pos,1,1); |
} |
if(dmode == 1) |
{ |
if(offset+7 > size) |
val = menu_choose3 (2, 6, target_pos,1,0); |
else |
val = menu_choose3 (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; |
} |
#if defined HWVERSION3_9 |
else if(val == 252) |
{ |
lcd_cls(); |
// lcd_printp_at (0, 2, PSTR(" PKT ausschalten?"),0); |
lcd_puts_at(0, 2, strGet(SHUTDOWN), 0); |
// lcd_printp_at (12, 7, PSTR("Nein Ja"),0); |
lcd_puts_at(12, 7, strGet(YESNO), 0); |
while(1) |
{ |
if (get_key_press (1 << KEY_ENTER)) |
clr_V_On(); // Spannung abschalten |
if (get_key_short (1 << KEY_ESC)) |
{ |
get_key_press(KEY_ALL); |
lcd_cls(); |
lcd_printp_at (0, 0, PSTR("PKT-Tool FC "), 2); |
lcd_printp_at (12, 0,PSTR(FC_Version), 2); |
// show_Lipo(); |
// lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
// lcd_printp_at (12, 7, PSTR("Aus "), 0); |
lcd_puts_at(12, 7, strGet(OFF), 0); |
break; |
} |
} |
} |
else if(val == 251) |
{ |
PC_Fast_Connect(); |
return; |
} |
#endif |
else if(val == 250) |
{ |
// Test_HB(); |
Test_Language(); |
return; |
} |
else |
break; |
} |
target_pos = val; |
if(hardware == NC) |
{ |
if((val+offset) == 1 ) |
osd(OSD_Mode); |
if((val+offset) == 2 ) |
osd(THREE_D_Mode); |
if((val+offset) == 3 ) |
display_data(); |
if((val+offset) == 4 ) |
edit_parameter(); |
if((val+offset) == 5 ) |
display_debug(); |
if((val+offset) == 6 ) |
gps(); |
if((val+offset) == 7 ) |
PKT_Tools(); |
} |
if(hardware == FC) |
{ |
if((val+offset) == 1 ) |
display_data(); |
if((val+offset) == 2 ) |
edit_parameter(); |
if((val+offset) == 3 ) |
display_debug(); |
if((val+offset) == 4 ) |
PKT_Tools(); |
} |
if(hardware == NO) |
{ |
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 Update_PKT (void) |
{ |
lcd_cls(); |
lcd_printp_at (0, 0, PSTR(" PKT Update "),2); |
// lcd_printp_at (0, 1, PSTR("Connect PC to PKT-USB"),0); |
lcd_puts_at(0, 1, strGet(UPDATE1), 0); |
// lcd_printp_at (0, 2, PSTR("Press 'Start' on PKT "),0); |
lcd_puts_at(0, 2, strGet(UPDATE2), 0); |
lcd_printp_at (0, 3, PSTR("Start avrdude.exe "),0); |
lcd_printp_at (0, 4, PSTR("-pm1284p -cavr109 "),0); |
lcd_printp_at (0, 5, PSTR("-Pcom? -b115200 "),0); |
lcd_printp_at (0, 6, PSTR("-Uflash:w:FILE.hex:a "),0); |
// avrdude -pm1284p -cavr109 -P/dev/ttyUSB1 -b115200 -V -Uflash:w:Dateiname.hex:a |
// lcd_printp_at (0, 7, PSTR(" Ende Start"), 0); |
lcd_puts_at(0, 7, strGet(ENDSTART), 0); |
do |
{ |
if (get_key_press (1 << KEY_ESC)) |
{ |
get_key_press(KEY_ALL); |
return; |
} |
} |
while (!(get_key_press (1 << KEY_ENTER))); |
{ |
// start bootloader with Reset, Hold KEY_ENTER*/ |
wdt_enable( WDTO_250MS ); |
while (1) |
{;} |
} |
} |
//-------------------------------------------------------------- |
// |
void Show_Error_HW (void) |
{ |
lcd_cls (); |
lcd_printp_at (0, 2, PSTR(" Mit dieser Hardware"), 0); |
lcd_printp_at (0, 3, PSTR(" nicht möglich!"), 0); |
lcd_printp_at (12, 7, PSTR("Ende"), 0); |
while (!get_key_press (1 << KEY_ESC)); |
get_key_press(KEY_ALL); |
return; |
} |
//-------------------------------------------------------------- |
// |
void Show_Version (void) |
{ |
uint8_t ii = 0; |
uint8_t size = ITEMS_CR; |
uint8_t page = 0; |
lcd_cls (); |
lcd_printp_at (0, 0, PSTR("PKT Tool V. "), 2); |
lcd_printp_at (13,0, PSTR(PKTSWVersion),2); |
// lcdPuts(Msg(MSG_VERSION1)); |
// lcd_printp_at (0, 0, Msg(MSG_VERSION1), 2); |
// lcd_printp_at (0, 1, PSTR("für FC ver "), 2); |
// lcd_printp_at (12,1, PSTR(FC_Version),2); |
lcd_puts_at(0, 1, strGet(START_MSG2), 2); |
// lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
while(1) |
{ |
for(ii = 0;ii < 3 ; ii++) |
if((ii + page) < size) |
lcd_printp_at(0,ii + 3,param_copyright[ii + page], 0); |
if (page == 0) |
{ |
lcd_printp_at (0, 2, PSTR(" "), 0); |
lcd_printp_at (0, 6, PSTR("\x13"), 0); |
} |
if (page > 0 && page < (size - 3)) |
{ |
lcd_printp_at (0, 2, PSTR("\x12"), 0); |
lcd_printp_at (0, 6, PSTR("\x13"), 0); |
} |
if (page >= (size - 3)) |
{ |
lcd_printp_at (0, 2, PSTR("\x12"), 0); |
lcd_printp_at (0, 6, PSTR(" "), 0); |
} |
if (get_key_press (1 << KEY_PLUS)) |
if (page < size - 3) |
page++; |
if (get_key_press (1 << KEY_MINUS)) |
if (page > 0) |
page--; |
if (get_key_press (1 << KEY_ESC) || get_key_press (1 << KEY_ENTER)) |
{ |
get_key_press(KEY_ALL); |
return; |
} |
} |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/menu.h |
---|
0,0 → 1,55 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
#ifndef MENU_H |
#define MENU_H |
#define CURSOR_COL 1 // column where the menu cursor is displayed |
#define MENU_LINE 1 // starting line of menu |
#define MENU_COL 3 // column where the menu starts |
#define OSD_Mode 1 // OSD Anzeige als OSD |
#define THREE_D_Mode 3 // OSD Anzeige in 3D Position |
void main_menu (void); |
void Show_Version (void); |
void Show_Error_HW (void); |
void Update_PKT (void); |
void PC_Fast_Connect (void); |
uint8_t menu_choose (uint8_t min, uint8_t max, uint8_t pos, uint8_t start); |
uint8_t menu_choose2 (uint8_t min, uint8_t max, uint8_t start, uint8_t return_at_start, uint8_t return_at_end); |
uint8_t menu_choose3 (uint8_t min, uint8_t max, uint8_t start, uint8_t return_at_start, uint8_t return_at_end); |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/messages.c |
---|
0,0 → 1,1451 |
/**************************************************************************************** |
* Copyright (C) 2011 Christian "Cebra" Brandtner, brandtner@brandtner.net * |
* * |
* 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. * |
* * |
* * |
* Languagesupport: * |
* http://www.netrino.com/Embedded-Systems/How-To/Firmware-Internationalization * |
* Nigel Jones * |
****************************************************************************************/ |
#include "cpu.h" |
#include <avr/io.h> |
#include <inttypes.h> |
#include <stdlib.h> |
#include <avr/pgmspace.h> |
#include <avr/wdt.h> |
#include <util/delay.h> |
#include "lcd.h" |
#include "timer.h" |
#include "eeprom.h" |
#include "messages.h" |
typedef enum |
{ GERMAN,ENGLISH, FRENCH, NETHERLAND, LAST_LANGUAGE } |
LANGUAGE; |
typedef struct |
{ |
/* |
* Maximum length |
*/ |
int const len; |
/* |
* Array of pointers to language-specific string |
*/ |
char const * const text[LAST_LANGUAGE]; |
} STRING; |
//-------------------------------------------------------------------------------------------------------------------- |
// Typdefinitionen für alle verwendeten Strings, LAST_STR muss am Ende stehen bleiben |
//typedef enum |
//{ |
// BOOT1,BOOT2,BOOT_WI1,BOOT_WI2,BOOT_SV,START_MSG1,START_MSG2,GNU_GPL,ATMEGA644,ATMEGA644P,ATMEGA1284P,HW12,HW12W,HW13,HW13W,HW39,START_LASTPOS,START_LASTPOS1,START_LASTPOS2,START_LASTPOSDEL, |
// START_SEARCHFC,ENDE,START_FCNOTFOUND,START_FCFOUND,START_FCFOUND1,START_FCFOUND2,START_FCFOUND3,START_VERSIONCHECK,START_VERSIONCHECK1, |
// START_VERSIONCHECK2,START_VERSIONCHECK3,START_VERSIONCHECK4,START_VERSIONCHECK5,LAST_STR |
//} STR; |
static const STRING strings[LAST_STR] = |
{ |
{ /*KEYLINE1*/ |
21, |
{ |
" \x1a \x1b Ende OK", /* German */ |
" \x1a \x1b end OK", /* English*/ |
" \x1a \x1b fin OK", /* French */ |
" \x1a \x1b Einde OK", /* Dutch */ |
} |
}, |
{ /*KEYLINE2*/ |
21, |
{ |
" \x18 \x19 Ende OK", /* German */ |
" \x18 \x19 end OK", /* English*/ |
" \x18 \x19 fin OK", /* French */ |
" \x18 \x19 Einde OK", /* Dutch */ |
} |
}, |
{ /*KEYLINE3*/ |
21, |
{ |
" \x18 \x19 Ende ", /* German */ |
" \x18 \x19 end ", /* English*/ |
" \x18 \x19 fin ", /* French */ |
" \x18 \x19 Einde", /* Dutch */ |
} |
}, |
{ /*KEYLINE4*/ |
21, |
{ |
"Ende OK", /* German */ |
"end OK", /* English*/ |
"fin OK", /* French */ |
"Einde OK", /* Dutch */ |
} |
}, |
{ /*BOOT1*/ |
21, |
{ |
"Taste 1 Sekunde", /* German */ |
"Keep the button", /* English*/ |
"Maintenez le bouton", /* French */ |
"Houd de knop ", /* Dutch */ |
} |
}, |
{ /* BOOT2*/ |
21, |
{ |
"lang festhalten.", /* German */ |
"pressed for 1 second", /* English*/ |
"enfoncee pend. 1 sec", /* French */ |
"1 seconde ingedrukt.", /* Dutch */ |
} |
}, |
{ /*BOOT_WI1*/ |
21, |
{ |
"Verbindung zum MK ist", /* German */ |
"Connection to MK is", /* English*/ |
"Connexion à MK est", /* French */ |
"Verbinding met MK is", /* Dutch */ |
} |
}, |
{ /* BOOT_WI2*/ |
21, |
{ |
"auf Wi232 eingestellt", /* German */ |
"set to Wi232", /* English*/ |
"mis a Wi232", /* French */ |
"ingesteld op Wi232", /* Dutch */ |
} |
}, |
{ /*BOOTSV1*/ |
21, |
{ |
"auf Kabel eingestellt", /* German */ |
"set to kabel on SV2", /* English*/ |
"mis a kabel sur SV2", /* French */ |
"via kabelverbinding", /* Dutch */ |
} |
}, |
{ /**/ |
21, |
{ |
"Portables Kopter Tool", /* German */ |
"Portable Kopter Tool ", /* English*/ |
"Portable Kopter Tool ", /* French */ |
"Portable Kopter Tool ", /* Dutch */ |
} |
}, |
{ /*START_MSG2 */ |
21, |
{ |
"für FC Ver "FC_Version, /* German */ |
"for FC Ver "FC_Version, /* English*/ |
"pour FC Ver "FC_Version, /* French */ |
"Voor FC Ver "FC_Version, /* Dutch */ |
} |
}, |
{ /* GNU/GPL */ |
21, |
{ |
"GNU GPL License", /* German */ |
"GNU GPL License", /* English*/ |
"GNU GPL License", /* French */ |
"GNU GPL License", /* Dutch */ |
} |
}, |
{ /**/ |
21, |
{ |
"ATmega 644", /* German */ |
"ATmega 644", /* English*/ |
"ATmega 644", /* French */ |
"ATmega 644", /* Dutch */ |
} |
}, |
{ /**/ |
21, |
{ |
"ATmega 644P", /* German */ |
"ATmega 644P", /* English*/ |
"ATmega 644P", /* French */ |
"ATmega 644P", /* Dutch */ |
} |
}, |
{ /**/ |
21, |
{ |
"ATmega 1284P", /* German */ |
"ATmega 1284P", /* English*/ |
"ATmega 1284P", /* French */ |
"ATmega 1284P", /* Dutch */ |
} |
}, |
{ /**/ |
21, |
{ |
"Hardware 1.2", /* German */ |
"Hardware 1.2", /* English*/ |
"Hardware 1.2", /* French */ |
"Hardware 1.2", /* Dutch */ |
} |
}, |
{ /**/ |
21, |
{ |
"Hardware 1.2W", /* German */ |
"Hardware 1.2W", /* English*/ |
"Hardware 1.2W", /* French */ |
"Hardware 1.2W", /* Dutch */ |
} |
}, |
{ /**/ |
21, |
{ |
"Hardware 1.3", /* German */ |
"Hardware 1.3", /* English*/ |
"Hardware 1.3", /* French */ |
"Hardware 1.3", /* Dutch */ |
} |
}, |
{ /**/ |
21, |
{ |
"Hardware 1.3W", /* German */ |
"Hardware 1.3W", /* English*/ |
"Hardware 1.3W", /* French */ |
"Hardware 1.3W", /* Dutch */ |
} |
}, |
{ /**/ |
21, |
{ |
"Hardware 3.9", /* German */ |
"Hardware 3.9", /* English*/ |
"Hardware 3.9", /* French */ |
"Hardware 3.9", /* Dutch */ |
} |
}, |
{ /*START_LASTPOS*/ |
21, |
{ |
" Letzte Position ", /* German */ |
" last position ", /* English*/ |
" derniere position ", /* French */ |
" Laatste positie ", /* Dutch */ |
} |
}, |
{ /*START_LASTPOS1*/ |
21, |
{ |
" Breitengr Längengr ", /* German */ |
" latitude longitude ", /* English*/ |
" latitude longitude ", /* French */ |
"breedtegr. lengtegr. ", /* Dutch */ |
} |
}, |
{ /*START_LASTPOS2*/ |
21, |
{ |
"löschen weiter", /* German */ |
"delete exit ", /* English*/ |
"supprimer plus ", /* French */ |
"wissen verder", /* Dutch */ |
} |
}, |
{ /*START_LASTPOS3*/ |
21, |
{ |
" Google Eingabe ", /* German */ |
" Google Input ", /* English*/ |
" Google Input ", /* French */ |
" Google Input ", /* Dutch */ |
} |
}, |
{ /*START_LASTPOSDEL*/ |
21, |
{ |
" gelöscht ", /* German */ |
" deleted ", /* English*/ |
" supprime ", /* French */ |
" gewist ", /* Dutch */ |
} |
}, |
{ /*START_SEARCHFC*/ |
21, |
{ |
"Suche FC...", /* German */ |
"searching FC...", /* English*/ |
"cherchant FC...", /* French */ |
"zoek FC...", /* Dutch */ |
} |
}, |
{ /*ENDE*/ |
21, |
{ |
"Ende ", /* German */ |
"end ", /* English*/ |
"fin ", /* French */ |
"Einde", /* Dutch */ |
} |
}, |
{ /*OK*/ |
21, |
{ |
"Ok", /* German */ |
"ok", /* English*/ |
"ok", /* French */ |
"gued", /* Dutch */ |
} |
}, |
{ /*FEHLER*/ |
21, |
{ |
"Fehler", /* German */ |
"error", /* English*/ |
"d'erreur", /* French */ |
"fout", /* Dutch */ |
} |
}, |
{ /*AKTIV*/ |
21, |
{ |
"aktiv", /* German */ |
"activ", /* English*/ |
"actifs", /* French */ |
"actief", /* Dutch */ |
} |
}, |
{ /*START_FCNOTFOUND*/ |
21, |
{ |
"FC nicht gefunden!", /* German */ |
"FC not found!", /* English*/ |
"FC pas trouve!", /* French */ |
"FC niet gevonden!", /* Dutch */ |
} |
}, |
{ /*START_FCFOUND*/ |
21, |
{ |
"PKT-Tool GNU GPL", /* German */ |
"PKT-Tool GNU GPL", /* English*/ |
"PKT-Tool GNU GPL", /* French */ |
"PKT-Tool GNU GPL", /* Dutch */ |
} |
}, |
{ /*START_FCFOUND1*/ |
21, |
{ |
"gefunden: ", /* German */ |
"found: ", /* English*/ |
"trouvés: ", /* French */ |
"gevonden: ", /* Dutch */ |
} |
}, |
{ /*START_FCFOUND2*/ |
21, |
{ |
"Flight-Ctrl", /* German */ |
"Flight-Ctrl", /* English*/ |
"Flight-Ctrl", /* French */ |
"Flight-Ctrl", /* Dutch */ |
} |
}, |
{ /*START_FCFOUND3*/ |
21, |
{ |
"Navi-Ctrl", /* German */ |
"Navi-Ctrl", /* English*/ |
"Navi-Ctrl", /* French */ |
"Navi-Ctrl", /* Dutch */ |
} |
}, |
{ /*START_VERSIONCHECK*/ |
21, |
{ |
"Version: ", /* German */ |
"Version: ", /* English*/ |
"Version: ", /* French */ |
"Versie: ", /* Dutch */ |
} |
}, |
{ /*START_VERSIONCHECK1*/ |
21, |
{ |
" erwartet", /* German */ |
" expected", /* English*/ |
" attendus", /* French */ |
" verwacht", /* Dutch */ |
} |
}, |
{ /*START_VERSIONCHECK2*/ |
21, |
{ |
" gefunden", /* German */ |
" found", /* English*/ |
" trouves", /* French */ |
" gevonden", /* Dutch */ |
} |
}, |
{ /*START_VERSIONCHECK3*/ |
21, |
{ |
"PKT-Tool nur mit", /* German */ |
"PKT-Tool only with", /* English*/ |
"PKT uniquement avec", /* French */ |
"PKT-Tool alleen met", /* Dutch */ |
} |
}, |
{ /*START_VERSIONCHECK4*/ |
21, |
{ |
"FC Software ", /* German */ |
"FC Software ", /* English*/ |
"FC Software ", /* French */ |
"FC Software ", /* Dutch */ |
} |
}, |
{ /*START_VERSIONCHECK5*/ |
21, |
{ |
"kompatibel", /* German */ |
"compatible", /* English*/ |
"compatibles", /* French */ |
"compatibel", /* Dutch */ |
} |
}, |
{ /*ON*/ |
21, |
{ |
"Ein ", /* German */ |
"On ", /* English*/ |
"Un ", /* French */ |
"Aan ", /* Dutch */ |
} |
}, |
{ /*AUS*/ |
21, |
{ |
"Aus ", /* German */ |
"Off ", /* English*/ |
"Du ", /* French */ |
"Uit ", /* Dutch */ |
} |
}, |
{ /*ESC*/ |
21, |
{ |
"ESC", /* German */ |
"ESC", /* English*/ |
"ESC", /* French */ |
"ESC", /* Dutch */ |
} |
}, |
{ /*SHUTDOWN*/ |
21, |
{ |
" PKT ausschalten?", /* German */ |
" shutdown PKT ?", /* English*/ |
" desactiver PKT ?", /* French */ |
" PKT uitschakelen ?", /* Dutch */ |
} |
}, |
{ /*YES NO*/ |
21, |
{ |
"Nein Ja", /* German */ |
"no yes", /* English*/ |
"non oui", /* French */ |
"Nee Ja", /* Dutch */ |
} |
}, |
{ /*UPDATE1*/ |
21, |
{ |
"Verbinde PC mit PKT ", /* German */ |
"Connect PC to PKT-USB", /* English*/ |
"associer PC a PKT-USB", /* French */ |
"Verbind PC met PKT ", /* Dutch */ |
} |
}, |
{ /*UPDATE2*/ |
21, |
{ |
"Drücke 'Start' am PKT", /* German */ |
"Press 'Start' on PKT ", /* English*/ |
"presse 'lancer' a PKT", /* French */ |
"Druk 'Start' op PKT ", /* Dutch */ |
} |
}, |
{ /*ENDSTART*/ |
21, |
{ |
" Ende Start", /* German */ |
" End Start", /* English*/ |
" fin lancer", /* French */ |
" Einde Start", /* Dutch */ |
} |
}, |
{ /*TOOLS1*/ |
21, |
{ |
" PC-Quick-Verbindung ", /* German */ |
" PC-Quick-Connection ", /* English*/ |
" PC-connexion rapide ", /* French */ |
" Snelle PC-verbinding", /* Dutch */ |
} |
}, |
{ /*CONNECT1,*/ |
21, |
{ |
"Verbinde das PKT mit", /* German */ |
"Connect PKT with MK", /* English*/ |
"connectez PKT a MK", /* French */ |
"Verbind PKT ", /* Dutch */ |
} |
}, |
{ /*CONNECT2*/ |
21, |
{ |
"dem MK über:", /* German */ |
" over :", /* English*/ |
" a propos :", /* French */ |
" met :", /* Dutch */ |
} |
}, |
{ /*CONNECT4,*/ |
21, |
{ |
"dem MK über: Kabel, ", /* German */ |
"over: Kabel", /* English*/ |
"a propos: Cable", /* French */ |
"MK via: kabel ", /* Dutch */ |
} |
}, |
{ /*CONNECT5*/ |
21, |
{ |
"es ist kein Wi.232", /* German */ |
"there is no Wi.232", /* English*/ |
"l n'ya pas de ", /* French */ |
"er is geen wi.232 ", /* Dutch */ |
} |
}, |
{ /*CONNECT6*/ |
21, |
{ |
"Modul eingebaut.", /* German */ |
"built in.", /* English*/ |
"module integre Wi232", /* French */ |
"module ingebouwd.", /* Dutch */ |
} |
}, |
{ /*CONNECT7,*/ |
21, |
{ |
"Wenn doch, dann bitte", /* German */ |
"if yes, then first", /* English*/ |
"Si vous le faites", /* French */ |
"zo ja, dan aub eerst", /* Dutch */ |
} |
}, |
{ /*CONNECT8*/ |
21, |
{ |
"das Modul zuerst im ", /* German */ |
"activate modul in", /* English*/ |
"activer le module", /* French */ |
"de module aktiveren", /* Dutch */ |
} |
}, |
{ /*CONNECT9*/ |
21, |
{ |
"Setupmenü aktivieren.", /* German */ |
"Setupmenu", /* English*/ |
"dans menu de config.", /* French */ |
"in het Setupmenu.", /* Dutch */ |
} |
}, |
{ /*CONNECT10*/ |
21, |
{ |
"Sie müssen das PKT", /* German */ |
"You have to", /* English*/ |
"Vous devez", /* French */ |
"U moet de PKT", /* Dutch */ |
} |
}, |
{ /*CONNECT11*/ |
21, |
{ |
"jetzt neu starten!", /* German */ |
"restart PKT", /* English*/ |
"redemarrer PKT", /* French */ |
"nu opnieuw starten!", /* Dutch */ |
} |
}, |
{ /*CONNECT12*/ |
21, |
{ |
"Es ist kein BTM-222", /* German */ |
"There is no BTM-222", /* English*/ |
"l n'ya pas de ", /* French */ |
"Er is geen BTM-222", /* Dutch */ |
} |
}, |
{ /*CONNECT13*/ |
21, |
{ |
"Modul eingebaut", /* German */ |
"Modul built in", /* English*/ |
"module integre BTM222", /* French */ |
"module ingebouwd.", /* Dutch */ |
} |
}, |
{ /*CONNECT14*/ |
21, |
{ |
" MK-USB Funktion ", /* German */ |
" MK-USB Function ", /* English*/ |
" MK-USB fonction ", /* French */ |
" MK-USB Functie ", /* Dutch */ |
} |
}, |
{ /*CONNECT15*/ |
21, |
{ |
" BT --> Kabel an FC ", /* German */ |
" BT --> Kabel to FC ", /* English*/ |
" BT --> Cable a FC ", /* French */ |
" BT --> kabel naar FC", /* Dutch */ |
} |
}, |
{ /*CONNECT16*/ |
21, |
{ |
"PC mit BT verb.", /* German */ |
"connect PC with BT", /* English*/ |
"associer PC a BT", /* French */ |
"PC via BT verbonden.", /* Dutch */ |
} |
}, |
{ /*CONNECT17*/ |
21, |
{ |
"PKT-Kabel an FC", /* German */ |
"PKT-Kabel to FC", /* English*/ |
"PKT-Cable a FC", /* French */ |
"PKT-kabel naar FC", /* Dutch */ |
} |
}, |
{ /*CONNECT18*/ |
21, |
{ |
" BT --> Wi.232 ", /* German */ |
" BT --> Wi.232 ", /* English*/ |
" BT --> Wi.232 ", /* French */ |
" BT --> Wi.232 ", /* Dutch */ |
} |
}, |
{ /*CONNECT19*/ |
21, |
{ |
"Wi.232 an FC ", /* German */ |
"Wi.232 to FC ", /* English*/ |
"Wi.232 a FC ", /* French */ |
"Wi.232 naar FC ", /* Dutch */ |
} |
}, |
{ /*CONNECT20*/ |
21, |
{ |
" USB --> Kabel an FC ", /* German */ |
" USB --> cable to FC ", /* English*/ |
" USB --> cable a FC ", /* French */ |
"USB --> kabel naar FC", /* Dutch */ |
} |
}, |
{ /*CONNECT21*/ |
21, |
{ |
"PC mit USB verbinden ", /* German */ |
"connect PC with USB ", /* English*/ |
"associer PC a USB ", /* French */ |
"Verbind PC met USB ", /* Dutch */ |
} |
}, |
{ /*CONNECT22*/ |
21, |
{ |
" USB --> Wi.232 ", /* German */ |
" USB --> Wi.232 ", /* English*/ |
" USB --> Wi.232 ", /* French */ |
" USB --> Wi.232 ", /* Dutch */ |
} |
}, |
{ /*CONNECT23*/ |
21, |
{ |
"MK-Tool starten", /* German */ |
"start MK-Tool", /* English*/ |
"demarrage MK-Tool", /* French */ |
"start MK-Tool", /* Dutch */ |
} |
}, |
{ /*CONNECT24*/ |
21, |
{ |
" Wi.232 Konfigurieren", /* German */ |
" Wi.232 Configuration", /* English*/ |
" Wi.232 configurer ", /* French */ |
" Wi.232 Configuratie ", /* Dutch */ |
} |
}, |
{ /*CONNECT25*/ |
21, |
{ |
"Programm starten. ", /* German */ |
"start program ", /* English*/ |
"Démarrer le programme", /* French */ |
"start programma.", /* Dutch */ |
} |
}, |
{ /*CONNECT26*/ |
21, |
{ |
"BTM-222 Konfigurieren", /* German */ |
"BTM-222 configuration", /* English*/ |
"BTM-222 de configura.", /* French */ |
"BTM-222 configuratie", /* Dutch */ |
} |
}, |
{ /*CONNECT27*/ |
21, |
{ |
"FC > MK-USB > BTM-222", /* German */ |
"FC > MK-USB > BTM-222", /* English*/ |
"FC > MK-USB > BTM-222", /* French */ |
"FC > MK-USB > BTM-222", /* Dutch */ |
} |
}, |
{ /*CONNECT28*/ |
21, |
{ |
"MK-USB an PC anschl. ", /* German */ |
"connect PC to MK-USB ", /* English*/ |
"associer PC a MK-USB ", /* French */ |
"Verbind PC met MK-USB", /* Dutch */ |
} |
}, |
{ /*CONNECT29*/ |
21, |
{ |
"Zwischen MK-USB und ", /* German */ |
"connect crossed cable", /* English*/ |
"la connexion entre PC", /* French */ |
"Tussen MK-USB en PKT ", /* Dutch */ |
} |
}, |
{ /*CONNECT30*/ |
21, |
{ |
"PKT ein gekreuztes ", /* German */ |
"between MK-USB and ", /* English*/ |
"et FC un cable croise", /* French */ |
"een gekruiste kabel ", /* Dutch */ |
} |
}, |
{ /*CONNECT31*/ |
21, |
{ |
"Kabel anschliessen. ", /* German */ |
"PKT SV2", /* English*/ |
" ", /* French */ |
"aansluiten.", /* Dutch */ |
} |
}, |
{ /*Kabel*/ |
21, |
{ |
"Kabel", /* German */ |
"cable", /* English*/ |
"cable", /* French */ |
"Kabel", /* Dutch */ |
} |
}, |
{ /*SLAVE*/ |
21, |
{ |
"Slave ", /* German */ |
"Slave ", /* English*/ |
"esclaves", /* French */ |
"Slave ", /* Dutch */ |
} |
}, |
{ /*NORMAL*/ |
21, |
{ |
"Normal", /* German */ |
"Normal", /* English*/ |
"normal", /* French */ |
"Norm. ", /* Dutch */ |
} |
}, |
{ /*Reverse*/ |
21, |
{ |
"Reverse", /* German */ |
"inverse", /* English*/ |
"inverse", /* French */ |
"geinver", /* Dutch */ |
} |
}, |
{ /*ENDOK*/ |
21, |
{ |
"Ende OK", /* German */ |
"End OK", /* English*/ |
"Fin OK", /* French */ |
"Eind OK", /* Dutch */ |
} |
}, |
{ /*EEPROM1*/ |
21, |
{ |
" EEProm wirklich", /* German */ |
" Realy delete", /* English*/ |
" eeprom supprimer?", /* French */ |
" Eeprom werkelijk", /* Dutch */ |
} |
}, |
{ /*EEPROM2*/ |
21, |
{ |
" löschen?", /* German */ |
" EEprom?", /* English*/ |
" ", /* French */ |
" wissen?", /* Dutch */ |
} |
}, |
{ /*DEUTSCH*/ |
21, |
{ |
"deutsch ", /* German */ |
"german ", /* English*/ |
"allemande ", /* French */ |
"duits ", /* Dutch */ |
} |
}, |
{ /*ENGLISCH*/ |
21, |
{ |
"englisch ", /* German */ |
"english ", /* English*/ |
"anglaise ", /* French */ |
"engels ", /* Dutch */ |
} |
}, |
{ /*FRANCE*/ |
21, |
{ |
"französisch", /* German */ |
"french " , /* English*/ |
"française ", /* French */ |
"frans ", /* Dutch */ |
} |
}, |
{ /*NETHERL*/ |
21, |
{ |
"holländisch", /* German */ |
"dutch ", /* English*/ |
"hollandaise", /* French */ |
"nederlands ", /* Dutch */ |
} |
}, |
{ /*DISPLAY1*/ |
21, |
{ |
"Anzeige Einstellungen", /* German */ |
" Display Setup ", /* English*/ |
" d'affichage config. ", /* French */ |
"Display instellingen ", /* Dutch */ |
} |
}, |
{ /*DISPLAY2*/ |
21, |
{ |
"Infos bei Start:", /* German */ |
"Info at startup ", /* English*/ |
"Inf.au demarrage", /* French */ |
"Info bij opstart", /* Dutch */ |
} |
}, |
{ /*DISPLAY3*/ |
21, |
{ |
"Sprache : ", /* German */ |
"Language: ", /* English*/ |
"la langue: ", /* French */ |
"Taal: ", /* Dutch */ |
} |
}, |
{ /*DISPLAY4*/ |
21, |
{ |
"Licht aus nach:", /* German */ |
"Light off after:", /* English*/ |
"Exti.feux p.les:", /* French */ |
"Licht uit na: ", /* Dutch */ |
} |
}, |
{ /*DISPLAY5*/ |
21, |
{ |
"LCD Helligk.:", /* German */ |
" Brightness :", /* English*/ |
" luminosite :", /* French */ |
" intensiteit:", /* Dutch */ |
} |
}, |
{ /*DISPLAY6*/ |
21, |
{ |
"LCD Kontrast:", /* German */ |
"LCD contrast:", /* English*/ |
"LCD contrast:", /* French */ |
"LCD contrast:", /* Dutch */ |
} |
}, |
{ /*DISPLAY7*/ |
21, |
{ |
"LCD Norm/Inv: ", /* German */ |
"LCD Norm/Inv: ", /* English*/ |
"LCD Norm/Inv: ", /* French */ |
"LCD Norm/Inv: ", /* Dutch */ |
} |
}, |
{ /*DISPLAY8*/ |
21, |
{ |
"LCD Orient.: ", /* German */ |
"LCD Orient.: ", /* English*/ |
"LCD Orient.: ", /* French */ |
"LCD Orient.: ", /* Dutch */ |
} |
}, |
{ /*DEBUGPKT*/ |
21, |
{ |
"Debug PKT", /* German */ |
"Debug PKT", /* English*/ |
"Debug PKT", /* French */ |
"Debug PKT", /* Dutch */ |
} |
}, |
{ /*WITXRX*/ |
21, |
{ |
"Wi TX/RX Chan:", /* German */ |
"Wi TX/RX Chan:", /* English*/ |
"Wi TX/RX Chan:", /* French */ |
"Wi TX/RX Chan:", /* Dutch */ |
} |
}, |
{ /*WINETG*/ |
21, |
{ |
"Wi NetW. Grp.:", /* German */ |
"Wi NetW. Grp.:", /* English*/ |
"Wi NetW. Grp.:", /* French */ |
"Wi NetW. Grp.:", /* Dutch */ |
} |
}, |
{ /*WINETM*/ |
21, |
{ |
"Wi NetW. Mode:", /* German */ |
"Wi NetW. Mode:", /* English*/ |
"Wi NetW. Mode:", /* French */ |
"Wi NetW. Mode:", /* Dutch */ |
} |
}, |
{ /*WITIMEOUT*/ |
21, |
{ |
"Wi TX Timeout:", /* German */ |
"Wi TX Timeout:", /* English*/ |
"Wi TX Timeout:", /* French */ |
"Wi TX Timeout:", /* Dutch */ |
} |
}, |
{ /*WIUART*/ |
21, |
{ |
"Wi UART MTU :", /* German */ |
"Wi UART MTU :", /* English*/ |
"Wi UART MTU :", /* French */ |
"Wi UART MTU :", /* Dutch */ |
} |
}, |
{ /*WI2321*/ |
21, |
{ |
"Wi.232 eingebaut:", /* German */ |
"Wi.232 built in :", /* English*/ |
"Wi.232 integre :", /* French */ |
"Wi.232 ingebouwd:", /* Dutch */ |
} |
}, |
{ /*WI2322*/ |
21, |
{ |
"Ist ein Wi.232-Modul ", /* German */ |
"Is Wi232 modul", /* English*/ |
"est un module ", /* French */ |
"Is er een Wi.232", /* Dutch */ |
} |
}, |
{ /*WI2323*/ |
21, |
{ |
"eingebaut?", /* German */ |
"built in?", /* English*/ |
"integre Wi232?", /* French */ |
"module ingebouwd?", /* Dutch */ |
} |
}, |
{ /*YES*/ |
21, |
{ |
"Ja ", /* German */ |
"yes ", /* English*/ |
"oui ", /* French */ |
"Ja ", /* Dutch */ |
} |
}, |
{ /*NO*/ |
21, |
{ |
"Nein", /* German */ |
"no ", /* English*/ |
"non ", /* French */ |
"Nee ", /* Dutch */ |
} |
}, |
{ /*BT1*/ |
21, |
{ |
"BTM222 eingebaut:", /* German */ |
"BTM222 built in :", /* English*/ |
"BTM222 integre :", /* French */ |
"BTM222 ingebouwd:", /* Dutch */ |
} |
}, |
{ /*BT2*/ |
21, |
{ |
"Ist ein BTM-222-Modul", /* German */ |
"Is BTM-222 Modul", /* English*/ |
"est un module ", /* French */ |
"Is er een BTM-222", /* Dutch */ |
} |
}, |
{ /*BT3*/ |
21, |
{ |
"eingebaut?", /* German */ |
"built in?", /* English*/ |
"integre BTM222?", /* French */ |
"module ingebouwd?", /* Dutch */ |
} |
}, |
{ /*LIPO1*/ |
21, |
{ |
" PKT Akku Einstellung", /* German */ |
" PKT Accu Setup ", /* English*/ |
" PKT Accu Setup ", /* French */ |
" PKT Accu Setup ", /* Dutch */ |
} |
}, |
{ /*LIPO2*/ |
21, |
{ |
"PKT Akkutyp: ", /* German */ |
"PKT Accutyp: ", /* English*/ |
"PKT Accutyp: ", /* French */ |
"PKT Accutype: ", /* Dutch */ |
} |
}, |
{ /*LIPO3*/ |
21, |
{ |
"Akku U Offset: ", /* German */ |
"Accu U Offset: ", /* English*/ |
"Accu U Offset: ", /* French */ |
"Accu U Offset: ", /* Dutch */ |
} |
}, |
{ /*LIPO4*/ |
21, |
{ |
"PKT Akkutyp: ", /* German */ |
"PKT Accutyp: ", /* English*/ |
"PKT Accutyp: ", /* French */ |
"PKT Accutype: ", /* Dutch */ |
} |
}, |
{ /*LIPO5*/ |
21, |
{ |
"Offset verstellen bis", /* German */ |
"adjust offset until", /* English*/ |
"Decalage l'ajuster ", /* French */ |
"Offset afregelen tot", /* Dutch */ |
} |
}, |
{ /*LIPO6*/ |
21, |
{ |
"die Spannung passt", /* German */ |
"voltage fits", /* English*/ |
"a la tension", /* French */ |
"de spanning juist is.", /* Dutch */ |
} |
}, |
{ /*LOWBAT*/ |
21, |
{ |
"LowBat Warn V:", /* German */ |
"LowBat Warn V:", /* English*/ |
"LowBat Warn V:", /* French */ |
"LowBat alarm :", /* Dutch */ |
} |
}, |
{ /*OSD_V, vorne*/ |
21, |
{ |
"V", /* German */ |
"F", /* English*/ |
"L", /* French */ |
"F", /* Dutch */ |
} |
}, |
{ /*OSD_H, hinten*/ |
21, |
{ |
"H", /* German */ |
"B", /* English*/ |
"D", /* French */ |
"A", /* Dutch */ |
} |
}, |
{ /*OSD_L, links*/ |
21, |
{ |
"L", /* German */ |
"L", /* English*/ |
"G", /* French */ |
"L", /* Dutch */ |
} |
}, |
{ /*OSD_R, rechts*/ |
21, |
{ |
"R", /* German */ |
"R", /* English*/ |
"D", /* French */ |
"R", /* Dutch */ |
} |
}, |
{ /*OSD_ERROR*/ |
21, |
{ |
"FEHLER: Datenverlust ", /* German */ |
"ERROR: Data lost", /* English*/ |
"perte de donnees", /* French */ |
"verbinding verbroken ", /* Dutch */ |
} |
}, |
{ /*OSD_POS1*/ |
21, |
{ |
"Letzte bekannte", /* German */ |
"Last known ", /* English*/ |
"Derniere position", /* French */ |
"Laatst bekende", /* Dutch */ |
} |
}, |
{ /*OSD_POS2*/ |
21, |
{ |
"Position ", /* German */ |
"position ", /* English*/ |
"", /* French */ |
"positie ", /* Dutch */ |
} |
}, |
{ /*PARA_SETTINGS*/ |
21, |
{ |
" Einstellungen x ", /* German */ |
" Setting x ", /* English*/ |
" Parametres x ", /* French */ |
" Instellingen x ", /* Dutch */ |
} |
}, |
{ /*PARA_CHANGE*/ |
21, |
{ |
"ändern", /* German */ |
"change", /* English*/ |
"le changement", /* French */ |
"verandering", /* Dutch */ |
} |
}, |
{ /*PARA_AKTIVI*/ |
21, |
{ |
"aktivieren", /* German */ |
"activate", /* English*/ |
"activer", /* French */ |
"activeren", /* Dutch */ |
} |
}, |
{ /*PARA_AKTIV*/ |
21, |
{ |
"aktiviert", /* German */ |
"activated", /* English*/ |
"activee", /* French */ |
"geactiveerd", /* Dutch */ |
} |
}, |
{ /*PARA_SAVESETT*/ |
21, |
{ |
" Setting x speichern?", /* German */ |
" store setting?", /* English*/ |
" Reglage magasin?", /* French */ |
" instell.op te slaan?", /* Dutch */ |
} |
}, |
{ /*PARA_SETTSAVED*/ |
21, |
{ |
"Gespeichert und", /* German */ |
"stored and", /* English*/ |
"stockes et", /* French */ |
"opgeslagen en", /* Dutch */ |
} |
}, |
{ /*PARA_COPY*/ |
21, |
{ |
"Kopiere Setting", /* German */ |
"copy settings", /* English*/ |
"parametres de copie", /* French */ |
"kopieer instel.", /* Dutch */ |
} |
}, |
{ /*PARA_FROMTO*/ |
21, |
{ |
" von x nach y", /* German */ |
" from x to y", /* English*/ |
" des x apres y", /* French */ |
" van x na y", /* Dutch */ |
} |
}, |
{ /*PARA_ENDE*/ |
21, |
{ |
"von nach Ende OK", /* German */ |
"from to end OK", /* English*/ |
"des apres fin OK", /* French */ |
"van na einde OK", /* Dutch */ |
} |
}, |
{ /*PARA_COPYQ*/ |
21, |
{ |
"Wirklich kopieren?", /* German */ |
"really copy?", /* English*/ |
"vraiment copie?", /* French */ |
"echt kopie?", /* Dutch */ |
} |
}, |
{ /*PARA_COPYACTIV*/ |
21, |
{ |
"Kopiert und aktiviert", /* German */ |
"copied and activated ", /* English*/ |
"copies et actifs", /* French */ |
"Kopieën en actief", /* Dutch */ |
} |
}, |
{ /*PARA_CHANGESETT*/ |
21, |
{ |
"Ändere Einstellungen ", /* German */ |
" change settings ", /* English*/ |
"modifier les reglages", /* French */ |
"instellingen wijzigen", /* Dutch */ |
} |
}, |
{ /*PARA_SELECT*/ |
21, |
{ |
" Wähle Parameter ", /* German */ |
" select parameters ", /* English*/ |
"selectionnez Paramet.", /* French */ |
"Selecteer Parameters ", /* Dutch */ |
} |
}, |
{ /*PARA_SEITE*/ |
21, |
{ |
" Wähle Seite ", /* German */ |
" select page ", /* English*/ |
"Selectionnez la page ", /* French */ |
" Selecteer pagina ", /* Dutch */ |
} |
}, |
{ /*PARA_SELSETT*/ |
21, |
{ |
" Wähle Setting: ", /* German */ |
" select setting ", /* English*/ |
"Selectionnez setting ", /* French */ |
" Selecteer setting ", /* Dutch */ |
} |
}, |
//---------, , |
//----------------- |
}; |
char const * strGet(int str_no) |
{ |
return strings[str_no].text[DisplayLanguage]; |
} |
void Test_Language (void) // bleibt für Tests |
{ |
lcd_cls(); |
lcd_printp_at(12, 7, PSTR("Ende"), 0); |
do |
{ |
lcd_puts_at(1, 2, strGet(BOOT_WI1), 0); |
// lcd_printp_at(1, 2, strGet(BOOT_WI1), 0); |
} |
while(!get_key_press (1 << KEY_ESC)); |
get_key_press(KEY_ALL); |
return; |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/messages.h |
---|
0,0 → 1,49 |
/**************************************************************************************** |
* Copyright (C) 2011 Christian "Cebra" Brandtner, brandtner@brandtner.net * |
* * |
* 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. * |
* * |
* * |
* Languagesupport: * |
* http://www.netrino.com/Embedded-Systems/How-To/Firmware-Internationalization * |
* Nigel Jones * |
****************************************************************************************/ |
#ifndef MESSAGES_H |
#define MESSAGES_H |
//--------------------------------------------------------------------------------------------------------------------- |
// Typdefinitionen für alle verwendeten Strings, LAST_STR muss am Ende stehen bleiben |
typedef enum |
{ |
KEYLINE1, KEYLINE2, KEYLINE3,KEYLINE4, BOOT1, BOOT2, BOOT_WI1, BOOT_WI2, BOOT_SV, START_MSG1, START_MSG2, GNU_GPL, ATMEGA644, ATMEGA644P, ATMEGA1284P, HW12, HW12W, HW13, |
HW13W, HW39, START_LASTPOS, START_LASTPOS1, START_LASTPOS2, START_LASTPOS3, START_LASTPOSDEL, START_SEARCHFC, ENDE, OK, FEHLER, AKTIV, START_FCNOTFOUND, START_FCFOUND, START_FCFOUND1, START_FCFOUND2, |
START_FCFOUND3, START_VERSIONCHECK, START_VERSIONCHECK1, START_VERSIONCHECK2, START_VERSIONCHECK3, START_VERSIONCHECK4, START_VERSIONCHECK5, ON, OFF, ESC, SHUTDOWN, |
YESNO, UPDATE1, UPDATE2, ENDSTART, TOOLS1, CONNECT1, CONNECT2, CONNECT4, CONNECT5, CONNECT6, CONNECT7, CONNECT8, CONNECT9, CONNECT10, CONNECT11, CONNECT12, |
CONNECT13, CONNECT14, CONNECT15, CONNECT16, CONNECT17, CONNECT18, CONNECT19, CONNECT20, CONNECT21, CONNECT22, CONNECT23, CONNECT24, CONNECT25, CONNECT26, CONNECT27, |
CONNECT28, CONNECT29, CONNECT30, CONNECT31, KABEL, SLAVE, NORMAL, REVERSE, ENDOK, EEPROM1, EEPROM2, DEUTSCH, ENGLISCH, FRANCE, NETHERL, DISPLAY1, DISPLAY2, |
DISPLAY3, DISPLAY4, DISPLAY5, DISPLAY6, DISPLAY7, DISPLAY8, DEBUGPKT, WITXRX, WINETWG, WINETWM, WITIMEOUT, WIUART, WI2321, WI2322, WI2323, YES, NOO, BT1, BT2, |
BT3, LIPO1, LIPO2, LIPO3, LIPO4, LIPO5, LIPO6, LOWBAT, OSD_V, OSD_H,OSD_L, OSD_R, OSD_ERROR, OSD_POS1, OSD_POS2, PARA_SETTINGS, PARA_CHANGE, PARA_AKTIVI, PARA_AKTIV, |
PARA_SAVESETT, PARA_SETTSAVED,PARA_COPY, PARA_FROMTO, PARA_ENDE,PARA_COPYQ ,PARA_COPYACTIV,PARA_CHANGESETT, PARA_SELECT, PARA_SEITE, PARA_SELSETT, LAST_STR |
} STR; |
#define NUM_LANG 4 // German, English, French, Netherlands |
char const * strGet(int str_no); |
void Test_Language (void); // bleibt für Tests |
#endif /* _MESSAGES_H_ */ |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/mk-data-structs.h |
---|
0,0 → 1,330 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
#ifndef _MK_DATA_STRUCTS_H |
#define _MK_DATA_STRUCTS_H |
// FC Version 0.86 |
#define EEProm_Version 88 // FC EEProm Revision / Struktur FC 0.86 |
#define FC_Version "0.86x" //Softwareversion der FC |
#define u8 uint8_t |
#define s8 int8_t |
#define u16 uint16_t |
#define s16 int16_t |
#define u32 uint32_t |
#define s32 int32_t |
#define NUMBER_OF_DEBUG_DATAS 32 |
#define ANALOG_NAME_LENGTH 16 |
// Version of supported serial protocol |
#define MIN_VERSION 7 |
#define MAX_VERSION 10 |
// Setting index |
#define SETTING_1 1 |
#define SETTING_2 2 |
#define SETTING_3 3 |
#define SETTING_4 4 |
#define SETTING_5 5 |
#define SETTING_CURRENT 0xff |
typedef struct |
{ |
unsigned char SWMajor; |
unsigned char SWMinor; |
unsigned char ProtoMajor; |
unsigned char ProtoMinor; |
unsigned char SWPatch; |
unsigned char HardwareError[5]; |
} __attribute__((packed)) Version_t; |
// FC Debug Struct |
// portions taken and adapted from |
// http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Ftags%2FV0.72p%2Fuart.h |
// |
typedef struct |
{ |
uint8_t Digital[2]; |
// NC: unsigned; FC: signed !!!! |
int16_t Analog[32]; // Debugvalues |
} __attribute__((packed)) DebugData_t; |
//typedef struct |
//{ |
// uint8_t line; |
// uint8_t text[20]; |
//} __attribute__((packed)) Display_t; |
//typedef struct |
//{ |
// uint8_t Revision; |
// int8_t Name[12]; |
// int8_t Motor[16][4]; |
// uint8_t crc; |
//} __attribute__((packed)) Mixer_t; |
// |
// NaviCtrl OSD Structs |
// portions taken and adapted from |
// http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=NaviCtrl&path=%2Ftags%2FV0.15c%2Fuart1.h |
// |
//typedef struct |
//{ |
// signed int Winkel[3]; // nick, roll, compass in 0,1.^ |
// signed char Centroid[3]; |
// signed char reserve[5]; |
//} __attribute__((packed)) Data3D_t; |
typedef struct |
{ |
s32 Longitude; // in 1E-7 deg |
s32 Latitude; // in 1E-7 deg |
s32 Altitude; // in mm |
u8 Status; // validity of data |
} __attribute__((packed)) GPS_Pos_t; |
typedef struct |
{ |
u16 Distance; // distance to target in cm |
s16 Bearing; // course to target in deg |
} __attribute__((packed)) GPS_PosDev_t; |
typedef struct |
{ |
GPS_Pos_t Position; // the gps position of the waypoint, see ubx.h for details |
s16 Heading; // orientation, 0 no action, 1...360 fix heading, neg. = Index to POI in WP List |
u8 ToleranceRadius; // in meters, if the MK is within that range around the target, then the next target is triggered |
u8 HoldTime; // in seconds, if the was once in the tolerance area around a WP, this time defines the delay before the next WP is triggered |
u8 Event_Flag; // future implementation |
u8 Index; // to indentify different waypoints, workaround for bad communications PC <-> NC |
u8 Type; // typeof Waypoint |
u8 WP_EventChannelValue; |
u8 AltitudeRate; // rate to change the setpoint |
u8 reserve[8]; // reserve |
} __attribute__((packed)) Point_t; |
// NaviCtrl struct |
// taken from |
// http://mikrocontroller.cco-ev.de/mikrowebsvn/filedetails.php?repname=NaviCtrl&path=%2Ftags%2FV0.15c%2Fuart1.h |
// |
typedef struct |
{ |
u8 Version; // version of the data structure |
GPS_Pos_t CurrentPosition; // see ubx.h for details |
GPS_Pos_t TargetPosition; |
GPS_PosDev_t TargetPositionDeviation; |
GPS_Pos_t HomePosition; |
GPS_PosDev_t HomePositionDeviation; |
u8 WaypointIndex; // index of current waypoints running from 0 to WaypointNumber-1 |
u8 WaypointNumber; // number of stored waypoints |
u8 SatsInUse; // number of satellites used for position solution |
s16 Altimeter; // hight according to air pressure |
s16 Variometer; // climb(+) and sink(-) rate |
u16 FlyingTime; // in seconds |
u8 UBat; // Battery Voltage in 0.1 Volts |
u16 GroundSpeed; // speed over ground in cm/s (2D) |
s16 Heading; // current flight direction in . as angle to north |
s16 CompassHeading; // current compass value in . |
s8 AngleNick; // current Nick angle in 1. |
s8 AngleRoll; // current Rick angle in 1. |
u8 RC_Quality; // RC_Quality |
u8 FCFlags; // Flags from FC |
u8 NCFlags; // Flags from NC |
u8 Errorcode; // 0 --> okay |
u8 OperatingRadius; // current operation radius around the Home Position in m |
s16 TopSpeed; // velocity in vertical direction in cm/s |
u8 TargetHoldTime; // time in s to stay at the given target, counts down to 0 if target has been reached |
u8 RC_RSSI; // Receiver signal strength (since version 2 added) |
s16 SetpointAltitude; // setpoint for altitude |
u8 Gas; // for future use |
u16 Current; // actual current in 0.1A steps |
u16 UsedCapacity; // used capacity in mAh |
} __attribute__((packed)) NaviData_t; |
// MikroKopter Flags |
// taken from |
// http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Ftags%2FV0.73d%2Ffc.h |
// |
#define FCFLAG_MOTOR_RUN 0x01 |
#define FCFLAG_FLY 0x02 |
#define FCFLAG_CALIBRATE 0x04 |
#define FCFLAG_START 0x08 |
#define FCFLAG_NOTLANDUNG 0x10 |
#define FCFLAG_LOWBAT 0x20 |
#define FCFLAG_SPI_RX_ERR 0x40 |
#define FCFLAG_I2CERR 0x80 |
// NaviCtrl Flags |
// taken from |
// http://mikrocontroller.cco-ev.de/mikrowebsvn/filedetails.php?repname=NaviCtrl&path=%2Ftags%2FV0.15c%2Fuart1.h |
// |
#define NC_FLAG_FREE 0x01 |
#define NC_FLAG_PH 0x02 |
#define NC_FLAG_CH 0x04 |
#define NC_FLAG_RANGE_LIMIT 0x08 |
#define NC_FLAG_NOSERIALLINK 0x10 |
#define NC_FLAG_TARGET_REACHED 0x20 |
#define NC_FLAG_MANUAL_CONTROL 0x40 |
#define NC_FLAG_GPS_OK 0x80 |
// Aus FC eeprom.h |
// |
typedef struct |
{ |
unsigned char Revision; |
unsigned char Kanalbelegung[12]; // GAS[0], GIER[1],NICK[2], ROLL[3], POTI1, POTI2, POTI3 |
unsigned char GlobalConfig; // 0x01=Höhenregler aktiv,0x02=Kompass aktiv, 0x04=GPS aktiv, 0x08=Heading Hold aktiv |
unsigned char Hoehe_MinGas; // Wert : 0-100 |
unsigned char Luftdruck_D; // Wert : 0-250 |
unsigned char MaxHoehe; // Wert : 0-32 |
unsigned char Hoehe_P; // Wert : 0-32 |
unsigned char Hoehe_Verstaerkung; // Wert : 0-50 |
unsigned char Hoehe_ACC_Wirkung; // Wert : 0-250 |
unsigned char Hoehe_HoverBand; // Wert : 0-250 |
unsigned char Hoehe_GPS_Z; // Wert : 0-250 |
unsigned char Hoehe_StickNeutralPoint; // Wert : 0-250 |
unsigned char Stick_P; // Wert : 1-6 |
unsigned char Stick_D; // Wert : 0-64 |
unsigned char StickGier_P; // Wert : 1-20 |
unsigned char Gas_Min; // Wert : 0-32 |
unsigned char Gas_Max; // Wert : 33-250 |
unsigned char GyroAccFaktor; // Wert : 1-64 |
unsigned char KompassWirkung; // Wert : 0-32 |
unsigned char Gyro_P; // Wert : 10-250 |
unsigned char Gyro_I; // Wert : 0-250 |
unsigned char Gyro_D; // Wert : 0-250 |
unsigned char Gyro_Gier_P; // Wert : 10-250 |
unsigned char Gyro_Gier_I; // Wert : 0-250 |
unsigned char Gyro_Stability; // Wert : 0-16 |
unsigned char UnterspannungsWarnung; // Wert : 0-250 |
unsigned char NotGas; // Wert : 0-250 //Gaswert bei Empängsverlust |
unsigned char NotGasZeit; // Wert : 0-250 // Zeitbis auf NotGas geschaltet wird, wg. Rx-Problemen |
unsigned char Receiver; // 0= Summensignal, 1= Spektrum, 2 =Jeti, 3=ACT DSL, 4=ACT S3D |
unsigned char I_Faktor; // Wert : 0-250 |
unsigned char UserParam1; // Wert : 0-250 |
unsigned char UserParam2; // Wert : 0-250 |
unsigned char UserParam3; // Wert : 0-250 |
unsigned char UserParam4; // Wert : 0-250 |
unsigned char ServoNickControl; // Wert : 0-250 // Stellung des Servos |
unsigned char ServoNickComp; // Wert : 0-250 // Einfluss Gyro/Servo |
unsigned char ServoNickMin; // Wert : 0-250 // Anschlag |
unsigned char ServoNickMax; // Wert : 0-250 // Anschlag |
//--- Seit V0.75 |
unsigned char ServoRollControl; // Wert : 0-250 // Stellung des Servos |
unsigned char ServoRollComp; // Wert : 0-250 |
unsigned char ServoRollMin; // Wert : 0-250 |
unsigned char ServoRollMax; // Wert : 0-250 |
//--- |
unsigned char ServoNickRefresh; // Speed of the Servo |
unsigned char ServoManualControlSpeed; // |
unsigned char CamOrientation; // |
unsigned char Servo3; // Value or mapping of the Servo Output |
unsigned char Servo4; // Value or mapping of the Servo Output |
unsigned char Servo5; // Value or mapping of the Servo Output |
unsigned char LoopGasLimit; // Wert: 0-250 max. Gas während Looping |
unsigned char LoopThreshold; // Wert: 0-250 Schwelle für Stickausschlag |
unsigned char LoopHysterese; // Wert: 0-250 Hysterese für Stickausschlag |
unsigned char AchsKopplung1; // Wert: 0-250 Faktor, mit dem Gier die Achsen Roll und Nick koppelt (NickRollMitkopplung) |
unsigned char AchsKopplung2; // Wert: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
unsigned char CouplingYawCorrection; // Wert: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
unsigned char WinkelUmschlagNick; // Wert: 0-250 180°-Punkt |
unsigned char WinkelUmschlagRoll; // Wert: 0-250 180°-Punkt |
unsigned char GyroAccAbgleich; // 1/k (Koppel_ACC_Wirkung) |
unsigned char Driftkomp; |
unsigned char DynamicStability; |
unsigned char UserParam5; // Wert : 0-250 |
unsigned char UserParam6; // Wert : 0-250 |
unsigned char UserParam7; // Wert : 0-250 |
unsigned char UserParam8; // Wert : 0-250 |
//---Output --------------------------------------------- |
unsigned char J16Bitmask; // for the J16 Output |
unsigned char J16Timing; // for the J16 Output |
unsigned char J17Bitmask; // for the J17 Output |
unsigned char J17Timing; // for the J17 Output |
// seit version V0.75c |
unsigned char WARN_J16_Bitmask; // for the J16 Output |
unsigned char WARN_J17_Bitmask; // for the J17 Output |
//---NaviCtrl--------------------------------------------- |
unsigned char NaviGpsModeControl; // Parameters for the Naviboard |
unsigned char NaviGpsGain; |
unsigned char NaviGpsP; |
unsigned char NaviGpsI; |
unsigned char NaviGpsD; |
unsigned char NaviGpsPLimit; |
unsigned char NaviGpsILimit; |
unsigned char NaviGpsDLimit; |
unsigned char NaviGpsACC; |
unsigned char NaviGpsMinSat; |
unsigned char NaviStickThreshold; |
unsigned char NaviWindCorrection; |
unsigned char NaviAccCompensation; // New since 0.86 -> was: SpeedCompensation |
unsigned char NaviOperatingRadius; |
unsigned char NaviAngleLimitation; |
unsigned char NaviPH_LoginTime; |
//---Ext.Ctrl--------------------------------------------- |
unsigned char ExternalControl; // for serial Control |
//---CareFree--------------------------------------------- |
unsigned char OrientationAngle; // Where is the front-direction? |
unsigned char CareFreeModeControl; // switch for CareFree |
unsigned char MotorSafetySwitch; |
unsigned char MotorSmooth; |
unsigned char ComingHomeAltitude; |
unsigned char FailSafeTime; |
unsigned char MaxAltitude; |
//------------------------------------------------ |
unsigned char BitConfig; // (war Loop-Cfg) Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt |
unsigned char ServoCompInvert; // 0x01 = Nick, 0x02 = Roll 0 oder 1 // WICHTIG!!! am Ende lassen |
unsigned char ExtraConfig; // bitcodiert |
char Name[12]; |
unsigned char crc; // MUST BE THE LAST BYTE! |
} __attribute__((packed)) mk_param_struct_t; |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/motortest.c |
---|
0,0 → 1,419 |
/***************************************************************************** |
* 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 "main.h" |
#include "motortest.h" |
#include "lcd.h" |
#include "timer.h" |
#include "twimaster.h" |
//#include "menu.h" |
#include "uart1.h" |
#include "usart.h" |
#include "messages.h" |
uint8_t m; |
uint8_t mmode; // 0=Value 1=Motor |
uint8_t v; |
volatile uint8_t i2c_state; |
volatile uint8_t motor_addr = 0; |
//-------------------------------------------------------------- |
// Senden der Motorwerte per I2C-Bus |
// |
void SendMotorData(uint8_t m,uint8_t v) |
{ |
if (m==0) |
for(m=0;m<MAX_MOTORS;m++) // alle Motoren |
{ |
// Motor[m].SetPoint = MotorTest[m]; |
Motor[m].SetPoint = v; |
Motor[m].SetPointLowerBits = 0; |
// Motor[i].SetPoint = MotorTest[i] / 4; // testing the high resolution |
// Motor[i].SetPointLowerBits = MotorTest[i] % 4; |
} |
else |
{ |
Motor[m-1].SetPoint = v; |
Motor[m-1].SetPointLowerBits = 0; |
} |
if(I2C_TransferActive) |
I2C_TransferActive = 0; // enable for the next time |
else |
{ |
motor_write = 0; |
I2C_Start(TWI_STATE_MOTOR_TX); //Start I2C Interrupt Mode |
} |
} |
//-------------------------------------------------------------- |
// |
void Search_BL (void) |
{ |
uint8_t i = 0; |
unsigned int timer; |
lcd_cls (); |
MotorenEin =0; |
MotorTest[i] = 0; |
lcd_printp (PSTR("Suche BL-Ctrl"), 0); |
// Check connected BL-Ctrls |
BLFlags |= BLFLAG_READ_VERSION; |
motor_read = 0; // read the first I2C-Data |
SendMotorData(0,0); |
timer = SetDelay(1); |
while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
timer = SetDelay(1); |
for(i=0; i < MAX_MOTORS; i++) |
{ |
SendMotorData(i,0); |
while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
if(Motor[i].State & MOTOR_STATE_PRESENT_MASK) |
{ |
lcd_printp_at (0, 1, PSTR("Found BL-Ctrl:"), 0); |
lcd_print_hex_at (18,1,i,0); |
lcd_printp_at (0, 2, PSTR("Version:"), 0); |
lcd_print_hex_at (8,2,Motor[i].Version,0); |
lcd_printp_at (11, 2, PSTR("SetPoi:"), 0); |
lcd_print_hex_at (18,2,Motor[i].SetPoint,0); |
lcd_printp_at (0, 3, PSTR("SetPoiL:"), 0); |
lcd_print_hex_at (8,3,Motor[i].SetPointLowerBits,0); |
lcd_printp_at (11, 3, PSTR("State :"), 0); |
lcd_print_hex_at (18,3,Motor[i].State,0); |
lcd_printp_at (0, 4, PSTR("ReadMod:"), 0); |
lcd_print_hex_at (8,4,Motor[i].ReadMode,0); |
lcd_printp_at (11, 4, PSTR("Currnt:"), 0); |
lcd_print_hex_at (18,4,Motor[i].Current,0); |
lcd_printp_at (0, 5, PSTR("MaxPWM :"), 0); |
lcd_print_hex_at (8,5,Motor[i].MaxPWM,0); |
lcd_printp_at (11, 5, PSTR("Temp :"), 0); |
write_ndigit_number_u (18,5,Motor[i].Temperature,3,1); |
} |
} //End For I |
} |
//-------------------------------------------------------------- |
// |
void motor (uint8_t m,uint8_t v) |
{ |
memset (buffer, 0, 16); |
if(m == 0) |
{ |
memset (buffer, v, 16); |
} |
else |
{ |
buffer[m-1] = v; |
} |
SendOutData('t', ADDRESS_FC, 1, buffer, 16); |
} |
//-------------------------------------------------------------- |
// |
void motor_test (uint8_t MotorMode) |
{ |
lcd_cls (); |
mmode = 1; // 1=Motor |
m = 1; |
v = 0; |
char buffer[7]; |
unsigned int SerLoop; |
SerLoop = 10; |
if (MotorMode == I2C_Mode) |
{ |
Search_BL(); |
do |
{ |
lcd_printp_at (11, 7, PSTR("Ende Check"), 0); |
if (get_key_press (1 << KEY_ESC)) |
{ |
get_key_press(KEY_ALL); |
return; |
} |
} |
while (!get_key_press (1 << KEY_ENTER)); |
} |
lcd_cls(); |
lcd_printp (PSTR(" BL-Ctrl Test "), 2); |
lcd_printp_at (2, 2, PSTR("Motor: 1"), 0); |
lcd_printp_at (2, 3, PSTR("Value: 0"), 0); |
lcd_frect ((8*1), (8*5), (0 * (14*8)) / 255, 6, 1); |
// lcd_printp_at (0, 7, PSTR(KEY_LINE_3), 0); |
lcd_puts_at(0, 7, strGet(KEYLINE3), 0); |
lcd_printp_at (18, 7, PSTR("\x1a \x1b"), 0); |
lcd_printp_at (0, 2, PSTR("\x1d"), 0); |
#if defined HWVERSION1_3W || defined HWVERSION1_3 || defined HWVERSION3_9 |
if (MotorMode == I2C_Mode) |
uart1_puts("Motor;Version;Setpoint high;Setpoint low;State;ReadMode;Current;MaxPWM;Temperature\r"); |
#endif |
#if defined HWVERSION1_2W || defined HWVERSION1_2 |
if (MotorMode == I2C_Mode) |
USART_puts("Motor;Version;Setpoint high;Setpoint low;State;ReadMode;Current;MaxPWM;Temperature\r"); |
#endif |
if (MotorMode == FC_Mode) |
{ |
if (hardware == NC && current_hardware == NC) |
{ |
SwitchToFC(); |
} |
} |
do |
{ |
// mmode 0=Value 1=Motor |
if ((mmode == 0) && (get_key_press (1 << KEY_PLUS) || get_key_long_rpt_sp ((1 << KEY_PLUS), 3)) && (v < 254)) |
{ |
v++; |
write_ndigit_number_u (9, 3, v, 3, 0); |
if (MotorMode == FC_Mode) |
lcd_frect ((8*1), (8*5), (v * (14*8)) / 255, 6, 1); |
} |
if ((mmode == 0) && (get_key_press (1 << KEY_MINUS) || get_key_long_rpt_sp ((1 << KEY_MINUS), 3)) && (v > 0)) |
{ |
if (MotorMode == FC_Mode) |
lcd_frect (((v * (14*8) / 255) + 8), (8*5), ((14*8) / 255), 6, 0); |
v--; |
write_ndigit_number_u (9, 3, v, 3, 0); |
if (MotorMode == FC_Mode) |
lcd_frect ((8*1), (8*5), (v * (14*8)) / 255, 6, 1); |
} |
if ((mmode == 1) && (get_key_press (1 << KEY_PLUS) || get_key_long_rpt_sp ((1 << KEY_PLUS), 1)) && (m < 16)) |
{ |
m++; |
write_ndigit_number_u (9, 2, m, 3, 0); |
} |
if ((mmode == 1) && (get_key_press (1 << KEY_MINUS) || get_key_long_rpt_sp ((1 << KEY_MINUS), 1)) && (m > 0)) |
{ |
m--; |
if(m > 0) |
write_ndigit_number_u (9, 2, m, 3, 0); |
if(m == 0) |
lcd_printp_at (9, 2, PSTR("All"), 0); |
} |
if (get_key_press (1 << KEY_ENTER)) |
{ |
if (MotorMode == I2C_Mode) |
{ |
if (v > 0) |
{ |
m = 0; |
v=0; |
lcd_frect ((8*1), (8*5), (0 * (14*8)) / 255, 6, 1); |
lcd_cls_line (0, 5, 21); |
if(m > 0) write_ndigit_number_u (9, 2, m, 3, 0); |
if(m == 0) lcd_printp_at (9, 2, PSTR("All"), 0); |
write_ndigit_number_u (9, 3, v, 3, 0); |
SendMotorData(m,v); |
timer = SetDelay(1); |
while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
} |
} |
if(mmode == 0) // 0=Value |
{ |
lcd_printp_at (0, 2, PSTR("\x1d"), 0); |
lcd_printp_at (0, 3, PSTR(" "), 0); |
mmode = 1; // 1=Motor |
} |
else |
{ |
lcd_printp_at (0, 2, PSTR(" "), 0); |
lcd_printp_at (0, 3, PSTR("\x1d"), 0); |
mmode = 0; // 0=Value |
} |
} |
//if (get_key_press (1 << KEY_ENTER))// |
if (MotorMode == I2C_Mode) |
{ |
SendMotorData(m,v); |
timer = SetDelay(1); |
lcd_printp_at (0, 3, PSTR("SetPoint :"), 0); |
write_ndigit_number_u (13,3,Motor[m-1].SetPoint,3,0); |
lcd_printp_at (0, 4, PSTR("Current :"), 0); |
lcd_print_hex_at (13,4,Motor[m-1].Current,0); |
write_ndigit_number_u (13,4,Motor[m-1].Current,3,0); |
lcd_printp_at (0, 5, PSTR("Temperature:"), 0); |
write_ndigit_number_u (13,5,Motor[m-1].Temperature,3,0); |
lcd_printp_at (0, 6, PSTR("Version:"), 0); |
lcd_print_hex_at (8,6,Motor[m-1].Version,0); |
lcd_printp_at (11, 6, PSTR("State :"), 0); |
lcd_print_hex_at (18,6,Motor[m-1].State,0); |
#if defined HWVERSION1_3W || defined HWVERSION1_3 || defined HWVERSION3_9 |
if (Motor[m-1].SetPoint > 0) |
{ |
if (SerLoop == 0) |
{ |
itoa( m-1, buffer, 10); // convert interger into string (decimal format) |
uart1_puts(buffer); // and transmit string to UART |
uart1_puts(";"); |
itoa( Motor[m-1].Version, buffer, 10); // |
uart1_puts(buffer); |
uart1_puts(";"); |
itoa( Motor[m-1].SetPoint, buffer, 10); // |
uart1_puts(buffer); |
uart1_puts(";"); |
itoa( Motor[m-1].SetPointLowerBits, buffer, 10); // |
uart1_puts(buffer); |
uart1_puts(";"); |
itoa( Motor[m-1].State, buffer, 10); // |
uart1_puts(buffer); |
uart1_puts(";"); |
itoa( Motor[m-1].ReadMode, buffer, 10); // |
uart1_puts(buffer); |
uart1_puts(";"); |
itoa( Motor[m-1].Current, buffer, 10); // |
uart1_puts(buffer); |
uart1_puts(";"); |
itoa( Motor[m-1].MaxPWM, buffer, 10); // |
uart1_puts(buffer); |
uart1_puts(";"); |
itoa( Motor[m-1].Temperature, buffer, 10); // |
uart1_puts(buffer); |
uart1_puts("\r"); |
uart1_puts("\n"); |
SerLoop =200; |
} |
else |
SerLoop--; |
} |
#endif |
#if defined HWVERSION1_2W || defined HWVERSION1_2 |
if (Motor[m-1].SetPoint > 0) |
{ |
if (SerLoop == 0) |
{ |
itoa( m-1, buffer, 10); // convert interger into string (decimal format) |
USART_puts(buffer); // and transmit string to UART |
USART_puts(";"); |
itoa( Motor[m-1].Version, buffer, 10); // |
USART_puts(buffer); |
USART_puts(";"); |
itoa( Motor[m-1].SetPoint, buffer, 10); // |
USART_puts(buffer); |
USART_puts(";"); |
itoa( Motor[m-1].SetPointLowerBits, buffer, 10); // |
USART_puts(buffer); |
USART_puts(";"); |
itoa( Motor[m-1].State, buffer, 10); // |
USART_puts(buffer); |
USART_puts(";"); |
itoa( Motor[m-1].ReadMode, buffer, 10); // |
USART_puts(buffer); |
USART_puts(";"); |
itoa( Motor[m-1].Current, buffer, 10); // |
USART_puts(buffer); |
USART_puts(";"); |
itoa( Motor[m-1].MaxPWM, buffer, 10); // |
USART_puts(buffer); |
USART_puts(";"); |
itoa( Motor[m-1].Temperature, buffer, 10); // |
USART_puts(buffer); |
USART_puts("\r"); |
USART_puts("\n"); |
SerLoop =200; |
} |
else |
SerLoop--; |
} |
#endif |
while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
} |
else |
motor (m,v); //if (MotorMode == I2C_Mode)// |
} |
while (!get_key_press (1 << KEY_ESC)); |
get_key_press(KEY_ALL); |
if (MotorMode == FC_Mode) |
{ |
motor(0,0); // switch all engines off at exit |
} |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/motortest.h |
---|
0,0 → 1,46 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
#ifndef _MOTORTEST_H |
#define _MOTORTEST_H |
#define I2C_Mode 1 // Motortest Lokal |
#define FC_Mode 2 // Motortest ueber FC |
void motor_test (uint8_t MotorMode); |
void SendMotorData(uint8_t m,uint8_t v); |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/osd.c |
---|
0,0 → 1,813 |
/***************************************************************************** |
* 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 <inttypes.h> |
#include <stdlib.h> |
#include <avr/pgmspace.h> |
#include <util/delay.h> |
#include "main.h" |
#include "osd.h" |
#include "lcd.h" |
#include "timer.h" |
#include "usart.h" |
#include "eeprom.h" |
#include "messages.h" |
#include "mk-data-structs.h" |
#define COSD_WASFLYING 4 |
#define TIMEOUT 200 // 2 sec |
// global definitions and global vars |
NaviData_t *naviData; |
// löschen und alle mit "naviData->Variometer" ersetzen |
//int8_t Variometer = 0; |
// Hier Höhenanzeigefehler Korrigieren |
#define AltimeterAdjust 1.5 |
// stats for after flight |
int16_t max_Altimeter = 0; |
uint16_t max_GroundSpeed = 0; |
int16_t max_Distance = 0; |
uint8_t min_UBat = 255; |
uint16_t max_FlyingTime = 0; |
uint16_t max_Current = 0; |
uint16_t max_Capacity = 0; |
// cache old vars for blinking attribute, checkup is faster than full |
// attribute write each time |
volatile uint8_t last_UBat = 255; |
volatile uint8_t last_RC_Quality = 255; |
volatile uint16_t ftimer = 0; |
// store stats description in progmem to save space |
const char stats_item_0[] PROGMEM = "max Altitude:"; |
const char stats_item_1[] PROGMEM = "max Speed :"; |
const char stats_item_2[] PROGMEM = "max Distance:"; |
const char stats_item_3[] PROGMEM = "min Voltage :"; |
const char stats_item_4[] PROGMEM = "max Time :"; |
#if 1 |
const char stats_item_5[] PROGMEM = "max Current :"; |
const char stats_item_6[] PROGMEM = "UsedCapacity:"; |
#else |
const char stats_item_5[] PROGMEM = "Long. :"; |
const char stats_item_6[] PROGMEM = "Lat. :"; |
#endif |
const char *stats_item_pointers[] PROGMEM = { |
stats_item_0, |
stats_item_1, |
stats_item_2, |
stats_item_3, |
stats_item_4, |
stats_item_5, |
stats_item_6 |
}; |
//char* rose = "-+-N-+-O-+-S-+-W-+-N-+-O-+-S-+-W-+-N-+-O-+-S-+-W"; |
const char rose[48] PROGMEM = { |
0x0e, 0x0f, 0x0e, 'N', 0x0e, 0x0f, 0x0e, 'O', 0x0e, 0x0f, 0x0e, 'S', |
0x0e, 0x0f, 0x0e, 'W', 0x0e, 0x0f, 0x0e, 'N', 0x0e, 0x0f, 0x0e, 'O', |
0x0e, 0x0f, 0x0e, 'S', 0x0e, 0x0f, 0x0e, 'W', 0x0e, 0x0f, 0x0e, 'N', |
0x0e, 0x0f, 0x0e, 'O', 0x0e, 0x0f, 0x0e, 'S', 0x0e, 0x0f, 0x0e, 'W', |
}; |
// the center is char 19 (north), we add the current heading in 8th |
// which would be 22.5 degrees, but float would bloat up the code |
// and *10 / 225 would take ages... so we take the uncorrect way |
const char str_NE[] PROGMEM = "NE"; |
const char str_E[] PROGMEM = "E "; |
const char str_SE[] PROGMEM = "SE"; |
const char str_S[] PROGMEM = "S "; |
const char str_SW[] PROGMEM = "SW"; |
const char str_W[] PROGMEM = "W "; |
const char str_NW[] PROGMEM = "NW"; |
const char str_N[] PROGMEM = "N "; |
const char *directions_p[8] PROGMEM = { |
str_NE, |
str_E, |
str_SE, |
str_S, |
str_SW, |
str_W, |
str_NW, |
str_N |
}; |
// Flags |
uint8_t COSD_FLAGS2 = 0; |
GPS_Pos_t last5pos[7]; |
uint8_t error = 0; |
//-------------------------------------------------------------- |
// convert the <heading> gotton from NC into an index |
uint8_t heading_conv (uint16_t heading) |
{ |
if (heading > 23 && heading < 68) |
return 0; //direction = "NE"; |
else if (heading > 67 && heading < 113) |
return 1; //direction = "E "; |
else if (heading > 112 && heading < 158) |
return 2; //direction = "SE"; |
else if (heading > 157 && heading < 203) |
return 3; //direction = "S "; |
else if (heading > 202 && heading < 248) |
return 4; //direction = "SW"; |
else if (heading > 247 && heading < 293) |
return 5; //direction = "W "; |
else if (heading > 292 && heading < 338) |
return 6; //direction = "NW"; |
return 7; //direction = "N "; |
} |
//-------------------------------------------------------------- |
// draw a compass rose at <x>/<y> for <heading> |
void draw_compass (uint8_t x, uint8_t y, uint16_t heading) |
{ |
uint8_t front = 19 + (heading / 22); |
for (uint8_t i = 0; i < 9; i++) |
lcd_putc (x++, y, pgm_read_byte(&rose[front - 4 + i]), 0); |
} |
//-------------------------------------------------------------- |
// variometer |
// draw variometer arrows at <x>/<y> according to <variometer> |
// |
void draw_variometer (uint8_t x, uint8_t y, uint8_t width, uint8_t hight, int16_t variometer) |
{ |
lcd_rect (x, y - ((hight) / 2), width, hight, 1); |
lcd_frect (x + 1, y - ((hight) / 2) + 1, width - 2, hight - 2, 0); |
lcd_line (x, y, x + width, y, 1); |
if (variometer > 0) // steigend |
{ |
switch (variometer / 5) |
{ |
case 0: |
lcd_line (x + 4, y - 1, x + 6, y - 1, 1); // 1 > 4 |
break; |
case 1: |
lcd_line (x + 4, y - 1, x + 6, y - 1, 1); // 1 > 4 |
lcd_frect (x + 3, y - 3, 4, 1, 1); // 5 > 9 |
break; |
case 2: |
lcd_line (x + 4, y - 1, x + 6, y - 1, 1); // 1 > 4 |
lcd_frect (x + 3, y - 3, 4, 1, 1); // 5 > 9 |
lcd_frect (x + 2, y - 5, 6, 1, 1); // 10 > 14 |
break; |
default: |
lcd_line (x + 4, y - 1, x + 6, y - 1, 1); // 1 > 4 |
lcd_frect (x + 3, y - 3, 4, 1, 1); // 5 > 9 |
lcd_frect (x + 2, y - 5, 6, 1, 1); // 10 > 14 |
lcd_frect (x + 1, y - 6, 8, 1, 1); // 15 > |
break; |
} |
} |
else if (variometer < 0) // fallend |
{ |
switch ((variometer) / -5) |
{ |
case 0: |
lcd_line (x + 4, y + 1, x + 6, y + 1, 1); // - 1 > - 4 |
break; |
case 1: |
lcd_line (x + 4, y + 1, x + 6, y + 1, 1); // - 1 > - 4 |
lcd_frect (x + 3, y + 2, 4, 1, 1); // - 5 > - 9 |
break; |
case 2: |
lcd_line (x + 4, y + 1, x + 6, y + 1, 1); // - 1 > - 4 |
lcd_frect (x + 3, y + 2, 4, 1, 1); // - 5 > - 9 |
lcd_frect (x + 2, y + 4, 6, 1, 1); // -10 > -14 |
break; |
default: |
lcd_line (x + 4, y + 1, x + 6, y + 1, 1); // - 1 > - 4 |
lcd_frect (x + 3, y + 2, 4, 1, 1); // - 5 > - 9 |
lcd_frect (x + 2, y + 4, 6, 1, 1); // -10 > -14 |
lcd_frect (x + 1, y + 5, 8, 1, 1); // -15 > |
break; |
} |
} |
} |
//-------------------------------------------------------------- |
void print_statistics (void) |
{ |
uint8_t line = 0; |
lcd_cls (); |
// lcd_printp_at (12, 7, PSTR("Ende"), 0); |
lcd_puts_at(12, 7, strGet(ENDE), 0); |
// max Altitude |
lcd_printp_at (0, line, stats_item_pointers[0], 0); |
write_ndigit_number_s (13, line, max_Altimeter / (30 / AltimeterAdjust), 4, 0); |
lcd_putc (17, line, 'm', 0); |
// max Speed |
lcd_printp_at (0, ++line, stats_item_pointers[1], 0); |
write_ndigit_number_u (14, line, (uint16_t) (((uint32_t) max_GroundSpeed * (uint32_t) 9) / (uint32_t) 250), 3, 0); |
lcd_printp_at(17, line, PSTR("km/h"), 0); |
// max Distance |
lcd_printp_at (0, ++line, stats_item_pointers[2], 0); |
write_ndigit_number_u (14, line, max_Distance / 10, 3, 0); |
lcd_putc (17, line, 'm', 0); |
// max time |
lcd_printp_at (0, ++line, stats_item_pointers[4], 0); |
write_time (13, line, max_FlyingTime); |
// min voltage |
lcd_printp_at (0, ++line, stats_item_pointers[3], 0); |
write_ndigit_number_u_10th (13, line, min_UBat, 3, 0); |
lcd_putc (17, line, 'V', 0); |
#if 1 |
// max Current |
lcd_printp_at (0, ++line, stats_item_pointers[5], 0); |
write_ndigit_number_u_10th (13, line, max_Current, 3, 0); |
lcd_putc (17, line, 'A', 0); |
// Used Capacity |
lcd_printp_at (0, ++line, stats_item_pointers[6], 0); |
write_ndigit_number_u (13, line, max_Capacity, 4, 0); |
lcd_printp_at(17, line, PSTR("mAh"), 0); |
#else |
// longitude |
lcd_printp_at (0, ++line, stats_item_pointers[5], 0); |
write_gps_pos (8, line, naviData->CurrentPosition.Longitude); |
// latitude |
lcd_printp_at (0, ++line, stats_item_pointers[6], 0); |
write_gps_pos (8, line, naviData->CurrentPosition.Latitude); |
#endif |
while (!get_key_press (1 << KEY_ESC)) |
timer = TIMEOUT; |
COSD_FLAGS2 &= ~COSD_WASFLYING; |
get_key_press(KEY_ALL); |
lcd_cls(); |
} |
//-------------------------------------------------------------- |
void print_position (void) |
{ |
lcd_cls (); |
// lcd_printp_at (0, 0, PSTR(" Breitengr Längengr "), 2); |
lcd_puts_at(0, 0, strGet(START_LASTPOS1), 2); |
// lcd_printp_at (12, 7, PSTR("Ende"), 0); |
lcd_puts_at(12, 7, strGet(ENDE), 0); |
uint8_t ij =0; |
for(ij=0;ij<6;ij++) |
{ |
uint32_t lon = last5pos[ij].Latitude; |
write_ndigit_number_u (1, ij+1, (uint16_t)(lon/10000000), 2, 0); |
lcd_printp_at (3, ij+1, PSTR("."), 0); |
write_ndigit_number_u (4, ij+1, (uint16_t)((lon/1000) % 10000), 4, 1); |
write_ndigit_number_u (8, ij+1, (uint16_t)((lon/10) % 100), 2, 1); |
uint32_t lat = last5pos[ij].Longitude; |
write_ndigit_number_u (12, ij+1, (uint16_t)(lat/10000000), 2, 0); |
lcd_printp_at (14, ij+1, PSTR("."), 0); |
write_ndigit_number_u (15, ij+1, (uint16_t)((lat/1000) % 10000), 4, 1); |
write_ndigit_number_u (19, ij+1, (uint16_t)((lat/10) % 100), 2, 1); |
} |
while (!get_key_press (1 << KEY_ESC)) |
timer = TIMEOUT; |
get_key_press(KEY_ALL); |
lcd_cls(); |
} |
void Show_LastPosition(void) |
{ |
lcd_puts_at(0, 2, strGet(OSD_POS1), 0); |
lcd_puts_at(0, 3, strGet(OSD_POS2), 0); |
lcd_puts_at(0, 5, strGet(START_LASTPOS1), 0); |
uint32_t lon = last5pos[0].Latitude; |
write_ndigit_number_u (1, 6, (uint16_t)(lon/10000000), 2, 0); |
lcd_printp_at (3, 6, PSTR("."), 0); |
write_ndigit_number_u (4, 6, (uint16_t)((lon/1000) % 10000), 4, 1); |
write_ndigit_number_u (8, 6, (uint16_t)((lon/10) % 100), 2, 1); |
uint32_t lat = last5pos[0].Longitude; |
write_ndigit_number_u (12, 6, (uint16_t)(lat/10000000), 2, 0); |
lcd_printp_at (14, 6, PSTR("."), 0); |
write_ndigit_number_u (15, 6, (uint16_t)((lat/1000) % 10000), 4, 1); |
write_ndigit_number_u (19, 6, (uint16_t)((lat/10) % 100), 2, 1); |
} |
void OSD_Timeout(uint8_t flag) |
{ |
// uint8_t flag; |
uint8_t tmp_dat; |
// flag = 0; |
timer = TIMEOUT; |
// disable OSD Data from NC |
// RS232_request_mk_data (1, 'o', 0); |
// tmp_dat = 0; |
// SendOutData ('o', ADDRESS_NC, 1, &tmp_dat, 1); |
mode = 0; |
rxd_buffer_locked = FALSE; |
// Bei Verbindungsverlusst werden hier die letzten bekannten Koordinaten ausgegeben!!! |
// if (!timer) |
// { // timeout occured |
if (flag) |
{ |
// Falls Spannungswarnung an war Beeper aus// |
BeepTime = 0; |
BeepMuster = 0xFFFF; |
lcd_cls (); |
WriteLastPosition(last5pos[0].Longitude,last5pos[0].Latitude); // im EEprom speichern |
lcd_puts_at(0, 0, strGet(OSD_ERROR), 2); |
// lcd_printp_at (0, 0, PSTR(" ERROR: Datenverlust "), 2); |
// lcd_printp_at (0, 2, PSTR("Letzte bekannte"), 0); |
// lcd_printp_at (0, 3, PSTR("Position gespeichert."), 0); |
lcd_puts_at(0, 2, strGet(OSD_POS1), 0); |
lcd_puts_at(0, 3, strGet(OSD_POS2), 0); |
// lcd_printp_at (19, 7, PSTR("OK"), 0); |
lcd_puts_at(19, 7, strGet(OK), 0); |
// lcd_printp_at (0, 5, PSTR(" Breitengr Längengr "), 0); |
lcd_puts_at(0, 5, strGet(START_LASTPOS1), 0); |
lcd_puts_at(12, 7, strGet(ENDE), 0); |
BeepTime = 250; |
BeepMuster = 0x0080; |
error = 1; |
uint32_t lon = last5pos[0].Latitude; |
write_ndigit_number_u (1, 6, (uint16_t)(lon/10000000), 2, 0); |
lcd_printp_at (3, 6, PSTR("."), 0); |
write_ndigit_number_u (4, 6, (uint16_t)((lon/1000) % 10000), 4, 1); |
write_ndigit_number_u (8, 6, (uint16_t)((lon/10) % 100), 2, 1); |
uint32_t lat = last5pos[0].Longitude; |
write_ndigit_number_u (12, 6, (uint16_t)(lat/10000000), 2, 0); |
lcd_printp_at (14, 6, PSTR("."), 0); |
write_ndigit_number_u (15, 6, (uint16_t)((lat/1000) % 10000), 4, 1); |
write_ndigit_number_u (19, 6, (uint16_t)((lat/10) % 100), 2, 1); |
// while (!get_key_press (1 << KEY_ENTER)); |
_delay_ms(1000); |
timer = TIMEOUT; |
lcd_cls(); |
// return; |
} |
else |
{ |
lcd_puts_at(0, 0, strGet(OSD_ERROR), 2); |
Show_LastPosition(); |
BeepTime = 250; |
BeepMuster = 0x0080; |
} |
// } |
SwitchToNC(); |
mode = 'O'; |
// disable debug... |
// RS232_request_mk_data (0, 'd', 0); |
tmp_dat = 0; |
SendOutData ('d', ADDRESS_ANY, 1, &tmp_dat, 1); |
// request OSD Data from NC every 100ms |
// RS232_request_mk_data (1, 'o', 100); |
tmp_dat = 10; |
SendOutData ('o', ADDRESS_NC, 1, &tmp_dat, 1); |
} |
//-------------------------------------------------------------- |
void osd (uint8_t ShowMode) |
{ |
uint8_t flag; |
uint8_t tmp_dat; |
uint8_t OSD_Mode; |
uint8_t info_3D = 0; |
// Clear statistics |
max_Altimeter = 0; |
max_GroundSpeed = 0; |
max_Distance = 0; |
min_UBat = 255; |
max_FlyingTime = 0; |
// flags from last round to check for changes |
uint8_t old_FCFlags = 0; |
uint16_t old_hh = 0; |
uint8_t old_AngleNick = 0; |
uint8_t old_AngleRoll = 0; |
lcd_cls(); |
OSD_Mode = ShowMode; |
// if(error == 0) |
// lcd_cls(); |
if (hardware == FC) |
{ |
lcd_printp_at(0, 3, PSTR("Only with NC !"), 0); |
timer = 100; |
while (timer > 0); |
return; |
} |
SwitchToNC(); |
mode = 'O'; |
// disable debug... |
// RS232_request_mk_data (0, 'd', 0); |
tmp_dat = 0; |
SendOutData ('d', ADDRESS_ANY, 1, &tmp_dat, 1); |
// request OSD Data from NC every 100ms |
// RS232_request_mk_data (1, 'o', 100); |
tmp_dat = 10; |
SendOutData ('o', ADDRESS_NC, 1, &tmp_dat, 1); |
flag = 0; |
timer = TIMEOUT; |
abo_timer = ABO_TIMEOUT; |
do |
{ |
if (rxd_buffer_locked) |
{ |
timer = TIMEOUT; |
Decode64 (); |
naviData = (NaviData_t *) pRxData; |
if(error == 1) |
lcd_cls(); |
error = 0; |
GPS_Pos_t currpos; |
currpos.Latitude = naviData->CurrentPosition.Latitude; |
currpos.Longitude = naviData->CurrentPosition.Longitude; |
if((currpos.Latitude != last5pos[0].Latitude)&&(currpos.Longitude != last5pos[0].Longitude)) |
{ |
last5pos[6] = last5pos[5]; |
last5pos[5] = last5pos[4]; |
last5pos[4] = last5pos[3]; |
last5pos[3] = last5pos[2]; |
last5pos[2] = last5pos[1]; |
last5pos[1] = last5pos[0]; |
last5pos[0] = currpos; |
} |
flag = 1; |
if (OSD_Mode == 1) |
{ |
if (naviData->FCFlags & FCFLAG_MOTOR_RUN) |
{ // should be engines running |
// motors are on, assume we were/are flying |
COSD_FLAGS2 |= COSD_WASFLYING; |
} |
else |
{ // stats |
if ((COSD_FLAGS2 & COSD_WASFLYING) | (get_key_press (1 << KEY_ENTER))) |
print_statistics (); |
if (get_key_press (1 << KEY_PLUS)) |
print_position (); |
} |
lcd_ecircle(22, 35, 16, 1); |
// Ground Speed |
write_ndigit_number_u (1, 0, (uint16_t) (((uint32_t) naviData->GroundSpeed * (uint32_t) 9) / (uint32_t) 250), 3, 0); |
lcd_printp_at(4, 0, PSTR("km/h"), 0); |
// Compass |
write_ndigit_number_u (14, 0, naviData->CompassHeading, 3, 0); |
lcd_putc (17, 0, 0x1E, 0); // degree symbol |
lcd_printp_at (18, 0, (const char *) (pgm_read_word ( &(directions_p[heading_conv(naviData->CompassHeading)]))), 0); |
draw_compass (12, 1, naviData->CompassHeading); |
// Altitude |
//note:lephisto:according to several sources it's /30 |
if (naviData->Altimeter > (300 / AltimeterAdjust) || naviData->Altimeter < (-300 / AltimeterAdjust)) // above 10m only write full meters |
write_ndigit_number_s (0, 1, naviData->Altimeter / (30 / AltimeterAdjust), 4, 0); |
else // up to 10m write meters.dm |
write_ndigit_number_s_10th (0, 1, naviData->Altimeter / (3 / AltimeterAdjust), 3, 0); |
lcd_putc (4, 1, 'm', 0); |
draw_variometer (54, 7, 10, 14, naviData->Variometer); |
// TODO: verify correctness |
uint16_t heading_home = (naviData->HomePositionDeviation.Bearing + 360 - naviData->CompassHeading) % 360; |
lcd_ecirc_line (22, 35, 15, old_hh, 0); |
old_hh = heading_home; |
lcd_ecirc_line (22, 35, 15, heading_home, 1); |
write_ndigit_number_u (7, 3, heading_home, 3, 0); |
lcd_putc (10, 3, 0x1e, 0); // degree symbol |
write_ndigit_number_u (7, 2, naviData->HomePositionDeviation.Distance / 10, 3, 0); |
lcd_putc (10, 2, 'm', 0); |
// Sats in use |
lcd_printp_at(11, 4, PSTR("Sats"), 0); |
write_ndigit_number_u (8, 4, naviData->SatsInUse, 2, 0); |
if (naviData->NCFlags & NC_FLAG_MANUAL_CONTROL) |
lcd_putc (19, 4, 'M', 0); // rc transmitter |
else |
lcd_putc (19, 4, 'X', 0); // clear |
if (naviData->NCFlags & NC_FLAG_CH) |
lcd_printp_at (8, 5, PSTR("Coming Home"), 0); |
else if (naviData->NCFlags & NC_FLAG_PH) |
lcd_printp_at (8, 5, PSTR("Pos. Hold "), 0); |
else // (naviData->NCFlags & NC_FLAG_FREE) |
lcd_printp_at (8, 5, PSTR("Free "), 0); |
// Flying time |
write_time (7, 6, naviData->FlyingTime); |
lcd_printp_at (12, 6, PSTR("h"), 0); |
// RC |
write_ndigit_number_u (15, 6, naviData->RC_Quality, 3, 0); |
lcd_printp_at(18, 6, PSTR("\x1F"), 0); // RC-transmitter |
if (naviData->NCFlags & NC_FLAG_NOSERIALLINK) |
{ |
lcd_printpns_at(19, 6, PSTR(" "), 0); // clear |
} |
else |
{ |
lcd_printpns_at(19, 6, PSTR("PC"), 0); |
} |
// Battery level |
write_ndigit_number_u_10th (0, 7, naviData->UBat, 3, 0); |
lcd_putc (4, 7, 'V', 0); |
// Akku Warnung |
if (naviData->UBat < MK_LowBat) |
{ //Beeper ein |
BeepTime = 3000; |
BeepMuster = 0x0020; |
} |
//if (naviData->UBat > MK_LowBat+2) //bei kurzzeitigen Schwankungen Beeper erst wieder aus wenn UBat 0,2 V höher als Warnschwelle |
//{ //Beeper aus |
// BeepTime = 0; |
// BeepMuster = 0xFFFF; |
//} |
// Akku Warnung Ende |
// Current |
write_ndigit_number_u_10th (7, 7, naviData->Current, 3, 0); |
lcd_putc (11, 7, 'A', 0); |
// Capacity |
write_ndigit_number_u (14, 7, naviData->UsedCapacity, 4, 0); |
lcd_printp_at(18, 7, PSTR("mAh"), 0); |
// remember statistics (only when engines running) |
if (naviData->FCFlags & FCFLAG_MOTOR_RUN) |
{ |
if (naviData->Altimeter > max_Altimeter) max_Altimeter = naviData->Altimeter; |
if (naviData->GroundSpeed > max_GroundSpeed) max_GroundSpeed = naviData->GroundSpeed; |
if (naviData->HomePositionDeviation.Distance > max_Distance) max_Distance = naviData->HomePositionDeviation.Distance; |
if (naviData->UBat < min_UBat) min_UBat = naviData->UBat; |
if (naviData->FlyingTime > max_FlyingTime) max_FlyingTime = naviData->FlyingTime; |
if (naviData->Current > max_Current) max_Current = naviData->Current; |
if (naviData->UsedCapacity > max_Capacity) max_Capacity = naviData->UsedCapacity; |
} |
// remember last values |
last_RC_Quality = naviData->RC_Quality; |
last_UBat = naviData->UBat; |
old_FCFlags = naviData->FCFlags; |
rxd_buffer_locked = FALSE; |
} |
// 3D Lage anzeige beginnt hier ----------------------------------- |
else if (OSD_Mode == 3) |
{ |
uint16_t head_home = (naviData->HomePositionDeviation.Bearing + 360 - naviData->CompassHeading) % 360; |
lcd_cls (); |
lcd_line(0,32,128,32,1); // horizontal // |
lcd_line(64,0,64,64,1); // vertical // |
lcd_printp_at(12, 7, PSTR("End Info"), 0); |
// 45' Angel |
lcd_line(62,11,66,11,1); // -- // |
lcd_line(22,30,22,34,1); // | // |
lcd_line(106,30,106,34,1); // | // |
lcd_line(62,53,66,53,1); // -- // |
if (info_3D == 1) |
{ |
lcd_line(34,17,36,15,1); // / // |
lcd_line(92,15,94,17,1); // \ // |
lcd_line(34,47,36,49,1); // \ // |
lcd_line(92,49,94,47,1); // / // |
// lcd_printp_at(9, 0, PSTR("V"), 0); |
// lcd_printp_at(0, 3, PSTR("L"), 0); |
// lcd_printp_at(20, 3, PSTR("R"), 0); |
// lcd_printp_at(9, 7, PSTR("H"), 0); |
lcd_puts_at(9, 0, strGet(OSD_V), 0); |
lcd_puts_at(0, 3, strGet(OSD_L), 0); |
lcd_puts_at(20, 3, strGet(OSD_R), 0); |
lcd_puts_at(9, 7, strGet(OSD_H), 0); |
lcd_printp_at(0, 0, PSTR("N:"), 0); |
write_ndigit_number_s (2, 0, naviData->AngleNick, 3, 0); |
lcd_printp_at(0, 7, PSTR("R:"), 0); |
write_ndigit_number_s (2, 7, naviData->AngleRoll, 3, 0); |
lcd_printp_at(15, 0, PSTR("K:"), 0); |
write_ndigit_number_s (18, 0,head_home, 3, 0); |
} |
if (get_key_press (1 << KEY_ENTER)) |
{ |
info_3D++; |
if (info_3D > 1) |
info_3D = 0; |
} |
uint8_t Nick = ((-naviData->AngleNick/2)+32); |
uint8_t Roll = -naviData->AngleRoll+64; |
lcd_ecircle(old_AngleRoll,old_AngleNick, 10, 0); |
lcd_ecirc_line (old_AngleRoll, old_AngleNick, 9, old_hh, 0); |
lcd_ecircle(Roll, Nick, 10, 1); |
lcd_ecirc_line (Roll, Nick, 9, head_home, 1); |
old_hh = head_home; |
old_AngleNick = Nick; |
old_AngleRoll = Roll; |
// remember last values |
last_RC_Quality = naviData->RC_Quality; |
last_UBat = naviData->UBat; |
old_FCFlags = naviData->FCFlags; |
rxd_buffer_locked = FALSE; |
} |
if (!abo_timer) |
{ // renew abo every 3 sec |
// request OSD Data from NC every 100ms |
// RS232_request_mk_data (1, 'o', 100); |
tmp_dat = 10; |
SendOutData ('o', ADDRESS_NC, 1, &tmp_dat, 1); |
abo_timer = ABO_TIMEOUT; |
} |
} |
if (!timer) |
{ |
OSD_Timeout(flag); |
flag = 0; |
} |
} |
while (!get_key_press (1 << KEY_ESC)); |
// while (!get_key_press (1 << KEY_ESC) && timer); |
// get_key_press(KEY_ALL); |
// |
// |
// // disable OSD Data from NC |
// // RS232_request_mk_data (1, 'o', 0); |
// tmp_dat = 0; |
// SendOutData ('o', ADDRESS_NC, 1, &tmp_dat, 1); |
// |
// mode = 0; |
// rxd_buffer_locked = FALSE; |
// |
// |
// // Bei Verbindungsverlusst werden hier die letzten bekannten Koordinaten ausgegeben!!! |
// if (!timer) |
// { // timeout occured |
// if (flag) |
// { |
// // Falls Spannungswarnung an war Beeper aus// |
// BeepTime = 0; |
// BeepMuster = 0xFFFF; |
// |
// lcd_cls (); |
// WriteLastPosition(last5pos[0].Longitude,last5pos[0].Latitude); // im EEprom speichern |
// lcd_puts_at(0, 0, strGet(OSD_ERROR), 2); |
// |
//// lcd_printp_at (0, 0, PSTR(" ERROR: Datenverlust "), 2); |
// |
//// lcd_printp_at (0, 2, PSTR("Letzte bekannte"), 0); |
//// lcd_printp_at (0, 3, PSTR("Position gespeichert."), 0); |
// lcd_puts_at(0, 2, strGet(OSD_POS1), 0); |
// lcd_puts_at(0, 3, strGet(OSD_POS2), 0); |
//// lcd_printp_at (19, 7, PSTR("OK"), 0); |
// lcd_puts_at(19, 7, strGet(OK), 0); |
//// lcd_printp_at (0, 5, PSTR(" Breitengr Längengr "), 0); |
// |
// lcd_puts_at(0, 5, strGet(START_LASTPOS1), 0); |
// |
// lcd_puts_at(12, 7, strGet(ENDE), 0); |
// |
// BeepTime = 1500; |
// BeepMuster = 0x0040; |
// error = 1; |
// |
// uint32_t lon = last5pos[0].Longitude; |
// write_ndigit_number_u (1, 6, (uint16_t)(lon/10000000), 2, 0); |
// lcd_printp_at (3, 6, PSTR("."), 0); |
// write_ndigit_number_u (4, 6, (uint16_t)((lon/1000) % 10000), 4, 1); |
// write_ndigit_number_u (8, 6, (uint16_t)((lon/10) % 100), 2, 1); |
// |
// uint32_t lat = last5pos[0].Latitude; |
// write_ndigit_number_u (12, 6, (uint16_t)(lat/10000000), 2, 0); |
// lcd_printp_at (14, 6, PSTR("."), 0); |
// write_ndigit_number_u (15, 6, (uint16_t)((lat/1000) % 10000), 4, 1); |
// write_ndigit_number_u (19, 6, (uint16_t)((lat/10) % 100), 2, 1); |
// |
// while (!get_key_press (1 << KEY_ENTER)); |
// |
// timer = TIMEOUT; |
// lcd_cls(); |
// return; |
// |
// } |
// } |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/osd.h |
---|
0,0 → 1,42 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
#ifndef _OSD_H |
#define _OSD_H |
void osd (uint8_t ShowMode); |
void vario_beep_output (void); |
void OSD_Timeout(uint8_t flag); |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/parameter.c |
---|
0,0 → 1,1384 |
/***************************************************************************** |
* Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* Copyright (C) 2011 Christian "Cebra" Brandtner, brandtner@brandtner.net * |
* Copyright (C) 2011 Harald Bongartz * |
* * |
* This program is free software; you can redistribute it and/or modify * |
* it under the terms of the GNU General Public License as published by * |
* the Free Software Foundation; either version 2 of the License. * |
* * |
* This program is distributed in the hope that it will be useful, * |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
* GNU General Public License for more details. * |
* * |
* You should have received a copy of the GNU General Public License * |
* along with this program; if not, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
* * |
* Credits to: * |
* Holger Buss & Ingo Busker from mikrokopter.de for the MK project + SVN * |
* http://www.mikrokopter.de * |
* Gregor "killagreg" Stobrawa for his version of the MK code * |
* Thomas Kaiser "thkais" for the original project. See * |
* http://www.ft-fanpage.de/mikrokopter/ * |
* http://forum.mikrokopter.de/topic-4061-1.html * |
* Claas Anders "CaScAdE" Rathje for providing the font and his C-OSD code * |
* http://www.mylifesucks.de/oss/c-osd/ * |
* Harald Bongartz "HaraldB" for providing his Ideas and Code for usibility* |
*****************************************************************************/ |
#include "cpu.h" |
#include <avr/io.h> |
#include <avr/pgmspace.h> |
#include <util/delay.h> |
#include <string.h> |
#include <stdlib.h> |
#include "main.h" |
#include "lcd.h" |
#include "timer.h" |
#include "usart.h" |
#include "mk-data-structs.h" |
#include "parameter.h" |
#include "menu.h" |
#include "eeprom.h" |
#include "parameter_names.h" |
#include "messages.h" |
#define TIMEOUT 500 // 5 sec |
uint8_t display_settings_menu (void); |
uint8_t display_param_menu (uint8_t); |
uint8_t load_setting (uint8_t); |
uint8_t write_setting (uint8_t); |
uint8_t display_section_menu(void); |
void edit_param(uint8_t); |
void copy_setting(void); |
mk_param_struct_t *mk_param_struct; |
uint8_t ii; |
volatile uint8_t offset = 0; |
volatile uint8_t dmode = 0; |
volatile uint8_t target_pos = 1; |
volatile uint8_t offset2 = 0; |
volatile uint8_t pmode = 0; |
volatile uint8_t target_pos2 = 1; |
volatile uint8_t setting = 0; |
uint8_t changes = 0; |
#define OFFSETOF(type, field) ((unsigned int) &(((type *) 0)->field)) |
#define MKOSO(field) (uint8_t)OFFSETOF(mk_param_struct_t, field) |
//-------------------------------------------------------------- |
// Group, Typ, Min, Max, Struct-Name(Value), Default1, Default2, Default3+4+5, |
// 0 1 2 3 4 5 6 7 |
// ||| |
// Typ == (0 ohne Poti, 1 mit Poti, 2 bitfield, 3 serCh, 4 LEDmask, 5 Angle, 6 Empfaenger), |
// |
prog_uchar param_config[8*PARAM_COUNT]= |
{ |
// group 0 (kanaele) 1-15 |
0,0,1,12, MKOSO(Kanalbelegung)+2 , 1,1,1, // gas |
0,0,1,12, MKOSO(Kanalbelegung)+3 , 4,4,4, // gier |
0,0,1,12, MKOSO(Kanalbelegung)+0 , 3,3,3, // nick |
0,0,1,12, MKOSO(Kanalbelegung)+1 , 2,2,2, // roll |
0,3,1,25, MKOSO(Kanalbelegung)+4 , 5,5,5, // poti1 |
0,3,1,25, MKOSO(Kanalbelegung)+5 , 6,6,6, // poti2 |
0,3,1,25, MKOSO(Kanalbelegung)+6 , 7,7,7, // poti3 |
0,3,1,25, MKOSO(Kanalbelegung)+7 , 8,8,8, // poti4 |
0,3,1,25, MKOSO(Kanalbelegung)+8 , 9,9,9, // poti5 |
0,3,1,25, MKOSO(Kanalbelegung)+9 , 10,10,10, // poti6 |
0,3,1,25, MKOSO(Kanalbelegung)+10, 11,11,11, // poti7 |
0,3,1,25, MKOSO(Kanalbelegung)+11, 12,12,12, // poti8 |
0,0,0,12, MKOSO(MotorSafetySwitch), 0,0,0, // Motor Sicherungsswitch |
0,2,0,0x04, MKOSO(ExtraConfig), 0,0,0, // erweiterte signal pruefung |
0,6,0,6, MKOSO(Receiver), 1,1,1, |
// group 1 (main) 16-23 |
1,2,0,0x01, MKOSO(GlobalConfig), 0,0,0, // hoehenregler |
1,2,0,0x20, MKOSO(GlobalConfig), 1,1,1, // gps |
1,2,0,0x08, MKOSO(GlobalConfig), 1,1,1, // kompass |
1,2,0,0x10, MKOSO(GlobalConfig), 0,0,0, // feste ausrichtung |
1,2,0,0x04, MKOSO(ExtraConfig), 0,0,0, // erweiterte signal pruefung |
1,2,0,0x40, MKOSO(GlobalConfig), 1,1,1, // achsentkopplung |
1,2,0,0x80, MKOSO(GlobalConfig), 0,0,0, // drehratenbregrenzung |
1,2,0,0x04, MKOSO(GlobalConfig), 0,0,0, // heading hold |
// group 2 (stick) 24-27 |
2,0,0,20, MKOSO(Stick_P), 10,8,6, |
2,0,0,20, MKOSO(Stick_D), 16,16,10, |
2,1,0,255, MKOSO(StickGier_P), 6,6,4, |
2,1,0,255, MKOSO(ExternalControl), 0,0,0, |
// group3 : looping 28-36 |
3,2,0,0x01, MKOSO(BitConfig), 0,0,0, // oben |
3,2,0,0x02, MKOSO(BitConfig), 0,0,0, // unten |
3,2,0,0x04, MKOSO(BitConfig), 0,0,0, // links |
3,2,0,0x08, MKOSO(BitConfig), 0,0,0, // rechts |
3,1,0,255, MKOSO(LoopGasLimit), 50,50,50, |
3,0,0,247, MKOSO(LoopThreshold), 90,90,90, |
3,0,0,247, MKOSO(LoopHysterese), 50,50,50, |
3,0,0,247, MKOSO(WinkelUmschlagNick), 78,78,78, |
3,0,0,247, MKOSO(WinkelUmschlagRoll), 78,78,78, |
// group 4 (hoehe) 37-50 |
4,2,0,0x01, MKOSO(GlobalConfig), 0,0,0, // hoehenrelger |
4,2,0,0x01, MKOSO(ExtraConfig), 0,0,0, // vario oder hoeenbergenzung |
4,2,0,0x02, MKOSO(GlobalConfig), 1,1,1, // hoehenschalter |
4,2,0,0x02, MKOSO(ExtraConfig), 1,1,1, // variobeep |
4,1,0,255, MKOSO(MaxHoehe), 255,255,255, |
4,0,0,247, MKOSO(Hoehe_MinGas), 30,30,30, |
4,1,0,255, MKOSO(Hoehe_P), 15,15,15, |
4,1,0,255, MKOSO(Luftdruck_D), 30,30,30, |
4,1,0,255, MKOSO(Hoehe_ACC_Wirkung), 0,0,0, |
4,1,0,255, MKOSO(MaxAltitude), 150,150,150, |
4,0,0,247, MKOSO(Hoehe_Verstaerkung), 15,15,15, |
4,0,0,247, MKOSO(Hoehe_HoverBand), 8,8,8, |
4,1,0,255, MKOSO(Hoehe_GPS_Z), 64,64,64, |
4,0,0,160, MKOSO(Hoehe_StickNeutralPoint), 0,0,0, |
// group 5 : kamera 51-66 |
5,1,0,255, MKOSO(ServoNickControl), 128,128,128, |
5,0,0,247, MKOSO(ServoNickComp), 50,50,50, |
5,2,0,0x01, MKOSO(ServoCompInvert), 0,0,0, // nick |
5,0,0,247, MKOSO(ServoNickMin), 15,15,15, |
5,0,0,247, MKOSO(ServoNickMax), 230,230,230, |
5,1,0,255, MKOSO(ServoRollControl), 128,128,128, |
5,0,0,247, MKOSO(ServoRollComp), 85,85,85, |
5,2,0,0x02, MKOSO(ServoCompInvert), 0,0,0, // roll |
5,0,0,247, MKOSO(ServoRollMin), 70,70,70, |
5,0,0,247, MKOSO(ServoRollMax), 220,220,220, |
5,0,2,8, MKOSO(ServoNickRefresh), 4,4,4, |
5,0,0,247, MKOSO(ServoManualControlSpeed), 60,60,60, |
5,5,0,247, MKOSO(CamOrientation), 0,0,0, |
5,1,0,255, MKOSO(Servo3), 125,125,125, |
5,1,0,255, MKOSO(Servo4), 125,125,125, |
5,1,0,255, MKOSO(Servo5), 125,125,125, |
// group 6 : navictrl 67-85 |
6,2,0,0x20, MKOSO(GlobalConfig), 1,1,1, // gps |
6,1,0,255, MKOSO(NaviGpsModeControl), 254,254,254, |
6,1,0,255, MKOSO(NaviGpsGain), 100,100,100, |
6,0,0,247, MKOSO(NaviStickThreshold), 8,8,8, |
6,0,0,247, MKOSO(NaviGpsMinSat), 6,6,6, |
6,1,0,255, MKOSO(NaviGpsP), 90,90,90, |
6,1,0,255, MKOSO(NaviGpsI), 90,90,90, |
6,1,0,255, MKOSO(NaviGpsD), 90,90,90, |
6,1,0,255, MKOSO(NaviGpsPLimit), 75,75,75, |
6,1,0,255, MKOSO(NaviGpsILimit), 85,85,85, |
6,1,0,255, MKOSO(NaviGpsDLimit), 75,75,75, |
6,1,0,255, MKOSO(NaviGpsACC), 0,0,0, |
6,1,0,255, MKOSO(NaviWindCorrection), 90,90,90, |
6,1,0,255, MKOSO(NaviAccCompensation), 42,42,42, |
6,1,0,255, MKOSO(NaviOperatingRadius), 245,245,245, |
6,1,0,255, MKOSO(NaviAngleLimitation), 140,140,140, |
6,0,0,247, MKOSO(NaviPH_LoginTime), 5,5,5, |
6,2,0,0x20, MKOSO(ExtraConfig), 0,0,0, // dynamic ph |
6,0,0,247, MKOSO(ComingHomeAltitude), 0,0,0, |
// group 7 : ausgaenge 86-95 |
7,4,0,255, MKOSO(J16Bitmask), 95,95,95, |
7,1,0,255, MKOSO(J16Timing), 20,20,20, |
7,2,0,0x20, MKOSO(BitConfig), 0,0,0, // Motor_Off_Led1 |
7,2,0,0x10, MKOSO(BitConfig), 1,1,1, // Motor_Blink1 |
7,4,0,255, MKOSO(J17Bitmask), 243,243,243, |
7,1,0,255, MKOSO(J17Timing), 20,20,20, |
7,2,0,0x40, MKOSO(BitConfig), 0,0,0, // Motor_Off_Led2 |
7,2,0,0x80, MKOSO(BitConfig), 1,1,1, // Motor_Blink2 |
7,4,0,255, MKOSO(WARN_J16_Bitmask), 170,170,170, |
7,4,0,255, MKOSO(WARN_J17_Bitmask), 170,170,170, |
// group 8 : versch. 96-107 |
8,0,0,247, MKOSO(Gas_Min), 8,8,8, |
8,0,0,247, MKOSO(Gas_Max), 230,230,230, |
8,1,0,255, MKOSO(KompassWirkung), 64,64,64, |
8,1,0,255, MKOSO(CareFreeModeControl), 0,0,0, // Carefree |
8,2,0,0x40, MKOSO(ExtraConfig), 0,0,0, // teachable Carefree |
8,0,0,247, MKOSO(UnterspannungsWarnung), 33,33,33, |
8,2,0,0x08, MKOSO(ExtraConfig), 0,0,0, // Voltage referenz |
8,0,0,247, MKOSO(NotGasZeit), 90,90,90, |
8,0,0,247, MKOSO(NotGas), 45,45,45, |
8,0,0,247, MKOSO(FailSafeTime), 0,0,0, |
8,2,0,0x80, MKOSO(ExtraConfig), 0,0,0, // Ignore Compass Error |
8,2,0,0x10, MKOSO(ExtraConfig), 0,0,0, // Kein Summer ohne Sender beim Start |
// group 9 : gyro 108-120 |
9,1,0,255, MKOSO(Gyro_P), 90,100,100, |
9,1,0,255, MKOSO(Gyro_I), 120,120,120, |
9,1,0,255, MKOSO(Gyro_D), 10,10,10, |
9,1,0,255, MKOSO(Gyro_Gier_P), 90,100,100, |
9,1,0,255, MKOSO(Gyro_Gier_I), 120,120,120, |
9,1,0,255, MKOSO(DynamicStability), 70,70,70, |
9,2,0,0x80, MKOSO(GlobalConfig), 0,0,0, // drehratenbregrenzung |
9,0,0,247, MKOSO(GyroAccFaktor), 27,27,27, |
9,0,0,247, MKOSO(GyroAccAbgleich), 32,32,32, |
9,1,0,255, MKOSO(I_Faktor), 16,16,16, |
9,0,0,247, MKOSO(Driftkomp), 0,0,0, |
9,0,0,16, MKOSO(Gyro_Stability), 6,6,6, |
9,0,0,247, MKOSO(MotorSmooth), 0,0,0, |
// group 10: benutzer 121-128 |
10,1,0,255, MKOSO(UserParam1), 0,0,0, |
10,1,0,255, MKOSO(UserParam2), 0,0,0, |
10,1,0,255, MKOSO(UserParam3), 0,0,0, |
10,1,0,255, MKOSO(UserParam4), 0,0,0, |
10,1,0,255, MKOSO(UserParam5), 0,0,0, |
10,1,0,255, MKOSO(UserParam6), 0,0,0, |
10,1,0,255, MKOSO(UserParam7), 0,0,0, |
10,1,0,255, MKOSO(UserParam8), 0,0,0, |
// group 11: achskoppl 129-132 |
11,2,0,0x40, MKOSO(GlobalConfig), 0,0,0, // achsentkopplung |
11,1,0,255, MKOSO(AchsKopplung1), 90,90,90, |
11,1,0,255, MKOSO(AchsKopplung2), 55,55,55, |
11,1,0,255, MKOSO(CouplingYawCorrection), 70,70,70, |
// group 12: mixer 133 |
12,5,0,23,MKOSO(OrientationAngle), 0,0,0, |
// group 13 (easy-setup) 134-144 |
13,2,0,0x01, MKOSO(GlobalConfig), 0,0,0, // hoehenrelger |
13,1,0,255, MKOSO(MaxHoehe), 255,255,255, |
13,0,0,160, MKOSO(Hoehe_StickNeutralPoint), 0,0,0, |
13,2,0,0x20, MKOSO(GlobalConfig), 1,1,1, // gps |
13,1,0,255, MKOSO(NaviGpsModeControl), 254,254,254, |
13,2,0,0x20, MKOSO(ExtraConfig), 0,0,0, // dynamic ph |
13,0,0,247, MKOSO(ComingHomeAltitude), 0,0,0, |
13,1,0,255, MKOSO(CareFreeModeControl), 0,0,0, // Carefree |
13,2,0,0x40, MKOSO(ExtraConfig), 0,0,0, // teachable Carefree |
13,0,0,12, MKOSO(MotorSafetySwitch), 0,0,0, // Motor Sicherungsswitch |
13,5,0,23, MKOSO(OrientationAngle), 0,0,0, |
}; |
//-------------------------------------------------------------- |
#define ITEMS_RX 7 |
prog_char param_items_rx[ITEMS_RX][17]= // zeilen,zeichen+1 |
{ |
"PPM ", |
"Spektrum ", |
"Spektrum HiRes ", |
"Spektrum LoRes ", |
"Jeti ", |
"ACT DSL ", |
"HOTT ", |
}; |
//-------------------------------------------------------------- |
void edit_parameter(void) |
{ |
SwitchToFC(); |
// uint8_t setting; |
setting = display_settings_menu(); |
if(setting == 255) |
return; |
if(setting == 6) |
{ |
copy_setting(); |
return; |
} |
lcd_cls(); |
// lcd_printp_at (0, 0, PSTR(" Setting x "), 2); |
lcd_puts_at(0, 0, strGet(PARA_SETTINGS), 2); |
lcd_putc (9, 0, (setting + 48), 2); // ASCII ab 48 (hex 30) beginnt 0 - 9 |
// lcd_printp_at (3, 2, PSTR("ändern"), 0); |
// lcd_printp_at (3, 3, PSTR("aktivieren"), 0); |
lcd_puts_at(3, 2, strGet(PARA_CHANGE), 0); |
lcd_puts_at(3, 3, strGet(PARA_AKTIVI), 0); |
// lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
uint8_t val = menu_choose2 (2, 3, 2, 0, 0); |
if (val == 255) |
return; |
if(val == 3) |
{ |
load_setting(setting); |
uint8_t setting_written = write_setting(setting); |
if(setting_written == setting) |
{ |
lcd_cls_line (0,2,21); |
lcd_cls_line (0,3,21); |
// lcd_printp_at (11, 0, PSTR("aktiviert"), 0); |
lcd_puts_at(11, 0, strGet(PARA_AKTIV), 0); |
} |
else |
{ |
lcd_cls_line (0,2,21); |
lcd_cls_line (0,3,21); |
// lcd_printp_at (0, 4, PSTR("Error"), 0); |
lcd_puts_at(0, 4, strGet(FEHLER), 0); |
} |
_delay_ms(2000); |
return; |
} |
if(setting == 255) |
return; |
uint8_t setting_loaded = load_setting(setting); |
if(setting_loaded == 255) |
return; |
offset = 0; |
dmode = 0; |
target_pos = 1; |
changes =0; |
uint8_t group =0; |
do |
{ |
group = display_section_menu(); |
if(group != 255) |
{ |
offset2 = 0; |
pmode = 0; |
target_pos2 = 1; |
uint8_t param; |
do |
{ |
param = display_param_menu(group); |
if(param != 255) |
{ |
edit_param(param); |
} |
} |
while(param != 255); |
} |
} |
while(group != 255); |
if(changes == 1) |
{ |
lcd_cls(); |
// lcd_printp_at (0, 0, PSTR(" Setting x speichern?"), 2); |
lcd_puts_at(0, 0, strGet(PARA_SAVESETT), 2); |
lcd_putc (9, 0, (setting + 48), 2); // ASCII ab 48 (hex 30) beginnt 0 - 9 |
write_ndigit_number_u(9, 0, setting, 1, 0); |
// lcd_printp_at (3, 2, PSTR("Ja"), 0); |
// lcd_printp_at (3, 3, PSTR("Nein"), 0); |
lcd_puts_at(3, 2, strGet(YES), 0); |
lcd_puts_at(3, 3, strGet(NOO), 0); |
// lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
uint8_t val = menu_choose2 (2, 3, 2, 0, 0); |
if(val == 2) |
{ |
uint8_t setting_written = write_setting(setting); |
if(setting_written == setting) |
{ |
// lcd_printp_at (3, 4, PSTR("Gespeichert und"), 0); |
lcd_puts_at(3, 4, strGet(PARA_SETTSAVED), 0); |
// lcd_printp_at (3, 5, PSTR("Aktiviert"), 0); |
lcd_puts_at(3, 5, strGet(PARA_AKTIV), 0); |
} |
else |
{ |
// lcd_printp_at (0, 4, PSTR("Error"), 0); |
lcd_puts_at(0, 4, strGet(FEHLER), 0); |
} |
timer = 100; |
while (timer > 0); |
} |
} |
} |
//-------------------------------------------------------------- |
void copy_setting(void) |
{ |
uint8_t fromsetting = 3; |
uint8_t tosetting = 5; |
lcd_cls(); |
// lcd_printp_at (0, 1, PSTR("Kopiere Setting"), 0); |
// lcd_printp_at (0, 3, PSTR("von x nach y"), 0); |
// lcd_printp_at (0, 7, PSTR("von nach Ende OK"), 0); |
lcd_puts_at(0, 1, strGet(PARA_COPY), 0); |
lcd_puts_at(0, 3, strGet(PARA_FROMTO), 0); |
lcd_puts_at(0, 7, strGet(PARA_ENDE), 0); |
do |
{ |
write_ndigit_number_u(5,3,fromsetting, 1,0); |
write_ndigit_number_u(14,3,tosetting, 1,0); |
if(get_key_press (1 << KEY_MINUS)) |
{ |
fromsetting++; |
if(fromsetting == 6) fromsetting = 1; |
} |
if(get_key_press (1 << KEY_PLUS)) |
{ |
tosetting++; |
if(tosetting == 6) tosetting = 1; |
} |
if(get_key_press (1 << KEY_ENTER)) |
{ |
lcd_printp_at (0, 5, PSTR("Wirklich Kopieren?"), 0); |
lcd_puts_at(0, 5, strGet(PARA_COPYQ), 0); |
// lcd_printp_at (0, 7, PSTR(" Ende OK"), 0); |
lcd_puts_at(12, 7, strGet(KEYLINE4), 0); |
do |
{ |
if(get_key_press (1 << KEY_ENTER)) |
{ |
uint8_t loaded = load_setting(fromsetting); |
if(loaded == fromsetting) |
{ |
uint8_t written = write_setting(tosetting); |
if(written == tosetting) |
{ |
lcd_printp_at (0, 5, PSTR("Kopiert und Aktiviert"), 0); |
lcd_puts_at(0, 5, strGet(PARA_COPYACTIV), 0); |
} |
else |
{ |
// lcd_printp_at (0, 5, PSTR("Fehler"), 0); |
lcd_puts_at(0, 5, strGet(FEHLER), 0); |
lcd_cls_line (6, 5, 14); |
} |
} |
else |
{ |
// lcd_printp_at (0, 5, PSTR("Fehler"), 0); |
lcd_puts_at(0, 5, strGet(FEHLER), 0); |
lcd_cls_line (6, 5, 14); |
} |
timer = 100; |
while (timer > 0); |
return; |
} |
} |
while (!get_key_press (1 << KEY_ESC)); |
get_key_press(KEY_ALL); |
lcd_cls_line (0, 5, 21); |
// lcd_printp_at (0, 7, PSTR("von nach Ende OK"), 0); |
lcd_puts_at(0, 7, strGet(PARA_ENDE), 0); |
} |
} |
while (!get_key_press (1 << KEY_ESC)); |
get_key_press(KEY_ALL); |
} |
//-------------------------------------------------------------- |
void edit_param(uint8_t param) |
{ |
lcd_cls(); |
uint8_t type = pgm_read_byte(param_config+(8*param)+1); |
// lcd_printp_at (0, 0, PSTR(" Ändere Setting: "), 2); |
lcd_puts_at(0, 0, strGet(PARA_CHANGESETT), 2); |
// lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
if(type != 6) |
lcd_printp_at(0,2,param_names[param][DisplayLanguage], 0); |
//------------------------------------------------------- |
if(type == 0) // ohne poti |
{ |
lcd_printp_at (4, 4, PSTR("( - ) (d: )"), 0); |
lcd_printp_at (12, 6, PSTR("Std."), 0); |
// lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0); |
lcd_puts_at(0, 7, strGet(KEYLINE2), 0); |
uint8_t min = pgm_read_byte(param_config+(8*param)+2); |
uint8_t max = pgm_read_byte(param_config+(8*param)+3); |
uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)); |
uint8_t defaultvalue = pgm_read_byte(param_config+(8*param)+4 + setting ); // 5 - 7 |
uint8_t newvalue = value; |
write_ndigit_number_u (5, 4, min, 3, 0); |
write_ndigit_number_u (9, 4, max, 3, 0); |
write_ndigit_number_u (17, 4, defaultvalue, 3, 0); |
do |
{ |
write_ndigit_number_u (0, 4, newvalue, 3, 0); |
lcd_frect ((8*0), (8*5), (newvalue * (16*8) / max), 6, 1); |
if(max >= 50) |
{ |
if(get_key_press (1 << KEY_PLUS) | get_key_long_rpt_sp ((1 << KEY_PLUS), 3)) |
{ |
if((newvalue+1) <= max) |
newvalue++; |
} |
if(get_key_press (1 << KEY_MINUS) | get_key_long_rpt_sp ((1 << KEY_MINUS), 3)) |
{ |
if((newvalue-1) >= min) |
{ |
lcd_frect (((newvalue - 1) * (16*8) / max), (8*5), (16*8), 6, 0); |
// lcd_frect ((newvalue * (16*8) / max), (8*5), ((16*8) / max), 6, 0); |
newvalue--; |
} |
} |
} |
else |
{ |
if(get_key_press (1 << KEY_PLUS) | get_key_long_rpt_sp ((1 << KEY_PLUS), 2)) |
{ |
if((newvalue+1) <= max) |
newvalue++; |
} |
if(get_key_press (1 << KEY_MINUS) | get_key_long_rpt_sp ((1 << KEY_MINUS), 2)) |
{ |
if((newvalue-1) >= min) |
{ |
lcd_frect (((newvalue - 1) * (16*8) / max), (8*5), (16*8), 6, 0); |
// lcd_frect ((newvalue * (16*8) / max), (8*5), ((16*8) / max), 6, 0); |
newvalue--; |
} |
} |
} |
if(get_key_long (1 << KEY_ESC)) |
{ |
lcd_frect ((8*0), (8*5), (16*8), 6, 0); |
newvalue = defaultvalue; |
} |
if(get_key_short (1 << KEY_ENTER)) |
{ |
if(newvalue != value) |
{ |
*(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)) = newvalue; |
changes=1; |
} |
break; |
} |
} |
while (!get_key_short (1 << KEY_ESC)); |
get_key_press(KEY_ALL); |
} |
//------------------------------------------------------- |
if(type == 1) // mit poti |
{ |
lcd_printp_at (4, 4, PSTR("(0-247-P8)(d:Po )"), 0); |
lcd_printp_at (12, 6, PSTR("Std."), 0); |
// lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0); |
lcd_puts_at(0, 7, strGet(KEYLINE2), 0); |
uint8_t min = pgm_read_byte(param_config+(8*param)+2); |
uint8_t max = pgm_read_byte(param_config+(8*param)+3); |
uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)); |
uint8_t defaultvalue = pgm_read_byte(param_config+(8*param)+4 + setting ); // 5 - 7 |
uint8_t newvalue = value; |
uint8_t mode = 0; |
if(defaultvalue > 247) |
{ |
lcd_printp_at (17, 4, PSTR("Po )"), 0); |
write_ndigit_number_u (19, 4, 256-defaultvalue, 1, 0); |
} |
else |
write_ndigit_number_u (17, 4, defaultvalue, 3, 0); |
if(value > 247) |
mode = 1; |
do |
{ |
if(newvalue > 247) |
mode = 1; |
else |
mode = 0; |
if(mode == 0) |
{ |
write_ndigit_number_u (0, 4, newvalue, 3, 0); |
lcd_frect ((8*0), (8*5), (newvalue * (16*8) / max), 6, 1); |
if(get_key_press (1 << KEY_PLUS) | get_key_long_rpt_sp ((1 << KEY_PLUS), 3)) |
{ |
if((newvalue+1) <= max) |
newvalue++; |
if(newvalue > 247) |
{ |
lcd_frect ((8*0), (8*5), (16*8), 6, 0); |
newvalue = 255; |
} |
} |
if(get_key_press (1 << KEY_MINUS) | get_key_long_rpt_sp ((1 << KEY_MINUS), 3)) |
{ |
if((newvalue-1)>=min) |
{ |
lcd_frect (((newvalue - 1) * (16*8) / max), (8*5), (16*8), 6, 0); |
// lcd_frect ((newvalue * (16*8) / max), (8*5), ((16*8) / max), 6, 0); |
newvalue--; |
} |
} |
} |
else |
{ |
lcd_printp_at (0, 4, PSTR("Po"), 0); |
write_ndigit_number_u (2, 4, 256 - newvalue, 1, 0); |
lcd_frect ((8*0), (8*5), ((256 - newvalue) * (16*8) / 8), 6, 1); |
if(get_key_press (1 << KEY_PLUS) | get_key_long_rpt_sp ((1 << KEY_PLUS), 1)) |
{ |
if(newvalue - 1 > 247) |
{ |
newvalue--; |
} |
} |
if(get_key_press (1 << KEY_MINUS) | get_key_long_rpt_sp ((1 << KEY_MINUS), 1)) |
{ |
lcd_frect (((255 - newvalue) * (16*8) / 8), (8*5), (16*8), 6, 0); |
// lcd_frect (((255 - newvalue) * (16*8) / 8), (8*5), ((16*8) / 8), 6, 0); |
newvalue++; |
if(newvalue == 0) |
{ |
lcd_frect ((8*0), (8*5), (16*8), 6, 0); // balken löschen |
newvalue = 247; |
} |
} |
} |
if(get_key_long (1 << KEY_ESC)) |
{ |
lcd_frect ((8*0), (8*5), (16*8), 6, 0); |
newvalue = defaultvalue; |
} |
if(get_key_short (1 << KEY_ENTER)) |
{ |
if(newvalue != value) |
{ |
*(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)) = newvalue; |
changes=1; |
} |
break; |
} |
} |
while (!get_key_short (1 << KEY_ESC)); |
get_key_press(KEY_ALL); |
} |
//------------------------------------------------------- |
if(type == 2) // ja/nein |
{ |
// lcd_printp_at (3, 4, PSTR("Ja"), 0); |
// lcd_printp_at (3, 5, PSTR("Nein"), 0); |
lcd_puts_at(3, 4, strGet(YES), 0); |
lcd_puts_at(3, 5, strGet(NOO), 0); |
// lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
uint8_t bitmap = pgm_read_byte(param_config+(8*param)+3); |
uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)); |
uint8_t defaultvalue = pgm_read_byte(param_config+(8*param)+4 + setting ); // 5 - 7 |
uint8_t newvalue = value; |
if(defaultvalue == 1) |
lcd_printp_at (8, 4, PSTR("*"), 0); |
if(defaultvalue == 0) |
lcd_printp_at (8, 5, PSTR("*"), 0); |
do |
{ |
if(newvalue & bitmap) |
{ |
lcd_printp_at (1, 4, PSTR("\x1d"), 0); |
lcd_printp_at (1, 5, PSTR(" "), 0); |
} |
else |
{ |
lcd_printp_at (1, 4, PSTR(" "), 0); |
lcd_printp_at (1, 5, PSTR("\x1d"), 0); |
} |
if((get_key_press (1 << KEY_MINUS)) && (!(newvalue & bitmap))) |
newvalue ^= bitmap; |
if((get_key_press (1 << KEY_PLUS)) && (newvalue & bitmap)) |
newvalue ^= bitmap; |
if(get_key_press (1 << KEY_ENTER)) |
{ |
if(newvalue != value) |
{ |
*(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)) = newvalue; |
changes=1; |
} |
break; |
} |
} |
while (!get_key_short (1 << KEY_ESC)); |
get_key_press(KEY_ALL); |
} |
//------------------------------------------------------- |
if(type == 3) // serCH |
{ |
lcd_printp_at (4, 4, PSTR("(1-S12/W) (d: )"), 0); |
lcd_printp_at (12, 6, PSTR("Std."), 0); |
// lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0); |
lcd_puts_at(0, 7, strGet(KEYLINE2), 0); |
uint8_t min = pgm_read_byte(param_config+(8*param)+2); |
uint8_t max = pgm_read_byte(param_config+(8*param)+3); |
uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)); |
uint8_t defaultvalue = pgm_read_byte(param_config+(8*param)+4 + setting ); // 5 - 7 |
uint8_t newvalue = value; |
write_ndigit_number_u (17, 4, defaultvalue, 3, 0); |
do |
{ |
if (newvalue<=(max-13)) |
write_ndigit_number_u (0, 4, newvalue, 3, 0); |
else |
{ |
if (newvalue<=(max-1)) |
{ |
lcd_printp_at (0, 4, PSTR("S"), 0); |
write_ndigit_number_u (1, 4, (newvalue-12), 2, 0); |
} |
} |
if (newvalue==max) |
lcd_printp_at (0, 4, PSTR("WPE"), 0); |
lcd_frect ((8*0), (8*5), (newvalue * (16*8)) / max, 6, 1); |
if(get_key_press (1 << KEY_PLUS) | get_key_long_rpt_sp ((1 << KEY_PLUS), 2)) |
{ |
if((newvalue+1) <= max) |
newvalue++; |
} |
if(get_key_press (1 << KEY_MINUS) | get_key_long_rpt_sp ((1 << KEY_MINUS), 2)) |
{ |
if((newvalue-1)>=min) |
{ |
lcd_frect (((newvalue - 1) * (16*8) / max), (8*5), (16*8), 6, 0); |
newvalue--; |
} |
} |
if(get_key_long (1 << KEY_ESC)) |
{ |
lcd_frect ((8*0), (8*5), (16*8), 6, 0); |
newvalue = defaultvalue; |
} |
if(get_key_short (1 << KEY_ENTER)) |
{ |
if(newvalue != value) |
{ |
*(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)) = newvalue; |
changes=1; |
} |
break; |
} |
} |
while (!get_key_short (1 << KEY_ESC)); |
get_key_press(KEY_ALL); |
} |
//------------------------------------------------------- |
if(type == 4) // led bitfeld |
{ |
// TODO: Übersetzung |
lcd_printp_at (0, 7, PSTR(" \x19 0\x11I Ende OK"), 0); |
if (param == 93 || param == 94) |
// lcd_printp_at (5, 6, PSTR("aktiv"), 0); |
lcd_puts_at(5, 6, strGet(AKTIV), 0); |
uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)); |
uint8_t newvalue = value; |
uint8_t pos = 0; |
do |
{ |
for(ii = 0; ii < 8; ii++) |
{ |
if(newvalue & (1 << ii)) |
lcd_printp_at (8-ii, 4,PSTR("1"),0); |
else |
lcd_printp_at (8-ii, 4,PSTR("0"),0); |
} |
lcd_printp_at (pos+1, 5,PSTR("\x12"),0); |
if(get_key_press (1 << KEY_MINUS)) |
{ |
lcd_printp_at (pos+1, 5,PSTR(" "),0); |
pos++; |
if(pos == 8) |
pos = 0; |
} |
if (param == 93 || param == 94) |
{ |
if(get_key_long (1 << KEY_PLUS)) |
{ |
if (newvalue != 0) |
newvalue = 0; |
else |
newvalue = 170; |
} |
} |
if(get_key_short (1 << KEY_PLUS)) |
newvalue ^= (1<<(7-pos)); |
if(get_key_short (1 << KEY_ENTER)) |
{ |
if(newvalue != value) |
{ |
*(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)) = newvalue; |
changes = 1; |
} |
break; |
} |
} |
while (!get_key_short (1 << KEY_ESC)); |
get_key_press(KEY_ALL); |
} |
//------------------------------------------------------- |
if(type == 5) // Angle |
{ |
// lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0); |
lcd_puts_at(0, 7, strGet(KEYLINE2), 0); |
uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)); |
lcd_ecircle(102, 35, 16, 1); |
uint8_t newvalue = value; |
uint8_t oldvalue = newvalue; |
do |
{ |
if(oldvalue != newvalue) lcd_ecirc_line (102, 35, 15, oldvalue*15, 0); |
oldvalue = newvalue; |
lcd_ecirc_line (102, 35, 15, newvalue*15, 1); |
if(get_key_press (1 << KEY_PLUS) | get_key_long_rpt_sp ((1 << KEY_PLUS), 1)) |
{ |
newvalue++; |
if(newvalue == 24) |
newvalue = 0; |
} |
if(get_key_press (1 << KEY_MINUS) | get_key_long_rpt_sp ((1 << KEY_MINUS), 1)) |
{ |
if(newvalue == 0) |
newvalue = 24; |
newvalue--; |
} |
if(get_key_short (1 << KEY_ENTER)) |
{ |
if(newvalue != value) |
{ |
*(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)) = newvalue; |
changes=1; |
} |
break; |
} |
} |
while (!get_key_short (1 << KEY_ESC)); |
get_key_press(KEY_ALL); |
} |
//------------------------------------------------------- |
if(type == 6) // receiver |
{ |
uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)); |
uint8_t newvalue = value + 1; |
uint8_t val =0; |
uint8_t ii = 0; |
uint8_t offset = 0; |
uint8_t dmode = 0; |
uint8_t target_pos = 1; |
uint8_t size = ITEMS_RX; |
// 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_items_rx[ii+offset], 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_choose3 (1, 5, target_pos,0,1); //menu_choose3 (min, max, start, return_at_start, return_at_end) |
else |
val = menu_choose3 (1, size, target_pos,0,0); |
} |
else |
val = menu_choose3 (2, 5, target_pos,1,1); |
} |
if(dmode == 1) |
{ |
if(offset+7 > size) |
val = menu_choose3 (2, 6, target_pos,1,0); |
else |
val = menu_choose3 (2, 5, target_pos,1,1); |
} |
if(val == 254) // überlauf unten |
{ |
offset++; |
dmode = 1; |
target_pos = 5; |
} |
else if(val == 253) // überlauf oben |
{ |
offset--; |
dmode = 0; |
target_pos = 2; |
} |
else if(val == 252) // ESC |
return; |
else if(val <= size) |
{ |
newvalue = val + offset - 1; |
*(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)) = newvalue; |
changes=1; |
return; |
} |
} |
} |
} |
//-------------------------------------------------------------- |
uint8_t display_param_menu(uint8_t group) |
{ |
uint8_t items[20]; |
uint8_t size=0; |
for(ii = 0;ii < PARAM_COUNT; ii++) |
{ |
if(pgm_read_byte(param_config+(8*ii)) == (group-1)) |
{ |
items[size] = ii; |
size++; |
} |
} |
uint8_t val =0 ; |
while(1) |
{ |
lcd_cls (); |
// lcd_printp_at (0, 0, PSTR(" Wähle Parameter: "), 2); |
lcd_puts_at(0, 0, strGet(PARA_SELECT), 2); |
// lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
ii = 0; |
if(offset2 > 0) |
lcd_printp_at(1,1, PSTR("\x12"), 0); |
for(ii = 0;ii < 6 ; ii++) |
{ |
if((ii+offset2) < size) |
{ |
lcd_printp_at(3,ii+1,param_names[items[ii+offset2]][DisplayLanguage], 0); |
// this reads the the offset in the struct from the pgm configuration table and then reads the value from the struct |
uint8_t type = pgm_read_byte(param_config+(8*items[ii+offset2])+1); |
if(type == 0) |
write_ndigit_number_u (18, ii+1, *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*items[ii+offset2])+4)), 3, 0); |
if(type == 1) |
{ |
uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*items[ii+offset2])+4)); |
if(value < 248) |
write_ndigit_number_u (18, ii+1, value, 3, 0); |
if(value >= 248) |
{ |
lcd_printp_at (18, ii+1, PSTR(" P"), 0); |
write_ndigit_number_u (20, ii+1, 256-value, 1, 0); |
} |
} |
if(type == 2) |
{ |
uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*items[ii+offset2])+4)); |
uint8_t bitmap = pgm_read_byte(param_config+(8*items[ii+offset2])+3); |
if(value & bitmap) |
lcd_printp_at (18, ii+1, PSTR(" J"), 0); |
else |
lcd_printp_at (18, ii+1, PSTR(" N"), 0); |
} |
if(type == 3) |
{ |
uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*items[ii+offset2])+4)); |
if (value<=12) |
write_ndigit_number_u (18, ii+1, value, 3, 0); |
else |
if (value<=(24)) |
{ |
lcd_printp_at (18, ii+1, PSTR("S"), 0); |
write_ndigit_number_u (19, ii+1, (value-12), 2, 0); |
} |
if (value==25) |
lcd_printp_at (18, ii+1, PSTR("WPE"), 0); |
} |
if(type == 4) |
write_ndigit_number_u (18, ii+1, *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*items[ii+offset2])+4)), 3, 0); |
if(type == 5) |
write_ndigit_number_u (18, ii+1, (*(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*items[ii+offset2])+4)))*15, 3, 0); |
if(type == 6) // Empfänger Typ |
{ |
uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*items[ii+offset2])+4)); |
if(value == 0) |
lcd_printp_at (18, ii+1, PSTR("PPM"), 0); |
else if(value == 1) |
lcd_printp_at (18, ii+1, PSTR("Spe"), 0); |
else if(value == 2) |
lcd_printp_at (18, ii+1, PSTR("SpH"), 0); |
else if(value == 3) |
lcd_printp_at (18, ii+1, PSTR("SpL"), 0); |
else if(value == 4) |
lcd_printp_at (18, ii+1, PSTR("Jet"), 0); |
else if(value == 5) |
lcd_printp_at (18, ii+1, PSTR("ACT"), 0); |
else if(value == 6) |
lcd_printp_at (18, ii+1, PSTR("HoT"), 0); |
else |
write_ndigit_number_u (18, ii+1, *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*items[ii+offset2])+4)), 3, 0); |
} |
} |
if((ii == 5)&&(ii+offset2 < (size-1))) |
lcd_printp_at(1,6, PSTR("\x13"), 0); |
} |
if(pmode == 0) |
{ |
if(offset2 == 0) |
{ |
if(size > 6) |
val = menu_choose2 (1, 5, target_pos2,0,1); |
else |
val = menu_choose2 (1, size, target_pos2,0,0); |
} |
else |
val = menu_choose2 (2, 5, target_pos2,1,1); |
} |
if(pmode == 1) |
{ |
if(offset2+7 > size) |
val = menu_choose2 (2, 6, target_pos2,1,0); |
else |
val = menu_choose2 (2, 5, target_pos2,1,1); |
} |
if(val == 254) |
{ |
offset2++; |
pmode = 1; |
target_pos2 = 5; |
} |
else if(val == 253) |
{ |
offset2--; |
pmode = 0; |
target_pos2 = 2; |
} |
else |
break; |
} |
if(val != 255) |
{ |
target_pos2=val; |
return items[val+offset2-1]; |
} |
else |
return val; |
} |
//-------------------------------------------------------------- |
uint8_t display_section_menu(void) |
{ |
uint8_t size = PAGES; |
uint8_t val =0; |
while(1) |
{ |
lcd_cls (); |
// lcd_printp_at (0, 0, PSTR(" Wähle Seite: "), 2); |
lcd_puts_at(0, 7, strGet(PARA_SEITE),2); |
// lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
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_pages[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 |
break; |
} |
if(val != 255) |
{ |
target_pos=val; |
return val+offset; |
} |
else |
return val; |
} |
//-------------------------------------------------------------- |
uint8_t display_settings_menu (void) |
{ |
uint8_t status; |
lcd_cls (); |
// lcd_printp_at (0, 0, PSTR(" Wähle Setting: "), 2); |
lcd_puts_at(0, 0, strGet(PARA_SELSETT), 2); |
// lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
for(setting=1;setting<6;setting++) |
{ |
status = load_setting(setting); |
if(status == 255) |
return 255; |
write_ndigit_number_u (3, setting, status, 1, 0); |
lcd_print_at (5,setting,(uint8_t*)mk_param_struct->Name, 0); |
} |
// lcd_printp_at (3, 6, PSTR("Kopiere Setting"), 0); |
lcd_puts_at(3, 6, strGet(PARA_COPY), 0); |
status = load_setting(0xff); |
if(status == 255) |
return 255; |
setting = menu_choose (1, 6, 1,status); |
return setting; |
} |
//-------------------------------------------------------------- |
uint8_t load_setting(uint8_t setting) |
{ |
mode = 'Q'; // Settings |
uint8_t timeout = 50; |
rxd_buffer_locked = FALSE; |
while (!rxd_buffer_locked && timeout) |
{ |
SendOutData ('q', ADDRESS_FC, 1, &setting, 1); |
// _delay_ms(50); |
timer = 20; |
while (timer > 0); |
timeout--; |
} |
if (timeout != 0) |
{ |
Decode64 (); |
setting = *pRxData; |
mk_param_struct = (mk_param_struct_t *) (pRxData + 1) ; |
} |
else |
{ // timeout occured |
// lcd_printp_at (0, 2, PSTR("Fehler: keine Daten"), 0); |
lcd_puts_at(0, 2, strGet(OSD_ERROR), 0); |
timer = 100; |
while (timer > 0); |
setting = 255; |
} |
return setting; |
} |
//-------------------------------------------------------------- |
uint8_t write_setting(uint8_t setting) |
{ |
mode = 'S'; // Settings |
uint8_t timeout = 50; |
rxd_buffer_locked = FALSE; |
while (!rxd_buffer_locked && timeout) |
{ |
SendOutData ('s', ADDRESS_FC, 2, &setting, 1, mk_param_struct, sizeof(mk_param_struct_t)); |
// _delay_ms(50); |
timer = 20; |
while (timer > 0); |
timeout--; |
} |
if (timeout != 0) |
{ |
Decode64 (); |
setting = *pRxData; |
} |
else // timeout occured |
{ |
// lcd_printp_at (0, 2, PSTR("Fehler: keine Daten"), 0); |
lcd_puts_at(0, 2, strGet(OSD_ERROR), 0); |
timer = 100; |
while (timer > 0); |
setting = 255; |
} |
return setting; |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/parameter.h |
---|
0,0 → 1,46 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
#ifndef _PARAMETER_H |
#define _PARAMETER_H |
void edit_parameter (void); |
uint8_t load_setting(uint8_t setting); |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/parameter_names.h |
---|
0,0 → 1,267 |
/***************************************************************************** |
* Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* Copyright (C) 2011 Christian "Cebra" Brandtner, brandtner@brandtner.net * |
* Copyright (C) 2011 Harald Bongartz * |
* * |
* This program is free software; you can redistribute it and/or modify * |
* it under the terms of the GNU General Public License as published by * |
* the Free Software Foundation; either version 2 of the License. * |
* * |
* This program is distributed in the hope that it will be useful, * |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
* GNU General Public License for more details. * |
* * |
* You should have received a copy of the GNU General Public License * |
* along with this program; if not, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
* * |
* Credits to: * |
* Holger Buss & Ingo Busker from mikrokopter.de for the MK project + SVN * |
* http://www.mikrokopter.de * |
* Gregor "killagreg" Stobrawa for his version of the MK code * |
* Thomas Kaiser "thkais" for the original project. See * |
* http://www.ft-fanpage.de/mikrokopter/ * |
* http://forum.mikrokopter.de/topic-4061-1.html * |
* Claas Anders "CaScAdE" Rathje for providing the font and his C-OSD code * |
* http://www.mylifesucks.de/oss/c-osd/ * |
* Harald Bongartz "HaraldB" for providing his Ideas and Code for usibility* |
*****************************************************************************/ |
#define PAGES 14 |
#define PARAM_COUNT 144 |
#define PARAM_LENGTH 15 |
#define PARAM_NUM_LANG 4 |
// German Englisch Franzïösisch Holländisch |
prog_char param_pages[PAGES][PARAM_NUM_LANG][PARAM_LENGTH]= // zeilen,zeichen+1 |
{ |
{"Kanäle ","Channel ","Canaux ","Kanaal "}, |
{"Konfiguration ","main ","Config ","Configuratie "}, |
{"Stick ","stick ","Manche ","Stick "}, |
{"Looping ","Looping ","Looping ","Looping "}, |
{"Höhe ","Altitude ","Altitude ","Hoogte "}, |
{"Kamera ","Camera ","Camera ","Camera "}, |
{"NaviCtrl ","NaviCtrl ","NaviCtrl ","NaviCtrl "}, |
{"Ausgänge ","Outputs ","Sorties ","Uitgangen "}, |
{"Verschiedenes ","Divers ","Divers ","Diversen "}, |
{"Gyro ","Gyro ","Gyro ","Gyro "}, |
{"Benutzer ","User ","Parametres ","Gebruiker "}, |
{"Achskopplung ","Coupl Axes ","Coupl Axes ","Koppeling Ass "}, |
{"Mixer-Setup ","Config Mix ","Config Mix ","Config. Mixer "}, |
{"Easy Setup ","Config Easy ","Config Easy ","Config. easy "}, |
}; |
//Namen |
prog_char param_names[PARAM_COUNT][PARAM_NUM_LANG][PARAM_LENGTH]= |
{ |
// group 0 (kanaele) 1-15 |
{"Gas ","Throttle ","Gaz ","Gas "}, |
{"Gier ","Gier ","Lacet ","Gier "}, |
{"Nick ","Nick ","Tangage ","Nick "}, |
{"Roll ","Roll ","Roulis ","Roll "}, |
{"Poti 1 ","Poti 1 ","Poti 1 ","Poti 1 "}, |
{"Poti 2 ","Poti 2 ","Poti 2 ","Poti 2 "}, |
{"Poti 3 ","Poti 3 ","Poti 3 ","Poti 3 "}, |
{"Poti 4 ","Poti 4 ","Poti 4 ","Poti 4 "}, |
{"Poti 5 ","Poti 5 ","Poti 5 ","Poti 5 "}, |
{"Poti 6 ","Poti 6 ","Poti 6 ","Poti 6 "}, |
{"Poti 7 ","Poti 7 ","Poti 7 ","Poti 7 "}, |
{"Poti 8 ","Poti 8 ","Poti 8 ","Poti 8 "}, |
{"Motor Sich.Sch","Mot.Safety Sw.","Mot.Safety Sw.","Mot.saf.schak."}, |
{"Erw. Sig. Pr. ","Enh. Sig.Check","Recep Renforce","Uitg.Sig.Check"}, |
{"Empfänger Typ ","Receiver Type ","Type Recepteur","Ontvang. Type "}, |
// group 1 (main) 16-23 |
{"Höhenregeler ","Ctrl Altitude ","Ctrl Altitude ","Ctrl Hoogte "}, |
{"GPS ","GPS ","GPS ","GPS "}, |
{"Kompass ","Compass ","Compas ","Kompas "}, |
{"KompFest Ausr.","CompOrient.Fix","Maintien Cap ","Kompas vast "}, |
{"Erw. Sig. Pr. ","Sens.RcvSigVal","Ctrl Ren Recep","ExtRec Signaal"}, |
{"Achs(e.)koppl.","Axis Couping ","Decouplage Axe","As koppeling "}, |
{"Drehratenbegr.","RotRate limit.","Limit Vit. Rot","RotRate limit."}, |
{"Heading Hold ","Nick/Roll ","Orient. Fixe ","Koers vast "}, |
// group 2 (stick) 24-27 |
{"Nick/Roll P ","Nick/Roll P ","Roul/Tang P ","Nick/Roll P "}, |
{"Nick/Roll D ","Nick/Roll D ","Roul/Tang D ","Nick/Roll D "}, |
{"Gier P ","Gier P ","Lacet P ","Gier P "}, |
{"Externe Kontr.","Extern Ctrl ","Ctrl Externe ","Extern Control"}, |
// group3 : (looping) 28-36 |
{"Looping oben ","Looping up ","Looping Avant ","Looping omhoog"}, |
{"Looping unten ","Looping down ","Looping Arrier","Looping bened."}, |
{"Looping links ","Looping left ","Looping Gauche","Looping links "}, |
{"Looping rechts","Looping right ","Looping Droite","Looping rechts"}, |
{"Gas Limit ","Throttle Limit","Limite Gaz ","Gas Limiet "}, |
{"Ansprechschw. ","Seuil Reponse ","Seuil Reponse ","Drempelwaarde "}, |
{"Hysterese ","Hysteresis ","Hysteresis ","Hysterese "}, |
{"Umkehrp. Nick ","Nick Invers ","Invers Roulis ","Nick geinvert."}, |
{"Umkehrp. Roll ","Roll Invers ","Invers Tangage","Roll geinvert."}, |
// group 4 (hoehe) 37-50 |
{"Höhenregelung ","Altitude Ctrl ","Ctrl Altitude ","Hoogte Control"}, |
{"J:HBeg,N:Vario","Y:LimH,N:Vario","Y:LimH,N:Vario","Y:LimH,N:Vario"}, |
{"Schalter f. H.","Switch f. High","Swith Hauteur ","Schak. Hoogte "}, |
{"akust. Vario ","acoustic Vario","Vario Acoustic","Akoest. Vario "}, |
{"Sollhöhe ","Setpoint ","Hauteur Max ","Gewenste hoogt"}, |
{"Min. Gas ","min. throttle ","Gaz Min ","Minimaal gas "}, |
{"Höhe P ","Altitude P ","Altitude P ","Hoogte P "}, |
{"Luftdruck D ","Barometric D ","Pression D ","Barometr. D "}, |
{"Z-ACC ","ACC Z ","ACC Z ","ACC Z "}, |
{"Max. Höhe ","Max. High ","Max. High ","Max. hoogte "}, |
{"Verstärkung/R ","gain/rate ","Gain/Frequence","Verst./rate "}, |
{"Schwebegas +/-","hoover varia. ","Var Vol Stat ","hoover varia. "}, |
{"GPS Z ","GPS Z ","GPS Z ","GPS Z "}, |
{"Stick Neutr. P","stick neutr. P","Pos Neutre Man","stick neutr. P"}, |
// group 5 : (kamera) 51-66 |
{"Nick S. Anst. ","nick serv ctrl","Asserv Tangage","nick serv ctrl"}, |
{"Nick Kompens. ","nick compens. ","Comp Tangage ","nick compens. "}, |
{"Nick Umkehren ","nick inv. dir.","Inverser Roul ","nick inv.rich."}, |
{"Nick Servo min","nick servo min","Servo Min ","nick servo min"}, |
{"Nick Servo max","nick servo max","Servo Max ","nick servo max"}, |
{"Roll S. Anst. ","roll serv ctrl","Asserv Roulis ","roll serv ctrl"}, |
{"Roll Kompens. ","roll compens. ","Comp Tangage ","roll compens. "}, |
{"Roll Umkehren ","roll inv. dir.","Inverser Tang ","roll omkeren "}, |
{"Roll Servo min","roll servo min","Servo Min ","roll servo min"}, |
{"Roll Servo max","roll servo max","Servo Max ","roll servo max"}, |
{"Anst. Geschw. ","servo refresh ","Taux Refresh ","Servo refresh "}, |
{"Manuelle Gesch","manuell Speed ","Vitesse Man. ","Snelh.handbed."}, |
{"Cam Richtung ","Cam Orient ","Cam Orient ","Camera richt. "}, |
{"Servo 3 ","Servo 3 ","Servo 3 ","Servo 3 "}, |
{"Servo 4 ","Servo 4 ","Servo 4 ","Servo 4 "}, |
{"Servo 5 ","Servo 5 ","Servo 5 ","Servo 5 "}, |
// group 6 : (navictrl) 67-85 "CH Hoogte " |
{"GPS ","enable GPS ","Activer GPS ","enable GPS "}, |
{"GPS Modus St. ","GPS mode contr","Def Mode GPS ","GPS mode contr"}, |
{"GPS Verstärk. ","GPS Gain ","Gain GPS ","GPS versterk. "}, |
{"GPS St. Schw. ","GPS stick thre","Seuil Manche ","GPS st. dremp."}, |
{"Min. Sat. ","Min. Sat. ","Nbre Min. Sat.","Min. Sat. "}, |
{"GPS-P ","GPS-P ","GPS-P ","GPS-P "}, |
{"GPS-I ","GPS-I ","GPS-I ","GPS-I "}, |
{"GPS-D ","GPS-D ","GPS-D ","GPS-D "}, |
{"P Limit ","Limit P ","Limite P ","Limiet P "}, |
{"I Limit ","Limit I ","Limite I ","Limiet I "}, |
{"D Limit ","Limit D ","Limite D ","Limiet D "}, |
{"GPS Acc ","GPS Acc ","Accel GPS ","GPS Acc "}, |
{"GPS Windkorr. ","GPS Wind Corr.","Correct Vent ","GPS Wind Corr."}, |
{"Bremswirkung ","Speed compens.","Compens Vit ","Remwerking "}, |
{"GPS max. Rad. ","GPS max.radius","Rayon GPS Max ","GPS max.radius"}, |
{"GPS Winkel Li.","GPS angl.limit","Limit Angl GPS","GPS hoek lim. "}, |
{"PH Login time ","PH login time ","Tps Memoris ","PH login tijd "}, |
{"Dynamic PH ","Dynamic PH ","Dynamic PH ","Dynamische PH "}, |
{"CH Höhe ","CH High ","CH High ","CH Hoogte "}, |
// group 7 : (ausgaenge) 86-95 |
{"LED1 Bitmaske ","Out1 Bitmask ","Bitmask S1 ","Uitg1 Bitpatr."}, |
{" Timing ","Out1 Timing ","Horloge S1 ","Uitg1 Timing "}, |
{" sofort an","Activ ","Actif ","Direct aan "}, |
{" n.m.Motor","Act. wi. Motor","Actif Au Repos","Akt. motor uit"}, |
{"LED2 Bitmaske ","Out2 Bitmask ","Bitmask S2 ","Uitg2 Bitpatr."}, |
{" Timing ","Out2 Timing ","Horloge S2 ","Uitg2 Timing "}, |
{" sofort an","Activ ","Actif ","Direct aan "}, |
{" n.m.Motor","Act. wi. Motor","Actif Au Repos","Akt. motor uit"}, |
{"LED1 Vmin.Warn","Out1 undervolt","Al Undervoltag","Uitg1 ondersp."}, |
{"LED2 Vmin.Warn","Out2 undervolt","Al Undervoltag","Uitg2 ondersp."}, |
// group 8 : (verschiedenes) 96-107 |
{"Min. Gas ","min. throttle ","Gaz Min. ","minimaal gas "}, |
{"Max. Gas ","max. throttle ","Gaz Max. ","maximaal gas "}, |
{"Kompasswirkung","compass effect","Effet compas ","Kompas effect "}, |
{"Carefree St. ","Carefree Ctrl ","Carefree Ctrl ","Carefree Ctrl "}, |
{"Teachable Care","Teachable Care","Teachable Care","Teachable Care"}, |
{"Unterspannung ","undervoltage ","Sous Tension ","Onderspanning "}, |
{"Volt Referenz ","Volt Referenz ","Tension Ref ","Ref. spanning "}, |
{"Not Gas Zeit ","Emerg.Thr.Time","Duree secours ","Nood gas tijd "}, |
{"Not Gas ","Emerg.Throttle","Gaz de secours","Nood gas "}, |
{"Fails. CH Time","Fails. CH Time","Fails. CH Time","Fails. CH Tijd"}, |
{"Compass Error ","Compass Error ","Compass Error ","Kompas Error "}, |
{"k.Summer o Sen","Compass Error ","Son Abs Emett ","Kompas Error "}, |
// group 9 : (gyro) 108-120 |
{"Gyro P ","Gyro P ","Gyro P ","Gyro P "}, |
{"Gyro I ","Gyro I ","Gyro I ","Gyro I "}, |
{"Gyro D ","Gyro D ","Gyro D ","Gyro D "}, |
{"Gier P ","Lacet P ","Lacet P ","Gier P "}, |
{"Gier I ","Lacet I ","Lacet I ","Gier I "}, |
{"Dynamische St.","dynamic stabi.","Stab Dynamique","Dynamis. stab."}, |
{"Drehratenbeg. ","RotRate limit.","Limit Dit Rota","Toerental lim."}, |
{"ACC/Gyro Fak. ","ACC/Gyro Fact ","ACC/Gyro Fact ","ACC/Gyro Fact "}, |
{"ACC/Gyro Komp.","Comp ACC/Gyro ","Comp ACC/Gyro ","Comp ACC/Gyro "}, |
{"Hauptregler I ","Main I ","Regul Princ I ","Hoofdregel. I "}, |
{"Drifkompensat.","drift Compens.","Compens Deriv ","Drift compens."}, |
{"Gyro stab. ","Gyro stability","Gyro Stability","Gyro stabilit."}, |
{"Motor smooth ","Motor smooth ","Motor Smooth ","Motor smooth "}, |
// group 10: (benutzer) 121-128 |
{"Parameter 1 ","Parameter 1 ","Parameter 1 ","Parameter 1 "}, |
{"Parameter 2 ","Parameter 2 ","Parameter 2 ","Parameter 2 "}, |
{"Parameter 3 ","Parameter 3 ","Parameter 3 ","Parameter 3 "}, |
{"Parameter 4 ","Parameter 4 ","Parameter 4 ","Parameter 4 "}, |
{"Parameter 5 ","Parameter 5 ","Parameter 5 ","Parameter 5 "}, |
{"Parameter 6 ","Parameter 6 ","Parameter 6 ","Parameter 6 "}, |
{"Parameter 7 ","Parameter 7 ","Parameter 7 ","Parameter 7 "}, |
{"Parameter 8 ","Parameter 8 ","Parameter 8 ","Parameter 8 "}, |
// group 11: (achskopplung) 129-132 |
{"Achs(e.)koppl.","(De)Coupl Axes","(De)Coupl Axes","As koppeling "}, |
{"Gier pos. Kopp","Retroac lacet ","Retroac Lacet ","Gier pos. kop."}, |
{"Nick/Roll Kopp","Retro roul/tan","Retro Roul/Tan","Nick/Roll kop."}, |
{"Gier Korrektur","Correct lacet ","Correct Lacet ","Gier correctie"}, |
// group 12: (mixer) 133 |
{"Orientierung ","Orientierung ","Orientation "}, |
// group 13 (easy) 134-144 |
{"Höhenregelung ","Altitude Ctrl ","Ctrl Altitude ","Hoogte Contr. "}, |
{"Sollhöhe ","Setpoint ","Hauteur Max ","Gewenst.hoogte"}, |
{"Stick Neutr. P","stick neutr. P","Pos Neutre Man","Stick neutr. P"}, |
{"GPS ","enable GPS ","Activer GPS ","Enable GPS "}, |
{"GPS Modus St. ","GPS mode contr","Def mode GPS ","GPS mode contr"}, |
{"Dynamic PH ","Dynamic PH ","Dynamic PH ","Dynamic PH "}, |
{"CH Höhe ","CH High ","CH High ","CH hoogte "}, |
{"Carefree St. ","Carefree Ctrl ","Carefree Ctrl ","Carefree Ctrl "}, |
{"Teachable Care","Teachable Care","Teachable Care","Teachable Care"}, |
{"Motor Sich.Sch","Mot.Safety Sw.","Mot.Safety Sw.","Mot.saf.schak."}, |
{"Orientierung ","Orientation ","Orientierung ","Orientatie "}, |
}; |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/servo.c |
---|
0,0 → 1,156 |
/***************************************************************************** |
* 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 "lcd.h" |
#include "timer.h" |
#include "servo.h" |
#include "messages.h" |
#define SERVO_CORRECT 3.125 |
//-------------------------------------------------------------- |
// |
void servo_test (void) |
{ |
uint8_t chg = 0; |
uint8_t Pos = 150; // 1,5mS |
OCR1A = 150 * SERVO_CORRECT; // Servomitte |
lcd_cls (); |
lcd_printp (PSTR(" Servo Tester "), 2); |
lcd_printp_at (7, 5, PSTR("%"), 0); |
lcd_printp_at (16, 5, PSTR("mS"), 0); |
// lcd_printp_at (0, 7, PSTR(KEY_LINE_3), 0); |
lcd_puts_at(0, 7, strGet(KEYLINE3), 0); |
lcd_printp_at (18, 7, PSTR("\x19O\x18"), 0); |
lcd_rect(3, 23, 120, 8, 1); // +-150% Rahmen |
lcd_line(23,23,23,31,1); // -100% |
lcd_line(43,23,43,31,1); // -50% |
lcd_frect(61, 23, 3, 8, 1); // 0% |
lcd_line(83,23,83,31,1); // +50% |
lcd_line(103,23,103,31,1); // +100% |
write_ndigit_number_u (4, 5, 0, 3, 0); // Pulse width in % |
write_ndigit_number_u_100th(12, 5, 150, 3, 0); // Pulse width in ms |
do |
{ |
if ((get_key_press (1 << KEY_PLUS) || get_key_long_rpt_sp ((1 << KEY_PLUS), 3)) && (Pos < 225)) |
{ |
if (Pos < 150) |
lcd_frect ((63 - ((150 - Pos) * 0.8)), 24, 1, 6, 0); |
Pos++; |
if (Pos == 75 || Pos == 100 || Pos == 125 || Pos == 150 || Pos == 175 || Pos == 200 || Pos == 225) |
{ |
BeepTime = 200; |
BeepMuster = 0x0080; |
} |
if (Pos >= 225) |
Pos = 225; |
chg++; |
} |
else if ((get_key_press (1 << KEY_MINUS) || get_key_long_rpt_sp ((1 << KEY_MINUS), 3)) && (Pos > 75)) |
{ |
if (Pos > 150) |
lcd_frect ((((Pos - 150) * 0.8) + 63), 24, ((Pos - 150) * 0.8), 6, 0); |
Pos--; |
if (Pos == 75 || Pos == 100 || Pos == 125 || Pos == 150 || Pos == 175 || Pos == 200 || Pos == 225) |
{ |
BeepTime = 200; |
BeepMuster = 0x0080; |
} |
if (Pos <= 75) |
Pos = 75; |
chg++; |
} |
else if (get_key_press (1 << KEY_ENTER)) |
{ |
lcd_frect (4, 24, 118, 6, 0); // Balken löschen |
lcd_frect(61, 23, 3, 8, 1); // 0% |
Pos = 150; |
BeepTime = 200; |
BeepMuster = 0x0080; |
chg++; |
} |
if (chg) |
{ |
chg = 0; |
if (Pos >= 150) |
{ |
lcd_frect (63, 24, ((Pos - 150) * 0.8), 6, 1); |
write_ndigit_number_u (4, 5, ((Pos - 150) * 2), 3, 0); // Pulse width in % |
lcd_frect(62, 23, 2, 8, 1); // 0% |
} |
else |
{ |
lcd_frect (63 - ((150 - Pos) * 0.8), 24, ((150 - Pos) * 0.8), 6, 1); |
write_ndigit_number_u (4, 5, ((150 - Pos) * 2), 3, 0); // Pulse width in % |
lcd_frect(61, 23, 2, 8, 1); // 0% |
} |
write_ndigit_number_u_100th(12, 5, Pos, 3, 0); // Pulse width in ms |
lcd_line(3, 23,3, 31,1); // -150% |
lcd_line(23, 23,23, 31,1); // -100% |
lcd_line(43, 23,43, 31,1); // -50% |
lcd_line(83, 23,83, 31,1); // +50% |
lcd_line(103,23,103,31,1); // +100% |
lcd_line(123,23,123,31,1); // +150% |
OCR1A = Pos * SERVO_CORRECT; // Servostellung |
} |
} |
while (!get_key_press (1 << KEY_ESC)); |
get_key_press(KEY_ALL); |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/servo.h |
---|
0,0 → 1,40 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
#ifndef _SERVO_H |
#define _SERVO_H |
void servo_test (void); |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/setup.c |
---|
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 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"}, |
{"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 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","info bij opstart "}, |
{"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 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 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 "}, |
{"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 |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/setup.h |
---|
0,0 → 1,50 |
/***************************************************************************** |
* Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* Copyright (C) 2011 Christian "Cebra" Brandtner, brandtner@brandtner.net * |
* Copyright (C) 2011 Harald Bongartz * |
* * |
* This program is free software; you can redistribute it and/or modify * |
* it under the terms of the GNU General Public License as published by * |
* the Free Software Foundation; either version 2 of the License. * |
* * |
* This program is distributed in the hope that it will be useful, * |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
* GNU General Public License for more details. * |
* * |
* You should have received a copy of the GNU General Public License * |
* along with this program; if not, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
* * |
* Credits to: * |
* Holger Buss & Ingo Busker from mikrokopter.de for the MK project + SVN * |
* http://www.mikrokopter.de * |
* Gregor "killagreg" Stobrawa for his version of the MK code * |
* Thomas Kaiser "thkais" for the original project. See * |
* http://www.ft-fanpage.de/mikrokopter/ * |
* http://forum.mikrokopter.de/topic-4061-1.html * |
* Claas Anders "CaScAdE" Rathje for providing the font and his C-OSD code * |
* http://www.mylifesucks.de/oss/c-osd/ * |
* Harald Bongartz "HaraldB" for providing his Ideas and Code for usibility* |
*****************************************************************************/ |
#ifndef _setup_H |
#define _setup_H |
void PKT_Setup (void); |
void Display_Setup (void); |
void Wi_Use (void); |
void Wi_Setup (void); |
void BT_Use (void); |
void BT_Setup (void); |
void Show_Error_HW12(void); |
void Accu_Setup (void); |
uint8_t Edit_Language(uint8_t Value, uint8_t min, uint8_t max,uint8_t Text); |
extern uint8_t bt_name_len; |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/timer.c |
---|
0,0 → 1,519 |
/***************************************************************************** |
* Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* based on the key handling by Peter Dannegger * |
* see www.mikrocontroller.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 <inttypes.h> |
#include "main.h" |
#include "timer.h" |
#include "eeprom.h" |
#include "lcd.h" |
#include "uart1.h" |
#if defined HWVERSION1_2W || defined HWVERSION1_2 |
#include "HAL_HW1_2.h" |
#endif |
#if defined HWVERSION1_3W || defined HWVERSION1_3 |
#include "HAL_HW1_3.h" |
#endif |
#ifdef HWVERSION3_9 |
#include "HAL_HW3_9.h" |
#endif |
volatile uint16_t timer; |
volatile uint16_t abo_timer; |
volatile static unsigned int tim_main; |
uint8_t key_state = 0; // debounced and inverted key state: |
// bit = 1: key pressed |
uint8_t key_press = 0; // key press detect |
uint8_t key_long = 0; // key long press |
uint8_t key_rpt = 0; // key repeat |
uint8_t key_lrpt = 0; // key long press and repeat |
uint8_t key_rpts = 0; // key long press and speed repeat |
uint8_t repeat_speed = 0; |
uint16_t DisplayTime = 0; // Leuchtdauer |
volatile uint16_t IdleTimer = 0; // InaktivitätsTimer |
uint16_t WarnCount = 0; // Zähler der LIPO Warnzeit |
uint16_t WarnToggle = 0; // Togglezähler zum blinken |
uint16_t WarnTime = 10; // Länge der LIPO Warnzeit 10 Sek. |
uint16_t PoffTime = 30; // Länge der Wartezeit vor Abschalten 30 Sek. |
//uint8_t servo = 0; |
volatile uint8_t Display_on;// Flag Display on/off |
unsigned int BeepTime = 0; |
unsigned int BeepMuster = 0xffff; |
volatile unsigned int CountMilliseconds = 0; |
// Size of Buffer for Converting unsigned int Value to ASCII |
#define STRING_BUFFER_SIZE 5 |
// Buffer for Converting unsigned int Value to ASCII |
char String_Buffer[STRING_BUFFER_SIZE]; |
//-------------------------------------------------------------- |
// |
void Timer1_Init (void) // Timer 1-A |
{ |
// löschen |
TCCR1A = 0; |
TCCR1B = 0; |
TIMSK1 = 0; |
// setzen |
TCCR1A |= (1 << COM1A1) | (1 << WGM11); |
TCCR1B |= (1 << CS11) | (1 << CS10) | (1 << WGM13) | (1 << WGM12); |
ICR1 = (F_CPU / 64) * 20 / 1000; |
OCR1A = 470; // ca. Servomitte |
} |
//-------------------------------------------------------------- |
void Timer2_Init (void) // Displayhelligkeit |
{ |
DDRD |= (1 << DDD7); // PD7 output |
TCCR2A |= (1 << WGM21) | (1 << WGM20) | (1 << COM2A1); // non invers |
TCCR2B |= (1 << CS20); // Prescaler 1/1 |
TIMSK2 |= (1 << OCIE2A) | (1 << OCIE2B); |
OCR2A = 255; |
} |
#if defined HWVERSION1_2 || defined HWVERSION1_2W |
//-------------------------------------------------------------- |
ISR(TIMER2_COMPA_vect) |
{ |
PORTD &= ~(1 << PD7); |
PORTC &= ~(1 << PC0); |
PORTC &= ~(1 << PC1); |
} |
ISR(TIMER2_COMPB_vect) |
{ |
PORTD |= (1 << PD7); |
PORTC |= (1 << PC0); |
PORTC |= (1 << PC1); |
} |
#endif |
#if defined HWVERSION1_3 || defined HWVERSION1_3W |
//-------------------------------------------------------------- |
ISR(TIMER2_COMPA_vect) |
{ |
PORTD &= ~(1 << PD7); |
PORTD &= ~(1 << PD6); |
PORTC &= ~(1 << PC2); |
} |
ISR(TIMER2_COMPB_vect) |
{ |
PORTD |= (1 << PD7); |
PORTD |= (1 << PD6); |
PORTC |= (1 << PC2); |
} |
#endif |
#ifdef HWVERSION3_9 |
//-------------------------------------------------------------- |
ISR(TIMER2_COMPA_vect) |
{ |
PORTD |= (1 << PD7); |
} |
ISR(TIMER2_COMPB_vect) |
{ |
PORTD &= ~(1 << PD7); |
} |
#endif |
//-------------------------------------------------------------- |
void Timer0_Init (void) // System (100Hz) |
{ |
timer = 0; |
TCCR0A = (1 << WGM01); |
TCCR0B = (1 << CS02) | (1 << CS00); |
OCR0A = (F_CPU / (100L * 1024L)) ; |
TIMSK0 |= (1 << OCIE0A); // enable interrupt for OCR |
} |
//-------------------------------------------------------------- |
ISR(TIMER0_COMPA_vect) // Timer-Interrupt (100 Hz) |
{ |
static uint8_t ct0 = 0; |
static uint8_t ct1 = 0; |
static uint8_t k_time_l = 0; |
static uint8_t k_time_r = 0; |
static uint8_t k_time_lr = 0; |
static uint8_t k_time_rs = 0; |
uint8_t i; |
static unsigned char cnt_1ms = 1,cnt = 0; |
unsigned char beeper_ein = 0; |
// unsigned char pieper_ein = 0; |
// Key handling by Peter Dannegger |
// see www.mikrocontroller.net |
i = key_state ^ ~KEY_PIN; // key changed ? |
ct0 = ~(ct0 & i); // reset or count ct0 |
ct1 = ct0 ^ (ct1 & i); // reset or count ct1 |
i &= (ct0 & ct1); // count until roll over ? |
key_state ^= i; // then toggle debounced state |
key_press |= (key_state & i); // 0->1: key press detect |
if (PKT_IdleBeep == 1) |
{ |
IdleTimer ++; // nix zu tun? Timer hochzählen |
if (IdleTimer == 12000) // Warnhinweis |
{ |
BeepTime = 200; |
BeepMuster = 0x0080; |
IdleTimer = 0; |
} |
} |
if (!cnt--) |
{ |
cnt = 9; |
CountMilliseconds++; |
cnt_1ms++; |
} |
if (i!=0) |
{ // Displaylicht einschalten, und bzw. Timeoutzählerreset wenn Taste gedrückt wurde |
if (Display_on == 0) |
set_D_LIGHT(); |
Display_on = 1; // Flag Display on |
DisplayTime = 0; // Timer Reset |
IdleTimer = 0; // Idletimeout Reset |
} |
if (DisplayTimeout > 0) |
{ |
if (Display_on == 1) |
{ |
DisplayTime++; |
if ((DisplayTime / 100) == DisplayTimeout) // ISR läuft mit 100Hz |
{ // Displaylicht ausschalten |
clr_D_LIGHT(); |
Display_on = 0; // Flag Display off |
} |
} |
} |
//-------------------------------------------------------------- |
#ifdef HWVERSION3_9 |
LipoCheck(); // Lipo prüfen |
#endif |
//-------------------------------------------------------------- |
if (BeepTime) |
{ |
if (BeepTime > 10) |
BeepTime -= 10; |
else |
BeepTime = 0; |
if (BeepTime & BeepMuster) |
beeper_ein = 1; |
else |
beeper_ein = 0; |
} |
else |
{ |
beeper_ein = 0; |
BeepMuster = 0xffff; |
} |
if (beeper_ein) |
set_BEEP(); |
else |
clr_BEEP(); |
//-------------------------------------------------------------- |
if ((key_state & LONG_MASK) == 0) // check long key function |
k_time_l = REPEAT_START; // start delay |
if (--k_time_l == 0) // long countdown |
key_long |= (key_state & LONG_MASK); |
//-------------------------------------------------------------- |
if ((key_state & REPEAT_MASK) == 0) // check repeat function |
k_time_r = 1; // kein delay |
if (--k_time_r == 0) |
{ |
k_time_r = REPEAT_NEXT; // repeat delay |
key_rpt |= (key_state & REPEAT_MASK); |
} |
//-------------------------------------------------------------- |
if ((key_state & LONG_REPEAT_MASK) == 0) // check repeat function |
k_time_lr = REPEAT_START; // start delay |
if (--k_time_lr == 0) |
{ |
k_time_lr = REPEAT_NEXT; // repeat delay |
key_lrpt |= (key_state & LONG_REPEAT_MASK); |
} |
//-------------------------------------------------------------- |
if ((key_state & LONG_REPEAT_SP_MASK) == 0) // check repeatX function |
k_time_rs = REPEAT_START; // start delay |
if (--k_time_rs == 0) // repeat countdown |
{ |
if (repeat_speed == 1) |
{ |
k_time_rs = REPEAT_SPEED_1; |
key_rpts |= (key_state & LONG_REPEAT_SP_MASK); |
} |
else if (repeat_speed == 2) |
{ |
k_time_rs = REPEAT_SPEED_2; |
key_rpts |= (key_state & LONG_REPEAT_SP_MASK); |
} |
else if (repeat_speed == 3) |
{ |
k_time_rs = REPEAT_SPEED_3; |
key_rpts |= (key_state & LONG_REPEAT_SP_MASK); |
} |
} |
if (timer > 0) |
timer --; |
if (abo_timer > 0) |
abo_timer --; |
} |
//-------------------------------------------------------------- |
#ifdef HWVERSION3_9 |
void LipoCheck (void) // Lowbatpin des Spannungswandlers prüfen |
// LBO des LT1308 wechselt zum Ende der Batterielaufzeit häufig seinen Zustand in der Übergangsphase zum LowBat |
// Die Akkuspannung schwankt auch abhängig vom momentanen Stromverbrauch |
{ |
if (WarnToggle == 1) // Beim ersten Auftreten Warnung ausgeben, Rythmus 5/10 Sekunden |
{ |
BeepTime = 1000; |
BeepMuster = 0x0020; |
lcd_printp_at (0, 0, PSTR(" LIPO !!Warnung!! "), 2); |
} |
if (WarnToggle == WarnTime * 100) |
WarnToggle = 0; // erstmal bis hier warnen |
if (WarnToggle > 0) |
WarnToggle++; // weiter hochzählen |
if (PINC & (1 << LowBat)) // Kurzzeitige Unterspannung bearbeiten und Warnung ausgeben |
{ |
WarnCount = 0; |
// if (WarnCount > 0) |
// WarnCount--; // Bei LIPO OK erstmal runterzählen, LT1308 überlegt sich noch genauer ob nun ok oder nicht |
} |
if (!(PINC & (1 << LowBat)) ) // LT1308 hat Unterspannung erkannt |
{ |
WarnCount++; // solange LBO low ist Zähler hochzählen |
if (WarnCount == 10 && WarnToggle == 0) // mit "10" etwas unempfindlicher gegen kurze Impulse machen |
WarnToggle = 1; // Warnhinweis starten |
} |
if ((WarnCount) == PoffTime * 100) |
clr_V_On(); // Spannung abschalten |
} |
#endif |
//-------------------------------------------------------------- |
unsigned int SetDelay (unsigned int t) |
{ |
return(CountMilliseconds + t + 1); |
} |
//-------------------------------------------------------------- |
char CheckDelay(unsigned int t) |
{ |
return(((t - CountMilliseconds) & 0x8000) >> 9); |
} |
//-------------------------------------------------------------- |
void Delay_ms(unsigned int w) |
{ |
unsigned int akt; |
akt = SetDelay(w); |
while (!CheckDelay(akt)); |
} |
//-------------------------------------------------------------- |
// |
uint8_t get_key_press (uint8_t key_mask) |
{ |
uint8_t sreg = SREG; |
// disable all interrupts |
cli(); |
key_mask &= key_press; // read key(s) |
key_press ^= key_mask; // clear key(s) |
SREG = sreg; // restore status register |
return key_mask; |
} |
//-------------------------------------------------------------- |
// |
uint8_t get_key_short (uint8_t key_mask) |
{ |
uint8_t ret; |
uint8_t sreg = SREG; |
// disable all interrupts |
cli(); |
ret = get_key_press (~key_state & key_mask); |
SREG = sreg; // restore status register |
return ret; |
} |
//-------------------------------------------------------------- |
// |
uint8_t get_key_long (uint8_t key_mask) |
{ |
uint8_t sreg = SREG; |
// disable all interrupts |
cli(); |
key_mask &= key_long; // read key(s) |
key_long ^= key_mask; // clear key(s) |
SREG = sreg; // restore status register |
return get_key_press (get_key_rpt (key_mask)); |
} |
//-------------------------------------------------------------- |
// |
uint8_t get_key_rpt (uint8_t key_mask) |
{ |
uint8_t sreg = SREG; |
// disable all interrupts |
cli(); |
key_mask &= key_rpt; // read key(s) |
key_rpt ^= key_mask; // clear key(s) |
SREG = sreg; // restore status register |
return key_mask; |
} |
//-------------------------------------------------------------- |
// |
uint8_t get_key_long_rpt (uint8_t key_mask) |
{ |
uint8_t sreg = SREG; |
// disable all interrupts |
cli(); |
key_mask &= key_lrpt; // read key(s) |
key_lrpt ^= key_mask; // clear key(s) |
SREG = sreg; // restore status register |
return get_key_rpt (~key_press^key_mask); |
} |
//-------------------------------------------------------------- |
// |
uint8_t get_key_long_rpt_sp (uint8_t key_mask, uint8_t key_speed) |
{ |
uint8_t sreg = SREG; |
// disable all interrupts |
cli(); |
key_mask &= key_rpts; // read key(s) |
key_rpts ^= key_mask; // clear key(s) |
repeat_speed = key_speed; |
SREG = sreg; // restore status register |
return key_mask; |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/timer.h |
---|
0,0 → 1,87 |
/***************************************************************************** |
* Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* based on the key handling by Peter Dannegger * |
* see www.mikrocontroller.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* |
*****************************************************************************/ |
#ifndef _TIMER_H |
#define _TIMER_H |
#include "cpu.h" |
#include "main.h" |
#define KEY_ALL ((1 << KEY_PLUS) | (1 << KEY_MINUS) | (1 << KEY_ENTER) | (1 << KEY_ESC)) |
#define LONG_MASK ((1 << KEY_PLUS) | (1 << KEY_MINUS) | (1 << KEY_ENTER) | (1 << KEY_ESC)) |
#define REPEAT_MASK ((1 << KEY_PLUS) | (1 << KEY_MINUS) | (1 << KEY_ENTER) | (1 << KEY_ESC)) |
#define LONG_REPEAT_MASK ((1 << KEY_PLUS) | (1 << KEY_MINUS) | (1 << KEY_ENTER) | (1 << KEY_ESC)) |
#define LONG_REPEAT_SP_MASK ((1 << KEY_PLUS) | (1 << KEY_MINUS) | (1 << KEY_ENTER) | (1 << KEY_ESC)) |
#define REPEAT_START 70 // after 700ms |
#define REPEAT_NEXT 15 // every 150ms |
#define REPEAT_SPEED_1 20 // every 200ms |
#define REPEAT_SPEED_2 8 // every 80ms |
#define REPEAT_SPEED_3 1 // every 10ms |
#define ABO_TIMEOUT 300 // 3 sec |
extern volatile uint8_t Display_on; |
extern volatile uint16_t IdleTimer; |
extern volatile uint16_t timer; |
extern volatile uint16_t abo_timer; |
extern uint16_t WarnCount; |
//extern volatile unsigned int BeepTime; |
extern unsigned int BeepTime; |
extern unsigned int BeepMuster; |
void Timer0_Init (void); // Systeminterrupt |
void Timer1_Init (void); // Servotester |
void Timer2_Init (void); // Displayhelligkeit |
uint8_t get_key_press (uint8_t key_mask); // sofort beim drücken |
uint8_t get_key_short (uint8_t key_mask); // erst beim loslassen |
uint8_t get_key_long (uint8_t key_mask); // verzögert |
uint8_t get_key_rpt (uint8_t key_mask); // mit verzögerung |
uint8_t get_key_long_rpt (uint8_t key_mask); // |
uint8_t get_key_long_rpt_sp (uint8_t key_mask, uint8_t key_speed); // mit verzögerung und 3 versch. geschw. |
extern volatile unsigned int CountMilliseconds; |
void Delay_ms(unsigned int); |
unsigned int SetDelay (unsigned int t); |
char CheckDelay (unsigned int t); |
void LipoCheck (void); // Lowbatpin des Spannungswandlers prüfen |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/tools.c |
---|
0,0 → 1,332 |
/***************************************************************************** |
* 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; |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/tools.h |
---|
0,0 → 1,41 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
#ifndef _tools_H |
#define _tools_H |
void PKT_Tools (void); |
void Test_HB (void); // TestTool für Softwareentwicklung |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/twimaster.c |
---|
0,0 → 1,511 |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + Copyright (c) Holger Buss, Ingo Busker |
// + Nur f?r den privaten Gebrauch |
// + www.MikroKopter.com |
// + porting the sources to other systems or using the software on other systems (except hardware from www.mikrokopter.de) is not allowed |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + Es gilt f?r das gesamte Projekt (Hardware, Software, Bin?rfiles, Sourcecode und Dokumentation), |
// + dass eine Nutzung (auch auszugsweise) nur f?r den privaten (nicht-kommerziellen) Gebrauch zul?ssig ist. |
// + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt |
// + bzgl. der Nutzungsbedingungen aufzunehmen. |
// + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Best?ckung und Verkauf von Platinen oder Baus?tzen, |
// + Verkauf von Luftbildaufnahmen, usw. |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder ver?ffentlicht, |
// + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright m?ssen dann beiliegen |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts |
// + auf anderen Webseiten oder sonstigen Medien ver?ffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de" |
// + eindeutig als Ursprung verlinkt werden |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + Keine Gew?hr auf Fehlerfreiheit, Vollst?ndigkeit oder Funktion |
// + Benutzung auf eigene Gefahr |
// + Wir ?bernehmen keinerlei Haftung f?r direkte oder indirekte Personen- oder Sachsch?den |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + Die Portierung der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur |
// + mit unserer Zustimmung zul?ssig |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + Redistributions of source code (with or without modifications) must retain the above copyright notice, |
// + this list of conditions and the following disclaimer. |
// + * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived |
// + from this software without specific prior written permission. |
// + * The use of this project (hardware, software, binary files, sources and documentation) is only permittet |
// + for non-commercial use (directly or indirectly) |
// + Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted |
// + with our written permission |
// + * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be |
// + clearly linked as origin |
// + * porting to systems other than hardware from www.mikrokopter.de is not allowed |
// + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
// + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
// + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
// + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
// + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
// + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
// + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
// + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN// + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
// + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
// + POSSIBILITY OF SUCH DAMAGE. |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
#include "cpu.h" |
#include <avr/io.h> |
#include <avr/interrupt.h> |
#include <util/twi.h> |
#include <util/delay.h> |
#include "eeprom.h" |
#include "twimaster.h" |
#include "timer.h" |
volatile uint8_t twi_state = TWI_STATE_MOTOR_TX; |
volatile uint8_t dac_channel = 0; |
volatile uint8_t motor_write = 0; |
volatile uint8_t motor_read = 0; |
volatile uint8_t I2C_TransferActive = 0; |
volatile uint16_t I2CTimeout = 100; |
uint8_t MissingMotor = 0; |
uint8_t RequiredMotors = 1; |
char MotorenEin = 0; |
volatile uint8_t BLFlags = 0; |
MotorData_t Motor[MAX_MOTORS]; |
// bit mask for witch BL the configuration should be sent |
volatile uint16_t BLConfig_WriteMask = 0; |
// bit mask for witch BL the configuration should be read |
volatile uint16_t BLConfig_ReadMask = 0; |
// buffer for BL Configuration |
BLConfig_t BLConfig; |
#define I2C_WriteByte(byte) {TWDR = byte; TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWIE);} |
#define I2C_ReceiveByte() {TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWIE) | (1<<TWEA);} |
#define I2C_ReceiveLastByte() {TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWIE);} |
#define SCL_CLOCK 200000L |
#define I2C_TIMEOUT 30000 |
#define TWI_BASE_ADDRESS 0x52 |
uint8_t RAM_Checksum(uint8_t* pBuffer, uint16_t len) |
{ |
uint8_t crc = 0xAA; |
uint16_t i; |
for(i=0; i<len; i++) |
{ |
crc += pBuffer[i]; |
} |
return crc; |
} |
//-------------------------------------------------------------- |
// Initialize I2C (TWI) |
// |
void I2C_Init(char clear) |
{ |
uint8_t i; |
uint8_t sreg = SREG; |
cli(); |
// SDA is INPUT |
DDRC &= ~(1<<DDC1); |
// SCL is output |
DDRC |= (1<<DDC0); |
// pull up SDA |
//PORTC |= (1<<PORTC0)|(1<<PORTC1); |
// TWI Status Register |
// prescaler 1 (TWPS1 = 0, TWPS0 = 0) |
TWSR &= ~((1<<TWPS1)|(1<<TWPS0)); |
// set TWI Bit Rate Register |
TWBR = ((F_CPU/SCL_CLOCK)-16)/2; |
twi_state = TWI_STATE_MOTOR_TX; |
motor_write = 0; |
motor_read = 0; |
if(clear) for(i=0; i < MAX_MOTORS; i++) |
{ |
Motor[i].Version = 0; |
Motor[i].SetPoint = 0; |
Motor[i].SetPointLowerBits = 0; |
Motor[i].State = 0; |
Motor[i].ReadMode = BL_READMODE_STATUS; |
Motor[i].Current = 0; |
Motor[i].MaxPWM = 0; |
Motor[i].Temperature = 0; |
} |
sei(); |
SREG = sreg; |
} |
//-------------------------------------------------------------- |
void I2C_Reset(void) |
{ |
// stop i2c bus |
I2C_Stop(TWI_STATE_MOTOR_TX); |
TWCR = (1<<TWINT); // reset to original state incl. interrupt flag reset |
TWAMR = 0; |
TWAR = 0; |
TWDR = 0; |
TWSR = 0; |
TWBR = 0; |
I2C_TransferActive = 0; |
I2C_Init(0); |
I2C_WriteByte(0); |
BLFlags |= BLFLAG_READ_VERSION; |
} |
//-------------------------------------------------------------- |
// I2C ISR |
// |
ISR (TWI_vect) |
{ |
static uint8_t missing_motor = 0, motor_read_temperature = 0; |
static uint8_t *pBuff = 0; |
static uint8_t BuffLen = 0; |
switch (twi_state++) |
{ |
// Master Transmit |
case 0: // TWI_STATE_MOTOR_TX |
I2C_TransferActive = 1; |
// skip motor if not used in mixer |
// while((Mixer.Motor[motor_write][MIX_GAS] <= 0) && (motor_write < MAX_MOTORS)) motor_write++; |
if(motor_write >= MAX_MOTORS) // writing finished, read now |
{ |
BLConfig_WriteMask = 0; // reset configuration bitmask |
motor_write = 0; // reset motor write counter for next cycle |
twi_state = TWI_STATE_MOTOR_RX; |
I2C_WriteByte(TWI_BASE_ADDRESS + TW_READ + (motor_read<<1) ); // select slave address in rx mode |
} |
else I2C_WriteByte(TWI_BASE_ADDRESS + TW_WRITE + (motor_write<<1) ); // select slave address in tx mode |
break; |
case 1: // Send Data to Slave |
I2C_WriteByte(Motor[motor_write].SetPoint); // transmit setpoint |
// if old version has been detected |
if(!(Motor[motor_write].Version & MOTOR_STATE_NEW_PROTOCOL_MASK)) |
{ |
twi_state = 4; //jump over sending more data |
} |
// the new version has been detected |
else if(!( (Motor[motor_write].SetPointLowerBits && (RequiredMotors < 7)) || BLConfig_WriteMask || BLConfig_ReadMask ) ) |
{ // or LowerBits are zero and no BlConfig should be sent (saves round trip time) |
twi_state = 4; //jump over sending more data |
} |
break; |
case 2: // lower bits of setpoint (higher resolution) |
if ((0x0001<<motor_write) & BLConfig_ReadMask) |
{ |
Motor[motor_write].ReadMode = BL_READMODE_CONFIG; // configuration request |
} |
else |
{ |
Motor[motor_write].ReadMode = BL_READMODE_STATUS; // normal status request |
} |
// send read mode and the lower bits of setpoint |
I2C_WriteByte((Motor[motor_write].ReadMode<<3)|(Motor[motor_write].SetPointLowerBits & 0x07)); |
// configuration tranmission request? |
if((0x0001<<motor_write) & BLConfig_WriteMask) |
{ // redirect tx pointer to configuration data |
pBuff = (uint8_t*)&BLConfig; // select config for motor |
BuffLen = sizeof(BLConfig_t); |
} |
else |
{ // jump to end of transmission for that motor |
twi_state = 4; |
} |
break; |
case 3: // send configuration |
I2C_WriteByte(*pBuff); |
pBuff++; |
if(--BuffLen > 0) |
twi_state = 3; // if there are some bytes left |
break; |
case 4: // repeat case 0-4 for all motors |
if(TWSR == TW_MT_DATA_NACK) // Data transmitted, NACK received |
{ |
if(!missing_motor) |
missing_motor = motor_write + 1; |
if((Motor[motor_write].State & MOTOR_STATE_ERROR_MASK) < MOTOR_STATE_ERROR_MASK) |
Motor[motor_write].State++; // increment error counter and handle overflow |
} |
I2C_Stop(TWI_STATE_MOTOR_TX); |
I2CTimeout = 10; |
motor_write++; // next motor |
I2C_Start(TWI_STATE_MOTOR_TX); // Repeated start -> switch slave or switch Master Transmit -> Master Receive |
break; |
// Master Receive Data |
case 5: // TWI_STATE_MOTOR_RX |
if(TWSR != TW_MR_SLA_ACK) // SLA+R transmitted but no ACK received |
{ // no response from the addressed slave received |
Motor[motor_read].State &= ~MOTOR_STATE_PRESENT_MASK; // clear present bit |
if(++motor_read >= MAX_MOTORS) |
{ // all motors read |
motor_read = 0; // restart from beginning |
BLConfig_ReadMask = 0; // reset read configuration bitmask |
if(++motor_read_temperature >= MAX_MOTORS) |
{ |
motor_read_temperature = 0; |
BLFlags &= ~BLFLAG_READ_VERSION; |
} |
} |
BLFlags |= BLFLAG_TX_COMPLETE; |
I2C_Stop(TWI_STATE_MOTOR_TX); |
I2C_TransferActive = 0; |
} |
else |
{ // motor successfully addressed |
Motor[motor_read].State |= MOTOR_STATE_PRESENT_MASK; // set present bit |
if(Motor[motor_read].Version & MOTOR_STATE_NEW_PROTOCOL_MASK) |
{ |
// new BL found |
switch(Motor[motor_read].ReadMode) |
{ |
case BL_READMODE_CONFIG: |
pBuff = (uint8_t*)&BLConfig; |
BuffLen = sizeof(BLConfig_t); |
break; |
case BL_READMODE_STATUS: |
pBuff = (uint8_t*)&(Motor[motor_read].Current); |
if(motor_read == motor_read_temperature) BuffLen = 3; // read Current, MaxPwm & Temp |
else BuffLen = 1;// read Current only |
break; |
} |
} |
else // old BL version |
{ |
pBuff = (uint8_t*)&(Motor[motor_read].Current); |
if((BLFlags & BLFLAG_READ_VERSION) || (motor_read == motor_read_temperature)) BuffLen = 2; // Current & MaxPwm |
else BuffLen = 1; // read Current only |
} |
if(BuffLen == 1) |
{ |
I2C_ReceiveLastByte(); // read last byte |
} |
else |
{ |
I2C_ReceiveByte(); // read next byte |
} |
} |
MissingMotor = missing_motor; |
missing_motor = 0; |
break; |
case 6: // receive bytes |
*pBuff = TWDR; |
pBuff++; |
BuffLen--; |
if(BuffLen>1) |
{ |
I2C_ReceiveByte(); // read next byte |
} |
else if (BuffLen == 1) |
{ |
I2C_ReceiveLastByte(); // read last byte |
} |
else // nothing left |
{ |
if(BLFlags & BLFLAG_READ_VERSION) |
{ |
// if(!(FC_StatusFlags & FC_STATUS_MOTOR_RUN) && (Motor[motor_read].MaxPWM == 250) ) Motor[motor_read].Version |= MOTOR_STATE_NEW_PROTOCOL_MASK; |
if((Motor[motor_read].MaxPWM == 250) ) Motor[motor_read].Version |= MOTOR_STATE_NEW_PROTOCOL_MASK; |
else Motor[motor_read].Version = 0; |
} |
if(++motor_read >= MAX_MOTORS) |
{ |
motor_read = 0; // restart from beginning |
BLConfig_ReadMask = 0; // reset read configuration bitmask |
if(++motor_read_temperature >= MAX_MOTORS) |
{ |
motor_read_temperature = 0; |
BLFlags &= ~BLFLAG_READ_VERSION; |
} |
} |
I2C_Stop(TWI_STATE_MOTOR_TX); |
BLFlags |= BLFLAG_TX_COMPLETE; |
I2C_TransferActive = 0; |
return; |
} |
twi_state = 6; // if there are some bytes left |
break; |
case 21: |
I2C_WriteByte(0x80); // 2nd byte for all channels is 0x80 |
break; |
case 22: |
I2C_Stop(TWI_STATE_MOTOR_TX); |
I2C_TransferActive = 0; |
I2CTimeout = 10; |
// repeat case 18...22 until all DAC Channels are updated |
if(dac_channel < 2) |
{ |
dac_channel ++; // jump to next channel |
I2C_Start(TWI_STATE_GYRO_OFFSET_TX); // start transmission for next channel |
} |
else |
{ |
dac_channel = 0; // reset dac channel counter |
BLFlags |= BLFLAG_TX_COMPLETE; |
} |
break; |
default: |
I2C_Stop(TWI_STATE_MOTOR_TX); |
BLFlags |= BLFLAG_TX_COMPLETE; |
I2CTimeout = 10; |
motor_write = 0; |
motor_read = 0; |
I2C_TransferActive = 0; |
break; |
} |
} |
//-------------------------------------------------------------- |
uint8_t I2C_WriteBLConfig(uint8_t motor) |
{ |
uint8_t i; |
uint16_t timer; |
// if(MotorenEin || PC_MotortestActive) |
// return(BLCONFIG_ERR_MOTOR_RUNNING); // not when motors are running! |
if(MotorenEin) |
return(BLCONFIG_ERR_MOTOR_RUNNING); // not when motors are running! |
if(motor > MAX_MOTORS) |
return (BLCONFIG_ERR_MOTOR_NOT_EXIST); // motor does not exist! |
if(motor) |
{ |
if(!(Motor[motor-1].State & MOTOR_STATE_PRESENT_MASK)) |
return(BLCONFIG_ERR_MOTOR_NOT_EXIST); // motor does not exist! |
if(!(Motor[motor-1].Version & MOTOR_STATE_NEW_PROTOCOL_MASK)) |
return(BLCONFIG_ERR_HW_NOT_COMPATIBLE); // not a new BL! |
} |
// check BL configuration to send |
if(BLConfig.Revision != BLCONFIG_REVISION) |
return (BLCONFIG_ERR_SW_NOT_COMPATIBLE); // bad revison |
i = RAM_Checksum((uint8_t*)&BLConfig, sizeof(BLConfig_t) - 1); |
if(i != BLConfig.crc) |
return(BLCONFIG_ERR_CHECKSUM); // bad checksum |
timer = SetDelay(2000); |
while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
// prepare the bitmask |
if(!motor) // 0 means all |
{ |
BLConfig_WriteMask = 0xFF; // all motors at once with the same configuration |
} |
else //only one specific motor |
{ |
BLConfig_WriteMask = 0x0001<<(motor-1); |
} |
for(i = 0; i < MAX_MOTORS; i++) |
{ |
if((0x0001<<i) & BLConfig_WriteMask) |
{ |
Motor[i].SetPoint = 0; |
Motor[i].SetPointLowerBits = 0; |
} |
} |
motor_write = 0; |
// needs at least MAX_MOTORS loops of 2 ms (12*2ms = 24ms) |
do |
{ |
I2C_Start(TWI_STATE_MOTOR_TX); // start an i2c transmission |
while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
} |
while(BLConfig_WriteMask && !CheckDelay(timer)); // repeat until the BL config has been sent |
if(BLConfig_WriteMask) return(BLCONFIG_ERR_MOTOR_NOT_EXIST); |
return(BLCONFIG_SUCCESS); |
} |
//-------------------------------------------------------------- |
uint8_t I2C_ReadBLConfig(uint8_t motor) |
{ |
uint8_t i; |
uint16_t timer; |
// if(MotorenEin || PC_MotortestActive) |
return(BLCONFIG_ERR_MOTOR_RUNNING); // not when motors are running! |
if(MotorenEin) |
return(BLCONFIG_ERR_MOTOR_RUNNING); // not when motors are running! |
if(motor > MAX_MOTORS) |
return (BLCONFIG_ERR_MOTOR_NOT_EXIST); // motor does not exist! |
if(motor == 0) |
return (BLCONFIG_ERR_READ_NOT_POSSIBLE); |
if(!(Motor[motor-1].State & MOTOR_STATE_PRESENT_MASK)) |
return(BLCONFIG_ERR_MOTOR_NOT_EXIST); // motor does not exist! |
if(!(Motor[motor-1].Version & MOTOR_STATE_NEW_PROTOCOL_MASK)) |
return(BLCONFIG_ERR_HW_NOT_COMPATIBLE); // not a new BL! |
timer = SetDelay(2000); |
while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
// prepare the bitmask |
BLConfig_ReadMask = 0x0001<<(motor-1); |
for(i = 0; i < MAX_MOTORS; i++) |
{ |
if((0x0001<<i) & BLConfig_ReadMask) |
{ |
Motor[i].SetPoint = 0; |
Motor[i].SetPointLowerBits = 0; |
} |
} |
motor_read = 0; |
BLConfig.Revision = 0; // bad revision |
BLConfig.crc = 0; // bad checksum |
// needs at least MAX_MOTORS loops of 2 ms (12*2ms = 24ms) |
do |
{ |
I2C_Start(TWI_STATE_MOTOR_TX); // start an i2c transmission |
while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer |
}while(BLConfig_ReadMask && !CheckDelay(timer)); // repeat until the BL config has been received from all motors |
// validate result |
if(BLConfig.Revision != BLCONFIG_REVISION) return (BLCONFIG_ERR_SW_NOT_COMPATIBLE); // bad revison |
i = RAM_Checksum((uint8_t*)&BLConfig, sizeof(BLConfig_t) - 1); |
if(i != BLConfig.crc) return(BLCONFIG_ERR_CHECKSUM); // bad checksum |
return(BLCONFIG_SUCCESS); |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/twimaster.h |
---|
0,0 → 1,100 |
#ifndef _I2C_MASTER_H |
#define _I2C_MASTER_H |
+ |
+#include <inttypes.h> |
+ |
+#define TWI_STATE_MOTOR_TX 0 |
+#define TWI_STATE_MOTOR_RX 5 |
+#define TWI_STATE_GYRO_OFFSET_TX 18 |
+ |
+extern volatile uint8_t twi_state; |
+extern volatile uint8_t motor_write; |
+extern volatile uint8_t motor_read; |
+extern volatile uint8_t I2C_TransferActive; |
+ |
+extern uint8_t MissingMotor; |
+ |
+#define MAX_MOTORS 12 |
+#define MOTOR_STATE_PRESENT_MASK 0x80 |
+#define MOTOR_STATE_ERROR_MASK 0x7F |
+#define MOTOR_STATE_NEW_PROTOCOL_MASK 0x01 |
+#define BLFLAG_TX_COMPLETE 0x01 |
+#define BLFLAG_READ_VERSION 0x02 |
+ |
+extern volatile uint8_t BLFlags; |
+extern char MotorenEin; |
+unsigned char MotorTest[16]; |
+#define BL_READMODE_STATUS 0 |
+#define BL_READMODE_CONFIG 16 |
+ |
+typedef struct |
+{ |
+ uint8_t Version; // the version of the BL (0 = old) |
+ uint8_t SetPoint; // written by attitude controller |
+ uint8_t SetPointLowerBits; // for higher Resolution of new BLs |
+ uint8_t State; // 7 bit for I2C error counter, highest bit indicates if motor is present |
+ uint8_t ReadMode; // select data to read |
+ // the following bytes must be exactly in that order! |
+ uint8_t Current; // in 0.1 A steps, read back from BL |
+ uint8_t MaxPWM; // read back from BL is less than 255 if BL is in current limit |
+ int8_t Temperature; // old BL-Ctrl will return a 255 here, the new version the temp. in �C |
+} __attribute__((packed)) MotorData_t; |
+ |
+extern MotorData_t Motor[MAX_MOTORS]; |
+ |
+#define BLCONFIG_REVISION 2 |
+ |
+#define MASK_SET_PWM_SCALING 0x01 |
+#define MASK_SET_CURRENT_LIMIT 0x02 |
+#define MASK_SET_TEMP_LIMIT 0x04 |
+#define MASK_SET_CURRENT_SCALING 0x08 |
+#define MASK_SET_BITCONFIG 0x10 |
+#define MASK_RESET_CAPCOUNTER 0x20 |
+#define MASK_SET_DEFAULT_PARAMS 0x40 |
+#define MASK_SET_SAVE_EEPROM 0x80 |
+ |
+#define BITCONF_REVERSE_ROTATION 0x01 |
+#define BITCONF_RES1 0x02 |
+#define BITCONF_RES2 0x04 |
+#define BITCONF_RES3 0x08 |
+#define BITCONF_RES4 0x10 |
+#define BITCONF_RES5 0x20 |
+#define BITCONF_RES6 0x40 |
+#define BITCONF_RES7 0x80 |
+ |
+typedef struct |
+{ |
+ uint8_t Revision; // must be BL_REVISION |
+ uint8_t SetMask; // settings mask |
+ uint8_t PwmScaling; // maximum value of control pwm, acts like a thrust limit |
+ uint8_t CurrentLimit; // current limit in A |
+ uint8_t TempLimit; // in �C |
+ uint8_t CurrentScaling; // scaling factor for current measurement |
+ uint8_t BitConfig; // see defines above |
+ uint8_t crc; // checksum |
+} __attribute__((packed)) BLConfig_t; |
+ |
+extern BLConfig_t BLConfig; |
+ |
+extern volatile uint16_t I2CTimeout; |
+ |
+void I2C_Init(char); // Initialize I2C |
+#define I2C_Start(start_state) {twi_state = start_state; BLFlags &= ~BLFLAG_TX_COMPLETE; TWCR = (1<<TWSTA) | (1<<TWEN) | (1<<TWINT) | (1<<TWIE);} |
+#define I2C_Stop(start_state) {twi_state = start_state; TWCR = (1<<TWEN) | (1<<TWSTO) | (1<<TWINT);} |
+void I2C_Reset(void); // Reset I2C |
+ |
+#define BLCONFIG_SUCCESS 0 |
+#define BLCONFIG_ERR_MOTOR_RUNNING 1 |
+#define BLCONFIG_ERR_MOTOR_NOT_EXIST 2 |
+#define BLCONFIG_ERR_HW_NOT_COMPATIBLE 3 |
+#define BLCONFIG_ERR_SW_NOT_COMPATIBLE 4 |
+#define BLCONFIG_ERR_CHECKSUM 5 |
+#define BLCONFIG_ERR_READ_NOT_POSSIBLE 6 |
+ |
+uint8_t I2C_WriteBLConfig(uint8_t motor); |
+uint8_t I2C_ReadBLConfig(uint8_t motor); |
+ |
+#endif |
+ |
+ |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/uart1.c |
---|
0,0 → 1,303 |
/************************************************************************* |
Title: Interrupt UART library with receive/transmit circular buffers |
Author: Peter Fleury <pfleury@gmx.ch> http://jump.to/fleury |
File: $Id: uart.c,v 1.6.2.2 2009/11/29 08:56:12 Peter Exp $ |
Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher |
Hardware: any AVR with built-in UART, |
License: GNU General Public License |
DESCRIPTION: |
An interrupt is generated when the UART has finished transmitting or |
receiving a byte. The interrupt handling routines use circular buffers |
for buffering received and transmitted data. |
The UART_RX_BUFFER_SIZE and UART_TX_BUFFER_SIZE variables define |
the buffer size in bytes. Note that these variables must be a |
power of 2. |
USAGE: |
Refere to the header file uart.h for a description of the routines. |
See also example test_uart.c. |
NOTES: |
Based on Atmel Application Note AVR306 |
LICENSE: |
Copyright (C) 2006 Peter Fleury |
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, or |
any later version. |
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. |
*************************************************************************/ |
#include <avr/io.h> |
#include <avr/interrupt.h> |
#include <avr/pgmspace.h> |
#include "uart1.h" |
#include "main.h" |
// |
// constants and macros |
// |
// size of RX/TX buffers |
#define UART_RX_BUFFER_MASK ( UART_RX_BUFFER_SIZE - 1) |
#define UART_TX_BUFFER_MASK ( UART_TX_BUFFER_SIZE - 1) |
#if ( UART_RX_BUFFER_SIZE & UART_RX_BUFFER_MASK ) |
#error RX buffer size is not a power of 2 |
#endif |
#if ( UART_TX_BUFFER_SIZE & UART_TX_BUFFER_MASK ) |
#error TX buffer size is not a power of 2 |
#endif |
// ATmega with two USART |
#define ATMEGA_USART1 |
#define UART1_STATUS UCSR1A |
#define UART1_CONTROL UCSR1B |
#define UART1_DATA UDR1 |
#define UART1_UDRIE UDRIE1 |
// |
// module global variables |
// |
#if defined( ATMEGA_USART1 ) |
static volatile unsigned char UART1_TxBuf[UART_TX_BUFFER_SIZE]; |
static volatile unsigned char UART1_RxBuf[UART_RX_BUFFER_SIZE]; |
static volatile unsigned char UART1_TxHead; |
static volatile unsigned char UART1_TxTail; |
static volatile unsigned char UART1_RxHead; |
static volatile unsigned char UART1_RxTail; |
static volatile unsigned char UART1_LastRxError; |
#endif |
// |
// these functions are only for ATmegas with two USART |
// |
#if defined( ATMEGA_USART1 ) |
//-------------------------------------------------------------- |
// Function: UART1 Receive Complete interrupt |
// Purpose: called when the UART1 has received a character |
//-------------------------------------------------------------- |
ISR(USART1_RX_vect) |
{ |
unsigned char tmphead; |
unsigned char data; |
unsigned char usr; |
unsigned char lastRxError; |
// read UART status register and UART data register |
usr = UART1_STATUS; |
data = UART1_DATA; |
lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) ); |
// calculate buffer index |
tmphead = ( UART1_RxHead + 1) & UART_RX_BUFFER_MASK; |
if ( tmphead == UART1_RxTail ) |
{ |
// error: receive buffer overflow |
lastRxError = UART_BUFFER_OVERFLOW >> 8; |
} |
else |
{ |
// store new index |
UART1_RxHead = tmphead; |
// store received data in buffer |
UART1_RxBuf[tmphead] = data; |
} |
UART1_LastRxError = lastRxError; |
} |
//-------------------------------------------------------------- |
// Function: UART1 Data Register Empty interrupt |
// Purpose: called when the UART1 is ready to transmit the next byte |
//-------------------------------------------------------------- |
ISR(USART1_UDRE_vect) |
{ |
unsigned char tmptail; |
if ( UART1_TxHead != UART1_TxTail) |
{ |
// calculate and store new buffer index |
tmptail = (UART1_TxTail + 1) & UART_TX_BUFFER_MASK; |
UART1_TxTail = tmptail; |
// get one byte from buffer and write it to UART |
UART1_DATA = UART1_TxBuf[tmptail]; // start transmission |
} |
else |
{ |
// tx buffer empty, disable UDRE interrupt |
UART1_CONTROL &= ~_BV(UART1_UDRIE); |
} |
} |
//-------------------------------------------------------------- |
// Function: uart1_init() |
// Purpose: initialize UART1 and set baudrate |
// Input: baudrate using macro UART_BAUD_SELECT() |
// Returns: none |
//-------------------------------------------------------------- |
void uart1_init(unsigned int baudrate) |
{ |
UART1_TxHead = 0; |
UART1_TxTail = 0; |
UART1_RxHead = 0; |
UART1_RxTail = 0; |
// Set baud rate |
if ( baudrate & 0x8000 ) |
{ |
UART1_STATUS = (1<<U2X1); //Enable 2x speed |
baudrate &= ~0x8000; |
} |
UBRR1H = (unsigned char)(baudrate>>8); |
UBRR1L = (unsigned char) baudrate; |
// Enable USART receiver and transmitter and receive complete interrupt |
UART1_CONTROL = _BV(RXCIE1)|(1<<RXEN1)|(1<<TXEN1); |
// Set frame format: asynchronous, 8data, no parity, 1stop bit |
#ifdef URSEL1 |
UCSR1C = (1<<URSEL1)|(3<<UCSZ10); |
#else |
UCSR1C = (3<<UCSZ10); |
#endif |
} |
//-------------------------------------------------------------- |
// Function: uart1_getc() |
// Purpose: return byte from ringbuffer |
// Returns: lower byte: received byte from ringbuffer |
// higher byte: last receive error |
//-------------------------------------------------------------- |
unsigned int uart1_getc(void) |
{ |
unsigned char tmptail; |
unsigned char data; |
if ( UART1_RxHead == UART1_RxTail ) |
{ |
return UART_NO_DATA; // no data available |
} |
// calculate /store buffer index |
tmptail = (UART1_RxTail + 1) & UART_RX_BUFFER_MASK; |
UART1_RxTail = tmptail; |
// get data from receive buffer |
data = UART1_RxBuf[tmptail]; |
return (UART1_LastRxError << 8) + data; |
} |
//-------------------------------------------------------------- |
// Function: uart1_putc() |
// Purpose: write byte to ringbuffer for transmitting via UART |
// Input: byte to be transmitted |
// Returns: 1 on succes, 0 if remote not ready |
//-------------------------------------------------------------- |
int uart1_putc(unsigned char data) |
{ |
unsigned char tmphead; |
tmphead = (UART1_TxHead + 1) & UART_TX_BUFFER_MASK; |
while ( tmphead == UART1_TxTail ) |
{;} // wait for free space in buffer |
UART1_TxBuf[tmphead] = data; |
UART1_TxHead = tmphead; |
// enable UDRE interrupt |
UART1_CONTROL |= _BV(UART1_UDRIE); |
return (UART1_LastRxError << 8) + data; |
} |
//-------------------------------------------------------------- |
// Function: uart1_puts() |
// Purpose: transmit string to UART1 |
// Input: string to be transmitted |
// Returns: none |
//-------------------------------------------------------------- |
void uart1_puts(const char *s ) |
{ |
while (*s) |
uart1_putc(*s++); |
} |
//-------------------------------------------------------------- |
// Function: uart1_puts_p() |
// Purpose: transmit string from program memory to UART1 |
// Input: program memory string to be transmitted |
// Returns: none |
//-------------------------------------------------------------- |
void uart1_puts_p(const char *progmem_s ) |
{ |
register char c; |
while ( (c = pgm_read_byte(progmem_s++)) ) |
uart1_putc(c); |
} |
//-------------------------------------------------------------- |
// Function: uart1_available() |
// Purpose: Determine the number of bytes waiting in the receive buffer |
// Input: None |
// Returns: Integer number of bytes in the receive buffer |
//-------------------------------------------------------------- |
int uart1_available(void) |
{ |
return (UART_RX_BUFFER_MASK + UART1_RxHead - UART1_RxTail) % UART_RX_BUFFER_MASK; |
} |
//-------------------------------------------------------------- |
// Function: uart1_flush() |
// Purpose: Flush bytes waiting the receive buffer. Acutally ignores them. |
// Input: None |
// Returns: None |
//-------------------------------------------------------------- |
void uart1_flush(void) |
{ |
UART1_RxHead = UART1_RxTail; |
} |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/uart1.h |
---|
0,0 → 1,167 |
/************************************************************************ |
Title: Interrupt UART library with receive/transmit circular buffers |
Author: Peter Fleury <pfleury@gmx.ch> http://jump.to/fleury |
File: $Id: uart.h,v 1.8.2.1 2007/07/01 11:14:38 peter Exp $ |
Software: AVR-GCC 4.1, AVR Libc 1.4 |
Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz |
License: GNU General Public License |
Usage: see Doxygen manual |
LICENSE: |
Copyright (C) 2006 Peter Fleury |
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, or |
any later version. |
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. |
************************************************************************/ |
// |
// @defgroup pfleury_uart UART Library |
// @code #include <uart.h> @endcode |
// |
// @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. |
// |
// This library can be used to transmit and receive data through the built in UART. |
// |
// An interrupt is generated when the UART has finished transmitting or |
// receiving a byte. The interrupt handling routines use circular buffers |
// for buffering received and transmitted data. |
// |
// The UART_RX_BUFFER_SIZE and UART_TX_BUFFER_SIZE constants define |
// the size of the circular buffers in bytes. Note that these constants must be a power of 2. |
// You may need to adapt this constants to your target and your application by adding |
// CDEFS += -DUART_RX_BUFFER_SIZE=nn -DUART_RX_BUFFER_SIZE=nn to your Makefile. |
// |
// @note Based on Atmel Application Note AVR306 |
// @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury |
// |
#ifndef UART_H |
#define UART_H |
#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 |
#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" |
#endif |
// constants and macros |
// @brief UART Baudrate Expression |
// @param xtalcpu system clock in Mhz, e.g. 4000000L for 4Mhz |
// @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 |
// |
#define UART_BAUD_SELECT(baudRate,xtalCpu) ((xtalCpu)/((baudRate)*16l)-1) |
// @brief UART Baudrate Expression for ATmega double speed mode |
// @param xtalcpu system clock in Mhz, e.g. 4000000L for 4Mhz |
// @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 |
// |
#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) (((xtalCpu)/((baudRate)*8l)-1)|0x8000) |
// Size of the circular receive buffer, must be power of 2 |
#ifndef UART_RX_BUFFER_SIZE |
#define UART_RX_BUFFER_SIZE 32 |
#endif |
// Size of the circular transmit buffer, must be power of 2 |
#ifndef UART_TX_BUFFER_SIZE |
#define UART_TX_BUFFER_SIZE 32 |
#endif |
// test if the size of the circular buffers fits into SRAM |
#if ( (UART_RX_BUFFER_SIZE+UART_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) |
#error "size of UART_RX_BUFFER_SIZE + UART_TX_BUFFER_SIZE larger than size of SRAM" |
#endif |
// high byte error return code of uart_getc() |
#define UART_FRAME_ERROR 0x0800 // Framing Error by UART |
#define UART_OVERRUN_ERROR 0x0400 // Overrun condition by UART |
#define UART_BUFFER_OVERFLOW 0x0200 // receive ringbuffer overflow |
#define UART_NO_DATA 0x0100 // no receive data available |
// |
// function prototypes |
// |
// |
// @brief Initialize UART and set baudrate |
// @param baudrate Specify baudrate using macro UART_BAUD_SELECT() |
// @return none |
// |
extern void uart_init(unsigned int baudrate); |
// |
// @brief Get received byte from ringbuffer |
// |
// Returns in the lower byte the received character and in the |
// higher byte the last receive error. |
// UART_NO_DATA is returned when no data is available. |
// |
// @param void |
// @return lower byte: received byte from ringbuffer |
// @return higher byte: last receive status |
// - \b 0 successfully received data from UART |
// - \b UART_NO_DATA |
// <br>no receive data available |
// - \b UART_BUFFER_OVERFLOW |
// <br>Receive ringbuffer overflow. |
// We are not reading the receive buffer fast enough, |
// one or more received character have been dropped |
// - \b UART_OVERRUN_ERROR |
// <br>Overrun condition by UART. |
// A character already present in the UART UDR register was |
// not read by the interrupt handler before the next character arrived, |
// one or more received characters have been dropped. |
// - \b UART_FRAME_ERROR |
// <br>Framing Error by UART |
// |
extern unsigned int uart_getc(void); |
// |
// @brief Put byte to ringbuffer for transmitting via UART |
// @param data byte to be transmitted |
// @return none |
// |
// @brief Initialize USART1 (only available on selected ATmegas) @see uart_init |
extern void uart1_init(unsigned int baudrate); |
// @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc |
extern unsigned int uart1_getc(void); |
// @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc |
//extern void uart1_putc(unsigned char data); |
extern int uart1_putc(unsigned char data); |
// @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts |
extern void uart1_puts(const char *s ); |
// @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p |
extern void uart1_puts_p(const char *s ); |
// @brief Macro to automatically put a string constant into program memory |
#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s)) |
extern char *utoa1(char* buffer, const unsigned int size, unsigned int value); |
#endif // UART_H |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/usart.c |
---|
0,0 → 1,634 |
/***************************************************************************** |
* 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 <avr/wdt.h> |
#include <util/delay.h> |
#include <stdarg.h> |
#include "main.h" |
#include "usart.h" |
#include "lcd.h" |
#include "timer.h" |
uint8_t buffer[30]; |
volatile uint8_t txd_buffer[TXD_BUFFER_LEN]; |
volatile uint8_t txd_complete = TRUE; |
volatile uint8_t rxd_buffer[RXD_BUFFER_LEN]; |
volatile uint8_t rxd_buffer_locked = FALSE; |
volatile uint8_t ReceivedBytes = 0; |
volatile uint8_t *pRxData = 0; |
volatile uint8_t RxDataLen = 0; |
volatile uint16_t stat_crc_error = 0; |
volatile uint16_t stat_overflow_error = 0; |
volatile uint8_t rx_byte; |
volatile uint8_t rxFlag = 0; |
#define UART_RXBUFSIZE 64 |
#define UART_NO_DATA 0x0100 /* no receive data available */ |
volatile static uint8_t rxbuf[UART_RXBUFSIZE]; |
volatile static uint8_t *volatile rxhead, *volatile rxtail; |
/* |
//----------------------------------------------------------------------------- |
// USART1 transmitter ISR |
ISR (USART1_TX_vect) |
{ |
static uint16_t ptr_txd1_buffer = 0; |
uint8_t tmp_tx1; |
if(!txd1_complete) // transmission not completed |
{ |
ptr_txd1_buffer++; // [0] was already sent |
tmp_tx1 = txd1_buffer[ptr_txd1_buffer]; |
// if terminating character or end of txd buffer was reached |
if((tmp_tx1 == '\r') || (ptr_txd1_buffer == TXD_BUFFER_LEN)) |
{ |
ptr_txd1_buffer = 0; // reset txd pointer |
txd1_complete = TRUE; // stop transmission |
} |
UDR1 = tmp_tx1; // send current byte will trigger this ISR again |
} |
// transmission completed |
else ptr_txd1_buffer = 0; |
} |
*/ |
#ifdef USART_INT |
//----------------------------------------------------------------------------- |
// USART0 transmitter ISR |
ISR (USART_TX_vect) |
{ |
static uint16_t ptr_txd_buffer = 0; |
uint8_t tmp_tx; |
if(!txd_complete) // transmission not completed |
{ |
ptr_txd_buffer++; // [0] was already sent |
tmp_tx = txd_buffer[ptr_txd_buffer]; |
// if terminating character or end of txd buffer was reached |
if((tmp_tx == '\r') || (ptr_txd_buffer == TXD_BUFFER_LEN)) |
{ |
ptr_txd_buffer = 0; // reset txd pointer |
txd_complete = TRUE; // stop transmission |
} |
UDR = tmp_tx; // send current byte will trigger this ISR again |
} |
// transmission completed |
else ptr_txd_buffer = 0; |
} |
#endif |
//----------------------------------------------------------------------------- |
// |
// |
//uint8_t uart_getc_nb(uint8_t *c) |
//{ |
// if (rxhead==rxtail) return 0; |
// *c = *rxtail; |
// if (++rxtail == (rxbuf + UART_RXBUFSIZE)) rxtail = rxbuf; |
// return 1; |
//} |
ISR (USART0_RX_vect) |
{ |
static uint16_t crc; |
static uint8_t ptr_rxd_buffer = 0; |
uint8_t crc1, crc2; |
uint8_t c; |
// IdleTimer = 0; |
if (current_hardware == Wi232) |
{ |
// rx_byte = c; |
// rxFlag = 1; |
int diff; |
uint8_t c; |
c=UDR; |
diff = rxhead - rxtail; |
if (diff < 0) diff += UART_RXBUFSIZE; |
if (diff < UART_RXBUFSIZE -1) |
{ |
*rxhead = c; |
++rxhead; |
if (rxhead == (rxbuf + UART_RXBUFSIZE)) rxhead = rxbuf; |
}; |
// USART_putc (c); |
return; |
} |
if (current_hardware == MKGPS) |
{ |
// rx_byte = c; |
// rxFlag = 1; |
int diff; |
uint8_t c; |
c=UDR; |
diff = rxhead - rxtail; |
if (diff < 0) diff += UART_RXBUFSIZE; |
if (diff < UART_RXBUFSIZE -1) |
{ |
*rxhead = c; |
++rxhead; |
if (rxhead == (rxbuf + UART_RXBUFSIZE)) rxhead = rxbuf; |
}; |
return; |
} |
c = UDR; // catch the received byte |
if (rxd_buffer_locked) |
return; // if rxd buffer is locked immediately return |
// the rxd buffer is unlocked |
if ((ptr_rxd_buffer == 0) && (c == '#')) // if rxd buffer is empty and syncronisation character is received |
{ |
rxd_buffer[ptr_rxd_buffer++] = c; // copy 1st byte to buffer |
crc = c; // init crc |
} |
else if (ptr_rxd_buffer < RXD_BUFFER_LEN) // collect incomming bytes |
{ |
if(c != '\r') // no termination character |
{ |
rxd_buffer[ptr_rxd_buffer++] = c; // copy byte to rxd buffer |
crc += c; // update crc |
} |
else // termination character was received |
{ |
// the last 2 bytes are no subject for checksum calculation |
// they are the checksum itself |
crc -= rxd_buffer[ptr_rxd_buffer-2]; |
crc -= rxd_buffer[ptr_rxd_buffer-1]; |
// calculate checksum from transmitted data |
crc %= 4096; |
crc1 = '=' + crc / 64; |
crc2 = '=' + crc % 64; |
// compare checksum to transmitted checksum bytes |
if((crc1 == rxd_buffer[ptr_rxd_buffer-2]) && (crc2 == rxd_buffer[ptr_rxd_buffer-1])) |
{ // checksum valid |
rxd_buffer[ptr_rxd_buffer] = '\r'; // set termination character |
ReceivedBytes = ptr_rxd_buffer + 1;// store number of received bytes |
if (mode == rxd_buffer[2]) |
{ |
rxd_buffer_locked = TRUE; // lock the rxd buffer |
// if 2nd byte is an 'R' enable watchdog that will result in an reset |
if(rxd_buffer[2] == 'R') {wdt_enable(WDTO_250MS);} // Reset-Commando |
} |
} |
else |
{ // checksum invalid |
stat_crc_error++; |
rxd_buffer_locked = FALSE; // unlock rxd buffer |
} |
ptr_rxd_buffer = 0; // reset rxd buffer pointer |
} |
} |
else // rxd buffer overrun |
{ |
stat_overflow_error++; |
ptr_rxd_buffer = 0; // reset rxd buffer |
rxd_buffer_locked = FALSE; // unlock rxd buffer |
} |
} |
//----------------------------------------------------------------------------- |
// Function: uart0_getc() |
// Purpose: return byte from ringbuffer |
// Returns: lower byte: received byte from ringbuffer |
// higher byte: last receive error |
//----------------------------------------------------------------------------- |
char USART_getc(void) |
{ |
char val; |
// while(rxhead==rxtail) ; |
if (rxhead==rxtail) |
return val=0; |
// IdleTimer = 0; |
val = *rxtail; |
if (++rxtail == (rxbuf + UART_RXBUFSIZE)) |
rxtail = rxbuf; |
return val; |
} |
uint8_t uart_getc_nb(uint8_t *c) |
{ |
if (rxhead==rxtail) |
return 0; |
// IdleTimer = 0; |
*c = *rxtail; |
if (++rxtail == (rxbuf + UART_RXBUFSIZE)) |
rxtail = rxbuf; |
return 1; |
} |
//----------------------------------------------------------------------------- |
// |
//----------------------------------------------------------------------------- |
// |
void USART_Init (unsigned int baudrate) |
{ |
// set clock divider |
// #undef BAUD |
// #define BAUD baudrate |
// #include <util/setbaud.h> |
// UBRRH = UBRRH_VALUE; |
// UBRRL = UBRRL_VALUE; |
UBRRH = (unsigned char)(baudrate>>8); |
UBRRL = (unsigned char) baudrate; |
#if USE_2X |
UCSRA |= (1 << U2X); // enable double speed operation |
#else |
UCSRA &= ~(1 << U2X); // disable double speed operation |
#endif |
// set 8N1 |
#if defined (__AVR_ATmega8__) || defined (__AVR_ATmega32__) |
UCSRC = (1 << URSEL) | (1 << UCSZ1) | (1 << UCSZ0); |
#else |
UCSRC = (1 << UCSZ1) | (1 << UCSZ0); |
#endif |
UCSRB &= ~(1 << UCSZ2); |
// flush receive buffer |
while ( UCSRA & (1 << RXC) ) UDR; |
UCSRB |= (1 << RXEN) | (1 << TXEN); |
#ifdef USART_INT |
UCSRB |= (1 << RXCIE) | (1 << TXCIE); |
#else |
UCSRB |= (1 << RXCIE); |
#endif |
rxhead = rxtail = rxbuf; |
} |
//----------------------------------------------------------------------------- |
// disable the txd pin of usart |
void USART_DisableTXD (void) |
{ |
#ifdef USART_INT |
UCSRB &= ~(1 << TXCIE); // disable TX-Interrupt |
#endif |
UCSRB &= ~(1 << TXEN); // disable TX in USART |
DDRB &= ~(1 << DDB3); // set TXD pin as input |
PORTB &= ~(1 << PORTB3); // disable pullup on TXD pin |
} |
//----------------------------------------------------------------------------- |
// enable the txd pin of usart |
void USART_EnableTXD (void) |
{ |
DDRB |= (1 << DDB3); // set TXD pin as output |
PORTB &= ~(1 << PORTB3); // disable pullup on TXD pin |
UCSRB |= (1 << TXEN); // enable TX in USART |
#ifdef USART_INT |
UCSRB |= (1 << TXCIE); // enable TX-Interrupt |
#endif |
} |
//----------------------------------------------------------------------------- |
// short script to directly send a request thorugh usart including en- and disabling it |
// where <address> is the address of the receipient, <label> is which data set to request |
// and <ms> represents the milliseconds delay between data |
void USART_request_mk_data (uint8_t cmd, uint8_t addr, uint8_t ms) |
{ |
USART_EnableTXD (); // re-enable TXD pin |
unsigned char mstenth = ms/10; |
SendOutData(cmd, addr, 1, &mstenth, 1); |
// wait until command transmitted |
while (txd_complete == FALSE); |
USART_DisableTXD (); // disable TXD pin again |
} |
//----------------------------------------------------------------------------- |
// |
void USART_putc (char c) |
{ |
#ifdef USART_INT |
#else |
loop_until_bit_is_set(UCSRA, UDRE); |
UDR = c; |
#endif |
} |
//----------------------------------------------------------------------------- |
// |
void USART_puts (char *s) |
{ |
#ifdef USART_INT |
#else |
while (*s) |
{ |
USART_putc (*s); |
s++; |
} |
#endif |
} |
//----------------------------------------------------------------------------- |
// |
void USART_puts_p (const char *s) |
{ |
#ifdef USART_INT |
#else |
while (pgm_read_byte(s)) |
{ |
USART_putc (pgm_read_byte(s)); |
s++; |
} |
#endif |
} |
//----------------------------------------------------------------------------- |
// |
void SendOutData(uint8_t cmd, uint8_t addr, uint8_t numofbuffers, ...) // uint8_t *pdata, uint8_t len, ... |
{ |
va_list ap; |
uint16_t pt = 0; |
uint8_t a,b,c; |
uint8_t ptr = 0; |
uint16_t tmpCRC = 0; |
uint8_t *pdata = 0; |
int len = 0; |
txd_buffer[pt++] = '#'; // Start character |
txd_buffer[pt++] = 'a' + addr; // Address (a=0; b=1,...) |
txd_buffer[pt++] = cmd; // Command |
va_start(ap, numofbuffers); |
if(numofbuffers) |
{ |
pdata = va_arg (ap, uint8_t*); |
len = va_arg (ap, int); |
ptr = 0; |
numofbuffers--; |
} |
while(len) |
{ |
if(len) |
{ |
a = pdata[ptr++]; |
len--; |
if((!len) && numofbuffers) |
{ |
pdata = va_arg(ap, uint8_t*); |
len = va_arg(ap, int); |
ptr = 0; |
numofbuffers--; |
} |
} |
else |
a = 0; |
if(len) |
{ |
b = pdata[ptr++]; |
len--; |
if((!len) && numofbuffers) |
{ |
pdata = va_arg(ap, uint8_t*); |
len = va_arg(ap, int); |
ptr = 0; |
numofbuffers--; |
} |
} |
else |
b = 0; |
if(len) |
{ |
c = pdata[ptr++]; |
len--; |
if((!len) && numofbuffers) |
{ |
pdata = va_arg(ap, uint8_t*); |
len = va_arg(ap, int); |
ptr = 0; |
numofbuffers--; |
} |
} |
else |
c = 0; |
txd_buffer[pt++] = '=' + (a >> 2); |
txd_buffer[pt++] = '=' + (((a & 0x03) << 4) | ((b & 0xf0) >> 4)); |
txd_buffer[pt++] = '=' + (((b & 0x0f) << 2) | ((c & 0xc0) >> 6)); |
txd_buffer[pt++] = '=' + ( c & 0x3f); |
} |
va_end(ap); |
for(a = 0; a < pt; a++) |
{ |
tmpCRC += txd_buffer[a]; |
} |
tmpCRC %= 4096; |
txd_buffer[pt++] = '=' + tmpCRC / 64; |
txd_buffer[pt++] = '=' + tmpCRC % 64; |
txd_buffer[pt++] = '\r'; |
txd_complete = FALSE; |
#ifdef USART_INT |
UDR = txd_buffer[0]; // initiates the transmittion (continued in the TXD ISR) |
#else |
for(a = 0; a < pt; a++) |
{ |
loop_until_bit_is_set(UCSRA, UDRE); |
UDR = txd_buffer[a]; |
} |
txd_complete = TRUE; |
#endif |
} |
//----------------------------------------------------------------------------- |
// |
void Decode64 (void) |
{ |
uint8_t a,b,c,d; |
uint8_t ptrIn = 3; |
uint8_t ptrOut = 3; |
uint8_t len = ReceivedBytes - 6; |
while (len) |
{ |
a = rxd_buffer[ptrIn++] - '='; |
b = rxd_buffer[ptrIn++] - '='; |
c = rxd_buffer[ptrIn++] - '='; |
d = rxd_buffer[ptrIn++] - '='; |
//if(ptrIn > ReceivedBytes - 3) break; |
if (len--) |
rxd_buffer[ptrOut++] = (a << 2) | (b >> 4); |
else |
break; |
if (len--) |
rxd_buffer[ptrOut++] = ((b & 0x0f) << 4) | (c >> 2); |
else |
break; |
if (len--) |
rxd_buffer[ptrOut++] = ((c & 0x03) << 6) | d; |
else |
break; |
} |
pRxData = &rxd_buffer[3]; |
RxDataLen = ptrOut - 3; |
} |
//----------------------------------------------------------------------------- |
// |
void SwitchToNC (void) |
{ |
if(hardware == NC) |
{ |
// switch to NC |
USART_putc (0x1b); |
USART_putc (0x1b); |
USART_putc (0x55); |
USART_putc (0xaa); |
USART_putc (0x00); |
current_hardware = NC; |
_delay_ms (50); |
} |
} |
//----------------------------------------------------------------------------- |
// |
//----------------------------------------------------------------------------- |
// |
void SwitchToWi232 (void) |
{ |
// if(hardware == NC) |
{ |
// switch to Wi232 |
current_hardware = Wi232; |
_delay_ms (50); |
} |
} |
//----------------------------------------------------------------------------- |
// |
void SwitchToFC (void) |
{ |
uint8_t cmd; |
if (current_hardware == NC) |
{ |
// switch to FC |
cmd = 0x00; // 0 = FC, 1 = MK3MAG, 2 = MKGPS |
SendOutData('u', ADDRESS_NC, 1, &cmd, 1); |
current_hardware = FC; |
_delay_ms (50); |
} |
} |
//----------------------------------------------------------------------------- |
// |
void SwitchToMAG (void) |
{ |
uint8_t cmd; |
if (current_hardware == NC) |
{ |
// switch to MK3MAG |
cmd = 0x01; // 0 = FC, 1 = MK3MAG, 2 = MKGPS |
SendOutData('u', ADDRESS_NC, 1, &cmd, 1); |
current_hardware = MK3MAG; |
_delay_ms (50); |
} |
} |
//----------------------------------------------------------------------------- |
// |
void SwitchToGPS (void) |
{ |
uint8_t cmd; |
if (current_hardware == NC) |
{ |
// switch to MKGPS |
cmd = 0x02; // 0 = FC, 1 = MK3MAG, 2 = MKGPS |
SendOutData('u', ADDRESS_NC, 1, &cmd, 1); |
current_hardware = MKGPS; |
_delay_ms (50); |
} |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/usart.h |
---|
0,0 → 1,149 |
/***************************************************************************** |
* 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* |
*****************************************************************************/ |
#ifndef _USART_H |
#define _USART_H |
//-------------------------------------------------------------- |
// |
#ifndef FALSE |
#define FALSE 0 |
#endif |
#ifndef TRUE |
#define TRUE 1 |
#endif |
// addresses |
#define ADDRESS_ANY 0 |
#define ADDRESS_FC 1 |
#define ADDRESS_NC 2 |
#define ADDRESS_MAG 3 |
// must be at least 4('#'+Addr+'CmdID'+'\r')+ (80 * 4)/3 = 111 bytes |
#define TXD_BUFFER_LEN 60 |
#define RXD_BUFFER_LEN 180 |
// Baud rate of the USART |
#define USART_BAUD 57600 |
//#define USART_BAUD 125000 |
//-------------------------------------------------------------- |
// |
extern uint8_t buffer[30]; |
extern volatile uint8_t txd_buffer[TXD_BUFFER_LEN]; |
extern volatile uint8_t txd_complete; |
extern volatile uint8_t txd1_buffer[TXD_BUFFER_LEN]; |
extern volatile uint8_t txd1_complete; |
extern volatile uint8_t rxd_buffer[RXD_BUFFER_LEN]; |
extern volatile uint8_t rxd_buffer_locked; |
extern volatile uint8_t ReceivedBytes; |
extern volatile uint8_t *pRxData; |
extern volatile uint8_t RxDataLen; |
extern volatile uint16_t stat_crc_error; |
extern volatile uint16_t stat_overflow_error; |
extern volatile uint8_t rxFlag; |
extern volatile uint8_t rx_byte; |
//-------------------------------------------------------------- |
// |
void USART_Init (unsigned int baudrate); |
void USART_DisableTXD (void); |
void USART_EnableTXD (void); |
void USART_request_mk_data (uint8_t cmd, uint8_t addr, uint8_t ms); |
void USART_putc (char c); |
void USART_puts (char *s); |
void USART_puts_p (const char *s); |
extern char USART_getc(void); |
void SendOutData (uint8_t cmd, uint8_t addr, uint8_t numofbuffers, ...); // uint8_t *pdata, uint8_t len, ... |
//void SendOutData(uint8_t cmd, uint8_t addr, uint8_t numofbuffers, uint8_t *pdata, uint8_t len); // uint8_t *pdata, uint8_t len, ... |
void Decode64 (void); |
void SwitchToNC (void); |
void SwitchToFC (void); |
void SwitchToMAG (void); |
void SwitchToGPS (void); |
void SwitchToWi232 (void); |
void debug1(void); |
uint8_t uart_getc_nb(uint8_t*); |
//-------------------------------------------------------------- |
//Anpassen der seriellen Schnittstellen Register |
#define USART_RXC_vect USART0_RX_vect |
//-------------------------------------------------------------- |
#define UCSRA UCSR0A |
#define UCSRB UCSR0B |
#define UCSRC UCSR0C |
#define UDR UDR0 |
#define UBRRL UBRR0L |
#define UBRRH UBRR0H |
// UCSRA |
#define RXC RXC0 |
#define TXC TXC0 |
#define UDRE UDRE0 |
#define FE FE0 |
#define UPE UPE0 |
#define U2X U2X0 |
#define MPCM MPCM0 |
// UCSRB |
#define RXCIE RXCIE0 |
#define TXCIE TXCIE0 |
#define UDRIE UDRIE0 |
#define TXEN TXEN0 |
#define RXEN RXEN0 |
#define UCSZ2 UCSZ02 |
#define RXB8 RXB80 |
#define TXB8 TXB80 |
// UCSRC |
#define UMSEL1 UMSEL01 |
#define UMSEL0 UMSEL00 |
#define UPM1 UPM01 |
#define UPM0 UPM00 |
#define USBS USBS0 |
#define UCSZ1 UCSZ01 |
#define UCSZ0 UCSZ00 |
#define UCPOL UCPOL0 |
#endif |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/waypoints.c |
---|
0,0 → 1,347 |
/*#######################################################################################*/ |
/* !!! THIS IS NOT FREE SOFTWARE !!! */ |
/*#######################################################################################*/ |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + Copyright (c) 2008 Ingo Busker, Holger Buss |
// + Nur für den privaten Gebrauch / NON-COMMERCIAL USE ONLY |
// + FOR NON COMMERCIAL USE ONLY |
// + www.MikroKopter.com |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation), |
// + dass eine Nutzung (auch auszugsweise) nur für den privaten (nicht-kommerziellen) Gebrauch zulässig ist. |
// + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt |
// + bzgl. der Nutzungsbedingungen aufzunehmen. |
// + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen, |
// + Verkauf von Luftbildaufnahmen, usw. |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht, |
// + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright müssen dann beiliegen |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts |
// + auf anderen Webseiten oder sonstigen Medien veröffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de" |
// + eindeutig als Ursprung verlinkt werden |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + Keine Gewähr auf Fehlerfreiheit, Vollständigkeit oder Funktion |
// + Benutzung auf eigene Gefahr |
// + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + Die Portierung oder Nutzung der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur |
// + mit unserer Zustimmung zulässig |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + Redistributions of source code (with or without modifications) must retain the above copyright notice, |
// + this list of conditions and the following disclaimer. |
// + * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived |
// + from this software without specific prior written permission. |
// + * The use of this project (hardware, software, binary files, sources and documentation) is only permitted |
// + for non-commercial use (directly or indirectly) |
// + Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted |
// + with our written permission |
// + * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be |
// + clearly linked as origin |
// + * porting the sources to other systems or using the software on other systems (except hardware from www.mikrokopter.de) is not allowed |
// |
// + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
// + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
// + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
// + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
// + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
// + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
// + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
// + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
// + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
// + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
// + POSSIBILITY OF SUCH DAMAGE. |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
#include <string.h> |
#include "91x_lib.h" |
#include "waypoints.h" |
#include "uart1.h" |
// the waypoints list |
#define MAX_LIST_LEN 31 |
Point_t PointList[MAX_LIST_LEN]; |
u8 WPIndex = 0; // list index of GPS point representig the current WP, can be maximal WPCount |
u8 POIIndex = 0; // list index of GPS Point representing the current POI, can be maximal WPCount |
u8 WPCount = 0; // number of waypoints |
u8 PointCount = 0; // number of wp in the list can be maximal equal to MAX_LIST_LEN |
u8 POICount = 0; |
u8 WPActive = FALSE; |
u8 PointList_Init(void) |
{ |
return PointList_Clear(); |
} |
u8 PointList_Clear(void) |
{ |
u8 i; |
WPIndex = 0; // real list position are 1 ,2, 3 ... |
POIIndex = 0; // real list position are 1 ,2, 3 ... |
WPCount = 0; // no waypoints |
POICount = 0; |
PointCount = 0; // no contents |
WPActive = FALSE; |
NaviData.WaypointNumber = WPCount; |
NaviData.WaypointIndex = 0; |
for(i = 0; i < MAX_LIST_LEN; i++) |
{ |
PointList[i].Position.Status = INVALID; |
PointList[i].Position.Latitude = 0; |
PointList[i].Position.Longitude = 0; |
PointList[i].Position.Altitude = 0; |
PointList[i].Heading = 361; // invalid value |
PointList[i].ToleranceRadius = 0; // in meters, if the MK is within that range around the target, then the next target is triggered |
PointList[i].HoldTime = 0; // in seconds, if the was once in the tolerance area around a WP, this time defines the delay before the next WP is triggered |
PointList[i].Type = POINT_TYPE_INVALID; |
PointList[i].Event_Flag = 0; // future implementation |
PointList[i].AltitudeRate = 0; // no change of setpoint |
} |
return TRUE; |
} |
u8 PointList_GetCount(void) |
{ |
return PointCount; // number of points in the list |
} |
Point_t* PointList_GetAt(u8 index) |
{ |
if((index > 0) && (index <= PointCount)) return(&(PointList[index-1])); // return pointer to this waypoint |
else return(NULL); |
} |
u8 PointList_SetAt(Point_t* pPoint) |
{ |
// if index is in range |
if((pPoint->Index > 0) && (pPoint->Index <= MAX_LIST_LEN)) |
{ |
// check list entry before update |
switch(PointList[pPoint->Index-1].Type) |
{ |
case POINT_TYPE_INVALID: // was invalid |
switch(pPoint->Type) |
{ |
default: |
case POINT_TYPE_INVALID: |
// nothing to do |
break; |
case POINT_TYPE_WP: |
WPCount++; |
PointCount++; |
break; |
case POINT_TYPE_POI: |
POICount++; |
PointCount++; |
break; |
} |
break; |
case POINT_TYPE_WP: // was a waypoint |
switch(pPoint->Type) |
{ |
case POINT_TYPE_INVALID: |
WPCount--; |
PointCount--; |
break; |
default: |
case POINT_TYPE_WP: |
//nothing to do |
break; |
case POINT_TYPE_POI: |
POICount++; |
WPCount--; |
break; |
} |
break; |
case POINT_TYPE_POI: // was a poi |
switch(pPoint->Type) |
{ |
case POINT_TYPE_INVALID: |
POICount--; |
PointCount--; |
break; |
case POINT_TYPE_WP: |
WPCount++; |
POICount--; |
break; |
case POINT_TYPE_POI: |
default: |
// nothing to do |
break; |
} |
break; |
} |
memcpy(&PointList[pPoint->Index-1], pPoint, sizeof(Point_t)); // copy data to list entry |
NaviData.WaypointNumber = WPCount; |
return pPoint->Index; |
} |
else return(0); |
} |
// returns the pointer to the first waypoint within the list |
Point_t* PointList_WPBegin(void) |
{ |
u8 i; |
WPIndex = 0; // set list position invalid |
if(WPActive == FALSE) return(NULL); |
POIIndex = 0; // set invalid POI |
if(PointCount > 0) |
{ |
// search for first wp in list |
for(i = 0; i <MAX_LIST_LEN; i++) |
{ |
if((PointList[i].Type == POINT_TYPE_WP) && (PointList[i].Position.Status != INVALID)) |
{ |
WPIndex = i + 1; |
break; |
} |
} |
if(WPIndex) // found a WP in the list |
{ |
NaviData.WaypointIndex = 1; |
// update index to POI |
if(PointList[WPIndex-1].Heading < 0) POIIndex = (u8)(-PointList[WPIndex-1].Heading); |
else POIIndex = 0; |
} |
else // some points in the list but no WP found |
{ |
NaviData.WaypointIndex = 0; |
//Check for an existing POI |
for(i = 0; i < MAX_LIST_LEN; i++) |
{ |
if((PointList[i].Type == POINT_TYPE_POI) && (PointList[i].Position.Status != INVALID)) |
{ |
POIIndex = i + 1; |
break; |
} |
} |
} |
} |
else // no point in the list |
{ |
POIIndex = 0; |
NaviData.WaypointIndex = 0; |
} |
if(WPIndex) return(&(PointList[WPIndex-1])); |
else return(NULL); |
} |
// returns the last waypoint |
Point_t* PointList_WPEnd(void) |
{ |
u8 i; |
WPIndex = 0; // set list position invalid |
POIIndex = 0; // set invalid |
if(WPActive == FALSE) return(NULL); |
if(PointCount > 0) |
{ |
// search backward! |
for(i = 1; i <= MAX_LIST_LEN; i++) |
{ |
if((PointList[MAX_LIST_LEN - i].Type == POINT_TYPE_WP) && (PointList[MAX_LIST_LEN - i].Position.Status != INVALID)) |
{ |
WPIndex = MAX_LIST_LEN - i + 1; |
break; |
} |
} |
if(WPIndex) // found a WP within the list |
{ |
NaviData.WaypointIndex = WPCount; |
if(PointList[WPIndex-1].Heading < 0) POIIndex = (u8)(-PointList[WPIndex-1].Heading); |
else POIIndex = 0; |
} |
else // list contains some points but no WP in the list |
{ |
// search backward for a POI! |
for(i = 1; i <= MAX_LIST_LEN; i++) |
{ |
if((PointList[MAX_LIST_LEN - i].Type == POINT_TYPE_POI) && (PointList[MAX_LIST_LEN - i].Position.Status != INVALID)) |
{ |
POIIndex = MAX_LIST_LEN - i + 1; |
break; |
} |
} |
NaviData.WaypointIndex = 0; |
} |
} |
else // no point in the list |
{ |
POIIndex = 0; |
NaviData.WaypointIndex = 0; |
} |
if(WPIndex) return(&(PointList[WPIndex-1])); |
else return(NULL); |
} |
// returns a pointer to the next waypoint or NULL if the end of the list has been reached |
Point_t* PointList_WPNext(void) |
{ |
u8 wp_found = 0; |
if(WPActive == FALSE) return(NULL); |
if(WPIndex < MAX_LIST_LEN) // if there is a next entry in the list |
{ |
u8 i; |
for(i = WPIndex; i < MAX_LIST_LEN; i++) // start search for next at next list entry |
{ |
if((PointList[i].Type == POINT_TYPE_WP) && (PointList[i].Position.Status != INVALID)) // jump over POIs |
{ |
wp_found = i+1; |
break; |
} |
} |
} |
if(wp_found) |
{ |
WPIndex = wp_found; // update list position |
NaviData.WaypointIndex++; |
if(PointList[WPIndex-1].Heading < 0) POIIndex = (u8)(-PointList[WPIndex-1].Heading); |
else POIIndex = 0; |
return(&(PointList[WPIndex-1])); // return pointer to this waypoint |
} |
else |
{ // no next wp found |
NaviData.WaypointIndex = 0; |
POIIndex = 0; |
return(NULL); |
} |
} |
void PointList_WPActive(u8 set) |
{ |
if(set) |
{ |
WPActive = TRUE; |
PointList_WPBegin(); // uopdates POI index |
} |
else |
{ |
WPActive = FALSE; |
POIIndex = 0; // disable POI also |
} |
} |
Point_t* PointList_GetPOI(void) |
{ |
return PointList_GetAt(POIIndex); |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/Transportables_Koptertool/branch/GPL_PKT_V3_5_8b_FC086/waypoints.h |
---|
0,0 → 1,56 |
#ifndef _WAYPOINTS_H |
#define _WAYPOINTS_H |
//#include "ubx.h" |
#define POINT_TYPE_INVALID 255 |
#define POINT_TYPE_WP 0 |
#define POINT_TYPE_POI 1 |
typedef struct |
{ |
s32 Longitude; // in 1E-7 deg |
s32 Latitude; // in 1E-7 deg |
s32 Altitude; // in mm |
u8 Status;// validity of data |
} __attribute__((packed)) GPS_Pos_t; |
typedef struct |
{ |
GPS_Pos_t Position; // the gps position of the waypoint, see ubx.h for details |
s16 Heading; // orientation, 0 no action, 1...360 fix heading, neg. = Index to POI in WP List |
u8 ToleranceRadius; // in meters, if the MK is within that range around the target, then the next target is triggered |
u8 HoldTime; // in seconds, if the was once in the tolerance area around a WP, this time defines the delay before the next WP is triggered |
u8 Event_Flag; // future implementation |
u8 Index; // to indentify different waypoints, workaround for bad communications PC <-> NC |
u8 Type; // typeof Waypoint |
u8 WP_EventChannelValue; // |
u8 AltitudeRate; // rate to change the setpoint |
u8 reserve[8]; // reserve |
} __attribute__((packed)) Point_t; |
// Init List, return TRUE on success |
u8 PointList_Init(void); |
// Clear List, return TRUE on success |
u8 PointList_Clear(void); |
// Returns number of points in the list |
u8 PointList_GetCount(void); |
// return pointer to point at position |
Point_t* PointList_GetAt(u8 index); |
// set a point in the list at index, returns its index on success, else 0 |
u8 PointList_SetAt(Point_t* pPoint); |
// goto the first WP in the list and return pointer to it |
Point_t* PointList_WPBegin(void); |
// goto the last WP in the list and return pointer to it |
Point_t* PointList_WPEnd(void); |
// goto next WP in the list and return pointer to it |
Point_t* PointList_WPNext(void); |
// enables/disables waypoint function |
void PointList_WPActive(u8 set); |
// returns pointer to actual POI |
Point_t* PointList_GetPOI(void); |
#endif // _WAYPOINTS_H |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |