2026-01-25 19:05:17 +09:00
|
|
|
#ifndef VOLTAGE_H
|
|
|
|
|
#define VOLTAGE_H
|
|
|
|
|
|
|
|
|
|
#include <Arduino.h>
|
|
|
|
|
|
|
|
|
|
// Initialize voltage monitoring (call in setup)
|
|
|
|
|
void voltage_init();
|
|
|
|
|
|
2026-02-02 19:30:15 +09:00
|
|
|
// Set smoothing window size (1-32 samples, default 20)
|
|
|
|
|
// Resets the buffer with current reading
|
|
|
|
|
void voltage_set_smoothing(int windowSize);
|
|
|
|
|
|
|
|
|
|
// Read battery voltage (smoothed), returns volts (e.g., 12.5)
|
2026-01-25 19:05:17 +09:00
|
|
|
float voltage_read();
|
|
|
|
|
|
2026-02-02 19:30:15 +09:00
|
|
|
// Read smoothed ADC value (averaged over window)
|
|
|
|
|
int voltage_read_smoothed();
|
|
|
|
|
|
|
|
|
|
// Read raw ADC value (0-1023), no smoothing
|
2026-01-25 19:05:17 +09:00
|
|
|
int voltage_read_raw();
|
|
|
|
|
|
|
|
|
|
#endif
|