Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions AutoPID.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
#include "AutoPID.h"
#ifdef ESP_PLATFORM
#include <math.h>
#include "esp_timer.h"
#endif

#ifdef ESP_PLATFORM
unsigned long millis() {
return (unsigned long)esp_timer_get_time()/1000;
}

template<class T>
const T& constrain(const T& x, const T& a, const T& b) {
if(x < a) {
return a;
}
else if(b < x) {
return b;
}
else
return x;
}
#endif

AutoPID::AutoPID(double *input, double *setpoint, double *output, double outputMin, double outputMax,
double Kp, double Ki, double Kd) {
Expand Down Expand Up @@ -100,5 +122,3 @@ void AutoPIDRelay::run() {
double AutoPIDRelay::getPulseValue(){
return (isStopped()?0:_pulseValue);
}


2 changes: 2 additions & 0 deletions AutoPID.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef AUTOPID_H
#define AUTOPID_H
#ifndef ESP_PLATFORM
#include <Arduino.h>
#endif

class AutoPID {

Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
idf_component_register(SRCS "AutoPID.cpp"
INCLUDE_DIRS "."
REQUIRES esp_common)