4 #if defined(POWER_OUTPUT_DAC)
10 #define DAC_REF_VCC 3300
15 DBGLN("Init DAC Driver");
17 Wire
.setSDA(GPIO_PIN_SDA
); // set is needed or it wont work :/
18 Wire
.setSCL(GPIO_PIN_SCL
);
25 if (m_state
!= STANDBY
)
27 Wire
.beginTransmission(POWER_OUTPUT_DAC
);
30 Wire
.endTransmission();
37 if (m_state
!= RUNNING
)
39 DAC::setVoltageRegDirect(m_currVoltageRegVal
);
43 void DAC::setVoltageMV(uint32_t voltsMV
)
45 uint8_t ScaledVolts
= map(voltsMV
, 0, DAC_REF_VCC
, 0, 255);
46 setVoltageRegDirect(ScaledVolts
);
47 m_currVoltageMV
= voltsMV
;
48 DBGLN("DAC Voltage %dmV", m_currVoltageMV
);
51 void DAC::setVoltageRegDirect(uint8_t voltReg
)
53 m_currVoltageRegVal
= voltReg
;
54 uint8_t RegH
= ((voltReg
& 0b11110000) >> 4) + (0b0000 << 4);
55 uint8_t RegL
= (voltReg
& 0b00001111) << 4;
57 Wire
.beginTransmission(POWER_OUTPUT_DAC
);
60 Wire
.endTransmission();
63 void DAC::setPower(int16_t milliVolts
)
65 DAC::setVoltageMV(milliVolts
);
70 #endif // defined(POWER_OUTPUT_DAC)