0,0 → 1,368 |
/*#######################################################################################*/ |
/* !!! 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 <stdlib.h> |
#include "91x_lib.h" |
#include "main.h" |
#include "led.h" |
#include "ubx.h" |
#include "GPS.h" |
#include "timer1.h" |
#include "compass.h" |
#include "spi_slave.h" |
#include "MobileMenu.h" |
#include "uart0.h" |
#include "uart1.h" |
#include "ncmag.h" |
#include "logging.h" |
#include "settings.h" |
#include "sdc.h" |
#include "analog.h" |
#include "canbus.h" |
#include "triggerlog.h" |
#include "CamCtrl.h" |
#include "eeprom.h" |
|
u8 MobileDispPtr = 0; |
|
MobileDataRequest_t MobileDataRequest; |
MobileDataInfo_t MobileDataInfo; |
Mobile_t Mobile; |
|
#define ML_SEND 0x0001 // show sendbutton |
#define ML_SLIDER 0x0002 |
#define ML_WHEEL 0x0004 |
#define ML_EDIT 0x0008 |
#define ML_WHEEL_RELATIV 0x0010 |
|
|
MobileLabel_t MobileLabel[MOBILE_MAX_MENU] = |
{ |
//{ 123456789012345678901 Min Max Default Decimals 1234567890123456 Keys Layout, LayoutOptions |
{ "Status " , 0, 1000, 200, 0, " ", {"SAT ","Time ","Magnet","Camera","Logs "},0, 0}, // 0 |
{ "Load Waypoint List " , 1, 99, 1, 0, "Select List ", {"Fixed "," ","Relati"," "," "},1, ML_EDIT }, // 1 |
{ "Load single Position " , 1, 99, 1, 0, "Load from Index:", {" "," "," "," ","Load "},1, ML_EDIT}, // 2 |
{ "Store single Position" , 1, 99, 1, 0, "Store on Index: ", {" "," "," "," ","Store "},1, ML_EDIT}, // 3 |
{ "BL-Gimbal Control " , -150, 150, 0, 0, "Move ", {"Yaw ","Nick "," "," ","Reset "},1, ML_WHEEL_RELATIV} // 4 |
}; |
|
|
|
void Mobile_Putchar(char c) |
{ |
if(MobileDispPtr < M_DISPLAYBUFFSIZE) Mobile.DisplayBuff[MobileDispPtr++] = c; |
} |
|
|
void Mobile_Putchar_INV(char c) |
{ |
if(MobileDispPtr < M_DISPLAYBUFFSIZE) Mobile.DisplayBuff[MobileDispPtr++] = c | 0x80; |
} |
|
void Mobile_Putchar_BLINK(char c) |
{ |
if(MenuBlinkBit) Mobile_Putchar_INV(c); else Mobile_Putchar(c); |
} |
|
void Mobile_Clear(void) |
{ |
u8 i; |
for( i = 0; i < M_DISPLAYBUFFSIZE; i++) Mobile.DisplayBuff[i] = ' '; |
} |
|
// Display with 20 characters in 4 lines |
void MobileMenuUpdate(u8 item, u8 Keys, s16 Value) |
{ |
//static u32 tmp,tmp2,tmp3; |
// s32 i1,i2; |
u8 sign; |
Mobile_Clear(); |
FromMenuGimbalYaw = 0; // will be set in the menu below |
FromMenuServoNickControl = 0; |
switch(item) |
{ |
// Version Info |
case 0: |
{ |
static u8 show = 0; |
// Mobile_printfxy(0,0,"++ Mobile Menu ++"); |
|
// Mobile_printfxy_BLINK(10,3,"BLINK"); |
|
// Mobile_printfxy(0,1,"HW V%d.%d SW V%d.%02d%c", UART_VersionInfo.HWMajor/10, UART_VersionInfo.HWMajor%10, VERSION_MAJOR, VERSION_MINOR, 'a'+ VERSION_PATCH); |
// if(FC.StatusFlags3 & FC_STATUS3_REDUNDANCE_AKTIVE) Mobile_printfxy(19,1,"R"); |
/* |
NaviData.Current |
s16 Altimeter_5cm; // hight according to air pressure |
s16 Variometer; // climb(+) and sink(-) rate |
u16 FlyingTime; // in seconds |
u16 GroundSpeed; // speed over ground in cm/s (2D) |
s16 Heading; // current flight direction in ° as angle to north |
s8 AngleNick; // current Nick angle in 1° |
s8 AngleRoll; // current Rick angle in 1° |
u8 FCStatusFlags; // Flags from FC see main.c FC_STATUS_xxx |
u8 NCFlags; // Flags from NC see main.h NC_FLAG_xxx |
u8 Errorcode; // 0 --> okay |
u8 WP_OperatingRadius; // current WP 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 FCStatusFlags2; // StatusFlags2 (since version 5 added) |
s16 SetpointAltitude; // setpoint for altitude |
u8 Gas; // current gas (thrust) |
|
NaviData.GroundSpeed |
NaviData. |
NaviData. |
NaviData. |
|
NaviData. |
NaviData.SatsInUse |
|
|
*/ |
if(FC.StatusFlags & FC_STATUS_LOWBAT) |
{ |
Mobile_printfxy_BLINK(0,0," %2i.%1iV ",FC.BAT_Voltage/10, FC.BAT_Voltage%10) |
Mobile_printfxy_BLINK(0,1," %2i:%02i ",NaviData.FlyingTime/60,NaviData.FlyingTime%60) |
Mobile_printfxy_BLINK(0,2," %5i ",NaviData.UsedCapacity) |
} |
else |
{ |
Mobile_printfxy(0,0," %2i.%1iV ",FC.BAT_Voltage/10, FC.BAT_Voltage%10) |
Mobile_printfxy(0,1," %2i:%02i ",NaviData.FlyingTime/60,NaviData.FlyingTime%60); |
Mobile_printfxy(0,2," %5i ",NaviData.UsedCapacity); |
} |
if(Parameter.GlobalConfig & FC_CFG_HOEHENREGELUNG) |
{ |
if(FC.StatusFlags2 & FC_STATUS2_ALTITUDE_CONTROL) Mobile_printfxy_INV(10,0,"ALT:%4im %c", (int16_t)(NaviData.Altimeter_5cm/20),FromFC_VarioCharacter) |
else Mobile_printfxy(10,0,"ALT:%4im ", (int16_t)(NaviData.Altimeter_5cm/20)) |
} |
else Mobile_printfxy(10,0,"ALT:---- "); |
|
Mobile_printfxy(10,1,"DIR: %3d%c",NaviData.CompassHeading,'`'); |
if(FC.StatusFlags2 & FC_STATUS2_CAREFREE) Mobile_printfxy_INV(20,1,"C") else Mobile_printfxy(20,1," "); |
|
Mobile_printfxy(12,2,"I:%2i.%1iA ",NaviData.Current/10, NaviData.Current%10); |
|
Mobile_printfxy(8,0,":"); |
Mobile_printfxy(8,1,":"); |
Mobile_printfxy(8,2,":"); |
|
if(Keys & KEY1) show = 0; |
if(Keys & KEY2) show = 1; |
if(Keys & KEY3) show = 2; |
if(Keys & KEY4) show = 3; |
if(Keys & KEY5) show = 4; |
switch(show) |
{ |
case 0: |
Mobile_printfxy(0,3,"S:%2d %2im/s HM:%3dm %c",NaviData.SatsInUse,NaviData.GroundSpeed/100,NaviData.HomePositionDeviation.Distance_dm/10,NC_GPS_ModeCharacter); |
break; |
case 1: |
Mobile_printfxy(0,3," %04i/%02i/%02i %02i:%02i:%02i", SystemTime.Year,SystemTime.Month, SystemTime.Day, SystemTime.Hour, SystemTime.Min, SystemTime.Sec); |
break; |
case 2: |
Mobile_printfxy(0,3,"MAG:%3u%% incl:%2d`(%2i)",EarthMagneticField/5,EarthMagneticInclination,EarthMagneticInclinationTheoretic); |
break; |
case 3: |
if(TrigLogging.CountExternal) Mobile_printfxy(0,3,"HotShoe:%4u ",TrigLogging.CountExternal-1) |
else Mobile_printfxy(0,3,"No HotShoe"); |
break; |
case 4: |
if(SDCardInfo.Valid == 1) |
Mobile_printfxy(0,3,"Logs: GPX:%3u TRG:%3u",Logged_GPX_Counter,Logged_TRIG_Counter) |
else |
Mobile_printfxy(0,3,"no card in slot "); |
break; |
} |
|
if(ErrorCode) Mobile_printfxy_BLINK(0,4,"%s",NaviData_HoTT_Text.HoTT_DisplayText) |
else Mobile_printfxy(0,4,"%s",NaviData_HoTT_Text.HoTT_DisplayText); |
|
} |
break; |
case 1: |
{ |
static u8 index = 0, fixed = 0; |
if(Keys & KEY1) |
{ |
index = Value; |
if(index > ToFC_MaxWpListIndex) index = ToFC_MaxWpListIndex; |
FromFC_LoadWP_List = index; |
fixed = 1; |
} |
if(Keys & KEY3) |
{ |
if(GPSData.SatFix == SATFIX_3D) |
{ |
index = Value; |
if(index > ToFC_MaxWpListIndex) index = ToFC_MaxWpListIndex; |
FromFC_LoadWP_List = index | 0x80; |
fixed = 2; |
} |
else fixed = 3; |
} |
|
if(!fixed) Mobile_printfxy(0,0,"Load relative or fix") |
else Mobile_printfxy(0,0,"Name: %s ", WPL_Store.Name); |
|
// 12345678901234567890 |
Mobile_printfxy(0,1,"Points Index "); |
Mobile_printfxy(0,2," %3d %3d ", PointList_GetCount(), index); |
if(fixed == 1) Mobile_printfxy(0,3," Fixed positions"); |
if(fixed == 2) Mobile_printfxy(0,3," Relative positions"); |
if(fixed == 3) { Mobile_printfxy(0,3," Error: No Satfix!"); if(GPSData.SatFix == SATFIX_3D) fixed = 0;}; |
Mobile_printfxy(0,4," LOAD List: %3i",Value); |
Mobile.ReturnValue = index; |
} |
break; |
case 2: |
{ |
static u8 index = 0; |
if(Keys & KEY5) |
{ |
index = Value; |
if(index > ToFC_MaxWpListIndex) index = ToFC_MaxWpListIndex; |
FromFC_Load_SinglePoint = index; |
} |
Mobile_printfxy(0,0,"Load Point" ); |
Mobile_printfxy(0,1,"Name: %s", WPL_Store.Name); |
// 12345678901234567890 |
Mobile_printfxy(0,3,"Number: %3d ", Value); |
if(index != Value) Mobile_printfxy(15,3,"(LOAD)"); |
Mobile.ReturnValue = index; |
} |
break; |
case 3: |
{ |
static u8 index = 1; |
Mobile_printfxy(0,0,"Save Point" ); |
Mobile_printfxy(0,1,"Alt: %3dm", NaviData.Altimeter_5cm/20); |
// 12345678901234567890 |
Mobile_printfxy(0,2,"Dir: %3d ", CompassSetpointCorrected/10); |
if(GPSData.SatFix == SATFIX_3D) |
{ |
Mobile_printfxy(0,4,"Number: %3d (Save)", Value); |
if(Keys & KEY5) |
{ |
index = Value; |
if(index > ToFC_MaxWpListIndex) index = ToFC_MaxWpListIndex; |
FromFC_Save_SinglePoint = index; |
} |
} |
else Mobile_printfxy(5,4,"No Satfix !"); |
Mobile.ReturnValue = index; |
} |
break; |
case 4: |
Mobile_printfxy(0,0,"GimbalCtrl"); |
Mobile.ReturnValue = 0; |
if(!(FromGimbalCtrl.GimbalStatus & GIMBAL_I2C_OK)) |
{ |
Mobile_printfxy(0,2,"Not connected"); |
if(GimbalCtrlTimeout < 10) Mobile_printfxy(14,4,"(conn)"); // connect manually |
if(Keys & KEY5) GimbalCtrlTimeout = 65000; |
} |
else |
{ |
static u8 control = 0; |
Mobile_printfxy(10,0,"V%i.%02i",1 + FromGimbalCtrl.Version / 100, FromGimbalCtrl.Version % 100); |
Mobile_printfxy(0,1,"Stat:"); |
if(FromGimbalCtrl.GimbalStatus & GIMBAL_DATA_OK) Mobile_printfxy(8,1,"OK") else Mobile_printfxy(5,1,"No Gimbal"); |
Mobile_printfxy(0,2,"Nick:%3i Roll:%3i",FromGimbalCtrl.Nick,FromGimbalCtrl.Roll); |
Mobile_printfxy(0,3,"Yaw: %3i [0,1 Deg]",FromGimbalCtrl.Yaw); |
if(control == 0) |
{ |
Mobile_printfxy(0,4,"Control: Yaw"); |
FromMenuServoNickControl = 0; |
FromMenuGimbalYaw = Value * (-2); |
} |
else |
{ |
Mobile_printfxy(0,4,"Control: Nick"); |
if(FC.RC_Quality < 50) Mobile_printfxy(0,4,"RC Failsafe pos.!!"); |
FromMenuServoNickControl = Value; |
FromMenuGimbalYaw = 0; |
} |
|
if(Keys & KEY5) |
{ |
ToGimbalCtrl.BitCmd |= (GIMBAL_CMD_YW_ZERO); |
FromMenuGimbalYaw = 0; |
MenuNickGimbalOffset = 0; |
} |
if(Keys & KEY1) control = 0; |
if(Keys & KEY2) control = 1; |
} |
break; |
case 99: |
{ |
// static u16 offset = 20, tmp; |
// Mobile_printfxy(0,0,"Testpage %i %c",item,33); |
for(sign = 0; sign < 21*5; sign++) Mobile.DisplayBuff[sign] = sign + ' '; |
|
// if(Keys & COPY) offset = Value; |
} |
break; |
|
default: |
Mobile_printfxy(0,0,"Not used "); |
//MaxMenuItem = MenuItem - 1; |
break; |
} |
Mobile.Index = item; // this menu item was processed |
|
} |