[simu] Traces allowed in SIMU mode
[stock] Flash saving (around 50bytes) [gruvin9x / sky9x / taranis] No "Restore Model" on non empty slots [taranis] Failsafe sent in PXX protocol
This commit is contained in:
+3
-1
@@ -41,6 +41,8 @@
|
||||
|
||||
#if defined(SIMU)
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define TRACE_DEBUG(...) { printf("-D- " __VA_ARGS__); fflush(stdout); }
|
||||
#define TRACE_DEBUG_WP(...) { printf(__VA_ARGS__); fflush(stdout); }
|
||||
#define TRACE_INFO(...) { printf("-I- " __VA_ARGS__); fflush(stdout); }
|
||||
@@ -64,7 +66,7 @@
|
||||
}
|
||||
#define DUMP(data, size) dump(data, size)
|
||||
|
||||
#elif defined(DEBUG)
|
||||
#elif defined(DEBUG) && defined(CPUARM)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
+2
-3
@@ -210,11 +210,10 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
|
||||
|
||||
uint8_t ym8 = (y & 0x07);
|
||||
p += 5;
|
||||
for (int8_t i=5; i>=0; i--) {
|
||||
uint8_t b = (i!=5 ? pgm_read_byte(q--) : 0);
|
||||
for (uint8_t i=6, b=0; i>0; i--, b=pgm_read_byte(q--)) {
|
||||
if (inv) b = ~b;
|
||||
|
||||
if (condense && i==1) {
|
||||
if (condense && i==2) {
|
||||
/*condense the letter by skipping column 4 */
|
||||
continue;
|
||||
}
|
||||
|
||||
+9
-11
@@ -404,7 +404,6 @@ void menuModelSelect(uint8_t event)
|
||||
if (eeModelExists(sub)) {
|
||||
s_menu[s_menu_count++] = STR_SELECT_MODEL;
|
||||
MENU_ADD_SD_ITEM(STR_BACKUP_MODEL);
|
||||
MENU_ADD_SD_ITEM(STR_RESTORE_MODEL);
|
||||
MENU_ADD_NAVIGATION_ITEM(STR_COPY_MODEL);
|
||||
MENU_ADD_NAVIGATION_ITEM(STR_MOVE_MODEL);
|
||||
s_menu[s_menu_count++] = STR_DELETE_MODEL;
|
||||
@@ -428,7 +427,6 @@ void menuModelSelect(uint8_t event)
|
||||
}
|
||||
else {
|
||||
MENU_ADD_SD_ITEM(STR_BACKUP_MODEL);
|
||||
MENU_ADD_SD_ITEM(STR_RESTORE_MODEL);
|
||||
MENU_ADD_NAVIGATION_ITEM(STR_COPY_MODEL);
|
||||
MENU_ADD_NAVIGATION_ITEM(STR_MOVE_MODEL);
|
||||
}
|
||||
@@ -479,9 +477,11 @@ void menuModelSelect(uint8_t event)
|
||||
#endif
|
||||
|
||||
case EVT_KEY_FIRST(KEY_MOVE_UP):
|
||||
case EVT_KEY_REPT(KEY_MOVE_UP):
|
||||
case EVT_KEY_FIRST(KEY_MOVE_DOWN):
|
||||
case EVT_KEY_REPT(KEY_MOVE_DOWN):
|
||||
if (s_copyMode) {
|
||||
int8_t next_ofs = (IS_ROTARY_UP(event) || event == EVT_KEY_FIRST(KEY_MOVE_UP)) ? s_copyTgtOfs+1 : s_copyTgtOfs-1;
|
||||
int8_t next_ofs = s_copyTgtOfs + oldSub - m_posVert;
|
||||
if (next_ofs == MAX_MODELS || next_ofs == -MAX_MODELS)
|
||||
next_ofs = 0;
|
||||
|
||||
@@ -526,9 +526,6 @@ void menuModelSelect(uint8_t event)
|
||||
|
||||
TITLE(STR_MENUMODELSEL);
|
||||
|
||||
if (sub-s_pgOfs < 1) s_pgOfs = max(0, sub-1);
|
||||
else if (sub-s_pgOfs > 5) s_pgOfs = min(MAX_MODELS-7, sub-4);
|
||||
|
||||
for (uint8_t i=0; i<LCD_LINES-1; i++) {
|
||||
uint8_t y=(i+1)*FH+1;
|
||||
uint8_t k=i+s_pgOfs;
|
||||
@@ -1064,12 +1061,13 @@ void menuModelSetup(uint8_t event)
|
||||
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);
|
||||
pushMenu(menuModelFailsafe);
|
||||
}
|
||||
else {
|
||||
lcd_filled_rect(MODEL_SETUP_2ND_COLUMN, y, LCD_W-MODEL_SETUP_2ND_COLUMN-MENUS_SCROLLBAR_WIDTH, 8);
|
||||
@@ -4197,10 +4195,10 @@ void menuModelFailsafe(uint8_t event)
|
||||
return;
|
||||
}
|
||||
|
||||
if(m_posVert >= 16)
|
||||
ch = 16;
|
||||
if (m_posVert >= 16)
|
||||
ch = 16;
|
||||
else
|
||||
ch = 0;
|
||||
ch = 0;
|
||||
|
||||
lcd_putsCenter(0*FH, FAILSAFESET);
|
||||
lcd_invert_line(0);
|
||||
@@ -4226,7 +4224,7 @@ void menuModelFailsafe(uint8_t event)
|
||||
else
|
||||
val = 0;
|
||||
|
||||
if(m_posVert == ch && event == EVT_KEY_LONG(KEY_ENTER)) {
|
||||
if (m_posVert == ch && event == EVT_KEY_LONG(KEY_ENTER)) {
|
||||
g_model.failsafeChannels[ch] = val;
|
||||
eeDirty(EE_MODEL);
|
||||
s_editMode = 0;
|
||||
|
||||
+3
-3
@@ -441,8 +441,8 @@ PACK( union u_int8int16_t {
|
||||
#define MAX_CSW_DELAY 120 /*60s*/
|
||||
#define MAX_CSW_ANDSW MAX_SWITCH
|
||||
PACK(typedef struct t_CustomSwData { // Custom Switches data
|
||||
int8_t v1; //input
|
||||
int8_t v2; //offset
|
||||
int8_t v1;
|
||||
int8_t v2; // TODO EEPROM change
|
||||
uint8_t func;
|
||||
uint8_t delay;
|
||||
uint8_t duration;
|
||||
@@ -1157,7 +1157,7 @@ PACK(typedef struct t_ModelData {
|
||||
TimerData timers[MAX_TIMERS];
|
||||
uint8_t protocol:3;
|
||||
uint8_t thrTrim:1; // Enable Throttle Trim
|
||||
int8_t ppmNCH:4;
|
||||
int8_t ppmNCH:4; /* TODO EEPROM change */
|
||||
uint8_t trimInc:3; // Trim Increments
|
||||
uint8_t disableThrottleWarning:1;
|
||||
uint8_t pulsePol:1;
|
||||
|
||||
@@ -205,9 +205,7 @@
|
||||
#include "stock/board_stock.h"
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
#include "debug.h"
|
||||
#endif
|
||||
|
||||
#if defined(SIMU)
|
||||
#include "simpgmspace.h"
|
||||
|
||||
+54
-9
@@ -38,7 +38,8 @@
|
||||
|
||||
uint8_t s_pulses_paused = 0;
|
||||
uint8_t s_current_protocol = 255;
|
||||
uint8_t pxxFlag = 0 ;
|
||||
uint32_t failsafeCounter = 100;
|
||||
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 } ;
|
||||
@@ -310,12 +311,25 @@ void setupPulsesPXX()
|
||||
putPcmByte(g_model.modelId);
|
||||
|
||||
/* FLAG1 */
|
||||
uint8_t flag1;
|
||||
if (pxxFlag & PXX_SEND_RXNUM) {
|
||||
putPcmByte((g_model.rfProtocol << 6) | (g_eeGeneral.countryCode << 1) | pxxFlag);
|
||||
flag1 = (g_model.rfProtocol << 6) | (g_eeGeneral.countryCode << 1) | pxxFlag;
|
||||
}
|
||||
else {
|
||||
putPcmByte((g_model.rfProtocol << 6) | pxxFlag);
|
||||
flag1 = (g_model.rfProtocol << 6) | pxxFlag;
|
||||
#if defined(PCBTARANIS)
|
||||
if (g_model.failsafeMode != FAILSAFE_HOLD) {
|
||||
if (failsafeCounter-- == 0) {
|
||||
failsafeCounter = 1000;
|
||||
flag1 |= PXX_SEND_FAILSAFE;
|
||||
}
|
||||
if (failsafeCounter == 0 && g_model.ppmNCH > 0) {
|
||||
flag1 |= PXX_SEND_FAILSAFE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
putPcmByte(flag1);
|
||||
|
||||
/* FLAG2 */
|
||||
putPcmByte(0);
|
||||
@@ -327,13 +341,44 @@ void setupPulsesPXX()
|
||||
sendUpperChannels = g_model.ppmNCH*2;
|
||||
}
|
||||
for (uint32_t i=0; i<8; i+=2) {
|
||||
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);
|
||||
#if defined(PCBTARANIS)
|
||||
if (flag1 & PXX_SEND_FAILSAFE) {
|
||||
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, (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, (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 {
|
||||
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);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
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
|
||||
|
||||
@@ -39,10 +39,13 @@
|
||||
|
||||
extern uint8_t s_current_protocol;
|
||||
extern uint8_t s_pulses_paused;
|
||||
extern uint32_t failsafeCounter;
|
||||
|
||||
void startPulses();
|
||||
inline bool pulsesStarted() { return s_current_protocol != 255; }
|
||||
inline void pausePulses() { s_pulses_paused = true; }
|
||||
inline void resumePulses() { s_pulses_paused = false; }
|
||||
|
||||
#define SEND_FAILSAFE_NOW() failsafeCounter = 1
|
||||
|
||||
#endif
|
||||
|
||||
@@ -54,10 +54,10 @@ void menuChannelsView(uint8_t event)
|
||||
break;
|
||||
}
|
||||
|
||||
if(secondPage)
|
||||
ch = 16;
|
||||
if (secondPage)
|
||||
ch = 16;
|
||||
else
|
||||
ch = 0;
|
||||
ch = 0;
|
||||
|
||||
lcd_putsCenter(0*FH, CHANNELS_MONITOR);
|
||||
lcd_invert_line(0);
|
||||
|
||||
Reference in New Issue
Block a user