Merge branch 'next' of https://github.com/opentx/opentx into bsongis/vario_improvements
Conflicts: radio/src/audio_arm.cpp
This commit is contained in:
@@ -67,6 +67,14 @@ EXT = STD
|
||||
# Values = YES, NO, CHOICE
|
||||
FAI = NO
|
||||
|
||||
# the latests deliveries for Turnigy 9x transmitters (since 2 years now, 2014) do not stop sending if no pulses are generated.
|
||||
# This fact totally breaks the nice throttle and switch warning concept, because even we prevent sending pulses the
|
||||
# transmitter modul ignores this, and continous to send the last value or 0 at beginning. And 0 means in the middle of throttle -> 50%.
|
||||
# To cope with this situation, we need a new concept how to handle throttle and switch warnings.
|
||||
# if you have a 0 value (50% ) for throttle, while throttle warning is active, you should activate this switch
|
||||
# Values = YES, NO
|
||||
TURNIGY_TRANSMITTER_FIX = NO
|
||||
|
||||
# Enable heli menu
|
||||
# Values = YES, NO
|
||||
HELI = NO
|
||||
@@ -761,6 +769,14 @@ ifeq ($(NAVIGATION), ROTENC)
|
||||
CPPDEFS += -DROTARY_ENCODER_NAVIGATION
|
||||
endif
|
||||
|
||||
ifeq ($(TURNIGY_TRANSMITTER_FIX), YES)
|
||||
ifeq ($(PCB), TARANIS)
|
||||
$(warning TURNIGY_TRANSMITTER_FIX is not available on Taranis)
|
||||
else
|
||||
CPPDEFS += -DMODULE_ALWAYS_SEND_PULSES
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(AUTOSWITCH), YES)
|
||||
CPPDEFS += -DAUTOSWITCH
|
||||
endif
|
||||
|
||||
+201
-80
@@ -204,130 +204,257 @@ const char * audioFilenames[] = {
|
||||
};
|
||||
|
||||
uint64_t sdAvailableSystemAudioFiles = 0;
|
||||
uint8_t sdAvailablePhaseAudioFiles[MAX_PHASES] = { 0 };
|
||||
uint8_t sdAvailableMixerAudioFiles[MAX_MIXERS] = { 0 };
|
||||
uint32_t sdAvailablePhaseAudioFiles = 0;
|
||||
uint64_t sdAvailableSwitchAudioFiles = 0;
|
||||
uint64_t sdAvailableLogicalSwitchAudioFiles = 0;
|
||||
|
||||
void refreshSystemAudioFiles()
|
||||
#define MASK_SYSTEM_AUDIO_FILE(index) ((uint64_t)1 << index)
|
||||
#define MASK_PHASE_AUDIO_FILE(index, event) ((uint32_t)1 << (2*index+event))
|
||||
#define MASK_SWITCH_AUDIO_FILE(index) ((uint64_t)1 << index)
|
||||
#define MASK_LOGICAL_SWITCH_AUDIO_FILE(index, event) ((uint64_t)1 << (2*index+event))
|
||||
|
||||
bool isFileAvailable(const char * filename)
|
||||
{
|
||||
FILINFO info;
|
||||
#if _USE_LFN
|
||||
TCHAR lfn[_MAX_LFN + 1];
|
||||
info.lfname = lfn;
|
||||
info.lfsize = sizeof(lfn);
|
||||
#endif
|
||||
return f_stat(filename, &info) == FR_OK;
|
||||
}
|
||||
|
||||
char filename[32] = SYSTEM_SOUNDS_PATH "/";
|
||||
strncpy(filename+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2);
|
||||
char * getAudioPath(char * path)
|
||||
{
|
||||
strcpy(path, SOUNDS_PATH "/");
|
||||
strncpy(path+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2);
|
||||
return path + sizeof(SOUNDS_PATH);
|
||||
}
|
||||
|
||||
char * getSystemAudioPath(char * path)
|
||||
{
|
||||
char * str = getAudioPath(path);
|
||||
strcpy(str, SYSTEM_SUBDIR "/");
|
||||
return str + sizeof(SYSTEM_SUBDIR);
|
||||
}
|
||||
|
||||
void getSystemAudioFile(char * filename, int index)
|
||||
{
|
||||
char * str = getSystemAudioPath(filename);
|
||||
strcpy(str, audioFilenames[index]);
|
||||
strcat(str, SOUNDS_EXT);
|
||||
}
|
||||
|
||||
void referenceSystemAudioFiles()
|
||||
{
|
||||
char path[AUDIO_FILENAME_MAXLEN+1];
|
||||
FILINFO fno;
|
||||
DIR dir;
|
||||
char *fn; /* This function is assuming non-Unicode cfg. */
|
||||
TCHAR lfn[_MAX_LFN + 1];
|
||||
fno.lfname = lfn;
|
||||
fno.lfsize = sizeof(lfn);
|
||||
|
||||
uint64_t availableAudioFiles = 0;
|
||||
|
||||
assert(sizeof(audioFilenames)==AU_FRSKY_FIRST*sizeof(char *));
|
||||
assert(sizeof(sdAvailableSystemAudioFiles)*8 >= AU_FRSKY_FIRST);
|
||||
|
||||
uint64_t availableAudioFiles = 0;
|
||||
char * filename = getSystemAudioPath(path);
|
||||
*(filename-1) = '\0';
|
||||
|
||||
for (uint32_t i=0; i<AU_FRSKY_FIRST; i++) {
|
||||
strcpy(filename+sizeof(SYSTEM_SOUNDS_PATH), audioFilenames[i]);
|
||||
strcat(filename+sizeof(SYSTEM_SOUNDS_PATH), SOUNDS_EXT);
|
||||
if (f_stat(filename, &info) == FR_OK)
|
||||
availableAudioFiles |= ((uint64_t)1 << i);
|
||||
FRESULT res = f_opendir(&dir, path); /* Open the directory */
|
||||
if (res == FR_OK) {
|
||||
for (;;) {
|
||||
res = f_readdir(&dir, &fno); /* Read a directory item */
|
||||
if (res != FR_OK || fno.fname[0] == 0) break; /* Break on error or end of dir */
|
||||
fn = *fno.lfname ? fno.lfname : fno.fname;
|
||||
uint8_t len = strlen(fn);
|
||||
|
||||
// Eliminates directories / non wav files
|
||||
if (len < 5 || strcasecmp(fn+len-4, SOUNDS_EXT) || (fno.fattrib & AM_DIR)) continue;
|
||||
|
||||
for (int i=0; i<AU_FRSKY_FIRST; i++) {
|
||||
getSystemAudioFile(path, i);
|
||||
if (!strcmp(filename, fn)) {
|
||||
availableAudioFiles |= MASK_SYSTEM_AUDIO_FILE(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sdAvailableSystemAudioFiles = availableAudioFiles;
|
||||
}
|
||||
|
||||
const char * suffixes[] = { "-OFF", "-ON", /*"-BG", */NULL };
|
||||
const char * suffixes[] = { "-off", "-on" };
|
||||
|
||||
inline uint8_t getAvailableFiles(char *prefix, FILINFO &info, char *filename)
|
||||
char * getModelPath(char * path)
|
||||
{
|
||||
uint8_t result = 0;
|
||||
|
||||
for (uint8_t i=0; suffixes[i]; i++) {
|
||||
strcpy(prefix, suffixes[i]);
|
||||
strcat(prefix, SOUNDS_EXT);
|
||||
if (f_stat(filename, &info) == FR_OK)
|
||||
result |= ((uint8_t)1 << i);
|
||||
}
|
||||
|
||||
strcpy(path, SOUNDS_PATH "/");
|
||||
strncpy(path+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2);
|
||||
char * result = strcat_modelname(path+sizeof(SOUNDS_PATH), g_eeGeneral.currModel);
|
||||
*result++ = '/';
|
||||
*result = '\0';
|
||||
return result;
|
||||
}
|
||||
|
||||
void refreshModelAudioFiles()
|
||||
void getPhaseAudioFile(char * filename, int index, unsigned int event)
|
||||
{
|
||||
FILINFO info;
|
||||
char * str = getModelPath(filename);
|
||||
char * tmp = strcat_phasename(str, index);
|
||||
strcpy(tmp, suffixes[event]);
|
||||
strcat(tmp, SOUNDS_EXT);
|
||||
}
|
||||
|
||||
void getSwitchAudioFile(char * filename, int index)
|
||||
{
|
||||
char * str = getModelPath(filename);
|
||||
int len = STR_VSWITCHES[0];
|
||||
strncpy(str, &STR_VSWITCHES[1+len*index], len);
|
||||
str += len-1;
|
||||
if (*str == '\300') {
|
||||
strcpy(str, "-up");
|
||||
str += 3;
|
||||
}
|
||||
else if (*str == '-') {
|
||||
strcpy(str, "-mid");
|
||||
str += 4;
|
||||
}
|
||||
else if (*str == '\301') {
|
||||
strcpy(str, "-down");
|
||||
str += 5;
|
||||
}
|
||||
else {
|
||||
str += 1;
|
||||
}
|
||||
strcat(str, SOUNDS_EXT);
|
||||
}
|
||||
|
||||
void getLogicalSwitchAudioFile(char * filename, int index, unsigned int event)
|
||||
{
|
||||
char * str = getModelPath(filename);
|
||||
int len = STR_VSWITCHES[0];
|
||||
strncpy(str, &STR_VSWITCHES[1+len*(index+SWSRC_FIRST_CSW-1)], len);
|
||||
str += len;
|
||||
strcpy(str, suffixes[event]);
|
||||
strcat(str, SOUNDS_EXT);
|
||||
}
|
||||
|
||||
void referenceModelAudioFiles()
|
||||
{
|
||||
char path[AUDIO_FILENAME_MAXLEN+1];
|
||||
FILINFO fno;
|
||||
DIR dir;
|
||||
char *fn; /* This function is assuming non-Unicode cfg. */
|
||||
TCHAR lfn[_MAX_LFN + 1];
|
||||
info.lfname = lfn;
|
||||
info.lfsize = sizeof(lfn);
|
||||
fno.lfname = lfn;
|
||||
fno.lfsize = sizeof(lfn);
|
||||
|
||||
char filename[AUDIO_FILENAME_MAXLEN+1] = SOUNDS_PATH "/";
|
||||
strncpy(filename+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2);
|
||||
sdAvailablePhaseAudioFiles = 0;
|
||||
sdAvailableSwitchAudioFiles = 0;
|
||||
sdAvailableLogicalSwitchAudioFiles = 0;
|
||||
|
||||
if (sdMounted()) {
|
||||
char *buf = strcat_modelname(&filename[sizeof(SOUNDS_PATH)], g_eeGeneral.currModel);
|
||||
*buf++ = '/';
|
||||
char * filename = getModelPath(path);
|
||||
*(filename-1) = '\0';
|
||||
|
||||
for (uint32_t i=0; i<MAX_PHASES; i++) {
|
||||
char *tmp = strcat_phasename(buf, i);
|
||||
sdAvailablePhaseAudioFiles[i] = (tmp != buf ? getAvailableFiles(strcat_phasename(buf, i), info, filename) : 0);
|
||||
FRESULT res = f_opendir(&dir, path); /* Open the directory */
|
||||
if (res == FR_OK) {
|
||||
for (;;) {
|
||||
res = f_readdir(&dir, &fno); /* Read a directory item */
|
||||
if (res != FR_OK || fno.fname[0] == 0) break; /* Break on error or end of dir */
|
||||
fn = *fno.lfname ? fno.lfname : fno.fname;
|
||||
uint8_t len = strlen(fn);
|
||||
bool found = false;
|
||||
|
||||
// Eliminates directories / non wav files
|
||||
if (len < 5 || strcasecmp(fn+len-4, SOUNDS_EXT) || (fno.fattrib & AM_DIR)) continue;
|
||||
|
||||
// Phases Audio Files <phasename>-[on|off].wav
|
||||
for (int i=0; i<MAX_PHASES && !found; i++) {
|
||||
for (int event=0; event<2; event++) {
|
||||
getPhaseAudioFile(path, i, event);
|
||||
if (!strcmp(filename, fn)) {
|
||||
sdAvailablePhaseAudioFiles |= MASK_PHASE_AUDIO_FILE(i, event);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* for (uint32_t i=0; i<MAX_MIXERS; i++) {
|
||||
char *tmp = strcat_mixername_nodefault(buf, i);
|
||||
sdAvailableMixerAudioFiles[i] = (tmp != buf ? getAvailableFiles(tmp, info, filename) : 0);
|
||||
} */
|
||||
// Switches Audio Files <switchname>-[up|mid|down].wav
|
||||
for (int i=0; i<SWSRC_LAST_SWITCH+NUM_XPOTS*POTS_POS_COUNT && !found; i++) {
|
||||
getSwitchAudioFile(path, i);
|
||||
if (!strcmp(filename, fn)) {
|
||||
sdAvailableSwitchAudioFiles |= MASK_SWITCH_AUDIO_FILE(i);
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool isAudioFileAvailable(uint32_t i, char * filename)
|
||||
// Logical Switches Audio Files <switchname>-[on|off].wav
|
||||
for (int i=0; i<NUM_CSW && !found; i++) {
|
||||
for (int event=0; event<2; event++) {
|
||||
getLogicalSwitchAudioFile(path, i, event);
|
||||
if (!strcmp(filename, fn)) {
|
||||
sdAvailableLogicalSwitchAudioFiles |= MASK_LOGICAL_SWITCH_AUDIO_FILE(i, event);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool isAudioFileReferenced(uint32_t i, char * filename)
|
||||
{
|
||||
uint8_t category = (i >> 24);
|
||||
uint8_t index = (i >> 16) & 0xFF;
|
||||
uint8_t event = i & 0xFF;
|
||||
|
||||
#if 0
|
||||
printf("isAudioFileAvailable(%08x)\n", i); fflush(stdout);
|
||||
printf("isAudioFileReferenced(%08x)\n", i); fflush(stdout);
|
||||
#endif
|
||||
|
||||
if (category == SYSTEM_AUDIO_CATEGORY) {
|
||||
if (sdAvailableSystemAudioFiles & ((uint64_t)1 << event)) {
|
||||
strcpy(filename, SYSTEM_SOUNDS_PATH "/");
|
||||
strncpy(filename+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2);
|
||||
strcpy(filename+sizeof(SYSTEM_SOUNDS_PATH), audioFilenames[i]);
|
||||
strcat(filename+sizeof(SYSTEM_SOUNDS_PATH), SOUNDS_EXT);
|
||||
if (sdAvailableSystemAudioFiles & MASK_SYSTEM_AUDIO_FILE(event)) {
|
||||
getSystemAudioFile(filename, event);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (category == PHASE_AUDIO_CATEGORY) {
|
||||
if (sdAvailablePhaseAudioFiles[index] & ((uint32_t)1 << event)) {
|
||||
strcpy(filename, SOUNDS_PATH "/");
|
||||
strncpy(filename+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2);
|
||||
char *str = strcat_modelname(filename+sizeof(SOUNDS_PATH), g_eeGeneral.currModel);
|
||||
*str++ = '/';
|
||||
char * tmp = strcat_phasename(str, index);
|
||||
if (tmp != str) {
|
||||
strcpy(tmp, suffixes[event]);
|
||||
strcat(tmp, SOUNDS_EXT);
|
||||
if (sdAvailablePhaseAudioFiles & MASK_PHASE_AUDIO_FILE(index, event)) {
|
||||
getPhaseAudioFile(filename, index, event);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (category == SWITCH_AUDIO_CATEGORY) {
|
||||
if (sdAvailableSwitchAudioFiles & MASK_SWITCH_AUDIO_FILE(index)) {
|
||||
getSwitchAudioFile(filename, index);
|
||||
return true;
|
||||
}
|
||||
else if (category == MIXER_AUDIO_CATEGORY) {
|
||||
if (sdAvailableMixerAudioFiles[index] & ((uint32_t)1 << event)) {
|
||||
strcpy(filename, SOUNDS_PATH "/");
|
||||
strncpy(filename+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2);
|
||||
char *str = strcat_modelname(filename+sizeof(SOUNDS_PATH), g_eeGeneral.currModel);
|
||||
*str++ = '/';
|
||||
char * tmp = strcat_mixername(str, index);
|
||||
if (tmp != str) {
|
||||
strcpy(tmp, suffixes[event]);
|
||||
strcat(tmp, SOUNDS_EXT);
|
||||
}
|
||||
else if (category == LOGICAL_SWITCH_AUDIO_CATEGORY) {
|
||||
if (sdAvailableLogicalSwitchAudioFiles & MASK_LOGICAL_SWITCH_AUDIO_FILE(index, event)) {
|
||||
getLogicalSwitchAudioFile(filename, index, event);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
tmr10ms_t timeAutomaticPromptsSilence = 0;
|
||||
|
||||
void playModelEvent(uint8_t category, uint8_t index, uint8_t event)
|
||||
{
|
||||
char filename[AUDIO_FILENAME_MAXLEN+1];
|
||||
if ((get_tmr10ms()-timeAutomaticPromptsSilence > 50) && isAudioFileReferenced((category << 24) + (index << 16) + event, filename)) {
|
||||
audioQueue.playFile(filename);
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define isAudioFileAvailable(i, f) false
|
||||
|
||||
#define isAudioFileReferenced(i, f) false
|
||||
|
||||
#endif
|
||||
|
||||
const int16_t alawTable[256] = { -5504, -5248, -6016, -5760, -4480, -4224, -4992, -4736, -7552, -7296, -8064, -7808, -6528, -6272, -7040, -6784, -2752, -2624, -3008, -2880, -2240, -2112, -2496, -2368, -3776, -3648, -4032, -3904, -3264, -3136, -3520, -3392, -22016, -20992, -24064, -23040, -17920, -16896, -19968, -18944, -30208, -29184, -32256, -31232, -26112, -25088, -28160, -27136, -11008, -10496, -12032, -11520, -8960, -8448, -9984, -9472, -15104, -14592, -16128, -15616, -13056, -12544, -14080, -13568, -344, -328, -376, -360, -280, -264, -312, -296, -472, -456, -504, -488, -408, -392, -440, -424, -88, -72, -120, -104, -24, -8, -56, -40, -216, -200, -248, -232, -152, -136, -184, -168, -1376, -1312, -1504, -1440, -1120, -1056, -1248, -1184, -1888, -1824, -2016, -1952, -1632, -1568, -1760, -1696, -688, -656, -752, -720, -560, -528, -624, -592, -944, -912, -1008, -976, -816, -784, -880, -848, 5504, 5248, 6016, 5760, 4480, 4224, 4992, 4736, 7552, 7296, 8064, 7808, 6528, 6272, 7040, 6784, 2752, 2624, 3008, 2880, 2240, 2112, 2496, 2368, 3776, 3648, 4032, 3904, 3264, 3136, 3520, 3392, 22016, 20992, 24064, 23040, 17920, 16896, 19968, 18944, 30208, 29184, 32256, 31232, 26112, 25088, 28160, 27136, 11008, 10496, 12032, 11520, 8960, 8448, 9984, 9472, 15104, 14592, 16128, 15616, 13056, 12544, 14080, 13568, 344, 328, 376, 360, 280, 264, 312, 296, 472, 456, 504, 488, 408, 392, 440, 424, 88, 72, 120, 104, 24, 8, 56, 40, 216, 200, 248, 232, 152, 136, 184, 168, 1376, 1312, 1504, 1440, 1120, 1056, 1248, 1184, 1888, 1824, 2016, 1952, 1632, 1568, 1760, 1696, 688, 656, 752, 720, 560, 528, 624, 592, 944, 912, 1008, 976, 816, 784, 880, 848 };
|
||||
@@ -808,10 +935,6 @@ void AudioQueue::reset()
|
||||
|
||||
void audioEvent(uint8_t e, uint16_t f)
|
||||
{
|
||||
#if defined(SDCARD)
|
||||
char filename[AUDIO_FILENAME_MAXLEN+1];
|
||||
#endif
|
||||
|
||||
#if defined(HAPTIC)
|
||||
haptic.event(e); //do this before audio to help sync timings
|
||||
#endif
|
||||
@@ -824,7 +947,8 @@ void audioEvent(uint8_t e, uint16_t f)
|
||||
|
||||
if (g_eeGeneral.beepMode>0 || (g_eeGeneral.beepMode==0 && e>=AU_TRIM_MOVE) || (g_eeGeneral.beepMode>=-1 && e<=AU_ERROR)) {
|
||||
#if defined(SDCARD)
|
||||
if (e < AU_FRSKY_FIRST && isAudioFileAvailable(e, filename)) {
|
||||
char filename[AUDIO_FILENAME_MAXLEN+1];
|
||||
if (e < AU_FRSKY_FIRST && isAudioFileReferenced(e, filename)) {
|
||||
audioQueue.playFile(filename);
|
||||
}
|
||||
else
|
||||
@@ -1033,16 +1157,13 @@ void audioEvent(uint8_t e, uint16_t f)
|
||||
void pushPrompt(uint16_t prompt, uint8_t id)
|
||||
{
|
||||
#if defined(SDCARD)
|
||||
|
||||
char filename[] = SYSTEM_SOUNDS_PATH "/0000" SOUNDS_EXT;
|
||||
strncpy(filename+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2);
|
||||
|
||||
char filename[AUDIO_FILENAME_MAXLEN+1];
|
||||
char * str = getSystemAudioPath(filename);
|
||||
strcpy(str, "0000" SOUNDS_EXT);
|
||||
for (int8_t i=3; i>=0; i--) {
|
||||
filename[sizeof(SYSTEM_SOUNDS_PATH)+i] = '0' + (prompt%10);
|
||||
str[i] = '0' + (prompt%10);
|
||||
prompt /= 10;
|
||||
}
|
||||
|
||||
audioQueue.playFile(filename, 0, id);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
+29
-13
@@ -297,16 +297,21 @@ void audioStart();
|
||||
|
||||
#define AUDIO_HEARTBEAT()
|
||||
|
||||
#define SYSTEM_AUDIO_CATEGORY 0
|
||||
#define MODEL_AUDIO_CATEGORY 1
|
||||
#define PHASE_AUDIO_CATEGORY 2
|
||||
#define MIXER_AUDIO_CATEGORY 3
|
||||
enum AutomaticPromptsCategories {
|
||||
SYSTEM_AUDIO_CATEGORY,
|
||||
MODEL_AUDIO_CATEGORY,
|
||||
PHASE_AUDIO_CATEGORY,
|
||||
SWITCH_AUDIO_CATEGORY,
|
||||
LOGICAL_SWITCH_AUDIO_CATEGORY,
|
||||
};
|
||||
|
||||
#define AUDIO_EVENT_OFF 0
|
||||
#define AUDIO_EVENT_ON 1
|
||||
#define AUDIO_EVENT_BG 2
|
||||
enum AutomaticPromptsEvents {
|
||||
AUDIO_EVENT_OFF,
|
||||
AUDIO_EVENT_ON,
|
||||
AUDIO_EVENT_MID,
|
||||
};
|
||||
|
||||
extern void pushPrompt(uint16_t prompt, uint8_t id=0);
|
||||
void pushPrompt(uint16_t prompt, uint8_t id=0);
|
||||
|
||||
#define I18N_PLAY_FUNCTION(lng, x, ...) void lng ## _ ## x(__VA_ARGS__, uint8_t id)
|
||||
#define PLAY_FUNCTION(x, ...) void x(__VA_ARGS__, uint8_t id)
|
||||
@@ -320,15 +325,26 @@ extern void pushPrompt(uint16_t prompt, uint8_t id=0);
|
||||
#define AUDIO_RESET() audioQueue.reset()
|
||||
|
||||
#if defined(SDCARD)
|
||||
#define PLAY_PHASE_OFF(phase) do { char filename[AUDIO_FILENAME_MAXLEN+1]; if (isAudioFileAvailable((PHASE_AUDIO_CATEGORY << 24) + (phase << 16) + AUDIO_EVENT_OFF, filename)) audioQueue.playFile(filename); } while (0)
|
||||
#define PLAY_PHASE_ON(phase) do { char filename[AUDIO_FILENAME_MAXLEN+1]; if (isAudioFileAvailable((PHASE_AUDIO_CATEGORY << 24) + (phase << 16) + AUDIO_EVENT_ON, filename)) audioQueue.playFile(filename); } while (0)
|
||||
extern tmr10ms_t timeAutomaticPromptsSilence;
|
||||
void playModelEvent(uint8_t category, uint8_t index, uint8_t event=0);
|
||||
#define PLAY_PHASE_OFF(phase) playModelEvent(PHASE_AUDIO_CATEGORY, phase, AUDIO_EVENT_OFF)
|
||||
#define PLAY_PHASE_ON(phase) playModelEvent(PHASE_AUDIO_CATEGORY, phase, AUDIO_EVENT_ON)
|
||||
#define PLAY_SWITCH_MOVED(sw) playModelEvent(SWITCH_AUDIO_CATEGORY, sw)
|
||||
#define PLAY_LOGICAL_SWITCH_OFF(sw) playModelEvent(LOGICAL_SWITCH_AUDIO_CATEGORY, sw, AUDIO_EVENT_OFF)
|
||||
#define PLAY_LOGICAL_SWITCH_ON(sw) playModelEvent(LOGICAL_SWITCH_AUDIO_CATEGORY, sw, AUDIO_EVENT_ON)
|
||||
#define SKIP_AUTOMATIC_PROMPTS() timeAutomaticPromptsSilence = get_tmr10ms()
|
||||
#else
|
||||
#define PLAY_PHASE_OFF(phase)
|
||||
#define PLAY_PHASE_ON(phase)
|
||||
#define PLAY_SWITCH_MOVED(sw)
|
||||
#define PLAY_LOGICAL_SWITCH_OFF(sw)
|
||||
#define PLAY_LOGICAL_SWITCH_ON(sw)
|
||||
#define SKIP_AUTOMATIC_PROMPTS()
|
||||
#endif
|
||||
|
||||
extern void refreshSystemAudioFiles();
|
||||
extern void refreshModelAudioFiles();
|
||||
extern bool isAudioFileAvailable(uint32_t i, char * filename);
|
||||
void referenceSystemAudioFiles();
|
||||
void referenceModelAudioFiles();
|
||||
|
||||
bool isAudioFileReferenced(uint32_t i, char * filename/*at least AUDIO_FILENAME_MAXLEN+1 long*/);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -157,5 +157,9 @@ void audioDefevent(uint8_t e);
|
||||
|
||||
#define PLAY_PHASE_OFF(phase)
|
||||
#define PLAY_PHASE_ON(phase)
|
||||
#define PLAY_SWITCH_MOVED(sw)
|
||||
#define PLAY_LOGICAL_SWITCH_OFF(sw)
|
||||
#define PLAY_LOGICAL_SWITCH_ON(sw)
|
||||
#define SKIP_AUTOMATIC_PROMPTS()
|
||||
|
||||
#endif
|
||||
|
||||
@@ -102,6 +102,10 @@ void beep(uint8_t val);
|
||||
|
||||
#define PLAY_PHASE_OFF(phase)
|
||||
#define PLAY_PHASE_ON(phase)
|
||||
#define PLAY_SWITCH_MOVED(sw)
|
||||
#define PLAY_LOGICAL_SWITCH_OFF(sw)
|
||||
#define PLAY_LOGICAL_SWITCH_ON(sw)
|
||||
#define SKIP_AUTOMATIC_PROMPTS()
|
||||
#endif
|
||||
|
||||
#if !defined(CPUARM)
|
||||
|
||||
@@ -144,7 +144,7 @@ PACK(typedef struct {
|
||||
int8_t swtch;
|
||||
uint8_t func;
|
||||
PACK(union {
|
||||
char name[LEN_CFN_NAME];
|
||||
char name[10];
|
||||
struct {
|
||||
int16_t val;
|
||||
int16_t ext1;
|
||||
@@ -193,7 +193,7 @@ PACK(typedef struct {
|
||||
int8_t points[NUM_POINTS];
|
||||
|
||||
LogicalSwitchData_v215 customSw[NUM_CSW];
|
||||
CustomFnData_v215 funcSw[NUM_CFN];
|
||||
CustomFnData_v215 funcSw[32];
|
||||
SwashRingData swashR;
|
||||
PhaseData_v215 phaseData[MAX_PHASES];
|
||||
|
||||
@@ -212,9 +212,27 @@ PACK(typedef struct {
|
||||
|
||||
}) ModelData_v215;
|
||||
|
||||
PACK(typedef struct {
|
||||
uint8_t version;
|
||||
uint16_t variant;
|
||||
int16_t calibMid[NUM_STICKS+NUM_POTS];
|
||||
int16_t calibSpanNeg[NUM_STICKS+NUM_POTS];
|
||||
int16_t calibSpanPos[NUM_STICKS+NUM_POTS];
|
||||
uint16_t chkSum;
|
||||
}) GeneralSettings_v215;
|
||||
|
||||
void ConvertGeneralSettings_215_to_216(EEGeneral &settings)
|
||||
{
|
||||
GeneralSettings_v215 oldSettings;
|
||||
memcpy(&oldSettings, &settings, sizeof(oldSettings));
|
||||
|
||||
settings.version = 216;
|
||||
for (int i=0; i<NUM_STICKS+NUM_POTS; i++) {
|
||||
settings.calib[i].mid = oldSettings.calibMid[i];
|
||||
settings.calib[i].spanNeg = oldSettings.calibSpanNeg[i];
|
||||
settings.calib[i].spanPos = oldSettings.calibSpanPos[i];
|
||||
}
|
||||
settings.chkSum = evalChkSum();
|
||||
}
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
@@ -575,7 +593,7 @@ void ConvertModel_215_to_216(ModelData &model)
|
||||
}
|
||||
|
||||
if (fn.func == FUNC_PLAY_TRACK || fn.func == FUNC_BACKGND_MUSIC) {
|
||||
memcpy(fn.play.name, oldModel.funcSw[i].param.name, LEN_CFN_NAME);
|
||||
memcpy(fn.play.name, oldModel.funcSw[i].param.name, 8);
|
||||
}
|
||||
else {
|
||||
fn.all.val = oldModel.funcSw[i].param.composite.val;
|
||||
@@ -592,6 +610,7 @@ void ConvertModel_215_to_216(ModelData &model)
|
||||
|
||||
for (uint8_t i=0; i<9; i++) {
|
||||
memcpy(&g_model.phaseData[i], &oldModel.phaseData[i], sizeof(oldModel.phaseData[i])); // the last 4 gvars will remain blank
|
||||
g_model.phaseData[i].swtch = ConvertSwitch_215_to_216(oldModel.phaseData[i].swtch);
|
||||
#if defined(PCBTARANIS)
|
||||
for (uint8_t t=0; t<4; t++) {
|
||||
int trim = oldModel.phaseData[i].trim[t];
|
||||
|
||||
@@ -404,7 +404,7 @@ void eeLoadModel(uint8_t id)
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM) && defined(SDCARD)
|
||||
refreshModelAudioFiles();
|
||||
referenceModelAudioFiles();
|
||||
#endif
|
||||
|
||||
LOAD_MODEL_BITMAP();
|
||||
|
||||
@@ -978,7 +978,7 @@ void eeLoadModel(uint8_t id)
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM) && defined(SDCARD)
|
||||
refreshModelAudioFiles();
|
||||
referenceModelAudioFiles();
|
||||
#endif
|
||||
|
||||
LOAD_MODEL_BITMAP();
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 448 B After Width: | Height: | Size: 448 B |
Binary file not shown.
|
Before Width: | Height: | Size: 449 B After Width: | Height: | Size: 449 B |
@@ -3077,7 +3077,7 @@ void gvarWeightItem(xcoord_t x, uint8_t y, MixData *md, uint8_t attr, uint8_t ev
|
||||
{
|
||||
u_int8int16_t weight;
|
||||
MD_WEIGHT_TO_UNION(md, weight);
|
||||
weight.word = GVAR_MENU_ITEM(x, y, weight.word, -500, 500, attr, 0, event);
|
||||
weight.word = GVAR_MENU_ITEM(x, y, weight.word, GV_RANGELARGE_WEIGHT_NEG, GV_RANGELARGE_WEIGHT, attr, 0, event);
|
||||
MD_UNION_TO_WEIGHT(weight, md);
|
||||
}
|
||||
|
||||
@@ -3155,7 +3155,7 @@ void menuModelMixOne(uint8_t event)
|
||||
lcd_putsColumnLeft(COLUMN_X, y, NO_INDENT(STR_OFFSET));
|
||||
u_int8int16_t offset;
|
||||
MD_OFFSET_TO_UNION(md2, offset);
|
||||
offset.word = GVAR_MENU_ITEM(COLUMN_X+MIXES_2ND_COLUMN, y, offset.word, GV_RANGELARGE_NEG, GV_RANGELARGE, attr|LEFT, 0, event);
|
||||
offset.word = GVAR_MENU_ITEM(COLUMN_X+MIXES_2ND_COLUMN, y, offset.word, GV_RANGELARGE_OFFSET_NEG, GV_RANGELARGE_OFFSET, attr|LEFT, 0, event);
|
||||
MD_UNION_TO_OFFSET(offset, md2);
|
||||
break;
|
||||
}
|
||||
@@ -5139,8 +5139,8 @@ void onModelCustomScriptMenu(const char *result)
|
||||
ScriptData &sd = g_model.scriptsData[s_currIdx];
|
||||
|
||||
if (result == STR_UPDATE_LIST) {
|
||||
if (!listSdFiles(SCRIPTS_PATH, MIXES_EXT, sizeof(sd.file), NULL)) {
|
||||
POPUP_WARNING(STR_NO_BITMAPS_ON_SD);
|
||||
if (!listSdFiles(SCRIPTS_PATH, SCRIPTS_EXT, sizeof(sd.file), NULL)) {
|
||||
POPUP_WARNING(STR_NO_SCRIPTS_ON_SD);
|
||||
s_menu_flags = 0;
|
||||
}
|
||||
}
|
||||
@@ -5187,7 +5187,7 @@ void menuModelCustomScriptOne(uint8_t event)
|
||||
lcd_putsiAtt(SCRIPT_ONE_2ND_COLUMN_POS, y, STR_VCSWFUNC, 0, attr);
|
||||
if (attr && event==EVT_KEY_BREAK(KEY_ENTER) && !READ_ONLY()) {
|
||||
s_editMode = 0;
|
||||
if (listSdFiles(SCRIPTS_PATH, MIXES_EXT, sizeof(sd.file), sd.file, LIST_NONE_SD_FILE)) {
|
||||
if (listSdFiles(SCRIPTS_PATH, SCRIPTS_EXT, sizeof(sd.file), sd.file, LIST_NONE_SD_FILE)) {
|
||||
menuHandler = onModelCustomScriptMenu;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -778,7 +778,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
|
||||
vertpos_t realPgOfs = s_pgOfs;
|
||||
vertpos_t realMaxrow = maxrow;
|
||||
for (vertpos_t i=1; i<=maxrow; i++) {
|
||||
if (horTab[i] == HIDDEN_ROW) {
|
||||
if (MAXCOL(i) == HIDDEN_ROW) {
|
||||
realMaxrow--;
|
||||
if (i < l_posVert)
|
||||
realPosVert--;
|
||||
@@ -790,7 +790,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
|
||||
else if (realPosVert<1+realPgOfs) realPgOfs = realPosVert-1;
|
||||
s_pgOfs = realPgOfs;
|
||||
for (vertpos_t i=1; i<=realPgOfs; i++) {
|
||||
if (horTab[i] == HIDDEN_ROW) {
|
||||
if (MAXCOL(i) == HIDDEN_ROW) {
|
||||
s_pgOfs++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,7 +318,9 @@ void displayTopBar()
|
||||
/* RTC time */
|
||||
struct gtm t;
|
||||
gettime(&t);
|
||||
lcd_putcAtt(BAR_TIME_X+1, BAR_Y+1, ':', BLINK);
|
||||
if (t.tm_sec % 2) {
|
||||
lcd_putcAtt(BAR_TIME_X+1, BAR_Y+1, ':', 0);
|
||||
}
|
||||
lcd_outdezNAtt(BAR_TIME_X+1, BAR_Y+1, t.tm_hour, LEADING0, 2);
|
||||
lcd_outdezNAtt(BAR_TIME_X+3*FWNUM-1, BAR_Y+1, t.tm_min, LEADING0, 2);
|
||||
|
||||
|
||||
+2
-2
@@ -935,10 +935,10 @@ void luaLoadModelScript(uint8_t index)
|
||||
sid.state = SCRIPT_NOFILE;
|
||||
|
||||
if (ZEXIST(sd.file)) {
|
||||
char filename[sizeof(SCRIPTS_PATH)+sizeof(sd.file)+sizeof(MIXES_EXT)] = SCRIPTS_PATH "/";
|
||||
char filename[sizeof(SCRIPTS_PATH)+sizeof(sd.file)+sizeof(SCRIPTS_EXT)] = SCRIPTS_PATH "/";
|
||||
strncpy(filename+sizeof(SCRIPTS_PATH), sd.file, sizeof(sd.file));
|
||||
filename[sizeof(SCRIPTS_PATH)+sizeof(sd.file)] = '\0';
|
||||
strcat(filename+sizeof(SCRIPTS_PATH), MIXES_EXT);
|
||||
strcat(filename+sizeof(SCRIPTS_PATH), SCRIPTS_EXT);
|
||||
luaLoad(filename, sid);
|
||||
}
|
||||
}
|
||||
|
||||
+22
-5
@@ -74,8 +74,8 @@
|
||||
#define MAX_MIXERS 64
|
||||
#define MAX_EXPOS 64
|
||||
#define NUM_CSW 32 // number of custom switches
|
||||
#define NUM_CFN 32 // number of functions assigned to switches
|
||||
#define MAX_SCRIPTS 3
|
||||
#define NUM_CFN 64 // number of functions assigned to switches
|
||||
#define MAX_SCRIPTS 7
|
||||
#define MAX_INPUTS 32
|
||||
#elif defined(CPUARM)
|
||||
#define MAX_MODELS 60
|
||||
@@ -84,7 +84,7 @@
|
||||
#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
|
||||
#define NUM_CFN 64 // number of functions assigned to switches
|
||||
#elif defined(CPUM2560) || defined(CPUM2561)
|
||||
#define MAX_MODELS 30
|
||||
#define NUM_CHNOUT 16 // number of real output channels CH1-CH16
|
||||
@@ -326,8 +326,9 @@ enum BacklightMode {
|
||||
#define SPLASH_MODE uint8_t splashMode:1; uint8_t spare4:2
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
#define POTS_POS_COUNT 6
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
PACK(typedef struct {
|
||||
uint8_t count;
|
||||
uint8_t steps[POTS_POS_COUNT-1];
|
||||
@@ -522,6 +523,16 @@ PACK(typedef struct t_LimitData {
|
||||
#define MLTPX_REP 2
|
||||
|
||||
#if defined(CPUARM)
|
||||
// highest bit used for small values in mix 128 --> 8 bit is enough
|
||||
#define GV1_SMALL 128
|
||||
// highest bit used for large values in mix 4096 --> 12 bits is used (type for weight and offset has even 16 bits)
|
||||
#define GV1_LARGE 4096
|
||||
// the define GV1_LARGE marks the highest bit value used for this variables
|
||||
// because this would give too big numbers for ARM, we limit it further for offset and weight
|
||||
// must be smaller than GV1_LARGE - RESERVE_RANGE_FOR_GVARS -1
|
||||
#define GV_RANGE_WEIGHT 500
|
||||
#define GV_RANGE_OFFSET 500
|
||||
|
||||
#define DELAY_STEP 10
|
||||
#define SLOW_STEP 10
|
||||
#define DELAY_MAX (25*DELAY_STEP) /* 25 seconds */
|
||||
@@ -587,6 +598,12 @@ PACK( union u_int8int16_t {
|
||||
// #define MD_SETOFFSET(md, val) md->offset = val
|
||||
|
||||
#else
|
||||
|
||||
// highest bit used for small values in mix 128 --> 8 bit is enough
|
||||
#define GV1_SMALL 128
|
||||
// highest bit used for large values in mix 256 --> 9 bits is used (8 bits + 1 extra bit from weightMode/offsetMode)
|
||||
#define GV1_LARGE 256
|
||||
|
||||
#define DELAY_STEP 2
|
||||
#define SLOW_STEP 2
|
||||
#define DELAY_MAX 15 /* 7.5 seconds */
|
||||
@@ -809,7 +826,7 @@ enum AdjustGvarFunctionParam {
|
||||
|
||||
#if defined(CPUARM)
|
||||
#if defined(PCBTARANIS)
|
||||
#define LEN_CFN_NAME 10
|
||||
#define LEN_CFN_NAME 8
|
||||
#else
|
||||
#define LEN_CFN_NAME 6
|
||||
#endif
|
||||
|
||||
+250
-114
@@ -51,6 +51,9 @@ int24_t act [MAX_MIXERS] = {0};
|
||||
SwOn swOn [MAX_MIXERS]; // TODO better name later...
|
||||
|
||||
uint8_t mixWarning;
|
||||
#if defined(MODULE_ALWAYS_SEND_PULSES)
|
||||
uint8_t startupWarningState;
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
#define MENUS_STACK_SIZE 2000
|
||||
@@ -1247,9 +1250,11 @@ getvalue_t getValue(uint8_t i)
|
||||
else if (i==MIXSRC_SH) return (switchState(SW_SH0) ? -1024 : 1024);
|
||||
else if (i<=MIXSRC_LAST_CSW) return getSwitch(SWSRC_FIRST_CSW+i-MIXSRC_FIRST_CSW) ? 1024 : -1024;
|
||||
#else
|
||||
else if (i==MIXSRC_3POS) return (switchState(SW_ID0) ? -1024 : (switchState(SW_ID1) ? 0 : 1024));
|
||||
else if (i==MIXSRC_3POS) return (getSwitch(SW_ID0-SW_BASE+1) ? -1024 : (getSwitch(SW_ID1-SW_BASE+1) ? 0 : 1024));
|
||||
// don't use switchState directly to give getSwitch possibility to hack values if needed for switch warning
|
||||
#if defined(EXTRA_3POS)
|
||||
else if (i==MIXSRC_3POS2) return (switchState(SW_ID3) ? -1024 : (switchState(SW_ID4) ? 0 : 1024));
|
||||
else if (i==MIXSRC_3POS2) return (getSwitch(SW_ID3-SW_BASE+1) ? -1024 : (getSwitch(SW_ID4-SW_BASE+1) ? 0 : 1024));
|
||||
// don't use switchState directly to give getSwitch possibility to hack values if needed for switch warning
|
||||
#endif
|
||||
else if (i<=MIXSRC_LAST_CSW) return getSwitch(SWSRC_THR+i-MIXSRC_THR) ? 1024 : -1024;
|
||||
#endif
|
||||
@@ -1309,7 +1314,6 @@ getvalue_t getValue(uint8_t i)
|
||||
|
||||
volatile GETSWITCH_RECURSIVE_TYPE s_last_switch_used = 0;
|
||||
volatile GETSWITCH_RECURSIVE_TYPE s_last_switch_value = 0;
|
||||
/* recursive function. stack as of today (16/03/2012) grows by 8bytes at each call, which is ok! */
|
||||
|
||||
#if defined(CPUARM)
|
||||
uint32_t cswDelays[NUM_CSW];
|
||||
@@ -1322,27 +1326,66 @@ tmr10ms_t switchesMidposStart[6] = { 0 };
|
||||
uint32_t switchesPos = 0;
|
||||
tmr10ms_t potsLastposStart[NUM_XPOTS];
|
||||
uint8_t potsPos[NUM_XPOTS];
|
||||
|
||||
uint32_t check2PosSwitchPosition(EnumKeys sw)
|
||||
{
|
||||
uint32_t result;
|
||||
uint32_t index;
|
||||
|
||||
if (switchState(sw))
|
||||
index = sw - SW_SA0;
|
||||
else
|
||||
index = sw - SW_SA0 + 1;
|
||||
|
||||
result = (1 << index);
|
||||
|
||||
if (!(switchesPos & result)) {
|
||||
PLAY_SWITCH_MOVED(index);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#define DELAY_SWITCH_3POS 10/*100ms*/
|
||||
#define CHECK_2POS(sw) newPos |= (switchState(sw ## 0) ? (1 << (sw ## 0 - SW_SA0)) : (1 << (sw ## 0 - SW_SA0 + 1)))
|
||||
#define CHECK_3POS(idx, sw) if (switchState(sw ## 0)) { \
|
||||
newPos |= (1 << (sw ## 0 - SW_SA0)); \
|
||||
switchesMidposStart[idx] = 0; \
|
||||
} \
|
||||
else if (switchState(sw ## 2)) { \
|
||||
newPos |= (1 << (sw ## 0 - SW_SA0 + 2)); \
|
||||
switchesMidposStart[idx] = 0; \
|
||||
} \
|
||||
else if ((switchesPos & (1 << (sw ## 0 - SW_SA0 + 1))) || (switchesMidposStart[idx] && (tmr10ms_t)(get_tmr10ms() - switchesMidposStart[idx]) > DELAY_SWITCH_3POS)) { \
|
||||
newPos |= (1 << (sw ## 0 - SW_SA0 + 1)); \
|
||||
switchesMidposStart[idx] = 0; \
|
||||
} \
|
||||
else { \
|
||||
if (!switchesMidposStart[idx]) { \
|
||||
switchesMidposStart[idx] = get_tmr10ms(); \
|
||||
} \
|
||||
newPos |= (switchesPos & (0x7 << (sw ## 0 - SW_SA0))); \
|
||||
}
|
||||
void getSwitchesPosition()
|
||||
uint32_t check3PosSwitchPosition(uint8_t idx, EnumKeys sw, bool startup)
|
||||
{
|
||||
uint32_t result;
|
||||
uint32_t index;
|
||||
|
||||
if (switchState(sw)) {
|
||||
index = sw - SW_SA0;
|
||||
result = (1 << index);
|
||||
switchesMidposStart[idx] = 0;
|
||||
}
|
||||
else if (switchState(EnumKeys(sw+2))) {
|
||||
index = sw - SW_SA0 + 2;
|
||||
result = (1 << index);
|
||||
switchesMidposStart[idx] = 0;
|
||||
}
|
||||
else if (startup || (switchesPos & (1 << (sw - SW_SA0 + 1))) || (switchesMidposStart[idx] && (tmr10ms_t)(get_tmr10ms() - switchesMidposStart[idx]) > DELAY_SWITCH_3POS)) {
|
||||
index = sw - SW_SA0 + 1;
|
||||
result = (1 << index);
|
||||
switchesMidposStart[idx] = 0;
|
||||
}
|
||||
else {
|
||||
index = sw - SW_SA0 + 1;
|
||||
if (!switchesMidposStart[idx]) {
|
||||
switchesMidposStart[idx] = get_tmr10ms();
|
||||
}
|
||||
result = (switchesPos & (0x7 << (sw - SW_SA0)));
|
||||
}
|
||||
|
||||
if (!(switchesPos & result)) {
|
||||
PLAY_SWITCH_MOVED(index);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#define CHECK_2POS(sw) newPos |= check2PosSwitchPosition(sw ## 0)
|
||||
#define CHECK_3POS(idx, sw) newPos |= check3PosSwitchPosition(idx, sw ## 0, startup)
|
||||
|
||||
void getSwitchesPosition(bool startup)
|
||||
{
|
||||
uint32_t newPos = 0;
|
||||
CHECK_3POS(0, SW_SA);
|
||||
@@ -1361,13 +1404,17 @@ void getSwitchesPosition()
|
||||
if (calib->count>0 && calib->count<POTS_POS_COUNT) {
|
||||
uint8_t pos = anaIn(POT1+i) / (2*RESX/calib->count);
|
||||
uint8_t previousPos = potsPos[i] >> 4;
|
||||
uint8_t previousStoredPos = potsPos[i] & 0x0F;
|
||||
if (pos != previousPos) {
|
||||
potsLastposStart[i] = get_tmr10ms();
|
||||
potsPos[i] = (pos << 4) | (potsPos[i] & 0x0f);
|
||||
potsPos[i] = (pos << 4) | previousStoredPos;
|
||||
}
|
||||
else if ((tmr10ms_t)(get_tmr10ms() - potsLastposStart[i]) > DELAY_SWITCH_3POS) {
|
||||
else if (startup || (tmr10ms_t)(get_tmr10ms() - potsLastposStart[i]) > DELAY_SWITCH_3POS) {
|
||||
potsLastposStart[i] = 0;
|
||||
potsPos[i] = (pos << 4) | (pos);
|
||||
potsPos[i] = (pos << 4) | pos;
|
||||
if (previousStoredPos != pos) {
|
||||
PLAY_SWITCH_MOVED(SWSRC_LAST_SWITCH+i*POTS_POS_COUNT+pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1376,12 +1423,14 @@ void getSwitchesPosition()
|
||||
#define SWITCH_POSITION(sw) (switchesPos & (1<<(sw)))
|
||||
#define POT_POSITION(sw) ((potsPos[(sw)/POTS_POS_COUNT] & 0x0f) == ((sw) % POTS_POS_COUNT))
|
||||
#else
|
||||
#define getSwitchesPosition()
|
||||
#define getSwitchesPosition(...)
|
||||
#define SWITCH_POSITION(idx) switchState((EnumKeys)(SW_BASE+(idx)))
|
||||
#endif
|
||||
|
||||
int16_t csLastValue[NUM_CSW];
|
||||
#define CS_LAST_VALUE_INIT -32768
|
||||
|
||||
/* recursive function. stack as of today (16/03/2012) grows by 8bytes at each call, which is ok! */
|
||||
bool getSwitch(int8_t swtch)
|
||||
{
|
||||
bool result;
|
||||
@@ -1396,6 +1445,20 @@ bool getSwitch(int8_t swtch)
|
||||
}
|
||||
else if (cs_idx <= SWSRC_LAST_SWITCH) {
|
||||
result = SWITCH_POSITION(cs_idx-SWSRC_FIRST_SWITCH);
|
||||
#if defined(MODULE_ALWAYS_SEND_PULSES)
|
||||
if (startupWarningState < STARTUP_WARNING_DONE) {
|
||||
// if throttle or switch warning is currently active, ignore actual stick position and use wanted values
|
||||
if (cs_idx <= 3) {
|
||||
if (!(g_model.nSwToWarn&1)) { // ID1 to ID3 is just one bit in nSwToWarn
|
||||
result = (cs_idx)==((g_model.switchWarningStates&3)+1); // overwrite result with desired value
|
||||
}
|
||||
}
|
||||
else if (!(g_model.nSwToWarn & (1<<(cs_idx-3)))) {
|
||||
// current switch should not be ignored for warning
|
||||
result = g_model.switchWarningStates & (1<<(cs_idx-2)); // overwrite result with desired value
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#if defined(PCBTARANIS)
|
||||
else if (cs_idx <= SWSRC_P26) {
|
||||
@@ -1587,10 +1650,14 @@ bool getSwitch(int8_t swtch)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (result)
|
||||
if (result) {
|
||||
if (!(s_last_switch_value&mask)) PLAY_LOGICAL_SWITCH_ON(cs_idx);
|
||||
s_last_switch_value |= mask;
|
||||
else
|
||||
}
|
||||
else {
|
||||
if (s_last_switch_value&mask) PLAY_LOGICAL_SWITCH_OFF(cs_idx);
|
||||
s_last_switch_value &= ~mask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1621,26 +1688,23 @@ int8_t getMovedSwitch()
|
||||
}
|
||||
}
|
||||
#else
|
||||
for (uint8_t i=NUM_PSWITCH; i>0; i--) {
|
||||
// return delivers 1 to 3 for ID1 to ID3
|
||||
// 4..8 for all other switches if changed to true
|
||||
// -4..-8 for all other switches if changed to false
|
||||
// 9 for Trainer switch if changed to true; Change to false is ignored
|
||||
swstate_t mask = 0x80;
|
||||
for (uint8_t i=NUM_PSWITCH; i>1; i--) {
|
||||
bool prev;
|
||||
swstate_t mask = 0;
|
||||
if (i <= 3) {
|
||||
prev = ((switches_states & 0x03) == (i-1));
|
||||
}
|
||||
else {
|
||||
mask = (1<<(i-2));
|
||||
prev = (switches_states & mask);
|
||||
}
|
||||
bool next = getSwitch(i);
|
||||
prev = (switches_states & mask);
|
||||
// don't use getSwitch here to always get the proper value, even getSwitch manipulates
|
||||
bool next = switchState((EnumKeys)(SW_BASE+i-1));
|
||||
if (prev != next) {
|
||||
if (i!=NUM_PSWITCH || next==true)
|
||||
if (((i<NUM_PSWITCH) && (i>3)) || next==true)
|
||||
result = next ? i : -i;
|
||||
if (mask)
|
||||
switches_states ^= mask;
|
||||
else {
|
||||
switches_states = (switches_states & 0xFC) | (i-1);
|
||||
}
|
||||
if (i<=3 && result==0) result = 1;
|
||||
switches_states ^= mask;
|
||||
}
|
||||
mask >>= 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2237,8 +2301,12 @@ void checkAll()
|
||||
checkLowEEPROM();
|
||||
#endif
|
||||
|
||||
#if defined(MODULE_ALWAYS_SEND_PULSES)
|
||||
startupWarningState = STARTUP_WARNING_THROTTLE;
|
||||
#else
|
||||
checkTHR();
|
||||
checkSwitches();
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
if (modelHasNotes() && g_model.displayText) {
|
||||
@@ -2250,8 +2318,22 @@ void checkAll()
|
||||
#endif
|
||||
|
||||
clearKeyEvents();
|
||||
|
||||
SKIP_AUTOMATIC_PROMPTS();
|
||||
}
|
||||
|
||||
#if defined(MODULE_ALWAYS_SEND_PULSES)
|
||||
void checkStartupWarnings()
|
||||
{
|
||||
if (startupWarningState < STARTUP_WARNING_DONE) {
|
||||
if (startupWarningState == STARTUP_WARNING_THROTTLE)
|
||||
checkTHR();
|
||||
else
|
||||
checkSwitches();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(PCBSKY9X)
|
||||
void checkLowEEPROM()
|
||||
{
|
||||
@@ -2264,105 +2346,136 @@ void checkLowEEPROM()
|
||||
|
||||
void checkTHR()
|
||||
{
|
||||
if (g_model.disableThrottleWarning) return;
|
||||
uint8_t thrchn = ((g_model.thrTraceSrc==0) || (g_model.thrTraceSrc>NUM_POTS)) ? THR_STICK : g_model.thrTraceSrc+NUM_STICKS-1;
|
||||
// throttle channel is either the stick according stick mode (already handled in evalInputs)
|
||||
// or P1 to P3;
|
||||
// in case an output channel is choosen as throttle source (thrTraceSrc>NUM_POTS) we assume the throttle stick is the input
|
||||
// no other information available at the moment, and good enough to my option (otherwise too much exceptions...)
|
||||
|
||||
uint8_t thrchn = (2-(stickMode&1)); //stickMode=0123 -> thr=2121
|
||||
|
||||
#ifdef SIMU
|
||||
int16_t lowLim = THRCHK_DEADBAND - 1024 ;
|
||||
#else
|
||||
getADC(); // if thr is down - do not display warning at all
|
||||
CalibData * calib = &g_eeGeneral.calib[thrchn];
|
||||
int16_t lowLim = calib->mid;
|
||||
lowLim = (g_model.throttleReversed ? - lowLim - calib->spanPos : lowLim - calib->spanNeg);
|
||||
lowLim += THRCHK_DEADBAND;
|
||||
#endif
|
||||
int16_t v = thrAnaIn(thrchn);
|
||||
|
||||
if (v<=lowLim) return;
|
||||
|
||||
// first - display warning
|
||||
MESSAGE(STR_THROTTLEWARN, STR_THROTTLENOTIDLE, STR_PRESSANYKEYTOSKIP, AU_THROTTLE_ALERT);
|
||||
|
||||
while (1)
|
||||
{
|
||||
SIMU_SLEEP(1);
|
||||
|
||||
getADC();
|
||||
|
||||
int16_t v = thrAnaIn(thrchn);
|
||||
|
||||
if (pwrCheck()==e_power_off || keyDown() || v<=lowLim)
|
||||
break;
|
||||
|
||||
checkBacklight();
|
||||
|
||||
wdt_reset();
|
||||
#if defined(MODULE_ALWAYS_SEND_PULSES)
|
||||
int16_t v = calibratedStick[thrchn];
|
||||
if (v<=THRCHK_DEADBAND-1024 || g_model.disableThrottleWarning || pwrCheck()==e_power_off || keyDown()) {
|
||||
startupWarningState = STARTUP_WARNING_THROTTLE+1;
|
||||
}
|
||||
else {
|
||||
calibratedStick[thrchn] = -1024;
|
||||
#if !defined(PCBTARANIS)
|
||||
rawAnas[thrchn] = anas[thrchn] = calibratedStick[thrchn];
|
||||
#endif
|
||||
MESSAGE(STR_THROTTLEWARN, STR_THROTTLENOTIDLE, STR_PRESSANYKEYTOSKIP, AU_THROTTLE_ALERT);
|
||||
}
|
||||
#else
|
||||
if (g_model.disableThrottleWarning) return;
|
||||
getADC();
|
||||
evalInputs(e_perout_mode_notrainer); // let do evalInputs do the job
|
||||
|
||||
int16_t v = calibratedStick[thrchn];
|
||||
if (v<=(THRCHK_DEADBAND-1024)) return; // prevent warning if throttle input OK
|
||||
|
||||
// first - display warning; also deletes inputs if any have been before
|
||||
MESSAGE(STR_THROTTLEWARN, STR_THROTTLENOTIDLE, STR_PRESSANYKEYTOSKIP, AU_THROTTLE_ALERT);
|
||||
|
||||
while (1) {
|
||||
|
||||
SIMU_SLEEP(1);
|
||||
|
||||
getADC();
|
||||
|
||||
evalInputs(e_perout_mode_notrainer); // let do evalInputs do the job
|
||||
v = calibratedStick[thrchn];
|
||||
|
||||
if (pwrCheck()==e_power_off || keyDown() || v<=(THRCHK_DEADBAND-1024))
|
||||
break;
|
||||
|
||||
checkBacklight();
|
||||
|
||||
wdt_reset();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void checkAlarm() // added by Gohst
|
||||
{
|
||||
if (g_eeGeneral.disableAlarmWarning) return;
|
||||
if (IS_SOUND_OFF()) ALERT(STR_ALARMSWARN, STR_ALARMSDISABLED, AU_ERROR);
|
||||
if (g_eeGeneral.disableAlarmWarning)
|
||||
return;
|
||||
|
||||
if (IS_SOUND_OFF())
|
||||
ALERT(STR_ALARMSWARN, STR_ALARMSDISABLED, AU_ERROR);
|
||||
}
|
||||
|
||||
void checkSwitches()
|
||||
{
|
||||
#if defined(MODULE_ALWAYS_SEND_PULSES)
|
||||
static swstate_t last_bad_switches = 0xff;
|
||||
#else
|
||||
swstate_t last_bad_switches = 0xff;
|
||||
#endif
|
||||
swstate_t states = g_model.switchWarningStates;
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
uint8_t bad_pots = 0, last_bad_pots = 0xff;
|
||||
#endif
|
||||
|
||||
#if !defined(MODULE_ALWAYS_SEND_PULSES)
|
||||
while (1) {
|
||||
|
||||
#if defined(TELEMETRY_MOD_14051) || defined(PCBTARANIS)
|
||||
getADC();
|
||||
#endif
|
||||
#endif // !defined(MODULE_ALWAYS_SEND_PULSES)
|
||||
|
||||
getMovedSwitch();
|
||||
|
||||
uint8_t warn = false;
|
||||
bool warn = false;
|
||||
#if defined(PCBTARANIS)
|
||||
for (uint8_t i=0; i<NUM_SWITCHES-1; i++) {
|
||||
if (!(g_model.nSwToWarn & (1<<i))) {
|
||||
swstate_t mask = (0x03 << (i*2));
|
||||
if(!((states & mask) == (switches_states & mask)))
|
||||
if (!((states & mask) == (switches_states & mask))) {
|
||||
warn = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
uint8_t potMode = g_model.nPotsToWarn >> 6;
|
||||
if(potMode) {
|
||||
if (potMode) {
|
||||
perOut(e_perout_mode_normal, 0);
|
||||
bad_pots = 0;
|
||||
for (uint8_t i=0; i<NUM_POTS; i++)
|
||||
if(!(g_model.nPotsToWarn & (1 << i)) && (abs(g_model.potPosition[i] - (getValue(MIXSRC_FIRST_POT+i) >> 3)) > 2)) {
|
||||
warn = true;
|
||||
bad_pots |= (1<<i);
|
||||
}
|
||||
for (uint8_t i=0; i<NUM_POTS; i++) {
|
||||
if (!(g_model.nPotsToWarn & (1 << i)) && (abs(g_model.potPosition[i] - (getValue(MIXSRC_FIRST_POT+i) >> 3)) > 2)) {
|
||||
warn = true;
|
||||
bad_pots |= (1<<i);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
for (uint8_t i=0; i<NUM_SWITCHES-1; i++) {
|
||||
if (!(g_model.nSwToWarn & (1<<i))) {
|
||||
if (i == 0) {
|
||||
if((states & 0x03) != (switches_states & 0x03))
|
||||
warn = true;
|
||||
}
|
||||
else if((states & (1<<(i+1))) != (switches_states & (1<<(i+1))))
|
||||
warn = true;
|
||||
if ((states & 0x03) != (switches_states & 0x03)) {
|
||||
warn = true;
|
||||
}
|
||||
}
|
||||
else if ((states & (1<<(i+1))) != (switches_states & (1<<(i+1)))) {
|
||||
warn = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if(!warn) return;
|
||||
if (!warn) {
|
||||
#if defined(MODULE_ALWAYS_SEND_PULSES)
|
||||
startupWarningState = STARTUP_WARNING_SWITCHES+1;
|
||||
last_bad_switches = 0xff;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// first - display warning
|
||||
#if defined(PCBTARANIS)
|
||||
if ((last_bad_switches != switches_states) || (last_bad_pots != bad_pots)) {
|
||||
MESSAGE(STR_SWITCHWARN, NULL, STR_PRESSANYKEYTOSKIP, ((last_bad_switches == 0xff) || (last_bad_pots == 0xff)) ? AU_SWITCH_ALERT : AU_NONE);
|
||||
for (uint8_t i=0; i<NUM_SWITCHES-1; i++) {
|
||||
if(!(g_model.nSwToWarn & (1<<i))) {
|
||||
if (!(g_model.nSwToWarn & (1<<i))) {
|
||||
swstate_t mask = (0x03 << (i*2));
|
||||
uint8_t attr = ((states & mask) == (switches_states & mask)) ? 0 : INVERS;
|
||||
char c = "\300-\301"[(states & mask) >> (i*2)];
|
||||
@@ -2370,7 +2483,7 @@ void checkSwitches()
|
||||
lcd_putcAtt(60+i*(2*FW+FW/2)+FW, 4*FH+3, c, attr);
|
||||
}
|
||||
}
|
||||
if(potMode) {
|
||||
if (potMode) {
|
||||
for (uint8_t i=0; i<NUM_POTS; i++) {
|
||||
if (!(g_model.nPotsToWarn & (1 << i))) {
|
||||
uint8_t flags = 0;
|
||||
@@ -2380,8 +2493,8 @@ void checkSwitches()
|
||||
case 1:
|
||||
lcd_putc(60+i*(5*FW)+2*FW+2, 6*FH-2, g_model.potPosition[i] > (getValue(MIXSRC_FIRST_POT+i) >> 3) ? 126 : 127);
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
case 2:
|
||||
case 3:
|
||||
lcd_putc(60+i*(5*FW)+2*FW+2, 6*FH-2, g_model.potPosition[i] > (getValue(MIXSRC_FIRST_POT+i) >> 3) ? '\300' : '\301');
|
||||
break;
|
||||
}
|
||||
@@ -2399,11 +2512,11 @@ void checkSwitches()
|
||||
for (uint8_t i=0; i<NUM_SWITCHES-1; i++) {
|
||||
uint8_t attr;
|
||||
if (i == 0)
|
||||
attr = ((states & 0x03) != (switches_states & 0x03)) ? INVERS : 0;
|
||||
attr = ((states & 0x03) != (switches_states & 0x03)) ? INVERS : 0;
|
||||
else
|
||||
attr = (states & (1 << (i+1))) == (switches_states & (1 << (i+1))) ? 0 : INVERS;
|
||||
if(!(g_model.nSwToWarn & (1<<i)))
|
||||
putsSwitches(x, 5*FH, (i>0?(i+3):(states&0x3)+1), attr);
|
||||
attr = (states & (1 << (i+1))) == (switches_states & (1 << (i+1))) ? 0 : INVERS;
|
||||
if (!(g_model.nSwToWarn & (1<<i)))
|
||||
putsSwitches(x, 5*FH, (i>0?(i+3):(states&0x3)+1), attr);
|
||||
x += 3*FW+FW/2;
|
||||
}
|
||||
#endif
|
||||
@@ -2411,7 +2524,13 @@ void checkSwitches()
|
||||
last_bad_switches = switches_states;
|
||||
}
|
||||
|
||||
if (pwrCheck()==e_power_off || keyDown()) return; // Usb on or power off
|
||||
#if defined(MODULE_ALWAYS_SEND_PULSES)
|
||||
if (pwrCheck()==e_power_off || keyDown()) {
|
||||
startupWarningState = STARTUP_WARNING_SWITCHES+1;
|
||||
last_bad_switches = 0xff;
|
||||
}
|
||||
#else
|
||||
if (pwrCheck()==e_power_off || keyDown()) return;
|
||||
|
||||
checkBacklight();
|
||||
|
||||
@@ -2419,6 +2538,7 @@ void checkSwitches()
|
||||
|
||||
SIMU_SLEEP(1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void alert(const pm_char * t, const pm_char *s MESSAGE_SOUND_ARG)
|
||||
@@ -2640,12 +2760,6 @@ uint16_t BandGap = 2040 ;
|
||||
uint16_t BandGap ;
|
||||
#endif
|
||||
|
||||
int16_t thrAnaIn(uint8_t chan)
|
||||
{
|
||||
int16_t v = anaIn(chan);
|
||||
return (g_model.throttleReversed) ? -v : v;
|
||||
}
|
||||
|
||||
#if !defined(SIMU)
|
||||
uint16_t anaIn(uint8_t chan)
|
||||
{
|
||||
@@ -2861,11 +2975,14 @@ void resetAll()
|
||||
#if defined(FRSKY)
|
||||
resetTelemetry();
|
||||
#endif
|
||||
for (uint8_t i=0; i<NUM_CSW; i++)
|
||||
for (uint8_t i=0; i<NUM_CSW; i++) {
|
||||
csLastValue[i] = CS_LAST_VALUE_INIT;
|
||||
}
|
||||
|
||||
s_last_switch_value = 0;
|
||||
|
||||
SKIP_AUTOMATIC_PROMPTS();
|
||||
|
||||
RESET_THR_TRACE();
|
||||
}
|
||||
|
||||
@@ -3503,6 +3620,10 @@ void perOut(uint8_t mode, uint8_t tick10ms)
|
||||
{
|
||||
evalInputs(mode);
|
||||
|
||||
#if defined(MODULE_ALWAYS_SEND_PULSES)
|
||||
checkStartupWarnings();
|
||||
#endif
|
||||
|
||||
#if defined(HELI)
|
||||
if (g_model.swashR.value) {
|
||||
uint32_t v = ((int32_t)anas[ELE_STICK]*anas[ELE_STICK] + (int32_t)anas[AIL_STICK]*anas[AIL_STICK]);
|
||||
@@ -3859,17 +3980,25 @@ void doMixerCalculations()
|
||||
PORTH |= 0x40; // PORTH:6 LOW->HIGH signals start of mixer interrupt
|
||||
#endif
|
||||
|
||||
static tmr10ms_t lastTMR;
|
||||
static tmr10ms_t lastTMR = 0;
|
||||
|
||||
tmr10ms_t tmr10ms = get_tmr10ms();
|
||||
uint8_t tick10ms = (tmr10ms >= lastTMR ? tmr10ms - lastTMR : 1); // handle tick10ms overrun
|
||||
//@@@ open.20.fsguruh: correct overflow handling costs a lot of code; happens only each 11 min;
|
||||
uint8_t tick10ms = (tmr10ms >= lastTMR ? tmr10ms - lastTMR : 1);
|
||||
// handle tick10ms overrun
|
||||
// correct overflow handling costs a lot of code; happens only each 11 min;
|
||||
// therefore forget the exact calculation and use only 1 instead; good compromise
|
||||
|
||||
#if !defined(CPUARM)
|
||||
lastTMR = tmr10ms;
|
||||
#endif
|
||||
|
||||
getADC();
|
||||
|
||||
getSwitchesPosition();
|
||||
getSwitchesPosition(lastTMR == 0);
|
||||
|
||||
#if defined(CPUARM)
|
||||
lastTMR = tmr10ms;
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X) && !defined(REVA) && !defined(SIMU)
|
||||
Current_analogue = (Current_analogue*31 + s_anaFilt[8] ) >> 5 ;
|
||||
@@ -4483,6 +4612,13 @@ void perMain()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MODULE_ALWAYS_SEND_PULSES)
|
||||
if (startupWarningState < STARTUP_WARNING_DONE) {
|
||||
// don't do menu's until throttle and switch warnings are handled
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!usbPlugged()) {
|
||||
// TODO merge these 2 branches
|
||||
#if defined(PCBSKY9X)
|
||||
|
||||
+29
-7
@@ -803,6 +803,18 @@ enum PerOutMode {
|
||||
e_perout_mode_noinput = e_perout_mode_notrainer+e_perout_mode_notrims+e_perout_mode_nosticks
|
||||
};
|
||||
|
||||
|
||||
#if defined(MODULE_ALWAYS_SEND_PULSES)
|
||||
extern uint8_t startupWarningState;
|
||||
|
||||
enum StartupWarningStates {
|
||||
STARTUP_WARNING_THROTTLE,
|
||||
STARTUP_WARNING_SWITCHES,
|
||||
STARTUP_WARNING_DONE,
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
// Fiddle to force compiler to use a pointer
|
||||
#if defined(CPUARM) || defined(SIMU)
|
||||
#define FORCE_INDIRECT(ptr)
|
||||
@@ -894,13 +906,9 @@ void setTrimValue(uint8_t phase, uint8_t idx, int trim);
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
#define GV1_SMALL 128
|
||||
#define GV1_LARGE 4096
|
||||
#define GV_GET_GV1_VALUE(max) ( (max<=GV_RANGESMALL && min>=GV_RANGESMALL_NEG) ? GV1_SMALL : GV1_LARGE )
|
||||
#define GV_INDEX_CALCULATION(x,max) ( (max<=GV_RANGESMALL && min>=GV_RANGESMALL_NEG) ? (uint8_t) x-GV1_SMALL : ((x&(GV1_LARGE*2-1))-GV1_LARGE) )
|
||||
#else
|
||||
#define GV1_SMALL 128
|
||||
#define GV1_LARGE 256
|
||||
#define GV_GET_GV1_VALUE(max) ( (max<=GV_RANGESMALL) ? GV1_SMALL : GV1_LARGE )
|
||||
#define GV_INDEX_CALCULATION(x,max) ( (max<=GV1_SMALL) ? (uint8_t) x-GV1_SMALL : ((x&(GV1_LARGE*2-1))-GV1_LARGE) )
|
||||
#endif
|
||||
@@ -915,6 +923,21 @@ void setTrimValue(uint8_t phase, uint8_t idx, int trim);
|
||||
#define GV_RANGESMALL_NEG (-GV1_SMALL + (RESERVE_RANGE_FOR_GVARS+1))
|
||||
#define GV_RANGELARGE (GV1_LARGE - (RESERVE_RANGE_FOR_GVARS+1))
|
||||
#define GV_RANGELARGE_NEG (-GV1_LARGE + (RESERVE_RANGE_FOR_GVARS+1))
|
||||
#if defined(CPUARM)
|
||||
// the define GV1_LARGE marks the highest bit value used for this variables
|
||||
// because this would give too big numbers for ARM, we limit it further for
|
||||
// offset and weight
|
||||
#define GV_RANGELARGE_WEIGHT (GV_RANGE_WEIGHT)
|
||||
#define GV_RANGELARGE_WEIGHT_NEG (-GV_RANGE_WEIGHT)
|
||||
#define GV_RANGELARGE_OFFSET (GV_RANGE_OFFSET)
|
||||
#define GV_RANGELARGE_OFFSET_NEG (-GV_RANGE_OFFSET)
|
||||
#else
|
||||
// for stock we just use as much as possible
|
||||
#define GV_RANGELARGE_WEIGHT GV_RANGELARGE
|
||||
#define GV_RANGELARGE_WEIGHT_NEG GV_RANGELARGE_NEG
|
||||
#define GV_RANGELARGE_OFFSET GV_RANGELARGE
|
||||
#define GV_RANGELARGE_OFFSET_NEG GV_RANGELARGE_NEG
|
||||
#endif
|
||||
|
||||
extern uint16_t s_timeCumTot;
|
||||
extern uint16_t s_timeCumThr;
|
||||
@@ -1211,8 +1234,8 @@ int applyCurve(int x, int8_t idx);
|
||||
void applyExpos(int16_t *anas, uint8_t mode APPLY_EXPOS_EXTRA_PARAMS_INC);
|
||||
int16_t applyLimits(uint8_t channel, int32_t value);
|
||||
|
||||
void evalInputs(uint8_t mode);
|
||||
uint16_t anaIn(uint8_t chan);
|
||||
int16_t thrAnaIn(uint8_t chan);
|
||||
extern int16_t calibratedStick[NUM_STICKS+NUM_POTS];
|
||||
|
||||
#define FLASH_DURATION 20 /*200ms*/
|
||||
@@ -1620,8 +1643,7 @@ uint8_t zlen(const char *str, uint8_t size);
|
||||
bool zexist(const char *str, uint8_t size);
|
||||
char * strcat_zchar(char * dest, char * name, uint8_t size, const char *defaultName, uint8_t defaultNameSize, uint8_t defaultIdx);
|
||||
#define strcat_modelname(dest, idx) strcat_zchar(dest, modelHeaders[idx].name, LEN_MODEL_NAME, STR_MODEL, PSIZE(TR_MODEL), idx+1)
|
||||
#define strcat_phasename(dest, idx) strcat_zchar(dest, g_model.phaseData[idx].name, LEN_FP_NAME, NULL, 0, 0)
|
||||
#define strcat_mixername(dest, idx) strcat_zchar(dest, g_model.mixData[idx].name, LEN_EXPOMIX_NAME, NULL, 0, 0)
|
||||
#define strcat_phasename(dest, idx) strcat_zchar(dest, g_model.phaseData[idx].name, LEN_FP_NAME, STR_FP, PSIZE(TR_FP), idx+1)
|
||||
#define ZLEN(s) zlen(s, sizeof(s))
|
||||
#define ZEXIST(s) zexist(s, sizeof(s))
|
||||
#endif
|
||||
|
||||
+1
-2
@@ -44,7 +44,7 @@
|
||||
#define LOGS_PATH ROOT_PATH "LOGS" // no trailing slash = important
|
||||
#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 SYSTEM_SUBDIR "SYSTEM" // no trailing slash = important
|
||||
#define BITMAPS_PATH ROOT_PATH "BMP"
|
||||
#define SCRIPTS_PATH ROOT_PATH "SCRIPTS"
|
||||
|
||||
@@ -53,7 +53,6 @@
|
||||
#define SOUNDS_EXT ".wav"
|
||||
#define BITMAPS_EXT ".bmp"
|
||||
#define SCRIPTS_EXT ".lua"
|
||||
#define MIXES_EXT ".mix"
|
||||
#define TEXT_EXT ".txt"
|
||||
|
||||
extern FATFS g_FATFS_Obj;
|
||||
|
||||
@@ -300,7 +300,7 @@ void *main_thread(void *)
|
||||
eeReadAll(); // load general setup and selected model
|
||||
|
||||
#if defined(CPUARM) && defined(SDCARD)
|
||||
refreshSystemAudioFiles();
|
||||
referenceSystemAudioFiles();
|
||||
#endif
|
||||
|
||||
if (g_eeGeneral.backlightMode != e_backlight_mode_off) backlightOn(); // on Tx start turn the light on
|
||||
@@ -473,9 +473,10 @@ char *convertSimuPath(const char *path)
|
||||
|
||||
FRESULT f_stat (const TCHAR * name, FILINFO *)
|
||||
{
|
||||
char *path = convertSimuPath(name);
|
||||
struct stat tmp;
|
||||
// printf("f_stat(%s)\n", path); fflush(stdout);
|
||||
return stat(convertSimuPath(name), &tmp) ? FR_INVALID_NAME : FR_OK;
|
||||
TRACE("f_stat(%s)", path);
|
||||
return stat(path, &tmp) ? FR_INVALID_NAME : FR_OK;
|
||||
}
|
||||
|
||||
FRESULT f_mount (BYTE, FATFS*)
|
||||
@@ -550,9 +551,11 @@ FRESULT f_readdir (DIR * rep, FILINFO * fil)
|
||||
fil->fattrib = (ent->d_type == DT_DIR ? AM_DIR : 0);
|
||||
#else
|
||||
if (ent->d_type == simu::DT_UNKNOWN) {
|
||||
fil->fattrib = 0;
|
||||
struct stat buf;
|
||||
lstat(ent->d_name, &buf);
|
||||
fil->fattrib = (S_ISDIR(buf.st_mode) ? AM_DIR : 0);
|
||||
if (stat(ent->d_name, &buf) == 0) {
|
||||
fil->fattrib = (S_ISDIR(buf.st_mode) ? AM_DIR : 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
fil->fattrib = (ent->d_type == simu::DT_DIR ? AM_DIR : 0);
|
||||
@@ -563,6 +566,7 @@ FRESULT f_readdir (DIR * rep, FILINFO * fil)
|
||||
memset(fil->lfname, 0, SD_SCREEN_FILE_LENGTH);
|
||||
strncpy(fil->fname, ent->d_name, 13-1);
|
||||
strcpy(fil->lfname, ent->d_name);
|
||||
// TRACE("f_readdir(): %s", fil->fname);
|
||||
return FR_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -1014,7 +1014,7 @@ void sdMountPoll()
|
||||
|
||||
case SD_ST_DATA:
|
||||
if (!usbPlugged() && f_mount(0, &g_FATFS_Obj) == FR_OK) {
|
||||
refreshSystemAudioFiles();
|
||||
referenceSystemAudioFiles();
|
||||
Card_state = SD_ST_MOUNTED;
|
||||
}
|
||||
break;
|
||||
@@ -1082,7 +1082,7 @@ void sdInit()
|
||||
Card_state = SD_ST_DATA;
|
||||
|
||||
if (f_mount(0, &g_FATFS_Obj) == FR_OK) {
|
||||
refreshSystemAudioFiles();
|
||||
referenceSystemAudioFiles();
|
||||
Card_state = SD_ST_MOUNTED;
|
||||
}
|
||||
|
||||
|
||||
@@ -969,7 +969,7 @@ FIL g_telemetryFile = {0};
|
||||
void sdInit()
|
||||
{
|
||||
if (f_mount(0, &g_FATFS_Obj) == FR_OK) {
|
||||
refreshSystemAudioFiles();
|
||||
referenceSystemAudioFiles();
|
||||
|
||||
#if defined(DEBUG)
|
||||
f_open(&g_telemetryFile, LOGS_PATH "/sport.log", FA_OPEN_ALWAYS | FA_WRITE);
|
||||
|
||||
@@ -124,7 +124,7 @@ extern "C" void TIM3_IRQHandler()
|
||||
val = (uint16_t)(capture - lastCapt) / 2 ;
|
||||
lastCapt = capture;
|
||||
|
||||
// We prcoess g_ppmInsright here to make servo movement as smooth as possible
|
||||
// We process 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
|
||||
|
||||
Reference in New Issue
Block a user