AP_HAL: update AnalogIn example to show voltages not raw values
This commit is contained in:
parent
af141c2487
commit
7681f3b639
@ -15,6 +15,7 @@ const AP_HAL::HAL& hal = AP_HAL_BOARD_DRIVER;
|
||||
AP_HAL::AnalogSource* ch0;
|
||||
AP_HAL::AnalogSource* ch1;
|
||||
AP_HAL::AnalogSource* ch2;
|
||||
AP_HAL::AnalogSource* ch3;
|
||||
AP_HAL::AnalogSource* ch10;
|
||||
AP_HAL::AnalogSource* ch11;
|
||||
AP_HAL::AnalogSource* ch12;
|
||||
@ -26,6 +27,7 @@ void setup (void) {
|
||||
ch0 = hal.analogin->channel(0);
|
||||
ch1 = hal.analogin->channel(1);
|
||||
ch2 = hal.analogin->channel(2);
|
||||
ch3 = hal.analogin->channel(3);
|
||||
ch10 = hal.analogin->channel(10);
|
||||
ch11 = hal.analogin->channel(11);
|
||||
ch12 = hal.analogin->channel(12);
|
||||
@ -34,18 +36,20 @@ void setup (void) {
|
||||
}
|
||||
|
||||
void loop (void) {
|
||||
float meas_ch0 = ch0->read_average();
|
||||
float meas_ch1 = ch1->read_average();
|
||||
float meas_ch2 = ch2->read_average();
|
||||
float meas_ch10 = ch10->read_average();
|
||||
float meas_ch11 = ch11->read_average();
|
||||
float meas_ch12 = ch12->read_average();
|
||||
float meas_ch13 = ch13->read_average();
|
||||
float meas_vcc = vcc->read_average();
|
||||
hal.console->printf_P(PSTR("read ch0:%.1f ch1:%.1f ch2:%.1f ch10:%.1f ch11:%.1f ch12:%.1f ch13:%.1f vcc:%.1f\n"),
|
||||
float meas_ch0 = ch0->voltage_average();
|
||||
float meas_ch1 = ch1->voltage_average();
|
||||
float meas_ch2 = ch2->voltage_average();
|
||||
float meas_ch3 = ch3->voltage_average();
|
||||
float meas_ch10 = ch10->voltage_average();
|
||||
float meas_ch11 = ch11->voltage_average();
|
||||
float meas_ch12 = ch12->voltage_average();
|
||||
float meas_ch13 = ch13->voltage_average();
|
||||
float meas_vcc = vcc->read_average() * 0.001;
|
||||
hal.console->printf_P(PSTR("Voltage ch0:%.2f ch1:%.2f ch2:%.2f ch3:%.2f ch10:%.2f ch11:%.2f ch12:%.2f ch13:%.2f vcc:%.2f\n"),
|
||||
meas_ch0,
|
||||
meas_ch1,
|
||||
meas_ch2,
|
||||
meas_ch3,
|
||||
meas_ch10,
|
||||
meas_ch11,
|
||||
meas_ch12,
|
||||
|
Loading…
Reference in New Issue
Block a user