Blame |
Last modification |
View Log
| RSS feed
/****************************************************************/
/* */
/* NG-Video 5,8GHz */
/* */
/* Copyright (C) 2011 - gebad */
/* */
/* This code is distributed under the GNU Public License */
/* which can be found at http://www.gnu.org/licenses/gpl.txt */
/* */
/****************************************************************/
#ifndef NGVIDEO_H_
#define NGVIDEO_H_
#include "config.h"
#include "messages.h"
#include "servo.h"
#include "dogm.h"
#include "menue.h"
#include "lipo.h"
/* Indexwerte für av_source bzw. zur Auswertung von av_source */
#define AV1 0
#define AV2 1
#define DIVERSITY 2
#define MARKER_SELECT 0xfc // 0xfc enspricht '>>' Menue-Marker
#define MARKER_AV 0xfb // 0xfb enspricht '<<' Diversity AV-Marker
#define MARKER_RSSI 'd' // Diversity, wenn RX umschaltet mittels RSSI-Wert
#define MARKER_SYNC 's' // Diversity, wenn RX umschaltet auf Grund der Bildsynchronisation
#define SET_MUX_0 PORTA &= ~(1<<MUX_IN); // MUX SxA enabled
#define SET_MUX_1 PORTA |= (1<<MUX_IN); // MUX SxB enabled
#define CLEAR_INT10 EIMSK &= ~((1<<INT1) | (1<<INT0));// Interrupt für Sync ausschalten
#define SET_INT10 EIMSK |= (1<<INT1) | (1<<INT0); // External Interrupt Mask Register ein
/* Beep Verzögerungszeitein */
#define DBEEPVERS 2 // Beep on nach Versionsanzeige
#define DBEEPVERSP 30 // Beep Pause nach Versionsanzeige
#define BEEPENTER 1 // Beep on nach Enter kurz Scroll_Menu() und Select_Menu()
#define DBEEPWR 4 // Beep on nach geänderten Werte ROM schreiben
#define DBEEPWRP 30 // Beep Pause nach geänderten Werte ROM schreiben
#define BEEPBAT 20 // Beep on bei Akku low
#define BEEP_LOW_TIME 240 // TIMER0_1 aller 500ms aufgerufen, BeepIntervall Akku leer mit 2 Min Abstand beginnen
#define DBEEPNMEAFIX 120 // Beep on nach NMEA SAT-FIX
#define DBEEPMEAFIXP 240 // Beep Pause nach NMEA SAT-FIX
#define ENABLE_BTIMER 1 // damit Intervall Beeper für Akku leer mit TIMER0_1 gesteuert wird
#define DISABLE_BTIMER 0
#define GPS_DISP_NONE 0 // Anzeigen bei Antennennachführung per WI232 und GPS
#define GPS_DISP_CALC 1
#define GPS_DISP_CURRENT 2
#define GPS_DISP_HOME 3
#define GPS_MISC 4
#define GPS_RX_COUNT 5
#define BAUDRATE 5 // für Antennennachführung mittels MKCockpit
#define BAUDRATE_MIN 0
#define BAUDRATE_MAX 6
#define getBaud(x) (uint16_t)pgm_read_dword(&baud[x])
extern const uint16_t PROGMEM baud[8];
#define POLOLU_CMD 2
#define OFF 0
#define ON 1
#define EEPROM __attribute__ ((section(".eeprom")))
typedef struct {
uint8_t rev;
uint16_t min;
uint16_t max;
uint16_t mid;
} servo_t;
typedef struct {
uint16_t min;
uint16_t max;
uint16_t korr_1;
uint16_t korr_2;
} udbm_t;
typedef struct {
uint16_t u0;
uint16_t u1;
} adc_avg_t;
/**************************************************************/
/* */
/* EEPROM */
/* */
/**************************************************************/
extern uint8_t ep_eep_init EEPROM;
extern char ep_version[sizeof(VERSION)] EEPROM;
extern uint8_t ep_dogm_vers EEPROM;
extern uint8_t ep_contrast EEPROM;
extern uint8_t ep_light_time EEPROM;
extern uint8_t ep_u_offset EEPROM;
extern uint16_t ep_u_min EEPROM;
extern uint8_t ep_rssi_inv EEPROM;
extern uint8_t ep_channel EEPROM;
extern uint8_t ep_av_source EEPROM;
extern uint8_t ep_language EEPROM;
extern udbm_t ep_udbm[CHANNEL_MAX] EEPROM;
extern uint16_t ep_tx_value_on EEPROM;
extern uint16_t ep_tx_value_off EEPROM;
extern uint8_t ep_sIdxSteps EEPROM;
extern servo_t ep_servo[SERVO_NUM_CHANNELS] EEPROM;
extern uint8_t ep_servo_frame EEPROM;
extern uint8_t ep_servo_nr EEPROM;
extern uint8_t ep_single_step EEPROM;
extern uint8_t ep_repeat EEPROM;
extern uint8_t ep_pause EEPROM;
extern uint8_t ep_pause_step EEPROM;
extern uint8_t ep_tracking EEPROM;
extern uint8_t ep_track_hyst EEPROM;
extern uint8_t ep_track_tx EEPROM;
extern uint8_t ep_baudrate EEPROM;
extern mk_current_t ep_mk_current EEPROM;
extern uint8_t ep_mk_akku_nr EEPROM;
extern mk_lipo_t ep_mk_lipo[AKKU_NR_MAX+1] EEPROM;
extern uint8_t ep_mk_i_offset EEPROM;
extern uint8_t ep_mk_i_faktor EEPROM;
extern uint8_t ep_mk_w_faktor EEPROM;
/**************************************************************/
// Working variables of EEPROM contents
extern uint8_t eep_init;
extern char version[sizeof(VERSION)];
extern uint8_t dogm_vers;
extern uint8_t contrast;
extern uint8_t light_time;
extern uint8_t u_offset;
extern uint16_t u_min;
extern uint8_t rssi_inv;
extern uint8_t channel;
extern uint8_t av_source;
extern uint8_t language;
extern udbm_t udbm;
extern uint16_t tx_value_on;
extern uint16_t tx_value_off;
extern uint8_t sIdxSteps;
extern servo_t servo[SERVO_NUM_CHANNELS];
extern uint8_t servo_frame;
extern uint8_t servo_nr;
extern uint8_t single_step;
extern uint8_t repeat;
extern uint8_t pause;
extern uint8_t pause_step;
extern uint8_t tracking;
extern uint8_t track_hyst;
extern uint8_t track_tx;
extern uint8_t baudrate;
extern uint8_t ch_stored; // Flag zur Speicherung, wenn Wert im Hauptdisplay geändert
/**************************************************************/
extern uint8_t coldstart; // Flag erstmaliger MK-Start(Motore) nur nach GPS-Fix
extern uint8_t bat_low;
extern uint16_t hyst_u_min;
extern uint8_t gps_display;
extern uint8_t gps_disp_clear;
extern uint8_t sw_avx;
extern uint16_t bar_udbm[12];
extern uint8_t MK_Motor_run; // Flag für RX Time-Counter Start/Stop
extern uint8_t mk_timer; // Zeitzähler lipo.time_on auf aus
extern volatile uint32_t rxcount0;
extern volatile uint32_t rxcount1;
extern SpecialChr_t lcdSpecialChr[7];
extern SpecialChr_t lcdSpecialChrLs[8];
extern SpecialChr_t lcdSpecialChrRs[5];
void Init_EEPROM(uint8_t ep_reset);
void servoSetDefaultPos(void);
void Set_DOGM_Version(void);
void Set_Channel(uint8_t channel);
uint8_t Set_AV_Source(uint8_t src);
void lcdSet_BackgrLight_Off(void);
void lcd_BackgrLight_On(void);
void lcd_BackgrLight(void);
void ADC_Init(void);
uint16_t ADC_Read( uint8_t channel );
uint16_t ADC_Read_inv( uint8_t channel );
void Beep(uint8_t time);
void Double_Beep(uint8_t time, uint8_t pause);
void Displ_VBat(void);
void Displ_U_2Nk(uint16_t u);
uint8_t RSSI_Calc_UdBm(uint16_t *pbar_udbm);
uint8_t RSSI_Min_Calibrate(uint8_t nchannel, uint16_t *pbar_udbm);
void RSSI_Max_Calibrate(uint16_t *pbar_udbm);
void USART_Init_Baudrate(void);
void Double_Beep(uint8_t time, uint8_t pause);
uint16_t Change_Value_plmi(uint16_t val, uint16_t min_val, uint16_t max_val, uint8_t posX, uint8_t posY, Displ_Fnct_t Displ_Fnct, uint8_t cycle, uint8_t vrepeat);
uint16_t U_Messen_cmp(uint8_t beep_timer);
void Task_0_1(void);
void Task_0_2(void);
void Task_0_3(void);
void Task_0_4(void);
void Task_0_5(void);
void Tasks_invisible(void);
#endif /* NGVIDEO_H_ */