Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support virtual rela-based audio processor
- Loading branch information
Showing
11 changed files
with
178 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
../src/drivers/STM32_USB_Device_Library/Core/Inc | ||
../src/display/fonts | ||
../src/usb | ||
../src/audio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
#include "relay.h" | ||
|
||
#include "audio.h" | ||
#include "pins.h" | ||
#include "swtimers.h" | ||
|
||
#define RELAY_IN_CNT 4 | ||
|
||
static const AudioGrid gridVolume = {NULL, -1, 1, (int8_t)(2.00)}; // -1..1dB with 2dB step | ||
|
||
static AudioParam *aPar; | ||
|
||
static const AudioApi relayApi = { | ||
.init = relayInit, | ||
.getInCnt = relayGetInCnt, | ||
|
||
.setTune = relaySetTune, | ||
.setInput = relaySetInput, | ||
|
||
.setLoudness = relaySetLoudness, | ||
}; | ||
|
||
const AudioApi *relayGetApi() | ||
{ | ||
return &relayApi; | ||
} | ||
|
||
void relayInit(AudioParam *param) | ||
{ | ||
aPar = param; | ||
aPar->grid[AUDIO_TUNE_VOLUME] = &gridVolume; | ||
|
||
OUT(VOL_UP); | ||
OUT(VOL_DN); | ||
OUT(LOUDNESS); | ||
|
||
OUT(IN_0); | ||
OUT(IN_1); | ||
OUT(IN_2); | ||
OUT(IN_3); | ||
} | ||
|
||
int8_t relayGetInCnt(void) | ||
{ | ||
return RELAY_IN_CNT; | ||
} | ||
|
||
void relaySetTune(AudioTune tune, int8_t value) | ||
{ | ||
if (tune == AUDIO_TUNE_VOLUME) { | ||
if (value > 0) { | ||
swTimSet(SW_TIM_VOLUME_KEY, 200); | ||
SET(VOL_UP); | ||
CLR(VOL_DN); | ||
} else if (value < 0) { | ||
swTimSet(SW_TIM_VOLUME_KEY, 200); | ||
SET(VOL_DN); | ||
CLR(VOL_UP); | ||
} | ||
} | ||
} | ||
|
||
void relayReleaseVolume() | ||
{ | ||
if (swTimGet(SW_TIM_VOLUME_KEY) == 0) { | ||
CLR(VOL_UP); | ||
CLR(VOL_DN); | ||
swTimSet(SW_TIM_VOLUME_KEY, SW_TIM_OFF); | ||
} | ||
} | ||
|
||
static void clearInputs() | ||
{ | ||
CLR(IN_0); | ||
CLR(IN_1); | ||
CLR(IN_2); | ||
CLR(IN_3); | ||
} | ||
|
||
void relaySetInput(int8_t value) | ||
{ | ||
clearInputs(); | ||
|
||
switch (value) { | ||
case 0: | ||
SET(IN_0); | ||
break; | ||
case 1: | ||
SET(IN_1); | ||
break; | ||
case 2: | ||
SET(IN_2); | ||
break; | ||
case 3: | ||
SET(IN_3); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
void relaySetLoudness(bool value) | ||
{ | ||
if (value) { | ||
SET(LOUDNESS); | ||
} else { | ||
CLR(LOUDNESS); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef RELAY_H | ||
#define RELAY_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include "audiodefs.h" | ||
|
||
const AudioApi *relayGetApi(void); | ||
|
||
void relayInit(AudioParam *param); | ||
int8_t relayGetInCnt(void); | ||
|
||
void relaySetTune(AudioTune tune, int8_t value); | ||
void relaySetInput(int8_t value); | ||
|
||
void relaySetLoudness(bool value); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // RELAY_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ enum { | |
SW_TIM_MPD_POWEROFF, | ||
SW_TIM_DIGIT_INPUT, | ||
SW_TIM_SCROLL, | ||
SW_TIM_VOLUME_KEY, | ||
|
||
SW_TIM_DEC_END, | ||
|
||
|