diff options
-rw-r--r-- | main.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -85,7 +85,6 @@ auto conf_desc = configuration_desc(2, 1, 0, 0xc0, 0, class DAC { Pin& reset; I2C& i2c; - uint8_t volume; public: DAC(Pin& _reset, I2C& _i2c) : reset(_reset), i2c(_i2c) { @@ -100,12 +99,13 @@ class DAC { i2c.write_reg(0x4a, 0x02, 0x9e); i2c.write_reg(0x4a, 0x06, (0 << 7) | (1 << 6) | (0 << 4) | (1 << 2) | (3 << 0)); } - uint8_t get_volume() { - return volume; + uint8_t get_volume(uint8_t c) { + uint8_t buf; + i2c.read_reg(0x4a, 0x1a + c, 1, &buf); + return buf & 0x7f; } void set_volume(uint8_t c, uint8_t v) { - volume = v; - i2c.write_reg(0x4a, 0x1a + c, volume & 0x7f); + i2c.write_reg(0x4a, 0x1a + c, v & 0x7f); } }; |