Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f2ff5bccd3 |
+20
-24
@@ -201,9 +201,9 @@ EEPROM_PROGRESS_BAR = NO
|
||||
# Values = YES, NO
|
||||
DEBUG = NO
|
||||
|
||||
# Flight Modes
|
||||
# Flight Phases
|
||||
# Values = YES, NO
|
||||
FLIGHT_MODES = YES
|
||||
FLIGHT_PHASES = YES
|
||||
|
||||
# Curves
|
||||
# Values = YES, NO
|
||||
@@ -268,8 +268,8 @@ ifeq ($(PCB), $(filter $(PCB), STD 9X 9XR))
|
||||
CPPDEFS += -DAUDIO
|
||||
CPPSRC += audio_avr.cpp
|
||||
else
|
||||
CPPDEFS += -DBUZZER
|
||||
CPPSRC += buzzer.cpp
|
||||
CPPDEFS += -DBEEPER
|
||||
CPPSRC += beeper.cpp
|
||||
endif
|
||||
|
||||
ifeq ($(VOICE), YES)
|
||||
@@ -280,11 +280,9 @@ ifeq ($(PCB), $(filter $(PCB), STD 9X 9XR))
|
||||
ifeq ($(PWM_BACKLIGHT), YES)
|
||||
ifeq ($(VOICE), YES)
|
||||
$(error Sorry, PWM_BACKLIGHT doesnt work on stock board with VOICE mod)
|
||||
else
|
||||
CPPDEFS += -DPWM_BACKLIGHT
|
||||
endif
|
||||
ifeq ($(AUDIO), YES)
|
||||
$(error Sorry, PWM_BACKLIGHT doesnt work on stock board with AUDIO mod)
|
||||
endif
|
||||
CPPDEFS += -DPWM_BACKLIGHT
|
||||
endif
|
||||
|
||||
ifeq ($(HAPTIC), YES)
|
||||
@@ -323,8 +321,8 @@ ifeq ($(PCB), $(filter $(PCB), STD128 9X128 9XR128))
|
||||
CPPDEFS += -DAUDIO
|
||||
CPPSRC += audio_avr.cpp
|
||||
else
|
||||
CPPDEFS += -DBUZZER
|
||||
CPPSRC += buzzer.cpp
|
||||
CPPDEFS += -DBEEPER
|
||||
CPPSRC += beeper.cpp
|
||||
endif
|
||||
|
||||
ifeq ($(VOICE), YES)
|
||||
@@ -335,11 +333,9 @@ ifeq ($(PCB), $(filter $(PCB), STD128 9X128 9XR128))
|
||||
ifeq ($(PWM_BACKLIGHT), YES)
|
||||
ifeq ($(VOICE), YES)
|
||||
$(error Sorry, PWM_BACKLIGHT doesnt work on stock board with VOICE mod)
|
||||
else
|
||||
CPPDEFS += -DPWM_BACKLIGHT
|
||||
endif
|
||||
ifeq ($(AUDIO), YES)
|
||||
$(error Sorry, PWM_BACKLIGHT doesnt work on stock board with AUDIO mod)
|
||||
endif
|
||||
CPPDEFS += -DPWM_BACKLIGHT
|
||||
endif
|
||||
|
||||
ifeq ($(HAPTIC), YES)
|
||||
@@ -365,7 +361,7 @@ ifeq ($(PCB), GRUVIN9X)
|
||||
OPT = 2
|
||||
CPPDEFS += -DF_CPU=$(F_CPU)UL -DPCBGRUVIN9X -DEEPROM_VARIANT=0 -DAUDIO -DHAPTIC
|
||||
SDCARD = NO
|
||||
BUZZER = NO
|
||||
BEEPER = NO
|
||||
THR_TRACE = YES
|
||||
EXTRAINCDIRS = gruvin9x stock FatFs FatFs/option
|
||||
BOARDSRC = gruvin9x/board_gruvin9x.cpp
|
||||
@@ -380,9 +376,9 @@ ifeq ($(PCB), GRUVIN9X)
|
||||
EXTRABOARDSRC += FatFs/ff.c FatFs/fattime.c FatFs/option/ccsbcs.c gruvin9x/diskio.cpp
|
||||
endif
|
||||
|
||||
ifeq ($(BUZZER), YES)
|
||||
CPPDEFS += -DBUZZER
|
||||
CPPSRC += buzzer.cpp
|
||||
ifeq ($(BEEPER), YES)
|
||||
CPPDEFS += -DBEEPER
|
||||
CPPSRC += beeper.cpp
|
||||
endif
|
||||
|
||||
ifeq ($(VOICE), YES)
|
||||
@@ -447,7 +443,7 @@ ifeq ($(PCB), SKY9X)
|
||||
MCU = cortex-m3
|
||||
OPT = 2
|
||||
SDCARD = YES
|
||||
BUZZER = NO
|
||||
BEEPER = NO
|
||||
THR_TRACE = YES
|
||||
CPPDEFS += -DPCBSKY9X -DCPUARM -DEEPROM_VARIANT=0 -DAUDIO -DHAPTIC -DPXX -DDSM2 -DDSM2_PPM -DROTARY_ENCODERS=1
|
||||
EXTRAINCDIRS = sky9x CoOS/kernel CoOS/portable
|
||||
@@ -470,9 +466,9 @@ ifeq ($(PCB), SKY9X)
|
||||
EXTRABOARDSRC += FatFs/ff.c FatFs/fattime.c FatFs/option/ccsbcs.c sky9x/diskio.cpp
|
||||
endif
|
||||
|
||||
ifeq ($(BUZZER), YES)
|
||||
CPPDEFS += -DBUZZER
|
||||
CPPSRC += buzzer.cpp
|
||||
ifeq ($(BEEPER), YES)
|
||||
CPPDEFS += -DBEEPER
|
||||
CPPSRC += beeper.cpp
|
||||
endif
|
||||
|
||||
ifeq ($(RTCLOCK), YES)
|
||||
@@ -669,8 +665,8 @@ ifeq ($(THR_TRACE), YES)
|
||||
CPPDEFS += -DTHRTRACE
|
||||
endif
|
||||
|
||||
ifeq ($(FLIGHT_MODES), YES)
|
||||
CPPDEFS += -DFLIGHT_MODES
|
||||
ifeq ($(FLIGHT_PHASES), YES)
|
||||
CPPDEFS += -DFLIGHT_PHASES
|
||||
endif
|
||||
|
||||
ifeq ($(CURVES), YES)
|
||||
|
||||
+11
-6
@@ -552,11 +552,11 @@ void AudioQueue::wakeup()
|
||||
inline uint8_t getToneLength(uint8_t tLen)
|
||||
{
|
||||
uint8_t result = tLen; // default
|
||||
if (g_eeGeneral.beepLength < 0) {
|
||||
result /= (1-g_eeGeneral.beepLength);
|
||||
if (g_eeGeneral.beeperLength < 0) {
|
||||
result /= (1-g_eeGeneral.beeperLength);
|
||||
}
|
||||
if (g_eeGeneral.beepLength > 0) {
|
||||
result *= (1+g_eeGeneral.beepLength);
|
||||
if (g_eeGeneral.beeperLength > 0) {
|
||||
result *= (1+g_eeGeneral.beeperLength);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -711,12 +711,17 @@ void audioEvent(uint8_t e, uint8_t f)
|
||||
#endif
|
||||
|
||||
if (e <= AU_ERROR || e >= AU_WARNING1) {
|
||||
#if defined(BEEPER)
|
||||
beep();
|
||||
#endif
|
||||
|
||||
if (g_eeGeneral.alarmsFlash) {
|
||||
flashCounter = FLASH_DURATION;
|
||||
if (lightOffCounter < FLASH_DURATION)
|
||||
lightOffCounter = FLASH_DURATION;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_eeGeneral.beepMode>0 || (g_eeGeneral.beepMode==0 && e>=AU_TRIM_MOVE) || (g_eeGeneral.beepMode>=-1 && e<=AU_ERROR)) {
|
||||
if (g_eeGeneral.beeperMode>0 || (g_eeGeneral.beeperMode==0 && e>=AU_TRIM_MOVE) || (g_eeGeneral.beeperMode>=-1 && e<=AU_ERROR)) {
|
||||
#if defined(SDCARD)
|
||||
if (e < AU_FRSKY_FIRST && isAudioFileAvailable(e, filename)) {
|
||||
audioQueue.playFile(filename);
|
||||
|
||||
+20
-27
@@ -151,13 +151,16 @@ void codecsInit();
|
||||
void audioEvent(uint8_t e, uint8_t f=BEEP_DEFAULT_FREQ);
|
||||
void audioStart();
|
||||
|
||||
#if defined(AUDIO) && defined(BUZZER)
|
||||
#define AUDIO_BUZZER(a, b) do { a; b; } while(0)
|
||||
#elif defined(AUDIO)
|
||||
#define AUDIO_BUZZER(a, b) a
|
||||
#else
|
||||
#define AUDIO_BUZZER(a, b) b
|
||||
#endif
|
||||
#define AUDIO_TADA() audioEvent(AU_TADA)
|
||||
#define AUDIO_KEYPAD_UP() audioEvent(AU_KEYPAD_UP)
|
||||
#define AUDIO_KEYPAD_DOWN() audioEvent(AU_KEYPAD_DOWN)
|
||||
#define AUDIO_MENUS() audioEvent(AU_MENUS)
|
||||
#define AUDIO_WARNING1() audioEvent(AU_WARNING1)
|
||||
#define AUDIO_WARNING2() audioEvent(AU_WARNING2)
|
||||
#define AUDIO_TX_BATTERY_LOW() audioEvent(AU_TX_BATTERY_LOW)
|
||||
#define AUDIO_TX_MAH_HIGH() audioEvent(AU_TX_MAH_HIGH)
|
||||
#define AUDIO_TX_TEMP_HIGH() audioEvent(AU_TX_TEMP_HIGH)
|
||||
#define AUDIO_ERROR() audioEvent(AU_ERROR)
|
||||
|
||||
#if defined(VOICE)
|
||||
#define AUDIO_ERROR_MESSAGE(e) audioEvent(e)
|
||||
@@ -167,28 +170,18 @@ void audioStart();
|
||||
#define AUDIO_TIMER_MINUTE(t) audioDefevent(AU_WARNING1)
|
||||
#endif
|
||||
|
||||
#define AUDIO_TADA() audioEvent(AU_TADA)
|
||||
#define AUDIO_KEYPAD_UP() AUDIO_BUZZER(audioEvent(AU_KEYPAD_UP), beep(0))
|
||||
#define AUDIO_KEYPAD_DOWN() AUDIO_BUZZER(audioEvent(AU_KEYPAD_DOWN), beep(0))
|
||||
#define AUDIO_MENUS() AUDIO_BUZZER(audioEvent(AU_MENUS), beep(0))
|
||||
#define AUDIO_WARNING1() AUDIO_BUZZER(audioEvent(AU_WARNING1), beep(3))
|
||||
#define AUDIO_WARNING2() AUDIO_BUZZER(audioEvent(AU_WARNING2), beep(2))
|
||||
#define AUDIO_TX_BATTERY_LOW() AUDIO_BUZZER(audioEvent(AU_TX_BATTERY_LOW), beep(4))
|
||||
#define AUDIO_TX_MAH_HIGH() audioEvent(AU_TX_MAH_HIGH)
|
||||
#define AUDIO_TX_TEMP_HIGH() audioEvent(AU_TX_TEMP_HIGH)
|
||||
#define AUDIO_ERROR() AUDIO_BUZZER(audioEvent(AU_ERROR), beep(4))
|
||||
#define AUDIO_TIMER_30() AUDIO_BUZZER(audioEvent(AU_TIMER_30), { beepAgain=2; beep(2); })
|
||||
#define AUDIO_TIMER_20() AUDIO_BUZZER(audioEvent(AU_TIMER_20), { beepAgain=1; beep(2); })
|
||||
#define AUDIO_TIMER_10() AUDIO_BUZZER(audioEvent(AU_TIMER_10), beep(2))
|
||||
#define AUDIO_TIMER_LT3(x) AUDIO_BUZZER(audioEvent(AU_TIMER_LT3), beep(2))
|
||||
#define AUDIO_INACTIVITY() AUDIO_BUZZER(audioEvent(AU_INACTIVITY), beep(3))
|
||||
#define AUDIO_MIX_WARNING(x) AUDIO_BUZZER(audioEvent(AU_MIX_WARNING_1+x-1), beep(1))
|
||||
#define AUDIO_POT_STICK_MIDDLE() AUDIO_BUZZER(audioEvent(AU_POT_STICK_MIDDLE), beep(2))
|
||||
#define AUDIO_TIMER_30() audioEvent(AU_TIMER_30)
|
||||
#define AUDIO_TIMER_20() audioEvent(AU_TIMER_20)
|
||||
#define AUDIO_TIMER_10() audioEvent(AU_TIMER_10)
|
||||
#define AUDIO_TIMER_LT3(x) audioEvent(AU_TIMER_LT3)
|
||||
#define AUDIO_INACTIVITY() audioEvent(AU_INACTIVITY)
|
||||
#define AUDIO_MIX_WARNING(x) audioEvent(AU_MIX_WARNING_1+x-1)
|
||||
#define AUDIO_POT_STICK_MIDDLE() audioEvent(AU_POT_STICK_MIDDLE)
|
||||
#define AUDIO_VARIO_UP() audioEvent(AU_KEYPAD_UP)
|
||||
#define AUDIO_VARIO_DOWN() audioEvent(AU_KEYPAD_DOWN)
|
||||
#define AUDIO_TRIM_MIDDLE(f) AUDIO_BUZZER(audioEvent(AU_TRIM_MIDDLE, f), beep(2))
|
||||
#define AUDIO_TRIM_END(f) AUDIO_BUZZER(audioEvent(AU_TRIM_END, f), beep(2))
|
||||
#define AUDIO_TRIM(event, f) AUDIO_BUZZER(audioEvent(AU_TRIM_MOVE, f), { if (!IS_KEY_FIRST(event)) warble = true; beep(1); })
|
||||
#define AUDIO_TRIM_MIDDLE(f) audioEvent(AU_TRIM_MIDDLE, f)
|
||||
#define AUDIO_TRIM_END(f) audioEvent(AU_TRIM_END, f)
|
||||
#define AUDIO_TRIM(event, f) audioEvent(AU_TRIM_MOVE, f)
|
||||
#define AUDIO_PLAY(p) audioEvent(p)
|
||||
#define AUDIO_VARIO(f, t) audioQueue.play(f, t, 0, PLAY_BACKGROUND)
|
||||
|
||||
|
||||
+11
-6
@@ -107,11 +107,11 @@ void audioQueue::heartbeat()
|
||||
inline uint8_t audioQueue::getToneLength(uint8_t tLen)
|
||||
{
|
||||
uint8_t result = tLen; // default
|
||||
if (g_eeGeneral.beepLength < 0) {
|
||||
result /= (1-g_eeGeneral.beepLength);
|
||||
if (g_eeGeneral.beeperLength < 0) {
|
||||
result /= (1-g_eeGeneral.beeperLength);
|
||||
}
|
||||
if (g_eeGeneral.beepLength > 0) {
|
||||
result *= (1+g_eeGeneral.beepLength);
|
||||
if (g_eeGeneral.beeperLength > 0) {
|
||||
result *= (1+g_eeGeneral.beeperLength);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -168,12 +168,17 @@ void audioQueue::event(uint8_t e, uint8_t f)
|
||||
#endif
|
||||
|
||||
if (e <= AU_ERROR || e >= AU_WARNING1) {
|
||||
#if defined(BEEPER)
|
||||
beep();
|
||||
#endif
|
||||
|
||||
if (g_eeGeneral.alarmsFlash) {
|
||||
flashCounter = FLASH_DURATION;
|
||||
if (lightOffCounter < FLASH_DURATION)
|
||||
lightOffCounter = FLASH_DURATION;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_eeGeneral.beepMode>0 || (g_eeGeneral.beepMode==0 && e>=AU_TRIM_MOVE) || (g_eeGeneral.beepMode>=-1 && e<=AU_ERROR)) {
|
||||
if (g_eeGeneral.beeperMode>0 || (g_eeGeneral.beeperMode==0 && e>=AU_TRIM_MOVE) || (g_eeGeneral.beeperMode>=-1 && e<=AU_ERROR)) {
|
||||
if (e < AU_FRSKY_FIRST || empty()) {
|
||||
// TODO when VOICE enable some cases here are not needed!
|
||||
switch (e) {
|
||||
|
||||
+30
-29
@@ -107,46 +107,47 @@ class audioQueue
|
||||
|
||||
};
|
||||
|
||||
|
||||
extern audioQueue audio;
|
||||
|
||||
void audioDefevent(uint8_t e);
|
||||
|
||||
#if defined(AUDIO) && defined(BUZZER)
|
||||
#define AUDIO_BUZZER(a, b) do { a; b; } while(0)
|
||||
#elif defined(AUDIO)
|
||||
#define AUDIO_BUZZER(a, b) a
|
||||
#else
|
||||
#define AUDIO_BUZZER(a, b) b
|
||||
#endif
|
||||
#define AUDIO_KEYPAD_UP() audioDefevent(AU_KEYPAD_UP)
|
||||
#define AUDIO_KEYPAD_DOWN() audioDefevent(AU_KEYPAD_DOWN)
|
||||
#define AUDIO_MENUS() audioDefevent(AU_MENUS)
|
||||
#define AUDIO_WARNING1() audioDefevent(AU_WARNING1)
|
||||
#define AUDIO_WARNING2() audioDefevent(AU_WARNING2)
|
||||
#define AUDIO_ERROR() audioDefevent(AU_ERROR)
|
||||
|
||||
#if defined(VOICE)
|
||||
#define VOICE_AUDIO_BUZZER(v, a, b) v
|
||||
#define AUDIO_TADA() PUSH_SYSTEM_PROMPT(AU_TADA)
|
||||
#define AUDIO_TX_BATTERY_LOW() PUSH_SYSTEM_PROMPT(AU_TX_BATTERY_LOW)
|
||||
#define AUDIO_INACTIVITY() PUSH_SYSTEM_PROMPT(AU_INACTIVITY)
|
||||
#define AUDIO_ERROR_MESSAGE(e) PUSH_SYSTEM_PROMPT((e))
|
||||
#define AUDIO_TIMER_MINUTE(t) playDuration(t)
|
||||
#define AUDIO_TIMER_30() PUSH_SYSTEM_PROMPT(AU_TIMER_30)
|
||||
#define AUDIO_TIMER_20() PUSH_SYSTEM_PROMPT(AU_TIMER_20)
|
||||
#define AUDIO_TIMER_10() PUSH_SYSTEM_PROMPT(AU_TIMER_10)
|
||||
#define AUDIO_TIMER_LT3(x) PUSH_SYSTEM_PROMPT(AU_TIMER_LT3)
|
||||
#else
|
||||
#define VOICE_AUDIO_BUZZER(v, a, b) AUDIO_BUZZER(a, b)
|
||||
#define AUDIO_TADA()
|
||||
#define AUDIO_TX_BATTERY_LOW() audioDefevent(AU_TX_BATTERY_LOW)
|
||||
#define AUDIO_INACTIVITY() audioDefevent(AU_INACTIVITY)
|
||||
#define AUDIO_ERROR_MESSAGE(e) audioDefevent(AU_ERROR)
|
||||
#define AUDIO_TIMER_MINUTE(t) audioDefevent(AU_WARNING1)
|
||||
#define AUDIO_TIMER_30() audioDefevent(AU_TIMER_30)
|
||||
#define AUDIO_TIMER_20() audioDefevent(AU_TIMER_20)
|
||||
#define AUDIO_TIMER_10() audioDefevent(AU_TIMER_10)
|
||||
#define AUDIO_TIMER_LT3(x) audioDefevent(AU_TIMER_LT3)
|
||||
#endif
|
||||
|
||||
#define AUDIO_KEYPAD_UP() AUDIO_BUZZER(audioDefevent(AU_KEYPAD_UP), beep(0))
|
||||
#define AUDIO_KEYPAD_DOWN() AUDIO_BUZZER(audioDefevent(AU_KEYPAD_DOWN), beep(0))
|
||||
#define AUDIO_MENUS() AUDIO_BUZZER(audioDefevent(AU_MENUS), beep(0))
|
||||
#define AUDIO_WARNING1() AUDIO_BUZZER(audioDefevent(AU_WARNING1), beep(3))
|
||||
#define AUDIO_WARNING2() AUDIO_BUZZER(audioDefevent(AU_WARNING2), beep(2))
|
||||
#define AUDIO_ERROR() AUDIO_BUZZER(audioDefevent(AU_ERROR), beep(4))
|
||||
#define AUDIO_TADA() VOICE_AUDIO_BUZZER(PUSH_SYSTEM_PROMPT(AU_TADA),,)
|
||||
#define AUDIO_TX_BATTERY_LOW() VOICE_AUDIO_BUZZER(PUSH_SYSTEM_PROMPT(AU_TX_BATTERY_LOW), audioDefevent(AU_TX_BATTERY_LOW), beep(4))
|
||||
#define AUDIO_INACTIVITY() VOICE_AUDIO_BUZZER(PUSH_SYSTEM_PROMPT(AU_INACTIVITY), audioDefevent(AU_INACTIVITY), beep(3))
|
||||
#define AUDIO_ERROR_MESSAGE(e) VOICE_AUDIO_BUZZER(PUSH_SYSTEM_PROMPT((e)), audioDefevent(AU_ERROR), beep(4))
|
||||
#define AUDIO_TIMER_MINUTE(t) VOICE_AUDIO_BUZZER(playDuration(t), audioDefevent(AU_WARNING1), beep(2))
|
||||
#define AUDIO_TIMER_30() VOICE_AUDIO_BUZZER(PUSH_SYSTEM_PROMPT(AU_TIMER_30), audioDefevent(AU_TIMER_30), { beepAgain=2; beep(2); })
|
||||
#define AUDIO_TIMER_20() VOICE_AUDIO_BUZZER(PUSH_SYSTEM_PROMPT(AU_TIMER_20), audioDefevent(AU_TIMER_20), { beepAgain=1; beep(2); })
|
||||
#define AUDIO_TIMER_10() VOICE_AUDIO_BUZZER(PUSH_SYSTEM_PROMPT(AU_TIMER_10), audioDefevent(AU_TIMER_10), beep(2))
|
||||
#define AUDIO_TIMER_LT3(x) VOICE_AUDIO_BUZZER(PUSH_SYSTEM_PROMPT(AU_TIMER_LT3), audioDefevent(AU_TIMER_LT3), beep(2))
|
||||
#define AUDIO_MIX_WARNING(x) AUDIO_BUZZER(audioDefevent(AU_MIX_WARNING_1+x-1), beep(1))
|
||||
#define AUDIO_POT_STICK_MIDDLE() AUDIO_BUZZER(audioDefevent(AU_POT_STICK_MIDDLE), beep(2))
|
||||
#define AUDIO_MIX_WARNING(x) audioDefevent(AU_MIX_WARNING_1+x-1)
|
||||
#define AUDIO_POT_STICK_MIDDLE() audioDefevent(AU_POT_STICK_MIDDLE)
|
||||
#define AUDIO_VARIO_UP() audioDefevent(AU_KEYPAD_UP)
|
||||
#define AUDIO_VARIO_DOWN() audioDefevent(AU_KEYPAD_DOWN)
|
||||
#define AUDIO_TRIM_MIDDLE(f) AUDIO_BUZZER(audio.event(AU_TRIM_MIDDLE, f), beep(2))
|
||||
#define AUDIO_TRIM_END(f) AUDIO_BUZZER(audioDefevent(f), beep(2))
|
||||
#define AUDIO_TRIM(event, f) AUDIO_BUZZER(audio.event(AU_TRIM_MOVE, f), { if (!IS_KEY_FIRST(event)) warble = true; beep(1); })
|
||||
#define AUDIO_TRIM_MIDDLE(f) audio.event(AU_TRIM_MIDDLE, f)
|
||||
#define AUDIO_TRIM_END(f) AUDIO_TRIM_MIDDLE(f)
|
||||
#define AUDIO_TRIM(event, f) audio.event(AU_TRIM_MOVE, f)
|
||||
#define AUDIO_PLAY(p) audio.event(p)
|
||||
#define AUDIO_VARIO(f, t) audio.play(f, t, 0, PLAY_BACKGROUND)
|
||||
|
||||
|
||||
@@ -43,6 +43,15 @@ uint8_t beepOn = false;
|
||||
bool warble = false;
|
||||
bool warbleC;
|
||||
|
||||
#if defined(AUDIO)
|
||||
static const pm_uint8_t beepTab[] PROGMEM = {
|
||||
60, 80, 100, 120, 150,
|
||||
};
|
||||
void beep()
|
||||
{
|
||||
_beep(pgm_read_byte(beepTab+(2+g_eeGeneral.beeperLength)));
|
||||
}
|
||||
#else
|
||||
// The various "beep" tone lengths
|
||||
static const pm_uint8_t beepTab[] PROGMEM = {
|
||||
// key, trim, warn2, warn1, error
|
||||
@@ -55,16 +64,14 @@ static const pm_uint8_t beepTab[] PROGMEM = {
|
||||
|
||||
void beep(uint8_t val)
|
||||
{
|
||||
#if defined(HAPTIC) && !defined(AUDIO)
|
||||
#if defined(HAPTIC)
|
||||
haptic.event(val==0 ? AU_KEYPAD_UP : (val==4 ? AU_ERROR : AU_TIMER_10+beepAgain));
|
||||
#endif
|
||||
|
||||
#if !defined(AUDIO)
|
||||
if (g_eeGeneral.alarmsFlash && val>1) flashCounter = FLASH_DURATION;
|
||||
#endif
|
||||
if (g_eeGeneral.alarmsFlash && val>1 && lightOffCounter<FLASH_DURATION) lightOffCounter = FLASH_DURATION;
|
||||
|
||||
if (g_eeGeneral.beepMode>0 || (g_eeGeneral.beepMode==0 && val!=0) || (g_eeGeneral.beepMode==-1 && val>=3)) {
|
||||
_beep(pgm_read_byte(beepTab+5*(2+g_eeGeneral.beepLength)+val));
|
||||
if (g_eeGeneral.beeperMode>0 || (g_eeGeneral.beeperMode==0 && val!=0) || (g_eeGeneral.beeperMode==-1 && val>=3)) {
|
||||
_beep(pgm_read_byte(beepTab+5*(2+g_eeGeneral.beeperLength)+val));
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -34,8 +34,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BUZZER_H
|
||||
#define BUZZER_H
|
||||
#ifndef BEEPER_H
|
||||
#define BEEPER_H
|
||||
|
||||
extern uint8_t g_beepCnt;
|
||||
extern uint8_t beepAgain;
|
||||
@@ -47,7 +47,7 @@ extern bool warbleC;
|
||||
extern uint8_t hapticTick;
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM) && !defined(SIMU)
|
||||
#if defined(CPUARM)
|
||||
inline void _beep(uint8_t b)
|
||||
{
|
||||
buzzerSound(b);
|
||||
@@ -59,7 +59,11 @@ inline void _beep(uint8_t b)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(AUDIO)
|
||||
void beep();
|
||||
#else
|
||||
void beep(uint8_t val);
|
||||
#endif
|
||||
|
||||
#if !defined(AUDIO)
|
||||
#if defined(VOICE)
|
||||
+2
-33
@@ -46,13 +46,9 @@ void doMixerCalculations();
|
||||
memset(channelOutputs, 0, sizeof(channelOutputs)); \
|
||||
memset(ex_chans, 0, sizeof(ex_chans))
|
||||
|
||||
uint16_t anaInValues[NUM_STICKS+NUM_POTS] = { 0 };
|
||||
uint16_t anaIn(uint8_t chan)
|
||||
{
|
||||
if (chan < NUM_STICKS+NUM_POTS)
|
||||
return anaInValues[chan];
|
||||
else
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
TEST(Trims, greaterTrimLink)
|
||||
@@ -303,7 +299,7 @@ TEST(getSwitch, nullSW)
|
||||
EXPECT_EQ(getSwitch(0, 0), false);
|
||||
}
|
||||
|
||||
TEST(FlightModes, nullFadeOut_posFadeIn)
|
||||
TEST(Phases, nullFadeOut_posFadeIn)
|
||||
{
|
||||
MODEL_RESET();
|
||||
g_model.phaseData[1].swtch = SWSRC_ID1;
|
||||
@@ -313,33 +309,6 @@ TEST(FlightModes, nullFadeOut_posFadeIn)
|
||||
perMain();
|
||||
}
|
||||
|
||||
TEST(Mixer, R2029Comment)
|
||||
{
|
||||
MODEL_RESET();
|
||||
MIXER_RESET();
|
||||
g_model.mixData[0].destCh = 0;
|
||||
g_model.mixData[0].srcRaw = MIXSRC_CH2;
|
||||
g_model.mixData[0].swtch = -SWSRC_THR;
|
||||
g_model.mixData[0].weight = 100;
|
||||
g_model.mixData[1].destCh = 1;
|
||||
g_model.mixData[1].srcRaw = MIXSRC_Thr;
|
||||
g_model.mixData[1].swtch = SWSRC_THR;
|
||||
g_model.mixData[1].weight = 100;
|
||||
anaInValues[THR_STICK] = 1024;
|
||||
simuSetSwitch(0, 1);
|
||||
perOut(e_perout_mode_normal, 0);
|
||||
EXPECT_EQ(chans[0], 0);
|
||||
EXPECT_EQ(chans[1], 1024*256);
|
||||
simuSetSwitch(0, 0);
|
||||
perOut(e_perout_mode_normal, 0);
|
||||
EXPECT_EQ(chans[0], 0);
|
||||
EXPECT_EQ(chans[1], 0);
|
||||
simuSetSwitch(0, 1);
|
||||
perOut(e_perout_mode_normal, 0);
|
||||
EXPECT_EQ(chans[0], 0);
|
||||
EXPECT_EQ(chans[1], 1024*256);
|
||||
}
|
||||
|
||||
TEST(Mixer, Cascaded3Channels)
|
||||
{
|
||||
MODEL_RESET();
|
||||
|
||||
+1
-1
@@ -885,7 +885,7 @@ void putsSwitches(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att)
|
||||
lcd_putsiAtt(x, y, STR_VSWITCHES, idx-1, att);
|
||||
}
|
||||
|
||||
#if defined(FLIGHT_MODES)
|
||||
#ifdef FLIGHT_PHASES
|
||||
void putsFlightPhase(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att)
|
||||
{
|
||||
if (idx==0) { lcd_putsiAtt(x, y, STR_MMMINV, 0, att); return; }
|
||||
|
||||
+20
-15
@@ -116,9 +116,9 @@ enum menuGeneralSetupItems {
|
||||
IF_RTCLOCK(ITEM_SETUP_TIME)
|
||||
IF_BATTGRAPH(ITEM_SETUP_BATT_RANGE)
|
||||
ITEM_SETUP_SOUND_LABEL,
|
||||
IF_AUDIO(ITEM_SETUP_BEEP_MODE)
|
||||
IF_BUZZER(ITEM_SETUP_BUZZER_MODE)
|
||||
ITEM_SETUP_BEEP_LENGTH,
|
||||
IF_AUDIO(ITEM_SETUP_AUDIO_MODE)
|
||||
IF_BEEPER(ITEM_SETUP_BEEPER_MODE)
|
||||
ITEM_SETUP_BEEPER_LENGTH,
|
||||
IF_AUDIO(ITEM_SETUP_SPEAKER_PITCH)
|
||||
IF_VOICE(ITEM_SETUP_SPEAKER_VOLUME)
|
||||
IF_HAPTIC(ITEM_SETUP_HAPTIC_LABEL)
|
||||
@@ -135,6 +135,7 @@ enum menuGeneralSetupItems {
|
||||
ITEM_SETUP_MEMORY_WARNING,
|
||||
ITEM_SETUP_ALARM_WARNING,
|
||||
IF_ROTARY_ENCODERS(ITEM_SETUP_RE_NAVIGATION)
|
||||
ITEM_SETUP_THROTTLE_REVERSED,
|
||||
ITEM_SETUP_BACKLIGHT_LABEL,
|
||||
ITEM_SETUP_BACKLIGHT_MODE,
|
||||
ITEM_SETUP_BACKLIGHT_DELAY,
|
||||
@@ -166,7 +167,7 @@ void menuGeneralSetup(uint8_t event)
|
||||
}
|
||||
#endif
|
||||
|
||||
MENU(STR_MENURADIOSETUP, menuTabDiag, e_Setup, ITEM_SETUP_MAX+1, {0, IF_RTCLOCK(2) IF_RTCLOCK(2) IF_BATTGRAPH(1) LABEL(SOUND), IF_AUDIO(0) IF_BUZZER(0) 0, IF_AUDIO(0) IF_VOICE(0) IF_HAPTIC(LABEL(HAPTIC)) IF_HAPTIC(0) IF_HAPTIC(0) IF_HAPTIC(0) IF_PCBSKY9X(0) IF_9X(0) LABEL(ALARMS), 0, IF_PCBSKY9X(0) IF_PCBSKY9X(0) 0, 0, 0, IF_ROTARY_ENCODERS(0) LABEL(BACKLIGHT), 0, 0, CASE_PWM_BACKLIGHT(0) CASE_PWM_BACKLIGHT(0) 0, IF_SPLASH(0) IF_FRSKY(0) IF_FRSKY(0) IF_PXX(0) IF_CPUARM(0) 0, LABEL(TX_MODE), CASE_PCBTARANIS(0) 1/*to force edit mode*/});
|
||||
MENU(STR_MENURADIOSETUP, menuTabDiag, e_Setup, ITEM_SETUP_MAX+1, {0, IF_RTCLOCK(2) IF_RTCLOCK(2) IF_BATTGRAPH(1) LABEL(SOUND), IF_AUDIO(0) IF_BEEPER(0) 0, IF_AUDIO(0) IF_VOICE(0) IF_HAPTIC(LABEL(HAPTIC)) IF_HAPTIC(0) IF_HAPTIC(0) IF_HAPTIC(0) IF_PCBSKY9X(0) IF_9X(0) LABEL(ALARMS), 0, IF_PCBSKY9X(0) IF_PCBSKY9X(0) 0, 0, 0, IF_ROTARY_ENCODERS(0) 0, LABEL(BACKLIGHT), 0, 0, CASE_PWM_BACKLIGHT(0) CASE_PWM_BACKLIGHT(0) 0, IF_SPLASH(0) IF_FRSKY(0) IF_FRSKY(0) IF_PXX(0) IF_CPUARM(0) 0, LABEL(TX_MODE), CASE_PCBTARANIS(0) 1/*to force edit mode*/});
|
||||
|
||||
uint8_t sub = m_posVert - 1;
|
||||
|
||||
@@ -262,32 +263,32 @@ void menuGeneralSetup(uint8_t event)
|
||||
break;
|
||||
|
||||
#if defined(AUDIO)
|
||||
case ITEM_SETUP_BEEP_MODE:
|
||||
g_eeGeneral.beepMode = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_SPEAKER, STR_VBEEPMODE, g_eeGeneral.beepMode, -2, 1, attr, event);
|
||||
case ITEM_SETUP_AUDIO_MODE:
|
||||
g_eeGeneral.beeperMode = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_SPEAKER, STR_VBEEPMODE, g_eeGeneral.beeperMode, -2, 1, attr, event);
|
||||
#if defined(FRSKY)
|
||||
if (attr && checkIncDec_Ret) frskySendAlarms();
|
||||
#endif
|
||||
break;
|
||||
|
||||
#if defined(BUZZER)
|
||||
case ITEM_SETUP_BUZZER_MODE:
|
||||
g_eeGeneral.buzzerMode = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_BUZZER, STR_VBEEPMODE, g_eeGeneral.buzzerMode, -2, 1, attr, event);
|
||||
#if defined(BEEPER)
|
||||
case ITEM_SETUP_BEEPER_MODE:
|
||||
g_eeGeneral.alarmsBeep = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_BEEPER, STR_VBEEPMODE, g_eeGeneral.alarmsBeep, 0, 1, attr, event);
|
||||
#if defined(FRSKY)
|
||||
if (attr && checkIncDec_Ret) frskySendAlarms();
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
#else
|
||||
case ITEM_SETUP_BUZZER_MODE:
|
||||
g_eeGeneral.beepMode = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_SPEAKER, STR_VBEEPMODE, g_eeGeneral.beepMode, -2, 1, attr, event);
|
||||
case ITEM_SETUP_BEEPER_MODE:
|
||||
g_eeGeneral.beeperMode = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_SPEAKER, STR_VBEEPMODE, g_eeGeneral.beeperMode, -2, 1, attr, event);
|
||||
#if defined(FRSKY)
|
||||
if (attr && checkIncDec_Ret) frskySendAlarms();
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
|
||||
case ITEM_SETUP_BEEP_LENGTH:
|
||||
SLIDER_5POS(y, g_eeGeneral.beepLength, STR_LENGTH, event, attr);
|
||||
case ITEM_SETUP_BEEPER_LENGTH:
|
||||
SLIDER_5POS(y, g_eeGeneral.beeperLength, STR_LENGTH, event, attr);
|
||||
break;
|
||||
|
||||
#if defined(AUDIO)
|
||||
@@ -420,14 +421,18 @@ void menuGeneralSetup(uint8_t event)
|
||||
break;
|
||||
#endif
|
||||
|
||||
case ITEM_SETUP_BACKLIGHT_LABEL:
|
||||
lcd_putsLeft(y, STR_BACKLIGHT_LABEL);
|
||||
case ITEM_SETUP_THROTTLE_REVERSED:
|
||||
g_eeGeneral.throttleReversed = onoffMenuItem(g_eeGeneral.throttleReversed, RADIO_SETUP_2ND_COLUMN, y, STR_THROTTLEREVERSE, attr, event ) ;
|
||||
break;
|
||||
|
||||
case ITEM_SETUP_BACKLIGHT_MODE:
|
||||
g_eeGeneral.backlightMode = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_MODE, STR_VBLMODE, g_eeGeneral.backlightMode, e_backlight_mode_off, e_backlight_mode_on, attr, event);
|
||||
break;
|
||||
|
||||
case ITEM_SETUP_BACKLIGHT_LABEL:
|
||||
lcd_putsLeft(y, STR_BACKLIGHT_LABEL);
|
||||
break;
|
||||
|
||||
case ITEM_SETUP_FLASH_BEEP:
|
||||
g_eeGeneral.alarmsFlash = onoffMenuItem(g_eeGeneral.alarmsFlash, RADIO_SETUP_2ND_COLUMN, y, STR_ALARM, attr, event ) ;
|
||||
break;
|
||||
|
||||
+228
-390
@@ -42,9 +42,9 @@
|
||||
|
||||
enum EnumTabModel {
|
||||
e_ModelSelect,
|
||||
e_ModelSetup,
|
||||
e_Model,
|
||||
IF_HELI(e_Heli)
|
||||
IF_FLIGHT_MODES(e_FlightModesAll)
|
||||
IF_FLIGHT_PHASES(e_PhasesAll)
|
||||
e_ExposAll,
|
||||
e_MixAll,
|
||||
e_Limits,
|
||||
@@ -61,7 +61,7 @@ enum EnumTabModel {
|
||||
void menuModelSelect(uint8_t event);
|
||||
void menuModelSetup(uint8_t event);
|
||||
void menuModelHeli(uint8_t event);
|
||||
void menuModelFlightModesAll(uint8_t event);
|
||||
void menuModelPhasesAll(uint8_t event);
|
||||
void menuModelExposAll(uint8_t event);
|
||||
void menuModelMixAll(uint8_t event);
|
||||
void menuModelLimits(uint8_t event);
|
||||
@@ -72,17 +72,18 @@ void menuModelCustomFunctions(uint8_t event);
|
||||
void menuModelTelemetry(uint8_t event);
|
||||
void menuModelTemplates(uint8_t event);
|
||||
void menuModelExpoOne(uint8_t event);
|
||||
void menuModelFailsafe(uint8_t event);
|
||||
|
||||
const MenuFuncP_PROGMEM menuTabModel[] PROGMEM = {
|
||||
menuModelSelect,
|
||||
menuModelSetup,
|
||||
IF_HELI(menuModelHeli)
|
||||
IF_FLIGHT_MODES(menuModelFlightModesAll)
|
||||
IF_FLIGHT_PHASES(menuModelPhasesAll)
|
||||
menuModelExposAll,
|
||||
menuModelMixAll,
|
||||
menuModelLimits,
|
||||
IF_CURVES(menuModelCurvesAll)
|
||||
#if LCD_W >= 212 && defined(GVARS) && defined(FLIGHT_MODES)
|
||||
#if LCD_W >= 212 && defined(GVARS) && defined(FLIGHT_PHASES)
|
||||
IF_GVARS(menuModelGVars)
|
||||
#endif
|
||||
menuModelCustomSwitches,
|
||||
@@ -251,6 +252,7 @@ void onModelSelectMenu(const char *result)
|
||||
eeLoadModel(sub);
|
||||
}
|
||||
}
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
else if (result == STR_COPY_MODEL) {
|
||||
s_copyMode = COPY_MODE;
|
||||
s_copyTgtOfs = 0;
|
||||
@@ -261,6 +263,7 @@ void onModelSelectMenu(const char *result)
|
||||
s_copyTgtOfs = 0;
|
||||
s_copySrcRow = -1;
|
||||
}
|
||||
#endif
|
||||
#if defined(SDCARD)
|
||||
else if (result == STR_BACKUP_MODEL) {
|
||||
eeCheck(true); // force writing of current model data before this is changed
|
||||
@@ -319,12 +322,6 @@ void menuModelSelect(uint8_t event)
|
||||
|
||||
if (!check_submenu_simple(_event_, MAX_MODELS-1)) return;
|
||||
|
||||
#if defined(NAVIGATION_POT2)
|
||||
if (event==0 && p2valdiff<0) {
|
||||
event = EVT_KEY_FIRST(KEY_RIGHT);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (s_editMode > 0) s_editMode = 0;
|
||||
|
||||
#if !defined(CPUARM)
|
||||
@@ -444,8 +441,8 @@ void menuModelSelect(uint8_t event)
|
||||
if (eeModelExists(sub)) {
|
||||
MENU_ADD_ITEM(STR_SELECT_MODEL);
|
||||
MENU_ADD_SD_ITEM(STR_BACKUP_MODEL);
|
||||
MENU_ADD_ITEM(STR_COPY_MODEL);
|
||||
MENU_ADD_ITEM(STR_MOVE_MODEL);
|
||||
MENU_ADD_NAVIGATION_ITEM(STR_COPY_MODEL);
|
||||
MENU_ADD_NAVIGATION_ITEM(STR_MOVE_MODEL);
|
||||
MENU_ADD_ITEM(STR_DELETE_MODEL);
|
||||
}
|
||||
else {
|
||||
@@ -467,8 +464,8 @@ void menuModelSelect(uint8_t event)
|
||||
}
|
||||
else {
|
||||
MENU_ADD_SD_ITEM(STR_BACKUP_MODEL);
|
||||
MENU_ADD_ITEM(STR_COPY_MODEL);
|
||||
MENU_ADD_ITEM(STR_MOVE_MODEL);
|
||||
MENU_ADD_NAVIGATION_ITEM(STR_COPY_MODEL);
|
||||
MENU_ADD_NAVIGATION_ITEM(STR_MOVE_MODEL);
|
||||
}
|
||||
menuHandler = onModelSelectMenu;
|
||||
#else
|
||||
@@ -612,103 +609,6 @@ void menuModelSelect(uint8_t event)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
uint8_t g_moduleIdx;
|
||||
void menuModelFailsafe(uint8_t event)
|
||||
{
|
||||
static bool longNames = false;
|
||||
bool newLongNames = false;
|
||||
uint8_t ch;
|
||||
|
||||
SUBMENU_NOTITLE(32, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0});
|
||||
|
||||
switch(event)
|
||||
{
|
||||
case EVT_KEY_BREAK(KEY_EXIT):
|
||||
popMenu();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_posVert >= 16)
|
||||
ch = 16;
|
||||
else
|
||||
ch = 0;
|
||||
|
||||
lcd_putsCenter(0*FH, FAILSAFESET);
|
||||
lcd_invert_line(0);
|
||||
|
||||
// Column separator
|
||||
lcd_vline(LCD_W/2, FH, LCD_H-FH);
|
||||
|
||||
for (uint8_t col=0; col<2; col++) {
|
||||
|
||||
uint8_t x = col*LCD_W/2+1;
|
||||
|
||||
// Channels
|
||||
for (uint8_t line=0; line<8; line++) {
|
||||
uint8_t y = 9+line*7;
|
||||
int32_t val;
|
||||
uint8_t ofs = (col ? 0 : 1);
|
||||
|
||||
if (ch < g_model.moduleData[g_moduleIdx].channelsStart || ch >= NUM_CHANNELS(g_moduleIdx) + g_model.moduleData[g_moduleIdx].channelsStart)
|
||||
val = 0;
|
||||
else if (s_editMode && m_posVert == ch)
|
||||
val = channelOutputs[ch];
|
||||
else
|
||||
val = g_model.moduleData[g_moduleIdx].failsafeChannels[8*col+line];
|
||||
|
||||
if (m_posVert == ch && event == EVT_KEY_LONG(KEY_ENTER)) {
|
||||
g_model.moduleData[g_moduleIdx].failsafeChannels[8*col+line] = val;
|
||||
eeDirty(EE_MODEL);
|
||||
s_editMode = 0;
|
||||
AUDIO_WARNING1();
|
||||
SEND_FAILSAFE_NOW();
|
||||
killEvents(event);
|
||||
}
|
||||
|
||||
// Channel name if present, number if not
|
||||
uint8_t lenLabel = zlen(g_model.limitData[ch].name, sizeof(g_model.limitData[ch].name));
|
||||
if (lenLabel > 4) {
|
||||
newLongNames = longNames = true;
|
||||
}
|
||||
|
||||
if (lenLabel > 0)
|
||||
lcd_putsnAtt(x+1-ofs, y, g_model.limitData[ch].name, sizeof(g_model.limitData[ch].name), ZCHAR | SMLSIZE);
|
||||
else
|
||||
putsChn(x+1-ofs, y, ch+1, SMLSIZE);
|
||||
|
||||
uint8_t wbar = (longNames ? 48 : 58);
|
||||
|
||||
// Value
|
||||
LcdFlags flags = PREC1 | TINSIZE;
|
||||
|
||||
if (m_posVert == ch) {
|
||||
flags |= INVERS;
|
||||
if (s_editMode)
|
||||
flags |= BLINK;
|
||||
}
|
||||
|
||||
lcd_outdezNAtt(x+LCD_W/2-3-wbar-ofs, y+1, calcRESXto1000(val), flags);
|
||||
|
||||
// Gauge
|
||||
lcd_rect(x+LCD_W/2-3-wbar-ofs, y, wbar+1, 6);
|
||||
uint16_t lim = g_model.extendedLimits ? 640*2 : 512*2;
|
||||
uint8_t len = limit((uint8_t)1, uint8_t((abs(val) * wbar/2 + lim/2) / lim), uint8_t(wbar/2));
|
||||
uint8_t x0 = (val>0) ? x+LCD_W/2-ofs-3-wbar/2 : x+LCD_W/2-ofs-2-wbar/2-len;
|
||||
lcd_hline(x0, y+1, len);
|
||||
lcd_hline(x0, y+2, len);
|
||||
lcd_hline(x0, y+3, len);
|
||||
lcd_hline(x0, y+4, len);
|
||||
|
||||
ch++;
|
||||
}
|
||||
}
|
||||
|
||||
longNames = newLongNames;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
void editName(uint8_t x, uint8_t y, char *name, uint8_t size, uint8_t event, uint8_t active)
|
||||
{
|
||||
#if defined(CPUM64)
|
||||
@@ -816,24 +716,16 @@ enum menuModelSetupItems {
|
||||
ITEM_MODEL_EXTENDED_LIMITS,
|
||||
ITEM_MODEL_EXTENDED_TRIMS,
|
||||
ITEM_MODEL_TRIM_INC,
|
||||
ITEM_MODEL_THROTTLE_REVERSED,
|
||||
ITEM_MODEL_THROTTLE_TRACE,
|
||||
ITEM_MODEL_THROTTLE_TRIM,
|
||||
ITEM_MODEL_THROTTLE_WARNING,
|
||||
ITEM_MODEL_SWITCHES_WARNING,
|
||||
ITEM_MODEL_BEEP_CENTER,
|
||||
#if defined(PCBTARANIS)
|
||||
ITEM_MODEL_INTERNAL_MODULE_LABEL,
|
||||
ITEM_MODEL_INTERNAL_MODULE_MODE,
|
||||
ITEM_MODEL_INTERNAL_MODULE_CHANNELS,
|
||||
ITEM_MODEL_INTERNAL_MODULE_BIND,
|
||||
ITEM_MODEL_INTERNAL_MODULE_FAILSAFE,
|
||||
ITEM_MODEL_EXTERNAL_MODULE_LABEL,
|
||||
ITEM_MODEL_EXTERNAL_MODULE_MODE,
|
||||
ITEM_MODEL_EXTERNAL_MODULE_CHANNELS,
|
||||
ITEM_MODEL_EXTERNAL_MODULE_BIND,
|
||||
ITEM_MODEL_EXTERNAL_MODULE_FAILSAFE,
|
||||
ITEM_MODEL_TRAINER,
|
||||
ITEM_MODE_INTERNAL_MODULE_LABEL,
|
||||
ITEM_MODE_INTERNAL_MODULE_MODE,
|
||||
ITEM_MODE_INTERNAL_MODULE_BIND,
|
||||
ITEM_MODE_INTERNAL_MODULE_FAILSAFE,
|
||||
#else
|
||||
ITEM_MODEL_PROTOCOL,
|
||||
IF_PCBSKY9X(ITEM_MODEL_PPM2_PROTOCOL)
|
||||
@@ -883,29 +775,17 @@ void menuModelSetup(uint8_t event)
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
if (event == EVT_KEY_LONG(KEY_EXIT)) {
|
||||
pxxFlag[0] = 0;
|
||||
pxxFlag[1] = 0;
|
||||
pxxFlag = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
bool CURSOR_ON_CELL = (m_posHorz >= 0);
|
||||
#define IF_PORT1_ON(x) (g_model.moduleData[0].rfProtocol == RF_PROTO_OFF ? (uint8_t)-1 : (uint8_t)(x))
|
||||
#define IF_PORT2_ON(x) (g_model.externalModule == MODULE_TYPE_NONE ? (uint8_t)-1 : (uint8_t)(x))
|
||||
#define IF_PORT_ON(idx, x) (idx==0 ? IS_PORT1_ON(x) : IS_PORT2_ON(x))
|
||||
#define IF_PORT2_XJT(x) (IS_MODULE_XJT(1) ? (uint8_t)x : (uint8_t)-1)
|
||||
#define PORT1_CHANNELS_ROWS() IF_PORT1_ON(1)
|
||||
#define PORT2_CHANNELS_ROWS() IF_PORT2_ON(g_model.externalModule == MODULE_TYPE_DJT ? (uint8_t)0 : (g_model.externalModule == MODULE_TYPE_DSM2 ? (uint8_t)0 : ((uint8_t)1)))
|
||||
#define PORT_CHANNELS_ROWS(x) (x==0 ? PORT1_CHANNELS_ROWS() : PORT2_CHANNELS_ROWS())
|
||||
MENU(STR_MENUSETUP, menuTabModel, e_ModelSetup, 1+ITEM_MODEL_SETUP_MAX, { 0, 0, CASE_PCBTARANIS(0) 2, IF_PERSISTENT_TIMERS(0) 0, 0, 2, IF_PERSISTENT_TIMERS(0) 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, NAVIGATION_LINE_BY_LINE|(NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1), LABEL(InternalModule), 0, IF_PORT1_ON(1), IF_PORT1_ON(2), IF_PORT1_ON(g_model.moduleData[0].failsafeMode==FAILSAFE_CUSTOM ? (uint8_t)1 : (uint8_t)0), LABEL(ExternalModule), g_model.externalModule==MODULE_TYPE_XJT ? (uint8_t)1 : (uint8_t)0, PORT2_CHANNELS_ROWS(), (IS_MODULE_PPM(1) || IS_MODULE_XJT(1) ? (uint8_t)2 : (uint8_t)-1), IF_PORT2_XJT(g_model.moduleData[1].failsafeMode==FAILSAFE_CUSTOM ? (uint8_t)1 : (uint8_t)0), 0});
|
||||
#elif defined(CPUM64)
|
||||
#define CURSOR_ON_CELL (true)
|
||||
uint8_t protocol = g_model.protocol;
|
||||
MENU(STR_MENUSETUP, menuTabModel, e_ModelSetup, ((IS_PPM_PROTOCOL(protocol)||IS_DSM2_PROTOCOL(protocol)||IS_PXX_PROTOCOL(protocol)) ? 1+ITEM_MODEL_SETUP_MAX : ITEM_MODEL_SETUP_MAX), { 0, 0, CASE_PCBTARANIS(0) 2, IF_PERSISTENT_TIMERS(0) 0, 0, 2, IF_PERSISTENT_TIMERS(0) 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1, FIELD_PROTOCOL_MAX, IF_PCBSKY9X(1) 2 });
|
||||
MENU(STR_MENUSETUP, menuTabModel, e_Model, 1+ITEM_MODEL_SETUP_MAX, { 0, 0, CASE_PCBTARANIS(0) 2, IF_PERSISTENT_TIMERS(0) 0, 0, 2, IF_PERSISTENT_TIMERS(0) 0, 0, 0, 0, 0, 0, 0, 0, 0, NAVIGATION_LINE_BY_LINE|(NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1), LABEL(InternalModule), 2, 2, g_model.failsafeMode==FAILSAFE_CUSTOM ? (uint8_t)1 : (uint8_t)0});
|
||||
#else
|
||||
#define CURSOR_ON_CELL (true)
|
||||
uint8_t protocol = g_model.protocol;
|
||||
MENU(STR_MENUSETUP, menuTabModel, e_ModelSetup, ((IS_PPM_PROTOCOL(protocol)||IS_DSM2_PROTOCOL(protocol)||IS_PXX_PROTOCOL(protocol)) ? 1+ITEM_MODEL_SETUP_MAX : ITEM_MODEL_SETUP_MAX), { 0, 0, CASE_PCBTARANIS(0) 2, IF_PERSISTENT_TIMERS(0) 0, 0, 2, IF_PERSISTENT_TIMERS(0) 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1, FIELD_PROTOCOL_MAX, IF_PCBSKY9X(1) 2 });
|
||||
MENU(STR_MENUSETUP, menuTabModel, e_Model, ((IS_PPM_PROTOCOL(protocol)||IS_DSM2_PROTOCOL(protocol)||IS_PXX_PROTOCOL(protocol)) ? 1+ITEM_MODEL_SETUP_MAX : ITEM_MODEL_SETUP_MAX), { 0, 0, CASE_PCBTARANIS(0) 2, IF_PERSISTENT_TIMERS(0) 0, 0, 2, IF_PERSISTENT_TIMERS(0) 0, 0, 0, 0, 0, 0, 0, 0, 0, NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1, FIELD_PROTOCOL_MAX, IF_PCBSKY9X(1) 2 });
|
||||
#endif
|
||||
|
||||
uint8_t sub = m_posVert - 1;
|
||||
@@ -1002,32 +882,13 @@ void menuModelSetup(uint8_t event)
|
||||
break;
|
||||
|
||||
case ITEM_MODEL_EXTENDED_TRIMS:
|
||||
#if defined(CPUM64)
|
||||
g_model.extendedTrims = onoffMenuItem(g_model.extendedTrims, MODEL_SETUP_2ND_COLUMN, y, STR_ETRIMS, attr, event);
|
||||
#else
|
||||
g_model.extendedTrims = onoffMenuItem(g_model.extendedTrims, MODEL_SETUP_2ND_COLUMN, y, STR_ETRIMS, m_posHorz<=0 ? attr : 0, event==EVT_KEY_BREAK(KEY_ENTER) ? event : 0);
|
||||
lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+3*FW, y, STR_RESET, m_posHorz>0 ? attr : 0);
|
||||
if (attr && m_posHorz>0) {
|
||||
s_editMode = 0;
|
||||
if (event==EVT_KEY_LONG(KEY_ENTER)) {
|
||||
for (uint8_t i=0; i<MAX_PHASES; i++) {
|
||||
memclear(&g_model.phaseData[i], TRIMS_ARRAY_SIZE);
|
||||
}
|
||||
eeDirty(EE_MODEL);
|
||||
AUDIO_WARNING1();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case ITEM_MODEL_TRIM_INC:
|
||||
g_model.trimInc = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_TRIMINC, STR_VTRIMINC, g_model.trimInc, 0, 4, attr, event);
|
||||
break;
|
||||
|
||||
case ITEM_MODEL_THROTTLE_REVERSED:
|
||||
g_model.throttleReversed = onoffMenuItem(g_model.throttleReversed, MODEL_SETUP_2ND_COLUMN, y, STR_THROTTLEREVERSE, attr, event ) ;
|
||||
break;
|
||||
|
||||
case ITEM_MODEL_THROTTLE_TRACE:
|
||||
{
|
||||
lcd_putsLeft(y, STR_TTRACE);
|
||||
@@ -1115,170 +976,89 @@ void menuModelSetup(uint8_t event)
|
||||
break;
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
case ITEM_MODEL_INTERNAL_MODULE_LABEL:
|
||||
case ITEM_MODE_INTERNAL_MODULE_LABEL:
|
||||
lcd_putsLeft(y, TR_INTERNALRF);
|
||||
break;
|
||||
|
||||
case ITEM_MODEL_EXTERNAL_MODULE_LABEL:
|
||||
lcd_putsLeft(y, TR_EXTERNALRF);
|
||||
break;
|
||||
|
||||
case ITEM_MODEL_INTERNAL_MODULE_MODE:
|
||||
case ITEM_MODE_INTERNAL_MODULE_MODE:
|
||||
lcd_putsLeft(y, STR_MODE);
|
||||
lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN, y, PSTR("\004""OFF\0""X16\0""D8\0 ""LR12"), 1+g_model.moduleData[0].rfProtocol, attr);
|
||||
if (attr) {
|
||||
CHECK_INCDEC_MODELVAR(event, g_model.moduleData[0].rfProtocol, RF_PROTO_OFF, RF_PROTO_LAST);
|
||||
if (checkIncDec_Ret) {
|
||||
g_model.moduleData[0].channelsStart = 0;
|
||||
g_model.moduleData[0].channelsCount = MAX_PORT1_CHANNELS();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ITEM_MODEL_EXTERNAL_MODULE_MODE:
|
||||
lcd_putsLeft(y, PSTR(INDENT "Module"));
|
||||
lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN, y, PSTR("\004""---\0""PPM\0""XJT\0""DJT\0""DSM2"), g_model.externalModule, m_posHorz==0 ? attr : 0);
|
||||
if (g_model.externalModule == MODULE_TYPE_XJT)
|
||||
lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN+5*FW, y, PSTR("\004""OFF\0""X16\0""D8\0 ""LR12"), 1+g_model.moduleData[1].rfProtocol, m_posHorz==1 ? attr : 0);
|
||||
lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN, y, PSTR("\004""OFF\0""X16\0""D8\0 ""LR12"), 1+g_model.rfProtocol, m_posHorz==0 ? attr : 0);
|
||||
lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+5*FW+3, y, STR_CH, m_posHorz==1 ? attr : 0);
|
||||
lcd_outdezAtt(lcdLastPos, y, g_model.ppmSCH+1, LEFT | (m_posHorz==1 ? attr : 0));
|
||||
lcd_putc(lcdLastPos, y, '-');
|
||||
lcd_outdezAtt(lcdLastPos + FW+1, y, g_model.ppmSCH+NUM_PORT1_CHANNELS(g_model), LEFT | (m_posHorz==2 ? attr : 0));
|
||||
if (attr && m_posHorz < 0) lcd_filled_rect(MODEL_SETUP_2ND_COLUMN, y, LCD_W-MODEL_SETUP_2ND_COLUMN-MENUS_SCROLLBAR_WIDTH, 8);
|
||||
if (attr && (editMode>0 || p1valdiff)) {
|
||||
static const int8_t maxChannels[] = { 0, 4, 0, 2 };
|
||||
switch (m_posHorz) {
|
||||
case 0:
|
||||
CHECK_INCDEC_MODELVAR(event, g_model.externalModule, MODULE_TYPE_NONE, MODULE_TYPE_LAST);
|
||||
if (checkIncDec_Ret) {
|
||||
g_model.moduleData[1].channelsStart = 0;
|
||||
g_model.moduleData[1].channelsCount = MAX_PORT2_CHANNELS();
|
||||
}
|
||||
CHECK_INCDEC_MODELVAR(event, g_model.rfProtocol, RF_PROTO_OFF, RF_PROTO_LAST);
|
||||
g_model.ppmSCH = 0;
|
||||
g_model.ppmNCH = maxChannels[1+g_model.rfProtocol];
|
||||
break;
|
||||
case 1:
|
||||
CHECK_INCDEC_MODELVAR(event, g_model.moduleData[1].rfProtocol, RF_PROTO_X16, RF_PROTO_LAST);
|
||||
if (checkIncDec_Ret) {
|
||||
g_model.moduleData[1].channelsStart = 0;
|
||||
g_model.moduleData[1].channelsCount = MAX_PORT2_CHANNELS();
|
||||
}
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, g_model.ppmSCH, 32-8-(g_model.ppmNCH*2));
|
||||
break;
|
||||
case 2:
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, g_model.ppmNCH, min<int8_t>(maxChannels[1+g_model.rfProtocol], (32-g_model.ppmSCH)/2-4));
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ITEM_MODE_INTERNAL_MODULE_BIND:
|
||||
lcd_putsLeft(y, STR_RXNUM);
|
||||
lcd_outdezNAtt(MODEL_SETUP_2ND_COLUMN, y, g_model.modelId, (m_posHorz==0 ? attr : 0) | LEADING0|LEFT, 2);
|
||||
if (attr && m_posHorz==0) {
|
||||
if (editMode>0 || p1valdiff) {
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, g_model.modelId, 63);
|
||||
if (checkIncDec_Ret)
|
||||
modelIds[g_eeGeneral.currModel] = g_model.modelId;
|
||||
}
|
||||
if (editMode==0 && event==EVT_KEY_BREAK(KEY_ENTER))
|
||||
checkModelIdUnique(g_eeGeneral.currModel);
|
||||
}
|
||||
|
||||
case ITEM_MODEL_INTERNAL_MODULE_CHANNELS:
|
||||
case ITEM_MODEL_EXTERNAL_MODULE_CHANNELS:
|
||||
{
|
||||
uint8_t moduleIdx = (k>=ITEM_MODEL_EXTERNAL_MODULE_LABEL ? 1 : 0);
|
||||
ModuleData & moduleData = g_model.moduleData[moduleIdx];
|
||||
lcd_putsLeft(y, PSTR(INDENT "Channels Range"));
|
||||
if ((int8_t)PORT_CHANNELS_ROWS(moduleIdx) >= 0) {
|
||||
lcd_putsAtt(MODEL_SETUP_2ND_COLUMN, y, STR_CH, m_posHorz==0 ? attr : 0);
|
||||
lcd_outdezAtt(lcdLastPos, y, moduleData.channelsStart+1, LEFT | (m_posHorz==0 ? attr : 0));
|
||||
lcd_putc(lcdLastPos, y, '-');
|
||||
lcd_outdezAtt(lcdLastPos + FW+1, y, moduleData.channelsStart+NUM_CHANNELS(moduleIdx), LEFT | (m_posHorz==1 ? attr : 0));
|
||||
if (attr && (editMode>0 || p1valdiff)) {
|
||||
switch (m_posHorz) {
|
||||
case 0:
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, moduleData.channelsStart, 32-8-moduleData.channelsCount);
|
||||
break;
|
||||
case 1:
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, moduleData.channelsCount, min<int8_t>(MAX_CHANNELS(moduleIdx), 32-moduleData.channelsStart-8));
|
||||
break;
|
||||
lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+3*FW, y, STR_MODULE_BIND, m_posHorz==1 ? attr : 0);
|
||||
lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+10*FW, y, STR_MODULE_RANGE, m_posHorz==2 ? attr : 0);
|
||||
{
|
||||
uint8_t newFlag = 0;
|
||||
if (attr && m_posHorz>0 && s_editMode>0) {
|
||||
if (m_posHorz == 1)
|
||||
newFlag = PXX_SEND_RXNUM;
|
||||
else if(m_posHorz == 2) {
|
||||
newFlag = PXX_SEND_RANGECHECK;
|
||||
displayPopup("RSSI: ");
|
||||
lcd_outdezAtt(16+4*FW, 5*FH, frskyData.rssi[0].value, BOLD);
|
||||
}
|
||||
}
|
||||
pxxFlag = newFlag;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ITEM_MODEL_INTERNAL_MODULE_BIND:
|
||||
case ITEM_MODEL_EXTERNAL_MODULE_BIND:
|
||||
{
|
||||
uint8_t moduleIdx = (k>=ITEM_MODEL_EXTERNAL_MODULE_LABEL ? 1 : 0);
|
||||
if (IS_MODULE_PPM(moduleIdx)) {
|
||||
lcd_putsLeft(y, STR_PPMFRAME);
|
||||
lcd_puts(MODEL_SETUP_2ND_COLUMN+3*FW, y, STR_MS);
|
||||
lcd_outdezAtt(MODEL_SETUP_2ND_COLUMN, y, (int16_t)g_model.ppmFrameLength*5 + 225, (m_posHorz<=0 ? attr : 0) | PREC1|LEFT);
|
||||
lcd_putc(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, 'u');
|
||||
lcd_outdezAtt(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, (g_model.ppmDelay*50)+300, (m_posHorz < 0 || m_posHorz==1) ? attr : 0);
|
||||
lcd_putcAtt(MODEL_SETUP_2ND_COLUMN+10*FW, y, g_model.pulsePol ? '+' : '-', (m_posHorz < 0 || m_posHorz==2) ? attr : 0);
|
||||
|
||||
if (attr && (editMode>0 || p1valdiff)) {
|
||||
switch (m_posHorz) {
|
||||
case 0:
|
||||
CHECK_INCDEC_MODELVAR(event, g_model.ppmFrameLength, -20, 35);
|
||||
break;
|
||||
case 1:
|
||||
CHECK_INCDEC_MODELVAR(event, g_model.ppmDelay, -4, 10);
|
||||
break;
|
||||
case 2:
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, g_model.pulsePol, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
lcd_putsLeft(y, STR_RXNUM);
|
||||
if (IS_MODULE_XJT(moduleIdx)) {
|
||||
lcd_outdezNAtt(MODEL_SETUP_2ND_COLUMN, y, g_model.modelId, (m_posHorz==0 ? attr : 0) | LEADING0|LEFT, 2);
|
||||
if (attr && m_posHorz==0) {
|
||||
if (editMode>0 || p1valdiff) {
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, g_model.modelId, 63);
|
||||
if (checkIncDec_Ret)
|
||||
modelIds[g_eeGeneral.currModel] = g_model.modelId;
|
||||
}
|
||||
if (editMode==0 && event==EVT_KEY_BREAK(KEY_ENTER))
|
||||
checkModelIdUnique(g_eeGeneral.currModel);
|
||||
}
|
||||
|
||||
lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+3*FW, y, STR_MODULE_BIND, m_posHorz==1 ? attr : 0);
|
||||
lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+10*FW, y, STR_MODULE_RANGE, m_posHorz==2 ? attr : 0);
|
||||
{
|
||||
uint8_t newFlag = 0;
|
||||
if (attr && m_posHorz>0 && s_editMode>0) {
|
||||
if (m_posHorz == 1)
|
||||
newFlag = PXX_SEND_RXNUM;
|
||||
else if (m_posHorz == 2) {
|
||||
newFlag = PXX_SEND_RANGECHECK;
|
||||
}
|
||||
}
|
||||
pxxFlag[moduleIdx] = newFlag;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ITEM_MODEL_INTERNAL_MODULE_FAILSAFE:
|
||||
case ITEM_MODEL_EXTERNAL_MODULE_FAILSAFE:
|
||||
{
|
||||
uint8_t moduleIdx = (k>=ITEM_MODEL_EXTERNAL_MODULE_LABEL ? 1 : 0);
|
||||
ModuleData & moduleData = g_model.moduleData[moduleIdx];
|
||||
case ITEM_MODE_INTERNAL_MODULE_FAILSAFE:
|
||||
lcd_putsLeft(y, TR_FAILSAFE);
|
||||
if (IS_MODULE_XJT(moduleIdx)) {
|
||||
lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN, y, STR_VFAILSAFE, moduleData.failsafeMode, m_posHorz==0 ? attr : 0);
|
||||
if (moduleData.failsafeMode == FAILSAFE_CUSTOM) lcd_putsAtt(MODEL_SETUP_2ND_COLUMN + 10*FW, y, STR_SET, m_posHorz==1 ? attr : 0);
|
||||
if (attr) {
|
||||
if (moduleData.failsafeMode != FAILSAFE_CUSTOM)
|
||||
m_posHorz = 0;
|
||||
if (m_posHorz==0) {
|
||||
if (editMode>0 || p1valdiff) {
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, moduleData.failsafeMode, FAILSAFE_LAST);
|
||||
if (checkIncDec_Ret) SEND_FAILSAFE_NOW();
|
||||
}
|
||||
}
|
||||
else if (m_posHorz==1) {
|
||||
s_editMode = 0;
|
||||
if (moduleData.failsafeMode==FAILSAFE_CUSTOM && event==EVT_KEY_FIRST(KEY_ENTER)) {
|
||||
g_moduleIdx = moduleIdx;
|
||||
pushMenu(menuModelFailsafe);
|
||||
}
|
||||
}
|
||||
else {
|
||||
lcd_filled_rect(MODEL_SETUP_2ND_COLUMN, y, LCD_W-MODEL_SETUP_2ND_COLUMN-MENUS_SCROLLBAR_WIDTH, 8);
|
||||
lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN, y, STR_VFAILSAFE, g_model.failsafeMode, m_posHorz==0 ? attr : 0);
|
||||
if (g_model.failsafeMode == FAILSAFE_CUSTOM) lcd_putsAtt(MODEL_SETUP_2ND_COLUMN + 10*FW, y, STR_SET, m_posHorz==1 ? attr : 0);
|
||||
if (attr) {
|
||||
if (g_model.failsafeMode != FAILSAFE_CUSTOM)
|
||||
m_posHorz = 0;
|
||||
if (m_posHorz==0) {
|
||||
if (editMode>0 || p1valdiff) {
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, g_model.failsafeMode, FAILSAFE_LAST);
|
||||
if (checkIncDec_Ret) SEND_FAILSAFE_NOW();
|
||||
}
|
||||
}
|
||||
else if (m_posHorz==1) {
|
||||
s_editMode = 0;
|
||||
if (g_model.failsafeMode==FAILSAFE_CUSTOM && event==EVT_KEY_FIRST(KEY_ENTER))
|
||||
pushMenu(menuModelFailsafe);
|
||||
}
|
||||
else {
|
||||
lcd_filled_rect(MODEL_SETUP_2ND_COLUMN, y, LCD_W-MODEL_SETUP_2ND_COLUMN-MENUS_SCROLLBAR_WIDTH, 8);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ITEM_MODEL_TRAINER:
|
||||
g_model.trainerMode = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, PSTR("Trainer Mode"), PSTR("\006MasterSlave"), g_model.trainerMode, 0, 1, attr, event);
|
||||
break;
|
||||
#else
|
||||
case ITEM_MODEL_PROTOCOL:
|
||||
#if defined(PCBSKY9X)
|
||||
@@ -1293,7 +1073,7 @@ void menuModelSetup(uint8_t event)
|
||||
lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+4*FW+3, y, STR_CH, m_posHorz==1 ? attr : 0);
|
||||
lcd_outdezAtt(lcdLastPos, y, g_model.ppmSCH+1, LEFT | (m_posHorz==1 ? attr : 0));
|
||||
lcd_putc(lcdLastPos, y, '-');
|
||||
lcd_outdezAtt(lcdLastPos + FW+1, y, g_model.ppmSCH+NUM_PORT1_CHANNELS(), LEFT | (m_posHorz==2 ? attr : 0));
|
||||
lcd_outdezAtt(lcdLastPos + FW+1, y, g_model.ppmSCH+NUM_PORT1_CHANNELS(g_model), LEFT | (m_posHorz==2 ? attr : 0));
|
||||
#else
|
||||
if (IS_PPM_PROTOCOL(protocol)) {
|
||||
lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN+7*FW, y, STR_NCHANNELS, g_model.ppmNCH+2, m_posHorz!=0 ? attr : 0);
|
||||
@@ -1315,7 +1095,7 @@ void menuModelSetup(uint8_t event)
|
||||
case 1:
|
||||
#if defined(PCBSKY9X)
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, g_model.ppmSCH, 32-8-(g_model.ppmNCH*2));
|
||||
g_model.ppmFrameLength = NUM_PORT1_CHANNELS()>NUM_PORT2_CHANNELS() ? 4*(NUM_PORT1_CHANNELS()-8) : 4*(NUM_PORT2_CHANNELS()-8);
|
||||
g_model.ppmFrameLength = NUM_PORT1_CHANNELS(g_model)>NUM_PORT2_CHANNELS(g_model) ? 4*(NUM_PORT1_CHANNELS(g_model)-8) : 4*(NUM_PORT2_CHANNELS(g_model)-8);
|
||||
#else
|
||||
CHECK_INCDEC_MODELVAR(event, g_model.ppmNCH, -2, 4);
|
||||
g_model.ppmFrameLength = g_model.ppmNCH * 8;
|
||||
@@ -1325,7 +1105,7 @@ void menuModelSetup(uint8_t event)
|
||||
case 2:
|
||||
if (IS_PPM_PROTOCOL(protocol)) {
|
||||
CHECK_INCDEC_MODELVAR(event, g_model.ppmNCH, -2, min<int8_t>(4, (32-g_model.ppmSCH)/2-4));
|
||||
g_model.ppmFrameLength = NUM_PORT1_CHANNELS()>NUM_PORT2_CHANNELS() ? 4*(NUM_PORT1_CHANNELS()-8) : 4*(NUM_PORT2_CHANNELS()-8);
|
||||
g_model.ppmFrameLength = NUM_PORT1_CHANNELS(g_model)>NUM_PORT2_CHANNELS(g_model) ? 4*(NUM_PORT1_CHANNELS(g_model)-8) : 4*(NUM_PORT2_CHANNELS(g_model)-8);
|
||||
}
|
||||
else
|
||||
REPEAT_LAST_CURSOR_MOVE();
|
||||
@@ -1347,11 +1127,11 @@ void menuModelSetup(uint8_t event)
|
||||
switch (m_posHorz) {
|
||||
case 0:
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, g_model.ppm2SCH, 32-8-(g_model.ppm2NCH*2));
|
||||
g_model.ppmFrameLength = NUM_PORT1_CHANNELS()>NUM_PORT2_CHANNELS() ? 4*(NUM_PORT1_CHANNELS()-8) : 4*(NUM_PORT2_CHANNELS()-8);
|
||||
g_model.ppmFrameLength = NUM_PORT1_CHANNELS(g_model)>NUM_PORT2_CHANNELS(g_model) ? 4*(NUM_PORT1_CHANNELS(g_model)-8) : 4*(NUM_PORT2_CHANNELS(g_model)-8);
|
||||
break;
|
||||
case 1:
|
||||
CHECK_INCDEC_MODELVAR(event, g_model.ppm2NCH, -2, min<int8_t>(4, (32-g_model.ppm2SCH)/2-4));
|
||||
g_model.ppmFrameLength = NUM_PORT1_CHANNELS()>NUM_PORT2_CHANNELS() ? 4*(NUM_PORT1_CHANNELS()-8) : 4*(NUM_PORT2_CHANNELS()-8);
|
||||
g_model.ppmFrameLength = NUM_PORT1_CHANNELS(g_model)>NUM_PORT2_CHANNELS(g_model) ? 4*(NUM_PORT1_CHANNELS(g_model)-8) : 4*(NUM_PORT2_CHANNELS(g_model)-8);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1360,7 +1140,7 @@ void menuModelSetup(uint8_t event)
|
||||
|
||||
case ITEM_MODEL_PROTOCOL_PARAMS:
|
||||
if (IS_PPM_PROTOCOL(protocol)) {
|
||||
lcd_putsLeft(y, STR_PPMFRAME);
|
||||
lcd_putsLeft( y, STR_PPMFRAME);
|
||||
lcd_puts(MODEL_SETUP_2ND_COLUMN+3*FW, y, STR_MS);
|
||||
lcd_outdezAtt(MODEL_SETUP_2ND_COLUMN, y, (int16_t)g_model.ppmFrameLength*5 + 225, (m_posHorz<=0 ? attr : 0) | PREC1|LEFT);
|
||||
lcd_putc(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, 'u');
|
||||
@@ -1409,7 +1189,7 @@ void menuModelSetup(uint8_t event)
|
||||
s_editMode = 0;
|
||||
if (event==EVT_KEY_LONG(KEY_ENTER)) {
|
||||
// send reset code
|
||||
pxxFlag[0] = PXX_SEND_RXNUM;
|
||||
pxxFlag = PXX_SEND_RXNUM;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1427,13 +1207,6 @@ void menuModelSetup(uint8_t event)
|
||||
#endif // defined(PCBTARANIS)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
if (pxxFlag[0] == PXX_SEND_RANGECHECK || pxxFlag[1] == PXX_SEND_RANGECHECK) {
|
||||
displayPopup("RSSI: ");
|
||||
lcd_outdezAtt(16+4*FW, 5*FH, frskyData.rssi[0].value, BOLD);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static uint8_t s_currIdx;
|
||||
@@ -1476,17 +1249,17 @@ uint8_t editDelay(const uint8_t y, const uint8_t event, const uint8_t attr, cons
|
||||
#define EDIT_DELAY(x, y, event, attr, str, delay) editDelay(y, event, attr, str, delay)
|
||||
#endif
|
||||
|
||||
#if defined(FLIGHT_MODES)
|
||||
#if defined(FLIGHT_PHASES)
|
||||
|
||||
#if defined(CPUARM)
|
||||
#define FlightModesType uint16_t
|
||||
#define PhasesType uint16_t
|
||||
#else
|
||||
#define FlightModesType uint8_t
|
||||
#define PhasesType uint8_t
|
||||
#endif
|
||||
|
||||
FlightModesType editFlightModes(uint8_t x, uint8_t y, uint8_t event, FlightModesType value, uint8_t attr)
|
||||
PhasesType editPhases(uint8_t x, uint8_t y, uint8_t event, PhasesType value, uint8_t attr)
|
||||
{
|
||||
lcd_putsColumnLeft(x, y, STR_FLMODE);
|
||||
lcd_putsColumnLeft(x, y, STR_FPHASE);
|
||||
|
||||
uint8_t posHorz = m_posHorz;
|
||||
|
||||
@@ -1523,7 +1296,7 @@ FlightModesType editFlightModes(uint8_t x, uint8_t y, uint8_t event, FlightModes
|
||||
|
||||
#if LCD_W >= 212
|
||||
|
||||
enum FlightModesItems {
|
||||
enum PhasesItems {
|
||||
ITEM_PHASES_NAME,
|
||||
ITEM_PHASES_SWITCH,
|
||||
ITEM_PHASES_TRIMS,
|
||||
@@ -1593,9 +1366,9 @@ void editPhaseTrims(uint8_t x, uint8_t y, uint8_t phase, uint8_t event, uint8_t
|
||||
}
|
||||
}
|
||||
|
||||
void menuModelFlightModesAll(uint8_t event)
|
||||
void menuModelPhasesAll(uint8_t event)
|
||||
{
|
||||
MENU(STR_MENUFLIGHTPHASES, menuTabModel, e_FlightModesAll, 1+MAX_PHASES+1, {0, NAVIGATION_LINE_BY_LINE|(ITEM_PHASES_LAST-2), NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, 0});
|
||||
MENU(STR_MENUFLIGHTPHASES, menuTabModel, e_PhasesAll, 1+MAX_PHASES+1, {0, NAVIGATION_LINE_BY_LINE|(ITEM_PHASES_LAST-2), NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_PHASES_LAST, 0});
|
||||
|
||||
int8_t sub = m_posVert - 1;
|
||||
|
||||
@@ -1845,9 +1618,9 @@ void menuModelPhaseOne(uint8_t event)
|
||||
#define TRIMS_OFS (FW/2)
|
||||
#endif
|
||||
|
||||
void menuModelFlightModesAll(uint8_t event)
|
||||
void menuModelPhasesAll(uint8_t event)
|
||||
{
|
||||
SIMPLE_MENU(STR_MENUFLIGHTPHASES, menuTabModel, e_FlightModesAll, 1+MAX_PHASES+1);
|
||||
SIMPLE_MENU(STR_MENUFLIGHTPHASES, menuTabModel, e_PhasesAll, 1+MAX_PHASES+1);
|
||||
|
||||
int8_t sub = m_posVert - 1;
|
||||
|
||||
@@ -1917,7 +1690,7 @@ void menuModelFlightModesAll(uint8_t event)
|
||||
|
||||
#endif // defined(PCBTARANIS)
|
||||
|
||||
#endif // defined(FLIGHT_MODES)
|
||||
#endif // defined(FLIGHT_PHASES)
|
||||
|
||||
#if defined(HELI)
|
||||
|
||||
@@ -2376,7 +2149,7 @@ enum ExposFields {
|
||||
EXPO_FIELD_WEIGHT,
|
||||
EXPO_FIELD_EXPO,
|
||||
IF_CURVES(EXPO_FIELD_CURVE)
|
||||
IF_FLIGHT_MODES(EXPO_FIELD_FLIGHT_PHASE)
|
||||
IF_FLIGHT_PHASES(EXPO_FIELD_FLIGHT_PHASE)
|
||||
EXPO_FIELD_SWITCH,
|
||||
EXPO_FIELD_SIDE,
|
||||
EXPO_FIELD_MAX
|
||||
@@ -2387,7 +2160,7 @@ void menuModelExpoOne(uint8_t event)
|
||||
ExpoData *ed = expoaddress(s_currIdx);
|
||||
putsMixerSource(7*FW+FW/2, 0, ed->chn+1, 0);
|
||||
|
||||
SUBMENU(STR_MENUDREXPO, EXPO_FIELD_MAX, {IF_CPUARM(0) 0, 0, IF_CURVES(0) IF_FLIGHT_MODES((MAX_PHASES-1) | NAVIGATION_LINE_BY_LINE) 0 /*, ...*/});
|
||||
SUBMENU(STR_MENUDREXPO, EXPO_FIELD_MAX, {IF_CPUARM(0) 0, 0, IF_CURVES(0) IF_FLIGHT_PHASES((MAX_PHASES-1) | NAVIGATION_LINE_BY_LINE) 0 /*, ...*/});
|
||||
|
||||
int8_t sub = m_posVert;
|
||||
|
||||
@@ -2435,9 +2208,9 @@ void menuModelExpoOne(uint8_t event)
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if defined(FLIGHT_MODES)
|
||||
#if defined(FLIGHT_PHASES)
|
||||
case EXPO_FIELD_FLIGHT_PHASE:
|
||||
ed->phases = editFlightModes(EXPO_ONE_2ND_COLUMN+3*FW-EXPO_ONE_FP_WIDTH, y, event, ed->phases, attr);
|
||||
ed->phases = editPhases(EXPO_ONE_2ND_COLUMN+3*FW-EXPO_ONE_FP_WIDTH, y, event, ed->phases, attr);
|
||||
break;
|
||||
#endif
|
||||
case EXPO_FIELD_SWITCH:
|
||||
@@ -2472,7 +2245,7 @@ enum MixFields {
|
||||
MIX_FIELD_OFFSET,
|
||||
MIX_FIELD_TRIM,
|
||||
IF_CURVES(MIX_FIELD_CURVE)
|
||||
IF_FLIGHT_MODES(MIX_FIELD_FLIGHT_PHASE)
|
||||
IF_FLIGHT_PHASES(MIX_FIELD_FLIGHT_PHASE)
|
||||
MIX_FIELD_SWITCH,
|
||||
MIX_FIELD_WARNING,
|
||||
MIX_FIELD_MLTPX,
|
||||
@@ -2511,11 +2284,11 @@ void menuModelMixOne(uint8_t event)
|
||||
#else
|
||||
if (m_posVert == MIX_FIELD_TRIM && md2->srcRaw > NUM_STICKS)
|
||||
#endif
|
||||
SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_CPUARM(0) 0, 0, 0, 0, IF_CURVES(0) IF_FLIGHT_MODES((MAX_PHASES-1) | NAVIGATION_LINE_BY_LINE) 0, 0 /*, ...*/})
|
||||
SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_CPUARM(0) 0, 0, 0, 0, IF_CURVES(0) IF_FLIGHT_PHASES((MAX_PHASES-1) | NAVIGATION_LINE_BY_LINE) 0, 0 /*, ...*/})
|
||||
else
|
||||
SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_CPUARM(0) 0, 0, 0, 1, IF_CURVES(1) IF_FLIGHT_MODES((MAX_PHASES-1) | NAVIGATION_LINE_BY_LINE) 0, 0 /*, ...*/});
|
||||
SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_CPUARM(0) 0, 0, 0, 1, IF_CURVES(1) IF_FLIGHT_PHASES((MAX_PHASES-1) | NAVIGATION_LINE_BY_LINE) 0, 0 /*, ...*/});
|
||||
#else
|
||||
SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_CPUARM(0) 0, 0, 0, 1, IF_CURVES(1) IF_FLIGHT_MODES((MAX_PHASES-1) | NAVIGATION_LINE_BY_LINE) 0, 0 /*, ...*/});
|
||||
SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_CPUARM(0) 0, 0, 0, 1, IF_CURVES(1) IF_FLIGHT_PHASES((MAX_PHASES-1) | NAVIGATION_LINE_BY_LINE) 0, 0 /*, ...*/});
|
||||
#endif
|
||||
|
||||
#if MENU_COLUMNS > 1
|
||||
@@ -2631,9 +2404,9 @@ void menuModelMixOne(uint8_t event)
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#if defined(FLIGHT_MODES)
|
||||
#if defined(FLIGHT_PHASES)
|
||||
case MIX_FIELD_FLIGHT_PHASE:
|
||||
md2->phases = editFlightModes(COLUMN_X+MIXES_2ND_COLUMN, y, event, md2->phases, attr);
|
||||
md2->phases = editPhases(COLUMN_X+MIXES_2ND_COLUMN, y, event, md2->phases, attr);
|
||||
break;
|
||||
#endif
|
||||
case MIX_FIELD_SWITCH:
|
||||
@@ -3328,24 +3101,15 @@ void menuModelCurvesAll(uint8_t event)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LCD_W >= 212 && defined(GVARS) && defined(FLIGHT_MODES)
|
||||
#if LCD_W >= 212 && defined(GVARS) && defined(FLIGHT_PHASES)
|
||||
void menuModelGVars(uint8_t event)
|
||||
{
|
||||
MENU(STR_MENUGLOBALVARS, menuTabModel, e_GVars, 1+MAX_GVARS, {0, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES});
|
||||
MENU(PSTR("GLOBAL VARIABLES"), menuTabModel, e_GVars, 1+MAX_GVARS, {0, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES});
|
||||
|
||||
uint8_t sub = m_posVert - 1;
|
||||
|
||||
#if MAX_GVARS > 6
|
||||
for (uint8_t l=0; l<LCD_LINES-1; l++) {
|
||||
uint8_t i = l+s_pgOfs;
|
||||
uint8_t y = 1 + FH + l*FH;
|
||||
#elif MAX_GVARS == 6
|
||||
for (uint8_t i=0; i<MAX_GVARS; i++) {
|
||||
uint8_t y = 1 + 2*FH + i*FH;
|
||||
#else
|
||||
for (uint8_t i=0; i<MAX_GVARS; i++) {
|
||||
uint8_t y = 1 + 3*FH + i*FH;
|
||||
#endif
|
||||
|
||||
putsStrIdx(0, y, STR_GV, i+1, (sub==i && m_posHorz<0) ? INVERS : 0);
|
||||
|
||||
@@ -3353,11 +3117,7 @@ void menuModelGVars(uint8_t event)
|
||||
uint8_t attr = ((sub==i && m_posHorz==j) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0);
|
||||
xcoord_t x = 12*FW + FWNUM + (j-1)*(2+3*FWNUM) - 1;
|
||||
|
||||
#if MAX_GVARS == 6
|
||||
if (i==0 && j!=9) putsStrIdx(x+2, FH+1, STR_FP, j, SMLSIZE);
|
||||
#elif MAX_GVARS <= 5
|
||||
if (i==0 && j!=9) putsStrIdx(x+2, 2*FH, STR_FP, j, SMLSIZE);
|
||||
#endif
|
||||
|
||||
switch(j)
|
||||
{
|
||||
@@ -3410,14 +3170,14 @@ enum CustomSwitchFields {
|
||||
#if LCD_W >= 212
|
||||
#define CSW_1ST_COLUMN (4*FW-3)
|
||||
#define CSW_2ND_COLUMN (8*FW+1)
|
||||
#define CSW_3RD_COLUMN (13*FW+2)
|
||||
#define CSW_3RD_COLUMN (16*FW+2)
|
||||
#define CSW_4TH_COLUMN (21*FW+1)
|
||||
#define CSW_5TH_COLUMN (26*FW+1)
|
||||
#define CSW_6TH_COLUMN (31*FW+1)
|
||||
#else
|
||||
#define CSW_1ST_COLUMN (4*FW-3)
|
||||
#define CSW_2ND_COLUMN (8*FW-3)
|
||||
#define CSW_3RD_COLUMN (13*FW-6)
|
||||
#define CSW_3RD_COLUMN (16*FW-6)
|
||||
#define CSW_4TH_COLUMN (18*FW+2)
|
||||
#endif
|
||||
|
||||
@@ -3512,7 +3272,7 @@ void menuModelCustomSwitchOne(uint8_t event)
|
||||
break;
|
||||
}
|
||||
case CSW_FIELD_ANDSW:
|
||||
lcd_putsLeft(y, STR_AND_SWITCH);
|
||||
lcd_putsLeft(y, PSTR("AND Switch"));
|
||||
putsSwitches(CSWONE_2ND_COLUMN, y, cs->andsw, attr);
|
||||
if (attr) CHECK_INCDEC_MODELVAR(event, cs->andsw, -MAX_SWITCH, MAX_SWITCH);
|
||||
break;
|
||||
@@ -3586,11 +3346,15 @@ void menuModelCustomSwitches(uint8_t event)
|
||||
}
|
||||
else {
|
||||
putsMixerSource(CSW_2ND_COLUMN, y, cs->v1, 0);
|
||||
|
||||
#if defined(FRSKY)
|
||||
if (cs->v1 >= MIXSRC_FIRST_TELEM) {
|
||||
putsTelemetryChannel(CSW_3RD_COLUMN, y, cs->v1 - MIXSRC_FIRST_TELEM, convertCswTelemValue(cs), LEFT);
|
||||
putsTelemetryChannel(CSW_3RD_COLUMN, y, cs->v1 - MIXSRC_FIRST_TELEM, convertCswTelemValue(cs), 0);
|
||||
}
|
||||
else {
|
||||
lcd_outdezAtt(CSW_3RD_COLUMN, y, cs->v2, LEFT);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
lcd_outdezAtt(CSW_3RD_COLUMN, y, cs->v2, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3603,15 +3367,6 @@ void menuModelCustomSwitches(uint8_t event)
|
||||
|
||||
void menuModelCustomSwitches(uint8_t event)
|
||||
{
|
||||
#if defined(CPUM64)
|
||||
#define INCDEC_SET_FLAG(f)
|
||||
#define CHECK_INCDEC_CSPARAM(event, var, min, max) CHECK_INCDEC_MODELVAR(event, var, min, max)
|
||||
#else
|
||||
uint8_t incdecFlag;
|
||||
#define INCDEC_SET_FLAG(f) incdecFlag = (EE_MODEL|(f))
|
||||
#define CHECK_INCDEC_CSPARAM(event, var, min, max) var=checkIncDec(event,var,min,max,incdecFlag)
|
||||
#endif
|
||||
|
||||
MENU(STR_MENUCUSTOMSWITCHES, menuTabModel, e_CustomSwitches, NUM_CSW+1, {0, NAVIGATION_LINE_BY_LINE|CSW_FIELD_LAST/*repeated...*/});
|
||||
|
||||
uint8_t y = 0;
|
||||
@@ -3643,25 +3398,20 @@ void menuModelCustomSwitches(uint8_t event)
|
||||
|
||||
if (cstate == CS_VBOOL) {
|
||||
putsSwitches(CSW_2ND_COLUMN, y, cs->v1, m_posHorz==1 ? attr : 0);
|
||||
putsSwitches(CSW_3RD_COLUMN, y, cs->v2, m_posHorz==2 ? attr : 0);
|
||||
putsSwitches(CSW_3RD_COLUMN-3*FW, y, cs->v2, m_posHorz==2 ? attr : 0);
|
||||
v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1;
|
||||
v2_min = SWSRC_OFF+1; v2_max = SWSRC_ON-1;
|
||||
INCDEC_SET_FLAG(INCDEC_SWITCH);
|
||||
}
|
||||
else if (cstate == CS_VCOMP) {
|
||||
putsMixerSource(CSW_2ND_COLUMN, y, cs->v1, m_posHorz==1 ? attr : 0);
|
||||
putsMixerSource(CSW_3RD_COLUMN, y, cs->v2, m_posHorz==2 ? attr : 0);
|
||||
INCDEC_SET_FLAG(INCDEC_SOURCE);
|
||||
putsMixerSource(CSW_3RD_COLUMN-3*FW, y, cs->v2, m_posHorz==2 ? attr : 0);
|
||||
}
|
||||
else {
|
||||
putsMixerSource(CSW_2ND_COLUMN, y, cs->v1, (m_posHorz==1 ? attr : 0));
|
||||
if (m_posHorz == 1)
|
||||
INCDEC_SET_FLAG(INCDEC_SOURCE);
|
||||
else
|
||||
INCDEC_SET_FLAG(0);
|
||||
|
||||
#if defined(FRSKY)
|
||||
if (cs->v1 >= MIXSRC_FIRST_TELEM) {
|
||||
putsTelemetryChannel(CSW_3RD_COLUMN, y, cs->v1 - MIXSRC_FIRST_TELEM, convertCswTelemValue(cs), LEFT | (m_posHorz==2 ? attr : 0));
|
||||
putsTelemetryChannel(CSW_3RD_COLUMN, y, cs->v1 - MIXSRC_FIRST_TELEM, convertCswTelemValue(cs), m_posHorz==2 ? attr : 0);
|
||||
v2_max = maxTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1);
|
||||
if (cstate == CS_VOFS) {
|
||||
v2_min = -128;
|
||||
@@ -3676,20 +3426,12 @@ void menuModelCustomSwitches(uint8_t event)
|
||||
eeDirty(EE_MODEL);
|
||||
}
|
||||
}
|
||||
else {
|
||||
lcd_outdezAtt(CSW_3RD_COLUMN, y, cs->v2, LEFT | (m_posHorz==2 ? attr : 0));
|
||||
v2_min = -125; v2_max = 125;
|
||||
}
|
||||
#else
|
||||
if (cs->v1 >= MIXSRC_FIRST_TELEM) {
|
||||
putsTime(CSW_3RD_COLUMN, y, (int16_t)3 * (CS_STATE(cs->func)==CS_VOFS ? 128+cs->v2 : cs->v2), LEFT | (m_posHorz==2 ? attr : 0), LEFT | (m_posHorz==2 ? attr : 0));
|
||||
v2_min = -128; v2_max = 127;
|
||||
}
|
||||
else {
|
||||
lcd_outdezAtt(CSW_3RD_COLUMN, y, cs->v2, LEFT | (m_posHorz==2 ? attr : 0));
|
||||
v2_min = -125; v2_max = 125;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
lcd_outdezAtt(CSW_3RD_COLUMN, y, cs->v2, m_posHorz==2 ? attr : 0);
|
||||
v2_min = -125; v2_max = 125;
|
||||
}
|
||||
}
|
||||
|
||||
// CSW and switch
|
||||
@@ -3719,14 +3461,14 @@ void menuModelCustomSwitches(uint8_t event)
|
||||
}
|
||||
break;
|
||||
case CSW_FIELD_V1:
|
||||
CHECK_INCDEC_CSPARAM(event, cs->v1, v1_min, v1_max);
|
||||
CHECK_INCDEC_MODELVAR(event, cs->v1, v1_min, v1_max);
|
||||
break;
|
||||
case CSW_FIELD_V2:
|
||||
CHECK_INCDEC_CSPARAM(event, cs->v2, v2_min, v2_max);
|
||||
CHECK_INCDEC_MODELVAR(event, cs->v2, v2_min, v2_max);
|
||||
break;
|
||||
case CSW_FIELD_ANDSW:
|
||||
#if defined(CPUARM)
|
||||
CHECK_INCDEC_MODELSWITCH(event, cs->andsw, -MAX_CSW_ANDSW, MAX_CSW_ANDSW);
|
||||
#if defined(PCBTARANIS)
|
||||
CHECK_INCDEC_MODELVAR(event, cs->andsw, -MAX_CSW_ANDSW, MAX_CSW_ANDSW);
|
||||
#else
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, cs->andsw, MAX_CSW_ANDSW);
|
||||
#endif
|
||||
@@ -3794,7 +3536,7 @@ void menuModelCustomFunctions(uint8_t event)
|
||||
k = i+s_pgOfs;
|
||||
|
||||
#if LCD_W >= 212
|
||||
putsStrIdx(0, y, STR_CF, k+1, (sub==k && m_posHorz<0) ? INVERS : 0);
|
||||
putsStrIdx(0, y, PSTR("CF"), k+1, (sub==k && m_posHorz<0) ? INVERS : 0);
|
||||
#endif
|
||||
|
||||
CustomFnData *sd = &g_model.funcSw[k];
|
||||
@@ -4462,3 +4204,99 @@ void menuModelTemplates(uint8_t event)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
void menuModelFailsafe(uint8_t event)
|
||||
{
|
||||
static bool longNames = false;
|
||||
bool newLongNames = false;
|
||||
uint8_t ch;
|
||||
|
||||
SUBMENU_NOTITLE(32, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0});
|
||||
|
||||
switch(event)
|
||||
{
|
||||
case EVT_KEY_BREAK(KEY_EXIT):
|
||||
popMenu();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_posVert >= 16)
|
||||
ch = 16;
|
||||
else
|
||||
ch = 0;
|
||||
|
||||
lcd_putsCenter(0*FH, FAILSAFESET);
|
||||
lcd_invert_line(0);
|
||||
|
||||
// Column separator
|
||||
lcd_vline(LCD_W/2, FH, LCD_H-FH);
|
||||
|
||||
for (uint8_t col=0; col<2; col++) {
|
||||
|
||||
uint8_t x = col*LCD_W/2+1;
|
||||
|
||||
// Channels
|
||||
for (uint8_t line=0; line<8; line++) {
|
||||
uint8_t y = 9+line*7;
|
||||
int32_t val;
|
||||
uint8_t ofs = (col ? 0 : 1);
|
||||
|
||||
if (ch >= g_model.ppmSCH)
|
||||
if (s_editMode && m_posVert == ch)
|
||||
val = (ch < NUM_PORT1_CHANNELS(g_model) + g_model.ppmSCH ? channelOutputs[ch] : 0);
|
||||
else
|
||||
val = (ch < NUM_PORT1_CHANNELS(g_model) + g_model.ppmSCH ? g_model.failsafeChannels[ch] : 0);
|
||||
else
|
||||
val = 0;
|
||||
|
||||
if (m_posVert == ch && event == EVT_KEY_LONG(KEY_ENTER)) {
|
||||
g_model.failsafeChannels[ch] = val;
|
||||
eeDirty(EE_MODEL);
|
||||
s_editMode = 0;
|
||||
AUDIO_WARNING1();
|
||||
SEND_FAILSAFE_NOW();
|
||||
killEvents(event);
|
||||
}
|
||||
|
||||
// Channel name if present, number if not
|
||||
uint8_t lenLabel = zlen(g_model.limitData[ch].name, sizeof(g_model.limitData[ch].name));
|
||||
if (lenLabel > 4) {
|
||||
newLongNames = longNames = true;
|
||||
}
|
||||
|
||||
if (lenLabel > 0)
|
||||
lcd_putsnAtt(x+1-ofs, y, g_model.limitData[ch].name, sizeof(g_model.limitData[ch].name), ZCHAR | SMLSIZE);
|
||||
else
|
||||
putsChn(x+1-ofs, y, ch+1, SMLSIZE);
|
||||
|
||||
uint8_t wbar = (longNames ? 48 : 58);
|
||||
|
||||
// Value
|
||||
LcdFlags flags = PREC1 | TINSIZE;
|
||||
|
||||
if (m_posVert == ch) {
|
||||
flags |= INVERS;
|
||||
if (s_editMode)
|
||||
flags |= BLINK;
|
||||
}
|
||||
|
||||
lcd_outdezNAtt(x+LCD_W/2-3-wbar-ofs, y+1, calcRESXto1000(val), flags);
|
||||
|
||||
// Gauge
|
||||
lcd_rect(x+LCD_W/2-3-wbar-ofs, y, wbar+1, 6);
|
||||
uint16_t lim = g_model.extendedLimits ? 640*2 : 512*2;
|
||||
uint8_t len = limit((uint8_t)1, uint8_t((abs(val) * wbar/2 + lim/2) / lim), uint8_t(wbar/2));
|
||||
uint8_t x0 = (val>0) ? x+LCD_W/2-ofs-3-wbar/2 : x+LCD_W/2-ofs-2-wbar/2-len;
|
||||
lcd_hline(x0, y+1, len);
|
||||
lcd_hline(x0, y+2, len);
|
||||
lcd_hline(x0, y+3, len);
|
||||
lcd_hline(x0, y+4, len);
|
||||
|
||||
ch++;
|
||||
}
|
||||
}
|
||||
|
||||
longNames = newLongNames;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
+14
-26
@@ -82,10 +82,6 @@ void displayScrollbar(xcoord_t x, uint8_t y, uint8_t h, uint16_t offset, uint16_
|
||||
int16_t p1valdiff;
|
||||
#endif
|
||||
|
||||
#if defined(NAVIGATION_POT2)
|
||||
int8_t p2valdiff;
|
||||
#endif
|
||||
|
||||
int8_t checkIncDec_Ret;
|
||||
int16_t checkIncDec(uint8_t event, int16_t val, int16_t i_min, int16_t i_max, uint8_t i_flags)
|
||||
{
|
||||
@@ -300,8 +296,10 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
|
||||
#ifdef NAVIGATION_POT2
|
||||
// check pot 2 - if changed -> scroll menu
|
||||
static int16_t p2valprev;
|
||||
p2valdiff = (p2valprev-calibratedStick[4]) / SCROLL_TH;
|
||||
if (p2valdiff) p2valprev = calibratedStick[4];
|
||||
int8_t scrollLR = (p2valprev-calibratedStick[4]) / SCROLL_TH;
|
||||
if (scrollLR) p2valprev = calibratedStick[4];
|
||||
#else
|
||||
#define scrollLR 0
|
||||
#endif
|
||||
|
||||
#ifdef NAVIGATION_POT3
|
||||
@@ -313,7 +311,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
|
||||
#define scrollUD 0
|
||||
#endif
|
||||
|
||||
if (p2valdiff || scrollUD || p1valdiff) backlightOn(); // on keypress turn the light on
|
||||
if (scrollLR || scrollUD || p1valdiff) backlightOn(); // on keypress turn the light on
|
||||
|
||||
if (menuTab) {
|
||||
uint8_t attr = 0;
|
||||
@@ -347,8 +345,8 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
|
||||
|
||||
int8_t cc = curr;
|
||||
|
||||
if (p2valdiff) {
|
||||
cc = limit((int8_t)0, (int8_t)(cc - p2valdiff), (int8_t)(menuTabSize-1));
|
||||
if (scrollLR) {
|
||||
cc = limit((int8_t)0, (int8_t)(cc - scrollLR), (int8_t)(menuTabSize-1));
|
||||
}
|
||||
|
||||
switch(event) {
|
||||
@@ -424,8 +422,8 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
|
||||
l_posHorz = min((uint8_t)l_posHorz, MAXCOL(l_posVert));
|
||||
}
|
||||
|
||||
if (p2valdiff && l_posVert>0) {
|
||||
l_posHorz = limit((int8_t)0, (int8_t)((uint8_t)l_posHorz - p2valdiff), (int8_t)maxcol);
|
||||
if (scrollLR && l_posVert>0) {
|
||||
l_posHorz = limit((int8_t)0, (int8_t)((uint8_t)l_posHorz - scrollLR), (int8_t)maxcol);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -893,7 +891,7 @@ const char * displayMenu(uint8_t event)
|
||||
const char * result = NULL;
|
||||
|
||||
uint8_t display_count = min(s_menu_count, (uint16_t)MENU_MAX_LINES);
|
||||
uint8_t y = (display_count >= 5 ? MENU_Y - FH : MENU_Y);
|
||||
uint8_t y = display_count > 4 ? MENU_Y - FH : MENU_Y;
|
||||
lcd_filled_rect(MENU_X, y, MENU_W, display_count * (FH+1) + 2, SOLID, ERASE);
|
||||
lcd_rect(MENU_X, y, MENU_W, display_count * (FH+1) + 2);
|
||||
|
||||
@@ -910,39 +908,29 @@ const char * displayMenu(uint8_t event)
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
CASE_EVT_ROTARY_LEFT
|
||||
#endif
|
||||
case EVT_KEY_FIRST(KEY_MOVE_UP):
|
||||
case EVT_KEY_REPT(KEY_MOVE_UP):
|
||||
if (s_menu_item > 0) {
|
||||
case EVT_KEY_BREAK(KEY_MOVE_UP):
|
||||
if (s_menu_item > 0)
|
||||
s_menu_item--;
|
||||
}
|
||||
#if defined(SDCARD)
|
||||
else if (s_menu_offset > 0) {
|
||||
s_menu_offset--;
|
||||
result = STR_UPDATE_LIST;
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
s_menu_item = display_count - 1;
|
||||
}
|
||||
break;
|
||||
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
CASE_EVT_ROTARY_RIGHT
|
||||
#endif
|
||||
case EVT_KEY_FIRST(KEY_MOVE_DOWN):
|
||||
case EVT_KEY_REPT(KEY_MOVE_DOWN):
|
||||
if (s_menu_item < display_count - 1 && s_menu_offset + s_menu_item + 1 < s_menu_count) {
|
||||
case EVT_KEY_BREAK(KEY_MOVE_DOWN):
|
||||
if (s_menu_item < display_count - 1 && s_menu_offset + s_menu_item + 1 < s_menu_count)
|
||||
s_menu_item++;
|
||||
}
|
||||
#if defined(SDCARD)
|
||||
else if (s_menu_count > s_menu_offset + display_count) {
|
||||
s_menu_offset++;
|
||||
result = STR_UPDATE_LIST;
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
s_menu_item = 0;
|
||||
}
|
||||
break;
|
||||
CASE_EVT_ROTARY_BREAK
|
||||
case EVT_KEY_BREAK(KEY_ENTER):
|
||||
|
||||
+5
-6
@@ -133,12 +133,6 @@ void menuStatisticsDebug(uint8_t event);
|
||||
#define p1valdiff 0
|
||||
#endif
|
||||
|
||||
#if defined(NAVIGATION_POT2)
|
||||
extern int8_t p2valdiff;
|
||||
#else
|
||||
#define p2valdiff 0
|
||||
#endif
|
||||
|
||||
extern int8_t checkIncDec_Ret; // global helper vars
|
||||
|
||||
#define EDIT_SELECT_MENU -1
|
||||
@@ -275,6 +269,11 @@ void displayWarning(uint8_t event);
|
||||
#else
|
||||
#define MENU_ADD_SD_ITEM(s)
|
||||
#endif
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
#define MENU_ADD_NAVIGATION_ITEM(s) MENU_ADD_ITEM(s)
|
||||
#else
|
||||
#define MENU_ADD_NAVIGATION_ITEM(s)
|
||||
#endif
|
||||
#define MENU_LINE_LENGTH (LEN_MODEL_NAME+1)
|
||||
extern const char *s_menu[MENU_MAX_LINES];
|
||||
extern uint16_t s_menu_count;
|
||||
|
||||
+66
-91
@@ -67,68 +67,15 @@
|
||||
#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__))
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
#define MAX_MODELS 60
|
||||
#define NUM_CHNOUT 32 // number of real output channels CH1-CH32
|
||||
#define MAX_PHASES 9
|
||||
#define MAX_MIXERS 64
|
||||
#define MAX_EXPOS 32
|
||||
#define NUM_CSW 32 // number of custom switches
|
||||
#define NUM_CFN 32 // number of functions assigned to switches
|
||||
#elif defined(PCBGRUVIN9X)
|
||||
#define MAX_MODELS 30
|
||||
#define NUM_CHNOUT 16 // number of real output channels CH1-CH16
|
||||
#define MAX_PHASES 6
|
||||
#define MAX_MIXERS 32
|
||||
#define MAX_EXPOS 16
|
||||
#define NUM_CSW 15 // number of custom switches
|
||||
#define NUM_CFN 24 // number of functions assigned to switches
|
||||
#elif defined(CPUM128)
|
||||
#define MAX_MODELS 30
|
||||
#define NUM_CHNOUT 16 // number of real output channels CH1-CH16
|
||||
#define MAX_PHASES 5
|
||||
#define MAX_MIXERS 32
|
||||
#define MAX_EXPOS 14
|
||||
#define NUM_CSW 15 // number of custom switches
|
||||
#define NUM_CFN 24 // number of functions assigned to switches
|
||||
#else
|
||||
#define MAX_MODELS 16
|
||||
#define NUM_CHNOUT 16 // number of real output channels CH1-CH16
|
||||
#define MAX_PHASES 5
|
||||
#define MAX_MIXERS 32
|
||||
#define MAX_EXPOS 14
|
||||
#define NUM_CSW 12 // number of custom switches
|
||||
#define NUM_CFN 16 // number of functions assigned to switches
|
||||
#endif
|
||||
|
||||
#define MAX_TIMERS 2
|
||||
|
||||
#if defined(CPUARM)
|
||||
#define MAX_CURVES 16
|
||||
#define NUM_POINTS 512
|
||||
#define CURVTYPE int16_t
|
||||
#else
|
||||
#define MAX_CURVES 8
|
||||
#define NUM_POINTS (112-MAX_CURVES)
|
||||
#define CURVTYPE int8_t
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
#define NUM_MODULES 2
|
||||
#else
|
||||
#define NUM_MODULES 1
|
||||
#endif
|
||||
|
||||
typedef int16_t gvar_t;
|
||||
|
||||
#if !defined(PCBSTD)
|
||||
typedef char gvar_name_t[6];
|
||||
#define GVAR_MAX 1024
|
||||
typedef char gvar_name_t[6];
|
||||
#define GVAR_MAX 1024
|
||||
#endif
|
||||
|
||||
#define RESERVE_RANGE_FOR_GVARS 10
|
||||
// even we do not spend space in EEPROM for 10 GVARS, we reserve the space inside the range of values, like offset, weight, etc.
|
||||
|
||||
#if defined(PCBSTD) && defined(GVARS)
|
||||
#define MAX_GVARS 5
|
||||
#define MODEL_GVARS_DATA gvar_t gvars[MAX_GVARS];
|
||||
@@ -206,20 +153,12 @@ enum BeeperMode {
|
||||
#define EXTRA_GENERAL_FIELDS
|
||||
#endif
|
||||
|
||||
PACK(typedef struct t_ModuleData {
|
||||
int8_t rfProtocol;
|
||||
uint8_t channelsStart;
|
||||
int8_t channelsCount; // 0=8 channels
|
||||
uint8_t failsafeMode;
|
||||
int16_t failsafeChannels[NUM_CHNOUT];
|
||||
}) ModuleData;
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
#define MODELDATA_EXTRA char bitmap[10]; uint8_t externalModule; ModuleData moduleData[NUM_MODULES]; uint8_t trainerMode;
|
||||
#define MODELDATA_EXTRA char bitmap[10]; int8_t rfProtocol; uint8_t ppmSCH; uint8_t failsafeMode; int16_t failsafeChannels[16];
|
||||
#define LIMITDATA_EXTRA char name[6];
|
||||
#define swstate_t uint16_t
|
||||
#elif defined(PCBSKY9X)
|
||||
#define MODELDATA_EXTRA uint8_t ppmSCH; int8_t ppm2SCH; int8_t ppm2NCH; ModuleData moduleData[NUM_MODULES];
|
||||
#define MODELDATA_EXTRA uint8_t ppmSCH; int8_t ppm2SCH; int8_t ppm2NCH; int8_t rfProtocol;
|
||||
#define LIMITDATA_EXTRA
|
||||
#define swstate_t uint8_t
|
||||
#else
|
||||
@@ -256,28 +195,28 @@ PACK(typedef struct t_EEGeneral {
|
||||
int8_t vBatCalib;
|
||||
int8_t backlightMode;
|
||||
TrainerData trainer;
|
||||
uint8_t view; // index of view in main screen
|
||||
int8_t buzzerMode:2; // -2=quiet, -1=only alarms, 0=no keys, 1=all
|
||||
uint8_t spare1:1;
|
||||
int8_t beepMode:2; // -2=quiet, -1=only alarms, 0=no keys, 1=all
|
||||
uint8_t view; //index of subview in main scrren
|
||||
uint8_t spare1:3;
|
||||
int8_t beeperMode:2;
|
||||
uint8_t alarmsFlash:1;
|
||||
uint8_t disableMemoryWarning:1;
|
||||
uint8_t disableAlarmWarning:1;
|
||||
uint8_t stickMode:2;
|
||||
int8_t timezone:5;
|
||||
uint8_t spare2:1;
|
||||
uint8_t alarmsBeep:1;
|
||||
uint8_t inactivityTimer;
|
||||
uint8_t spare3:3;
|
||||
uint8_t throttleReversed:1;
|
||||
uint8_t spare2:2;
|
||||
SPLASH_MODE; /* 3bits */
|
||||
int8_t hapticMode:2; // -2=quiet, -1=only alarms, 0=no keys, 1=all
|
||||
uint8_t blOffBright:4;
|
||||
uint8_t blOnBright:4;
|
||||
uint8_t lightAutoOff;
|
||||
uint8_t templateSetup; // RETA order for receiver channels
|
||||
uint8_t templateSetup; //RETA order according to chout_ar array
|
||||
int8_t PPM_Multiplier;
|
||||
int8_t hapticLength;
|
||||
uint8_t reNavigation; // not used on STOCK board
|
||||
int8_t beepLength:3;
|
||||
uint8_t reNavigation; // not used on STOCK board
|
||||
int8_t beeperLength:3;
|
||||
uint8_t hapticStrength:3;
|
||||
uint8_t gpsFormat:1;
|
||||
uint8_t unexpectedShutdown:1;
|
||||
@@ -349,6 +288,7 @@ PACK(typedef struct t_LimitData {
|
||||
|
||||
}) LimitData;
|
||||
|
||||
|
||||
#define TRIM_OFF (1)
|
||||
#define TRIM_ON (0)
|
||||
#define TRIM_RUD (-1)
|
||||
@@ -885,16 +825,14 @@ PACK(typedef struct t_SwashRingData { // Swash Ring data
|
||||
#endif
|
||||
|
||||
#if defined(PCBSTD)
|
||||
#define TRIMS_ARRAY int8_t trim[4]; int8_t trim_ext:8
|
||||
#define TRIMS_ARRAY_SIZE 5
|
||||
#define TRIM_ARRAY int8_t trim[4]; int8_t trim_ext:8
|
||||
#else
|
||||
#define TRIMS_ARRAY int16_t trim[4]
|
||||
#define TRIMS_ARRAY_SIZE 8
|
||||
#define TRIM_ARRAY int16_t trim[4]
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
PACK(typedef struct t_PhaseData {
|
||||
TRIMS_ARRAY;
|
||||
TRIM_ARRAY;
|
||||
int8_t swtch; // swtch of phase[0] is not used
|
||||
char name[LEN_FP_NAME];
|
||||
uint8_t fadeIn;
|
||||
@@ -904,7 +842,7 @@ PACK(typedef struct t_PhaseData {
|
||||
}) PhaseData;
|
||||
#else
|
||||
PACK(typedef struct t_PhaseData {
|
||||
TRIMS_ARRAY;
|
||||
TRIM_ARRAY;
|
||||
int8_t swtch; // swtch of phase[0] is not used
|
||||
char name[LEN_FP_NAME];
|
||||
uint8_t fadeIn:4;
|
||||
@@ -914,6 +852,52 @@ PACK(typedef struct t_PhaseData {
|
||||
}) PhaseData;
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
#define MAX_MODELS 60
|
||||
#define NUM_CHNOUT 32 // number of real output channels CH1-CH32
|
||||
#define MAX_PHASES 9
|
||||
#define MAX_MIXERS 64
|
||||
#define MAX_EXPOS 32
|
||||
#define NUM_CSW 32 // number of custom switches
|
||||
#define NUM_CFN 32 // number of functions assigned to switches
|
||||
#elif defined(PCBGRUVIN9X)
|
||||
#define MAX_MODELS 30
|
||||
#define NUM_CHNOUT 16 // number of real output channels CH1-CH16
|
||||
#define MAX_PHASES 6
|
||||
#define MAX_MIXERS 32
|
||||
#define MAX_EXPOS 16
|
||||
#define NUM_CSW 15 // number of custom switches
|
||||
#define NUM_CFN 24 // number of functions assigned to switches
|
||||
#elif defined(CPUM128)
|
||||
#define MAX_MODELS 30
|
||||
#define NUM_CHNOUT 16 // number of real output channels CH1-CH16
|
||||
#define MAX_PHASES 5
|
||||
#define MAX_MIXERS 32
|
||||
#define MAX_EXPOS 14
|
||||
#define NUM_CSW 15 // number of custom switches
|
||||
#define NUM_CFN 24 // number of functions assigned to switches
|
||||
#else
|
||||
#define MAX_MODELS 16
|
||||
#define NUM_CHNOUT 16 // number of real output channels CH1-CH16
|
||||
#define MAX_PHASES 5
|
||||
#define MAX_MIXERS 32
|
||||
#define MAX_EXPOS 14
|
||||
#define NUM_CSW 12 // number of custom switches
|
||||
#define NUM_CFN 16 // number of functions assigned to switches
|
||||
#endif
|
||||
|
||||
#define MAX_TIMERS 2
|
||||
|
||||
#if defined(CPUARM)
|
||||
#define MAX_CURVES 16
|
||||
#define NUM_POINTS 512
|
||||
#define CURVTYPE int16_t
|
||||
#else
|
||||
#define MAX_CURVES 8
|
||||
#define NUM_POINTS (112-MAX_CURVES)
|
||||
#define CURVTYPE int8_t
|
||||
#endif
|
||||
|
||||
enum SwitchSources {
|
||||
SWSRC_NONE = 0,
|
||||
|
||||
@@ -1150,7 +1134,7 @@ enum Protocols {
|
||||
PROTO_NONE
|
||||
};
|
||||
|
||||
enum RFProtocols {
|
||||
enum RfProtocols {
|
||||
RF_PROTO_OFF = -1,
|
||||
RF_PROTO_X16,
|
||||
RF_PROTO_D8,
|
||||
@@ -1158,15 +1142,6 @@ enum RFProtocols {
|
||||
RF_PROTO_LAST = RF_PROTO_LR12
|
||||
};
|
||||
|
||||
enum ModuleTypes {
|
||||
MODULE_TYPE_NONE = 0,
|
||||
MODULE_TYPE_PPM,
|
||||
MODULE_TYPE_XJT,
|
||||
MODULE_TYPE_DJT,
|
||||
MODULE_TYPE_DSM2,
|
||||
MODULE_TYPE_LAST = MODULE_TYPE_DJT
|
||||
};
|
||||
|
||||
enum FailsafeModes {
|
||||
FAILSAFE_HOLD,
|
||||
FAILSAFE_CUSTOM,
|
||||
@@ -1200,7 +1175,7 @@ PACK(typedef struct t_ModelData {
|
||||
uint8_t pulsePol:1;
|
||||
uint8_t extendedLimits:1;
|
||||
uint8_t extendedTrims:1;
|
||||
uint8_t throttleReversed:1;
|
||||
uint8_t spare1:1;
|
||||
int8_t ppmDelay;
|
||||
BeepANACenter beepANACenter; // 1<<0->A1.. 1<<6->A7
|
||||
MixData mixData[MAX_MIXERS];
|
||||
|
||||
+11
-18
@@ -234,7 +234,6 @@ void per10ms()
|
||||
#endif
|
||||
|
||||
if (lightOffCounter) lightOffCounter--;
|
||||
if (flashCounter) flashCounter--;
|
||||
if (s_noHi) s_noHi--;
|
||||
if (trimsCheckTimer) trimsCheckTimer --;
|
||||
|
||||
@@ -920,7 +919,7 @@ getvalue_t getValue(uint8_t i)
|
||||
else if (i<MIXSRC_FIRST_TELEM-1+TELEM_VSPD) return frskyData.hub.varioSpeed;
|
||||
else if (i<MIXSRC_FIRST_TELEM-1+TELEM_MIN_A1) return frskyData.analog[0].min;
|
||||
else if (i<MIXSRC_FIRST_TELEM-1+TELEM_MIN_A2) return frskyData.analog[1].min;
|
||||
else if (i<MIXSRC_FIRST_TELEM-1+TELEM_MAX_CURRENT) return *(((int16_t*)(&frskyData.hub.minAltitude))+i+1-(MIXSRC_FIRST_TELEM-1+TELEM_MIN_ALT));
|
||||
else if (i<MIXSRC_FIRST_TELEM-1+TELEM_MAX_CURRENT) return *(((int16_t*)(&frskyData.hub.minAltitude))+i+1-(MIXSRC_FIRST_TELEM-1+TELEM_MAX_CURRENT));
|
||||
#endif
|
||||
#endif
|
||||
else return 0;
|
||||
@@ -1017,7 +1016,7 @@ bool __getSwitch(int8_t swtch)
|
||||
#if defined(FRSKY)
|
||||
// Telemetry
|
||||
if (cs->v1 >= MIXSRC_FIRST_TELEM) {
|
||||
if (frskyStreaming <= 0 && cs->v1 > MIXSRC_FIRST_TELEM-1+TELEM_TM2)
|
||||
if (frskyStreaming <= 0 && cs->v1 > MIXSRC_FIRST_TELEM-1+MAX_TIMERS)
|
||||
return swtch > 0 ? false : true;
|
||||
|
||||
y = convertCswTelemValue(cs);
|
||||
@@ -1039,11 +1038,8 @@ bool __getSwitch(int8_t swtch)
|
||||
y = calc100toRESX(cs->v2);
|
||||
}
|
||||
#else
|
||||
if (cs->v1 >= MIXSRC_FIRST_TELEM) {
|
||||
y = (int16_t)3 * cs->v2; // it's a Timer
|
||||
}
|
||||
else if (cs->v1 >= MIXSRC_GVAR1) {
|
||||
y = cs->v2; // it's a GVAR
|
||||
if (cs->v1 >= MIXSRC_GVAR1) {
|
||||
y = cs->v2; // it's a GVAR or a Timer
|
||||
}
|
||||
else {
|
||||
y = calc100toRESX(cs->v2);
|
||||
@@ -1215,7 +1211,7 @@ int8_t getMovedSource()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FLIGHT_MODES)
|
||||
#ifdef FLIGHT_PHASES
|
||||
uint8_t getFlightPhase()
|
||||
{
|
||||
for (uint8_t i=1; i<MAX_PHASES; i++) {
|
||||
@@ -1460,9 +1456,7 @@ void checkBacklight()
|
||||
backlightOn();
|
||||
}
|
||||
|
||||
bool backlightOn = (g_eeGeneral.backlightMode == e_backlight_mode_on || lightOffCounter || isFunctionActive(FUNC_BACKLIGHT));
|
||||
if (flashCounter) backlightOn = !backlightOn;
|
||||
if (backlightOn)
|
||||
if (g_eeGeneral.backlightMode == e_backlight_mode_on || lightOffCounter || isFunctionActive(FUNC_BACKLIGHT))
|
||||
BACKLIGHT_ON();
|
||||
else
|
||||
BACKLIGHT_OFF();
|
||||
@@ -1584,7 +1578,7 @@ void checkTHR()
|
||||
#else
|
||||
getADC(); // if thr is down - do not display warning at all
|
||||
int16_t lowLim = g_eeGeneral.calibMid[thrchn];
|
||||
lowLim = (g_model.throttleReversed ? - lowLim - g_eeGeneral.calibSpanPos[thrchn] : lowLim - g_eeGeneral.calibSpanNeg[thrchn]);
|
||||
lowLim = (g_eeGeneral.throttleReversed ? - lowLim - g_eeGeneral.calibSpanPos[thrchn] : lowLim - g_eeGeneral.calibSpanNeg[thrchn]);
|
||||
lowLim += THRCHK_DEADBAND;
|
||||
#endif
|
||||
int16_t v = thrAnaIn(thrchn);
|
||||
@@ -1868,7 +1862,7 @@ uint16_t BandGap ;
|
||||
int16_t thrAnaIn(uint8_t chan)
|
||||
{
|
||||
int16_t v = anaIn(chan);
|
||||
return (g_model.throttleReversed) ? -v : v;
|
||||
return (g_eeGeneral.throttleReversed) ? -v : v;
|
||||
}
|
||||
|
||||
#if !defined(SIMU)
|
||||
@@ -1980,7 +1974,6 @@ void getADC_bandgap()
|
||||
|
||||
uint8_t g_vbat100mV = 0;
|
||||
uint16_t lightOffCounter;
|
||||
uint8_t flashCounter = 0;
|
||||
|
||||
uint16_t s_timeCumTot;
|
||||
uint16_t s_timeCumThr; // THR in 1/16 sec
|
||||
@@ -2072,7 +2065,7 @@ FORCEINLINE void evalTrims()
|
||||
// do trim -> throttle trim if applicable
|
||||
int16_t trim = getTrimValue(phase, i);
|
||||
if (i==THR_STICK && g_model.thrTrim) {
|
||||
if (g_model.throttleReversed)
|
||||
if (g_eeGeneral.throttleReversed)
|
||||
trim = -trim;
|
||||
int16_t v = anas[i];
|
||||
int32_t vv = ((int32_t)trim-TRIM_MIN)*(RESX-v)>>(RESX_SHIFT+1);
|
||||
@@ -2130,7 +2123,7 @@ BeepANACenter evalSticks(uint8_t mode)
|
||||
v = -v;
|
||||
#endif
|
||||
|
||||
if (g_model.throttleReversed && ch==THR_STICK)
|
||||
if (g_eeGeneral.throttleReversed && ch==THR_STICK)
|
||||
v = -v;
|
||||
|
||||
#if defined(EXTRA_3POS)
|
||||
@@ -3667,7 +3660,7 @@ ISR(TIMER_10MS_VECT, ISR_NOBLOCK)
|
||||
AUDIO_HEARTBEAT();
|
||||
#endif
|
||||
|
||||
#if defined(BUZZER)
|
||||
#if defined(BEEPER)
|
||||
BUZZER_HEARTBEAT();
|
||||
#endif
|
||||
|
||||
|
||||
+20
-25
@@ -86,10 +86,10 @@
|
||||
#define IF_RTCLOCK(x)
|
||||
#endif
|
||||
|
||||
#if defined(BUZZER)
|
||||
#define IF_BUZZER(x) x,
|
||||
#if defined(BEEPER)
|
||||
#define IF_BEEPER(x) x,
|
||||
#else
|
||||
#define IF_BUZZER(x)
|
||||
#define IF_BEEPER(x)
|
||||
#endif
|
||||
|
||||
#if defined(AUDIO)
|
||||
@@ -164,10 +164,10 @@
|
||||
#define IF_TEMPLATES(x)
|
||||
#endif
|
||||
|
||||
#if defined(FLIGHT_MODES)
|
||||
#define IF_FLIGHT_MODES(x) x,
|
||||
#if defined(FLIGHT_PHASES)
|
||||
#define IF_FLIGHT_PHASES(x) x,
|
||||
#else
|
||||
#define IF_FLIGHT_MODES(x)
|
||||
#define IF_FLIGHT_PHASES(x)
|
||||
#endif
|
||||
|
||||
#if defined(CURVES)
|
||||
@@ -457,17 +457,13 @@ enum EnumKeys {
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
static const int8_t maxChannelsModules[] = { 0, 8, 8, 0, 0 };
|
||||
static const int8_t maxChannelsXJT[] = { 0, 8, 0, 4 };
|
||||
#define IS_MODULE_XJT(idx) ((idx==0 || g_model.externalModule == MODULE_TYPE_XJT) && (g_model.moduleData[idx].rfProtocol != RF_PROTO_OFF))
|
||||
#define IS_MODULE_PPM(idx) (idx==1 && g_model.externalModule == MODULE_TYPE_PPM)
|
||||
#define NUM_CHANNELS(idx) (8+g_model.moduleData[idx].channelsCount)
|
||||
#define MAX_PORT1_CHANNELS() (maxChannelsXJT[1+g_model.moduleData[0].rfProtocol])
|
||||
#define MAX_PORT2_CHANNELS() ((g_model.externalModule == MODULE_TYPE_XJT) ? maxChannelsXJT[1+g_model.moduleData[1].rfProtocol] : maxChannelsModules[g_model.externalModule])
|
||||
#define MAX_CHANNELS(idx) (idx==0 ? MAX_PORT1_CHANNELS() : MAX_PORT2_CHANNELS())
|
||||
#define NUM_PORT1_CHANNELS(model) ((8+(model.ppmNCH*2)))
|
||||
#else
|
||||
#define NUM_PORT1_CHANNELS() (IS_PXX_PROTOCOL(g_model.protocol) ? 8 : (IS_DSM2_PROTOCOL(g_model.protocol) ? 6 : (8+(g_model.ppmNCH*2))))
|
||||
#define NUM_PORT2_CHANNELS() (8+(g_model.ppm2NCH*2))
|
||||
#define NUM_PORT1_CHANNELS(model) (IS_PXX_PROTOCOL(model.protocol) ? 8 : (IS_DSM2_PROTOCOL(model.protocol) ? 6 : (8+(model.ppmNCH*2))))
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#define NUM_PORT2_CHANNELS(model) (8+(model.ppm2NCH*2))
|
||||
#endif
|
||||
|
||||
#include "lcd.h"
|
||||
@@ -670,7 +666,7 @@ extern uint16_t inacCounter;
|
||||
extern uint16_t inacSum;
|
||||
|
||||
#if defined(PXX)
|
||||
extern uint8_t pxxFlag[NUM_MODULES];
|
||||
extern uint8_t pxxFlag;
|
||||
#endif
|
||||
|
||||
#define PXX_SEND_RXNUM 0x01
|
||||
@@ -751,7 +747,7 @@ int8_t getMovedSwitch();
|
||||
int8_t getMovedSource();
|
||||
#endif
|
||||
|
||||
#if defined(FLIGHT_MODES)
|
||||
#ifdef FLIGHT_PHASES
|
||||
extern uint8_t getFlightPhase();
|
||||
#else
|
||||
#define getFlightPhase() 0
|
||||
@@ -1066,11 +1062,10 @@ extern uint16_t anaIn(uint8_t chan);
|
||||
extern int16_t thrAnaIn(uint8_t chan);
|
||||
extern int16_t calibratedStick[NUM_STICKS+NUM_POTS];
|
||||
|
||||
#define FLASH_DURATION 20 /*200ms*/
|
||||
#define FLASH_DURATION 50 /*500ms*/
|
||||
|
||||
extern uint8_t beepAgain;
|
||||
extern uint16_t lightOffCounter;
|
||||
extern uint8_t flashCounter;
|
||||
extern uint8_t mixWarning;
|
||||
|
||||
extern PhaseData *phaseaddress(uint8_t idx);
|
||||
@@ -1239,8 +1234,8 @@ enum AUDIO_SOUNDS {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BUZZER)
|
||||
#include "buzzer.h"
|
||||
#if defined(BEEPER)
|
||||
#include "beeper.h"
|
||||
#endif
|
||||
|
||||
#if defined(PCBSTD) && defined(VOICE)
|
||||
@@ -1381,10 +1376,10 @@ void getGpsPilotPosition();
|
||||
void getGpsDistance();
|
||||
void varioWakeup();
|
||||
|
||||
#if defined(AUDIO) && defined(BUZZER)
|
||||
#define IS_SOUND_OFF() (g_eeGeneral.buzzerMode==e_mode_quiet && g_eeGeneral.beepMode==e_mode_quiet)
|
||||
#if defined(AUDIO) && defined(BEEPER)
|
||||
#define IS_SOUND_OFF() (!g_eeGeneral.alarmsBeep && g_eeGeneral.beeperMode == e_mode_quiet)
|
||||
#else
|
||||
#define IS_SOUND_OFF() (g_eeGeneral.beepMode == e_mode_quiet)
|
||||
#define IS_SOUND_OFF() (g_eeGeneral.beeperMode == e_mode_quiet)
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
|
||||
+46
-206
@@ -39,7 +39,7 @@
|
||||
uint8_t s_pulses_paused = 0;
|
||||
uint8_t s_current_protocol = 255;
|
||||
uint32_t failsafeCounter = 100;
|
||||
uint8_t pxxFlag[NUM_MODULES] = { 0 };
|
||||
uint8_t pxxFlag = 0;
|
||||
|
||||
uint16_t ppmStream[20] = { 2000, 2200, 2400, 2600, 2800, 3000, 3200, 3400, 9000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } ;
|
||||
uint16_t ppm2Stream[20] = { 2000, 2200, 2400, 2600, 2800, 3000, 3200, 3400, 9000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } ;
|
||||
@@ -51,14 +51,8 @@ uint8_t Bit_pulses[64] ; // Likely more than we need
|
||||
uint8_t *Pulses2MHzptr ;
|
||||
#else
|
||||
uint16_t pxxStream[400] ; // Transisitions
|
||||
#if defined(PCBTARANIS)
|
||||
uint16_t pxx2Stream[400] ; // Transisitions
|
||||
uint16_t *pxxStreamPtr[NUM_MODULES] ;
|
||||
uint16_t PxxValue[NUM_MODULES] ;
|
||||
#else
|
||||
uint16_t *pxxStreamPtr ;
|
||||
uint16_t PxxValue ;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// DSM2 control bits
|
||||
@@ -73,14 +67,7 @@ uint8_t Serial_byte ;
|
||||
uint8_t Serial_bit_count;
|
||||
uint8_t Serial_byte_count ;
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
#define MODULE_INDEX_PARAM uint32_t module_index
|
||||
#else
|
||||
#define MODULE_INDEX_PARAM
|
||||
#endif
|
||||
|
||||
void setupPulses( MODULE_INDEX_PARAM ) ;
|
||||
|
||||
void setupPulses();
|
||||
void setupPulsesDsm2(uint8_t chns);
|
||||
void setupPulsesPXX();
|
||||
|
||||
@@ -90,11 +77,7 @@ void startPulses()
|
||||
#if defined(PCBSKY9X)
|
||||
init_main_ppm(3000, 1) ; // Default for now, initial period 1.5 mS, output on
|
||||
#else
|
||||
#if defined(PCBTARANIS)
|
||||
init_ppm( 0 ) ;
|
||||
#else
|
||||
init_main_ppm();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -130,11 +113,11 @@ void setupPulsesPPM(PPM_PORT_PARAM) // Don't enable interrupts
|
||||
pwmCh = 1;
|
||||
ptr = ppm2Stream;
|
||||
firstCh = g_model.ppm2SCH;
|
||||
lastCh = min<uint32_t>(NUM_CHNOUT, firstCh + NUM_PORT2_CHANNELS());
|
||||
lastCh = min<uint32_t>(NUM_CHNOUT, firstCh + 8 + (g_model.ppm2NCH * 2));
|
||||
}
|
||||
#else
|
||||
#define firstCh 0
|
||||
uint32_t lastCh = NUM_CHANNELS(0);
|
||||
uint32_t lastCh = 8 + g_model.ppmNCH * 2; //Channels *2
|
||||
uint16_t * ptr = ppmStream;
|
||||
#endif
|
||||
|
||||
@@ -158,13 +141,8 @@ void setupPulsesPPM(PPM_PORT_PARAM) // Don't enable interrupts
|
||||
*(ptr + 1) = 0;
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
// THIS IS SPECIFIC TO EITHER THE INTERNAL OR EXTERNAL MODULE
|
||||
// OTHER IS COMMENTED OUT. IF PPM IS NEEDED ON INTERNAL AS WELL AS EXTARNAL
|
||||
// setupPulsesPPM() WILL NEED A "MODULE" PARAMETER
|
||||
TIM8->CCR2 = rest - 1000 ; // Update time
|
||||
TIM8->CCR1 = (g_model.ppmDelay*50+300)*2 ;
|
||||
// TIM1->CCR2 = rest - 1000 ; // Update time
|
||||
// TIM1->CCR3 = (g_model.ppmDelay*50+300)*2 ;
|
||||
TIM1->CCR2 = rest - 1000 ; // Update time
|
||||
TIM1->CCR1 = (g_model.ppmDelay*50+300)*2 ;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -204,80 +182,9 @@ const uint16_t CRCTable[]=
|
||||
0x7bc7,0x6a4e,0x58d5,0x495c,0x3de3,0x2c6a,0x1ef1,0x0f78
|
||||
};
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
uint16_t PcmCrc[2] ;
|
||||
uint8_t PcmOnesCount[2] ;
|
||||
|
||||
void crc( uint8_t data, uint32_t module_index )
|
||||
{
|
||||
// uint8_t i ;
|
||||
|
||||
PcmCrc[module_index]=(PcmCrc[module_index]<<8)^(CRCTable[((PcmCrc[module_index]>>8)^data) & 0xFF]);
|
||||
}
|
||||
|
||||
void putPcmPart( uint8_t value, uint32_t module_index )
|
||||
{
|
||||
PxxValue[module_index] += 18 ; // Output 1 for this time
|
||||
*pxxStreamPtr[module_index]++ = PxxValue[module_index] ;
|
||||
PxxValue[module_index] += 14 ;
|
||||
if ( value ) {
|
||||
PxxValue[module_index] += 16 ;
|
||||
}
|
||||
*pxxStreamPtr[module_index]++ = PxxValue[module_index] ; // Output 0 for this time
|
||||
}
|
||||
|
||||
void putPcmFlush( uint32_t module_index )
|
||||
{
|
||||
*pxxStreamPtr[module_index]++ = 18010 ; // Past the 18000 of the ARR
|
||||
}
|
||||
|
||||
void putPcmBit( uint8_t bit, uint32_t module_index )
|
||||
{
|
||||
if ( bit )
|
||||
{
|
||||
PcmOnesCount[module_index] += 1 ;
|
||||
putPcmPart( 1, module_index ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
PcmOnesCount[module_index] = 0 ;
|
||||
putPcmPart( 0, module_index ) ;
|
||||
}
|
||||
if ( PcmOnesCount[module_index] >= 5 )
|
||||
{
|
||||
putPcmBit( 0, module_index ) ; // Stuff a 0 bit in
|
||||
}
|
||||
}
|
||||
|
||||
void putPcmByte( uint8_t byte, uint32_t module_index )
|
||||
{
|
||||
crc(byte, module_index);
|
||||
|
||||
for (uint8_t i=0; i<8; i++) {
|
||||
putPcmBit(byte & 0x80, module_index);
|
||||
byte <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
void putPcmHead( uint32_t module_index )
|
||||
{
|
||||
// send 7E, do not CRC
|
||||
// 01111110
|
||||
putPcmPart( 0, module_index ) ;
|
||||
putPcmPart( 1, module_index ) ;
|
||||
putPcmPart( 1, module_index ) ;
|
||||
putPcmPart( 1, module_index ) ;
|
||||
putPcmPart( 1, module_index ) ;
|
||||
putPcmPart( 1, module_index ) ;
|
||||
putPcmPart( 1, module_index ) ;
|
||||
putPcmPart( 0, module_index ) ;
|
||||
}
|
||||
|
||||
#else // Not Taranis
|
||||
uint16_t PcmCrc ;
|
||||
uint8_t PcmOnesCount ;
|
||||
|
||||
|
||||
void crc( uint8_t data )
|
||||
{
|
||||
// uint8_t i ;
|
||||
@@ -378,11 +285,11 @@ void putPcmHead()
|
||||
putPcmPart( 1 ) ;
|
||||
putPcmPart( 0 ) ;
|
||||
}
|
||||
#endif // Taranis
|
||||
|
||||
void setupPulsesPXX(MODULE_INDEX_PARAM)
|
||||
void setupPulsesPXX()
|
||||
{
|
||||
uint16_t chan=0, chan_low=0;
|
||||
uint16_t chan ;
|
||||
uint16_t chan_1 ;
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
Serial_byte = 0 ;
|
||||
@@ -390,25 +297,10 @@ void setupPulsesPXX(MODULE_INDEX_PARAM)
|
||||
Serial_byte_count = 0 ;
|
||||
Pulses2MHzptr = Bit_pulses ;
|
||||
#else
|
||||
#if defined(PCBTARANIS)
|
||||
pxxStreamPtr[module_index] = module_index ? pxx2Stream : pxxStream ;
|
||||
PxxValue[module_index] = 0 ;
|
||||
#else
|
||||
pxxStreamPtr = pxxStream ;
|
||||
PxxValue = 0 ;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
PcmCrc[module_index] = 0;
|
||||
PcmOnesCount[module_index] = 0;
|
||||
|
||||
/* Sync */
|
||||
putPcmHead(module_index);
|
||||
|
||||
/* Rx Number */
|
||||
putPcmByte(g_model.modelId, module_index);
|
||||
#else
|
||||
PcmCrc = 0;
|
||||
PcmOnesCount = 0;
|
||||
|
||||
@@ -417,116 +309,83 @@ void setupPulsesPXX(MODULE_INDEX_PARAM)
|
||||
|
||||
/* Rx Number */
|
||||
putPcmByte(g_model.modelId);
|
||||
#endif
|
||||
|
||||
/* FLAG1 */
|
||||
uint8_t flag1;
|
||||
if (pxxFlag[0] & PXX_SEND_RXNUM) {
|
||||
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
flag1 = (g_model.moduleData[module_index].rfProtocol << 6) | (g_eeGeneral.countryCode << 1) | pxxFlag[module_index];
|
||||
if (pxxFlag & PXX_SEND_RXNUM) {
|
||||
flag1 = (g_model.rfProtocol << 6) | (g_eeGeneral.countryCode << 1) | pxxFlag;
|
||||
}
|
||||
else {
|
||||
flag1 = (g_model.moduleData[module_index].rfProtocol << 6) | pxxFlag[0];
|
||||
#else
|
||||
flag1 = (g_model.moduleData[0].rfProtocol << 6) | (g_eeGeneral.countryCode << 1) | pxxFlag[0];
|
||||
}
|
||||
else {
|
||||
flag1 = (g_model.moduleData[0].rfProtocol << 6) | pxxFlag[0];
|
||||
#endif
|
||||
|
||||
flag1 = (g_model.rfProtocol << 6) | pxxFlag;
|
||||
#if defined(PCBTARANIS)
|
||||
if (g_model.moduleData[module_index].failsafeMode != FAILSAFE_HOLD) {
|
||||
if (g_model.failsafeMode != FAILSAFE_HOLD) {
|
||||
if (failsafeCounter-- == 0) {
|
||||
failsafeCounter = 1000;
|
||||
flag1 |= PXX_SEND_FAILSAFE;
|
||||
}
|
||||
if (failsafeCounter == 0 && g_model.moduleData[module_index].channelsCount > 0) {
|
||||
if (failsafeCounter == 0 && g_model.ppmNCH > 0) {
|
||||
flag1 |= PXX_SEND_FAILSAFE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#if defined(PCBTARANIS)
|
||||
putPcmByte(flag1, module_index);
|
||||
|
||||
/* FLAG2 */
|
||||
putPcmByte(0, module_index);
|
||||
#else
|
||||
putPcmByte(flag1);
|
||||
|
||||
/* FLAG2 */
|
||||
putPcmByte(0);
|
||||
#endif
|
||||
|
||||
/* PPM */
|
||||
static uint32_t pass = 0;
|
||||
uint32_t sendUpperChannels = 0;
|
||||
if (pass++ & 0x01) {
|
||||
#if defined(PCBTARANIS)
|
||||
sendUpperChannels = g_model.moduleData[module_index].channelsCount;
|
||||
#else
|
||||
sendUpperChannels = g_model.moduleData[0].channelsCount;
|
||||
#endif
|
||||
sendUpperChannels = g_model.ppmNCH*2;
|
||||
}
|
||||
for (uint32_t i=0; i<8; i++) {
|
||||
for (uint32_t i=0; i<8; i+=2) {
|
||||
#if defined(PCBTARANIS)
|
||||
if (flag1 & PXX_SEND_FAILSAFE) {
|
||||
if (g_model.moduleData[module_index].failsafeMode == FAILSAFE_NOPULSES) {
|
||||
if (i < sendUpperChannels)
|
||||
chan = 3072;
|
||||
else
|
||||
chan = 1024;
|
||||
if (g_model.failsafeMode == FAILSAFE_NOPULSES) {
|
||||
if (i < sendUpperChannels) {
|
||||
chan = 3072;
|
||||
chan_1 = 3072;
|
||||
}
|
||||
else {
|
||||
chan = 1024;
|
||||
chan_1 = 1024;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (i < sendUpperChannels) {
|
||||
chan = limit(2048, PPM_CH_CENTER(8+g_model.moduleData[module_index].channelsStart+i) - PPM_CENTER + (g_model.moduleData[module_index].failsafeChannels[8+g_model.moduleData[0].channelsStart+i] * 512 / 682) + 3072, 4095);
|
||||
chan = limit(2048, (g_model.failsafeChannels[8+g_model.ppmSCH+i] * 512 / 682) + 3072, 4095);
|
||||
chan_1 = limit(2048, (g_model.failsafeChannels[8+g_model.ppmSCH+i+1] * 512 / 682) + 3072, 4095);
|
||||
if (chan == 3072) chan = 3073;
|
||||
if (chan_1 == 3072) chan_1 = 3073;
|
||||
}
|
||||
else {
|
||||
chan = limit(0, PPM_CH_CENTER(g_model.moduleData[module_index].channelsStart+i) - PPM_CENTER + (g_model.moduleData[module_index].failsafeChannels[g_model.moduleData[0].channelsStart+i] * 512 / 682) + 1024, 2047);
|
||||
chan = limit(0, (g_model.failsafeChannels[g_model.ppmSCH+i] * 512 / 682) + 1024, 2047);
|
||||
chan_1 = limit(0, (g_model.failsafeChannels[g_model.ppmSCH+i+1] * 512 / 682) + 1024, 2047);
|
||||
if (chan == 1024) chan = 1025;
|
||||
if (chan_1 == 1024) chan_1 = 1025;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (i < sendUpperChannels)
|
||||
chan = limit(2048, PPM_CH_CENTER(8+g_model.moduleData[0].channelsStart+i) - PPM_CENTER + (channelOutputs[8+g_model.moduleData[0].channelsStart+i] * 512 / 682) + 3072, 4095);
|
||||
else
|
||||
chan = limit(0, PPM_CH_CENTER(g_model.moduleData[0].channelsStart+i) - PPM_CENTER + (channelOutputs[g_model.moduleData[0].channelsStart+i] * 512 / 682) + 1024, 2047);
|
||||
}
|
||||
|
||||
if (i & 1) {
|
||||
#if defined(PCBTARANIS)
|
||||
putPcmByte(chan_low, module_index); // Low byte of channel
|
||||
putPcmByte( ( ( chan_low >> 8 ) & 0x0F ) | ( chan << 4), module_index ) ; // 4 bits each from 2 channels
|
||||
putPcmByte(chan >> 4, module_index); // High byte of channel
|
||||
#else
|
||||
putPcmByte(chan_low); // Low byte of channel
|
||||
putPcmByte( ( ( chan_low >> 8 ) & 0x0F ) | ( chan << 4) ) ; // 4 bits each from 2 channels
|
||||
putPcmByte(chan >> 4); // High byte of channel
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
chan_low = chan;
|
||||
if (i < sendUpperChannels) {
|
||||
chan = limit(2048, (channelOutputs[8+g_model.ppmSCH+i] * 512 / 682) + 3072, 4095);
|
||||
chan_1 = limit(2048, (channelOutputs[8+g_model.ppmSCH+i+1] * 512 / 682) + 3072, 4095);
|
||||
}
|
||||
else {
|
||||
chan = limit(0, (channelOutputs[g_model.ppmSCH+i] * 512 / 682) + 1024, 2047);
|
||||
chan_1 = limit(0, (channelOutputs[g_model.ppmSCH+i+1] * 512 / 682) + 1024, 2047);
|
||||
}
|
||||
}
|
||||
putPcmByte(chan); // Low byte of channel
|
||||
putPcmByte( ( ( chan >> 8 ) & 0x0F ) | ( chan_1 << 4) ) ; // 4 bits each from 2 channels
|
||||
putPcmByte(chan_1 >> 4); // High byte of channel
|
||||
}
|
||||
|
||||
/* CRC16 */
|
||||
#if defined(PCBTARANIS)
|
||||
putPcmByte(0, module_index);
|
||||
chan = PcmCrc[module_index];
|
||||
putPcmByte(chan>>8, module_index);
|
||||
putPcmByte(chan, module_index);
|
||||
|
||||
/* Sync */
|
||||
putPcmHead(module_index);
|
||||
|
||||
putPcmFlush(module_index);
|
||||
#else
|
||||
putPcmByte(0);
|
||||
chan = PcmCrc;
|
||||
putPcmByte(chan>>8);
|
||||
@@ -536,7 +395,6 @@ void setupPulsesPXX(MODULE_INDEX_PARAM)
|
||||
putPcmHead();
|
||||
|
||||
putPcmFlush();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(DSM2)
|
||||
@@ -691,16 +549,12 @@ extern "C" void PWM_IRQHandler(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
void setupPulses(MODULE_INDEX_PARAM)
|
||||
void setupPulses()
|
||||
{
|
||||
heartbeat |= HEART_TIMER_PULSES;
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
if ( module_index )
|
||||
{
|
||||
module_index = 1 ; // Ensure is 0 or 1 only
|
||||
}
|
||||
uint8_t required_protocol = (g_model.moduleData[module_index].rfProtocol == RF_PROTO_OFF ? PROTO_NONE : PROTO_PXX);
|
||||
uint8_t required_protocol = (g_model.rfProtocol == RF_PROTO_OFF ? PROTO_NONE : PROTO_PXX);
|
||||
#else
|
||||
uint8_t required_protocol = g_model.protocol;
|
||||
#endif
|
||||
@@ -712,11 +566,7 @@ void setupPulses(MODULE_INDEX_PARAM)
|
||||
|
||||
switch (s_current_protocol) { // stop existing protocol hardware
|
||||
case PROTO_PXX:
|
||||
#if defined(PCBTARANIS)
|
||||
disable_pxx(module_index);
|
||||
#else
|
||||
disable_pxx();
|
||||
#endif
|
||||
break;
|
||||
#if defined(DSM2)
|
||||
case PROTO_DSM2_LP45:
|
||||
@@ -726,11 +576,7 @@ void setupPulses(MODULE_INDEX_PARAM)
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
#if defined(PCBTARANIS)
|
||||
disable_ppm(module_index);
|
||||
#else
|
||||
disable_main_ppm();
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -739,12 +585,10 @@ void setupPulses(MODULE_INDEX_PARAM)
|
||||
#if defined(PCBTARANIS)
|
||||
switch (required_protocol) {
|
||||
case PROTO_PXX:
|
||||
init_pxx(0);
|
||||
// init_pxx(module_index);
|
||||
init_pxx();
|
||||
break;
|
||||
default:
|
||||
init_ppm(0);
|
||||
// init_ppm(module_index);
|
||||
init_main_ppm();
|
||||
break;
|
||||
}
|
||||
#elif defined(PCBSKY9X)
|
||||
@@ -772,11 +616,7 @@ void setupPulses(MODULE_INDEX_PARAM)
|
||||
// Set up output data here
|
||||
switch (required_protocol) {
|
||||
case PROTO_PXX:
|
||||
#if defined(PCBTARANIS)
|
||||
setupPulsesPXX(module_index);
|
||||
#else
|
||||
setupPulsesPXX();
|
||||
#endif
|
||||
break;
|
||||
#if defined(DSM2)
|
||||
case PROTO_DSM2_LP45:
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ typedef const uint8_t pm_uint8_t;
|
||||
typedef const int16_t pm_int16_t;
|
||||
typedef const int8_t pm_int8_t;
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
#if defined(PCBTARANIS) || defined(PCBACT)
|
||||
extern GPIO_TypeDef gpioa;
|
||||
#undef GPIOA
|
||||
#define GPIOA (&gpioa)
|
||||
|
||||
+62
-9
@@ -56,6 +56,7 @@ public:
|
||||
Open9xSim(){};
|
||||
Open9xSim(FXApp* a);
|
||||
long onKeypress(FXObject*,FXSelector,void*);
|
||||
long onArrowPress(FXObject*,FXSelector,void*);
|
||||
long onTimeout(FXObject*,FXSelector,void*);
|
||||
void makeSnapshot(const FXDrawable* drawable);
|
||||
void doEvents();
|
||||
@@ -68,13 +69,18 @@ private:
|
||||
|
||||
public:
|
||||
FXSlider *sliders[8];
|
||||
FXKnob *knobs[NUM_POTS];
|
||||
FXKnob *knobs[8];
|
||||
FXKnob *knobsppm[8];
|
||||
FXArrowButton *arrow[3];
|
||||
FXArrowButton *arrow2[3];
|
||||
FXToggleButton *togButPpm;
|
||||
};
|
||||
// Message Map
|
||||
FXDEFMAP(Open9xSim) Open9xSimMap[]={
|
||||
|
||||
//________Message_Type_________ID_____________________Message_Handler_______
|
||||
FXMAPFUNC(SEL_TIMEOUT, 2, Open9xSim::onTimeout),
|
||||
FXMAPFUNC(SEL_COMMAND, 1000, Open9xSim::onArrowPress),
|
||||
FXMAPFUNC(SEL_KEYPRESS, 0, Open9xSim::onKeypress),
|
||||
};
|
||||
|
||||
@@ -83,10 +89,16 @@ FXIMPLEMENT(Open9xSim,FXMainWindow,Open9xSimMap,ARRAYNUMBER(Open9xSimMap))
|
||||
Open9xSim::Open9xSim(FXApp* a)
|
||||
:FXMainWindow(a,"Open9xSim",NULL,NULL,DECOR_ALL,20,90,0,0)
|
||||
{
|
||||
|
||||
firstTime=true;
|
||||
for(int i=0; i<(LCD_W*LCD_H/8); i++) displayBuf[i]=0;//rand();
|
||||
bmp = new FXPPMImage(getApp(),NULL,IMAGE_OWNED|IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP, W2, H2);
|
||||
|
||||
FXHorizontalFrame *hf00=new FXHorizontalFrame(this,LAYOUT_CENTER_X);
|
||||
FXHorizontalFrame *hf01=new FXHorizontalFrame(this,LAYOUT_CENTER_X);
|
||||
FXHorizontalFrame *hf02=new FXHorizontalFrame(this,LAYOUT_CENTER_X);
|
||||
//FXHorizontalFrame *hf2=new FXHorizontalFrame(this,LAYOUT_FILL_X);
|
||||
FXHorizontalFrame *hf10=new FXHorizontalFrame(this,LAYOUT_CENTER_X);
|
||||
FXHorizontalFrame *hf11=new FXHorizontalFrame(this,LAYOUT_CENTER_X);
|
||||
FXHorizontalFrame *hf1=new FXHorizontalFrame(this,LAYOUT_FILL_X);
|
||||
|
||||
@@ -97,18 +109,18 @@ Open9xSim::Open9xSim(FXApp* a)
|
||||
#define L LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT|LAYOUT_FIX_X|LAYOUT_FIX_Y
|
||||
#undef X0
|
||||
#define X0 10
|
||||
#define Y0 10
|
||||
#define Y0 20
|
||||
case 0:
|
||||
sliders[i]=new FXSlider(hf1,NULL,0,L|SLIDER_HORIZONTAL,X0+0,Y0+100,100,20);
|
||||
sliders[i]=new FXSlider(hf1,NULL,0,L|SLIDER_HORIZONTAL,X0+0,Y0+120,100,20);
|
||||
break;
|
||||
case 1:
|
||||
sliders[i]=new FXSlider(hf1,NULL,0,L|SLIDER_VERTICAL,X0+100,Y0+0,20,100);
|
||||
sliders[i]=new FXSlider(hf1,NULL,0,L|SLIDER_VERTICAL,X0+100,Y0+20,20,100);
|
||||
break;
|
||||
case 2:
|
||||
sliders[i]=new FXSlider(hf1,NULL,0,L|SLIDER_VERTICAL,X0+120,Y0+0,20,100);
|
||||
sliders[i]=new FXSlider(hf1,NULL,0,L|SLIDER_VERTICAL,X0+120,Y0+20,20,100);
|
||||
break;
|
||||
case 3:
|
||||
sliders[i]=new FXSlider(hf1,NULL,0,L|SLIDER_HORIZONTAL,X0+140,Y0+100,100,20);
|
||||
sliders[i]=new FXSlider(hf1,NULL,0,L|SLIDER_HORIZONTAL,X0+140,Y0+120,100,20);
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
@@ -116,13 +128,26 @@ Open9xSim::Open9xSim(FXApp* a)
|
||||
sliders[i]->setTickDelta(7);
|
||||
sliders[i]->setValue(0);
|
||||
}
|
||||
|
||||
for(int i=0; i<NUM_POTS; i++){
|
||||
arrow[0]= new FXArrowButton(hf10,this,1000,ARROW_LEFT);
|
||||
arrow[1]= new FXArrowButton(hf10,this,1000,ARROW_UP);
|
||||
arrow[2]= new FXArrowButton(hf10,this,1000,ARROW_RIGHT);
|
||||
for(int i=4; i<8; i++){
|
||||
knobs[i]= new FXKnob(hf11,NULL,0,KNOB_TICKS|LAYOUT_LEFT);
|
||||
knobs[i]->setRange(-1024, 1024);
|
||||
knobs[i]->setValue(0);
|
||||
}
|
||||
|
||||
arrow2[0]= new FXArrowButton(hf00,this,1000,ARROW_LEFT);
|
||||
arrow2[1]= new FXArrowButton(hf00,this,1000,ARROW_UP);
|
||||
arrow2[2]= new FXArrowButton(hf00,this,1000,ARROW_RIGHT);
|
||||
togButPpm = new FXToggleButton(hf00,"on", "off", NULL, NULL, NULL, 0, TOGGLEBUTTON_NORMAL);
|
||||
for(int i=0; i<8; i++){
|
||||
knobsppm[i]= new FXKnob(i<4?hf01:hf02,NULL,0,KNOB_TICKS|LAYOUT_LEFT);
|
||||
knobsppm[i]->setRange(1000,2000);
|
||||
knobsppm[i]->setValue(1500+i*20);
|
||||
}
|
||||
|
||||
|
||||
bmf = new FXImageFrame(this,bmp);
|
||||
|
||||
getApp()->addTimeout(this,2,100);
|
||||
@@ -169,6 +194,25 @@ void Open9xSim::doEvents()
|
||||
getApp()->runOneEvent(false);
|
||||
}
|
||||
|
||||
long Open9xSim::onArrowPress(FXObject*sender,FXSelector sel,void*v)
|
||||
{
|
||||
int which,val;
|
||||
if(sender==arrow[0]) { which=1; val=0;}
|
||||
if(sender==arrow[1]) { which=1; val=512;}
|
||||
if(sender==arrow[2]) { which=1; val=1023;}
|
||||
if(sender==arrow2[0]){ which=2; val=1000;}
|
||||
if(sender==arrow2[1]){ which=2; val=1500;}
|
||||
if(sender==arrow2[2]){ which=2; val=2000;}
|
||||
if(which == 1){
|
||||
for(int i=0; i<4; i++) sliders[i]->setValue(val);
|
||||
for(int i=4; i<7; i++) knobs[i]->setValue(val);
|
||||
}
|
||||
if(which == 2){
|
||||
for(int i=0; i<8; i++) knobsppm[i]->setValue(val);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
long Open9xSim::onKeypress(FXObject*,FXSelector,void*v)
|
||||
{
|
||||
FXEvent *evt=(FXEvent*)v;
|
||||
@@ -181,6 +225,15 @@ long Open9xSim::onKeypress(FXObject*,FXSelector,void*v)
|
||||
|
||||
long Open9xSim::onTimeout(FXObject*,FXSelector,void*)
|
||||
{
|
||||
if(togButPpm->getState()){
|
||||
for(int i=0; i<8; i++){
|
||||
g_ppmIns[i]=knobsppm[i]->getValue()-1500;
|
||||
if(g_ppmIns[i]<-400){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(hasFocus()) {
|
||||
static int keys1[]={
|
||||
#if defined(PCBTARANIS)
|
||||
@@ -411,5 +464,5 @@ uint16_t anaIn(uint8_t chan)
|
||||
else if (chan<NUM_STICKS)
|
||||
return th9xSim->sliders[chan]->getValue();
|
||||
else
|
||||
return th9xSim->knobs[chan-NUM_STICKS]->getValue();
|
||||
return th9xSim->knobs[chan]->getValue();
|
||||
}
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@
|
||||
const pm_char stamp1[] PROGMEM = " SVN: " SVN_STR;
|
||||
const pm_char stamp2[] PROGMEM = "DATE: " DATE_STR;
|
||||
const pm_char stamp3[] PROGMEM = "TIME: " TIME_STR;
|
||||
#if defined(PCBSTD)
|
||||
#if defined(CPUM64)
|
||||
const pm_char eeprom_stamp[] PROGMEM = "EEPR: " DEFNUMSTR(EEPROM_VER) "-" DEFNUMSTR(EEPROM_VARIANT);
|
||||
#else
|
||||
const pm_char eeprom_stamp[] PROGMEM = "EEPR: " DEFNUMSTR(EEPROM_VER);
|
||||
|
||||
@@ -221,14 +221,14 @@ void boardInit()
|
||||
usbInit();
|
||||
|
||||
//Temporary: Configure second PPM pin as input (done after USB init in case the lib already initialises USB_ID)
|
||||
// GPIO_InitTypeDef GPIO_InitStructure;
|
||||
// RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIO_EXTPPM, ENABLE);
|
||||
// GPIO_InitStructure.GPIO_Pin = PIN_EXTPPM_OUT;
|
||||
// GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
// GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
// GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
|
||||
// GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||
// GPIO_Init(GPIO_EXTPPM, &GPIO_InitStructure);
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIO_EXTPPM, ENABLE);
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_EXTPPM_OUT;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||
GPIO_Init(GPIO_EXTPPM, &GPIO_InitStructure);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -84,8 +84,7 @@ uint8_t usbPlugged(void);
|
||||
#define BOOTLOADER_REQUEST() (0)
|
||||
#define usbBootloader()
|
||||
|
||||
#define SLAVE_MODE() (g_model.trainerMode == 1)
|
||||
#define TRAINER_CONNECTED() (GPIO_ReadInputDataBit(GPIOTRNDET, PIN_TRNDET) == Bit_RESET)
|
||||
#define SLAVE_MODE() (0/*pwrCheck() == e_power_trainer*/)
|
||||
|
||||
void delaysInit();
|
||||
|
||||
@@ -114,16 +113,15 @@ uint32_t sdMounted();
|
||||
#endif
|
||||
|
||||
// Pulses driver
|
||||
void init_ppm( uint32_t module_index );
|
||||
void disable_ppm( uint32_t module_index );
|
||||
void init_pxx( uint32_t module_index );
|
||||
void disable_pxx( uint32_t module_index );
|
||||
void init_main_ppm();
|
||||
void disable_main_ppm();
|
||||
void init_pxx();
|
||||
void disable_pxx();
|
||||
|
||||
// Trainer driver
|
||||
void init_trainer_ppm();
|
||||
void stop_trainer_ppm();
|
||||
void init_trainer_capture();
|
||||
void stop_trainer_ppm() ;
|
||||
|
||||
// Keys driver
|
||||
void keysInit();
|
||||
@@ -166,7 +164,7 @@ void pwrOff();
|
||||
#define setBacklight(xx)
|
||||
#define __BACKLIGHT_ON GPIO_SetBits(GPIOB, GPIO_Pin_BL)
|
||||
#define __BACKLIGHT_OFF GPIO_ResetBits(GPIOB, GPIO_Pin_BL)
|
||||
#define IS_BACKLIGHT_ON() GPIO_IsSet(GPIOB, GPIO_Pin_BL)
|
||||
#define IS_BACKLIGHT_ON() GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_BL)
|
||||
|
||||
// USB driver
|
||||
void usbInit(void);
|
||||
|
||||
+62
-316
@@ -36,136 +36,72 @@
|
||||
|
||||
#include "../opentx.h"
|
||||
|
||||
#define EXTERNAL_TEST 0
|
||||
|
||||
// CURRENTLY EXPECTS ONLY PXX ON THE INTERNAL SIGNAL, PPM ALLOWED ON THE EXTERNAL SIGNAL
|
||||
|
||||
// TODO not here!
|
||||
void setupPulses( uint32_t module );
|
||||
void setupPulsesPPM() ;
|
||||
void setupPulsesPXX( uint32_t module );
|
||||
void setupPulses();
|
||||
void setupPulsesPPM();
|
||||
void setupPulsesPXX();
|
||||
|
||||
uint16_t *ppmStreamPtr;
|
||||
uint16_t *ppm2StreamPtr;
|
||||
extern uint16_t ppmStream[20];
|
||||
extern uint16_t ppm2Stream[20];
|
||||
extern uint16_t pxxStream[400] ;
|
||||
extern uint16_t pxx2Stream[400] ;
|
||||
|
||||
#define INT_MODULE 0
|
||||
#define EXT_MODULE 0
|
||||
|
||||
static void init_pa10_pxx( void ) ;
|
||||
static void disable_pa10_pxx( void ) ;
|
||||
static void init_pa10_ppm( void ) ;
|
||||
static void disable_pa10_ppm( void ) ;
|
||||
static void init_pa7_pxx( void ) ;
|
||||
static void disable_pa7_pxx( void ) ;
|
||||
static void init_pa7_ppm( void ) ;
|
||||
static void disable_pa7_ppm( void ) ;
|
||||
|
||||
void init_pxx( uint32_t module_index )
|
||||
void init_pxx()
|
||||
{
|
||||
if ( module_index )
|
||||
{
|
||||
init_pa10_pxx() ;
|
||||
}
|
||||
else
|
||||
{
|
||||
init_pa7_pxx() ;
|
||||
}
|
||||
}
|
||||
INTERNAL_RF_ON();
|
||||
|
||||
void disable_pxx( uint32_t module_index )
|
||||
{
|
||||
if ( module_index )
|
||||
{
|
||||
disable_pa10_pxx() ;
|
||||
}
|
||||
else
|
||||
{
|
||||
disable_pa7_pxx() ;
|
||||
}
|
||||
}
|
||||
|
||||
void init_ppm( uint32_t module_index )
|
||||
{
|
||||
if ( module_index )
|
||||
{
|
||||
init_pa10_ppm() ;
|
||||
}
|
||||
else
|
||||
{
|
||||
init_pa7_ppm() ;
|
||||
}
|
||||
}
|
||||
|
||||
void disable_ppm( uint32_t module_index )
|
||||
{
|
||||
if ( module_index )
|
||||
{
|
||||
disable_pa10_ppm() ;
|
||||
}
|
||||
else
|
||||
{
|
||||
disable_pa7_ppm() ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void init_pa10_pxx()
|
||||
{
|
||||
EXTERNAL_RF_ON();
|
||||
|
||||
// Timer1, channel 3
|
||||
setupPulsesPXX(EXT_MODULE) ; // TODO not here!
|
||||
// Timer1
|
||||
setupPulsesPXX() ; // TODO not here!
|
||||
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN ; // Enable portA clock
|
||||
#if defined(REV3)
|
||||
configure_pins( 0x0100, PIN_PERIPHERAL | PIN_PORTA | PIN_PER_1 | PIN_OS25 | PIN_PUSHPULL ) ;
|
||||
#else
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
// RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOCPPM, ENABLE);
|
||||
|
||||
GPIO_PinAFConfig(GPIO_EXTPPM, GPIO_PinSource_EXTPPM, GPIO_AF_TIM1);
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_EXTPPM_OUT;
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOCPPM, ENABLE);
|
||||
GPIO_PinAFConfig(GPIOCPPM, GPIO_PinSource_CPPM, GPIO_AF_TIM1);
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_CPPM_OUT;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(GPIOCPPM, &GPIO_InitStructure);
|
||||
|
||||
RCC->APB2ENR |= RCC_APB2ENR_TIM1EN ; // Enable clock
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_DMA2EN ; // Enable DMA2 clock
|
||||
#endif
|
||||
RCC->APB2ENR |= RCC_APB2ENR_TIM1EN ; // Enable clock
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_DMA2EN ; // Enable DMA1 clock
|
||||
|
||||
TIM1->CR1 &= ~TIM_CR1_CEN ;
|
||||
TIM1->ARR = 18000 ; // 9mS
|
||||
TIM1->CCR2 = 15000 ; // Update time
|
||||
TIM1->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 2000000 - 1 ; // 0.5uS from 30MHz
|
||||
|
||||
TIM1->CCER = TIM_CCER_CC3E ;
|
||||
|
||||
TIM1->CR2 = TIM_CR2_OIS3 ; // O/P idle high
|
||||
#if defined(REV3)
|
||||
TIM1->CCER = TIM_CCER_CC1E | TIM_CCER_CC1P ;
|
||||
#else
|
||||
TIM1->CCER = TIM_CCER_CC1NE ;
|
||||
#endif
|
||||
TIM1->CR2 = TIM_CR2_OIS1 ; // O/P idle high
|
||||
TIM1->BDTR = TIM_BDTR_MOE ; // Enable outputs
|
||||
TIM1->CCR3 = pxxStream[0] ;
|
||||
TIM1->CCMR2 = TIM_CCMR2_OC3M_2 | TIM_CCMR2_OC3M_0 ; // Force O/P high
|
||||
TIM1->CCR1 = pxxStream[0] ;
|
||||
TIM1->CCMR1 = TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_0 ; // Force O/P high
|
||||
TIM1->EGR = 1 ; // Restart
|
||||
|
||||
// TIM1->SR &= ~TIM_SR_UIF ; // Clear flag
|
||||
// TIM1->SR &= ~TIM_SR_CC2IF ; // Clear flag
|
||||
TIM1->DIER |= TIM_DIER_CC3DE ; // Enable DMA on CC3 match
|
||||
TIM1->DCR = 15 ; // DMA to CC1
|
||||
// TIM1->SR &= ~TIM_SR_UIF ; // Clear flag
|
||||
// TIM1->SR &= ~TIM_SR_CC2IF ; // Clear flag
|
||||
TIM1->DIER |= TIM_DIER_CC1DE ; // Enable DMA on CC1 match
|
||||
TIM1->DCR = 13 ; // DMA to CC1
|
||||
|
||||
// TIM1->CR1 = TIM_CR1_OPM ; // Just run once
|
||||
// Enable the DMA channel here, DMA2 stream 6, channel 6
|
||||
DMA2_Stream6->CR &= ~DMA_SxCR_EN ; // Disable DMA
|
||||
DMA2->HIFCR = DMA_HIFCR_CTCIF6 | DMA_HIFCR_CHTIF6 | DMA_HIFCR_CTEIF6 | DMA_HIFCR_CDMEIF6 | DMA_HIFCR_CFEIF6 ; // Write ones to clear bits
|
||||
DMA2_Stream6->CR = DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_2 | DMA_SxCR_PL_0 | DMA_SxCR_MSIZE_0
|
||||
| DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC | DMA_SxCR_DIR_0 | DMA_SxCR_PFCTRL ;
|
||||
DMA2_Stream6->PAR = CONVERT_PTR(&TIM1->DMAR);
|
||||
DMA2_Stream6->M0AR = CONVERT_PTR(&pxxStream[1]);
|
||||
// DMA2_Stream2->FCR = 0x05 ; //DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0 ;
|
||||
// DMA2_Stream2->NDTR = 100 ;
|
||||
DMA2_Stream6->CR |= DMA_SxCR_EN ; // Enable DMA
|
||||
// Enable the DMA channel here, DMA2 stream 1, channel 6
|
||||
DMA2_Stream1->CR &= ~DMA_SxCR_EN ; // Disable DMA
|
||||
DMA2->LIFCR = DMA_LIFCR_CTCIF1 | DMA_LIFCR_CHTIF1 | DMA_LIFCR_CTEIF1 | DMA_LIFCR_CDMEIF1 | DMA_LIFCR_CFEIF1 ; // Write ones to clear bits
|
||||
DMA2_Stream1->CR = DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_2 | DMA_SxCR_PL_0 | DMA_SxCR_MSIZE_0
|
||||
| DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC | DMA_SxCR_DIR_0 | DMA_SxCR_PFCTRL ;
|
||||
DMA2_Stream1->PAR = CONVERT_PTR(&TIM1->DMAR);
|
||||
DMA2_Stream1->M0AR = CONVERT_PTR(&pxxStream[1]);
|
||||
// DMA2_Stream1->FCR = 0x05 ; //DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0 ;
|
||||
// DMA2_Stream1->NDTR = 100 ;
|
||||
DMA2_Stream1->CR |= DMA_SxCR_EN ; // Enable DMA
|
||||
|
||||
TIM1->CCMR2 = TIM_CCMR2_OC3M_1 | TIM_CCMR2_OC3M_0 ; // Toggle CC1 o/p
|
||||
TIM1->CCMR1 = TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_0 ; // Toggle CC1 o/p
|
||||
TIM1->SR &= ~TIM_SR_CC2IF ; // Clear flag
|
||||
TIM1->DIER |= TIM_DIER_CC2IE ; // Enable this interrupt
|
||||
TIM1->CR1 |= TIM_CR1_CEN ;
|
||||
@@ -173,19 +109,18 @@ static void init_pa10_pxx()
|
||||
NVIC_EnableIRQ(TIM1_CC_IRQn) ;
|
||||
}
|
||||
|
||||
static void disable_pa10_pxx()
|
||||
void disable_pxx()
|
||||
{
|
||||
DMA2_Stream6->CR &= ~DMA_SxCR_EN ; // Disable DMA
|
||||
NVIC_DisableIRQ(TIM1_CC_IRQn) ;
|
||||
TIM1->DIER &= ~TIM_DIER_CC2IE ;
|
||||
TIM1->CR1 &= ~TIM_CR1_CEN ;
|
||||
EXTERNAL_RF_OFF();
|
||||
INTERNAL_RF_OFF();
|
||||
}
|
||||
|
||||
// PPM output
|
||||
// Timer 1, channel 1 on PA8 for prototype
|
||||
// Pin is AF1 function for timer 1
|
||||
static void init_pa10_ppm()
|
||||
void init_main_ppm()
|
||||
{
|
||||
EXTERNAL_RF_ON();
|
||||
// Timer1
|
||||
@@ -193,20 +128,22 @@ static void init_pa10_ppm()
|
||||
ppmStreamPtr = ppmStream ;
|
||||
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN ; // Enable portA clock
|
||||
#if defined(REV3)
|
||||
configure_pins( 0x0100, PIN_PERIPHERAL | PIN_PORTA | PIN_PER_1 | PIN_OS25 | PIN_PUSHPULL ) ;
|
||||
#else
|
||||
configure_pins( 0x0080, PIN_PERIPHERAL | PIN_PORTA | PIN_PER_1 | PIN_OS25 | PIN_PUSHPULL ) ;
|
||||
#endif
|
||||
RCC->APB2ENR |= RCC_APB2ENR_TIM1EN ; // Enable clock
|
||||
|
||||
configure_pins( PIN_EXTPPM_OUT, PIN_PERIPHERAL | PIN_PORTA | PIN_PER_1 | PIN_OS25 | PIN_PUSHPULL ) ;
|
||||
|
||||
RCC->APB2ENR |= RCC_APB2ENR_TIM1EN ; // Enable clock
|
||||
|
||||
TIM1->CR1 &= ~TIM_CR1_CEN ;
|
||||
TIM1->ARR = *ppmStreamPtr++ ;
|
||||
TIM1->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 2000000 - 1 ; // 0.5uS from 30MHz
|
||||
|
||||
TIM1->CCER = TIM_CCER_CC3E ;
|
||||
|
||||
TIM1->CCMR2 = TIM_CCMR2_OC3M_1 | TIM_CCMR2_OC3M_2 ; // PWM mode 1
|
||||
TIM1->CCMR1 = TIM_CCMR1_OC2PE ; // PWM mode 1
|
||||
TIM1->CCR3 = 600 ; // 300 uS pulse ?? (g_model.ppmDelay*50+300)*2 ??
|
||||
#if defined(REV3)
|
||||
TIM1->CCER = TIM_CCER_CC1E ;
|
||||
#else
|
||||
TIM1->CCER = TIM_CCER_CC1NE | TIM_CCER_CC1NP ;
|
||||
#endif
|
||||
TIM1->CCMR1 = TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC2PE ; // PWM mode 1
|
||||
TIM1->CCR1 = 600 ; // 300 uS pulse
|
||||
TIM1->BDTR = TIM_BDTR_MOE ;
|
||||
TIM1->EGR = 1 ;
|
||||
TIM1->DIER = TIM_DIER_UDE ;
|
||||
@@ -221,23 +158,12 @@ static void init_pa10_ppm()
|
||||
NVIC_EnableIRQ(TIM1_UP_TIM10_IRQn) ;
|
||||
}
|
||||
|
||||
static void disable_pa10_ppm()
|
||||
void disable_main_ppm()
|
||||
{
|
||||
NVIC_DisableIRQ(TIM1_CC_IRQn) ;
|
||||
NVIC_DisableIRQ(TIM1_UP_TIM10_IRQn) ;
|
||||
TIM1->DIER &= ~TIM_DIER_CC2IE & ~TIM_DIER_UIE ;
|
||||
TIM1->CR1 &= ~TIM_CR1_CEN ;
|
||||
|
||||
// Make pin an input
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIO_EXTPPM, ENABLE);
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_EXTPPM_OUT;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||
GPIO_Init(GPIO_EXTPPM, &GPIO_InitStructure);
|
||||
|
||||
EXTERNAL_RF_OFF();
|
||||
}
|
||||
|
||||
@@ -246,14 +172,14 @@ extern "C" void TIM1_CC_IRQHandler()
|
||||
TIM1->DIER &= ~TIM_DIER_CC2IE ; // stop this interrupt
|
||||
TIM1->SR &= ~TIM_SR_CC2IF ; // Clear flag
|
||||
|
||||
setupPulses(1) ;
|
||||
setupPulses() ;
|
||||
|
||||
if (s_current_protocol == PROTO_PXX) {
|
||||
DMA2_Stream6->CR &= ~DMA_SxCR_EN ; // Disable DMA
|
||||
DMA2->HIFCR = DMA_HIFCR_CTCIF6 | DMA_HIFCR_CHTIF6 | DMA_HIFCR_CTEIF6 | DMA_HIFCR_CDMEIF6 | DMA_HIFCR_CFEIF6 ; // Write ones to clear bits
|
||||
DMA2_Stream6->M0AR = CONVERT_PTR(&pxxStream[1]);
|
||||
DMA2_Stream6->CR |= DMA_SxCR_EN ; // Enable DMA
|
||||
TIM1->CCR3 = pxxStream[0] ;
|
||||
DMA2_Stream1->CR &= ~DMA_SxCR_EN ; // Disable DMA
|
||||
DMA2->LIFCR = DMA_LIFCR_CTCIF1 | DMA_LIFCR_CHTIF1 | DMA_LIFCR_CTEIF1 | DMA_LIFCR_CDMEIF1 | DMA_LIFCR_CFEIF1 ; // Write ones to clear bits
|
||||
DMA2_Stream1->M0AR = CONVERT_PTR(&pxxStream[1]);
|
||||
DMA2_Stream1->CR |= DMA_SxCR_EN ; // Enable DMA
|
||||
TIM1->CCR1 = pxxStream[0] ;
|
||||
TIM1->DIER |= TIM_DIER_CC2IE ; // Enable this interrupt
|
||||
}
|
||||
else {
|
||||
@@ -276,183 +202,3 @@ extern "C" void TIM1_UP_TIM10_IRQHandler()
|
||||
TIM1->DIER |= TIM_DIER_CC2IE ; // Enable this interrupt
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void init_pa7_pxx()
|
||||
{
|
||||
#if EXTERNAL_TEST
|
||||
init_pa10_pxx() ;
|
||||
return ;
|
||||
#endif
|
||||
INTERNAL_RF_ON();
|
||||
|
||||
// Timer8
|
||||
setupPulsesPXX(INT_MODULE) ; // TODO not here!
|
||||
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN ; // Enable portA clock
|
||||
#if defined(REV3)
|
||||
configure_pins( PIN_CPPM_OUT, PIN_PERIPHERAL | PIN_PORTA | PIN_PER_1 | PIN_OS25 | PIN_PUSHPULL ) ;
|
||||
#else
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOCPPM, ENABLE);
|
||||
GPIO_PinAFConfig(GPIOCPPM, GPIO_PinSource_CPPM, GPIO_AF_TIM8);
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_CPPM_OUT;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(GPIOCPPM, &GPIO_InitStructure);
|
||||
#endif
|
||||
RCC->APB2ENR |= RCC_APB2ENR_TIM8EN ; // Enable clock
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_DMA2EN ; // Enable DMA2 clock
|
||||
|
||||
TIM8->CR1 &= ~TIM_CR1_CEN ;
|
||||
TIM8->ARR = 18000 ; // 9mS
|
||||
TIM8->CCR2 = 15000 ; // Update time
|
||||
TIM8->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 2000000 - 1 ; // 0.5uS from 30MHz
|
||||
#if defined(REV3)
|
||||
TIM8->CCER = TIM_CCER_CC1E | TIM_CCER_CC1P ;
|
||||
#else
|
||||
TIM8->CCER = TIM_CCER_CC1NE ;
|
||||
#endif
|
||||
TIM8->CR2 = TIM_CR2_OIS1 ; // O/P idle high
|
||||
TIM8->BDTR = TIM_BDTR_MOE ; // Enable outputs
|
||||
TIM8->CCR1 = pxxStream[0] ;
|
||||
TIM8->CCMR1 = TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_0 ; // Force O/P high
|
||||
TIM8->EGR = 1 ; // Restart
|
||||
|
||||
// TIM8->SR &= ~TIM_SR_UIF ; // Clear flag
|
||||
// TIM8->SR &= ~TIM_SR_CC2IF ; // Clear flag
|
||||
TIM8->DIER |= TIM_DIER_CC1DE ; // Enable DMA on CC1 match
|
||||
TIM8->DCR = 13 ; // DMA to CC1
|
||||
|
||||
// TIM8->CR1 = TIM_CR1_OPM ; // Just run once
|
||||
// Enable the DMA channel here, DMA2 stream 2, channel 7
|
||||
DMA2_Stream2->CR &= ~DMA_SxCR_EN ; // Disable DMA
|
||||
DMA2->LIFCR = DMA_LIFCR_CTCIF2 | DMA_LIFCR_CHTIF2 | DMA_LIFCR_CTEIF2 | DMA_LIFCR_CDMEIF2 | DMA_LIFCR_CFEIF2 ; // Write ones to clear bits
|
||||
DMA2_Stream2->CR = DMA_SxCR_CHSEL_0 | DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_2 | DMA_SxCR_PL_0 | DMA_SxCR_MSIZE_0
|
||||
| DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC | DMA_SxCR_DIR_0 | DMA_SxCR_PFCTRL ;
|
||||
DMA2_Stream2->PAR = CONVERT_PTR(&TIM8->DMAR);
|
||||
DMA2_Stream2->M0AR = CONVERT_PTR(&pxxStream[1]);
|
||||
// DMA2_Stream2->FCR = 0x05 ; //DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0 ;
|
||||
// DMA2_Stream2->NDTR = 100 ;
|
||||
DMA2_Stream2->CR |= DMA_SxCR_EN ; // Enable DMA
|
||||
|
||||
TIM8->CCMR1 = TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_0 ; // Toggle CC1 o/p
|
||||
TIM8->SR &= ~TIM_SR_CC2IF ; // Clear flag
|
||||
TIM8->DIER |= TIM_DIER_CC2IE ; // Enable this interrupt
|
||||
TIM8->CR1 |= TIM_CR1_CEN ;
|
||||
// NVIC_SetPriority(TIM8_CC_IRQn, 1); // Debug - high priority, doesn't help
|
||||
NVIC_EnableIRQ(TIM8_CC_IRQn) ;
|
||||
}
|
||||
|
||||
static void disable_pa7_pxx()
|
||||
{
|
||||
#if EXTERNAL_TEST
|
||||
disable_pa10_pxx() ;
|
||||
return ;
|
||||
#endif
|
||||
DMA2_Stream2->CR &= ~DMA_SxCR_EN ; // Disable DMA
|
||||
NVIC_DisableIRQ(TIM8_CC_IRQn) ;
|
||||
TIM8->DIER &= ~TIM_DIER_CC2IE ;
|
||||
TIM8->CR1 &= ~TIM_CR1_CEN ;
|
||||
INTERNAL_RF_OFF();
|
||||
}
|
||||
|
||||
// PPM output
|
||||
// Timer 1, channel 1 on PA8 for prototype
|
||||
// Pin is AF1 function for timer 1
|
||||
static void init_pa7_ppm()
|
||||
{
|
||||
#if EXTERNAL_TEST
|
||||
init_pa10_ppm() ;
|
||||
return ;
|
||||
#endif
|
||||
INTERNAL_RF_ON();
|
||||
// Timer1
|
||||
setupPulsesPPM() ;
|
||||
ppmStreamPtr = ppmStream ;
|
||||
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN ; // Enable portA clock
|
||||
#if defined(REV3)
|
||||
configure_pins( 0x0100, PIN_PERIPHERAL | PIN_PORTA | PIN_PER_1 | PIN_OS25 | PIN_PUSHPULL ) ;
|
||||
#else
|
||||
configure_pins( 0x0080, PIN_PERIPHERAL | PIN_PORTA | PIN_PER_3 | PIN_OS25 | PIN_PUSHPULL ) ;
|
||||
#endif
|
||||
RCC->APB2ENR |= RCC_APB2ENR_TIM8EN ; // Enable clock
|
||||
|
||||
TIM8->CR1 &= ~TIM_CR1_CEN ;
|
||||
|
||||
TIM8->ARR = *ppmStreamPtr++ ;
|
||||
TIM8->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 2000000 - 1 ; // 0.5uS from 30MHz
|
||||
#if defined(REV3)
|
||||
TIM8->CCER = TIM_CCER_CC1E ;
|
||||
#else
|
||||
TIM8->CCER = TIM_CCER_CC1NE | TIM_CCER_CC1NP ;
|
||||
#endif
|
||||
TIM8->CCMR1 = TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC2PE ; // PWM mode 1
|
||||
TIM8->CCR1 = 600 ; // 300 uS pulse ?? (g_model.ppmDelay*50+300)*2 ??
|
||||
TIM8->BDTR = TIM_BDTR_MOE ;
|
||||
TIM8->EGR = 1 ;
|
||||
TIM8->DIER = TIM_DIER_UDE ;
|
||||
|
||||
TIM8->SR &= ~TIM_SR_UIF ; // Clear flag
|
||||
TIM8->SR &= ~TIM_SR_CC2IF ; // Clear flag
|
||||
TIM8->DIER |= TIM_DIER_CC2IE ;
|
||||
TIM8->DIER |= TIM_DIER_UIE ;
|
||||
|
||||
TIM8->CR1 = TIM_CR1_CEN ;
|
||||
NVIC_EnableIRQ(TIM8_CC_IRQn) ;
|
||||
NVIC_EnableIRQ(TIM8_UP_TIM13_IRQn) ;
|
||||
}
|
||||
|
||||
static void disable_pa7_ppm()
|
||||
{
|
||||
#if EXTERNAL_TEST
|
||||
disable_pa10_ppm() ;
|
||||
return ;
|
||||
#endif
|
||||
NVIC_DisableIRQ(TIM8_CC_IRQn) ;
|
||||
NVIC_DisableIRQ(TIM8_UP_TIM13_IRQn) ;
|
||||
TIM8->DIER &= ~TIM_DIER_CC2IE & ~TIM_DIER_UIE ;
|
||||
TIM8->CR1 &= ~TIM_CR1_CEN ;
|
||||
INTERNAL_RF_OFF();
|
||||
}
|
||||
|
||||
extern "C" void TIM8_CC_IRQHandler()
|
||||
{
|
||||
TIM8->DIER &= ~TIM_DIER_CC2IE ; // stop this interrupt
|
||||
TIM8->SR &= ~TIM_SR_CC2IF ; // Clear flag
|
||||
|
||||
setupPulses(INT_MODULE) ;
|
||||
|
||||
if (s_current_protocol == PROTO_PXX) {
|
||||
DMA2_Stream2->CR &= ~DMA_SxCR_EN ; // Disable DMA
|
||||
DMA2->LIFCR = DMA_LIFCR_CTCIF2 | DMA_LIFCR_CHTIF2 | DMA_LIFCR_CTEIF2 | DMA_LIFCR_CDMEIF2 | DMA_LIFCR_CFEIF2 ; // Write ones to clear bits
|
||||
DMA2_Stream2->M0AR = CONVERT_PTR(&pxxStream[1]);
|
||||
DMA2_Stream2->CR |= DMA_SxCR_EN ; // Enable DMA
|
||||
TIM8->CCR1 = pxxStream[0] ;
|
||||
TIM8->DIER |= TIM_DIER_CC2IE ; // Enable this interrupt
|
||||
}
|
||||
else {
|
||||
ppmStreamPtr = ppmStream ;
|
||||
|
||||
TIM8->DIER |= TIM_DIER_UDE ;
|
||||
TIM8->SR &= ~TIM_SR_UIF ; // Clear this flag
|
||||
TIM8->DIER |= TIM_DIER_UIE ; // Enable this interrupt
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void TIM8_UP_TIM13_IRQHandler()
|
||||
{
|
||||
TIM8->SR &= ~TIM_SR_UIF ; // Clear flag
|
||||
|
||||
TIM8->ARR = *ppmStreamPtr++ ;
|
||||
if ( *ppmStreamPtr == 0 )
|
||||
{
|
||||
TIM8->SR &= ~TIM_SR_CC2IF ; // Clear this flag
|
||||
TIM8->DIER |= TIM_DIER_CC2IE ; // Enable this interrupt
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,10 @@ uint32_t pwrCheck()
|
||||
#else
|
||||
if (GPIO_ReadInputDataBit(GPIOPWR, PIN_PWR_STATUS) == Bit_RESET)
|
||||
return e_power_on;
|
||||
#if !defined(REV3)
|
||||
else if (GPIO_ReadInputDataBit(GPIOTRNDET, PIN_TRNDET) == Bit_SET)
|
||||
return e_power_trainer;
|
||||
#endif
|
||||
else if (usbPlugged())
|
||||
return e_power_usb;
|
||||
else
|
||||
|
||||
@@ -57,7 +57,7 @@ void setupTrainerPulses()
|
||||
int16_t PPM_range = g_model.extendedLimits ? 640 * 2 : 512 * 2; //range of 0.7..1.7msec
|
||||
|
||||
uint16_t *ptr ;
|
||||
uint32_t p = NUM_CHANNELS(0);
|
||||
uint32_t p=8+g_model.ppmNCH*2; //Channels *2
|
||||
|
||||
ptr = TrainerPpmStream ;
|
||||
|
||||
@@ -72,48 +72,72 @@ void setupTrainerPulses()
|
||||
*ptr++ = rest ;
|
||||
*ptr = 0 ;
|
||||
|
||||
TIM3->CCR2 = rest - 1000 ; // Update time
|
||||
TIM3->CCR4 = (g_model.ppmDelay*50+300)*2 ;
|
||||
TIM8->CCR2 = rest - 1000 ; // Update time
|
||||
TIM8->CCR4 = (g_model.ppmDelay*50+300)*2 ;
|
||||
}
|
||||
|
||||
// Trainer PPM oputput PC9, Timer 3 channel 4, (Alternate Function 2)
|
||||
// Trainer PPM oputput PC9, Timer 8 channel 4
|
||||
void init_trainer_ppm()
|
||||
{
|
||||
setupTrainerPulses() ;
|
||||
TrainerPulsePtr = TrainerPpmStream ;
|
||||
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOCEN ; // Enable portC clock
|
||||
configure_pins( PIN_TR_PPM_OUT, PIN_PERIPHERAL | PIN_PORTC | PIN_PER_3 | PIN_OS25 | PIN_PUSHPULL ) ;
|
||||
configure_pins( PIN_TR_PPM_IN, PIN_PORTA | PIN_INPUT ) ;
|
||||
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN ; // Enable clock
|
||||
configure_pins( 0x0200, PIN_PERIPHERAL | PIN_PORTC | PIN_PER_3 | PIN_OS25 | PIN_PUSHPULL ) ;
|
||||
RCC->APB2ENR |= RCC_APB2ENR_TIM8EN ; // Enable clock
|
||||
|
||||
TIM3->ARR = *TrainerPulsePtr++ ;
|
||||
TIM3->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 2000000 - 1 ; // 0.5uS
|
||||
TIM3->CCER = TIM_CCER_CC4E ;
|
||||
TIM3->CCMR2 = TIM_CCMR2_OC4M_1 | TIM_CCMR2_OC4M_2 | TIM_CCMR2_OC4PE ; // PWM mode 1
|
||||
TIM3->CCR4 = 600 ; // 300 uS pulse
|
||||
TIM3->BDTR = TIM_BDTR_MOE ;
|
||||
TIM3->EGR = 1 ;
|
||||
// TIM3->DIER = TIM_DIER_UDE ;
|
||||
TIM8->ARR = *TrainerPulsePtr++ ;
|
||||
TIM8->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 2000000 - 1 ; // 0.5uS from 30MHz
|
||||
TIM8->CCER = TIM_CCER_CC4E ;
|
||||
TIM8->CCMR2 = TIM_CCMR2_OC4M_1 | TIM_CCMR2_OC4M_2 | TIM_CCMR2_OC4PE ; // PWM mode 1
|
||||
TIM8->CCR4 = 600 ; // 300 uS pulse
|
||||
TIM8->BDTR = TIM_BDTR_MOE ;
|
||||
TIM8->EGR = 1 ;
|
||||
// TIM8->DIER = TIM_DIER_UDE ;
|
||||
|
||||
TIM3->SR &= ~TIM_SR_UIF ; // Clear flag
|
||||
TIM3->SR &= ~TIM_SR_CC2IF ; // Clear flag
|
||||
TIM3->DIER |= TIM_DIER_CC2IE ;
|
||||
TIM3->DIER |= TIM_DIER_UIE ;
|
||||
TIM8->SR &= ~TIM_SR_UIF ; // Clear flag
|
||||
TIM8->SR &= ~TIM_SR_CC2IF ; // Clear flag
|
||||
TIM8->DIER |= TIM_DIER_CC2IE ;
|
||||
TIM8->DIER |= TIM_DIER_UIE ;
|
||||
|
||||
TIM3->CR1 = TIM_CR1_CEN ;
|
||||
NVIC_EnableIRQ(TIM3_IRQn) ;
|
||||
// NVIC_EnableIRQ(TIM8_UP_TIM13_IRQn) ;
|
||||
TIM8->CR1 = TIM_CR1_CEN ;
|
||||
NVIC_EnableIRQ(TIM8_CC_IRQn) ;
|
||||
NVIC_EnableIRQ(TIM8_UP_TIM13_IRQn) ;
|
||||
}
|
||||
|
||||
// TODO - testing
|
||||
void stop_trainer_ppm()
|
||||
{
|
||||
configure_pins( PIN_TR_PPM_OUT, PIN_INPUT | PIN_PORTC ) ; // Pin as input
|
||||
TIM3->CR1 &= ~TIM_CR1_CEN ; // Stop counter
|
||||
TIM3->DIER &= ~TIM_DIER_CC2IE ; // Stop Interrupt
|
||||
TIM3->DIER &= ~TIM_DIER_UIE ; // Stop Interrupt
|
||||
NVIC_DisableIRQ(TIM3_IRQn) ; // Stop Interrupt
|
||||
configure_pins( 0x0200, PIN_INPUT | PIN_PORTC ) ;
|
||||
TIM8->CR1 &= ~TIM_CR1_CEN ; // Stop counter
|
||||
NVIC_DisableIRQ(TIM8_CC_IRQn) ; // Stop Interrupt
|
||||
NVIC_DisableIRQ(TIM8_UP_TIM13_IRQn) ; // Stop Interrupt
|
||||
}
|
||||
|
||||
extern "C" void TIM8_CC_IRQHandler()
|
||||
{
|
||||
TIM8->DIER &= ~TIM_DIER_CC2IE ; // stop this interrupt
|
||||
TIM8->SR &= ~TIM_SR_CC2IF ; // Clear flag
|
||||
|
||||
setupTrainerPulses() ;
|
||||
|
||||
TrainerPulsePtr = TrainerPpmStream ;
|
||||
TIM8->DIER |= TIM_DIER_UDE ;
|
||||
|
||||
TIM8->SR &= ~TIM_SR_UIF ; // Clear this flag
|
||||
TIM8->DIER |= TIM_DIER_UIE ; // Enable this interrupt
|
||||
}
|
||||
|
||||
extern "C" void TIM8_UP_TIM13_IRQHandler()
|
||||
{
|
||||
TIM8->SR &= ~TIM_SR_UIF ; // Clear flag
|
||||
|
||||
TIM8->ARR = *TrainerPulsePtr++ ;
|
||||
if ( *TrainerPulsePtr == 0 )
|
||||
{
|
||||
TIM8->SR &= ~TIM_SR_CC2IF ; // Clear this flag
|
||||
TIM8->DIER |= TIM_DIER_CC2IE ; // Enable this interrupt
|
||||
}
|
||||
}
|
||||
|
||||
// Trainer capture, PC8, Timer 3 channel 3
|
||||
@@ -128,18 +152,12 @@ void init_trainer_capture()
|
||||
TIM3->CR2 = 0 ;
|
||||
TIM3->CCMR2 = TIM_CCMR2_IC3F_0 | TIM_CCMR2_IC3F_1 | TIM_CCMR2_CC3S_0 ;
|
||||
TIM3->CCER = TIM_CCER_CC3E ;
|
||||
TIM3->SR &= ~TIM_SR_CC3IF & ~TIM_SR_CC2IF & ~TIM_SR_UIF ; // Clear flags
|
||||
TIM3->SR &= ~TIM_SR_CC3IF ; // Clear flag
|
||||
TIM3->DIER |= TIM_DIER_CC3IE ;
|
||||
TIM3->CR1 = TIM_CR1_CEN ;
|
||||
NVIC_EnableIRQ(TIM3_IRQn) ;
|
||||
}
|
||||
|
||||
void stop_trainer_capture()
|
||||
{
|
||||
TIM3->CR1 &= ~TIM_CR1_CEN ; // Stop counter
|
||||
TIM3->DIER &= ~TIM_DIER_CC3IE ; // Stop Interrupt
|
||||
NVIC_DisableIRQ(TIM3_IRQn) ; // Stop Interrupt
|
||||
}
|
||||
|
||||
extern "C" void TIM3_IRQHandler()
|
||||
{
|
||||
@@ -147,58 +165,25 @@ extern "C" void TIM3_IRQHandler()
|
||||
static uint16_t lastCapt ;
|
||||
uint16_t val ;
|
||||
|
||||
// What mode? in or out?
|
||||
if ( (TIM3->DIER & TIM_DIER_CC3IE ) && ( TIM3->SR & TIM_SR_CC3IF ) )
|
||||
{
|
||||
// capture mode
|
||||
capture = TIM3->CCR3 ;
|
||||
capture = TIM3->CCR3 ;
|
||||
|
||||
val = (uint16_t)(capture - lastCapt) / 2 ;
|
||||
lastCapt = capture;
|
||||
val = (uint16_t)(capture - lastCapt) / 2 ;
|
||||
lastCapt = capture;
|
||||
|
||||
// We prcoess g_ppmInsright here to make servo movement as smooth as possible
|
||||
// while under trainee control
|
||||
if ((val>4000) && (val < 19000)) { // G: Prioritize reset pulse. (Needed when less than 8 incoming pulses)
|
||||
ppmInState = 1; // triggered
|
||||
}
|
||||
else {
|
||||
if(ppmInState && (ppmInState<=8)) {
|
||||
if ((val>800) && (val<2200)) {
|
||||
g_ppmIns[ppmInState++ - 1] = (int16_t)(val - 1500)*(g_eeGeneral.PPM_Multiplier+10)/10; //+-500 != 512, but close enough.
|
||||
}
|
||||
else {
|
||||
ppmInState = 0; // not triggered
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// PPM out compare interrupt
|
||||
if ( ( TIM3->DIER & TIM_DIER_CC2IE ) && ( TIM3->SR & TIM_SR_CC2IF ) )
|
||||
{ // compare interrupt
|
||||
TIM3->SR &= ~TIM_SR_CC2IF ; // Clear flag
|
||||
TIM3->DIER &= ~TIM_DIER_CC2IE ; // stop this interrupt
|
||||
TIM3->SR &= ~TIM_SR_CC2IF ; // Clear flag
|
||||
|
||||
setupTrainerPulses() ;
|
||||
|
||||
TrainerPulsePtr = TrainerPpmStream ;
|
||||
TIM3->DIER |= TIM_DIER_UDE ;
|
||||
|
||||
TIM3->SR &= ~TIM_SR_UIF ; // Clear this flag
|
||||
TIM3->DIER |= TIM_DIER_UIE ; // Enable this interrupt
|
||||
}
|
||||
|
||||
// PPM out update interrupt
|
||||
if ( (TIM3->DIER & TIM_DIER_UIE) && ( TIM3->SR & TIM_SR_UIF ) )
|
||||
{
|
||||
TIM3->SR &= ~TIM_SR_UIF ; // Clear flag
|
||||
|
||||
TIM3->ARR = *TrainerPulsePtr++ ;
|
||||
if ( *TrainerPulsePtr == 0 )
|
||||
{
|
||||
TIM3->SR &= ~TIM_SR_CC2IF ; // Clear this flag
|
||||
TIM3->DIER |= TIM_DIER_CC2IE ; // Enable this interrupt
|
||||
}
|
||||
}
|
||||
// We prcoess g_ppmInsright here to make servo movement as smooth as possible
|
||||
// while under trainee control
|
||||
if ((val>4000) && (val < 19000)) { // G: Prioritize reset pulse. (Needed when less than 8 incoming pulses)
|
||||
ppmInState = 1; // triggered
|
||||
}
|
||||
else {
|
||||
if(ppmInState && (ppmInState<=8)) {
|
||||
if ((val>800) && (val<2200)) {
|
||||
g_ppmIns[ppmInState++ - 1] = (int16_t)(val - 1500)*(g_eeGeneral.PPM_Multiplier+10)/10; //+-500 != 512, but close enough.
|
||||
}
|
||||
else {
|
||||
ppmInState = 0; // not triggered
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ void USB_OTG_BSP_Init(USB_OTG_CORE_HANDLE *pdev)
|
||||
RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOA , ENABLE);
|
||||
|
||||
/* Configure SOF ID DM DP Pins */
|
||||
GPIO_InitStructure.GPIO_Pin = // GPIO_Pin_8 |
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 |
|
||||
GPIO_Pin_11 |
|
||||
GPIO_Pin_12;
|
||||
|
||||
@@ -59,7 +59,7 @@ void USB_OTG_BSP_Init(USB_OTG_CORE_HANDLE *pdev)
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
|
||||
//GPIO_PinAFConfig(GPIOA,GPIO_PinSource8,GPIO_AF_OTG1_FS) ;
|
||||
GPIO_PinAFConfig(GPIOA,GPIO_PinSource8,GPIO_AF_OTG1_FS) ;
|
||||
GPIO_PinAFConfig(GPIOA,GPIO_PinSource11,GPIO_AF_OTG1_FS) ;
|
||||
GPIO_PinAFConfig(GPIOA,GPIO_PinSource12,GPIO_AF_OTG1_FS) ;
|
||||
|
||||
@@ -71,14 +71,14 @@ void USB_OTG_BSP_Init(USB_OTG_CORE_HANDLE *pdev)
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
|
||||
/* // Configure ID pin
|
||||
/* Configure ID pin */
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
GPIO_PinAFConfig(GPIOA,GPIO_PinSource10,GPIO_AF_OTG1_FS) ;
|
||||
*/
|
||||
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
|
||||
RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_OTG_FS, ENABLE) ;
|
||||
}
|
||||
|
||||
@@ -140,9 +140,9 @@ const pm_char STR_AILDIRECTION[] PROGMEM = TR_AILDIRECTION;
|
||||
const pm_char STR_COLDIRECTION[] PROGMEM = TR_COLDIRECTION;
|
||||
#endif
|
||||
const pm_char STR_MODE[] PROGMEM = TR_MODE;
|
||||
#if defined(AUDIO) && defined(BUZZER)
|
||||
#if defined(AUDIO) && defined(BEEPER)
|
||||
const pm_char STR_SPEAKER[] PROGMEM = INDENT"Speaker";
|
||||
const pm_char STR_BUZZER[] PROGMEM = INDENT"Buzzer";
|
||||
const pm_char STR_BEEPER[] PROGMEM = INDENT"Beeper";
|
||||
#endif
|
||||
const pm_char STR_NOFREEEXPO[] PROGMEM = TR_NOFREEEXPO;
|
||||
const pm_char STR_NOFREEMIXER[] PROGMEM = TR_NOFREEMIXER;
|
||||
@@ -157,7 +157,7 @@ const pm_char STR_OFFSET[] PROGMEM = TR_OFFSET;
|
||||
const pm_char STR_TRIM[] PROGMEM = TR_TRIM;
|
||||
const pm_char STR_DREX[] PROGMEM = TR_DREX;
|
||||
const pm_char STR_CURVE[] PROGMEM = TR_CURVE;
|
||||
const pm_char STR_FLMODE[] PROGMEM = TR_FLMODE;
|
||||
const pm_char STR_FPHASE[] PROGMEM = TR_FPHASE;
|
||||
const pm_char STR_MIXWARNING[] PROGMEM = TR_MIXWARNING;
|
||||
const pm_char STR_OFF[] PROGMEM = TR_OFF;
|
||||
const pm_char STR_MULTPX[] PROGMEM = TR_MULTPX;
|
||||
@@ -297,7 +297,6 @@ const pm_char STR_MENUTEMPLATES[] PROGMEM = TR_MENUTEMPLATES;
|
||||
|
||||
const pm_char STR_MENUSTAT[] PROGMEM = TR_MENUSTAT;
|
||||
const pm_char STR_MENUDEBUG[] PROGMEM = TR_MENUDEBUG;
|
||||
const pm_char STR_MENUGLOBALVARS[] PROGMEM = "GLOBAL VARIABLES";
|
||||
|
||||
#if defined(DSM2) || defined(PXX)
|
||||
const pm_char STR_RXNUM[] PROGMEM = TR_RXNUM;
|
||||
@@ -314,8 +313,6 @@ const pm_char STR_FAILSAFESET[] PROGMEM = TR_FAILSAFESET;
|
||||
#endif
|
||||
|
||||
const pm_char STR_INVERT_THR[] PROGMEM = TR_INVERT_THR;
|
||||
const pm_char STR_AND_SWITCH[] PROGMEM = "AND Switch";
|
||||
extern const pm_char STR_CF[] PROGMEM = "CF";
|
||||
|
||||
#if defined(FRSKY_HUB)
|
||||
const pm_char STR_MINRSSI[] PROGMEM = TR_MINRSSI;
|
||||
@@ -359,8 +356,6 @@ const pm_char STR_RESET_TELEMETRY[] PROGMEM = "Reset Telemetry";
|
||||
const pm_char STR_STATISTICS[] PROGMEM = "Statistics";
|
||||
#endif
|
||||
|
||||
const pm_char STR_RESET[] PROGMEM = "[Reset]";
|
||||
|
||||
#if defined(SDCARD)
|
||||
const pm_char STR_BACKUP_MODEL[] PROGMEM = TR_BACKUP_MODEL;
|
||||
const pm_char STR_RESTORE_MODEL[] PROGMEM = TR_RESTORE_MODEL;
|
||||
@@ -442,7 +437,6 @@ const pm_char STR_BYTES[] PROGMEM = "bytes";
|
||||
const pm_char STR_MODULE_BIND[] PROGMEM = "[Bind]";
|
||||
const pm_char STR_MODULE_RANGE[] PROGMEM = "[Range]";
|
||||
const pm_char STR_SET[] PROGMEM = "[Set]";
|
||||
const pm_char STR_TRAINER[] PROGMEM = "Trainer";
|
||||
#endif
|
||||
|
||||
const pm_uchar font_5x7[] PROGMEM = {
|
||||
|
||||
+4
-10
@@ -271,12 +271,12 @@ extern const pm_char STR_ELEDIRECTION[];
|
||||
extern const pm_char STR_AILDIRECTION[];
|
||||
extern const pm_char STR_COLDIRECTION[];
|
||||
extern const pm_char STR_MODE[];
|
||||
#if defined(AUDIO) && defined(BUZZER)
|
||||
#if defined(AUDIO) && defined(BEEPER)
|
||||
extern const pm_char STR_SPEAKER[];
|
||||
extern const pm_char STR_BUZZER[];
|
||||
extern const pm_char STR_BEEPER[];
|
||||
#else
|
||||
#define STR_SPEAKER STR_MODE
|
||||
#define STR_BUZZER STR_MODE
|
||||
#define STR_BEEPER STR_MODE
|
||||
#endif
|
||||
extern const pm_char STR_NOFREEEXPO[];
|
||||
extern const pm_char STR_NOFREEMIXER[];
|
||||
@@ -291,7 +291,7 @@ extern const pm_char STR_OFFSET[];
|
||||
extern const pm_char STR_TRIM[];
|
||||
extern const pm_char STR_DREX[];
|
||||
extern const pm_char STR_CURVE[];
|
||||
extern const pm_char STR_FLMODE[];
|
||||
extern const pm_char STR_FPHASE[];
|
||||
extern const pm_char STR_MIXWARNING[];
|
||||
extern const pm_char STR_OFF[];
|
||||
extern const pm_char STR_MULTPX[];
|
||||
@@ -407,10 +407,7 @@ extern const pm_char STR_MENUTELEMETRY[];
|
||||
extern const pm_char STR_MENUTEMPLATES[];
|
||||
extern const pm_char STR_MENUSTAT[];
|
||||
extern const pm_char STR_MENUDEBUG[];
|
||||
extern const pm_char STR_MENUGLOBALVARS[];
|
||||
extern const pm_char STR_INVERT_THR[];
|
||||
extern const pm_char STR_AND_SWITCH[];
|
||||
extern const pm_char STR_CF[];
|
||||
|
||||
#if defined(DSM2) || defined(PXX)
|
||||
extern const pm_char STR_RXNUM[];
|
||||
@@ -475,8 +472,6 @@ extern const pm_char STR_CURRENT[];
|
||||
extern const pm_char STR_STATISTICS[];
|
||||
#endif
|
||||
|
||||
extern const pm_char STR_RESET[];
|
||||
|
||||
#if defined(SDCARD)
|
||||
extern const pm_char STR_BACKUP_MODEL[];
|
||||
extern const pm_char STR_RESTORE_MODEL[];
|
||||
@@ -580,7 +575,6 @@ extern const pm_char STR_CHANNELS_MONITOR[];
|
||||
extern const pm_char STR_MODULE_BIND[];
|
||||
extern const pm_char STR_MODULE_RANGE[];
|
||||
extern const pm_char STR_SET[];
|
||||
extern const pm_char STR_TRAINER[];
|
||||
#endif
|
||||
|
||||
// TODO move to translations files
|
||||
|
||||
@@ -381,7 +381,7 @@
|
||||
#define TR_TRIM "Trim"
|
||||
#define TR_DREX "DVex"
|
||||
#define TR_CURVE "K\206ivka"
|
||||
#define TR_FLMODE "F\200ze"
|
||||
#define TR_FPHASE "F\200ze"
|
||||
#define TR_MIXWARNING "Varov\200n\204"
|
||||
#define TR_OFF "VYP"
|
||||
#define TR_MULTPX "Mat.Operace"
|
||||
|
||||
@@ -272,7 +272,7 @@
|
||||
#define LEN_VSWITCHES "\003"
|
||||
#define LEN_VSRCRAW "\004"
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
#if defined(PCBX9D)
|
||||
#define TR_POTS_VSRCRAW "S1\0 ""S2\0 ""LS\0 ""RS\0 " //4 Potis S1,S2,Links,Rechts
|
||||
#define TR_SW_VSRCRAW "SA\0 ""SB\0 ""SC\0 ""SD\0 ""SE\0 ""SF\0 ""SG\0 ""SH\0 "
|
||||
#elif defined(EXTRA_3POS)
|
||||
@@ -286,7 +286,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
#define TR_CUSTOMSW "PS1""PS2""PS3""PS4""PS5""PS6""PS7""PS8""PS9""PSA""PSB""PSC""PSD""PSE""PSF""PSG""PSH""PSI""PSJ""PSK""PSL""PSM""PSN""PSO""PSP""PSQ""PSR""PSS""PST""PSU""PSV""PSW"
|
||||
#define TR_CUSTOMSW "PS1""PS2""PS3""PS4""PS5""PS6""PS7""PS8""PS9""PSA""PSB""PSC""PSD""PSE""PSF""PSG""PSH""PSI""PSJ""PSK""PSL""PSM""PSN""PSO""PSP""PSQ""PSR""PSS""PST""PSU""PSV""PSW"
|
||||
#elif defined(PCBGRUVIN9X) || defined(CPUM128)
|
||||
#define TR_CUSTOMSW "PS1""PS2""PS3""PS4""PS5""PS6""PS7""PS8""PS9""PSA""PSB""PSC""PSD""PSE""PSF"
|
||||
#else
|
||||
@@ -325,7 +325,7 @@
|
||||
#define LEN_INDENT 1
|
||||
#define INDENT_WIDTH (FW/2)
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
#if defined(PCBX9D)
|
||||
#define TR_ENTER "[ENTER]"
|
||||
#else
|
||||
#define TR_ENTER "[MENU]"
|
||||
@@ -383,7 +383,7 @@
|
||||
#define TR_TRIM "Trim"
|
||||
#define TR_DREX "DRex"
|
||||
#define TR_CURVE "Kurve"
|
||||
#define TR_FLMODE TR("Phase","Phasen")
|
||||
#define TR_FPHASE TR("Phase","Phasen")
|
||||
#define TR_MIXWARNING "Warnung"
|
||||
#define TR_OFF "AUS"
|
||||
#define TR_MULTPX "Wirkung"
|
||||
|
||||
@@ -365,8 +365,8 @@
|
||||
#define TR_TTRACE TR("T-Source","Throttle Source")
|
||||
#define TR_TTRIM TR("T-Trim","Throttle Trim")
|
||||
#define TR_BEEPCTR TR("Ctr Beep","Center Beep")
|
||||
#define TR_PROTO TR(INDENT "Proto", INDENT "Protocol")
|
||||
#define TR_PPMFRAME TR("PPM frame", INDENT "PPM frame")
|
||||
#define TR_PROTO TR(INDENT"Proto",INDENT"Protocol")
|
||||
#define TR_PPMFRAME "PPM frame"
|
||||
#define TR_MS "ms"
|
||||
#define TR_SWITCH "Switch"
|
||||
#define TR_TRIMS "Trims"
|
||||
@@ -395,7 +395,7 @@
|
||||
#define TR_TRIM "Trim"
|
||||
#define TR_DREX "DRex"
|
||||
#define TR_CURVE "Curve"
|
||||
#define TR_FLMODE TR("Mode","Modes")
|
||||
#define TR_FPHASE TR("Mode","Modes")
|
||||
#define TR_MIXWARNING "Warning"
|
||||
#define TR_OFF "OFF"
|
||||
#define TR_MULTPX "Multpx"
|
||||
@@ -426,7 +426,7 @@
|
||||
#define TR_MEMORYWARNING INDENT"Memory Low"
|
||||
#define TR_ALARMWARNING INDENT"Sound Off"
|
||||
#define TR_RENAVIG "RotEnc Navig"
|
||||
#define TR_THROTTLEREVERSE TR("T-Reverse", "Throttle reverse")
|
||||
#define TR_THROTTLEREVERSE TR("Thr reverse","Throttle reverse")
|
||||
#define TR_MINUTEBEEP TR(INDENT"Minute",INDENT"Minute call")
|
||||
#define TR_BEEPCOUNTDOWN INDENT"Countdown"
|
||||
#define TR_PERSISTENT TR(INDENT"Persist.",INDENT"Persistent")
|
||||
@@ -590,6 +590,6 @@
|
||||
#define TR_CHANNELS_MONITOR "CHANNEL MONITOR"
|
||||
#define TR_INTERNALRF "Internal RF"
|
||||
#define TR_EXTERNALRF "External RF"
|
||||
#define TR_FAILSAFE INDENT "Failsafe mode"
|
||||
#define TR_FAILSAFE "Failsafe mode"
|
||||
#define TR_FAILSAFESET "FAILSAFE SETTINGS"
|
||||
#define TR_COUNTRYCODE "Country Code"
|
||||
|
||||
@@ -381,7 +381,7 @@
|
||||
#define TR_TRIM "Trim"
|
||||
#define TR_DREX "DRex"
|
||||
#define TR_CURVE "Curva"
|
||||
#define TR_FLMODE "Fase"
|
||||
#define TR_FPHASE "Fase"
|
||||
#define TR_MIXWARNING "Aviso"
|
||||
#define TR_OFF "OFF"
|
||||
#define TR_MULTPX "Multpx"
|
||||
|
||||
@@ -395,7 +395,7 @@
|
||||
#define TR_TRIM "Trim"
|
||||
#define TR_DREX "DRex"
|
||||
#define TR_CURVE "Courbe"
|
||||
#define TR_FLMODE TR("Phase","Phases")
|
||||
#define TR_FPHASE TR("Phase","Phases")
|
||||
#define TR_MIXWARNING "Alerte"
|
||||
#define TR_OFF "OFF"
|
||||
#define TR_MULTPX "Op\200ration"
|
||||
|
||||
@@ -380,7 +380,7 @@
|
||||
#define TR_TRIM "Trim"
|
||||
#define TR_DREX "DRex"
|
||||
#define TR_CURVE "Curva"
|
||||
#define TR_FLMODE "Fase"
|
||||
#define TR_FPHASE "Fase"
|
||||
#define TR_MIXWARNING "Avviso"
|
||||
#define TR_OFF "OFF"
|
||||
#define TR_MULTPX "MultPx"
|
||||
|
||||
@@ -359,7 +359,7 @@
|
||||
#define TR_TRIM "Trim"
|
||||
#define TR_DREX "DRex"
|
||||
#define TR_CURVE "Curvas"
|
||||
#define TR_FLMODE "Fase"
|
||||
#define TR_FPHASE "Fase"
|
||||
#define TR_MIXWARNING "Aviso"
|
||||
#define TR_OFF "OFF"
|
||||
#define TR_MULTPX "Aplicar"
|
||||
|
||||
@@ -354,7 +354,7 @@
|
||||
#define TR_LOADINGMODEL "Laddar Modell "
|
||||
#define TR_NAME "Namn"
|
||||
#define TR_MODELNAME "Modellnamn"
|
||||
#define TR_PHASENAME "Modnamn "
|
||||
#define TR_PHASENAME "Fasnamn "
|
||||
#define TR_MIXNAME "Mixnamn "
|
||||
#define TR_EXPONAME "Exponamn "
|
||||
#define TR_BITMAP "Modell-bild"
|
||||
@@ -395,7 +395,7 @@
|
||||
#define TR_TRIM "Trim"
|
||||
#define TR_DREX "DRex"
|
||||
#define TR_CURVE "Kurva"
|
||||
#define TR_FLMODE TR("Mod","Moder")
|
||||
#define TR_FPHASE TR("Fas","Faser")
|
||||
#define TR_MIXWARNING "Varning"
|
||||
#define TR_OFF "AV "
|
||||
#define TR_MULTPX "Multpx"
|
||||
@@ -494,8 +494,8 @@
|
||||
#define TR_TRIMS2OFFSETS "\004[Spara Trimv\201rden]"
|
||||
#define TR_MENUMODELSEL TR("Modell","V\201lj Modell")
|
||||
#define TR_MENUSETUP TR("V\201rden","Modellinst\201llningar")
|
||||
#define TR_MENUFLIGHTPHASE "Flygmod"
|
||||
#define TR_MENUFLIGHTPHASES "Flygmoder"
|
||||
#define TR_MENUFLIGHTPHASE "Flygfas"
|
||||
#define TR_MENUFLIGHTPHASES "Flygfaser"
|
||||
#define TR_MENUHELISETUP "Helikopter"
|
||||
|
||||
#if defined(PPM_CENTER_ADJUSTABLE) || defined(PPM_LIMITS_SYMETRICAL) // The right menu titles for the gurus ...
|
||||
|
||||
+4
-4
@@ -137,11 +137,11 @@ void doMainScreenGraphics()
|
||||
DO_CROSS(RBOX_CENTERX, RBOX_CENTERY, 3)
|
||||
|
||||
int16_t calibStickVert = calibratedStick[CONVERT_MODE(1+1)-1];
|
||||
if (g_model.throttleReversed && CONVERT_MODE(1+1)-1 == THR_STICK)
|
||||
if (g_eeGeneral.throttleReversed && CONVERT_MODE(1+1)-1 == THR_STICK)
|
||||
calibStickVert = -calibStickVert;
|
||||
lcd_square(LBOX_CENTERX+(calibratedStick[CONVERT_MODE(0+1)-1]*BOX_LIMIT/(2*RESX))-MARKER_WIDTH/2, LBOX_CENTERY-(calibStickVert*BOX_LIMIT/(2*RESX))-MARKER_WIDTH/2, MARKER_WIDTH, ROUND);
|
||||
calibStickVert = calibratedStick[CONVERT_MODE(2+1)-1];
|
||||
if (g_model.throttleReversed && CONVERT_MODE(2+1)-1 == THR_STICK)
|
||||
if (g_eeGeneral.throttleReversed && CONVERT_MODE(2+1)-1 == THR_STICK)
|
||||
calibStickVert = -calibStickVert;
|
||||
lcd_square(RBOX_CENTERX+(calibratedStick[CONVERT_MODE(3+1)-1]*BOX_LIMIT/(2*RESX))-MARKER_WIDTH/2, RBOX_CENTERY-(calibStickVert*BOX_LIMIT/(2*RESX))-MARKER_WIDTH/2, MARKER_WIDTH, ROUND);
|
||||
|
||||
@@ -263,11 +263,11 @@ void displayTopBar()
|
||||
x -= 12;
|
||||
}
|
||||
|
||||
if (TRAINER_CONNECTED() && SLAVE_MODE()) {
|
||||
if (SLAVE_MODE()) {
|
||||
LCD_NOTIF_ICON(x, ICON_TRAINEE);
|
||||
x -= 12;
|
||||
}
|
||||
else if (TRAINER_CONNECTED() && !SLAVE_MODE()) {
|
||||
else if (0) {
|
||||
LCD_NOTIF_ICON(x, ICON_TRAINER);
|
||||
x -= 12;
|
||||
}
|
||||
|
||||
+1
-1
@@ -372,7 +372,7 @@ if __name__ == "__main__":
|
||||
voice = "german"
|
||||
|
||||
for i in range(101):
|
||||
systemSounds.extend(generate(str(i), PROMPT_SYSTEM_BASE+i))
|
||||
systemSounds.extend(generate(str(i), i))
|
||||
systemSounds.extend(generate("tausend", PROMPT_SYSTEM_BASE+101))
|
||||
for i, s in enumerate(["comma", "und", "minus", "uhr", "minute", "minuten", "sekunde", "sekunden"]):
|
||||
systemSounds.extend(generate(s, PROMPT_SYSTEM_BASE+102+i))
|
||||
|
||||
Reference in New Issue
Block a user