Snaha o vylepseni obsluhy - nutno overit!
This commit is contained in:
parent
b8e9092035
commit
707d6a3375
@ -20,6 +20,8 @@
|
||||
// moved into a C file so the attribute will be applied correctly
|
||||
extern "C" void ICACHE_RAM_ATTR send_pixels_800(uint8_t* pixel, size_t count, uint8_t pin);
|
||||
#endif
|
||||
// TODO: Proverit ESP32 s https://github.com/adafruit/Adafruit_NeoPixel/blob/master/esp.c
|
||||
// ... a s https://github.com/Freenove/Freenove_WS2812_Lib_for_ESP32
|
||||
|
||||
#define countof(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
||||
@ -69,20 +71,12 @@ led_data_buffer[bit] = bit_is_set ? (rmt_item32_t) {{{T1H, 1, TL, 0}}} : (rmt_it
|
||||
}
|
||||
|
||||
|
||||
wsLED::wsLED(int pin, int order)
|
||||
wsLED::wsLED(int pin, int order) : _pin(pin), _order(order), _ledState(LED_STOP)
|
||||
{
|
||||
|
||||
_pin = pin;
|
||||
_order = order;
|
||||
_ledState = LED_STOP;
|
||||
}
|
||||
|
||||
wsLED::wsLED(void)
|
||||
wsLED::wsLED(void) : _pin(NOT_A_PIN), _order(RGB), _ledState(LED_STOP)
|
||||
{
|
||||
|
||||
_pin = NOT_A_PIN;
|
||||
_order = RGB;
|
||||
_ledState = LED_STOP;
|
||||
}
|
||||
|
||||
void wsLED::begin(int pin)
|
||||
@ -146,25 +140,30 @@ void ICACHE_RAM_ATTR wsLED::rtLed(void)
|
||||
|
||||
|
||||
case LED_BREATH: {
|
||||
_handler.detach();
|
||||
++_subState;
|
||||
_subState %= countof(LB);
|
||||
uint16_t val = pgm_read_word(&LB[_subState]);
|
||||
_scale = (uint8_t)val;
|
||||
show();
|
||||
val >>= 8;
|
||||
_handler.attach_ms(30ul * val, lh, this);
|
||||
_lastTiming = 30ul * val;
|
||||
_handler.attach_ms(_lastTiming, lh, this);
|
||||
break;
|
||||
}
|
||||
|
||||
case LED_PULSE: {
|
||||
_handler.detach();
|
||||
_ledState = _savedState;
|
||||
_handler.attach_ms(300, lh, this); // vratime zpet puvodni casovani
|
||||
setColor(_color1);
|
||||
show();
|
||||
_handler.attach_ms(_lastTiming, lh, this); // vratime zpet puvodni casovani
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
_handler.attach_ms(300, lh, this); // jen pomale casovani
|
||||
_handler.detach();
|
||||
// _handler.attach_ms(300, lh, this); // jen pomale casovani
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -195,7 +194,8 @@ void wsLED::blink(int speed)
|
||||
_ledState = LED_BLINK;
|
||||
_scale = 0xff;
|
||||
_subState = 1;
|
||||
_handler.attach_ms(300, lh, this);
|
||||
_lastTiming = 300;
|
||||
_handler.attach_ms(_lastTiming, lh, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -209,7 +209,8 @@ void wsLED::breath(void)
|
||||
_ledState = LED_BREATH;
|
||||
_subState = 0;
|
||||
setColor(_color1);
|
||||
_handler.attach_ms(1, lh, this);
|
||||
_lastTiming = 1;
|
||||
_handler.attach_ms(_lastTiming, lh, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -135,6 +135,7 @@ protected:
|
||||
ledstate_t _ledState; // stav LEDky (blika, dycha, ...)
|
||||
ledstate_t _savedState; // stav pro navrat
|
||||
int _subState; // pomocny stav/index v poli dychani
|
||||
uint32_t _lastTiming; // posledni nastaveny cas
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
int _rmtChannel;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user