Compare commits
33 Commits
a9fba3267d
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
33d8d9938e | ||
|
|
27d0dd7a68 | ||
|
|
5fd8c3be40 | ||
|
|
6bb5b67f00 | ||
|
|
3af3b8139a | ||
|
|
601c624d65 | ||
|
|
c227eb61d6 | ||
|
|
0d9025e9e3 | ||
|
|
a3837e8a4f | ||
|
|
ee9fd2da8c | ||
|
|
899d998dc7 | ||
|
|
87b2d4cb2c | ||
|
|
547aa99a3b | ||
|
|
f5ce1c97b2 | ||
|
|
77ee1a9a05 | ||
|
|
9f59a70e36 | ||
|
|
de590a5556 | ||
|
|
875086605b | ||
|
|
6f2fe801ea | ||
|
|
459a9e4bfc | ||
|
|
894769be1c | ||
|
|
1a69ac514a | ||
|
|
3934ccab52 | ||
|
|
cf2cb91314 | ||
|
|
458edf0971 | ||
|
|
f2691d62f9 | ||
|
|
a723f75433 | ||
|
|
9826a1299e | ||
|
|
c1809f9b91 | ||
|
|
8ebd9377b1 | ||
|
|
27fcfa4b84 | ||
|
|
3fb41c25d4 | ||
|
|
f650e12e80 |
@@ -39,7 +39,7 @@
|
||||
|
||||
#include "HomeSpan.h"
|
||||
#include "DEV_LED.h"
|
||||
|
||||
int zmienna = 0;
|
||||
void setup() {
|
||||
|
||||
// Example 6 changes Example 5 so that LED #2 is now dimmable, instead of just on/off. This requires us to create a new
|
||||
@@ -61,14 +61,12 @@ void setup() {
|
||||
homeSpan.setPairingCode("11122333");
|
||||
homeSpan.setQRID("111-22-333");
|
||||
|
||||
homeSpan.begin(Category::Lighting,"HomeSpan LED");
|
||||
// konfiguracja WIFI przez port szerefowy "W<returm"
|
||||
// 1.Płytka ESP32 Dev Module
|
||||
// 2 Partycja: Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS)
|
||||
// 3. konfiguracja WIFI przez port szerefowy komenda "W", U - unpair
|
||||
homeSpan.begin(Category::Lighting,"HomeSpan LED tst");
|
||||
|
||||
new SpanAccessory();
|
||||
|
||||
new Service::AccessoryInformation();
|
||||
new Characteristic::Identify();
|
||||
|
||||
new DEV_LED(16); // create an on/off LED attached to pin 16 (same as in Example 5)
|
||||
|
||||
new SpanAccessory();
|
||||
|
||||
@@ -84,5 +82,6 @@ void setup() {
|
||||
void loop(){
|
||||
|
||||
homeSpan.poll();
|
||||
|
||||
Serial.println(zmienna);
|
||||
delay(500);
|
||||
} // end of loop()
|
||||
|
||||
@@ -1,33 +1,5 @@
|
||||
|
||||
////////////////////////////////////
|
||||
// DEVICE-SPECIFIC LED SERVICES //
|
||||
////////////////////////////////////
|
||||
|
||||
struct DEV_LED : Service::LightBulb { // ON/OFF LED
|
||||
|
||||
int ledPin; // pin number defined for this LED
|
||||
SpanCharacteristic *power; // reference to the On Characteristic
|
||||
|
||||
DEV_LED(int ledPin) : Service::LightBulb(){ // constructor() method
|
||||
|
||||
power=new Characteristic::On();
|
||||
this->ledPin=ledPin;
|
||||
pinMode(ledPin,OUTPUT);
|
||||
|
||||
} // end constructor
|
||||
|
||||
boolean update(){ // update() method
|
||||
|
||||
digitalWrite(ledPin,power->getNewVal());
|
||||
|
||||
return(true); // return true
|
||||
|
||||
} // update
|
||||
};
|
||||
|
||||
//////////////////////////////////
|
||||
|
||||
// Here's the new code defining DEV_DimmableLED - changes from above are noted in the comments
|
||||
extern int zmienna;
|
||||
|
||||
struct DEV_DimmableLED : Service::LightBulb { // Dimmable LED
|
||||
|
||||
@@ -41,7 +13,6 @@ struct DEV_DimmableLED : Service::LightBulb { // Dimmable LED
|
||||
|
||||
level=new Characteristic::Brightness(50); // NEW! Instantiate the Brightness Characteristic with an initial value of 50% (same as we did in Example 4)
|
||||
level->setRange(5,100,1); // NEW! This sets the range of the Brightness to be from a min of 5%, to a max of 100%, in steps of 1% (different from Example 4 values)
|
||||
|
||||
this->ledPin=new LedPin(pin); // NEW! Configures a PWM LED for output to the specified pin. Note pinMode() does NOT need to be called in advance
|
||||
|
||||
} // end constructor
|
||||
@@ -58,7 +29,8 @@ struct DEV_DimmableLED : Service::LightBulb { // Dimmable LED
|
||||
// set the LED level to zero when the LightBulb is off, or to the current brightness level when it is on.
|
||||
|
||||
ledPin->set(power->getNewVal()*level->getNewVal());
|
||||
|
||||
zmienna = power->getNewVal()*level->getNewVal();
|
||||
|
||||
return(true); // return true
|
||||
|
||||
} // update
|
||||
|
||||
78
ESP32/10-RGB_LED/10-RGB_LED.ino
Normal file
78
ESP32/10-RGB_LED/10-RGB_LED.ino
Normal file
@@ -0,0 +1,78 @@
|
||||
/*********************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-2024 Gregg E. Berman
|
||||
*
|
||||
* https://github.com/HomeSpan/HomeSpan
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
********************************************************************************/
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// HomeSpan: A HomeKit implementation for the ESP32 //
|
||||
// ------------------------------------------------ //
|
||||
// //
|
||||
// Example 10: Controlling a full-color RGB LED //
|
||||
// //
|
||||
// //
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
#include "HomeSpan.h"
|
||||
#include "DEV_LED.h"
|
||||
int RedHomeKit = 0;
|
||||
int GreenHomeKit = 0;
|
||||
int BlueHomeKit = 0;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
homeSpan.setPairingCode("11122333");
|
||||
homeSpan.setQRID("111-22-333");
|
||||
// konfiguracja WIFI przez port szerefowy "W<returm"
|
||||
// 1.Płytka ESP32 Dev Module
|
||||
// 2 Partycja: Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS)
|
||||
// 3. konfiguracja WIFI przez port szerefowy komenda "W", U - unpair
|
||||
homeSpan.begin(Category::Bridges,"HomeSpan Bridge");
|
||||
|
||||
new SpanAccessory();
|
||||
new Service::AccessoryInformation();
|
||||
new Characteristic::Identify();
|
||||
|
||||
new SpanAccessory();
|
||||
new Service::AccessoryInformation();
|
||||
new Characteristic::Identify();
|
||||
new Characteristic::Name("RGB LED");
|
||||
new DEV_RgbLED(); // Create an RGB LED attached to pins 32,22,23 (for R, G, and B LED anodes)
|
||||
|
||||
}
|
||||
void loop(){
|
||||
|
||||
homeSpan.poll();
|
||||
Serial.println("---------------------------");
|
||||
Serial.print("R: ");
|
||||
Serial.println(RedHomeKit);
|
||||
Serial.print("G: ");
|
||||
Serial.println(GreenHomeKit);
|
||||
Serial.print("B: ");
|
||||
Serial.println(BlueHomeKit);
|
||||
|
||||
delay(500);
|
||||
} // end of loop()
|
||||
88
ESP32/10-RGB_LED/DEV_LED.h
Normal file
88
ESP32/10-RGB_LED/DEV_LED.h
Normal file
@@ -0,0 +1,88 @@
|
||||
extern int RedHomeKit;
|
||||
extern int GreenHomeKit;
|
||||
extern int BlueHomeKit;
|
||||
|
||||
|
||||
struct DEV_RgbLED : Service::LightBulb { // RGB LED (Command Cathode)
|
||||
|
||||
SpanCharacteristic *power; // reference to the On Characteristic
|
||||
SpanCharacteristic *H; // reference to the Hue Characteristic
|
||||
SpanCharacteristic *S; // reference to the Saturation Characteristic
|
||||
SpanCharacteristic *V; // reference to the Brightness Characteristic
|
||||
|
||||
DEV_RgbLED() : Service::LightBulb(){ // constructor() method
|
||||
|
||||
power=new Characteristic::On();
|
||||
H=new Characteristic::Hue(0); // instantiate the Hue Characteristic with an initial value of 0 out of 360
|
||||
S=new Characteristic::Saturation(0); // instantiate the Saturation Characteristic with an initial value of 0%
|
||||
V=new Characteristic::Brightness(100); // instantiate the Brightness Characteristic with an initial value of 100%
|
||||
V->setRange(5,100,1); // sets the range of the Brightness to be from a min of 5%, to a max of 100%, in steps of 1%
|
||||
|
||||
char cBuf[128];
|
||||
Serial.print(cBuf);
|
||||
|
||||
} // end constructor
|
||||
|
||||
boolean update(){ // update() method
|
||||
|
||||
boolean p;
|
||||
float v, h, s, r, g, b;
|
||||
|
||||
h=H->getVal<float>(); // get and store all current values. Note the use of the <float> template to properly read the values
|
||||
s=S->getVal<float>();
|
||||
v=V->getVal<float>(); // though H and S are defined as FLOAT in HAP, V (which is brightness) is defined as INT, but will be re-cast appropriately
|
||||
p=power->getVal();
|
||||
|
||||
char cBuf[128];
|
||||
LOG1(cBuf);
|
||||
|
||||
if(power->updated()){
|
||||
p=power->getNewVal();
|
||||
sprintf(cBuf,"Power=%s->%s, ",power->getVal()?"true":"false",p?"true":"false");
|
||||
} else {
|
||||
sprintf(cBuf,"Power=%s, ",p?"true":"false");
|
||||
}
|
||||
LOG1(cBuf);
|
||||
|
||||
if(H->updated()){
|
||||
h=H->getNewVal<float>();
|
||||
sprintf(cBuf,"H=%.0f->%.0f, ",H->getVal<float>(),h);
|
||||
} else {
|
||||
sprintf(cBuf,"H=%.0f, ",h);
|
||||
}
|
||||
LOG1(cBuf);
|
||||
|
||||
if(S->updated()){
|
||||
s=S->getNewVal<float>();
|
||||
sprintf(cBuf,"S=%.0f->%.0f, ",S->getVal<float>(),s);
|
||||
} else {
|
||||
sprintf(cBuf,"S=%.0f, ",s);
|
||||
}
|
||||
LOG1(cBuf);
|
||||
|
||||
if(V->updated()){
|
||||
v=V->getNewVal<float>();
|
||||
sprintf(cBuf,"V=%.0f->%.0f ",V->getVal<float>(),v);
|
||||
} else {
|
||||
sprintf(cBuf,"V=%.0f ",v);
|
||||
}
|
||||
LOG1(cBuf);
|
||||
|
||||
LedPin::HSVtoRGB(h,s/100.0,v/100.0,&r,&g,&b); // since HomeKit provides S and V in percent, scale down by 100
|
||||
|
||||
int R, G, B;
|
||||
|
||||
R=p*r*100; // since LedPin uses percent, scale back up by 100, and multiple by status fo power (either 0 or 1)
|
||||
G=p*g*100;
|
||||
B=p*b*100;
|
||||
|
||||
RedHomeKit = R;
|
||||
GreenHomeKit = G;
|
||||
BlueHomeKit = B;
|
||||
|
||||
sprintf(cBuf,"RGB=(%d,%d,%d)\n",R,G,B);
|
||||
LOG1(cBuf);
|
||||
|
||||
return(true); // return true
|
||||
}
|
||||
};
|
||||
78
ESP32/DualCore/DualCore.ino
Normal file
78
ESP32/DualCore/DualCore.ino
Normal file
@@ -0,0 +1,78 @@
|
||||
#include <Arduino.h>
|
||||
#include "DHT.h"
|
||||
|
||||
#define LED_PIN 2
|
||||
#define DHT_PIN 17
|
||||
#define DHT_TYPE DHT22
|
||||
|
||||
DHT dht(DHT_PIN, DHT_TYPE);
|
||||
|
||||
// Uchwyty do tasków
|
||||
TaskHandle_t TaskBlink;
|
||||
// TaskHandle_t TaskDHT;
|
||||
|
||||
float h;
|
||||
float t;
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
pinMode(LED_PIN, OUTPUT);
|
||||
dht.begin();
|
||||
|
||||
// Task pulsowania LED
|
||||
xTaskCreatePinnedToCore(
|
||||
blinkTask, "TaskBlink", 2048, NULL, 1, &TaskBlink, 1);
|
||||
|
||||
// Task odczytu DHT22
|
||||
// xTaskCreatePinnedToCore(
|
||||
// dhtTask, "TaskDHT", 4096, NULL, 1, &TaskDHT, 1);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
h = dht.readHumidity();
|
||||
t = dht.readTemperature();
|
||||
|
||||
if (isnan(h) || isnan(t)) {
|
||||
Serial.println("Błąd odczytu z DHT22!");
|
||||
} else {
|
||||
Serial.printf("Temperatura: %.1f °C | Wilgotność: %.1f %%\n", t, h);
|
||||
}
|
||||
|
||||
delay(2000 / portTICK_PERIOD_MS);
|
||||
}
|
||||
|
||||
// --- Task LED PWM ---
|
||||
void blinkTask(void *pvParameters) {
|
||||
(void) pvParameters;
|
||||
|
||||
while (1) {
|
||||
// Rozjaśnianie
|
||||
for (int i = 0; i <= 255; i++) {
|
||||
analogWrite(LED_PIN, i);
|
||||
vTaskDelay(10 / portTICK_PERIOD_MS);
|
||||
}
|
||||
// Ściemnianie
|
||||
for (int i = 255; i >= 0; i--) {
|
||||
analogWrite(LED_PIN, i);
|
||||
vTaskDelay(10 / portTICK_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// // --- Task DHT22 ---
|
||||
// void dhtTask(void *pvParameters) {
|
||||
// (void) pvParameters;
|
||||
|
||||
// while (1) {
|
||||
// h = dht.readHumidity();
|
||||
// t = dht.readTemperature();
|
||||
|
||||
// if (isnan(h) || isnan(t)) {
|
||||
// Serial.println("Błąd odczytu z DHT22!");
|
||||
// } else {
|
||||
// Serial.printf("Temperatura: %.1f °C | Wilgotność: %.1f %%\n", t, h);
|
||||
// }
|
||||
|
||||
// vTaskDelay(2000 / portTICK_PERIOD_MS);
|
||||
// }
|
||||
// }
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
|
||||
#define Version "2.2.9"
|
||||
#define Version "2.2.11"
|
||||
////2DO:
|
||||
// menu do zmiany zakresu predkosci biegów
|
||||
// menu do zmiany zakresu kątów biegów, obwodu koła, ilosci magnesow
|
||||
@@ -23,7 +23,9 @@ Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
||||
#define PinLED 25 //on board: D25 ORANGE loop signal
|
||||
#define VoltInptPin 27 //on board: D27
|
||||
#define Btn2 33 //on board: D33 Button2
|
||||
|
||||
#define ServoShift 4 //ręczna kalibracja biegu
|
||||
// SDA D21
|
||||
// SCL D22
|
||||
// #define VoltInptPin 23 //on board: D23 Battery Voltage prawdopodobnie uszkodzone ADC
|
||||
|
||||
#define ServoMaxAngle 130
|
||||
@@ -65,13 +67,13 @@ unsigned long loopTime = millis();
|
||||
int currentGear = 1;
|
||||
int calculatedGear = 1;
|
||||
//Przedziały dia biegów
|
||||
float spdRange1and2 = 8.5;
|
||||
float spdRange2and3 = 13.0;
|
||||
float spdRange3and4 = 16.5;
|
||||
float spdRange4and5 = 18.0;
|
||||
float spdRange5and6 = 24.5;
|
||||
float spdRange6and7 = 29.9;
|
||||
float spdRange7and8 = 36.5;
|
||||
float spdRange1and2 = 12.0;
|
||||
float spdRange2and3 = 16.0;
|
||||
float spdRange3and4 = 18.5;
|
||||
float spdRange4and5 = 21.0;
|
||||
float spdRange5and6 = 26.0;
|
||||
float spdRange6and7 = 33.0;
|
||||
float spdRange7and8 = 37.0;
|
||||
double calcTimeDiff = 0.0;
|
||||
double lastGearCalc = millis();
|
||||
double speedDiffKmh = 0.80;
|
||||
@@ -177,6 +179,7 @@ void setPosition(int currentGear) {
|
||||
}
|
||||
sleepMode = 0;
|
||||
}
|
||||
pos = pos + ServoShift; //reczna kalibracja
|
||||
myservo.write(pos);
|
||||
}
|
||||
|
||||
@@ -315,8 +318,10 @@ void calcGear() {
|
||||
currentGear = currentGear;
|
||||
pointerVisibility = 0;
|
||||
} else {
|
||||
if (currentGear != calculatedGear) {
|
||||
lastGearCalc = millis();
|
||||
}
|
||||
currentGear = calculatedGear;
|
||||
lastGearCalc = millis();
|
||||
pointerVisibility = 1;
|
||||
}
|
||||
}
|
||||
|
||||
BIN
ESP32/ESP_AutomatedGearShifter/Kakl kadencji i zakresy.xlsx
Normal file
BIN
ESP32/ESP_AutomatedGearShifter/Kakl kadencji i zakresy.xlsx
Normal file
Binary file not shown.
1502
ESP32/GRA_dspl_128x128/GRA_dspl_128x128/GRA_dspl_128x128.ino
Normal file
1502
ESP32/GRA_dspl_128x128/GRA_dspl_128x128/GRA_dspl_128x128.ino
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,273 @@
|
||||
/*
|
||||
|
||||
GraphicsTest.ino
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <U8g2lib.h>
|
||||
|
||||
#ifdef U8X8_HAVE_HW_SPI
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
#ifdef U8X8_HAVE_HW_I2C
|
||||
#include <Wire.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
U8g2lib Example Overview:
|
||||
Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption
|
||||
Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards.
|
||||
U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only.
|
||||
|
||||
*/
|
||||
|
||||
U8G2_SH1107_SEEED_128X128_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
|
||||
|
||||
|
||||
|
||||
void u8g2_prepare(void) {
|
||||
u8g2.setFont(u8g2_font_6x10_tf);
|
||||
u8g2.setFontRefHeightExtendedText();
|
||||
u8g2.setDrawColor(1);
|
||||
u8g2.setFontPosTop();
|
||||
u8g2.setFontDirection(0);
|
||||
}
|
||||
|
||||
void u8g2_box_frame(uint8_t a) {
|
||||
u8g2.drawStr( 0, 0, "drawBox");
|
||||
u8g2.drawBox(5,10,20,10);
|
||||
u8g2.drawBox(10+a,15,30,7);
|
||||
u8g2.drawStr( 0, 30, "drawFrame");
|
||||
u8g2.drawFrame(5,10+30,20,10);
|
||||
u8g2.drawFrame(10+a,15+30,30,7);
|
||||
}
|
||||
|
||||
void u8g2_disc_circle(uint8_t a) {
|
||||
u8g2.drawStr( 0, 0, "drawDisc");
|
||||
u8g2.drawDisc(10,18,9);
|
||||
u8g2.drawDisc(24+a,16,7);
|
||||
u8g2.drawStr( 0, 30, "drawCircle");
|
||||
u8g2.drawCircle(10,18+30,9);
|
||||
u8g2.drawCircle(24+a,16+30,7);
|
||||
}
|
||||
|
||||
void u8g2_r_frame(uint8_t a) {
|
||||
u8g2.drawStr( 0, 0, "drawRFrame/Box");
|
||||
u8g2.drawRFrame(5, 10,40,30, a+1);
|
||||
u8g2.drawRBox(50, 10,25,40, a+1);
|
||||
}
|
||||
|
||||
void u8g2_string(uint8_t a) {
|
||||
u8g2.setFontDirection(0);
|
||||
u8g2.drawStr(30+a,31, " 0");
|
||||
u8g2.setFontDirection(1);
|
||||
u8g2.drawStr(30,31+a, " 90");
|
||||
u8g2.setFontDirection(2);
|
||||
u8g2.drawStr(30-a,31, " 180");
|
||||
u8g2.setFontDirection(3);
|
||||
u8g2.drawStr(30,31-a, " 270");
|
||||
}
|
||||
|
||||
void u8g2_line(uint8_t a) {
|
||||
u8g2.drawStr( 0, 0, "drawLine");
|
||||
u8g2.drawLine(7+a, 10, 40, 55);
|
||||
u8g2.drawLine(7+a*2, 10, 60, 55);
|
||||
u8g2.drawLine(7+a*3, 10, 80, 55);
|
||||
u8g2.drawLine(7+a*4, 10, 100, 55);
|
||||
}
|
||||
|
||||
void u8g2_triangle(uint8_t a) {
|
||||
uint16_t offset = a;
|
||||
u8g2.drawStr( 0, 0, "drawTriangle");
|
||||
u8g2.drawTriangle(14,7, 45,30, 10,40);
|
||||
u8g2.drawTriangle(14+offset,7-offset, 45+offset,30-offset, 57+offset,10-offset);
|
||||
u8g2.drawTriangle(57+offset*2,10, 45+offset*2,30, 86+offset*2,53);
|
||||
u8g2.drawTriangle(10+offset,40+offset, 45+offset,30+offset, 86+offset,53+offset);
|
||||
}
|
||||
|
||||
void u8g2_ascii_1() {
|
||||
char s[2] = " ";
|
||||
uint8_t x, y;
|
||||
u8g2.drawStr( 0, 0, "ASCII page 1");
|
||||
for( y = 0; y < 6; y++ ) {
|
||||
for( x = 0; x < 16; x++ ) {
|
||||
s[0] = y*16 + x + 32;
|
||||
u8g2.drawStr(x*7, y*10+10, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void u8g2_ascii_2() {
|
||||
char s[2] = " ";
|
||||
uint8_t x, y;
|
||||
u8g2.drawStr( 0, 0, "ASCII page 2");
|
||||
for( y = 0; y < 6; y++ ) {
|
||||
for( x = 0; x < 16; x++ ) {
|
||||
s[0] = y*16 + x + 160;
|
||||
u8g2.drawStr(x*7, y*10+10, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void u8g2_extra_page(uint8_t a)
|
||||
{
|
||||
u8g2.drawStr( 0, 0, "Unicode");
|
||||
u8g2.setFont(u8g2_font_unifont_t_symbols);
|
||||
u8g2.setFontPosTop();
|
||||
u8g2.drawUTF8(0, 24, "☀ ☁");
|
||||
switch(a) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
u8g2.drawUTF8(a*3, 36, "☂");
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
u8g2.drawUTF8(a*3, 36, "☔");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#define cross_width 24
|
||||
#define cross_height 24
|
||||
static const unsigned char cross_bits[] U8X8_PROGMEM = {
|
||||
0x00, 0x18, 0x00, 0x00, 0x24, 0x00, 0x00, 0x24, 0x00, 0x00, 0x42, 0x00,
|
||||
0x00, 0x42, 0x00, 0x00, 0x42, 0x00, 0x00, 0x81, 0x00, 0x00, 0x81, 0x00,
|
||||
0xC0, 0x00, 0x03, 0x38, 0x3C, 0x1C, 0x06, 0x42, 0x60, 0x01, 0x42, 0x80,
|
||||
0x01, 0x42, 0x80, 0x06, 0x42, 0x60, 0x38, 0x3C, 0x1C, 0xC0, 0x00, 0x03,
|
||||
0x00, 0x81, 0x00, 0x00, 0x81, 0x00, 0x00, 0x42, 0x00, 0x00, 0x42, 0x00,
|
||||
0x00, 0x42, 0x00, 0x00, 0x24, 0x00, 0x00, 0x24, 0x00, 0x00, 0x18, 0x00, };
|
||||
|
||||
#define cross_fill_width 24
|
||||
#define cross_fill_height 24
|
||||
static const unsigned char cross_fill_bits[] U8X8_PROGMEM = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x18, 0x64, 0x00, 0x26,
|
||||
0x84, 0x00, 0x21, 0x08, 0x81, 0x10, 0x08, 0x42, 0x10, 0x10, 0x3C, 0x08,
|
||||
0x20, 0x00, 0x04, 0x40, 0x00, 0x02, 0x80, 0x00, 0x01, 0x80, 0x18, 0x01,
|
||||
0x80, 0x18, 0x01, 0x80, 0x00, 0x01, 0x40, 0x00, 0x02, 0x20, 0x00, 0x04,
|
||||
0x10, 0x3C, 0x08, 0x08, 0x42, 0x10, 0x08, 0x81, 0x10, 0x84, 0x00, 0x21,
|
||||
0x64, 0x00, 0x26, 0x18, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
|
||||
|
||||
#define cross_block_width 14
|
||||
#define cross_block_height 14
|
||||
static const unsigned char cross_block_bits[] U8X8_PROGMEM = {
|
||||
0xFF, 0x3F, 0x01, 0x20, 0x01, 0x20, 0x01, 0x20, 0x01, 0x20, 0x01, 0x20,
|
||||
0xC1, 0x20, 0xC1, 0x20, 0x01, 0x20, 0x01, 0x20, 0x01, 0x20, 0x01, 0x20,
|
||||
0x01, 0x20, 0xFF, 0x3F, };
|
||||
|
||||
void u8g2_bitmap_overlay(uint8_t a) {
|
||||
uint8_t frame_size = 28;
|
||||
|
||||
u8g2.drawStr(0, 0, "Bitmap overlay");
|
||||
|
||||
u8g2.drawStr(0, frame_size + 12, "Solid / transparent");
|
||||
u8g2.setBitmapMode(false /* solid */);
|
||||
u8g2.drawFrame(0, 10, frame_size, frame_size);
|
||||
u8g2.drawXBMP(2, 12, cross_width, cross_height, cross_bits);
|
||||
if(a & 4)
|
||||
u8g2.drawXBMP(7, 17, cross_block_width, cross_block_height, cross_block_bits);
|
||||
|
||||
u8g2.setBitmapMode(true /* transparent*/);
|
||||
u8g2.drawFrame(frame_size + 5, 10, frame_size, frame_size);
|
||||
u8g2.drawXBMP(frame_size + 7, 12, cross_width, cross_height, cross_bits);
|
||||
if(a & 4)
|
||||
u8g2.drawXBMP(frame_size + 12, 17, cross_block_width, cross_block_height, cross_block_bits);
|
||||
}
|
||||
|
||||
void u8g2_bitmap_modes(uint8_t transparent) {
|
||||
const uint8_t frame_size = 24;
|
||||
|
||||
u8g2.drawBox(0, frame_size * 0.5, frame_size * 5, frame_size);
|
||||
u8g2.drawStr(frame_size * 0.5, 50, "Black");
|
||||
u8g2.drawStr(frame_size * 2, 50, "White");
|
||||
u8g2.drawStr(frame_size * 3.5, 50, "XOR");
|
||||
|
||||
if(!transparent) {
|
||||
u8g2.setBitmapMode(false /* solid */);
|
||||
u8g2.drawStr(0, 0, "Solid bitmap");
|
||||
} else {
|
||||
u8g2.setBitmapMode(true /* transparent*/);
|
||||
u8g2.drawStr(0, 0, "Transparent bitmap");
|
||||
}
|
||||
u8g2.setDrawColor(0);// Black
|
||||
u8g2.drawXBMP(frame_size * 0.5, 24, cross_width, cross_height, cross_bits);
|
||||
u8g2.setDrawColor(1); // White
|
||||
u8g2.drawXBMP(frame_size * 2, 24, cross_width, cross_height, cross_bits);
|
||||
u8g2.setDrawColor(2); // XOR
|
||||
u8g2.drawXBMP(frame_size * 3.5, 24, cross_width, cross_height, cross_bits);
|
||||
}
|
||||
|
||||
uint8_t draw_state = 0;
|
||||
|
||||
void draw(void) {
|
||||
u8g2_prepare();
|
||||
switch(draw_state >> 3) {
|
||||
case 0: u8g2_box_frame(draw_state&7); break;
|
||||
case 1: u8g2_disc_circle(draw_state&7); break;
|
||||
case 2: u8g2_r_frame(draw_state&7); break;
|
||||
case 3: u8g2_string(draw_state&7); break;
|
||||
case 4: u8g2_line(draw_state&7); break;
|
||||
case 5: u8g2_triangle(draw_state&7); break;
|
||||
case 6: u8g2_ascii_1(); break;
|
||||
case 7: u8g2_ascii_2(); break;
|
||||
case 8: u8g2_extra_page(draw_state&7); break;
|
||||
case 9: u8g2_bitmap_modes(0); break;
|
||||
case 10: u8g2_bitmap_modes(1); break;
|
||||
case 11: u8g2_bitmap_overlay(draw_state&7); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void setup(void) {
|
||||
u8g2.begin();
|
||||
}
|
||||
|
||||
void loop(void) {
|
||||
// picture loop
|
||||
u8g2.clearBuffer();
|
||||
draw();
|
||||
u8g2.sendBuffer();
|
||||
|
||||
// increase the state
|
||||
draw_state++;
|
||||
if ( draw_state >= 12*8 )
|
||||
draw_state = 0;
|
||||
|
||||
// delay between each page
|
||||
delay(100);
|
||||
|
||||
}
|
||||
79
ESP32/Gyroscope_TEST/Gyroscope_TEST.ino
Normal file
79
ESP32/Gyroscope_TEST/Gyroscope_TEST.ino
Normal file
@@ -0,0 +1,79 @@
|
||||
//
|
||||
// FILE: GY521_angle.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: read angleX, angleY, angleZ
|
||||
// URL: https://github.com/RobTillaart/GY521
|
||||
|
||||
|
||||
#include "GY521.h"
|
||||
|
||||
GY521 sensor(0x68);
|
||||
|
||||
uint32_t counter = 0;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("GY521_LIB_VERSION: ");
|
||||
Serial.println(GY521_LIB_VERSION);
|
||||
|
||||
Wire.begin();
|
||||
|
||||
delay(100);
|
||||
while (sensor.wakeup() == false)
|
||||
{
|
||||
Serial.print(millis());
|
||||
Serial.println("\tCould not connect to GY521: please check the GY521 address (0x68/0x69)");
|
||||
delay(1000);
|
||||
}
|
||||
sensor.setAccelSensitivity(2); // 8g
|
||||
sensor.setGyroSensitivity(1); // 500 degrees/s
|
||||
|
||||
sensor.setThrottle();
|
||||
Serial.println("start...");
|
||||
|
||||
// set calibration values from calibration sketch.
|
||||
sensor.axe = 0;
|
||||
sensor.aye = 0;
|
||||
sensor.aze = 0;
|
||||
sensor.gxe = 0;
|
||||
sensor.gye = 0;
|
||||
sensor.gze = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
sensor.read();
|
||||
float x = sensor.getAngleX();
|
||||
float y = sensor.getAngleY();
|
||||
float z = sensor.getAngleZ();
|
||||
|
||||
float gx = sensor.getGyroX();
|
||||
float gy = sensor.getGyroY();
|
||||
float gz = sensor.getGyroZ();
|
||||
|
||||
if (counter % 10 == 0)
|
||||
{
|
||||
// Serial.println("\nCNT\tX\tY\tZ");
|
||||
}
|
||||
|
||||
// Serial.print(counter);
|
||||
// Serial.print('\t');
|
||||
Serial.print(gx, 1);
|
||||
Serial.print('\t');
|
||||
Serial.print(gy, 1);
|
||||
Serial.print('\t');
|
||||
Serial.print(gz, 1);
|
||||
Serial.println();
|
||||
delay (25);
|
||||
counter++;
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
133
ESP32/LampkiBalkon/LampkiBalkon.ino
Normal file
133
ESP32/LampkiBalkon/LampkiBalkon.ino
Normal file
@@ -0,0 +1,133 @@
|
||||
#include <Wire.h>
|
||||
#include <BH1750.h>
|
||||
#include <esp_sleep.h>
|
||||
#define Version "0.1.3"
|
||||
|
||||
#define PinLED 2 // on-board LED
|
||||
#define IN1 32
|
||||
#define IN2 14
|
||||
|
||||
#define SCREEN_WIDTH 128
|
||||
#define SCREEN_HEIGHT 32
|
||||
#define OLED_RESET -1
|
||||
#define SCREEN_ADDRESS 0x3C
|
||||
|
||||
// Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
||||
BH1750 lightMeter;
|
||||
|
||||
// TaskHandle_t TaskReadLux;
|
||||
|
||||
float lux = 0.0;
|
||||
|
||||
void setup() {
|
||||
|
||||
Serial.begin(9600);
|
||||
Wire.begin();
|
||||
lightMeter.begin();
|
||||
|
||||
// if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
|
||||
// Serial.println(F("SSD1306 allocation failed"));
|
||||
// }
|
||||
// xTaskCreatePinnedToCore(
|
||||
// readLuxTask, "ReadLux", 2048, NULL, 1, &TaskReadLux, 1);
|
||||
|
||||
|
||||
// display.setTextSize(1);
|
||||
// display.setTextColor(SSD1306_WHITE);
|
||||
// display.clearDisplay();
|
||||
// display.setCursor(0, 0);
|
||||
// display.println("Version:");
|
||||
// display.setCursor(60, 0);
|
||||
// display.println(Version);
|
||||
// display.display();
|
||||
|
||||
pinMode(IN1, OUTPUT);
|
||||
pinMode(IN2, OUTPUT);
|
||||
pinMode(PinLED, OUTPUT);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void pulsujNaprzemiennie(int czasSekundy) {
|
||||
const int steps = 600; // większa liczba = gładsze przejścia
|
||||
const int totalMillis = czasSekundy * 1000;
|
||||
const int delayPerStep = totalMillis / steps;
|
||||
// display.clearDisplay();
|
||||
// display.setCursor(0, 20);
|
||||
// display.println("1");
|
||||
// display.display();
|
||||
for (int i = 0; i < 20; i++) {
|
||||
|
||||
for (int i = 0; i <= steps; i++) {
|
||||
float phase = (float)i / steps;
|
||||
float angle = phase * PI; // pół cyklu (od 0 do π)
|
||||
|
||||
// sinusoidalne przejście
|
||||
float brightness1 = (cos(angle) + 1.0) / 2.0; // 1 → 0
|
||||
float brightness2 = 1.0 - brightness1; // 0 → 1
|
||||
|
||||
// Konwersja jasności do długości impulsu (maks. 2000us)
|
||||
int pulse1 = (int)(brightness1 * 2000);
|
||||
int pulse2 = (int)(brightness2 * 2000);
|
||||
|
||||
// Wysterowanie IN1
|
||||
digitalWrite(IN1, HIGH);
|
||||
delayMicroseconds(pulse1);
|
||||
digitalWrite(IN1, LOW);
|
||||
|
||||
// Wysterowanie IN2
|
||||
digitalWrite(IN2, HIGH);
|
||||
delayMicroseconds(pulse2);
|
||||
digitalWrite(IN2, LOW);
|
||||
|
||||
// Opóźnienie (reszta czasu kroku)
|
||||
delayMicroseconds(1000 * delayPerStep - pulse1 - pulse2);
|
||||
}
|
||||
|
||||
// drugi półcykl: kolory zamienione miejscami (pełny cykl = 2x π)
|
||||
// display.clearDisplay();
|
||||
// display.setCursor(0, 20);
|
||||
// display.println("2");
|
||||
// display.display();
|
||||
|
||||
for (int i = 0; i <= steps; i++) {
|
||||
float phase = (float)i / steps;
|
||||
float angle = phase * PI;
|
||||
|
||||
float brightness1 = (cos(angle) + 1.0) / 2.0;
|
||||
float brightness2 = 1.0 - brightness1;
|
||||
|
||||
int pulse1 = (int)(brightness2 * 2000);
|
||||
int pulse2 = (int)(brightness1 * 2000);
|
||||
|
||||
digitalWrite(IN1, HIGH);
|
||||
delayMicroseconds(pulse1);
|
||||
digitalWrite(IN1, LOW);
|
||||
|
||||
digitalWrite(IN2, HIGH);
|
||||
delayMicroseconds(pulse2);
|
||||
digitalWrite(IN2, LOW);
|
||||
|
||||
delayMicroseconds(1000 * delayPerStep - pulse1 - pulse2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
uint16_t lux = lightMeter.readLightLevel();
|
||||
if (lux < 10 || lux == -2) {
|
||||
digitalWrite(PinLED, LOW);
|
||||
pulsujNaprzemiennie(8); // pełny cykl 8 sekund
|
||||
} else {
|
||||
digitalWrite(PinLED, HIGH);
|
||||
// display.setCursor(0, 10);
|
||||
// display.println("OFF");
|
||||
esp_sleep_enable_timer_wakeup(100 * 1000000ULL); // 5s w mikrosekundach
|
||||
esp_light_sleep_start();
|
||||
|
||||
}
|
||||
// display.display();
|
||||
|
||||
}
|
||||
|
||||
|
||||
114
ESP32/PlantWaterer/PlantWaterer.ino
Normal file
114
ESP32/PlantWaterer/PlantWaterer.ino
Normal file
@@ -0,0 +1,114 @@
|
||||
#include <SPI.h>
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
#include <esp_sleep.h>
|
||||
|
||||
#define Version "0.3"
|
||||
#define SCREEN_WIDTH 128
|
||||
#define SCREEN_HEIGHT 32
|
||||
#define OLED_RESET -1
|
||||
#define SCREEN_ADDRESS 0x3C
|
||||
//PINS
|
||||
#define WTR_SENSOR 4 //GPIO04 D4
|
||||
#define PIN_PUMP 26 //GPIO26 D26
|
||||
#define wetSoil 1200 // Define max value we consider soil 'wet'
|
||||
#define midSoil 1730 // Define max value we consider soil 'wet'
|
||||
#define drySoil 2400 // Define min value we consider soil 'dry'
|
||||
#define AIR 3150 // Define min value we consider soil 'dry'
|
||||
#define cupOfWater 1024 // Define min value we consider soil 'dry'
|
||||
// #define LED_RED_TANK 26 //GPIO25 D25
|
||||
// #define WTR_LVL 33 //GPI
|
||||
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
||||
|
||||
//MAIN VALUES VARIABLES
|
||||
int moisture = 0;
|
||||
int watertingCnt = 0;
|
||||
int minValue = 5000;
|
||||
int maxValue = 0;
|
||||
int waitSec = 96;
|
||||
int waitMs = 1000 * waitSec;
|
||||
|
||||
void setup() {
|
||||
pinMode(WTR_SENSOR, INPUT_PULLDOWN);
|
||||
pinMode(PIN_PUMP, OUTPUT);
|
||||
digitalWrite(PIN_PUMP, HIGH);
|
||||
Serial.begin(9600);
|
||||
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
|
||||
Serial.println(F("SSD1306 allocation failed"));
|
||||
}
|
||||
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
display.clearDisplay();
|
||||
display.setCursor(0, 0);
|
||||
display.println("Version:");
|
||||
display.setCursor(60, 0);
|
||||
display.println(Version);
|
||||
display.display();
|
||||
moisture = analogRead(WTR_SENSOR);
|
||||
delay(5000);
|
||||
moisture = analogRead(WTR_SENSOR);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// ###################################################
|
||||
// WYŚWIETLACZ
|
||||
moisture = analogRead(WTR_SENSOR);
|
||||
display.clearDisplay();
|
||||
display.setCursor(110, 0);
|
||||
display.println(Version);
|
||||
display.setCursor(0, 0);
|
||||
display.println("cnt:");
|
||||
display.setCursor(25, 0);
|
||||
display.println(watertingCnt);
|
||||
display.setCursor(45, 0);
|
||||
display.println("lvl:");
|
||||
display.setCursor(70, 0);
|
||||
display.println(moisture);
|
||||
display.setCursor(0, 10);
|
||||
display.println("threshold:>");
|
||||
display.setCursor(73, 10);
|
||||
display.println(drySoil);
|
||||
|
||||
if (moisture > maxValue){
|
||||
maxValue = moisture;
|
||||
}
|
||||
if (moisture < minValue){
|
||||
minValue = moisture;
|
||||
}
|
||||
display.setCursor(0, 20);
|
||||
display.println("min:");
|
||||
display.setCursor(23, 20);
|
||||
display.println(minValue);
|
||||
display.setCursor(70, 20);
|
||||
display.println("max:");
|
||||
display.setCursor(93, 20);
|
||||
display.println(maxValue);
|
||||
|
||||
Serial.print("Analog output: ");
|
||||
Serial.println(moisture);
|
||||
|
||||
if (moisture < drySoil) {
|
||||
Serial.println("Status: Soil is too wet");
|
||||
digitalWrite(PIN_PUMP, HIGH);
|
||||
|
||||
} else {
|
||||
display.fillCircle(110, 12, 5, SSD1306_WHITE);
|
||||
display.display();
|
||||
Serial.println("Status: Soil is too dry - time to water!");
|
||||
digitalWrite(PIN_PUMP, LOW);
|
||||
watertingCnt++;
|
||||
delay(waitMs/16);
|
||||
digitalWrite(PIN_PUMP, HIGH);
|
||||
}
|
||||
Serial.println();
|
||||
|
||||
display.fillCircle(110, 12, 5, SSD1306_BLACK);
|
||||
|
||||
display.display();
|
||||
esp_sleep_enable_timer_wakeup(waitSec * 1000000ULL); // 5s w mikrosekundach
|
||||
esp_light_sleep_start();
|
||||
|
||||
}
|
||||
@@ -1,17 +1,11 @@
|
||||
#include <TFT_eSPI.h>
|
||||
#include <SPI.h>
|
||||
|
||||
|
||||
// Wymaga konfiguracjie:
|
||||
// C:\Users\siiee\Documents\Arduino\libraries\TFT_eSPI
|
||||
|
||||
TFT_eSPI tft = TFT_eSPI(); // domyślna konfiguracja z User_Setup.h
|
||||
|
||||
//2DO:
|
||||
// obsługa przycisków zmieniających menu i LED
|
||||
//160x128
|
||||
|
||||
#define Version "0.1.0"
|
||||
#define Version "0.1.1"
|
||||
#include <SPI.h>
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
@@ -38,10 +32,6 @@ TFT_eSPI tft = TFT_eSPI(); // domyślna konfiguracja z User_Setup.h
|
||||
#define MAGENTA 0xF81F
|
||||
#define PINK 0xF8FF
|
||||
#define SPACE_4_TEXT 20
|
||||
//#define ST7735 NEW 0xD500FF
|
||||
|
||||
|
||||
|
||||
|
||||
AS726X sensor;
|
||||
|
||||
@@ -64,11 +54,11 @@ int HeightGreen = 0;
|
||||
int HeightBlue = 0;
|
||||
int HeightViolet = 0;
|
||||
|
||||
byte gain = 3; // values: 0,1,2,3
|
||||
byte old_gain = 3; // values: 0,1,2,3
|
||||
byte gain = 3; // values: 0,1,2,3
|
||||
byte old_gain = 3; // values: 0,1,2,3
|
||||
float gainValue = 64;
|
||||
int menu_number = 0; // values:0 menu 1,2,3
|
||||
int old_menu_number = 0; // values:0 menu 1,2,3
|
||||
int menu_number = 0; // values:0 menu 1,2,3
|
||||
int old_menu_number = 0; // values:0 menu 1,2,3
|
||||
int LedPower = 0;
|
||||
int GraphHeight = 128;
|
||||
int GrapWidth = 25;
|
||||
@@ -82,13 +72,10 @@ float test_vle = 1.0;
|
||||
char FloatInChar[20];
|
||||
char ChValue[20];
|
||||
|
||||
|
||||
|
||||
void setup() {
|
||||
tft.init();
|
||||
tft.setRotation(1);
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
tft.setTextColor(TFT_YELLOW, TFT_BLACK);
|
||||
tft.setTextSize(2);
|
||||
tft.drawString("Version:"+ String(Version), 0, 0);
|
||||
@@ -98,9 +85,7 @@ void setup() {
|
||||
pinMode(Btn1, INPUT);
|
||||
pinMode(Btn2, INPUT);
|
||||
pinMode(Btn3, INPUT);
|
||||
|
||||
tft.fillRect(0, 0, 240, 240, TFT_BLACK);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -142,23 +127,37 @@ void loop() {
|
||||
tft.drawString("1:Calc.Values",0, 48);
|
||||
tft.drawString("2:Raw",0, 64);
|
||||
tft.drawString("3:Rel. Graph",0, 80);
|
||||
tft.drawString("4:Calc. Graph",0, 96);
|
||||
// tft.drawString("4:Calc. Graph",0, 96);
|
||||
}
|
||||
// show calculated values
|
||||
if (menu_number == 1 ) {//show calculated values
|
||||
tft.drawString("1.Calc Values",0,0);
|
||||
tft.drawString("Gain: " + String(gainValue) + " LED: ", 0,10);
|
||||
tft.drawString("Gain: " + String(gainValue) + " LED: ", 0,9);
|
||||
if (LedPower == 1){
|
||||
tft.drawString("ON ",100, 10);
|
||||
} else {
|
||||
tft.drawString("OFF",100, 10);
|
||||
}
|
||||
tft.drawString("R:" + String(CalcRed),0, 20);
|
||||
tft.drawString("O:" + String(CalcOrange),0, 39);
|
||||
tft.drawString("Y:" + String(CalcYellow),0, 58);
|
||||
tft.drawString("G:" + String(CalcGreen),0, 77);
|
||||
tft.drawString("B:" + String(CalcBlue),0, 96);
|
||||
tft.drawString("V:" + String(CalcViolet),0, 115);
|
||||
|
||||
tft.fillRect(0, 20, 160,18, TFT_RED);
|
||||
tft.fillRect(0, 38, 160,18, TFT_ORANGE);
|
||||
tft.fillRect(0, 56, 160,18, TFT_YELLOW);
|
||||
tft.fillRect(0, 74, 160,18, TFT_GREEN);
|
||||
tft.fillRect(0, 92, 160,18, TFT_BLUE);
|
||||
tft.fillRect(0, 110, 160,20, TFT_MAGENTA);
|
||||
tft.setTextSize(2);
|
||||
tft.setTextColor(TFT_BLACK, TFT_RED);
|
||||
tft.drawString("R:" + String(CalcRed),2, 22);
|
||||
tft.setTextColor(TFT_BLACK, TFT_ORANGE);
|
||||
tft.drawString("O:" + String(CalcOrange),2, 40);
|
||||
tft.setTextColor(TFT_BLACK, TFT_YELLOW);
|
||||
tft.drawString("Y:" + String(CalcYellow),2, 58);
|
||||
tft.setTextColor(TFT_BLACK, TFT_GREEN);
|
||||
tft.drawString("G:" + String(CalcGreen),2, 76);
|
||||
tft.setTextColor(TFT_BLACK, TFT_BLUE);
|
||||
tft.drawString("B:" + String(CalcBlue),2, 94);
|
||||
tft.setTextColor(TFT_BLACK, TFT_MAGENTA);
|
||||
tft.drawString("V:" + String(CalcViolet),2, 112);
|
||||
}
|
||||
// //show raw values
|
||||
if (menu_number == 2 || menu_number == 6) {
|
||||
@@ -169,13 +168,26 @@ void loop() {
|
||||
} else {
|
||||
tft.drawString("OFF",100, 10);
|
||||
}
|
||||
tft.drawString("R:" + String(RawRed),0, 20);
|
||||
tft.drawString("O:" + String(RawOrange),0, 39);
|
||||
tft.drawString("Y:" + String(RawYellow),0, 58);
|
||||
tft.drawString("G:" + String(RawGreen),0, 77);
|
||||
tft.drawString("B:" + String(RawBlue),0, 96);
|
||||
tft.drawString("V:" + String(RawViolet),0, 115);
|
||||
|
||||
tft.fillRect(0, 20, 160,18, TFT_RED);
|
||||
tft.fillRect(0, 38, 160,18, TFT_ORANGE);
|
||||
tft.fillRect(0, 56, 160,18, TFT_YELLOW);
|
||||
tft.fillRect(0, 74, 160,18, TFT_GREEN);
|
||||
tft.fillRect(0, 92, 160,18, TFT_BLUE);
|
||||
tft.fillRect(0, 110, 160,20, TFT_MAGENTA);
|
||||
tft.setTextSize(2);
|
||||
tft.setTextColor(TFT_BLACK, TFT_RED);
|
||||
tft.drawString("R:" + String(RawRed),2, 22);
|
||||
tft.setTextColor(TFT_BLACK, TFT_ORANGE);
|
||||
tft.drawString("O:" + String(RawOrange),2, 40);
|
||||
tft.setTextColor(TFT_BLACK, TFT_YELLOW);
|
||||
tft.drawString("Y:" + String(RawYellow),2, 58);
|
||||
tft.setTextColor(TFT_BLACK, TFT_GREEN);
|
||||
tft.drawString("G:" + String(RawGreen),2, 76);
|
||||
tft.setTextColor(TFT_BLACK, TFT_BLUE);
|
||||
tft.drawString("B:" + String(RawBlue),2, 94);
|
||||
tft.setTextColor(TFT_BLACK, TFT_MAGENTA);
|
||||
tft.drawString("V:" + String(RawViolet),2, 112);
|
||||
}
|
||||
//show relative calculated values graph
|
||||
if (menu_number == 3){
|
||||
@@ -242,55 +254,55 @@ void loop() {
|
||||
|
||||
|
||||
|
||||
// //show relative raw data graph
|
||||
if (menu_number == 4){
|
||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
maxValue = 0.0;
|
||||
minValue = 0.0;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
maxValue = max(maxValue, ReadRawValues[i]);
|
||||
}
|
||||
for (int i = 0; i < 5; i++) {
|
||||
minValue = min(minValue, ReadRawValues[i]);
|
||||
}
|
||||
// // //show relative raw data graph
|
||||
// if (menu_number == 4){
|
||||
// tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
// maxValue = 0.0;
|
||||
// minValue = 0.0;
|
||||
// for (int i = 0; i < 5; i++) {
|
||||
// maxValue = max(maxValue, ReadRawValues[i]);
|
||||
// }
|
||||
// for (int i = 0; i < 5; i++) {
|
||||
// minValue = min(minValue, ReadRawValues[i]);
|
||||
// }
|
||||
|
||||
// HeightRed = int(((RawRed + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
||||
// HeightOrange = int(((RawOrange + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
||||
// HeightYellow = int(((RawYellow + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
||||
// HeightGreen = int(((RawGreen + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
||||
// HeightBlue = int(((RawBlue + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
||||
// HeightViolet = int(((RawViolet + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
||||
tft.fillRect(minValue, 0, 240, maxValue-minValue, TFT_BLACK);
|
||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
tft.drawString("4.Relvative Raw Values",0,0);
|
||||
tft.drawString("Gain: " + String(gainValue) + " LED: ", 0,10);
|
||||
if (LedPower == 1){
|
||||
tft.drawString("ON ",100, 10);
|
||||
} else {
|
||||
tft.drawString("OFF",100, 10);
|
||||
}
|
||||
// // HeightRed = int(((RawRed + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
||||
// // HeightOrange = int(((RawOrange + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
||||
// // HeightYellow = int(((RawYellow + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
||||
// // HeightGreen = int(((RawGreen + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
||||
// // HeightBlue = int(((RawBlue + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
||||
// // HeightViolet = int(((RawViolet + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
||||
// tft.fillRect(minValue, 0, 240, maxValue-minValue, TFT_BLACK);
|
||||
// tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
// tft.drawString("4.Relvative Raw Values",0,0);
|
||||
// tft.drawString("Gain: " + String(gainValue) + " LED: ", 0,10);
|
||||
// if (LedPower == 1){
|
||||
// tft.drawString("ON ",100, 10);
|
||||
// } else {
|
||||
// tft.drawString("OFF",100, 10);
|
||||
// }
|
||||
|
||||
tft.fillRect(0 * GrapWidth, GraphHeight - HeightRed, GrapWidth, HeightRed + SPACE_4_TEXT, TFT_RED);
|
||||
tft.fillRect(1 * GrapWidth + 1, GraphHeight - HeightOrange, GrapWidth, HeightOrange + SPACE_4_TEXT, TFT_ORANGE);
|
||||
tft.fillRect(2 * GrapWidth + 2, GraphHeight - HeightYellow, GrapWidth, HeightYellow + SPACE_4_TEXT, TFT_YELLOW);
|
||||
tft.fillRect(3 * GrapWidth + 3, GraphHeight - HeightGreen, GrapWidth, HeightGreen + SPACE_4_TEXT, TFT_GREEN);
|
||||
tft.fillRect(4 * GrapWidth + 4, GraphHeight - HeightBlue, GrapWidth, HeightBlue + SPACE_4_TEXT, TFT_BLUE);
|
||||
tft.fillRect(5 * GrapWidth + 5, GraphHeight - HeightViolet, GrapWidth, HeightViolet + SPACE_4_TEXT, TFT_MAGENTA);
|
||||
tft.setTextColor(TFT_BLACK, TFT_RED);
|
||||
tft.drawString(" R:",1 * GrapWidth -20, 120);
|
||||
tft.setTextColor(TFT_BLACK, TFT_ORANGE);
|
||||
tft.drawString(" O:",2 * GrapWidth -19, 120);
|
||||
tft.setTextColor(TFT_BLACK, TFT_YELLOW);
|
||||
tft.drawString(" Y:",3 * GrapWidth -18, 120);
|
||||
tft.setTextColor(TFT_BLACK, TFT_GREEN);
|
||||
tft.drawString(" G:",4 * GrapWidth -17, 120);
|
||||
tft.setTextColor(TFT_BLACK, TFT_BLUE);
|
||||
tft.drawString(" B:",5 * GrapWidth -16, 120);
|
||||
tft.setTextColor(TFT_BLACK, TFT_MAGENTA);
|
||||
tft.drawString(" V:",6 * GrapWidth -15, 120);
|
||||
maxValue = 0.0;
|
||||
minValue = 0.0;
|
||||
}
|
||||
// tft.fillRect(0 * GrapWidth, GraphHeight - HeightRed, GrapWidth, HeightRed + SPACE_4_TEXT, TFT_RED);
|
||||
// tft.fillRect(1 * GrapWidth + 1, GraphHeight - HeightOrange, GrapWidth, HeightOrange + SPACE_4_TEXT, TFT_ORANGE);
|
||||
// tft.fillRect(2 * GrapWidth + 2, GraphHeight - HeightYellow, GrapWidth, HeightYellow + SPACE_4_TEXT, TFT_YELLOW);
|
||||
// tft.fillRect(3 * GrapWidth + 3, GraphHeight - HeightGreen, GrapWidth, HeightGreen + SPACE_4_TEXT, TFT_GREEN);
|
||||
// tft.fillRect(4 * GrapWidth + 4, GraphHeight - HeightBlue, GrapWidth, HeightBlue + SPACE_4_TEXT, TFT_BLUE);
|
||||
// tft.fillRect(5 * GrapWidth + 5, GraphHeight - HeightViolet, GrapWidth, HeightViolet + SPACE_4_TEXT, TFT_MAGENTA);
|
||||
// tft.setTextColor(TFT_BLACK, TFT_RED);
|
||||
// tft.drawString(" R:",1 * GrapWidth -20, 120);
|
||||
// tft.setTextColor(TFT_BLACK, TFT_ORANGE);
|
||||
// tft.drawString(" O:",2 * GrapWidth -19, 120);
|
||||
// tft.setTextColor(TFT_BLACK, TFT_YELLOW);
|
||||
// tft.drawString(" Y:",3 * GrapWidth -18, 120);
|
||||
// tft.setTextColor(TFT_BLACK, TFT_GREEN);
|
||||
// tft.drawString(" G:",4 * GrapWidth -17, 120);
|
||||
// tft.setTextColor(TFT_BLACK, TFT_BLUE);
|
||||
// tft.drawString(" B:",5 * GrapWidth -16, 120);
|
||||
// tft.setTextColor(TFT_BLACK, TFT_MAGENTA);
|
||||
// tft.drawString(" V:",6 * GrapWidth -15, 120);
|
||||
// maxValue = 0.0;
|
||||
// minValue = 0.0;
|
||||
// }
|
||||
|
||||
|
||||
if (gain == 0 ) {
|
||||
@@ -354,7 +366,7 @@ void setLed() {
|
||||
}
|
||||
}
|
||||
void setMenu() {
|
||||
if (menu_number < 4) {
|
||||
if (menu_number < 3) {
|
||||
menu_number = menu_number + 1;
|
||||
} else {
|
||||
menu_number = 0;
|
||||
|
||||
27
ESP32/Sleep/DeepSleep/DeepSleep.ino
Normal file
27
ESP32/Sleep/DeepSleep/DeepSleep.ino
Normal file
@@ -0,0 +1,27 @@
|
||||
#include <esp_sleep.h>
|
||||
|
||||
#define LED_PIN 2
|
||||
|
||||
void setup() {
|
||||
pinMode(LED_PIN, OUTPUT);
|
||||
Serial.begin(115200);
|
||||
|
||||
// Włącz LED – aktywny stan
|
||||
digitalWrite(LED_PIN, HIGH);
|
||||
Serial.println("ESP32 aktywne – LED ON");
|
||||
delay(5000); // 2 sekundy "pracy"
|
||||
|
||||
// Wyłącz LED przed snem
|
||||
digitalWrite(LED_PIN, LOW);
|
||||
Serial.println("Przechodzę w deep sleep na 5 sekund...");
|
||||
|
||||
// Konfiguracja wybudzenia po 5 sekundach
|
||||
esp_sleep_enable_timer_wakeup(5 * 1000000ULL);
|
||||
|
||||
// Wejście w deep sleep (ESP restartuje się po wybudzeniu)
|
||||
esp_deep_sleep_start();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Tu nic się nie dzieje – kod nigdy tu nie wraca w deep sleep
|
||||
}
|
||||
29
ESP32/Sleep/LightSleep/LightSleep.ino
Normal file
29
ESP32/Sleep/LightSleep/LightSleep.ino
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <esp_sleep.h>
|
||||
|
||||
#define LED_PIN 2
|
||||
|
||||
void setup() {
|
||||
pinMode(LED_PIN, OUTPUT);
|
||||
Serial.begin(115200);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// LED ON (czas aktywny)
|
||||
digitalWrite(LED_PIN, HIGH);
|
||||
Serial.println("ESP32 aktywne – LED ON");
|
||||
delay(5000); // symulacja pracy przez 2 sekundy
|
||||
|
||||
// Przygotowanie do light sleep
|
||||
Serial.println("Przechodzę w light sleep na 5 sekund...");
|
||||
digitalWrite(LED_PIN, LOW); // LED OFF w czasie uśpienia
|
||||
delay(100);
|
||||
// Konfiguracja wybudzenia po czasie
|
||||
esp_sleep_enable_timer_wakeup(5 * 1000000ULL); // 5s w mikrosekundach
|
||||
|
||||
// Wejście w light sleep
|
||||
esp_light_sleep_start();
|
||||
|
||||
// Po wybudzeniu wracamy tutaj
|
||||
Serial.println("Wybudzono z light sleep!");
|
||||
}
|
||||
|
||||
105
ESP32/StadlerHomeKitUpgrade/DEV_LED.h
Normal file
105
ESP32/StadlerHomeKitUpgrade/DEV_LED.h
Normal file
@@ -0,0 +1,105 @@
|
||||
extern int RedHomeKit;
|
||||
extern int GreenHomeKit;
|
||||
extern int BlueHomeKit;
|
||||
extern int RedHomeKit;
|
||||
|
||||
extern bool turnOnFlag;
|
||||
|
||||
struct DEV_RgbLED : Service::LightBulb { // RGB LED (Command Cathode)
|
||||
|
||||
SpanCharacteristic *power; // reference to the On Characteristic
|
||||
SpanCharacteristic *H; // reference to the Hue Characteristic
|
||||
SpanCharacteristic *S; // reference to the Saturation Characteristic
|
||||
SpanCharacteristic *V; // reference to the Brightness Characteristic
|
||||
|
||||
DEV_RgbLED() : Service::LightBulb(){ // constructor() method
|
||||
|
||||
power=new Characteristic::On();
|
||||
H=new Characteristic::Hue(100); // instantiate the Hue Characteristic with an initial value of 0 out of 360
|
||||
S=new Characteristic::Saturation(100); // instantiate the Saturation Characteristic with an initial value of 0%
|
||||
V=new Characteristic::Brightness(100); // instantiate the Brightness Characteristic with an initial value of 100%
|
||||
|
||||
V->setRange(5,100,1); // sets the range of the Brightness to be from a min of 5%, to a max of 100%, in steps of 1%
|
||||
// reczne ustawianie
|
||||
power->setVal(1);
|
||||
H->setVal(360);
|
||||
S->setVal(100);
|
||||
V->setVal(100);
|
||||
RedHomeKit = 100;
|
||||
GreenHomeKit = 100;
|
||||
BlueHomeKit = 100;
|
||||
// koniec recznego ustawiania
|
||||
|
||||
char cBuf[128];
|
||||
Serial.print(cBuf);
|
||||
|
||||
} // end constructor
|
||||
|
||||
boolean update(){ // update() method
|
||||
|
||||
if (turnOnFlag == true){
|
||||
power->setVal(1);
|
||||
turnOnFlag = false;
|
||||
}
|
||||
boolean p;
|
||||
float v, h, s, r, g, b;
|
||||
|
||||
h=H->getVal<float>(); // get and store all current values. Note the use of the <float> template to properly read the values
|
||||
s=S->getVal<float>();
|
||||
v=V->getVal<float>(); // though H and S are defined as FLOAT in HAP, V (which is brightness) is defined as INT, but will be re-cast appropriately
|
||||
p=power->getVal();
|
||||
|
||||
char cBuf[128];
|
||||
LOG1(cBuf);
|
||||
|
||||
if(power->updated()){
|
||||
p=power->getNewVal();
|
||||
sprintf(cBuf,"Power=%s->%s, ",power->getVal()?"true":"false",p?"true":"false");
|
||||
} else {
|
||||
sprintf(cBuf,"Power=%s, ",p?"true":"false");
|
||||
}
|
||||
LOG1(cBuf);
|
||||
|
||||
if(H->updated()){
|
||||
h=H->getNewVal<float>();
|
||||
sprintf(cBuf,"H=%.0f->%.0f, ",H->getVal<float>(),h);
|
||||
} else {
|
||||
sprintf(cBuf,"H=%.0f, ",h);
|
||||
}
|
||||
LOG1(cBuf);
|
||||
|
||||
if(S->updated()){
|
||||
s=S->getNewVal<float>();
|
||||
sprintf(cBuf,"S=%.0f->%.0f, ",S->getVal<float>(),s);
|
||||
} else {
|
||||
sprintf(cBuf,"S=%.0f, ",s);
|
||||
}
|
||||
LOG1(cBuf);
|
||||
|
||||
if(V->updated()){
|
||||
v=V->getNewVal<float>();
|
||||
sprintf(cBuf,"V=%.0f->%.0f ",V->getVal<float>(),v);
|
||||
} else {
|
||||
sprintf(cBuf,"V=%.0f ",v);
|
||||
}
|
||||
LOG1(cBuf);
|
||||
|
||||
LedPin::HSVtoRGB(h,s/100.0,v/100.0,&r,&g,&b); // since HomeKit provides S and V in percent, scale down by 100
|
||||
|
||||
int R, G, B;
|
||||
|
||||
|
||||
R=p*r*100; // since LedPin uses percent, scale back up by 100, and multiple by status fo power (either 0 or 1)
|
||||
G=p*g*100;
|
||||
B=p*b*100;
|
||||
|
||||
RedHomeKit = R;
|
||||
GreenHomeKit = G;
|
||||
BlueHomeKit = B;
|
||||
|
||||
sprintf(cBuf,"RGB=(%d,%d,%d)\n",R,G,B);
|
||||
LOG1(cBuf);
|
||||
|
||||
return(true); // return true
|
||||
}
|
||||
};
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "DHT.h"
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
#include <BH1750.h>
|
||||
#define Version "0.3.1"
|
||||
#define Version "0.3.4"
|
||||
|
||||
|
||||
|
||||
@@ -39,9 +39,10 @@ const uint8_t ledMap[LED_COUNT] = { 3, 0, 1, 8, 2, 5, 4, 7, 6 };
|
||||
#define LED_RED_TANK 26 //GPIO25 D25
|
||||
#define NEOPIXEL 27 //GPIO04 D27
|
||||
#define IN_PHOTOTRA 12
|
||||
#define WTR_LVL 33 //GPIO04 D27
|
||||
|
||||
#define DIMM_MAX_VALUE 3 // docelowo 4, tylko na testy
|
||||
#define WTR_LVL 33 //GPIO33 D33
|
||||
// SDA D21
|
||||
// SCL D22
|
||||
#define DIMM_MAX_VALUE 4 //
|
||||
|
||||
//NEO PIXEL ARDESES:
|
||||
#define NEOPXL_MULTIPLIER 25
|
||||
@@ -67,11 +68,17 @@ BH1750 lightMeter;
|
||||
|
||||
|
||||
//MAIN VALUES VARIABLES
|
||||
// homekit
|
||||
int RedHomeKit = 0;
|
||||
int GreenHomeKit = 0;
|
||||
int BlueHomeKit = 0;
|
||||
bool turnOnFlag = true;
|
||||
|
||||
int8_t resetVal = 0;
|
||||
int8_t fanSpeedVal = 1;
|
||||
int8_t hygrostatVal = 55;
|
||||
int8_t dimmStep = 1;
|
||||
int8_t dimmVal = 1;
|
||||
int8_t dimmStep = 3;
|
||||
int8_t dimmVal ;
|
||||
int8_t waterLvlVal = 0;
|
||||
int8_t photoVal = 0;
|
||||
float temp = 0.0;
|
||||
@@ -80,7 +87,7 @@ float lux = 0.0;
|
||||
|
||||
//NEOPIXELS VARIABLES
|
||||
int8_t neoPixelSwitch = 1;
|
||||
int8_t neoPixelRed = 0;
|
||||
int8_t neoPixelRed = 10;
|
||||
int8_t neoPixelGreen = 10;
|
||||
int8_t neoPixelBlue = 10;
|
||||
|
||||
@@ -96,6 +103,11 @@ int8_t neoPixelWaterLvlR = 1;
|
||||
int8_t neoPixelWaterLvlG = 1;
|
||||
int8_t neoPixelWaterLvlB = 1;
|
||||
int8_t neoPixelTank = 1;
|
||||
uint8_t LastSpdInpt = 0;
|
||||
unsigned long spdInptTimeStamp = 0;
|
||||
int changeSpdDelay = 30000; //interwał zmiany predkości - nie mniej niż wartość milisekund
|
||||
int8_t wtrLvlOff = 0;
|
||||
int8_t nightMode = 0;
|
||||
|
||||
|
||||
|
||||
@@ -111,39 +123,50 @@ void IRAM_ATTR speedButtonFcn() {
|
||||
if (fanSpeedVal >= 3) {
|
||||
fanSpeedVal = 1;
|
||||
}
|
||||
spdInptTimeStamp = millis() - changeSpdDelay;
|
||||
}
|
||||
void IRAM_ATTR hygrostatButtonFcn() {
|
||||
hygrostatVal = hygrostatVal + 5;
|
||||
if (hygrostatVal > 65) {
|
||||
hygrostatVal = 45;
|
||||
}
|
||||
spdInptTimeStamp = millis() - changeSpdDelay;
|
||||
}
|
||||
|
||||
void setFanSpeed(uint8_t spdInpt) {
|
||||
if (spdInpt == 1) {
|
||||
delay(100);
|
||||
digitalWrite(PIN_SPEED_2, LOW);
|
||||
delay(200);
|
||||
digitalWrite(PIN_SPEED_1, HIGH);
|
||||
delay(100);
|
||||
} else if (spdInpt == 2) {
|
||||
delay(100);
|
||||
digitalWrite(PIN_SPEED_1, LOW);
|
||||
delay(200);
|
||||
digitalWrite(PIN_SPEED_2, HIGH);
|
||||
delay(100);
|
||||
} else {
|
||||
delay(100);
|
||||
digitalWrite(PIN_SPEED_1, LOW);
|
||||
delay(200);
|
||||
digitalWrite(PIN_SPEED_2, LOW);
|
||||
delay(100);
|
||||
// if (wtrLvlOff == 1) { dokomentować do testów wody
|
||||
// spdInpt = 0;
|
||||
// }
|
||||
|
||||
if (nightMode == 1 && spdInpt == 2 ){
|
||||
spdInpt = 1;
|
||||
}
|
||||
|
||||
if ( millis() > (spdInptTimeStamp + changeSpdDelay)) {
|
||||
if (LastSpdInpt != spdInpt) {
|
||||
if (spdInpt == 1) {
|
||||
digitalWrite(PIN_SPEED_2, LOW);
|
||||
digitalWrite(PIN_SPEED_1, HIGH);
|
||||
LastSpdInpt = spdInpt;
|
||||
spdInptTimeStamp = millis();
|
||||
} else if (spdInpt == 2) {
|
||||
digitalWrite(PIN_SPEED_1, LOW);
|
||||
digitalWrite(PIN_SPEED_2, HIGH);
|
||||
LastSpdInpt = spdInpt;
|
||||
spdInptTimeStamp = millis();
|
||||
} else {
|
||||
digitalWrite(PIN_SPEED_1, LOW);
|
||||
digitalWrite(PIN_SPEED_2, LOW);
|
||||
LastSpdInpt = spdInpt;
|
||||
spdInptTimeStamp = millis();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void rainbowCycle(uint8_t wait) {
|
||||
uint16_t i, j;
|
||||
for (j = 0; j < 256 * 3; j++) { // mniej cykli niż 5 — szybciej wraca
|
||||
for (j = 0; j < 256 * 3; j++) {
|
||||
for (i = 0; i < LED_COUNT; i++) {
|
||||
uint8_t physIndex = ledMap[i]; // mapowanie pozycji logicznej na fizyczną
|
||||
pixels.setPixelColor(physIndex, Wheel((i * 256 / LED_COUNT + j) & 255));
|
||||
@@ -178,6 +201,20 @@ uint32_t Wheel(byte pos) {
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
pinMode(BTN_RST, INPUT);
|
||||
pinMode(BTN_DIMM, INPUT);
|
||||
pinMode(BTN_SPEED, INPUT);
|
||||
pinMode(BTN_HYGRSTT, INPUT);
|
||||
pinMode(PIN_SPEED_1, OUTPUT);
|
||||
pinMode(PIN_SPEED_2, OUTPUT);
|
||||
digitalWrite(PIN_SPEED_1, LOW);
|
||||
digitalWrite(PIN_SPEED_2, LOW);
|
||||
pinMode(LED_RED_TANK, OUTPUT);
|
||||
pinMode(LED_WHT_TANK, OUTPUT);
|
||||
pinMode(IN_PHOTOTRA, INPUT_PULLDOWN);
|
||||
pinMode(WTR_LVL, INPUT);
|
||||
|
||||
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
|
||||
Serial.println(F("SSD1306 allocation failed"));
|
||||
}
|
||||
@@ -191,18 +228,6 @@ void setup() {
|
||||
display.println(Version);
|
||||
display.display();
|
||||
|
||||
// delay(500);
|
||||
pinMode(BTN_RST, INPUT);
|
||||
pinMode(BTN_DIMM, INPUT);
|
||||
pinMode(BTN_SPEED, INPUT);
|
||||
pinMode(BTN_HYGRSTT, INPUT);
|
||||
pinMode(PIN_SPEED_1, OUTPUT);
|
||||
pinMode(PIN_SPEED_2, OUTPUT);
|
||||
pinMode(LED_RED_TANK, OUTPUT);
|
||||
pinMode(LED_WHT_TANK, OUTPUT);
|
||||
pinMode(IN_PHOTOTRA, INPUT_PULLDOWN);
|
||||
pinMode(WTR_LVL, INPUT);
|
||||
|
||||
attachInterrupt(digitalPinToInterrupt(BTN_DIMM), dimmButtonFcn, FALLING);
|
||||
attachInterrupt(digitalPinToInterrupt(BTN_SPEED), speedButtonFcn, FALLING);
|
||||
attachInterrupt(digitalPinToInterrupt(BTN_HYGRSTT), hygrostatButtonFcn, FALLING);
|
||||
@@ -221,8 +246,7 @@ void setup() {
|
||||
} else {
|
||||
dimmVal = 24;
|
||||
}
|
||||
}
|
||||
|
||||
} //setup end
|
||||
void loop() {
|
||||
// ###################################################
|
||||
// WYŚWIETLACZ
|
||||
@@ -341,13 +365,14 @@ void loop() {
|
||||
} else if (dimmStep == 1) {
|
||||
dimmVal = 1;
|
||||
} else if (dimmStep == 2) {
|
||||
dimmVal = 6;
|
||||
dimmVal = 2;
|
||||
} else if (dimmStep == 3) {
|
||||
dimmVal = 12;
|
||||
dimmVal = 4;
|
||||
} else {
|
||||
dimmVal = 24;
|
||||
dimmVal = 8;
|
||||
}
|
||||
|
||||
// Ustawianie LED docelowych wartości
|
||||
if (hygrostatVal >= 65) {
|
||||
neoPixelLvl_1 = 1;
|
||||
neoPixelLvl_2 = 1;
|
||||
@@ -393,6 +418,23 @@ void loop() {
|
||||
neoPixelLvl_5 = 1;
|
||||
}
|
||||
|
||||
// Ustawianie LED osiągniętych wartości
|
||||
if (hum >= 65 && hygrostatVal >= 65) {
|
||||
neoPixelLvl_5 = 8;
|
||||
}
|
||||
if (hum >= 60 && hygrostatVal >= 60) {
|
||||
neoPixelLvl_4 = 8;
|
||||
}
|
||||
if (hum >= 55 && hygrostatVal >= 55) {
|
||||
neoPixelLvl_3 = 8;
|
||||
}
|
||||
if (hum >= 50 && hygrostatVal >= 50) {
|
||||
neoPixelLvl_2 = 8;
|
||||
}
|
||||
if (hum >= 45 && hygrostatVal >= 45) {
|
||||
neoPixelLvl_1 = 8;
|
||||
}
|
||||
|
||||
// wartości zależne od sposobu zasilania PC/Powerbank/Ładowarka
|
||||
|
||||
//46-47 - sonda nie dotyka wody
|
||||
@@ -407,7 +449,7 @@ void loop() {
|
||||
neoPixelWaterLvlB = 0;
|
||||
analogWrite(LED_WHT_TANK, dimmVal * 8);
|
||||
analogWrite(LED_RED_TANK, 0);
|
||||
// tu set fan
|
||||
wtrLvlOff = 1;
|
||||
}
|
||||
if (waterLvlVal < 40 && waterLvlVal >= 25) { //a bit of water TANK
|
||||
neoPixelWaterLvlR = 10;
|
||||
@@ -415,6 +457,8 @@ void loop() {
|
||||
neoPixelWaterLvlB = 0;
|
||||
analogWrite(LED_WHT_TANK, 0);
|
||||
analogWrite(LED_RED_TANK, dimmVal * 8);
|
||||
wtrLvlOff = 0;
|
||||
|
||||
}
|
||||
if (waterLvlVal <= 24) { // FULL TANK
|
||||
neoPixelWaterLvlR = neoPixelRed;
|
||||
@@ -422,7 +466,7 @@ void loop() {
|
||||
neoPixelWaterLvlB = neoPixelBlue;
|
||||
analogWrite(LED_WHT_TANK, 0);
|
||||
analogWrite(LED_RED_TANK, dimmVal * 8);
|
||||
// tu set fan
|
||||
wtrLvlOff = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -434,20 +478,27 @@ void loop() {
|
||||
neoPixelFilter = 1;
|
||||
}
|
||||
|
||||
if ( lux < 0.5 ) {
|
||||
dimmVal = 0;
|
||||
nightMode = 1;
|
||||
} else {
|
||||
nightMode = 0;
|
||||
}
|
||||
|
||||
|
||||
delay(100);
|
||||
//NEOPIXELS
|
||||
// #################################################################
|
||||
// #################################################################
|
||||
pixels.clear();
|
||||
//(G,R,B)
|
||||
pixels.setPixelColor(ADR_NEOPXL_SPEED_1, pixels.Color(int((neoPixelGreen * dimmVal * neoPixelSwitch * neoPixelSpeed_1) / NON_ACTIVE_LED_DIVIDER), int((neoPixelRed * dimmVal * neoPixelSwitch * neoPixelSpeed_1) / NON_ACTIVE_LED_DIVIDER), int((neoPixelBlue * dimmVal * neoPixelSwitch * neoPixelSpeed_1) / NON_ACTIVE_LED_DIVIDER)));
|
||||
pixels.setPixelColor(ADR_NEOPXL_SPEED_2, pixels.Color(int((neoPixelGreen * dimmVal * neoPixelSwitch * neoPixelSpeed_2) / NON_ACTIVE_LED_DIVIDER), int((neoPixelRed * dimmVal * neoPixelSwitch * neoPixelSpeed_2) / NON_ACTIVE_LED_DIVIDER), int((neoPixelBlue * dimmVal * neoPixelSwitch * neoPixelSpeed_2) / NON_ACTIVE_LED_DIVIDER)));
|
||||
pixels.setPixelColor(ADR_NEOPXL_FILTER, pixels.Color(neoPixelGreen * dimmVal * neoPixelSwitch * neoPixelFilter, neoPixelRed * dimmVal * neoPixelSwitch * neoPixelFilter, neoPixelBlue * dimmVal * neoPixelSwitch * neoPixelFilter));
|
||||
pixels.setPixelColor(ADR_NEOPXL_L1, pixels.Color(neoPixelGreen * dimmVal * neoPixelSwitch * neoPixelLvl_1, neoPixelRed * dimmVal * neoPixelSwitch * neoPixelLvl_1, neoPixelBlue * dimmVal * neoPixelSwitch * neoPixelLvl_1));
|
||||
pixels.setPixelColor(ADR_NEOPXL_L2, pixels.Color(neoPixelGreen * dimmVal * neoPixelSwitch * neoPixelLvl_2, neoPixelRed * dimmVal * neoPixelSwitch * neoPixelLvl_2, neoPixelBlue * dimmVal * neoPixelSwitch * neoPixelLvl_2));
|
||||
pixels.setPixelColor(ADR_NEOPXL_L3, pixels.Color(neoPixelGreen * dimmVal * neoPixelSwitch * neoPixelLvl_3, neoPixelRed * dimmVal * neoPixelSwitch * neoPixelLvl_3, neoPixelBlue * dimmVal * neoPixelSwitch * neoPixelLvl_3));
|
||||
pixels.setPixelColor(ADR_NEOPXL_L4, pixels.Color(neoPixelGreen * dimmVal * neoPixelSwitch * neoPixelLvl_4, neoPixelRed * dimmVal * neoPixelSwitch * neoPixelLvl_4, neoPixelBlue * dimmVal * neoPixelSwitch * neoPixelLvl_4));
|
||||
pixels.setPixelColor(ADR_NEOPXL_L5, pixels.Color(neoPixelGreen * dimmVal * neoPixelSwitch * neoPixelLvl_5, neoPixelRed * dimmVal * neoPixelSwitch * neoPixelLvl_5, neoPixelBlue * dimmVal * neoPixelSwitch * neoPixelLvl_5));
|
||||
pixels.setPixelColor(ADR_NEOPXL_L1, pixels.Color(int(neoPixelGreen * dimmVal * neoPixelSwitch * neoPixelLvl_1 / NON_ACTIVE_LED_DIVIDER), int(neoPixelRed * dimmVal * neoPixelSwitch * neoPixelLvl_1 / NON_ACTIVE_LED_DIVIDER), int(neoPixelBlue * dimmVal * neoPixelSwitch * neoPixelLvl_1 / NON_ACTIVE_LED_DIVIDER)));
|
||||
pixels.setPixelColor(ADR_NEOPXL_L2, pixels.Color(int(neoPixelGreen * dimmVal * neoPixelSwitch * neoPixelLvl_2 / NON_ACTIVE_LED_DIVIDER), int(neoPixelRed * dimmVal * neoPixelSwitch * neoPixelLvl_2 / NON_ACTIVE_LED_DIVIDER), int(neoPixelBlue * dimmVal * neoPixelSwitch * neoPixelLvl_2 / NON_ACTIVE_LED_DIVIDER)));
|
||||
pixels.setPixelColor(ADR_NEOPXL_L3, pixels.Color(int(neoPixelGreen * dimmVal * neoPixelSwitch * neoPixelLvl_3 / NON_ACTIVE_LED_DIVIDER), int(neoPixelRed * dimmVal * neoPixelSwitch * neoPixelLvl_3 / NON_ACTIVE_LED_DIVIDER), int(neoPixelBlue * dimmVal * neoPixelSwitch * neoPixelLvl_3 / NON_ACTIVE_LED_DIVIDER)));
|
||||
pixels.setPixelColor(ADR_NEOPXL_L4, pixels.Color(int(neoPixelGreen * dimmVal * neoPixelSwitch * neoPixelLvl_4 / NON_ACTIVE_LED_DIVIDER), int(neoPixelRed * dimmVal * neoPixelSwitch * neoPixelLvl_4 / NON_ACTIVE_LED_DIVIDER), int(neoPixelBlue * dimmVal * neoPixelSwitch * neoPixelLvl_4 / NON_ACTIVE_LED_DIVIDER)));
|
||||
pixels.setPixelColor(ADR_NEOPXL_L5, pixels.Color(int(neoPixelGreen * dimmVal * neoPixelSwitch * neoPixelLvl_5 / NON_ACTIVE_LED_DIVIDER), int(neoPixelRed * dimmVal * neoPixelSwitch * neoPixelLvl_5 / NON_ACTIVE_LED_DIVIDER), int(neoPixelBlue * dimmVal * neoPixelSwitch * neoPixelLvl_5 / NON_ACTIVE_LED_DIVIDER)));
|
||||
pixels.setPixelColor(ADR_NEOPXL_WATERLVL, pixels.Color(dimmVal * neoPixelSwitch * neoPixelWaterLvlG, dimmVal * neoPixelSwitch * neoPixelWaterLvlR, dimmVal * neoPixelSwitch * neoPixelWaterLvlB));
|
||||
// pixels.setPixelColor(ADR_NEOPXL_TANK, pixels.Color(neoPixelGreen*dimmVal*neoPixelSwitch*neoPixelTank, neoPixelRed*dimmVal*neoPixelSwitch*neoPixelTank, neoPixelBlue*dimmVal*neoPixelSwitch*neoPixelTank));
|
||||
pixels.show();
|
||||
|
||||
Binary file not shown.
@@ -10,10 +10,10 @@
|
||||
#include "SD.h"
|
||||
#include "SPI.h"
|
||||
|
||||
#define Version "0.5"
|
||||
#define Version "0.8"
|
||||
#define WIRE Wire
|
||||
#define DHTTYPE DHT22
|
||||
#define DHTPIN 4 //GPIO04 D4
|
||||
#define DHTPIN 2 //GPIO02 D2
|
||||
#define SD_CS 5 //GPIO05 D5
|
||||
|
||||
#define BTN_UP 33 //GPIO33 D33
|
||||
@@ -25,6 +25,8 @@
|
||||
#define DHTPIN_L 13 //GPIO36 D13
|
||||
#define DHTPIN_M 17 //GPIO36 D17
|
||||
#define DHTPIN_H 16 //GPIO36 D16
|
||||
// SDA D21
|
||||
// SCL D22
|
||||
|
||||
|
||||
|
||||
@@ -45,7 +47,7 @@ DHT dhtL(DHTPIN_L, DHT22);
|
||||
DHT dhtM(DHTPIN_M, DHT22);
|
||||
DHT dhtH(DHTPIN_H, DHT22);
|
||||
|
||||
RTC_DS3231 rtc; // Obiekt dla DS3231
|
||||
RTC_DS1307 rtc; // Obiekt dla RTC_DS1307
|
||||
int menuL0 = 10;
|
||||
int menuL1 = 10;
|
||||
int menuL2 = 10;
|
||||
@@ -103,7 +105,7 @@ float quickBatteryVoltage3 = 0;
|
||||
float quickBatteryVoltage4 = 0;
|
||||
float currentBatteryVoltage = 0;
|
||||
float lastBatteryVoltage = 0;
|
||||
int battLifeMins = 998;
|
||||
int battLifeMins = 4000;
|
||||
int estHours = 0;
|
||||
int estMins = 0;
|
||||
|
||||
@@ -142,7 +144,7 @@ float voltageToPercentage(float voltage) {
|
||||
// Reprezentatywne punkty (wolt, procent)
|
||||
const int nPoints = 9;
|
||||
// Napięcia – uporządkowane malejąco
|
||||
float vPoints[nPoints] = { 4.06, 4.00, 3.95, 3.90, 3.85, 3.80, 3.70, 3.45, 2.75 };
|
||||
float vPoints[nPoints] = { 4.180, 4.115, 4.060, 4.005, 3.951, 3.896, 3.787, 3.514, 2.750 };
|
||||
// Odpowiednie poziomy naładowania
|
||||
float pPoints[nPoints] = { 100, 95, 90, 80, 70, 60, 50, 10, 0 };
|
||||
if (voltage >= vPoints[0])
|
||||
@@ -170,30 +172,10 @@ float chargeVoltageToPercentage(float voltage) {
|
||||
// Przykładowe punkty (napięcie w V rosnąco)
|
||||
// Dopasuj je do własnych obserwacji / charakterystyki baterii
|
||||
const int nPoints = 10;
|
||||
float vPoints[nPoints] = {
|
||||
4.03, // ~0%
|
||||
4.06, // ~1%
|
||||
4.12, // ~5%
|
||||
4.14, // ~10%
|
||||
4.16, // ~30%
|
||||
4.18, // ~60%
|
||||
4.19, // ~80%
|
||||
4.20, // ~95%
|
||||
4.21, // ~98%
|
||||
4.22 // 100%
|
||||
};
|
||||
float pPoints[nPoints] = {
|
||||
0, // 4.03 V
|
||||
1, // 4.06 V
|
||||
5, // 4.12 V
|
||||
10, // 4.14 V
|
||||
30, // 4.16 V
|
||||
60, // 4.18 V
|
||||
80, // 4.19 V
|
||||
95, // 4.20 V
|
||||
98, // 4.21 V
|
||||
100 // 4.22 V
|
||||
};
|
||||
float vPoints[nPoints] = { 3.100, 3.274, 3.621, 3.737, 3.853, 3.968, 4.026, 4.084, 4.142, 4.200 };
|
||||
|
||||
float pPoints[nPoints] = { 0, 1, 5, 10, 30, 60, 80, 95, 98, 100 };
|
||||
|
||||
|
||||
// 1. Jeśli napięcie jest poniżej najniższego punktu, zwróć minimalny procent
|
||||
if (voltage <= vPoints[0]) {
|
||||
@@ -222,9 +204,7 @@ void setup() {
|
||||
analogSetAttenuation(ADC_11db);
|
||||
|
||||
if (!rtc.begin()) {
|
||||
Serial.println("Nie znaleziono DS3231 RTC!");
|
||||
while (1)
|
||||
; // Zatrzymaj program, jeśli RTC nie jest dostępny
|
||||
Serial.println("Nie znaleziono DS1307 RTC!");
|
||||
}
|
||||
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Address 0x3C for 128x32
|
||||
display.setTextSize(1);
|
||||
@@ -255,7 +235,7 @@ void setup() {
|
||||
|
||||
display.println("DHT22");
|
||||
display.setCursor(40, 16);
|
||||
display.println("RTC: DS3231");
|
||||
display.println("RTC: DS1307");
|
||||
display.setCursor(0, 24);
|
||||
display.println("Battery: ");
|
||||
display.setCursor(55, 24);
|
||||
@@ -268,9 +248,9 @@ void setup() {
|
||||
dhtL.begin();
|
||||
dhtM.begin();
|
||||
dhtH.begin();
|
||||
pinMode(BTN_UP, INPUT_PULLDOWN);
|
||||
pinMode(BTN_ENTER, INPUT_PULLDOWN);
|
||||
pinMode(BTN_DOWN, INPUT_PULLDOWN);
|
||||
pinMode(BTN_UP, INPUT);
|
||||
pinMode(BTN_ENTER, INPUT);
|
||||
pinMode(BTN_DOWN, INPUT);
|
||||
rtc.now();
|
||||
DateTime now = rtc.now();
|
||||
years = now.year();
|
||||
@@ -366,6 +346,8 @@ void setup() {
|
||||
lastHumL = 0.0;
|
||||
humL = lastHumL;
|
||||
}
|
||||
// rtc.adjust(DateTime(2025 , 8, 7, 17, 25, 0));
|
||||
|
||||
//setup END
|
||||
//######################################################################################################################################################################
|
||||
}
|
||||
@@ -648,7 +630,7 @@ void loop() {
|
||||
if (currentBatteryVoltage >= 4.20) {
|
||||
display.print("Full");
|
||||
chrgState = "FUL";
|
||||
} else if ((lastBatteryVoltage < currentBatteryVoltage && currentBatteryVoltage >= 2.0 && currentBatteryVoltage >= 4.0) || currentBatteryVoltage >= 4.10) {
|
||||
} else if ((lastBatteryVoltage < currentBatteryVoltage && currentBatteryVoltage >= 3.1)|| currentBatteryVoltage >= 4.20) {
|
||||
display.print("Charging");
|
||||
chrgState = "CHR";
|
||||
} else if (lastBatteryVoltage >= currentBatteryVoltage && currentBatteryVoltage >= 2.0) {
|
||||
@@ -824,6 +806,8 @@ void loop() {
|
||||
file.print(" V: ");
|
||||
file.println(formatNumber(currentBatteryVoltage, 2));
|
||||
file.close();
|
||||
esp_sleep_enable_timer_wakeup(85 * 1000ULL); // 5s w mikrosekundach
|
||||
esp_light_sleep_start();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -881,13 +865,16 @@ void loop() {
|
||||
file.println(formatNumber(humLCalc));
|
||||
file.close();
|
||||
delay(1000);
|
||||
esp_sleep_enable_timer_wakeup(1 * 1000000ULL); // 1s
|
||||
esp_light_sleep_start();
|
||||
}
|
||||
}
|
||||
if (sd_error == 1){
|
||||
display.drawLine(0, 0,128, 32, SSD1306_WHITE);
|
||||
}
|
||||
display.display();
|
||||
delay(150);
|
||||
esp_sleep_enable_timer_wakeup(15 * 10000ULL); // 150ms
|
||||
esp_light_sleep_start();
|
||||
yield();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user