0,0 → 1,281 |
/*#######################################################################################*/ |
/* !!! 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 <stdlib.h> |
#include "91x_lib.h" |
#include "printf_P.h" |
#include "main.h" |
#include "ubx.h" |
#include "GPS.h" |
#include "timer.h" |
#include "i2c.h" |
#include "spi_slave.h" |
#include "menu.h" |
#include "uart1.h" |
|
s8 DisplayBuff[DISPLAYBUFFSIZE] = "Hello World"; |
u8 DispPtr = 0; |
|
u8 MenuItem = 0; |
u8 MaxMenuItem = 12; |
u8 RemoteKeys = 0; |
|
#define KEY1 0x01 |
#define KEY2 0x02 |
#define KEY3 0x04 |
#define KEY4 0x08 |
#define KEY5 0x10 |
|
/************************************/ |
/* Clear LCD Buffer */ |
/************************************/ |
void LCD_Clear(void) |
{ |
u8 i; |
for( i = 0; i < DISPLAYBUFFSIZE; i++) DisplayBuff[i] = ' '; |
} |
|
|
/************************************/ |
/* Update Menu on LCD */ |
/************************************/ |
// Display with 20 characters in 4 lines |
void LCD_PrintMenu(void) |
{ |
s32 i1,i2; |
if(RemoteKeys & KEY1) { if(MenuItem) MenuItem--; else MenuItem = MaxMenuItem;} |
if(RemoteKeys & KEY2) { if(MenuItem == MaxMenuItem) MenuItem = 0; else MenuItem++;} |
if((RemoteKeys & KEY1) && (RemoteKeys & KEY2)) MenuItem = 0; |
|
LCD_Clear(); |
if(MenuItem > MaxMenuItem) MenuItem = MaxMenuItem; |
// print menu item number in the upper right corner |
if(MenuItem < 10) |
{ |
LCD_printfxy(17,0,"[%i]",MenuItem); |
} |
else |
{ |
LCD_printfxy(16,0,"[%i]",MenuItem); |
} |
|
switch(MenuItem) |
{ |
// Version Info |
case 0: |
LCD_printfxy(0,0,"++ Navi-Ctrl ++"); |
LCD_printfxy(0,1," V%d.%d%c ", VERSION_MAJOR, VERSION_MINOR, 'a'+ VERSION_PATCH); |
if(ErrorCode) LCD_printfxy(11,1," Err:%d",ErrorCode) else LCD_printfxy(11,1," "); |
LCD_printfxy(0,2,"%s",ErrorMSG); |
LCD_printfxy(0,3,"(c) Buss, Busker"); |
break; |
case 1: |
if (GPSData.Status == INVALID) |
{ |
LCD_printfxy(0,0,"No GPS data"); |
LCD_printfxy(0,1,"Lon: "); |
LCD_printfxy(0,2,"Lat: "); |
LCD_printfxy(0,3,"Alt: "); |
} |
else // newdata or processed |
{ |
switch (GPSData.SatFix) |
{ |
case SATFIX_NONE: |
LCD_printfxy(0,0,"Sats:%02d Fix:None", GPSData.NumOfSats); |
break; |
case SATFIX_2D: |
LCD_printfxy(0,0,"Sats:%02d Fix:2D ", GPSData.NumOfSats); |
break; |
case SATFIX_3D: |
LCD_printfxy(0,0,"Sats:%02d Fix:3D ", GPSData.NumOfSats); |
break; |
default: |
LCD_printfxy(0,0,"Sats:%02d Fix:?? ", GPSData.NumOfSats); |
break; |
} |
i1 = GPSData.Position.Longitude/10000000L; |
i2 = abs(GPSData.Position.Longitude%10000000L); |
LCD_printfxy(0,1,"Lon:%+3ld.%07ld deg",i1, i2); |
i1 = GPSData.Position.Latitude/10000000L; |
i2 = abs(GPSData.Position.Latitude%10000000L); |
LCD_printfxy(0,2,"Lat:%+3ld.%07ld deg",i1, i2); |
i1 = GPSData.Position.Altitude/1000L; |
i2 = abs(GPSData.Position.Altitude%1000L); |
LCD_printfxy(0,3,"Alt:%4ld.%03ld m",i1, i2); |
} |
break; |
case 2: |
if (GPSData.Status == INVALID) |
{ |
LCD_printfxy(0,0,"No GPS data"); |
LCD_printfxy(0,1,"Speed N: "); |
LCD_printfxy(0,2,"Speed E: "); |
LCD_printfxy(0,3,"Speed T: "); |
} |
else // newdata or processed |
{ |
switch (GPSData.SatFix) |
{ |
case SATFIX_NONE: |
LCD_printfxy(0,0,"Sats:%02d Fix:None", GPSData.NumOfSats); |
break; |
case SATFIX_2D: |
LCD_printfxy(0,0,"Sats:%02d Fix:2D ", GPSData.NumOfSats); |
break; |
case SATFIX_3D: |
LCD_printfxy(0,0,"Sats:%02d Fix:3D ", GPSData.NumOfSats); |
break; |
default: |
LCD_printfxy(0,0,"Sats:%02d Fix:?? ", GPSData.NumOfSats); |
break; |
} |
LCD_printfxy(0,1,"Speed N: %+4ld cm/s",GPSData.Speed_North); |
LCD_printfxy(0,2,"Speed E: %+4ld cm/s",GPSData.Speed_East); |
LCD_printfxy(0,3,"Speed T: %+4ld cm/s",GPSData.Speed_Top); |
} |
break; |
case 3: |
LCD_printfxy(0,0,"GPS UTC Time"); |
if (!SystemTime.Valid) |
{ |
LCD_printfxy(0,0,"GPS UTC Time"); |
LCD_printfxy(0,1," "); |
LCD_printfxy(0,2," No time data! "); |
LCD_printfxy(0,3," "); |
} |
else // newdata or processed |
{ |
LCD_printfxy(0,1," "); |
LCD_printfxy(0,2,"Date: %02i/%02i/%04i",SystemTime.Month, SystemTime.Day, SystemTime.Year); |
LCD_printfxy(0,3,"Time: %02i:%02i:%02i.%03i", SystemTime.Hour, SystemTime.Min, SystemTime.Sec, SystemTime.mSec); |
|
} |
break; |
case 4: // Navi Params from FC |
LCD_printfxy(0,0,"NaviMode: %3i" , Parameter.NaviGpsModeControl); |
LCD_printfxy(0,1,"G :%3i P :%3i ",Parameter.NaviGpsGain, Parameter.NaviGpsP); |
LCD_printfxy(0,2,"I :%3i D :%3i ",Parameter.NaviGpsI, Parameter.NaviGpsD); |
LCD_printfxy(0,3,"ACC:%3i SAT:%3i ",Parameter.NaviGpsACC, Parameter.NaviGpsMinSat); |
break; |
case 5: |
LCD_printfxy(0,0,"Home Position"); |
if(GPS_HomePosition.Status == INVALID) |
{ |
LCD_printfxy(0,1," "); |
LCD_printfxy(0,2," Is not set. "); |
LCD_printfxy(0,3," "); |
} |
else |
{ |
i1 = GPS_HomePosition.Longitude/10000000L; |
i2 = abs(GPS_HomePosition.Longitude%10000000L); |
LCD_printfxy(0,1,"Lon: %3ld.%07ld deg",i1, i2); |
i1 = GPS_HomePosition.Latitude/10000000L; |
i2 = abs(GPS_HomePosition.Latitude%10000000L); |
LCD_printfxy(0,2,"Lat: %3ld.%07ld deg",i1, i2); |
i1 = GPS_HomePosition.Altitude/1000L; |
i2 = abs(GPS_HomePosition.Altitude%1000L); |
LCD_printfxy(0,3,"Alt:%4ld.%03ld m",i1, i2); |
} |
break; |
case 6: // RC stick controls from FC |
LCD_printfxy(0,0,"RC-Sticks" ); |
LCD_printfxy(0,1,"Ni:%4i Ro:%4i ",FC.StickNick, FC.StickRoll); |
LCD_printfxy(0,2,"Gs:%4i Ya:%4i ",FC.StickGas, FC.StickYaw); |
break; |
case 7: // RC poti controls from FC |
LCD_printfxy(0,0,"RC-Potis" ); |
LCD_printfxy(0,1,"Po1:%3i Po2:%3i ",FC.Poti1, FC.Poti2); |
LCD_printfxy(0,2,"Po3:%3i Po4:%3i ",FC.Poti3, FC.Poti4); |
break; |
case 8: // attitude from FC |
LCD_printfxy(0,0,"IntNick: %5i", FromFlightCtrl.IntegralNick); |
LCD_printfxy(0,1,"IntRoll: %5i", FromFlightCtrl.IntegralRoll); |
LCD_printfxy(0,2,"AccNick: %5i", FromFlightCtrl.AccNick); |
LCD_printfxy(0,3,"AccRoll: %5i", FromFlightCtrl.AccRoll); |
break; |
case 9: // gyros from FC |
LCD_printfxy(0,0,"GyroNick: %4i", FromFlightCtrl.GyroNick); |
LCD_printfxy(0,1,"GyroRoll: %4i", FromFlightCtrl.GyroRoll); |
LCD_printfxy(0,2,"GyroYaw: %4i", FromFlightCtrl.GyroYaw); |
break; |
case 10: // Remote Control Level from FC |
LCD_printfxy(0,0,"RC-Level: %3i", FC.RC_Quality); |
LCD_printfxy(0,1,"Ubat: %3i", FC.UBat); |
LCD_printfxy(0,2,"CompHeading: %3i", I2C_Heading.Heading); |
LCD_printfxy(0,3,"GyroHeading: %3i", FromFlightCtrl.GyroHeading); |
break; |
case 11: // User Parameter |
LCD_printfxy(0,0,"UP1:%3i UP2:%3i ",Parameter.User1,Parameter.User2); |
LCD_printfxy(0,1,"UP3:%3i UP4:%3i ",Parameter.User3,Parameter.User4); |
LCD_printfxy(0,2,"UP5:%3i UP6:%3i ",Parameter.User5,Parameter.User6); |
LCD_printfxy(0,3,"UP7:%3i UP8:%3i ",Parameter.User7,Parameter.User8); |
break; |
case 12: // MK3MAG |
I2C1_SendCommand(I2C_CMD_READ_MAG); |
LCD_printfxy(0,0,"MK3MAG V%i.%i%c",MK3MAG_Version.Major, MK3MAG_Version.Minor, 'a'+ MK3MAG_Version.Patch); |
LCD_printfxy(0,1,"MagX: %4i ",I2C_Mag.MagX); |
LCD_printfxy(0,2,"MagY: %4i ",I2C_Mag.MagY); |
LCD_printfxy(0,3,"MagZ: %4i ",I2C_Mag.MagZ); |
break; |
default: |
MaxMenuItem = MenuItem - 1; |
MenuItem = 0; |
break; |
} |
RemoteKeys = 0; |
} |