POprawki pod siebie

This commit is contained in:
sieja
2025-07-22 21:11:43 +02:00
parent 8ebd9377b1
commit c1809f9b91
2 changed files with 9 additions and 5 deletions

View File

@@ -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
@@ -62,7 +62,9 @@ void setup() {
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::Lighting,"HomeSpan LED tst");
@@ -80,5 +82,6 @@ void setup() {
void loop(){
homeSpan.poll();
Serial.println(zmienna);
delay(500);
} // end of loop()

View File

@@ -1,4 +1,5 @@
// 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
@@ -12,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
@@ -29,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