mirror of
https://github.com/opentx/opentx.git
synced 2025-07-23 16:25:16 +03:00
[Horus] VS1053B Volume added. No ticks at all compared to Taranis!
This commit is contained in:
parent
da76106465
commit
6c54374ed8
9 changed files with 85 additions and 35 deletions
|
@ -30,12 +30,14 @@
|
|||
#define MINUTE_SEPARATOR_OFFSET 63
|
||||
#define SECOND_OFFSET 75
|
||||
|
||||
#define SLIDER_5POS(y, value, event, attr) { \
|
||||
int8_t tmp = value; \
|
||||
drawSlider(RADIO_SETUP_2ND_COLUMN, y, 2+tmp, 4, attr); \
|
||||
value = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, NULL, tmp, -2, +2, attr, event); \
|
||||
int8_t editSlider(coord_t x, coord_t y, evt_t event, int8_t value, int8_t min, int8_t max, LcdFlags attr)
|
||||
{
|
||||
drawSlider(x, y, value-min, max-min, attr);
|
||||
return selectMenuItem(x, y, NULL, value, min, max, attr, event);
|
||||
}
|
||||
|
||||
#define SLIDER_5POS(y, val, event, attr) val = editSlider(RADIO_SETUP_2ND_COLUMN, y, event, val, -2, +2, attr)
|
||||
|
||||
#if defined(SPLASH) && !defined(FSPLASH)
|
||||
#define CASE_SPLASH_PARAM(x) x,
|
||||
#else
|
||||
|
@ -48,6 +50,7 @@ enum menuGeneralSetupItems {
|
|||
// ITEM_SETUP_BATT_RANGE,
|
||||
ITEM_SETUP_SOUND_LABEL,
|
||||
ITEM_SETUP_BEEP_MODE,
|
||||
ITEM_SETUP_GENERAL_VOLUME,
|
||||
ITEM_SETUP_BEEP_VOLUME,
|
||||
ITEM_SETUP_BEEP_LENGTH,
|
||||
ITEM_SETUP_SPEAKER_PITCH,
|
||||
|
@ -109,7 +112,11 @@ bool menuGeneralSetup(evt_t event)
|
|||
}
|
||||
#endif
|
||||
|
||||
MENU(STR_MENURADIOSETUP, menuTabGeneral, e_Setup, ITEM_SETUP_MAX, DEFAULT_SCROLLBAR_X, { 2|NAVIGATION_LINE_BY_LINE, 2|NAVIGATION_LINE_BY_LINE, LABEL(SOUND), 0, 0, 0, 0, 0, 0, CASE_VARIO(LABEL(VARIO)) CASE_VARIO(0) CASE_VARIO(0) CASE_VARIO(0) CASE_VARIO(0) CASE_HAPTIC(LABEL(HAPTIC)) CASE_HAPTIC(0) CASE_HAPTIC(0) CASE_HAPTIC(0) LABEL(ALARMS), 0, 0, 0, CASE_GPS(0) CASE_GPS(0) CASE_PXX(0) 0, 0, CASE_MAVLINK(0) 0, 0, 0, 0, 1/*to force edit mode*/ });
|
||||
MENU(STR_MENURADIOSETUP, menuTabGeneral, e_Setup, ITEM_SETUP_MAX, DEFAULT_SCROLLBAR_X, { 2|NAVIGATION_LINE_BY_LINE, 2|NAVIGATION_LINE_BY_LINE,
|
||||
LABEL(SOUND), 0, 0, 0, 0, 0, 0, 0,
|
||||
CASE_VARIO(LABEL(VARIO)) CASE_VARIO(0) CASE_VARIO(0) CASE_VARIO(0) CASE_VARIO(0)
|
||||
CASE_HAPTIC(LABEL(HAPTIC)) CASE_HAPTIC(0) CASE_HAPTIC(0) CASE_HAPTIC(0)
|
||||
LABEL(ALARMS), 0, 0, 0, CASE_GPS(0) CASE_GPS(0) CASE_PXX(0) 0, 0, CASE_MAVLINK(0) 0, 0, 0, 0, 1/*to force edit mode*/ });
|
||||
|
||||
int sub = menuVerticalPosition;
|
||||
|
||||
|
@ -225,17 +232,22 @@ bool menuGeneralSetup(evt_t event)
|
|||
#endif
|
||||
break;
|
||||
|
||||
case ITEM_SETUP_GENERAL_VOLUME:
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SPEAKER_VOLUME);
|
||||
g_eeGeneral.speakerVolume = editSlider(RADIO_SETUP_2ND_COLUMN, y, event, g_eeGeneral.speakerVolume, -VOLUME_LEVEL_DEF, VOLUME_LEVEL_MAX-VOLUME_LEVEL_DEF, attr);
|
||||
break;
|
||||
|
||||
case ITEM_SETUP_BEEP_VOLUME:
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_BEEP_VOLUME);
|
||||
SLIDER_5POS(y, g_eeGeneral.beepVolume, event, attr);
|
||||
g_eeGeneral.beepVolume = editSlider(RADIO_SETUP_2ND_COLUMN, y, event, g_eeGeneral.beepVolume, -4, +4, attr);
|
||||
break;
|
||||
case ITEM_SETUP_WAV_VOLUME:
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_WAV_VOLUME);
|
||||
SLIDER_5POS(y, g_eeGeneral.wavVolume, event, attr);
|
||||
g_eeGeneral.wavVolume = editSlider(RADIO_SETUP_2ND_COLUMN, y, event, g_eeGeneral.wavVolume, -4, +4, attr);
|
||||
break;
|
||||
case ITEM_SETUP_BACKGROUND_VOLUME:
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_BG_VOLUME);
|
||||
SLIDER_5POS(y, g_eeGeneral.backgroundVolume, event, attr);
|
||||
g_eeGeneral.backgroundVolume = editSlider(RADIO_SETUP_2ND_COLUMN, y, event, g_eeGeneral.backgroundVolume, -4, +4, attr);
|
||||
break;
|
||||
|
||||
case ITEM_SETUP_BEEP_LENGTH:
|
||||
|
@ -257,7 +269,7 @@ bool menuGeneralSetup(evt_t event)
|
|||
break;
|
||||
case ITEM_SETUP_VARIO_VOLUME:
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, TR_SPEAKER_VOLUME);
|
||||
SLIDER_5POS(y, g_eeGeneral.varioVolume, event, attr);
|
||||
g_eeGeneral.varioVolume = editSlider(RADIO_SETUP_2ND_COLUMN, y, event, g_eeGeneral.varioVolume, -4, +4, attr);
|
||||
break;
|
||||
case ITEM_SETUP_VARIO_PITCH:
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_PITCH_AT_ZERO);
|
||||
|
|
|
@ -382,13 +382,13 @@ enum BeeperMode {
|
|||
uint8_t countryCode; \
|
||||
uint8_t imperial; \
|
||||
char ttsLanguage[2]; \
|
||||
int8_t beepVolume; \
|
||||
int8_t wavVolume; \
|
||||
int8_t varioVolume; \
|
||||
int8_t beepVolume:4; \
|
||||
int8_t wavVolume:4; \
|
||||
int8_t varioVolume:4; \
|
||||
int8_t backgroundVolume:4; \
|
||||
int8_t varioPitch; \
|
||||
int8_t varioRange; \
|
||||
int8_t varioRepeat; \
|
||||
int8_t backgroundVolume;
|
||||
int8_t varioRepeat;
|
||||
#endif
|
||||
|
||||
#if defined(PCBHORUS) || defined(PCBFLAMENCO)
|
||||
|
|
|
@ -20,6 +20,14 @@
|
|||
|
||||
#include "../../opentx.h"
|
||||
|
||||
const uint8_t volumeScale[VOLUME_LEVEL_MAX+1] = {
|
||||
254, 127, 110, 100, 90, 80, 70, 60, 50, 40,
|
||||
30, 20, 19, 18, 17, 16, 15, 14, 13, 12,
|
||||
11, 10, 5, 0
|
||||
};
|
||||
|
||||
#if !defined(SIMU)
|
||||
|
||||
#define VS_WRITE_COMMAND 0x02
|
||||
#define VS_READ_COMMAND 0x03
|
||||
|
||||
|
@ -314,6 +322,8 @@ uint8_t audioSoftReset(void)
|
|||
|
||||
uint32_t audioSpiWriteData(const uint8_t * buffer, uint32_t size)
|
||||
{
|
||||
XDCS_LOW();
|
||||
|
||||
uint32_t index = 0;
|
||||
while (index < size && READ_DREQ() != 0) {
|
||||
for (int i=0; i<MP3_BUFFER_SIZE && index<size; i++) {
|
||||
|
@ -340,6 +350,11 @@ const uint8_t RiffHeader[] = {
|
|||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
void audioSendRiffHeader()
|
||||
{
|
||||
audioSpiWriteBuffer(RiffHeader, sizeof(RiffHeader));
|
||||
}
|
||||
|
||||
void audioInit()
|
||||
{
|
||||
audioSpiInit();
|
||||
|
@ -348,13 +363,12 @@ void audioInit()
|
|||
audioSpiSetSpeed(SPI_SPEED_8);
|
||||
|
||||
delay_01us(10000); // 1ms
|
||||
|
||||
XDCS_LOW();
|
||||
audioSpiWriteBuffer(RiffHeader, sizeof(RiffHeader));
|
||||
audioSendRiffHeader();
|
||||
}
|
||||
|
||||
uint8_t * currentBuffer = NULL;
|
||||
uint32_t currentSize = 0;
|
||||
int16_t newVolume = -1;
|
||||
|
||||
void audioSetCurrentBuffer(AudioBuffer * buffer)
|
||||
{
|
||||
|
@ -364,6 +378,13 @@ void audioSetCurrentBuffer(AudioBuffer * buffer)
|
|||
|
||||
void audioConsumeCurrentBuffer()
|
||||
{
|
||||
if (newVolume >= 0) {
|
||||
uint8_t value = newVolume;
|
||||
audioSpiWriteCmd(SPI_VOL, (value << 8) + value);
|
||||
// audioSendRiffHeader();
|
||||
newVolume = -1;
|
||||
}
|
||||
|
||||
if (currentBuffer) {
|
||||
uint32_t written = audioSpiWriteData(currentBuffer, currentSize);
|
||||
currentBuffer += written;
|
||||
|
@ -392,3 +413,24 @@ bool audioPushBuffer(AudioBuffer * buffer)
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void setScaledVolume(uint8_t volume)
|
||||
{
|
||||
if (volume > VOLUME_LEVEL_MAX) {
|
||||
volume = VOLUME_LEVEL_MAX;
|
||||
}
|
||||
|
||||
setVolume(volumeScale[volume]);
|
||||
}
|
||||
|
||||
void setVolume(uint8_t volume)
|
||||
{
|
||||
newVolume = volume;
|
||||
}
|
||||
|
||||
int32_t getVolume()
|
||||
{
|
||||
return -1; // TODO
|
||||
}
|
||||
|
||||
#endif
|
|
@ -279,11 +279,11 @@ void usbSerialPutc(uint8_t c);
|
|||
void audioInit(void);
|
||||
void audioConsumeCurrentBuffer(void);
|
||||
#define setSampleRate(freq)
|
||||
|
||||
// Fake volume driver
|
||||
#define setScaledVolume(...)
|
||||
#define setVolume(...)
|
||||
#define getVolume(...) (-1)
|
||||
void setScaledVolume(uint8_t volume);
|
||||
void setVolume(uint8_t volume);
|
||||
int32_t getVolume(void);
|
||||
#define VOLUME_LEVEL_MAX 23
|
||||
#define VOLUME_LEVEL_DEF 12
|
||||
|
||||
// Telemetry driver
|
||||
void telemetryPortInit(uint32_t baudrate);
|
||||
|
@ -292,18 +292,17 @@ void sportSendBuffer(uint8_t *buffer, uint32_t count);
|
|||
// Haptic driver
|
||||
void hapticInit(void);
|
||||
void hapticOff(void);
|
||||
#define HAPTIC_OFF() hapticOff()
|
||||
#define HAPTIC_OFF() hapticOff()
|
||||
void hapticOn(uint32_t pwmPercent);
|
||||
|
||||
// Second serial port driver
|
||||
#define DEBUG_BAUDRATE 115200
|
||||
#define DEBUG_BAUDRATE 115200
|
||||
void serial2Init(unsigned int mode, unsigned int protocol);
|
||||
void serial2Putc(char c);
|
||||
#define serial2TelemetryInit(protocol) serial2Init(UART_MODE_TELEMETRY, protocol)
|
||||
void serial2SbusInit(void);
|
||||
void serial2Stop(void);
|
||||
|
||||
#define USART_FLAG_ERRORS (USART_FLAG_ORE | USART_FLAG_NE | USART_FLAG_FE | USART_FLAG_PE)
|
||||
#define USART_FLAG_ERRORS (USART_FLAG_ORE | USART_FLAG_NE | USART_FLAG_FE | USART_FLAG_PE)
|
||||
|
||||
#if defined(USB_JOYSTICK) && !defined(SIMU)
|
||||
void usbJoystickUpdate(void);
|
||||
|
|
|
@ -468,7 +468,7 @@ void audioConsumeCurrentBuffer()
|
|||
#if defined(HARDWARE_VOLUME)
|
||||
void setScaledVolume(uint8_t volume)
|
||||
{
|
||||
simuAudio.currentVolume = min<int>((volumeScale[min<uint8_t>(volume, VOLUME_LEVEL_MAX)] * simuAudio.volumeGain) / 10, 127);
|
||||
simuAudio.currentVolume = 127 * volume * simuAudio.volumeGain / VOLUME_LEVEL_MAX / 10;
|
||||
// TRACE("setVolume(): in: %u, out: %u", volume, simuAudio.currentVolume);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@ inline void dacStop()
|
|||
|
||||
#define VOLUME_LEVEL_MAX 23
|
||||
#define VOLUME_LEVEL_DEF 12
|
||||
extern const int8_t volumeScale[];
|
||||
|
||||
void setScaledVolume(uint8_t volume);
|
||||
|
||||
|
|
|
@ -20,12 +20,6 @@
|
|||
|
||||
#include "../../opentx.h"
|
||||
|
||||
const int8_t volumeScale[VOLUME_LEVEL_MAX+1] =
|
||||
{
|
||||
0, 1, 2, 3, 5, 9, 13, 17, 22, 27, 33, 40,
|
||||
64, 82, 96, 105, 112, 117, 120, 122, 124, 125, 126, 127
|
||||
};
|
||||
|
||||
#if !defined(SIMU)
|
||||
bool dacIdle = true;
|
||||
|
||||
|
|
|
@ -325,7 +325,6 @@ void audioEnd(void) ;
|
|||
void dacStart(void);
|
||||
void dacStop(void);
|
||||
void setSampleRate(uint32_t frequency);
|
||||
extern const int8_t volumeScale[];
|
||||
#define VOLUME_LEVEL_MAX 23
|
||||
#define VOLUME_LEVEL_DEF 12
|
||||
void setScaledVolume(uint8_t volume);
|
||||
|
|
|
@ -243,6 +243,11 @@ void eepromWaitEepromStandbyState(void)
|
|||
}
|
||||
|
||||
#if !defined(BOOT)
|
||||
const uint8_t volumeScale[VOLUME_LEVEL_MAX+1] = {
|
||||
0, 1, 2, 3, 5, 9, 13, 17, 22, 27, 33, 40,
|
||||
64, 82, 96, 105, 112, 117, 120, 122, 124, 125, 126, 127
|
||||
};
|
||||
|
||||
void setScaledVolume(uint8_t volume)
|
||||
{
|
||||
if (volume > VOLUME_LEVEL_MAX) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue