code clean
This commit is contained in:
parent
9dae447b17
commit
917450676b
@ -32,6 +32,10 @@ private:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
explicit Dallas(int pin) : oneWire(pin), sensors(&oneWire) {
|
explicit Dallas(int pin) : oneWire(pin), sensors(&oneWire) {
|
||||||
|
// nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
void begin() {
|
||||||
sensors.begin();
|
sensors.begin();
|
||||||
sensors.setWaitForConversion(false);
|
sensors.setWaitForConversion(false);
|
||||||
}
|
}
|
||||||
@ -39,7 +43,7 @@ public:
|
|||||||
void loop() {
|
void loop() {
|
||||||
if (converting) {
|
if (converting) {
|
||||||
if (sensors.isConversionComplete()) {
|
if (sensors.isConversionComplete()) {
|
||||||
if (first) {
|
if (first || isDebugEnabled()) {
|
||||||
first = false;
|
first = false;
|
||||||
uint8_t count = sensors.getDeviceCount();
|
uint8_t count = sensors.getDeviceCount();
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
|
|||||||
@ -10,10 +10,10 @@ monitor_speed = 115200
|
|||||||
monitor_filters = esp32_exception_decoder
|
monitor_filters = esp32_exception_decoder
|
||||||
WIFI_SSID = HappyNet
|
WIFI_SSID = HappyNet
|
||||||
WIFI_PKEY = 1Grausame!Sackratte7
|
WIFI_PKEY = 1Grausame!Sackratte7
|
||||||
lib_deps = milesburton/DallasTemperature
|
lib_deps = https://github.com/milesburton/Arduino-Temperature-Control-Library
|
||||||
knolleary/PubSubClient
|
knolleary/PubSubClient
|
||||||
bblanchon/ArduinoJson
|
bblanchon/ArduinoJson
|
||||||
paulstoffregen/OneWire
|
Wire
|
||||||
https://github.com/phassel/ArduPID/
|
https://github.com/phassel/ArduPID/
|
||||||
|
|
||||||
[env:TEST32]
|
[env:TEST32]
|
||||||
|
|||||||
@ -5,12 +5,13 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#define CONTROL_GPIO 4
|
#define SENSOR_GPIO D4
|
||||||
|
#define CONTROL_GPIO D2
|
||||||
#define CONTROL_PWM_BITS 10
|
#define CONTROL_PWM_BITS 10
|
||||||
|
|
||||||
Dallas dallas(2);
|
Dallas dallas(SENSOR_GPIO);
|
||||||
|
|
||||||
DallasSensor sensor(dallas, 0xAA0121125E4A7528, "sensor", 0.5, 5, 60); // TODO wrong address
|
DallasSensor sensor(dallas, 0xAA0121125E4A7528, "sensor", 0.5, 5, 60);
|
||||||
|
|
||||||
ArduPID pid;
|
ArduPID pid;
|
||||||
|
|
||||||
@ -29,10 +30,11 @@ double integral = 0;
|
|||||||
double derivative = 0;
|
double derivative = 0;
|
||||||
|
|
||||||
void patrixSetup() {
|
void patrixSetup() {
|
||||||
configLoad();
|
dallas.begin();
|
||||||
|
|
||||||
analogWriteResolution(CONTROL_PWM_BITS);
|
analogWriteResolution(CONTROL_PWM_BITS);
|
||||||
|
|
||||||
|
configLoad();
|
||||||
|
|
||||||
pid.begin(&temperatureCurrent, &heaterPWM, &temperatureTarget, proportional, integral, derivative);
|
pid.begin(&temperatureCurrent, &heaterPWM, &temperatureTarget, proportional, integral, derivative);
|
||||||
pid.setOutputLimits(0, pow(10, CONTROL_PWM_BITS) - 1);
|
pid.setOutputLimits(0, pow(10, CONTROL_PWM_BITS) - 1);
|
||||||
pid.start();
|
pid.start();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user