#ifndef ADC_H #define ADC_H class ADC { public: static uint16_t getA0() { return 0xffff & system_adc_read(); } static uint16_t getVcc() { static constexpr float SCALER = 1.93; // divider of 10k / 10k -> * 2 static constexpr int V_REF = 330; // 3.3 volt static constexpr int MUL = SCALER * V_REF; return getA0() * MUL / 1024; } }; #endif // ADC_H