Subversion Repositories Projects

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

/*****************************************************************************
 *   Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de                  *
 *   Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net                  *
 *   Copyright (C) 2013 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"
#include "../tracking/ng_servo.h"
#include "../waypoints/waypoints.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           0x78  //wird nach jeder Parametererweiterung hochgezählt

#define NumberOfWaypoints       55      //Anzahl der Waypoints in der EEPromliste
#define NumberOfWPLists         5       //Anzahl WP Listen im PKT
#define MAX_LIST_LEN            31      // Länge Waypointlist

#define bt_pin_length           4
#define RE_ID_length            4       // Länge der RE-ID
#define bt_name_length          10
#define bt_mac_length           14
#define GPS_Bluetoothmouse1     0       //NMEA BT-Mouse
#define GPS_Mikrokopter         1      // GPS Daten vom MK für Tracking


#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 rev;
        uint16_t min;
        uint16_t max;
        uint16_t mid;
} servo_t;


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;




typedef struct SStructure{
         uint8_t Version;
         uint8_t MK_LowBat;
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
volatile uint8_t BTIsSlave;                                    // Slave Flag
char bt_pin[bt_pin_length + 1];                                 // BT Pinnummer
char bt_name[bt_name_length + 1];                               // BT Name
char RE_ID[RE_ID_length + 1];                                 // RE-ID
char bt_Mac[bt_mac_length + 1];                                 // MAC-Adresse BTM222

char gps_UsedDevName[20];                                         // benutztes GPS Device Name
char gps_UsedMac[14];                                             // benutztes GPS Device Mac Adresse
volatile uint8_t gps_UseGPS;                                        // ist GPS aktiv?
volatile uint8_t gps_UsedGPSMouse;                                  // GPS Maustyp

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 uint8_t OSD_RCErrorbeep;                               //Empfangsausffallwarnung im OSD Screen
volatile uint8_t OSD_InvertOut;                                 // Out1/2 invertiert anzeigen
volatile uint8_t OSD_LEDform;                                   // Form der Anzeige ( + oder schwarz)
volatile uint8_t OSD_SendOSD;                                   // OSD Daten an SV2 senden
volatile uint8_t OSD_Fallspeed;                                 // maximale Sinkrate
volatile uint8_t OSD_VarioBeep;                                 // Vario Beep im OSD Screen
volatile uint8_t OSD_HomeMKView;                                // Home Circle from MK-View
volatile uint16_t OSD_mAh_Warning;                              // mAh Warnschwelle
volatile uint8_t OSD_ScreenMode;                                //Variante des OSD-Screen
volatile uint8_t OSD_LipoBar;                                   //Bargraphanzeige für MK Lipo
volatile uint8_t PKT_Baudrate;                                  // Baudrate für BT und Wi232
volatile uint16_t FM_Refresh;                                   // FollowMe interval
volatile uint16_t FM_Speed;                                     // FollowMe Speed in m/s *0.1
volatile uint16_t FM_Radius;                                    // Waypoint Tolerance Radius in meter
volatile uint8_t HWSound;                                       // Hardware Sounderweiterung an PD7
volatile uint8_t HWBeeper;                                       // Hardware Beeper an PC7
volatile uint8_t Volume;                                        // Lautstärke
volatile servo_t  servo[2];
volatile uint8_t   sIdxSteps;
volatile uint16_t  hyst_u_min;
volatile uint8_t   servo_frame;

volatile uint8_t   single_step;
volatile uint8_t   repeat;
volatile uint8_t   pause;
volatile uint8_t   pause_step;
volatile uint8_t   tracking;
volatile uint8_t   track_hyst;
volatile uint8_t   track_tx;
// Stickparameter
volatile uint16_t stick_min[5];
volatile uint16_t stick_max[5];
volatile uint8_t  stick_typ[5];
volatile uint8_t  stick_dir[5];
volatile uint8_t  stick_neutral[5];     // ja/nein
volatile uint8_t  Lipomessung;          // wenn Lipomessung deaktiviert(Lötbrücke öffnen), kann der Kanal als Stick verwendet werden
Point_t PointList[MAX_LIST_LEN];        // ab 3.6.6b EEPROM Version 78


//!!!neue Parameter immer am Ende anfügen!!!!!!
}  ST;

extern ST Config;

void ReadParameter (void);
void WriteParameter (void);
void ReadLastPosition(void);
void WriteLastPosition(uint32_t ELongitude,uint32_t ELatitude);
void WriteWiInitFlag(void);
void WriteBTInitFlag(void);
void WriteBTSlaveFlag(void);
void WriteBTMasterFlag(void);
void Delete_EEPROM(void);
//void EEWayPointList_Clear(void);      // l�schen der Waypointliste im EEProm

#endif