Automatic sounds for multipos switches
This commit is contained in:
@@ -306,9 +306,9 @@ void pushPrompt(uint16_t prompt, uint8_t id=0);
|
|||||||
|
|
||||||
#if defined(SDCARD)
|
#if defined(SDCARD)
|
||||||
void playModelEvent(uint8_t category, uint8_t index, uint8_t event=0);
|
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_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_PHASE_ON(phase) playModelEvent(PHASE_AUDIO_CATEGORY, phase, AUDIO_EVENT_ON)
|
||||||
#define PLAY_SWITCH_MOVED(sw) playModelEvent(SWITCH_AUDIO_CATEGORY, sw)
|
#define PLAY_SWITCH_MOVED(sw) playModelEvent(SWITCH_AUDIO_CATEGORY, sw)
|
||||||
#else
|
#else
|
||||||
#define PLAY_PHASE_OFF(phase)
|
#define PLAY_PHASE_OFF(phase)
|
||||||
#define PLAY_PHASE_ON(phase)
|
#define PLAY_PHASE_ON(phase)
|
||||||
|
|||||||
@@ -1400,13 +1400,17 @@ void getSwitchesPosition(bool play)
|
|||||||
if (calib->count>0 && calib->count<POTS_POS_COUNT) {
|
if (calib->count>0 && calib->count<POTS_POS_COUNT) {
|
||||||
uint8_t pos = anaIn(POT1+i) / (2*RESX/calib->count);
|
uint8_t pos = anaIn(POT1+i) / (2*RESX/calib->count);
|
||||||
uint8_t previousPos = potsPos[i] >> 4;
|
uint8_t previousPos = potsPos[i] >> 4;
|
||||||
|
uint8_t previousStoredPos = potsPos[i] & 0x0F;
|
||||||
if (pos != previousPos) {
|
if (pos != previousPos) {
|
||||||
potsLastposStart[i] = get_tmr10ms();
|
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 ((tmr10ms_t)(get_tmr10ms() - potsLastposStart[i]) > DELAY_SWITCH_3POS) {
|
||||||
potsLastposStart[i] = 0;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user