{"id":23802357,"url":"https://github.com/technosf/espxrgb","last_synced_at":"2025-09-06T15:32:49.802Z","repository":{"id":46982245,"uuid":"168030089","full_name":"technosf/ESPxRGB","owner":"technosf","description":"ESPxRGB is an Arduino/ESP-IDF library of RGB, RGBW, HSV conversion functions and Gamma Correction written in Xtensa assembler for ESP SoCs with Xtensa cores (ESP32).","archived":false,"fork":false,"pushed_at":"2021-09-19T06:53:26.000Z","size":47,"stargazers_count":28,"open_issues_count":0,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-07T05:51:09.560Z","etag":null,"topics":["arduino-library","assembler","esp-idf","esp32","gamma-correction","hsv2rgb","rgb","rgbw","xtensa","xtensa-lx6"],"latest_commit_sha":null,"homepage":"","language":"Assembly","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/technosf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-28T20:16:14.000Z","updated_at":"2025-03-21T20:13:47.000Z","dependencies_parsed_at":"2022-09-06T00:21:49.853Z","dependency_job_id":null,"html_url":"https://github.com/technosf/ESPxRGB","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/technosf/ESPxRGB","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technosf%2FESPxRGB","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technosf%2FESPxRGB/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technosf%2FESPxRGB/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technosf%2FESPxRGB/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/technosf","download_url":"https://codeload.github.com/technosf/ESPxRGB/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technosf%2FESPxRGB/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273925625,"owners_count":25192311,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-06T02:00:13.247Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino-library","assembler","esp-idf","esp32","gamma-correction","hsv2rgb","rgb","rgbw","xtensa","xtensa-lx6"],"created_at":"2025-01-01T22:21:04.257Z","updated_at":"2025-09-06T15:32:49.424Z","avatar_url":"https://github.com/technosf.png","language":"Assembly","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ESPxRGB \n\n**ESPxRGB** is an Arduino library of RGB, RGBW, HSV conversion functions and Gamma Correction written in **Xtensa** assembler for ESP SoCs that use Xtensa cores (_ESP32_).\n\n## Table of Contents \n\n- [Why an assembler RGB manipulation library](#why-an-assembler-rgb-manipulation-library)\n- [Features](#features)\n- [Performance](#performance)\n- [Options and Use](#options-and-use)\n- [Versions](#versions)\n- [History and References](#history_and_references)\n- [License](#license)\n\n## Why an assembler RGB manipulation library \n\nLooking to use small, low-powered SoCs to drive long strings of LEDs with the optimum speed and power efficiency places a premium on efficient algorythms and code, and Assembler is as efficient as you can get. The ESP SoCs are great given their feature set, conectivity, power and price. Plus, they are easy to program with a nice instruction set. \n\nThe assembler itself is contained in GNU-format assembler **.S** files, and is not _inline assembler_. The **.S** files are compiled along with the **ESPxRGB.h** header when pulled into a project.\n\n## Features \n\nESPxRGB currently works in the 8-bit RGB/W space only. It covers functions supporting:\n* RGB to RGBW\n* HSV to RGB and RGBW, with a choice of four HSV algorythms\n* RGB gamma correction (for normalizing the perception of pulsing luminance)\n* RGB chroma correction (for normalizing the perception of luminance across the spectrum)\n\nplus intersections of some of the above.\n\nExternal **C** headers provide regular Arduino and ESP-IDF code access to the functions.\n\n## Performance\n\nFrom the HSV Benchmark example\n```\nBenching HSV Conversions for 6291456 iterations\n\nImpl\t\t\tTime ms\t\tCalls per Second\nFastHSV        \t\t 2232.91\t  894121\nKKs Spectrum   \t\t 2123.05\t  940389\nESPxRGB Spectrum\t 1972.31\t 1012261\nESPxRGB Efficient\t 1987.78\t 1004383\nESPxRGB Wave   \t\t 2188.28\t  912356\nESPxRGB Tweak  \t\t 2040.31\t  978521\n```\n\nTaking KasperKampemans C impementation of HSV as the baseline:\n\nHSV Implementation | CpS | Additional CpS | Gain % | Gain @ 50 FPS and 60 LEDs per Meter\n-------------------|-----|----------------|--------|------------------------------------\nFastHSV | 894,121 | -46,268 | -4.9% | -15 Meters\nKKs Spectrum | 940,389 | 0 |0% | 0 Meters\nESPxRGB Spectrum| 1,012,261 | 71,872 | 7.6% | +23 Meters\nESPxRGB Efficient| 1,004,383 | 63,994 | 6.8% | +21 Meters\nESPxRGB Wave | 912,356 | -28,033 | -3% | -9 Meters\nESPxRGB Tweak | 978,521 | 38,132 | 4.0% | +12 Meters\n\n## Options and Use\n\nDrop the library into your *~Arduino/libraries* folder and include the *ESPxRGB.h* header in your project.\nThe library is compiled based on flags in the *src/options.h* file:\nThe functions are grouped and can be included/excluded in the compiled code as dictated by pre-processor definitions.\n\nThe *examples* folder contains *sketches* than can test the functions and generate look-up tables used by the code.\n\n### Functions\n\n#### Conversion\n\n* *xgamma8* - Normalizes the value of a single 8-bit color value \n* *xgammaarray8*  -  Normalizes a range of 8-bit color values \n* *xrgbgamma8* -  Normalizes a set of 8-bit RGB values \n* *xrgbwgamma8*  - Normalizes a set of 8-bit RGBW values \n\n#### Conversion\n\n* *xrgb2rgbw8* - RGB to RGBW\n* *xhsv2rgb8s* - HSV to RGB using the Spectrum algorythm\n* *xhsv2rgb8e* -  HSV to RGB using a power efficient function\n* *xhsv2rgb8t* - HSV to RGB using a tweaked function aproximating FastLED Rainbow HSV \n* *xhsv2rgb8w* -  HSV to RGB using a (sine) wave function\n* *xhsv2rgb8* -  HSV to RGB default function that points to an above function of your choice.\n\n#### Combined \n\n* *xhsv2rgbgamma8* -  HSV to RGB with gamma correction\n* *xhsv2rgbwgamma8* - HSV to RGB with gamma correction\n* *xrgb2rgbwgamma8* -  RGB to RGBW with gamma correction\n\n\n##  Versions\n\n* _1.0.0_\tInitial release\n* _0.1.0_\tInitial commit and pre-release\n\n\n## History and References\n\nI came to write this library after looking into options to do HSV-to-RGB conversion. Initially I looked at [FastLED](http://github.com/FastLED/FastLED) but determined it too broad a library for my use, and it dictated that FastLED be at the center of whatever you were doing which was not what I wanted.\n\nNext I came to use [fast_hsv2rgb from Vagrearg](http://www.vagrearg.org/content/hsvrgb): Lots of interesting math and theory on _spectrum_ HSV, with **C** implementations, and also **AVR**, which got me thinking of why not an **Xtensa** version. I tried copying the logic of the _AVR_ in _fast_hsv2rgb_, and then the _C_ logic, both of which use opaque iterative pointer-swapping, but I decided to use a _jump table_, and then to move to simplify the whole thing.\n\nAnd the simplest HSV to RGB code out there, I found, is [Kasper Kamperman's](http://www.kasperkamperman.com/blog/arduino/arduino-programming-hsb-to-rgb/), with a simple flow through and _case_ at the end. Looking at it, I found I could simplify it a little more by pulling common calculation up out of the _case_; I then implemented that in _Xtensa_. Kasper also addressed _dimming_ for luminance normalization.\n\nReading up on HSV again on [Instructables](http://www.instructables.com/id/How-to-Make-Proper-Rainbow-and-Random-Colors-With-/), [Ontaelio](http://www.instructables.com/member/Ontaelio/) also spoke to power efficiency through using wave forms and in to how they effected percieved color. I added both power-efficient (saw-tooth) and smoother looking (sine) wave implementation leveraging the _spectrum_ HSV code.\n\nYet the discussion of more natural looking HSV color-wheels led me to look back at [FastLED HSV to RGB](http://github.com/FastLED/FastLED/wiki/FastLED-HSV-Colors) and at their _Rainbow_ HSV. Not being able to quickly grok the code, [looking at the rainbow waveform image](http://raw.github.com/FastLED/FastLED/gh-pages/images/HSV-rainbow-with-desc.jpg) led me to implement an approximation of that as simply as I could.\n\n\n## License\n\nESPxRGB - Copyright 2019  technosf  [http://github.com/technosf]\n\nLicensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3.0 or greater (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\nhttp://www.gnu.org/licenses/lgpl-3.0.en.html\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\n![lglp3 logo](http://www.gnu.org/graphics/lgplv3-88x31.png)\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechnosf%2Fespxrgb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechnosf%2Fespxrgb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechnosf%2Fespxrgb/lists"}