Automatic sounds for multipos switches

This commit is contained in:
Bertrand Songis
2014-02-20 19:51:32 +01:00
parent e5f336fba1
commit f2f9579b77
2 changed files with 9 additions and 5 deletions
+3 -3
View File
@@ -306,9 +306,9 @@ void pushPrompt(uint16_t prompt, uint8_t id=0);
#if defined(SDCARD)
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_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)
#else
#define PLAY_PHASE_OFF(phase)
#define PLAY_PHASE_ON(phase)
+6 -2
View File
@@ -1400,13 +1400,17 @@ void getSwitchesPosition(bool play)
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) {
potsLastposStart[i] = 0;
potsPos[i] = (pos << 4) | (pos);
potsPos[i] = (pos << 4) | pos;
if (play && previousStoredPos != pos) {
PLAY_SWITCH_MOVED(SWSRC_LAST_SWITCH+i*POTS_POS_COUNT+pos);
}
}
}
}