Files
ODrive/Firmware/MotorControl/oscilloscope.cpp
Samuel Sadok 69897ece9c improve debug instrumentation
- add ERROR output on GPIO
 - add exported get_gpio_states() function
 - add task timer for DC calib ADC wait time
 - fix oscilloscope
2020-11-13 18:45:49 +01:00

28 lines
704 B
C++

#include "oscilloscope.hpp"
// if you use the oscilloscope feature you can bump up this value
#define OSCILLOSCOPE_SIZE 4096
void Oscilloscope::update() {
float trigger_data = trigger_src_ ? *trigger_src_ : 0.0f;
float trigger_threshold = trigger_threshold_;
float sample_data = data_src_ ? **data_src_ : 0.0f;
if (trigger_data < trigger_threshold) {
ready_ = true;
}
if (ready_ && trigger_data >= trigger_threshold) {
capturing_ = true;
ready_ = false;
}
if (capturing_) {
if (pos_ < OSCILLOSCOPE_SIZE) {
data_[pos_++] = sample_data;
} else {
pos_ = 0;
capturing_ = false;
}
}
}