Работает, кроме автополива

This commit is contained in:
skysamara 2021-06-21 02:05:55 +03:00
parent 21f6546f58
commit 6bbc20548e
6 changed files with 49 additions and 63 deletions

View File

@ -28,4 +28,4 @@ BLYNK_CONNECTED() {
// Motor M1(0x2D,_MOTOR_A, 1000); // Адрес, мотор, частота
// Motor M1(0x30,_MOTOR_A, 1000); // Адрес, мотор, частота

View File

@ -7,21 +7,20 @@ class Pump
int currentDuration; // Текущее время полива для отображения в приложении
public:
Pump(){ // int address, char motor, int freq
// Motor M1(0x2D,_MOTOR_A, 1000); // Адрес, мотор, частот
_m = new Motor(0x2D, _MOTOR_A, 1000);
Pump(uint8_t address, uint8_t motor, uint32_t freq) {
_m = new Motor(address, motor, freq);
lastTime = millis();
currentDuration = 0;
Serial.println("Pump created");
}
void Update() {
if ((millis() - lastTime) > duration * 1000) // Пора выключать
{
Serial.println("Update-stop");
_m -> setmotor(_STOP);
}
// if ((millis() - lastTime) > duration * 1000) // Пора выключать
// {
// lastTime = millis();
// Serial.println("Update-stop");
// _m -> setmotor(_STOP);
// }
}
void Start() {
@ -31,7 +30,7 @@ class Pump
Serial.println(duration);
lastTime = millis();
_m -> setmotor(_CCW, 100);
Update();
// Update();
// }
}
@ -42,7 +41,7 @@ class Pump
Serial.println(duration);
lastTime = millis();
_m -> setmotor(_STOP);
Update();
// Update();
// }
}

View File

@ -1 +1 @@
Pump pump1;
Pump pump1(0x30, _MOTOR_A, 1000);

View File

@ -3,35 +3,17 @@ void setup(void)
Serial.begin(115200);
delay(100);
//
pinMode(term_power, OUTPUT);
digitalWrite(term_power, HIGH);
pinMode(DHTPin, INPUT);
// readSettings();
dht.begin();
Blynk.begin(auth, ssid, pass);
timer.setInterval(1000L, timerEvent);
// bool b = 1;
// float f = 100000;
// int i = 5;
// Serial.print("***** b *****");
// Serial.println(sizeof(b));
//
// Serial.print("***** f *****");
// Serial.println(sizeof(f));
//
// Serial.print("***** i *****");
// Serial.println(sizeof(i));
//
// EEPROM.begin(512);
// CreateObjects();
readSettings();
pump1.Stop();

View File

@ -6,7 +6,7 @@ void timerEvent()
void refreshApp()
{
// Blynk.virtualWrite(V5, pump1.GetCurrentDuration());
Blynk.virtualWrite(V5, pump1.GetCurrentDuration());
// Blynk.virtualWrite(V4, pump1.IsON());
}

View File

@ -20,5 +20,10 @@ BLYNK_WRITE(V1) // Установка времени старта полива
BLYNK_WRITE(V4) // Кнопка помпы 1
{
if (param.asInt() == 0) {
pump1.Stop();
}
else {
pump1.Start();
}
}