Power monitor and display (#17437)
This commit is contained in:
@ -139,9 +139,15 @@ const uint8_t adc_pins[] = {
|
||||
#if HAS_JOY_ADC_Z
|
||||
JOY_Z_PIN,
|
||||
#endif
|
||||
#if ENABLED(POWER_MONITOR_CURRENT)
|
||||
POWER_MONITOR_CURRENT_PIN,
|
||||
#endif
|
||||
#if ENABLED(POWER_MONITOR_VOLTAGE)
|
||||
POWER_MONITOR_VOLTAGE_PIN,
|
||||
#endif
|
||||
};
|
||||
|
||||
enum TEMP_PINS : char {
|
||||
enum TempPinIndex : char {
|
||||
#if HAS_TEMP_ADC_0
|
||||
TEMP_0,
|
||||
#endif
|
||||
@ -187,6 +193,12 @@ enum TEMP_PINS : char {
|
||||
#if HAS_JOY_ADC_Z
|
||||
JOY_Z,
|
||||
#endif
|
||||
#if ENABLED(POWER_MONITOR_CURRENT)
|
||||
POWERMON_CURRENT,
|
||||
#endif
|
||||
#if ENABLED(POWER_MONITOR_VOLTAGE)
|
||||
POWERMON_VOLTS,
|
||||
#endif
|
||||
ADC_PIN_COUNT
|
||||
};
|
||||
|
||||
@ -323,7 +335,8 @@ void HAL_adc_init() {
|
||||
}
|
||||
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin) {
|
||||
TEMP_PINS pin_index;
|
||||
//TEMP_PINS pin_index;
|
||||
TempPinIndex pin_index;
|
||||
switch (adc_pin) {
|
||||
default: return;
|
||||
#if HAS_TEMP_ADC_0
|
||||
@ -371,6 +384,12 @@ void HAL_adc_start_conversion(const uint8_t adc_pin) {
|
||||
#if ENABLED(ADC_KEYPAD)
|
||||
case ADC_KEYPAD_PIN: pin_index = ADC_KEY; break;
|
||||
#endif
|
||||
#if ENABLED(POWER_MONITOR_CURRENT)
|
||||
case POWER_MONITOR_CURRENT_PIN: pin_index = POWERMON_CURRENT; break;
|
||||
#endif
|
||||
#if ENABLED(POWER_MONITOR_VOLTAGE)
|
||||
case POWER_MONITOR_VOLTAGE_PIN: pin_index = POWERMON_VOLTS; break;
|
||||
#endif
|
||||
}
|
||||
HAL_adc_result = (HAL_adc_results[(int)pin_index] >> 2) & 0x3FF; // shift to get 10 bits only.
|
||||
}
|
||||
|
@ -255,8 +255,9 @@ static int freeMemory() {
|
||||
|
||||
void HAL_adc_init();
|
||||
|
||||
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
|
||||
#define HAL_ADC_VREF 3.3
|
||||
#define HAL_ADC_RESOLUTION 10
|
||||
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
|
||||
#define HAL_READ_ADC() HAL_adc_result
|
||||
#define HAL_ADC_READY() true
|
||||
|
||||
|
Reference in New Issue
Block a user