0,0 → 1,159 |
/*#######################################################################################*/ |
/* !!! THIS IS NOT FREE SOFTWARE !!! */ |
/*#######################################################################################*/ |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + Copyright (c) 2008 Ingo Busker, Holger Buss |
// + Nur für den privaten Gebrauch |
// + 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 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 this software (or part of it) 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 "main.h" |
|
u8 OsdBar; // Direction home for OSD |
s16 OsdDistance; // Distance home |
s16 GPS_Nick; |
s16 GPS_Roll; |
|
struct str_GPSParameter GPSParameter; |
|
#define GPS_MODE_FREE 0 |
#define GPS_MODE_AID 1 |
#define GPS_MODE_HOLD 2 |
#define GPS_MODE_HOME 3 |
u32 GpsFlightMode = GPS_MODE_FREE; |
|
//------------------------------------------------------------ |
// Init variables or send configuration to GPS module |
void GPS_Init(void) |
{ |
GPS_Nick = 0; |
GPS_Roll = 0; |
OsdDistance = 0; |
OsdBar = 0; |
|
GPSParameter.P = 100; |
GPSParameter.I = 100; |
GPSParameter.D = 100; |
GPSParameter.A = 100; |
GPSParameter.ACC = 100; |
GPSParameter.ModeSchalter = 100; |
GPSParameter.Amplification = 100;; |
} |
//------------------------------------------------------------ |
|
u8 Navigation(void) |
{ |
static char GpsFix = 0, NewGpsMode = 0; |
static u32 beep_rythm; |
u32 tmp_long; |
if(NewGPSDataAvail) // there are new data from gps module |
{ |
NewGPSDataAvail = 0; |
beep_rythm++; |
|
GPSParameter.ModeSchalter = Parameter_UserParam1; |
GPSParameter.Amplification = (float) Parameter_UserParam2 / (100.0); |
GPSParameter.P = (float) Parameter_UserParam3; |
GPSParameter.I = (float) Parameter_UserParam4; |
GPSParameter.D = (float) Parameter_UserParam5; |
GPSParameter.A = (float) Parameter_UserParam6; |
GPSParameter.ACC = (float) Parameter_UserParam7; |
|
if(SenderOkay < 100) // Empfangsausfall |
{ |
GPSParameter.ModeSchalter = 0; |
GPSParameter.Amplification = 100; |
GPSParameter.P = (float) 90; |
GPSParameter.I = (float) 90; |
GPSParameter.D = (float) 90; |
GPSParameter.A = (float) 90; |
GPSParameter.ACC = (float) 90; |
} |
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
//+ GPS-Mode |
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
tmp_long = GpsFlightMode; |
if(GPSParameter.ModeSchalter < 20) GpsFlightMode = GPS_MODE_AID; |
else |
if(GPSParameter.ModeSchalter < 200) GpsFlightMode = GPS_MODE_FREE; |
else GpsFlightMode = GPS_MODE_HOME; |
if(GpsFlightMode != tmp_long) // Mode changed |
{ |
BeepTime = 100; |
NewGpsMode = 1; |
} |
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
//+ Fix okay |
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
if((GPS_Data.Flags & GPS_FIX) && ((GPS_Data.Used_Sat >= GPS_SAT_MIN) || GpsFix)) |
{ |
GpsFix = 1; // hysteresis |
// here is a good place to put your GPS code... |
GPS_Nick = 0; // do nothing |
GPS_Roll = 0; // do nothing |
} |
else |
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
//+ No Fix |
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
{ |
GPS_Nick = 0; // reset value |
GPS_Roll = 0; // reset value |
if(!(GPS_Data.Flags & 0x01) && !(beep_rythm % 5)) BeepTime = 100; |
else if (GPS_Data.Used_Sat < GPS_SAT_MIN && !(beep_rythm % 5)) BeepTime = 10; |
} |
} |
return (0); |
} |
|