Próba uruchamiania z włączonymi LEDami

This commit is contained in:
sieja
2025-07-22 20:54:20 +02:00
parent 27fcfa4b84
commit 8ebd9377b1
2 changed files with 20 additions and 3 deletions

View File

@@ -1,7 +1,9 @@
extern int RedHomeKit;
extern int GreenHomeKit;
extern int BlueHomeKit;
extern int RedHomeKit;
extern bool turnOnFlag;
struct DEV_RgbLED : Service::LightBulb { // RGB LED (Command Cathode)
@@ -16,7 +18,17 @@ struct DEV_RgbLED : Service::LightBulb { // RGB LED (Command Cathode)
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);
@@ -25,6 +37,10 @@ struct DEV_RgbLED : Service::LightBulb { // RGB LED (Command Cathode)
boolean update(){ // update() method
if (turnOnFlag == true){
power->setVal(1);
turnOnFlag = false;
}
boolean p;
float v, h, s, r, g, b;
@@ -72,9 +88,6 @@ struct DEV_RgbLED : Service::LightBulb { // RGB LED (Command Cathode)
int R, G, B;
// if (trurOnFlag == 1){
// p = 1;
// }
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;

View File

@@ -74,6 +74,7 @@ BH1750 lightMeter;
int RedHomeKit = 0;
int GreenHomeKit = 0;
int BlueHomeKit = 0;
bool turnOnFlag = true;
int8_t resetVal = 0;
int8_t fanSpeedVal = 1;
@@ -503,6 +504,9 @@ void loop() {
Serial.println(GreenHomeKit);
Serial.print("B: ");
Serial.println(BlueHomeKit);
Serial.print("turnOnFlag: ");
Serial.println(turnOnFlag);
delay(500);