firmware: add equalizing commands
bass boost (B) and treble boost (T)
This commit is contained in:
parent
a60a0fa459
commit
7498016107
@ -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);
|
uint8_t bd_set_attenuation(I2C_HandleTypeDef * handle, uint8_t right_channel, uint8_t attenuation_in_db);
|
||||||
|
|
||||||
// when gain == 0, cut bass boost
|
// 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
|
// 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 {
|
enum BD_SOURROUND_GAIN {
|
||||||
BD_SOURROUND_OFF = 0,
|
BD_SOURROUND_OFF = 0,
|
||||||
|
@ -70,13 +70,21 @@ uint8_t bd_set_attenuation(I2C_HandleTypeDef * handle, uint8_t right_channel, ui
|
|||||||
}
|
}
|
||||||
|
|
||||||
// when gain == 0, cut bass boost
|
// 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);
|
bd_write_reg(handle, 0x51, (gain == 0)?(0x80):(0x00) | (gain&0x07) << 1);
|
||||||
|
|
||||||
|
return gain;
|
||||||
}
|
}
|
||||||
|
|
||||||
// when gain == 0, cut treble boost
|
// 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);
|
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) {
|
void bd_set_sourround(I2C_HandleTypeDef * handle, enum BD_SOURROUND_GAIN gain) {
|
||||||
|
@ -169,8 +169,21 @@ int parse_buffer() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'B':
|
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:
|
default:
|
||||||
printf("E\n");
|
printf("E\n");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user