From 10c33c518fdea638ffd64cb7cbd2e59ed8c0ed1d Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Sat, 29 Sep 2012 16:53:47 +0200 Subject: Fixed get_volume for multiple channels. --- main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.cpp b/main.cpp index 031c042..6e46591 100644 --- a/main.cpp +++ b/main.cpp @@ -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); } }; -- cgit v1.2.3