Оптимизация использования памяти

This commit is contained in:
gunner47
2019-09-15 23:09:13 +03:00
parent 2d5a709116
commit 798aa66052
6 changed files with 54 additions and 32 deletions

View File

@@ -3,16 +3,17 @@
// залить все
void fillAll(CRGB color)
{
for (int32_t i = 0; i < NUM_LEDS; i++) {
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(uint8_t x, uint8_t y, CRGB color)
{
if (x < 0 || x > WIDTH - 1 || y < 0 || y > HEIGHT - 1) return;
int32_t thisPixel = getPixelNumber(x, y) * SEGMENTS;
uint32_t thisPixel = getPixelNumber(x, y) * SEGMENTS;
for (uint8_t i = 0; i < SEGMENTS; i++)
{
leds[thisPixel + i] = color;
@@ -28,7 +29,7 @@ uint32_t getPixColor(uint32_t thisSegm)
}
// функция получения цвета пикселя в матрице по его координатам
uint32_t getPixColorXY(int8_t x, int8_t y)
uint32_t getPixColorXY(uint8_t x, uint8_t y)
{
return getPixColor(getPixelNumber(x, y));
}
@@ -83,7 +84,7 @@ uint32_t getPixColorXY(int8_t x, int8_t y)
#endif
// получить номер пикселя в ленте по координатам
uint16_t getPixelNumber(int8_t x, int8_t y)
uint16_t getPixelNumber(uint8_t x, uint8_t y)
{
if ((THIS_Y % 2 == 0) || MATRIX_TYPE) // если чётная строка
{