From 998d75557da3304586484168d0b2da78ce835f2d Mon Sep 17 00:00:00 2001 From: Andrey G Date: Thu, 27 Apr 2023 00:01:14 +0300 Subject: [PATCH] dac: fix overflow (#238) --- firmware/dac.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/dac.cpp b/firmware/dac.cpp index 51a548a..5c71d1a 100644 --- a/firmware/dac.cpp +++ b/firmware/dac.cpp @@ -21,7 +21,7 @@ void Dac::SetVoltage(int channel, float voltage) { voltage = clampF(0, voltage, VCC_VOLTS); m_voltageFloat[channel] = voltage; - dacPutChannelX(m_driver, channel, voltage / VCC_VOLTS * (1 << 12)); + dacPutChannelX(m_driver, channel, voltage / VCC_VOLTS * ((1 << 12) - 1)); } float Dac::GetLastVoltage(int channel)