summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2012-09-29 16:53:47 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2012-09-29 16:53:47 +0200
commit10c33c518fdea638ffd64cb7cbd2e59ed8c0ed1d (patch)
treeea626a38e0d9cbb1ebd4804991176c3edb884eb6
parentf35b446fabaad48020b57633a1e01bf6832b3f96 (diff)
Fixed get_volume for multiple channels.
-rw-r--r--main.cpp10
1 files 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);
}
};