firmware: add equalizing commands

bass boost (B) and treble boost (T)
This commit is contained in:
Julian Daube 2019-10-22 00:04:30 +02:00
parent a60a0fa459
commit 7498016107
3 changed files with 26 additions and 5 deletions

View File

@ -20,9 +20,9 @@ int bd_set_gain(I2C_HandleTypeDef * handle, uint8_t gain_in_db);
uint8_t bd_set_attenuation(I2C_HandleTypeDef * handle, uint8_t right_channel, uint8_t attenuation_in_db);
// when gain == 0, cut bass boost
void bd_set_bass_boost(I2C_HandleTypeDef * handle, uint8_t gain);
uint8_t bd_set_bass_boost(I2C_HandleTypeDef * handle, uint8_t gain);
// when gain == 0, cut treble boost
void bd_set_treble_boost(I2C_HandleTypeDef * handle, uint8_t gain);
uint8_t bd_set_treble_boost(I2C_HandleTypeDef * handle, uint8_t gain);
enum BD_SOURROUND_GAIN {
BD_SOURROUND_OFF = 0,

View File

@ -70,13 +70,21 @@ uint8_t bd_set_attenuation(I2C_HandleTypeDef * handle, uint8_t right_channel, ui
}
// when gain == 0, cut bass boost
void bd_set_bass_boost(I2C_HandleTypeDef * handle, uint8_t gain) {
uint8_t bd_set_bass_boost(I2C_HandleTypeDef * handle, uint8_t gain) {
if (gain > 0x07) gain = 0x07;
bd_write_reg(handle, 0x51, (gain == 0)?(0x80):(0x00) | (gain&0x07) << 1);
return gain;
}
// when gain == 0, cut treble boost
void bd_set_treble_boost(I2C_HandleTypeDef * handle, uint8_t gain) {
uint8_t bd_set_treble_boost(I2C_HandleTypeDef * handle, uint8_t gain) {
if (gain > 0x07) gain = 0x07;
bd_write_reg(handle, 0x57, (gain == 0)?(0x80):(0x00) | (gain&0x07) << 1);
return gain;
}
void bd_set_sourround(I2C_HandleTypeDef * handle, enum BD_SOURROUND_GAIN gain) {

View File

@ -169,8 +169,21 @@ int parse_buffer() {
}
break;
case 'B':
case 'T':
{
uint16_t boost;
if (next_arg_unsigned(&boost)) break;
printf("B%d\n", bd_set_bass_boost(&hi2c1, boost));
}
break;
case 'T':
{
uint16_t boost;
if (next_arg_unsigned(&boost)) break;
printf("T%d\n", bd_set_treble_boost(&hi2c1, boost));
}
break;
default:
printf("E\n");
}