mirror of
https://github.com/Skysamara/hydro.git
synced 2025-12-06 06:16:01 +00:00
Работает, кроме автополива
This commit is contained in:
parent
21f6546f58
commit
6bbc20548e
@ -28,4 +28,4 @@ BLYNK_CONNECTED() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Motor M1(0x2D,_MOTOR_A, 1000); // Адрес, мотор, частота
|
// Motor M1(0x30,_MOTOR_A, 1000); // Адрес, мотор, частота
|
||||||
|
|||||||
@ -7,57 +7,56 @@ class Pump
|
|||||||
int currentDuration; // Текущее время полива для отображения в приложении
|
int currentDuration; // Текущее время полива для отображения в приложении
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Pump(){ // int address, char motor, int freq
|
Pump(uint8_t address, uint8_t motor, uint32_t freq) {
|
||||||
// Motor M1(0x2D,_MOTOR_A, 1000); // Адрес, мотор, частот
|
_m = new Motor(address, motor, freq);
|
||||||
|
|
||||||
_m = new Motor(0x2D, _MOTOR_A, 1000);
|
|
||||||
lastTime = millis();
|
lastTime = millis();
|
||||||
currentDuration = 0;
|
currentDuration = 0;
|
||||||
Serial.println("Pump created");
|
Serial.println("Pump created");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update(){
|
void Update() {
|
||||||
if ((millis() - lastTime) > duration * 1000) // Пора выключать
|
// if ((millis() - lastTime) > duration * 1000) // Пора выключать
|
||||||
{
|
|
||||||
Serial.println("Update-stop");
|
|
||||||
_m -> setmotor(_STOP);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Start(){
|
|
||||||
// if (!IsON())
|
|
||||||
// {
|
// {
|
||||||
Serial.print("Start! ");
|
// lastTime = millis();
|
||||||
Serial.println(duration);
|
// Serial.println("Update-stop");
|
||||||
lastTime = millis();
|
// _m -> setmotor(_STOP);
|
||||||
_m -> setmotor(_CCW, 100);
|
|
||||||
Update();
|
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stop(){
|
void Start() {
|
||||||
// if (IsON())
|
// if (!IsON())
|
||||||
// {
|
// {
|
||||||
Serial.print("Stop! ");
|
Serial.print("Start! ");
|
||||||
Serial.println(duration);
|
Serial.println(duration);
|
||||||
lastTime = millis();
|
lastTime = millis();
|
||||||
_m -> setmotor(_STOP);
|
_m -> setmotor(_CCW, 100);
|
||||||
Update();
|
// Update();
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetCurrentDuration(){
|
void Stop() {
|
||||||
// if (IsON()) // Если помпа включена
|
// if (IsON())
|
||||||
// {
|
// {
|
||||||
return ((millis() - lastTime) / 1000); // Текущее время полива
|
Serial.print("Stop! ");
|
||||||
// }
|
Serial.println(duration);
|
||||||
// else
|
lastTime = millis();
|
||||||
// {
|
_m -> setmotor(_STOP);
|
||||||
// return 0;
|
// Update();
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetDuration(int d){
|
int GetCurrentDuration() {
|
||||||
|
// if (IsON()) // Если помпа включена
|
||||||
|
// {
|
||||||
|
return ((millis() - lastTime) / 1000); // Текущее время полива
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetDuration(int d) {
|
||||||
duration = d;
|
duration = d;
|
||||||
Serial.print("SetDuration ");
|
Serial.print("SetDuration ");
|
||||||
Serial.println(duration);
|
Serial.println(duration);
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
Pump pump1;
|
Pump pump1(0x30, _MOTOR_A, 1000);
|
||||||
|
|||||||
@ -3,35 +3,17 @@ void setup(void)
|
|||||||
|
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
delay(100);
|
delay(100);
|
||||||
|
//
|
||||||
pinMode(term_power, OUTPUT);
|
pinMode(term_power, OUTPUT);
|
||||||
digitalWrite(term_power, HIGH);
|
digitalWrite(term_power, HIGH);
|
||||||
|
|
||||||
pinMode(DHTPin, INPUT);
|
pinMode(DHTPin, INPUT);
|
||||||
|
|
||||||
// readSettings();
|
|
||||||
|
|
||||||
|
|
||||||
dht.begin();
|
dht.begin();
|
||||||
Blynk.begin(auth, ssid, pass);
|
Blynk.begin(auth, ssid, pass);
|
||||||
|
|
||||||
timer.setInterval(1000L, timerEvent);
|
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();
|
readSettings();
|
||||||
pump1.Stop();
|
pump1.Stop();
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ void timerEvent()
|
|||||||
|
|
||||||
void refreshApp()
|
void refreshApp()
|
||||||
{
|
{
|
||||||
// Blynk.virtualWrite(V5, pump1.GetCurrentDuration());
|
Blynk.virtualWrite(V5, pump1.GetCurrentDuration());
|
||||||
// Blynk.virtualWrite(V4, pump1.IsON());
|
// Blynk.virtualWrite(V4, pump1.IsON());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,12 +13,17 @@ BLYNK_WRITE(V1) // Установка времени старта полива
|
|||||||
// clean stop/start fields of widget
|
// clean stop/start fields of widget
|
||||||
|
|
||||||
Serial.print("Таймер: ");
|
Serial.print("Таймер: ");
|
||||||
// Serial.println(pump1.GetCurrentDuration());
|
// Serial.println(pump1.GetCurrentDuration());
|
||||||
|
|
||||||
// pump1.Start();
|
// pump1.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
BLYNK_WRITE(V4) // Кнопка помпы 1
|
BLYNK_WRITE(V4) // Кнопка помпы 1
|
||||||
{
|
{
|
||||||
pump1.Start();
|
if (param.asInt() == 0) {
|
||||||
|
pump1.Stop();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pump1.Start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user