[stock] TelemetrEZ board support

[stock] Flash saving again
[stock] Inactivity alarm / Light auto off should be again ok
[X9D] Mixer sources names / Switches names
This commit is contained in:
bsongis
2012-11-23 18:56:19 +00:00
parent 03751a1c75
commit 8220f84616
18 changed files with 279 additions and 204 deletions
+14 -1
View File
@@ -100,8 +100,13 @@ VOICE = NO
HAPTIC = NO
# SmartieParts 2.2 Backlight support (inverted)
# Values = YES, NO
SP22 = NO
# TelemetrEZ
# Values = YES, NO
TELEMETREZ = NO
# SPLASH on START
# Values = YES, NO, FIXED
SPLASH = YES
@@ -281,7 +286,7 @@ SRC =
STD_TTS_SRC = translations/tts_$(shell sh -c "echo $(TTS) | tr '[:upper:]' '[:lower:]'").cpp
TTS_SRC = $(shell sh -c "if test -f $(STD_TTS_SRC); then echo $(STD_TTS_SRC); else echo translations/tts_en.cpp; fi")
CPPSRC = open9x.cpp $(PULSESSRC) stamp.cpp menus.cpp model_menus.cpp general_menus.cpp main_views.cpp statistics_views.cpp $(EEPROMSRC) lcd.cpp drivers.cpp translations.cpp $(TTS_SRC)
CPPSRC = open9x.cpp $(PULSESSRC) stamp.cpp menus.cpp model_menus.cpp general_menus.cpp main_views.cpp statistics_views.cpp $(EEPROMSRC) lcd.cpp keys.cpp translations.cpp $(TTS_SRC)
ifeq ($(EXT), JETI)
CPPSRC += jeti.cpp
@@ -563,6 +568,10 @@ ifeq ($(PCB), STD128)
ifeq ($(SP22), YES)
CPPDEFS += -DSP22
endif
ifeq ($(TELEMETREZ), YES)
CPPDEFS += -DTELEMETREZ
endif
endif
ifeq ($(PCB), STD)
@@ -594,6 +603,10 @@ ifeq ($(PCB), STD)
ifeq ($(SP22), YES)
CPPDEFS += -DSP22
endif
ifeq ($(TELEMETREZ), YES)
CPPDEFS += -DTELEMETREZ
endif
endif
### Global Build-Option Directives ###
+1 -1
View File
@@ -56,7 +56,7 @@ void beep(uint8_t val)
haptic.event(val==0 ? AU_KEYPAD_UP : (val==4 ? AU_ERROR : AU_TIMER_10+beepAgain));
#endif
if(g_eeGeneral.flashBeep && val > 1 && g_LightOffCounter < FLASH_DURATION) g_LightOffCounter = FLASH_DURATION;
if (g_eeGeneral.flashBeep && val>1 && lightOffCounter<FLASH_DURATION) lightOffCounter = FLASH_DURATION;
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));
+2 -2
View File
@@ -69,7 +69,7 @@ extern void beep(uint8_t val);
#define AUDIO_TIMER_30() { beepAgain=2; beep(2); }
#define AUDIO_TIMER_20() { beepAgain=1; beep(2); }
#define AUDIO_TIMER_10() beep(2)
#define AUDIO_TIMER_LT3(x) beep(2)
#define AUDIO_TIMER_LT3(x) beep(2)
#define AUDIO_MINUTE_BEEP() beep(2)
#define AUDIO_INACTIVITY() beep(3)
#define AUDIO_MIX_WARNING_1() beep(1)
@@ -80,7 +80,7 @@ extern void beep(uint8_t val);
#define AUDIO_VARIO_DOWN() _beep(1)
#define AUDIO_TRIM(event, f) { if (!IS_KEY_FIRST(event)) warble = true; beep(1); }
#define AUDIO_TRIM_MIDDLE(f) beep(2)
#define AUDIO_TRIM_END(f) beep(2)
#define AUDIO_TRIM_END(f) beep(2)
#define AUDIO_PLAY(p) beep(3)
#define IS_AUDIO_BUSY() (g_beepCnt || beepAgain || beepOn)
+33 -11
View File
@@ -157,9 +157,8 @@ ISR(USART1_RX_vect)
}
}
}
#endif //EXTRA_ROTARY_ENCODERS
#endif
#endif // EXTRA_ROTARY_ENCODERS
#endif // !SIMU
uint8_t check_soft_power()
{
@@ -177,10 +176,7 @@ void soft_power_off()
#endif
}
#ifndef SIMU
FORCEINLINE
#endif
uint8_t keyDown()
FORCEINLINE uint8_t keyDown()
{
return (~PINL) & 0x3F;
}
@@ -239,10 +235,7 @@ bool keyState(EnumKeys enuk)
return result;
}
#ifndef SIMU
FORCEINLINE
#endif
void readKeysAndTrims()
FORCEINLINE void readKeysAndTrims()
{
/* Original keys were connected to PORTB as follows:
@@ -296,3 +289,32 @@ void readKeysAndTrims()
++enuk;
}
}
#if defined(ROTARY_ENCODERS)
#if !defined(EXTRA_ROTARY_ENCODERS)
ISR(INT2_vect)
{
uint8_t input = PIND & 0b00001100;
if (input == 0 || input == 0b00001100) incRotaryEncoder(0, -1);
}
ISR(INT3_vect)
{
uint8_t input = PIND & 0b00001100;
if (input == 0 || input == 0b00001100) incRotaryEncoder(0, +1);
}
#endif // !EXTRA_ROTARY_ENCODERS
ISR(INT5_vect)
{
uint8_t input = PINE & 0b01100000;
if (input == 0 || input == 0b01100000) incRotaryEncoder(1, +1);
}
ISR(INT6_vect)
{
uint8_t input = PINE & 0b01100000;
if (input == 0 || input == 0b01100000) incRotaryEncoder(1, -1);
}
#endif // ROTARY_ENCODERS
+60 -18
View File
@@ -50,6 +50,10 @@
#define BYTESTUFF 0x7d
#define STUFF_MASK 0x20
#if defined(TELEMETREZ)
#define PRIVATE 0x1B
#endif
uint8_t frskyRxBuffer[FRSKY_RX_PACKET_SIZE]; // Receive buffer. 9 bytes (full packet), worst case 18 bytes with byte-stuffing (+1)
uint8_t frskyTxBuffer[FRSKY_TX_PACKET_SIZE]; // Ditto for transmit buffer
#if !defined(PCBSKY9X)
@@ -392,11 +396,23 @@ void processFrskyPacket(uint8_t *packet)
FrskyRxBufferReady = 0;
}
// Receive buffer state machine state defs
#define frskyDataIdle 0
#define frskyDataStart 1
#define frskyDataInFrame 2
#define frskyDataXOR 3
// Receive buffer state machine state enum
enum FrSkyDataState {
STATE_DATA_IDLE,
STATE_DATA_START,
STATE_DATA_IN_FRAME,
STATE_DATA_XOR,
#if defined(TELEMETREZ)
STATE_DATA_PRIVATE_LEN,
STATE_DATA_PRIVATE_VALUE
#endif
};
#if defined(TELEMETREZ)
uint8_t privateDataLen;
uint8_t privateDataPos;
#endif
/*
Receive serial (RS-232) characters, detecting and storing each Fr-Sky
0x7e-framed packet as it arrives. When a complete packet has been
@@ -418,7 +434,7 @@ NOINLINE void processSerialData(uint8_t stat, uint8_t data)
#endif
{
static uint8_t numPktBytes = 0;
static uint8_t dataState = frskyDataIdle;
static uint8_t dataState = STATE_DATA_IDLE;
#if defined(BLUETOOTH)
// TODO if (g_model.bt_telemetry)
@@ -438,44 +454,70 @@ NOINLINE void processSerialData(uint8_t stat, uint8_t data)
{
switch (dataState)
{
case frskyDataStart:
case STATE_DATA_START:
if (data == START_STOP) break; // Remain in userDataStart if possible 0x7e,0x7e doublet found.
if (numPktBytes < FRSKY_RX_PACKET_SIZE)
frskyRxBuffer[numPktBytes++] = data;
dataState = frskyDataInFrame;
dataState = STATE_DATA_IN_FRAME;
break;
case frskyDataInFrame:
case STATE_DATA_IN_FRAME:
if (data == BYTESTUFF)
{
dataState = frskyDataXOR; // XOR next byte
dataState = STATE_DATA_XOR; // XOR next byte
break;
}
if (data == START_STOP) // end of frame detected
{
processFrskyPacket(frskyRxBuffer); // FrskyRxBufferReady = 1;
dataState = frskyDataIdle;
dataState = STATE_DATA_IDLE;
break;
}
if (numPktBytes < FRSKY_RX_PACKET_SIZE)
frskyRxBuffer[numPktBytes++] = data;
break;
case frskyDataXOR:
case STATE_DATA_XOR:
if (numPktBytes < FRSKY_RX_PACKET_SIZE)
frskyRxBuffer[numPktBytes++] = data ^ STUFF_MASK;
dataState = frskyDataInFrame;
dataState = STATE_DATA_IN_FRAME;
break;
case frskyDataIdle:
if (data == START_STOP)
{
case STATE_DATA_IDLE:
if (data == START_STOP) {
numPktBytes = 0;
dataState = frskyDataStart;
dataState = STATE_DATA_START;
}
#if defined(TELEMETREZ)
if (data == PRIVATE) {
dataState = STATE_DATA_PRIVATE_LEN;
}
#endif
break;
#if defined(TELEMETREZ)
case STATE_DATA_PRIVATE_LEN:
dataState = STATE_DATA_PRIVATE_VALUE;
privateDataLen = data; // Count of bytes to receive
privateDataPos = 0;
break;
case STATE_DATA_PRIVATE_VALUE :
if (privateDataPos++ == 0) {
// process first private data byte
// PC6, PC7
if ((data & 0x3F) == 0) // check byte is valid
{
DDRC |= 0xC0; // set as outputs
PORTC = ( PORTC & 0x3F ) | ( data & 0xC0 ); // update outputs
}
}
if (privateDataPos == privateDataLen) {
dataState = STATE_DATA_IDLE;
}
break;
#endif
} // switch
} // if (FrskyRxBufferReady == 0)
}
+8 -4
View File
@@ -44,7 +44,9 @@ enum EnumTabDiag {
e_Vers,
e_Keys,
e_Ana,
#if !defined(PCBX9D) // TODO
IF_PCBSKY9X(e_Hardware)
#endif
e_Calib
};
@@ -66,7 +68,9 @@ const MenuFuncP_PROGMEM menuTabDiag[] PROGMEM = {
menuGeneralVersion,
menuGeneralDiagKeys,
menuGeneralDiagAna,
#if !defined(PCBX9D) // TODO
IF_PCBSKY9X(menuGeneralHardware)
#endif
menuGeneralCalib
};
@@ -140,7 +144,7 @@ void menuGeneralSetup(uint8_t event)
}
#endif
MENU(STR_MENURADIOSETUP, menuTabDiag, e_Setup, ITEM_SETUP_MAX+1, {0, IF_RTCLOCK(2) IF_RTCLOCK(2) (uint8_t)-1, 0, 0, IF_AUDIO(0) IF_VOICE(0) IF_HAPTIC((uint8_t)-1) IF_HAPTIC(0) IF_HAPTIC(0) IF_HAPTIC(0) IF_PCBSKY9X(0) 0, (uint8_t)-1, 0, IF_PCBSKY9X(0) IF_PCBSKY9X(0) 0, 0, 0, IF_ROTARY_ENCODERS(0) 0, 0, (uint8_t)-1, 0, 0, (uint8_t)-1, 0, 0, 0, IF_SPLASH(0) IF_FRSKY(0) IF_FRSKY(0) 0, (uint8_t)-1, 1});
MENU(STR_MENURADIOSETUP, menuTabDiag, e_Setup, ITEM_SETUP_MAX+1, {0, IF_RTCLOCK(2) IF_RTCLOCK(2) (uint8_t)-1, 0, 0, IF_AUDIO(0) IF_VOICE(0) IF_HAPTIC((uint8_t)-1) IF_HAPTIC(0) IF_HAPTIC(0) IF_HAPTIC(0) IF_PCBSKY9X(0) 0, (uint8_t)-1, 0, IF_PCBSKY9X(0) IF_PCBSKY9X(0) 0, 0, 0, IF_ROTARY_ENCODERS(0) 0, 0, (uint8_t)-1, 0, 0, (uint8_t)-1, 0, 0, 0, IF_SPLASH(0) IF_FRSKY(0) IF_FRSKY(0) 0, (uint8_t)-1, IF_PCBX9D(0) 1/*to force edit mode*/});
uint8_t sub = m_posVert - 1;
@@ -352,9 +356,9 @@ void menuGeneralSetup(uint8_t event)
if(attr) g_eeGeneral.inactivityTimer = checkIncDec(event, g_eeGeneral.inactivityTimer, 0, 250, EE_GENERAL); //0..250minutes
break;
#if defined(ROTARY_ENCODERS)
#if defined(ROTARY_ENCODERS) && NUM_ROTARY_ENCODERS > 0
case ITEM_SETUP_RE_NAVIGATION:
g_eeGeneral.reNavigation = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_RENAVIG, STR_VRENAVIG, g_eeGeneral.reNavigation, 0, ROTARY_ENCODERS, attr, event);
g_eeGeneral.reNavigation = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_RENAVIG, STR_VRENAVIG, g_eeGeneral.reNavigation, 0, NUM_ROTARY_ENCODERS, attr, event);
if (attr && checkIncDec_Ret) {
for (uint8_t i=0; i<ROTARY_ENCODERS; i++)
g_rotenc[i] = 0;
@@ -908,7 +912,7 @@ void menuGeneralDiagAna(uint8_t event)
#endif
}
#if defined(PCBSKY9X)
#if defined(PCBSKY9X) && !defined(PCBX9D)
enum menuGeneralHwItems {
ITEM_SETUP_HW_OPTREX_DISPLAY,
IF_BLUETOOTH(ITEM_SETUP_HW_BT_BAUDRATE)
+9 -43
View File
@@ -146,51 +146,17 @@ void killEvents(uint8_t event)
if (event < (int)DIM(keys)) keys[event].killEvents();
}
volatile tmr10ms_t g_tmr10ms;
volatile uint8_t g_blinkTmr10ms;
volatile uint8_t rtc_count=0;
void per10ms()
void clearKeyEvents()
{
g_tmr10ms++;
g_blinkTmr10ms++;
if (s_noHi) s_noHi--;
if (trimsCheckTimer) trimsCheckTimer --;
#if defined (PCBSKY9X)
Tenms |= 1 ; // 10 mS has passed
#if defined(PCBSKY9X)
CoTickDelay(100); // 200ms
#endif
#if defined(RTCLOCK)
/* Update global Date/Time every 100 per10ms cycles */
if (++g_ms100 == 100) {
g_rtcTime++; // inc global unix timestamp one second
#if defined (PCBSKY9X)
if (g_rtcTime < 60 || rtc_count<5) {
rtc_init();
rtc_count++;
} else {
read_coprocessor(true);
}
#endif
g_ms100 = 0;
}
#if defined(SIMU)
while (keyDown() && main_thread_running) sleep(1/*ms*/);
#else
while (keyDown()) wdt_reset(); // loop until all keys are up
#endif
readKeysAndTrims();
#if defined(MAVLINK) && !defined(PCBSKY9X)
check_mavlink();
#endif
#if defined (FRSKY) && !defined(PCBSKY9X) && !(defined(PCBSTD) && (defined(AUDIO) || defined(VOICE)))
check_frsky();
#endif
// These moved here from perOut() to improve beep trigger reliability.
if(mixWarning & 1) if(((g_tmr10ms&0xFF)== 0)) AUDIO_MIX_WARNING_1();
if(mixWarning & 2) if(((g_tmr10ms&0xFF)== 64) || ((g_tmr10ms&0xFF)== 72)) AUDIO_MIX_WARNING_2();
if(mixWarning & 4) if(((g_tmr10ms&0xFF)==128) || ((g_tmr10ms&0xFF)==136) || ((g_tmr10ms&0xFF)==144)) AUDIO_MIX_WARNING_3();
memclear(keys, sizeof(keys));
putEvent(0);
}
+18 -9
View File
@@ -524,24 +524,33 @@ void putsChnRaw(xcoord_t x, uint8_t y, uint8_t idx, uint8_t att)
{
if (idx==0)
lcd_putsiAtt(x, y, STR_MMMINV, 0, att);
else if (idx<=NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+2+NUM_CYC)
else if (idx<=NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+1+NUM_SW_SRCRAW+NUM_CYC)
lcd_putsiAtt(x, y, STR_VSRCRAW, idx-1, att);
else if (idx<=NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+2+NUM_CYC+NUM_PPM)
putsStrIdx(x, y, STR_PPM, idx - (NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+2+NUM_CYC), att);
else if (idx<=NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+2+NUM_CYC+NUM_PPM+NUM_CHNOUT)
putsStrIdx(x, y, STR_CH, idx - (NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+2+NUM_CYC+NUM_PPM), att);
else if (idx<=NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+1+NUM_SW_SRCRAW+NUM_CYC+NUM_PPM)
putsStrIdx(x, y, STR_PPM, idx - (NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+1+NUM_SW_SRCRAW+NUM_CYC), att);
else if (idx<=NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+1+NUM_SW_SRCRAW+NUM_CYC+NUM_PPM+NUM_CHNOUT)
putsStrIdx(x, y, STR_CH, idx - (NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+1+NUM_SW_SRCRAW+NUM_CYC+NUM_PPM), att);
else
lcd_putsiAtt(x, y, STR_VTELEMCHNS, idx-(NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+2+NUM_CYC+NUM_PPM+NUM_CHNOUT), att);
lcd_putsiAtt(x, y, STR_VTELEMCHNS, idx-(NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+1+NUM_SW_SRCRAW+NUM_CYC+NUM_PPM+NUM_CHNOUT), att);
}
void putsMixerSource(xcoord_t x, uint8_t y, uint8_t idx, uint8_t att)
{
if (idx<=NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+2)
#if defined(PCBX9D)
if (idx<=NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+1+NUM_SW_SRCRAW)
putsChnRaw(x, y, idx, att);
else if (idx<=NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+2+MAX_SWITCH)
putsSwitches(x, y, idx-NUM_STICKS-NUM_POTS-NUM_ROTARY_ENCODERS-NUM_STICKS-2, att);
else if (idx<=NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+1+NUM_SW_SRCRAW+NUM_CSW)
putsSwitches(x, y, MAX_PSWITCH + idx-(NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+1+NUM_SW_SRCRAW), att);
else
putsChnRaw(x, y, idx-NUM_CSW, att);
#else
if (idx<=NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+1+NUM_SW_SRCRAW)
putsChnRaw(x, y, idx, att);
else if (idx<=NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+1+NUM_SW_SRCRAW+MAX_SWITCH)
putsSwitches(x, y, idx-(NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+1+NUM_SW_SRCRAW), att);
else
putsChnRaw(x, y, idx-MAX_SWITCH, att);
#endif
}
void putsChnLetter(xcoord_t x, uint8_t y, uint8_t idx, uint8_t attr)
+1 -2
View File
@@ -143,7 +143,7 @@ void putsRotaryEncoderMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, ui
#endif
extern void putsChnRaw(xcoord_t x,uint8_t y,uint8_t idx1,uint8_t att);
#define putsChn(x, y, idx, att) putsChnRaw(x, y, (idx)+(NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+2+NUM_CYC+NUM_PPM), att)
#define putsChn(x, y, idx, att) putsChnRaw(x, y, (idx)+(NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+1+NUM_SW_SRCRAW+NUM_CYC+NUM_PPM), att)
extern void putsChnLetter(xcoord_t x, uint8_t y, uint8_t idx, uint8_t attr);
extern void putsVolts(xcoord_t x, uint8_t y, uint16_t volts, uint8_t att);
@@ -195,7 +195,6 @@ extern void lcdSetContrast();
extern void refreshDisplay();
#define BLINK_ON_PHASE (g_blinkTmr10ms & (1<<6))
#define BLINK_SYNC g_blinkTmr10ms = (3<<5)
#ifdef SIMU
extern bool lcd_refresh;
+12 -9
View File
@@ -270,7 +270,7 @@ void title(const pm_char * s)
#if defined(PCBX9D)
#define RE_NAV_ENTER (KEY_ENTER)
#define RE_NAV_ENABLE true
#define SCROLL(min, val, max) ((val) > (max) ? ((min) + (val) - (max) - 1) : ((val) < (min) ? ((max) - (min) + (val) - 1) : (val)))
#define SCROLL(min, val, max) (int8_t(val) > int8_t(max) ? (int8_t(min) + int8_t(val) - int8_t(max) - 1) : (int8_t(val) < int8_t(min) ? (int8_t(max) - int8_t(min) + int8_t(val) + 1) : int8_t(val)))
#else
#define RE_NAV_ENTER (BTN_REa+g_eeGeneral.reNavigation-1)
#define RE_NAV_ENABLE g_eeGeneral.reNavigation
@@ -285,12 +285,20 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
uint8_t maxcol = MAXCOL(l_posVert);
#if defined(ROTARY_ENCODERS)
#if defined(PCBX9D)
if (!(s_warning || s_menu_count || s_editMode<0))
CHECK_ROTARY_ENCODER(event);
#else
if (!(s_warning || s_menu_count))
CHECK_ROTARY_ENCODER(event);
#endif
if (l_posVert < 0 && (event==EVT_KEY_BREAK(RE_NAV_ENTER) || event==EVT_KEY_BREAK(KEY_MENU))) {
popMenu();
return false;
}
if (RE_NAV_ENABLE && event==EVT_KEY_BREAK(RE_NAV_ENTER)) {
if (s_editMode > 0 && (maxcol & ZCHAR)) {
if (l_posHorz < maxcol-ZCHAR) {
@@ -346,7 +354,9 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
int8_t cc = curr;
if (scrollLR || (scrollRE && s_editMode < 0)) {
cc = SCROLL((int8_t)0, (int8_t)(curr - scrollLR + scrollRE), (int8_t)(menuTabSize-1));
printf("tab size=%d cur=%d scrollLR=%d scrollRE=%d\n", menuTabSize, cc, scrollLR, scrollRE); fflush(stdout);
cc = SCROLL((int8_t)0, (int8_t)(cc - scrollLR + scrollRE), (int8_t)(menuTabSize-1));
printf("cc=%d\n", cc); fflush(stdout);
}
switch(event) {
@@ -396,12 +406,10 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
if (scrollUD) {
l_posVert = limit((int8_t)0, (int8_t)(l_posVert - scrollUD), (int8_t)maxrow);
l_posHorz = min(l_posHorz, MAXCOL(l_posVert));
BLINK_SYNC;
}
if (scrollLR && l_posVert>0) {
l_posHorz = limit((int8_t)0, (int8_t)(l_posHorz - scrollLR), (int8_t)maxcol);
BLINK_SYNC;
}
#if defined(ROTARY_ENCODERS)
@@ -509,7 +517,6 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
AUDIO_MENUS();
l_posVert = 0;
l_posHorz = 0;
BLINK_SYNC;
}
break;
@@ -520,7 +527,6 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
case EVT_KEY_FIRST(KEY_RIGHT)://inc
if (!horTab || s_editMode>0) break;
INC(l_posHorz, maxcol);
BLINK_SYNC;
break;
case EVT_KEY_REPT(KEY_LEFT): //dec
if (l_posHorz==0) break;
@@ -528,7 +534,6 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
case EVT_KEY_FIRST(KEY_LEFT)://dec
if (!horTab || s_editMode>0) break;
DEC(l_posHorz, maxcol);
BLINK_SYNC;
break;
case EVT_KEY_REPT(KEY_DOWN): //inc
if (l_posVert==maxrow) break;
@@ -542,7 +547,6 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
s_editMode = 0;
#endif
l_posHorz = min(l_posHorz, MAXCOL(l_posVert));
BLINK_SYNC;
break;
case EVT_KEY_REPT(KEY_UP): //dec
if (l_posVert==0) break;
@@ -553,7 +557,6 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
DEC(l_posVert, maxrow);
} while(MAXCOL(l_posVert) == (uint8_t)-1);
l_posHorz = min(l_posHorz, MAXCOL(l_posVert));
BLINK_SYNC;
break;
#endif
}
+3 -3
View File
@@ -1005,7 +1005,7 @@ void menuModelPhaseOne(uint8_t event)
}
break;
#if defined(ROTARY_ENCODERS)
#if defined(ROTARY_ENCODERS) && NUM_ROTARY_ENCODERS > 0
case ITEM_MODEL_PHASE_ROTARY_ENCODERS:
lcd_putsLeft(y, STR_ROTARY_ENCODER);
for (uint8_t t=0; t<NUM_ROTARY_ENCODERS; t++) {
@@ -1754,8 +1754,8 @@ void menuModelMixOne(uint8_t event)
putsChn(lcdLastPos+1*FW,0,md2->destCh+1,0);
#if defined(ROTARY_ENCODERS)
if (m_posVert == MIX_FIELD_TRIM && md2->srcRaw > NUM_STICKS)
SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_PCBSKY9X(ZCHAR|(sizeof(md2->name)-1)) 0, 0, 0, 0, IF_CURVES(1) 0, IF_FLIGHT_PHASES(MAX_PHASES-1) 0 /*, ...*/})
if ((m_posVert == MIX_FIELD_TRIM && md2->srcRaw > NUM_STICKS) || (m_posVert == MIX_FIELD_CURVE && md2->curveMode == MODE_CURVE))
SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_PCBSKY9X(ZCHAR|(sizeof(md2->name)-1)) 0, 0, 0, 0, IF_CURVES(0) 0, IF_FLIGHT_PHASES(MAX_PHASES-1) 0 /*, ...*/})
else
SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_PCBSKY9X(ZCHAR|(sizeof(md2->name)-1)) 0, 0, 0, 1, IF_CURVES(1) 0, IF_FLIGHT_PHASES(MAX_PHASES-1) 0 /*, ...*/});
#else
+69 -74
View File
@@ -169,6 +169,63 @@ uint8_t zlen(const char *str, uint8_t size)
}
#endif
volatile tmr10ms_t g_tmr10ms;
#if defined(PCBSKY9X)
volatile uint8_t rtc_count=0;
#endif
void per10ms()
{
g_tmr10ms++;
if (lightOffCounter) lightOffCounter--;
if (s_noHi) s_noHi--;
if (trimsCheckTimer) trimsCheckTimer --;
if ((g_blinkTmr10ms & 0x1F) == 0) {
inacCounter++;
if ((((uint8_t)inacCounter)&0x0F)==0x01 && g_eeGeneral.inactivityTimer && g_vbat100mV>50 && inacCounter > ((uint16_t)g_eeGeneral.inactivityTimer*187))
AUDIO_INACTIVITY();
}
#if defined (PCBSKY9X)
Tenms |= 1 ; // 10 mS has passed
#endif
#if defined(RTCLOCK)
/* Update global Date/Time every 100 per10ms cycles */
if (++g_ms100 == 100) {
g_rtcTime++; // inc global unix timestamp one second
#if defined (PCBSKY9X)
if (g_rtcTime < 60 || rtc_count<5) {
rtc_init();
rtc_count++;
}
else {
read_coprocessor(true);
}
#endif
g_ms100 = 0;
}
#endif
readKeysAndTrims();
#if defined(MAVLINK) && !defined(PCBSKY9X)
check_mavlink();
#endif
#if defined (FRSKY) && !defined(PCBSKY9X) && !(defined(PCBSTD) && (defined(AUDIO) || defined(VOICE)))
check_frsky();
#endif
// These moved here from perOut() to improve beep trigger reliability.
if(mixWarning & 1) if(((g_tmr10ms&0xFF)== 0)) AUDIO_MIX_WARNING_1();
if(mixWarning & 2) if(((g_tmr10ms&0xFF)== 64) || ((g_tmr10ms&0xFF)== 72)) AUDIO_MIX_WARNING_2();
if(mixWarning & 4) if(((g_tmr10ms&0xFF)==128) || ((g_tmr10ms&0xFF)==136) || ((g_tmr10ms&0xFF)==144)) AUDIO_MIX_WARNING_3();
}
PhaseData *phaseaddress(uint8_t idx)
{
return &g_model.phaseData[idx];
@@ -1034,22 +1091,7 @@ void putsTelemetryValue(uint8_t x, uint8_t y, int16_t val, uint8_t unit, uint8_t
}
#endif
void clearKeyEvents()
{
#if defined(PCBSKY9X)
CoTickDelay(100); // 200ms
#endif
#if defined(SIMU)
while (keyDown() && main_thread_running) sleep(1/*ms*/);
#else
while (keyDown()) wdt_reset(); // loop until all keys are up
#endif
memclear(keys, sizeof(keys));
putEvent(0);
}
#define INAC_DEVISOR 256 // Bypass splash screen with stick movement
#define INAC_DEVISOR 1024 // Bypass splash screen with stick movement
uint16_t stickMoveValue()
{
uint16_t sum = 0;
@@ -1063,7 +1105,7 @@ void checkBacklight()
static uint8_t tmr10ms ;
if (tmr10ms != g_blinkTmr10ms) {
tmr10ms = g_blinkTmr10ms ;
tmr10ms = g_blinkTmr10ms;
uint16_t tsum = stickMoveValue();
if (tsum != inacSum) {
inacSum = tsum;
@@ -1071,16 +1113,8 @@ void checkBacklight()
if (g_eeGeneral.backlightMode & e_backlight_mode_sticks)
backlightOn();
}
else if (g_eeGeneral.inactivityTimer && (!g_vbat100mV || g_vbat100mV>50)) {
if (++inacPrescale > 15 ) {
inacCounter++;
inacPrescale = 0;
if (inacCounter > ((uint16_t)g_eeGeneral.inactivityTimer*25*15))
if ((inacCounter&0x1F)==1) AUDIO_INACTIVITY();
}
}
if (g_eeGeneral.backlightMode == e_backlight_mode_on || g_LightOffCounter || isFunctionActive(FUNC_BACKLIGHT))
if (g_eeGeneral.backlightMode == e_backlight_mode_on || lightOffCounter || isFunctionActive(FUNC_BACKLIGHT))
BACKLIGHT_ON();
else
BACKLIGHT_OFF();
@@ -1093,7 +1127,7 @@ void checkBacklight()
void backlightOn()
{
g_LightOffCounter = ((uint16_t)g_eeGeneral.lightAutoOff*250) << 1;
lightOffCounter = ((uint16_t)g_eeGeneral.lightAutoOff*250) << 1;
}
#if defined(SPLASH)
@@ -1119,10 +1153,8 @@ void doSplash()
lcdSetRefVolt(contrast);
#endif
#if !defined(SIMU)
for (uint8_t i=0; i<32; i++)
getADC_filt(); // init ADC array
#endif
uint16_t inacSum = stickMoveValue();
@@ -1130,11 +1162,11 @@ void doSplash()
while (tgtime != get_tmr10ms())
{
#if defined(SIMU)
if (!main_thread_running) return;
sleep(1/*ms*/);
SIMU_SLEEP(1);
#elif defined(PCBSKY9X)
CoTickDelay(1);
#endif
getADC_filt();
uint16_t tsum = stickMoveValue();
@@ -1207,12 +1239,10 @@ void checkTHR()
while (1)
{
#ifdef SIMU
if (!main_thread_running) return;
sleep(1/*ms*/);
#else
SIMU_SLEEP(1);
getADC_single();
#endif
int16_t v = thrAnaIn(thrchn);
if (check_soft_power() > e_power_trainer || v<=lowLim || keyDown())
@@ -1265,10 +1295,7 @@ void checkSwitches()
wdt_reset();
#ifdef SIMU
if (!main_thread_running) return;
sleep(1/*ms*/);
#endif
SIMU_SLEEP(1);
}
}
@@ -1278,11 +1305,7 @@ void alert(const pm_char * t, const pm_char *s MESSAGE_SOUND_ARG)
while(1)
{
#ifdef SIMU
if (!main_thread_running) return;
sleep(1/*ms*/);
#endif
SIMU_SLEEP(1);
if (check_soft_power() >= e_power_usb) return; // Usb on or power off
@@ -1634,7 +1657,7 @@ void getADC_bandgap()
#endif // SIMU
uint8_t g_vbat100mV = 0;
uint16_t g_LightOffCounter;
uint16_t lightOffCounter;
uint16_t s_timeCumTot;
uint16_t s_timeCumThr; // THR in 1/16 sec
@@ -2886,7 +2909,6 @@ void perMain()
evt = checkTrim(evt);
#endif
if (g_LightOffCounter) g_LightOffCounter--;
if (evt && (g_eeGeneral.backlightMode & e_backlight_mode_keys)) backlightOn(); // on keypress turn the light on
checkBacklight();
@@ -3245,33 +3267,6 @@ volatile rotenc_t g_rotenc[ROTARY_ENCODERS] = {0};
#ifndef SIMU
#if defined(PCBGRUVIN9X) && defined(ROTARY_ENCODERS)
#if !defined(EXTRA_ROTARY_ENCODERS)
ISR(INT2_vect)
{
uint8_t input = PIND & 0b00001100;
if (input == 0 || input == 0b00001100) incRotaryEncoder(0, -1);
}
ISR(INT3_vect)
{
uint8_t input = PIND & 0b00001100;
if (input == 0 || input == 0b00001100) incRotaryEncoder(0, +1);
}
#endif //!EXTRA_ROTARY_ENCODERS
ISR(INT5_vect)
{
uint8_t input = PINE & 0b01100000;
if (input == 0 || input == 0b01100000) incRotaryEncoder(1, +1);
}
ISR(INT6_vect)
{
uint8_t input = PINE & 0b01100000;
if (input == 0 || input == 0b01100000) incRotaryEncoder(1, -1);
}
#endif //PCBGRUVIN9X+ROTARY_ENCODERS
#if defined(PCBSKY9X)
void stack_paint()
{
+36 -19
View File
@@ -48,6 +48,12 @@
#define IF_PCBSKY9X(x)
#endif
#if defined(PCBX9D)
#define IF_PCBX9D(x) x,
#else
#define IF_PCBX9D(x)
#endif
#if defined(RTCLOCK)
#define IF_RTCLOCK(x) x,
#else
@@ -96,12 +102,6 @@
#define IF_SDCARD(x)
#endif
#if defined(ROTARY_ENCODERS)
#define IF_ROTARY_ENCODERS(x) x,
#else
#define IF_ROTARY_ENCODERS(x)
#endif
#if defined(BLUETOOTH)
#define IF_BLUETOOTH(x) x,
#else
@@ -190,6 +190,12 @@ extern void board_init();
#include "myeeprom.h"
#if defined(ROTARY_ENCODERS) && NUM_ROTARY_ENCODERS > 0
#define IF_ROTARY_ENCODERS(x) x,
#else
#define IF_ROTARY_ENCODERS(x)
#endif
#define PPM_CENTER 1500
#if defined(PCBSKY9X)
@@ -557,15 +563,18 @@ enum CswFunctions {
#define CS_VDIFF 3
#define CS_STATE(x) ((x)<CS_AND ? CS_VOFS : ((x)<CS_EQUAL ? CS_VBOOL : ((x)<CS_DIFFEGREATER ? CS_VCOMP : CS_VDIFF)))
#define NUM_STICKS 4
#define NUM_STICKS 4
#if defined(PCBX9D)
#define MAX_PSWITCH (SW_SH-SW_SA+1)
#define NUM_POTS 4
#define NUM_POTS 4
#define NUM_SW_SRCRAW 8
#else
#define MAX_PSWITCH (SW_Trainer-SW_ThrCt+1) // 9 physical switches
#define NUM_POTS 3
#define NUM_POTS 3
#define NUM_SW_SRCRAW 1
#endif
#define MAX_SWITCH (MAX_PSWITCH+NUM_CSW)
#define SWITCH_ON (1+MAX_SWITCH)
#define SWITCH_OFF (-SWITCH_ON)
@@ -598,10 +607,17 @@ enum CswFunctions {
#define NUM_TELEMETRY TELEM_TM2
#endif
#define NUM_XCHNRAW (NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+1/*MAX*/+1/*ID3*/+NUM_CYC+NUM_PPM+NUM_CHNOUT)
#define NUM_XCHNCSW (NUM_XCHNRAW+NUM_TELEMETRY)
#define NUM_XCHNRAW (NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+1/*MAX*/+NUM_SW_SRCRAW+NUM_CYC+NUM_PPM+NUM_CHNOUT)
#if defined(PCBX9D)
#define NUM_XCHNMIX (NUM_XCHNRAW+NUM_CSW)
#define NUM_XCHNCSW (NUM_XCHNRAW+NUM_CSW+NUM_TELEMETRY)
#define NUM_XCHNPLAY (NUM_XCHNRAW+NUM_CSW+TELEM_DISPLAY_MAX)
#else
#define NUM_XCHNMIX (NUM_XCHNRAW+MAX_SWITCH)
#define NUM_XCHNCSW (NUM_XCHNRAW+NUM_TELEMETRY)
#define NUM_XCHNPLAY (NUM_XCHNRAW+TELEM_DISPLAY_MAX)
#endif
#define DSW_THR 1
#define DSW_RUD 2
@@ -720,12 +736,13 @@ enum PerOutMode {
e_perout_mode_noinput = e_perout_mode_notrainer+e_perout_mode_notrims+e_perout_mode_nosticks
};
#ifndef FORCEINLINE
#ifdef SIMU
#define FORCEINLINE
#define NOINLINE
#else
#define FORCEINLINE inline __attribute__ ((always_inline))
#endif
#ifndef NOINLINE
#define NOINLINE __attribute__ ((noinline))
#define SIMU_SLEEP(x)
#endif
// Fiddle to force compiler to use a pointer
@@ -1025,7 +1042,7 @@ extern const char stamp3[];
extern const char eeprom_stamp[];
extern uint8_t g_vbat100mV;
extern volatile uint8_t g_blinkTmr10ms;
#define g_blinkTmr10ms (*(uint8_t*)&g_tmr10ms)
extern uint8_t g_beepCnt;
extern uint8_t g_beepVal[5];
@@ -1047,10 +1064,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 50
#define FLASH_DURATION 50 /*500ms*/
extern uint8_t beepAgain;
extern uint16_t g_LightOffCounter;
extern uint8_t beepAgain;
extern uint16_t lightOffCounter;
extern uint8_t mixWarning;
extern PhaseData *phaseaddress(uint8_t idx);
+4
View File
@@ -263,6 +263,8 @@ extern void rxPdcUsart( void (*pChProcess)(uint8_t x) );
#define UPE0 0
#define FE0 0
#define ISR(x) void x()
#if defined(PCBSKY9X)
extern volatile uint32_t Tenms;
extern uint32_t Master_frequency;
@@ -282,6 +284,8 @@ extern uint8_t main_thread_running;
#define getADC_osmp()
#define getADC_bandgap()
#define SIMU_SLEEP(x) do { if (!main_thread_running) return; sleep(x/*ms*/); } while (0)
extern void setSwitch(int8_t swtch);
void StartMainThread(bool tests=true);
+2 -3
View File
@@ -559,8 +559,8 @@ void audioEvent(uint8_t e, uint8_t f)
#endif
if (g_eeGeneral.flashBeep && (e <= AU_ERROR || e >= AU_WARNING1)) {
if (g_LightOffCounter < FLASH_DURATION)
g_LightOffCounter = FLASH_DURATION;
if (lightOffCounter < FLASH_DURATION)
lightOffCounter = FLASH_DURATION;
}
if (g_eeGeneral.beeperMode>0 || (g_eeGeneral.beeperMode==0 && e>=AU_TRIM_MOVE) || (g_eeGeneral.beeperMode>=-1 && e<=AU_ERROR)) {
@@ -575,7 +575,6 @@ void audioEvent(uint8_t e, uint8_t f)
// inactivity timer alert
case AU_INACTIVITY:
audioQueue.play(70, 20, 4, 2|PLAY_NOW);
audioQueue.pause(200);
break;
// low battery in tx
case AU_TX_BATTERY_LOW:
+3 -3
View File
@@ -134,7 +134,7 @@ void audioQueue::play(uint8_t tFreq, uint8_t tLen, uint8_t tPause,
tFreq += g_eeGeneral.speakerPitch + BEEP_OFFSET; // add pitch compensator
}
tLen = getToneLength(tLen);
if (tFlags & PLAY_NOW || (!busy() && empty())) {
if ((tFlags & PLAY_NOW) || (!busy() && empty())) {
toneFreq = tFreq;
toneTimeLeft = tLen;
tonePause = tPause;
@@ -167,8 +167,8 @@ void audioQueue::event(uint8_t e, uint8_t f)
#endif
if (g_eeGeneral.flashBeep && (e <= AU_ERROR || e >= AU_WARNING1)) {
if (g_LightOffCounter < FLASH_DURATION)
g_LightOffCounter = FLASH_DURATION;
if (lightOffCounter < FLASH_DURATION)
lightOffCounter = FLASH_DURATION;
}
if (g_eeGeneral.beeperMode>0 || (g_eeGeneral.beeperMode==0 && e>=AU_TRIM_MOVE) || (g_eeGeneral.beeperMode>=-1 && e<=AU_ERROR)) {
+1 -1
View File
@@ -37,7 +37,7 @@
#endif
//audio
#define AUDIO_QUEUE_LENGTH (8) //8 seems to suit most alerts
#define AUDIO_QUEUE_LENGTH (8) // 8 seems to suit most alerts
#define BEEP_DEFAULT_FREQ (70)
#define BEEP_OFFSET (10)
#define BEEP_KEY_UP_FREQ (BEEP_DEFAULT_FREQ+5)
+3 -1
View File
@@ -210,8 +210,10 @@
#define LEN_VSRCRAW "\004"
#if defined(PCBX9D)
#define TR_POTS_VSRCRAW "S1\0 ""S2\0 ""S3\0 ""S4\0 "
#define TR_SW_VSRCRAW "SA\0 ""SB\0 ""SC\0 ""SD\0 ""SE\0 ""SF\0 ""SG\0 ""SH\0 "
#else
#define TR_POTS_VSRCRAW "P1\0 ""P2\0 ""P3\0 "
#define TR_SW_VSRCRAW "3POS"
#endif
#if defined(PCBX9D)
#define TR_ROTARY_ENCODERS_VSRCRAW
@@ -229,7 +231,7 @@
#else
#define TR_CYC_VSRCRAW "[C1]""[C2]""[C3]"
#endif
#define TR_VSRCRAW "Rud\0""Ele\0""Thr\0""Ail\0" TR_POTS_VSRCRAW TR_ROTARY_ENCODERS_VSRCRAW "TrmR" "TrmE" "TrmT" "TrmA" "MAX ""3POS" TR_CYC_VSRCRAW
#define TR_VSRCRAW "Rud\0""Ele\0""Thr\0""Ail\0" TR_POTS_VSRCRAW TR_ROTARY_ENCODERS_VSRCRAW "TrmR" "TrmE" "TrmT" "TrmA" "MAX " TR_SW_VSRCRAW TR_CYC_VSRCRAW
#define LEN_VTMRMODES "\003"
#define TR_VTMRMODES "OFF""ABS""THs""TH%""THt"