Pridani stop metody

This commit is contained in:
Pavel Brychta 2021-07-16 11:30:25 +02:00
parent 692a25771a
commit b8e9092035
4 changed files with 21 additions and 4 deletions

View File

@ -1,4 +1,4 @@
MIT License Copyright (c) 2019,2020 xPablo.cz MIT License Copyright (c) 2019-2021 xPablo.cz
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

4
library.json Normal file
View File

@ -0,0 +1,4 @@
{
"name": "WSLed",
"version": "0.0.0+20210128092328"
}

View File

@ -55,7 +55,7 @@ void wsLED::show(void)
uint32_t mask = 1 << (BITS_PER_LED_CMD - 1); uint32_t mask = 1 << (BITS_PER_LED_CMD - 1);
for (uint32_t bit = 0; bit < BITS_PER_LED_CMD; bit++) { for (uint32_t bit = 0; bit < BITS_PER_LED_CMD; bit++) {
uint32_t bit_is_set = bits_to_send & mask; uint32_t bit_is_set = bits_to_send & mask;
led_data_buffer[bit] = bit_is_set ? (rmt_item32_t) {{{T1H, 1, TL, 0}}} : (rmt_item32_t) {{{T0H, 1, TL, 0}}}; led_data_buffer[bit] = bit_is_set ? (rmt_item32_t) {{{T1H, 1, TL, 0}}} : (rmt_item32_t) {{{T0H, 1, TL, 0}}};
mask >>= 1; mask >>= 1;
} }
ESP_ERROR_CHECK(rmt_write_items(LED_RMT_TX_CHANNEL, led_data_buffer, LED_BUFFER_ITEMS, false)); ESP_ERROR_CHECK(rmt_write_items(LED_RMT_TX_CHANNEL, led_data_buffer, LED_BUFFER_ITEMS, false));
@ -121,7 +121,7 @@ void wsLED::begin(void)
} }
} }
void wsLED::setColor(LEDRGB &color) void wsLED::setColor(LEDRGB color)
{ {
_color[(_order >> 6) & 7] = color.r; _color[(_order >> 6) & 7] = color.r;
@ -241,3 +241,15 @@ ledstate_t wsLED::getState(void)
return _ledState; return _ledState;
} }
void wsLED::stop(void)
{
if (NOT_A_PIN != _pin) {
_handler.detach();
_ledState = LED_STOP;
_scale = 0xff;
setColor(LEDRGB(0, 0, 0));
show();
}
}

View File

@ -141,7 +141,7 @@ protected:
bool canShow(void); bool canShow(void);
void show(void); void show(void);
void setColor(LEDRGB &color); void setColor(LEDRGB color);
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)
portMUX_TYPE _mux = portMUX_INITIALIZER_UNLOCKED; portMUX_TYPE _mux = portMUX_INITIALIZER_UNLOCKED;
#endif #endif
@ -159,6 +159,7 @@ public:
void setOrder(int neworder); void setOrder(int neworder);
ledstate_t getState(void); ledstate_t getState(void);
void pulse(LEDRGB color, uint32_t duration); void pulse(LEDRGB color, uint32_t duration);
void stop(void);
}; };
#endif #endif