From f158870f9f9c5d2221d6294dbc632d7501a726bd Mon Sep 17 00:00:00 2001 From: Oleg Kravtsov Date: Tue, 26 Mar 2024 23:48:59 +0700 Subject: [PATCH 1/5] Implement conditional compilation for optional FastLED support --- src/FastLEDsupport.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/FastLEDsupport.cpp b/src/FastLEDsupport.cpp index 21683cf..815194e 100644 --- a/src/FastLEDsupport.cpp +++ b/src/FastLEDsupport.cpp @@ -1,11 +1,15 @@ +#ifdef FASTLED_SUPPORT + #include "FastLEDsupport.h" mData CRGBtoData(CRGB col) { -#if (COLOR_DEBTH == 1) - return RGBto8(col.r, col.g, col.b); -#elif (COLOR_DEBTH == 2) - return RGBto16(col.r, col.g, col.b); -#elif (COLOR_DEBTH == 3) - return mData(col.r, col.g, col.b); + #if (COLOR_DEBTH == 1) + return RGBto8(col.r, col.g, col.b); + #elif (COLOR_DEBTH == 2) + return RGBto16(col.r, col.g, col.b); + #elif (COLOR_DEBTH == 3) + return mData(col.r, col.g, col.b); + #endif +} + #endif -} \ No newline at end of file From b54b3f71d3612d6b6d2c41525fc2d489cff09c43 Mon Sep 17 00:00:00 2001 From: Oleg Kravtsov Date: Tue, 26 Mar 2024 23:51:08 +0700 Subject: [PATCH 2/5] Implement conditional compilation for optional FastLED support --- src/FastLEDsupport.h | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/FastLEDsupport.h b/src/FastLEDsupport.h index 37dbccb..c3f3cac 100644 --- a/src/FastLEDsupport.h +++ b/src/FastLEDsupport.h @@ -1,9 +1,14 @@ -#ifndef _FastLEDsupport_h -#define _FastLEDsupport_h -// поддержка типа данных FastLED для microLED +#ifdef FASTLED_SUPPORT -#include -#include "microLED.h" + #ifndef _FastLEDsupport_h + #define _FastLEDsupport_h -mData CRGBtoData(CRGB col); -#endif \ No newline at end of file + // поддержка типа данных FastLED для microLED + #include + #include "microLED.h" + + mData CRGBtoData(CRGB col); + + #endif // _FastLEDsupport_h + +#endif // FASTLED_SUPPORT From fc69cfd4eb814c1b07fcd0dbb7a5c290bfc35a7a Mon Sep 17 00:00:00 2001 From: Oleg Kravtsov Date: Wed, 27 Mar 2024 00:16:01 +0700 Subject: [PATCH 3/5] Update README.md --- README.md | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 1992d53..7f12959 100644 --- a/README.md +++ b/README.md @@ -11,13 +11,13 @@ microLED - ультра-лёгкая библиотека для работы с - Поддержка сжатия цвета: 8, 16 и 24 бита - Возможность работать вообще без буфера (с некоторыми ограничениями) - Работа с цветом: -- RGB -- HSV -- HEX (WEB цвета) -- "Цветовое колесо" (1500 или 255 самых ярких оттенков) -- 16 встроенных цветов -- Цвет по теплоте -- Градиенты + - RGB + - HSV + - HEX (WEB цвета) + - "Цветовое колесо" (1500 или 255 самых ярких оттенков) + - 16 встроенных цветов + - Цвет по теплоте + - Градиенты - Возможность чтения сжатого цвета в mHEX 0xRRGGBB и массив RGB - Оптимизированный asm вывод - Встроенная поддержка работы с адресными матрицами @@ -26,11 +26,11 @@ microLED - ультра-лёгкая библиотека для работы с - Совместимость типов данных и инструментов из FastLED - Расширенная настройка прерываний - Нативная поддержка матриц -- Сохранение работы millis() (только для AVR) +- Сохранение работы `millis()` (только для AVR) - Поддержка SPI лент (программная и аппаратная) ### Совместимость -Только AVR, ATmega и ATtiny +Только AVR: ATmega и ATtiny ### Документация К библиотеке есть [расширенная документация](https://alexgyver.ru/microLED/) @@ -185,6 +185,11 @@ RGBto8(r,g,b) - склеить 8-бит цвет // без него будет 3 байта по умолчанию #define COLOR_DEBTH 3 +// ===== ПОДДЕРЖКА FASTLED ===== +// дефайн делается ДО ПОДКЛЮЧЕНИЯ БИБЛИОТЕКИ +// без него будет отключена по умолчанию +// #define FASTLED_SUPPORT + #include // подключаем библу // ======= ИНИЦИАЛИЗАЦИЯ ======= @@ -398,6 +403,9 @@ void loop() { - v3.6 - Добавлена настройка режима запрета прерываний на лету + +- v3.7 + - Исправлена ошибка компиляции при отсутствии библиотеки FastLED.h (если не используется поддержка типа данных FastLED) ## Баги и обратная связь From 4943a373d026d60d9ebf7e18b40a43f76a1e8847 Mon Sep 17 00:00:00 2001 From: Oleg Kravtsov Date: Wed, 27 Mar 2024 01:07:00 +0700 Subject: [PATCH 4/5] Complete overhaul of README translation, significantly reducing errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Автоматический перевод содержал неприличное количество различных ошибок - исправил --- README_EN.md | 720 ++++++++++++++++++++++++++------------------------- 1 file changed, 362 insertions(+), 358 deletions(-) diff --git a/README_EN.md b/README_EN.md index ec57408..84ad138 100644 --- a/README_EN.md +++ b/README_EN.md @@ -1,410 +1,414 @@ -This is an automatic translation, may be incorrect in some places. See sources and examples! - -# Microled -Microled - Ultra -Luga Library for working with targeted tape/matrix -- The main feature: compression of the color, the code takes many times less space in SRAM compared to analogues (Fastled, Neopixel, etc.) -- Support for color compression: 8, 16 and 24 bits -- the ability to work at all without a buffer (with some restrictions) -- Work with color: -- RGB -- HSV -- Hex (Web color) -- "Color wheel" (1500 or 255 of the brightest shades) -- 16 built -in colors -- Color according to warmth -- gradients -- the ability to read compressed color in MHEX 0XRRGGBB and RGB array -- optimized ASM conclusion -- Built -in support for working with targeted matrices -- Support of chips: 2811/2812/2813/2815/2818/WS6812/APA102 -- Built -in Tinyled to work on Attiny -- compatibility of data and tools from Fastled -- Expanded interruption setting +# microLED +MicroLED - an ultra-lightweight library for working with addressable LED strips/matrices +- The main feature: color compression, the code occupies significantly less space in SRAM compared to alternatives (FastLED, NeoPixel, etc.) +- Supports color compression: 8, 16, and 24 bits +- Possibility to work without a buffer at all (with some restrictions) +- Working with color: + - RGB + - HSV + - Hex (Web color) + - "Color wheel" (1500 or 255 of the brightest shades) + - 16 built-in colors + - Colors by temperature + - Gradients +- Ability to read compressed color in MHEX 0xRRGGBB format and RGB array +- Optimized ASM output +- Built-in support for working with addressable matrices +- Supported chips: 2811/2812/2813/2815/2818/WS6812/APA102 +- Built-in TinyLED for working on ATtiny +- Compatibility with data types and tools from FastLED +- Expanded interrupt settings - Native support for matrices -- Preservation of the work Millis () (only for AVR) -- Support for SPI ribbons (software and hardware) +- Preservation of `millis()` functionality (only for AVR) +- Support for SPI strips (software and hardware) -## compatibility -Only AVR, Atmega and Attiny +## Compatibility +Only AVR: Atmega and Attiny ### Documentation -There is [expanded documentation] to the library (https://alexgyver.ru/microled/) +There is [expanded documentation](https://alexgyver.ru/microled/) to the library ## Content -- [installation] (# Install) -- [initialization] (#init) -- [use] (#usage) -- [Example] (# Example) -- [versions] (#varsions) -- [bugs and feedback] (#fedback) +- [Installation](#install) +- [Initialization](#init) +- [Use](#usage) +- [Example](#example) +- [Versions](#versions) +- [Bugs and feedback](#feedback) ## Installation -- The library can be found by the name ** Microled ** and installed through the library manager in: - - Arduino ide - - Arduino ide v2 - - Platformio -- [download the library] (https://github.com/gyverlibs/microled/archive/refs/heads/main.zip) .Zip archive for manual installation: - - unpack and put in * C: \ Program Files (X86) \ Arduino \ Libraries * (Windows X64) - - unpack and put in * C: \ Program Files \ Arduino \ Libraries * (Windows X32) - - unpack and put in *documents/arduino/libraries/ * - - (Arduino id) Automatic installation from. Zip: * sketch/connect the library/add .Zip library ... * and specify downloaded archive -- Read more detailed instructions for installing libraries [here] (https://alexgyver.ru/arduino-first/#%D0%A3%D1%81%D1%82%D0%B0%BD%D0%BE%BE%BE%BED0%B2%D0%BA%D0%B0_%D0%B1%D0%B8%D0%B1%D0%BB%D0%B8%D0%BE%D1%82%D0%B5%D0%BA) +- The library can be found by the name MicroLED and installed through the library manager in: + - Arduino IDE + - Arduino IDE v2 + - PlatformIO +- [Download the library](https://github.com/gyverlibs/microled/archive/refs/heads/main.zip) .zip archive for manual installation: + - Unpack and put in `C:\Program Files (x86)\Arduino\Libraries` (Windows x64) + - Unpack and put in `C:\Program Files\Arduino\Libraries` (Windows x32) + - Unpack and put in `Documents\Arduino\libraries\` + - (Arduino IDE) Automatic installation from .zip: Sketch\Include Library\Add .ZIP Library... and specify the downloaded archive +- Read more detailed instructions for installing libraries [here](https://alexgyver.ru/arduino-first) ### Update - I recommend always updating the library: errors and bugs are corrected in the new versions, as well as optimization and new features are added -- through the IDE library manager: find the library how to install and click "update" -- Manually: ** remove the folder with the old version **, and then put a new one in its place.“Replacement” cannot be done: sometimes in new versions, files that remain when replacing are deleted and can lead to errors! +- Through the IDE library manager: find the library how to install and click "update" +- Manually: **remove the folder with the old version**, and then put a new one in its place. "Replacement" cannot be done: sometimes, in new versions, files that remain when replacing are deleted and can lead to errors! -## initialization -`` `CPP -Microled -- Amount - the number of LEDs in the tape.To work in the flow mode, you can specify 0, since the length of the tape is actually unlimited. -- PIN- PIN, to which the date-entry of the tape is connected (D, DIN, DI). -- Clock- PIN, to which the clock-input of the tape (C, CLK) is connected.This pin is connected only for SPI ribbons, such as APA102. - - To work with the ribbons of the WSXXXX series, you need to specify instead of Pin the parameter MLED_NO_CLOCK or minus 1, i.e.-1 -- Chip - a model of tape (LEDs), in the library supportLED_WS2811, LED_WS2812, LED_WS2813, LED_WS2815, LED_WS2818, LED_WS6812, APA102, APA102_SPI.The choice of the tape model sets the speed of the protocol (they have different ones) and the consumption current settings for restriction modes (read more about them). -- Order - the order of flowers in the tape.In the ideal world, the color order should depend on the chip model and this setting should be built into the choice of the chip, but the Chinese sell ribbons that coincide with one chip in the protocol, but have a different color order.Thus, the library supports more types of tapes than written above, but you need to guess with the choice of “clone” and the order of flowers. - - Order: Order_RGB, Order_RBG, Order_BRG, Order_BGR, Order_GRB, Order_GBR. - -Microleds strip; -Microleds strip; -Microleds strip; -Microleds strip; -Microleds strip; -Microleds strip; -Microleds strip; -Microleds strip; -`` ` +## Initialization +```cpp +microLED +- amount – the number of LEDs on the strip. To work in stream mode, you can specify 0, as the length of the strip is effectively unlimited. +- pin – the pin to which the data input of the strip is connected (D, Din, DI). +- clock – the pin to which the clock input of the strip is connected (C, CLK). This pin is only connected for SPI strips, for example, APA102. + - For working with WSxxxx series strips, you need to specify M_LED_NO_CLOCK or minus 1 instead of this pin, i.e., -1. +- chip – the model of the strip (LEDs), supported by the library are LEDWS2811, LEDWS2812, LEDWS2813, LEDWS2815, LEDWS2818, LEDWS6812, APA102, APA102SPI. The choice of the strip model sets the speed of the protocol (they vary) and settings for current consumption for limitation modes (read further on this). +- order – the order of colors on the strip. In an ideal world, the order of colors should depend on the chip model, and this setting should be built into the chip choice, but some Chinese strips, although matching one chip in protocol, may have a different color order. Thus, the library supports more types of strips than mentioned above, but you need to guess with the choice of "clone" and the order of colors. + - Orders: ORDER_RGB, ORDER_RBG, ORDER_BRG, ORDER_BGR, ORDER_GRB, ORDER_GBR. + +microLED strip; +microLED strip; +microLED strip; +microLED strip; +microLED strip; +microLED strip; +microLED strip; +microLED strip; +``` ## Usage See [documentation] (https://alexgyver.ru/microled/) -`` `CPP -// template: -// initialization of the tape: no arguments -Microled; - -// Initialization Matrix: matrix width, matrix height, matrix type, connection angle, direction (see the connection of the matrix) -Microled (Uint8_t Width, Uint8_t Height, M_type Type, M_connection Conn, M_dir Dir); - -// Tape and Matrix -VOID set (int n, mdata color);// put the color of the LED MDATA (equivalent to leds [n] = color) -Mdata Get (int num);// Get the color of the diode in mdata (equivalent to leds [n]) -Void Fill (Mdata Color);// pouring with color mdata -VOID Fill (Int FROM, Int to, MDATA Color); // Pouring MDATA color -VOID Fillgradient (Int frim, int to, mdata color1, mdata color2);// Pour a gradient of two colors -VOID FADE (int num, byte val);// Reduce brightness +```cpp +// template: +// initialize STRIP: no arguments +microLED; + +// initialize MATRIX: matrix width, matrix height, matrix type, connection angle, direction (see MATRIX CONNECTION) +microLED(uint8_t width, uint8_t height, M_type type, M_connection conn, M_dir dir); + +// strip and matrix +void set(int n, mData color); // set the color of the LED to mData (equivalent to leds[n] = color) +mData get(int num); // get the color of the LED in mData (equivalent to leds[n]) +void fill(mData color); // fill with the color mData +void fill(int from, int to, mData color); // fill with the color mData +void fillGradient(int from, int to, mData color1, mData color2); // fill with a gradient of two colors +void fade(int num, byte val); // reduce brightness // matrix -uint16_t getpixnumber (int x, int y);// Get a pixel number in the tape according to the coordinates -VOID SET (int X, int y, mdata color);// put the color of the pixel x y in mdata -mdata get (int x, int y);// get the color of the pixel in mdata -VOID FADE (Int X, Int Y, Byte Val);// Reduce brightness -VOID DRAWBITMAP8 (Int X, Int Y, COST UINT8_T *FRAME, Int Width, Intt Height);// Bitmap output (Bitmap 1mater Progmem) -VOID DRAWBITMAP16 (Int X, Int Y, COST UINT16_T *FRAME, IntHIDTH, IntHTHT);// Bitmap output (Bitmap 1mater Progmem) -VOID DRAWBITMAP32 (Int X, Int Y, COST UINT32_T *FRAME, IntHIDTH, IntHTHT);// Bitmap output (Bitmap 1mater Progmem) - -// General -VOID setmaxcurrent (int ma);// Set the maximum current (auto -correction of brightness).0 - off -VOID Setbrightness (Uint8_T Newbright);// brightness 0-255 -Void Clear ();// Cleaning -VOID setcli (Type);// Prohibition of interruptions of pli_off, cli_low, cli_aver, cli_high - -// Boofer conclusion -VOID show ();// Determine the entire buffer - -// Stream output -VOID Begin ();// Start the conclusion with a stream -VOID SEND (MDATA DATA);// Send one LED -VOID end ();// End the output with a stream +uint16_t getPixNumber(int x, int y); // get the pixel number in the strip by coordinates +void set(int x, int y, mData color); // set the color of pixel x y in mData +mData get(int x, int y); // get the color of the pixel in mData +void fade(int x, int y, byte val); // reduce brightness +void drawBitmap8(int X, int Y, const uint8_t *frame, int width, int height); // output bitmap (1-dimensional bitmap PROGMEM) +void drawBitmap16(int X, int Y, const uint16_t *frame, int width, int height); // output bitmap (1-dimensional bitmap PROGMEM) +void drawBitmap32(int X, int Y, const uint32_t *frame, int width, int height); // output bitmap (1-dimensional bitmap PROGMEM) + +// general +void setMaxCurrent(int ma); // set the maximum current (auto brightness correction). 0 - turned off +void setBrightness(uint8_t newBright); // brightness 0-255 +void clear(); // clear +void setCLI(type); // interrupt disable mode CLI_OFF, CLI_LOW, CLI_AVER, CLI_HIGH + +// output buffer +void show(); // output the entire buffer + +// stream output +void begin(); // start outputting in stream +void send(mData data); // send a single LED +void end(); // end outputting in stream // color -uint32_t gethex (mdata data);// reproduce in 24 bits hex -Mdata Getfade (Mdata Data, Uint8_t Val);// Reduce brightness by val -MDATA Getblend (Int X, Intsount, MDATA C0, MDATA C1);// get an interim color -mdata mrgb (uint8_t r, uint8_t g, uint8_t b);// RGB 255, 255, 255 -Mdata mwheel (int color, uint8_t bright = 255);// Colors 0-1530 + brightness -mdata mwheel8 (Uint8_t Color, Uint8_t Bright = 255);// Colors 0-255 + brightness -mdata mhex (uint32_t color);// mhex color -mdata mhsv (uint8_t h, uint8_t s, uint8_t v);// hsv 255, 255, 255 -Mdata mhsvfast (uint8_th, uint8_t s, uint8_t v);// hsv 255, 255, 255 -Mdata Mkelvin (Int Kelvin);// temperature - -// Macros of brightness reduction -fade8 (x, b) -Fade8r (x, b) -Fade8g (x, b) -Fade8b (x, b) - -// packaging-packing -Getr (x) -Getg (x) -Getb (x) -Mergergb (r, g, b) -Mergergbraw (r, g, b) -Getcrt (byte X) - get the adjusted value of brightness X taking into account the selected CRT model of gamma correction -Getcrt_pgm (Byte X) - get CRT from the progress (it only works if the PGM model is selected) -Getcrt_SQUARE (Byte X) - Get CRT by square model -Getcrt_Qubic (Byte X) - Get CRT by cubic model -RGB24TO16 (X)-Convertation 24-bit color in 16-bit -RGB24TO8 (x)-Convertation 24-bit colors in 8-bit -RGB16TO24 (X)-Convertation 16-bit color in 24-bit -RGB8TO24 (x)-8-bit color conversion in 24-bit -RGB24TOR (x) - pull out byt R of 24 -bit color -RGB24TOG (x) - pull out byt G of 24 -bit color -RGB24TOB (x) - pull out byte B of 24 -bit color -Rgbto24 (r, g, b) - glue 24 -bit color -Rgbto16 (r, g, b) - glue 16 -bit color -Rgbto8 (r, g, b) - glue 8 -bit color -`` ` - - +uint32_t getHEX(mData data); // repackage into 24-bit HEX +mData getFade(mData data, uint8_t val); // decrease brightness by val +mData getBlend(int x, int amount, mData c0, mData c1); // get intermediate color +mData mRGB(uint8_t r, uint8_t g, uint8_t b); // RGB 255, 255, 255 +mData mWheel(int color, uint8_t bright=255); // colors 0-1530 + brightness +mData mWheel8(uint8_t color, uint8_t bright=255); // colors 0-255 + brightness +mData mHEX(uint32_t color); // mHEX color +mData mHSV(uint8_t h, uint8_t s, uint8_t v); // HSV 255, 255, 255 +mData mHSVfast(uint8_t h, uint8_t s, uint8_t v); // HSV 255, 255, 255 +mData mKelvin(int kelvin); // temperature + +// brightness reduction macros +fade8(x, b) +fade8R(x, b) +fade8G(x, b) +fade8B(x, b) + +// packing-unpacking +getR(x) +getG(x) +getB(x) +mergeRGB(r,g,b) +mergeRGBraw(r,g,b) +getCRT(byte x) - get corrected brightness value x considering selected CRT gamma correction model +getCRT_PGM(byte x) - get CRT from PROGMEM (works only if PGM model is selected) +getCRT_SQUARE(byte x) - get CRT by square model +getCRT_QUBIC(byte x) - get CRT by cubic model +RGB24to16(x) - convert 24-bit color to 16-bit +RGB24to8(x) - convert 24-bit color to 8-bit +RGB16to24(x) - convert 16-bit color to 24-bit +RGB8to24(x) - convert 8-bit color to 24-bit +RGB24toR(x) - extract the R byte from 24-bit color +RGB24toG(x) - extract the G byte from 24-bit color +RGB24toB(x) - extract the B byte from 24-bit color +RGBto24(r,g,b) - merge into 24-bit color +RGBto16(r,g,b) - merge into 16-bit color +RGBto8(r,g,b) - merge into 8-bit color +``` + + ## Example The rest of the examples look at ** Examples **! -`` `CPP -// Basic example of working with the tape, basic possibilities -// Library Microled version 3.0+ -// For more information, read the documentation - -// Constants for convenience -#define strip_pin 2 // Pin tape -#define numleds 20 // Sum of LEDs - -// ===== Color depth ======== -// 1, 2, 3 (byte for color) -// on a smaller color resolution, the sketch will occupy many times less space, -// But the number of shades and brightness levels will decrease! -// Define is made before connecting the library -// Without it there will be 3 bytes by default -#define color_debth 3 - -#include // Connect the bibla - -// ====== Entialization ============ -// -// microleds strip; -// Clock Pin is needed only for SPI tapes (for example, APA102) -// For ordinary WS tapes, indicate mled_no_clock -// by APA102 see a separate guide in the examples - -// Various Chinese fakes can have compatibility -// with one chip, but another order of flowers! -// Supported tapes and their official color order: -// Microleds strip; -// Microleds strip; -// microleds Strip; -// Microleds strip; -// Microleds strip; -// Microleds strip; -// microleds strip; -// Microleds strip;// for hardware SPI - - -// ======= Interruption ============ -// To increase the reliability of data transfer to the tape, you can turn off the interruption. +```cpp +// basic example of working with a strip, main features +// microLED library version 3.0+ +// for more detailed information, read the documentation + +// constants for convenience +#define STRIP_PIN 2 // strip pin +#define NUMLEDS 20 // number of LEDs + +// ===== COLOR DEPTH ===== +// 1, 2, 3 (bytes per color) +// At lower color resolution, the sketch will take up significantly less space, +// but the number of shades and brightness levels will decrease! +// The define is made BEFORE THE LIBRARY IS INCLUDED +// Without it, 3 bytes will be the default +#define COLOR_DEBTH 3 + +// ===== FASTLED SUPPORT ===== +// The define is made BEFORE THE LIBRARY IS INCLUDED +// Without it, it will be turned off by default +// #define FASTLED_SUPPORT + +#include // include the library + +// ======= INITIALIZATION ======= +// +// microLED strip; +// CLOCK pin is only needed for SPI strips (like APA102) +// for regular WS strips specify MLED_NO_CLOCK +// see a separate guide in the examples for APA102 + +// various Chinese knockoffs may be compatible +// with one chip, but have a different color order! +// Supported strip chips and their official color order: +// microLED strip; +// microLED strip; +// microLED strip; +// microLED strip; +// microLED strip; +// microLED strip; +// microLED strip; +// microLED strip; // for hardware SPI + + +// ======= INTERRUPTS ======= +// to increase the reliability of data transfer to the strip, interrupts can be disabled. // The library has 4 modes: -// cli_Off - interruptions are not disconnected (tape failures are possible) -// cli_low - interruptions are disconnected during the transmission of one color -// cli_aver - interruptions are disconnected during the transfer of one LED (3 colors) -// cli_high - interruptions are disconnected during the transfer of the given to the entire tape - -// by default, the disabling of interruptions stands on Cli_off (do not turn off) -// The parameter is transmitted to the 5th during initialization: -// Microleds strip; - -// ======= Save millis ============= -// when disconnecting interruptions in medium and high proportion mode (Cli_aver and Cli_high) -// Inevitably, the functions of the time millis () and micros () will be slightly lagging behind -// The library is built into the maintenance of the functions of the time, for activation, we transfer Save_Millis -// 6th argument in initialization: -// Microleds strip; -// This will slowly slow down on the tape, but will allow Millis to count without a lag! - -// I initialize the tape (it was aboveHyde!) -Microleds strip; - -VOID setup () { - // ===================== Basic things ============================================ +// CLI_OFF - interrupts are not disabled (possible strip malfunctions) +// CLI_LOW - interrupts are disabled for the duration of one color transmission +// CLI_AVER - interrupts are disabled for the duration of one LED transmission (3 colors) +// CLI_HIGH - interrupts are disabled for the duration of data transmission to the entire strip + +// By default, interrupt disabling is set to CLI_OFF (not disabled) +// The parameter is passed as the 5th during initialization: +// microLED strip; + +// ======= SAVE THE MILLIS ======= +// When disabling interrupts in mid and high priority mode (CLI_AVER and CLI_HIGH), +// the time functions millis() and micros() will inevitably lag slightly. +// The library includes support functions for time, to activate pass SAVE_MILLIS +// as the 6th argument during initialization: +// microLED strip; +// this will SLOWLY slow down the output to the strip but will allow millis to count without lag! + +// initializing the strip (guide above!) +microLED strip; + +void setup() { + // ===================== BASIC STUFF ===================== // brightness (0-255) - strip.setbrightness (60); - // brightness is used in CRT gamut - // applies in the withdrawal of .show ()! - - // Cleaning the buffer (turn off the diodes, black) - strip.clear (); - // applies in the withdrawal of .show ()! - - strip.show ();// Conclusion of changes to the tape - DELAY (1);// Between the show challenges there should be a pause of at least 40 μs !!!! - - // ====ward - // The library supports two options for working with the tape: - // Changing the color of a particular diode using the SET function (diode, color) - // or work with the .LEDS [] "Manual" array - - // recording Strip.set (diode, color);equivalent to strip.leds [diode] = color; - - // ------------ The main functions of working with color ----------- - // The following functions of the BRZENT are the type of data MDATA - compressed color view - - // mrgb (uint8_t r, uint8_t g, uint8_t b);// Color RGB, 0-255 Each channel - strip.set (0, mrgb (255, 0, 0));// diode 0, color RGB (255 0 0) (red) - - // mhsv (uint8_t h, uint8_t s, uint8_t v);// color hsv, 0-255 each channel - strip.leds [1] = mhsv (30, 255, 255);// diode 1, (color 30, brightness and saturation maximum) - - // mhsvfast (uint8_t h, uint8_t s, uint8_t v);// color hsv, 0-255 each channel - // The calculation is performed a little faster, but the colors are not so smooth - Strip.set (2, mhsvfast (90, 255, 255));// diode 2, color 90, brightness and saturation maximum - - // mhex (uint32_t color);// Web Colors (0xrrggb) - strip.set (3, mhex (0x30b210));// diode 3, color hex 0x30b210 - - // The library has 17 pre -installed colors (max. Brightness) - strip.leds [4] = maqua;// diode 4, color aqua - - // mwheel (int color);// Rainbow colors 0-1530 - // mwheel (int color, uint8_t bright);// rainbow colors 0-1530 + brightness 0-255 - strip.set (5, mwheel (1200));// diode 5, color 1200 - - // mwheel8 (int color);// Rainbow colors 0-255 - // mwheel8 (int color, uint8_t Bright);// rainbow colors 0-255 + brightness 0-255 - //strip.set(6, mwheel8 (100));// diode 6, color 100 (range 0-255 along the rainbow) - strip.set (6, mwheel8 (100, 50));// The second parameter can be conveyed brightness - - // mkelvin (int Kelvin);// Color temperature 1'000-40'000 Kelvin - strip.set (7, mkelvin (3500));// diode 7, color temperature 3500k - - strip.show ();// We display all changes to the tape - DELAY (2000);// delay in the show - - // =========================================ward - // there is a ready -made function for filling the entire tape with color - .Fill () - // accepts the converted color, for example, from color functions or constants above - strip.fill (Myillow);// Pour yellow - strip.show ();// We display changes - DELAY (2000); - - // You can also specify the beginning and end of the filling - strip.fill (3, 7, mwheel8 (100));// Pour ~ green from 3 to 6: the account goes from 0, poured to the specified -1 - strip.show ();// We display changes - DELAY (2000); - - // ------------- Manual filling in the cycle ----------- - // For example, paint half the tape into one, half in the other - for (int i = 0; i -## versions -- V1.1 - - The initialization is corrected - - added orange color +## Versions +- v1.1 + - Fixed initialization + - Added orange color -- V2.0 - - rewritten and greatly accelerated the output algorithm - - Added current restriction +- v2.0 + - Rewritten and significantly optimized output algorithm + - Added current limit -- V2.1 - - corrected error with the matrix +- v2.1 + - Fixed a matrix error -- V2.2 - - Pink color is replaced by Magenta +- v2.2 + - Color PINK replaced with MAGENTA -- V2.3 - - Added define setting Microled_allow_interrupts - - Fixed small errors, improved stability +- v2.3 + - Added define setting MICROLEDALLOWINTERRUPTS + - Fixed minor bugs, improved stability -- V2.4 - - Added Order_BGR +- v2.4 + - Added ORDERBGR -- V2.5 - - CRT Gamma brightness +- v2.5 + - Brightness by CRT gamma -- V3.0 +- v3.0 - Added functions and colors: - - color temperature .Setkelvin () and Kelvin date - - Getblend (position, total color1, color2) and getblend2 (position, all, color1, color2) - - .Fill (from, to) - - .Fillgradient (from, to, color1, color2) - - added the noise of Perlin (pulled out of Fastled) + - Color temperature .setKelvin() and data Kelvin + - getBlend(position, total, color1, color2) and getBlend2(position, total, color1, color2) + - .fill(from, to) + - .fillGradient(from, to, color1, color2) + - Added Perlin noise (extracted from FastLED) - Added gradients - - the conclusion is completely redone and optimized - - the ability to work at all without a buffer - - Setting up current restrictions for all types of tapes - - Networking ban on interruptions - - Preservation of the work of Millis for the duration of sending - - Support for tapes 2811, 2812, 2813, 2815, 2818 - - Support for 4 color tapes: WS6812 - - Initialization was converted to the template, see examples! - - Many changes in the names, everything is redone and simplified, read the documentation! + - Completely remade and optimized output + - Ability to work without any buffer + - Current limit setting for all types of strips + - Configurable interrupt disable + - Maintaining millis() operation during sending + - Support for strips 2811, 2812, 2813, 2815, 2818 + - Support for 4-color strips: WS6812 + - Initialization remade into a template, see examples! + - Many changes in names, everything is redone and simplified, read the documentation! -- V3.1 - - Correction errors for non -standard nuclei Arduino and Attini are adjusted - - added Tinyled.h class for output with a stream from Attiny and in general any avr (see example) - - Fastled tools are cut out (random, noise), we will work directly from the fastric - - Added support for joint work with the Fastled library and converting from its types! - - Added support for the APA102 tape (as well as other SPIs), software and hardware SPI +- v3.1 + - Fixed compilation errors for non-standard Arduino and Attiny cores + - Added tinyLED.h class for streaming output with ATtiny and any AVR (see example) + - Cut out FastLED tools (random, noise), will work directly with FastLED + - Added support for joint work with the FastLED library and conversion from its types! + - Added support for APA102 strip (and other SPI strips), software and hardware SPI -- V3.2 - - slightly optimization and corrections +- v3.2 + - Some optimizations and fixes -- V3.3 - - Fixed a critical bug with influence on other pins +- v3.3 + - Fixed a critical bug affecting other pins -- V3.4 - - ASM recycled, less weighs, adapts easier to other frequencies / timings - - Added Support LGT8F328P with a frequency of 32/16/8 MHZ - - redesigned Polling Millis ()/Micros () - direct call call to interrupt Timer0_OVF, removed the extra code +- v3.4 + - Reworked ASM output, lighter, easier to adapt to other frequencies / timings + - Added support for LGT8F328P with frequencies 32/16/8 MHz + - Redone polling of millis()/micros() - direct call to TIMER0OVF interrupt, removed redundant code -- V3.5 - - Fixed compilation error in some cases +- v3.5 + - Fixed a compilation error in some cases -- V3.6 - - Added adjustment of the interruption ban regime on the fly +- v3.6 + - Added setting for configuring interrupt disable mode on the fly + +- v3.7 + - Fixed a compilation error when the FastLED.h library is missing (if FastLED data type support is not used) -## bugs and feedback -Create ** Issue ** when you find the bugs, and better immediately write to the mail [alex@alexgyver.ru] (mailto: alex@alexgyver.ru) -The library is open for refinement and your ** pull Request ** 'ow! - +## Bugs and Feedback +Please create an **issue** if you find any bugs, and it's even better to directly email alex@alexgyver.ru. The library is open for improvements and your **pull requests** are welcome! -When reporting about bugs or incorrect work of the library, it is necessary to indicate: +When reporting bugs or malfunctions of the library, it is necessary to specify: - The version of the library -- What is MK used +- The microcontroller (MCU) used - SDK version (for ESP) -- version of Arduino ide -- whether the built -in examples work correctly, in which the functions and designs are used, leading to a bug in your code -- what code has been loaded, what work was expected from it and how it works in reality -- Ideally, attach the minimum code in which the bug is observed.Not a canvas of a thousand lines, but a minimum code \ No newline at end of file +- Arduino IDE version +- Whether the built-in examples work correctly, especially those utilizing the functions and structures that lead to the bug in your code +- The code that was uploaded, what you expected it to do, and how it actually behaves +- Ideally, attach the minimum code that reproduces the bug. Not a thousand lines of code, but the minimal code necessary to observe the bug. From e0c3b38056c140b208ef4661e9ce53146e9b1926 Mon Sep 17 00:00:00 2001 From: Oleg Kravtsov Date: Wed, 27 Mar 2024 01:07:52 +0700 Subject: [PATCH 5/5] Upd: v3.7 --- library.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library.properties b/library.properties index 28c8b6f..b90e0bd 100644 --- a/library.properties +++ b/library.properties @@ -1,9 +1,9 @@ name=microLED -version=3.6 +version=3.7 author=AlexGyver maintainer=AlexGyver sentence=Light library for addressable LEDs paragraph=Light library for addressable LEDs category=Device Control url=https://github.com/GyverLibs/microLED -architectures=avr \ No newline at end of file +architectures=avr