[Taranis / sky9x] Delay now applies also to non-switches sources! For my demo tomorrow on ardupilot flight modes selection (8 modes selectable with S1, voice 1s after the pot is moved, fligh mode started 2s after pot is moved)

[all] Same reason ... curves can now be like steps: x(N) = x(N+1)
[Taranis] Model bitmap chosen from the SD Files Manager
This commit is contained in:
bsongis@gmail.com
2013-06-19 20:38:30 +00:00
parent 171c77ff64
commit 318abd2667
7 changed files with 51 additions and 18 deletions
+22 -1
View File
@@ -677,6 +677,23 @@ void onSdManagerMenu(const char *result)
strcat(lfn, reusableBuffer.sdmanager.lines[index]);
audioQueue.playFile(lfn, PLAY_BACKGROUND, 255);
}
else if (result == STR_ASSIGN_BITMAP) {
strcpy(lfn, reusableBuffer.sdmanager.lines[index]);
// TODO duplicated code for finding extension
uint8_t len = strlen(lfn) - 4;
memset(lfn+len, 0, sizeof(g_model.header.bitmap)-len);
// TODO duplicated code
memcpy(g_model.header.bitmap, lfn, sizeof(g_model.header.bitmap));
#if defined(SIMU)
f_chdir("..");
#endif
LOAD_MODEL_BITMAP();
#if defined(SIMU)
f_chdir(BITMAPS_PATH);
#endif
memcpy(modelHeaders[g_eeGeneral.currModel].bitmap, g_model.header.bitmap, sizeof(g_model.header.bitmap));
eeDirty(EE_MODEL);
}
#endif
}
@@ -736,14 +753,18 @@ void menuGeneralSdManager(uint8_t event)
else {
#if defined(CPUARM)
uint8_t index = m_posVert-1-s_pgOfs;
// TODO duplicated code for finding extension
char * ext = reusableBuffer.sdmanager.lines[index];
ext += strlen(ext) - 4;
/* TODO if (!strcmp(ext, MODELS_EXT)) {
/* TODO if (!strcasecmp(ext, MODELS_EXT)) {
s_menu[s_menu_count++] = STR_LOAD_FILE;
}
else */ if (!strcasecmp(ext, SOUNDS_EXT)) {
MENU_ADD_ITEM(STR_PLAY_FILE);
}
else if (!strcasecmp(ext, BITMAPS_EXT)) {
MENU_ADD_ITEM(STR_ASSIGN_BITMAP);
}
#endif
MENU_ADD_ITEM(STR_DELETE_FILE);
MENU_ADD_ITEM(STR_RENAME_FILE);
+1 -1
View File
@@ -2370,7 +2370,7 @@ void menuModelCurveOne(uint8_t event)
lcd_filled_rect(point.x-FW, point.y-1, 3, 3, SOLID);
if (s_editMode > 0) {
if (selectionMode == 1)
CHECK_INCDEC_MODELVAR(event, crv.crv[crv.points+i-1], i==1 ? -99 : crv.crv[crv.points+i-2]+1, i==crv.points-2 ? 99 : crv.crv[crv.points+i]-1); // edit X
CHECK_INCDEC_MODELVAR(event, crv.crv[crv.points+i-1], i==1 ? -99 : crv.crv[crv.points+i-2], i==crv.points-2 ? 99 : crv.crv[crv.points+i]); // edit X
else if (selectionMode == 2)
CHECK_INCDEC_MODELVAR(event, crv.crv[i], -100, 100);
}
+10 -11
View File
@@ -2841,7 +2841,7 @@ void perOut(uint8_t mode, uint8_t tick10ms)
//========== PHASE && SWITCH =====
bool mixCondition = (md->phases != 0 || md->swtch);
int8_t mixEnabled = !(md->phases & (1 << s_perout_flight_phase)) && getSwitch(md->swtch);
delayval_t mixEnabled = !(md->phases & (1 << s_perout_flight_phase)) && getSwitch(md->swtch);
//========== VALUE ===============
getvalue_t v = 0;
@@ -2859,9 +2859,6 @@ void perOut(uint8_t mode, uint8_t tick10ms)
}
else {
v = getValue(k);
if (!mixCondition && k >= MIXSRC_FIRST_SWITCH-1 && k <= MIXSRC_LAST_CSW-1) {
mixEnabled = v >> 10;
}
if (k>=MIXSRC_CH1-1 && k<=MIXSRC_LAST_CH-1 && md->destCh != k-MIXSRC_CH1+1) {
if (dirtyChannels & ((bitfield_channels_t)1 << (k-MIXSRC_CH1+1)) & (passDirtyChannels|~(((bitfield_channels_t) 1 << md->destCh)-1)))
passDirtyChannels |= (bitfield_channels_t) 1 << md->destCh;
@@ -2869,13 +2866,16 @@ void perOut(uint8_t mode, uint8_t tick10ms)
v = chans[k-MIXSRC_CH1+1] >> 8;
}
}
if (!mixCondition) {
mixEnabled = v >> DELAY_POS_SHIFT;
}
}
bool apply_offset_and_curve = true;
// ========== DELAYS ===============
int8_t _swOn = swOn[i].now;
int8_t _swPrev = swOn[i].prev;
delayval_t _swOn = swOn[i].now;
delayval_t _swPrev = swOn[i].prev;
bool swTog = (mixEnabled != _swOn);
if (mode==e_perout_mode_normal && swTog) {
if (!swOn[i].delay) _swPrev = _swOn;
@@ -2886,7 +2886,7 @@ void perOut(uint8_t mode, uint8_t tick10ms)
if (mode==e_perout_mode_normal && swOn[i].delay > 0) {
swOn[i].delay = max<int16_t>(0, (int16_t)swOn[i].delay - tick10ms);
if (!mixCondition)
v = _swPrev << 10;
v = _swPrev << DELAY_POS_SHIFT;
else if (mixEnabled)
continue;
}
@@ -2903,7 +2903,7 @@ void perOut(uint8_t mode, uint8_t tick10ms)
}
if (mode==e_perout_mode_normal && (!mixCondition || mixEnabled || swOn[i].delay)) {
if (md->mixWarn) lv_mixWarning |= 1 << (md->mixWarn - 1); // Mix warning
if (md->mixWarn) lv_mixWarning |= 1 << (md->mixWarn - 1);
#if defined(BOLD_FONT)
swOn[i].activeMix = true;
#endif
@@ -2911,9 +2911,8 @@ void perOut(uint8_t mode, uint8_t tick10ms)
//========== OFFSET ===============
if (apply_offset_and_curve) {
int16_t offset = GET_GVAR(MD_OFFSET(md), GV_RANGELARGE_NEG, GV_RANGELARGE, s_perout_flight_phase); // open.20.fsguruh
if (offset) v += calc100toRESX_16Bits(offset); // @@@ open.20.fsguruh
int16_t offset = GET_GVAR(MD_OFFSET(md), GV_RANGELARGE_NEG, GV_RANGELARGE, s_perout_flight_phase);
if (offset) v += calc100toRESX_16Bits(offset);
//========== TRIMS ===============
if (!(mode & e_perout_mode_notrims)) {
+15 -4
View File
@@ -1179,11 +1179,20 @@ extern void instantTrim();
extern void moveTrimsToOffsets();
#if defined(CPUARM)
#define ACTIVE_PHASES_TYPE uint16_t
#define ACTIVE_PHASES_TYPE uint16_t
#define DELAY_POS_SHIFT 0
#define delayval_t int16_t
PACK(typedef struct t_SwOn {
uint16_t delay;
int16_t now; // timer trigger source -> off, abs, stk, stk%, sw/!sw, !m_sw/!m_sw
int16_t prev;
uint8_t activeMix;
uint8_t activeExpo;
}) SwOn;
#else
#define ACTIVE_PHASES_TYPE uint8_t
#endif
#define ACTIVE_PHASES_TYPE uint8_t
#define DELAY_POS_SHIFT 10
#define delayval_t int8_t
PACK(typedef struct t_SwOn {
uint16_t delay:10;
int16_t now:2; // timer trigger source -> off, abs, stk, stk%, sw/!sw, !m_sw/!m_sw
@@ -1191,6 +1200,8 @@ PACK(typedef struct t_SwOn {
int16_t activeMix:1;
int16_t activeExpo:1;
}) SwOn;
#endif
extern SwOn swOn [MAX_MIXERS];
extern int24_t act [MAX_MIXERS];
+1 -1
View File
@@ -50,7 +50,7 @@
#define SOUNDS_PATH ROOT_PATH "SOUNDS/en" // no trailing slash = important
#define SOUNDS_PATH_LNG_OFS (sizeof(SOUNDS_PATH)-3)
#define SYSTEM_SOUNDS_PATH SOUNDS_PATH "/SYSTEM" // no trailing slash = important
#define BITMAPS_PATH ROOT_PATH "/BMP"
#define BITMAPS_PATH ROOT_PATH "BMP"
#define MODELS_EXT ".bin"
#define LOGS_EXT ".csv"
+1
View File
@@ -410,6 +410,7 @@ const pm_char STR_NO_SOUNDS_ON_SD[] PROGMEM = TR_NO_SOUNDS_ON_SD;
const pm_char STR_NO_MODELS_ON_SD[] PROGMEM = TR_NO_MODELS_ON_SD;
const pm_char STR_NO_BITMAPS_ON_SD[] PROGMEM = TR_NO_BITMAPS_ON_SD;
const pm_char STR_PLAY_FILE[] PROGMEM = TR_PLAY_FILE;
const pm_char STR_ASSIGN_BITMAP[] PROGMEM = PSTR("Assign Bitmap");
const pm_char STR_DELETE_FILE[] PROGMEM = TR_DELETE_FILE;
const pm_char STR_COPY_FILE[] PROGMEM = TR_COPY_FILE;
const pm_char STR_RENAME_FILE[] PROGMEM = TR_RENAME_FILE;
+1
View File
@@ -555,6 +555,7 @@ extern const pm_char STR_NO_SOUNDS_ON_SD[];
extern const pm_char STR_NO_MODELS_ON_SD[];
extern const pm_char STR_NO_BITMAPS_ON_SD[];
extern const pm_char STR_PLAY_FILE[];
extern const pm_char STR_ASSIGN_BITMAP[];
extern const pm_char STR_DELETE_FILE[];
extern const pm_char STR_COPY_FILE[];
extern const pm_char STR_RENAME_FILE[];