mirror of
https://github.com/gunner47/GyverLamp.git
synced 2025-08-08 09:20:59 +03:00
WiFi подключение переработано, код переформатирован, добавлены комментарии
This commit is contained in:
@@ -1,34 +1,39 @@
|
||||
// служебные функции
|
||||
|
||||
// залить все
|
||||
void fillAll(CRGB color) {
|
||||
for (int i = 0; i < NUM_LEDS; i++) {
|
||||
void fillAll(CRGB color)
|
||||
{
|
||||
for (int32_t i = 0; i < NUM_LEDS; i++) {
|
||||
leds[i] = color;
|
||||
}
|
||||
}
|
||||
|
||||
// функция отрисовки точки по координатам X Y
|
||||
void drawPixelXY(int8_t x, int8_t y, CRGB color) {
|
||||
void drawPixelXY(int8_t x, int8_t y, CRGB color)
|
||||
{
|
||||
if (x < 0 || x > WIDTH - 1 || y < 0 || y > HEIGHT - 1) return;
|
||||
int thisPixel = getPixelNumber(x, y) * SEGMENTS;
|
||||
for (byte i = 0; i < SEGMENTS; i++) {
|
||||
int32_t thisPixel = getPixelNumber(x, y) * SEGMENTS;
|
||||
for (uint8_t i = 0; i < SEGMENTS; i++)
|
||||
{
|
||||
leds[thisPixel + i] = color;
|
||||
}
|
||||
}
|
||||
|
||||
// функция получения цвета пикселя по его номеру
|
||||
uint32_t getPixColor(int thisSegm) {
|
||||
int thisPixel = thisSegm * SEGMENTS;
|
||||
uint32_t getPixColor(uint32_t thisSegm)
|
||||
{
|
||||
uint32_t thisPixel = thisSegm * SEGMENTS;
|
||||
if (thisPixel < 0 || thisPixel > NUM_LEDS - 1) return 0;
|
||||
return (((uint32_t)leds[thisPixel].r << 16) | ((long)leds[thisPixel].g << 8 ) | (long)leds[thisPixel].b);
|
||||
return (((uint32_t)leds[thisPixel].r << 16) | ((uint32_t)leds[thisPixel].g << 8 ) | (uint32_t)leds[thisPixel].b);
|
||||
}
|
||||
|
||||
// функция получения цвета пикселя в матрице по его координатам
|
||||
uint32_t getPixColorXY(int8_t x, int8_t y) {
|
||||
uint32_t getPixColorXY(int8_t x, int8_t y)
|
||||
{
|
||||
return getPixColor(getPixelNumber(x, y));
|
||||
}
|
||||
|
||||
// **************** НАСТРОЙКА МАТРИЦЫ ****************
|
||||
// ************* НАСТРОЙКА МАТРИЦЫ *****
|
||||
#if (CONNECTION_ANGLE == 0 && STRIP_DIRECTION == 0)
|
||||
#define _WIDTH WIDTH
|
||||
#define THIS_X x
|
||||
@@ -78,10 +83,14 @@ uint32_t getPixColorXY(int8_t x, int8_t y) {
|
||||
#endif
|
||||
|
||||
// получить номер пикселя в ленте по координатам
|
||||
uint16_t getPixelNumber(int8_t x, int8_t y) {
|
||||
if ((THIS_Y % 2 == 0) || MATRIX_TYPE) { // если чётная строка
|
||||
uint16_t getPixelNumber(int8_t x, int8_t y)
|
||||
{
|
||||
if ((THIS_Y % 2 == 0) || MATRIX_TYPE) // если чётная строка
|
||||
{
|
||||
return (THIS_Y * _WIDTH + THIS_X);
|
||||
} else { // если нечётная строка
|
||||
}
|
||||
else // если нечётная строка
|
||||
{
|
||||
return (THIS_Y * _WIDTH + _WIDTH - THIS_X - 1);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user