Skip to content

Commit

Permalink
Merge branch 'matrix-build' into I2SClocklessLedDriver
Browse files Browse the repository at this point in the history
  • Loading branch information
netmindz committed Mar 4, 2024
2 parents 4202712 + 0538044 commit b222055
Show file tree
Hide file tree
Showing 22 changed files with 1,599 additions and 1,470 deletions.
34 changes: 32 additions & 2 deletions .github/workflows/pio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,39 @@ name: PlatformIO CI
on: [push]

jobs:
build:
get_default_envs:
name: Gather Environments
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install PlatformIO Core
run: pip install --upgrade platformio
- name: Get default environments
id: envs
run: |
echo -n "environments=" >> $GITHUB_OUTPUT
jq -c -n '$ARGS.positional' --args $(pio project config --json-output | jq -cr '.[][0]' | grep 'env:'| awk -F: '{ print $2" "}' | tr -d '\n') >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
outputs:
environments: ${{ steps.envs.outputs.environments }}

build:
runs-on: ubuntu-latest
needs: get_default_envs
strategy:
fail-fast: false
matrix:
environment: ${{ fromJSON(needs.get_default_envs.outputs.environments) }}
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -29,7 +59,7 @@ jobs:
echo "git_hash=${git_hash}" >> $GITHUB_ENV
echo "git_branch=${git_branch}" >> $GITHUB_ENV
- name: Build PlatformIO Project
run: pio run
run: pio run -e ${{ matrix.environment }}
- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
with:
Expand Down
4 changes: 4 additions & 0 deletions data/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
// @license GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
// @license For non GPL-v3 usage, commercial licenses must be purchased. Contact [email protected]

function appName() {
return "Led";
}

function userFun(data) {
let buffer = new Uint8Array(data);
if (buffer[0]==1 && jsonValues.pview) {
Expand Down
2 changes: 1 addition & 1 deletion data/index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<h1>StarMod💫 LEDs 🎨 by MoonModules 🌔</h1>
<h2><div id="instanceName"></div></h2>
<input type="button" value="App" id="vApp" onclick="setView(this)">
<input type="button" value="Stage" id="vStage" onclick="setView(this)">
<input type="button" value="DashBoard" id="vDash" onclick="setView(this)">
<input type="button" value="User" id="vUser" onclick="setView(this)">
<input type="button" value="System" id="vSys" onclick="setView(this)">
<input type="button" value="All" id="vAll" onclick="setView(this)">
Expand Down
16 changes: 8 additions & 8 deletions data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function makeWS() {
else
changeHTMLView("vApp"); //default

gId("vApp").value = "Leds"; //tbd: should be set by server
gId("vApp").value = appName(); //tbd: should be set by server

//send request for uiFun
flushUIFunCommands();
Expand Down Expand Up @@ -221,7 +221,7 @@ function createHTML(json, parentNode = null, rowNr = UINT8_MAX) {
let helpNode = cE("a");
helpNode.innerText = "ⓘ";
helpNode.style="float: right;"
let initCapVarType = variable.type=="appmod"?"AppMod":variable.type=="usermod"?"UserMod":"SysMod";
let initCapVarType = variable.type=="appmod"?appName() + "Mod":variable.type=="usermod"?"UserMod":"SysMod";
helpNode.setAttribute('href', "https://ewowi.github.io/StarDocs/" + initCapVarType + "/" + initCapVarType + initCap(variable.id));
hgroupNode.appendChild(helpNode);

Expand Down Expand Up @@ -1302,7 +1302,7 @@ function setInstanceTableColumns() {

let tbl = gId("insTbl");
if (!tbl) return;
let isStageView = gId("vStage").classList.contains("selected");
let isDashView = gId("vDash").classList.contains("selected");
let thead = tbl.querySelector("thead");
let tbody = tbl.querySelector("tbody");

Expand All @@ -1318,13 +1318,13 @@ function setInstanceTableColumns() {
// console.log("setInstanceTableColumns", tbl, thead, tbody);
columnNr = 2;
for (; columnNr<6; columnNr++) {
showHideColumn(columnNr, isStageView);
showHideColumn(columnNr, isDashView);
}
for (; columnNr<thead.querySelector("tr").childNodes.length; columnNr++) {
showHideColumn(columnNr, !isStageView);
showHideColumn(columnNr, !isDashView);
}

if (gId("sma")) gId("sma").parentNode.hidden = isStageView; //hide sync master label field and comment
if (gId("sma")) gId("sma").parentNode.hidden = isDashView; //hide sync master label field and comment
}

function changeHTMLView(value) {
Expand All @@ -1333,7 +1333,7 @@ function changeHTMLView(value) {

gId("vAI").classList.remove("selected");
gId("vApp").classList.remove("selected");
gId("vStage").classList.remove("selected");
gId("vDash").classList.remove("selected");
gId("vUser").classList.remove("selected");
gId("vSys").classList.remove("selected");
gId("vAll").classList.remove("selected");
Expand All @@ -1359,7 +1359,7 @@ function changeHTMLView(value) {
found = true;
if (value=="vUser" && moduleNode.className == "usermod")
found = true;
if (value=="vStage" && moduleNode.id == "Instances")
if (value=="vDash" && moduleNode.id == "Instances")
found = true;
}
// console.log(mdlColumnNode, moduleNode, moduleNode.className);
Expand Down
4 changes: 2 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ build_flags =

; Compiler warnings FastLed:
; In file included from .pio/libdeps/esp32dev/FastLED/src/FastLED.h:75,
; from src/App/AppLeds.h:11,
; from src/App/AppModEffects.h:13,
; from src/App/LedLeds.h:11,
; from src/App/LedModEffects.h:13,
; from src/main.cpp:25:
; .pio/libdeps/esp32dev/FastLED/src/fastspi.h:157:23: note: #pragma message: No hardware SPI pins defined. All SPI access will default to bitbanged output
; # pragma message "No hardware SPI pins defined. All SPI access will default to bitbanged output"
Expand Down
87 changes: 85 additions & 2 deletions src/App/AppEffects.h → src/App/LedEffects.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
@title StarMod
@file AppEffects.h
@file LedEffects.h
@date 20240228
@repo https://github.com/ewowi/StarMod
@Authors https://github.com/ewowi/StarMod/commits/main
Expand Down Expand Up @@ -49,7 +49,7 @@ class Effect {
default: return false;
}});
//tbd: check if memory is freed!
// currentVar["stage"] = true;
// currentVar["dash"] = true;
}

CRGBPalette16 getPalette() {
Expand Down Expand Up @@ -1048,6 +1048,88 @@ class FreqMatrix:public Effect {
}
};


class DJLight:public Effect {
public:

const char * name() {
return "DJLight 1D";
}

void setup(Leds &leds) {
leds.fill_solid(CRGB::Black);
}

void loop(Leds &leds) {

const int mid = leds.nrOfLeds / 2;

unsigned8 *aux0 = leds.sharedData.bind(aux0);

uint8_t *fftResult = wledAudioMod->fftResults;
float volumeSmth = wledAudioMod->volumeSmth;

unsigned8 speed = mdl->getValue("speed");
bool candyFactory = mdl->getValue("candyFactory").as<bool>();
unsigned8 fade = mdl->getValue("fade");


unsigned8 secondHand = (speed < 255) ? (micros()/(256-speed)/500 % 16) : 0;
if((speed > 254) || (*aux0 != secondHand)) { // WLEDMM allow run run at full speed
*aux0 = secondHand;

CRGB color = CRGB(0,0,0);
// color = CRGB(fftResult[15]/2, fftResult[5]/2, fftResult[0]/2); // formula from 0.13.x (10Khz): R = 3880-5120, G=240-340, B=60-100
if (!candyFactory) {
color = CRGB(fftResult[12]/2, fftResult[3]/2, fftResult[1]/2); // formula for 0.14.x (22Khz): R = 3015-3704, G=216-301, B=86-129
} else {
// candy factory: an attempt to get more colors
color = CRGB(fftResult[11]/2 + fftResult[12]/4 + fftResult[14]/4, // red : 2412-3704 + 4479-7106
fftResult[4]/2 + fftResult[3]/4, // green: 216-430
fftResult[0]/4 + fftResult[1]/4 + fftResult[2]/4); // blue: 46-216
if ((color.getLuma() < 96) && (volumeSmth >= 1.5f)) { // enhance "almost dark" pixels with yellow, based on not-yet-used channels
unsigned yello_g = (fftResult[5] + fftResult[6] + fftResult[7]) / 3;
unsigned yello_r = (fftResult[7] + fftResult[8] + fftResult[9] + fftResult[10]) / 4;
color.green += (uint8_t) yello_g / 2;
color.red += (uint8_t) yello_r / 2;
}
}

if (volumeSmth < 1.0f) color = CRGB(0,0,0); // silence = black

// make colors less "pastel", by turning up color saturation in HSV space
if (color.getLuma() > 32) { // don't change "dark" pixels
CHSV hsvColor = rgb2hsv_approximate(color);
hsvColor.v = min(max(hsvColor.v, (uint8_t)48), (uint8_t)204); // 48 < brightness < 204
if (candyFactory)
hsvColor.s = max(hsvColor.s, (uint8_t)204); // candy factory mode: strongly turn up color saturation (> 192)
else
hsvColor.s = max(hsvColor.s, (uint8_t)108); // normal mode: turn up color saturation to avoid pastels
color = hsvColor;
}
//if (color.getLuma() > 12) color.maximizeBrightness(); // for testing

//SEGMENT.setPixelColor(mid, color.fadeToBlackBy(map(fftResult[4], 0, 255, 255, 4))); // 0.13.x fade -> 180hz-260hz
uint8_t fadeVal = map(fftResult[3], 0, 255, 255, 4); // 0.14.x fade -> 216hz-301hz
if (candyFactory) fadeVal = constrain(fadeVal, 0, 176); // "candy factory" mode - avoid complete fade-out
leds.setPixelColor(mid, color.fadeToBlackBy(fadeVal));

for (int i = leds.nrOfLeds - 1; i > mid; i--) leds.setPixelColor(i, leds.getPixelColor(i-1)); // move to the left
for (int i = 0; i < mid; i++) leds.setPixelColor(i, leds.getPixelColor(i+1)); // move to the right

leds.fadeToBlackBy(fade);

}
}

void controls(JsonObject parentVar) {
ui->initSlider(parentVar, "speed", 255);
ui->initCheckBox(parentVar, "candyFactory", true);
ui->initSlider(parentVar, "fade", 4, 0, 10);
}
};


#endif // End Audio Effects

class Effects {
Expand Down Expand Up @@ -1080,6 +1162,7 @@ class Effects {
effects.push_back(new GEQEffect);
effects.push_back(new AudioRings);
effects.push_back(new FreqMatrix);
effects.push_back(new DJLight);
#endif
}

Expand Down
41 changes: 23 additions & 18 deletions src/App/AppFixture.cpp → src/App/LedFixture.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
@title StarMod
@file AppFixture.cpp
@file LedFixture.cpp
@date 20240228
@repo https://github.com/ewowi/StarMod
@Authors https://github.com/ewowi/StarMod/commits/main
Expand All @@ -9,7 +9,7 @@
@license For non GPL-v3 usage, commercial licenses must be purchased. Contact [email protected]
*/

#include "AppFixture.h"
#include "LedFixture.h"

#include "../Sys/SysModFiles.h"
#include "../Sys/SysStarModJson.h"
Expand Down Expand Up @@ -44,8 +44,12 @@ void Fixture::projectAndMap() {
if (leds->doMap) {
USER_PRINTF("Leds pre [%d] f:%d p:%d s:%d\n", rowNr, leds->fx, leds->projectionNr, ledsList.size());
//vectors really gone now?
for (std::vector<std::vector<unsigned16>> ::iterator physMap=leds->mappingTable.begin(); physMap!=leds->mappingTable.end(); ++physMap)
physMap->clear();
for (std::vector<unsigned16>* physMap:leds->mappingTable) {
if (physMap) {
physMap->clear();
delete physMap;
}
}
leds->mappingTable.clear();
leds->sharedData.clear();
}
Expand Down Expand Up @@ -328,12 +332,13 @@ void Fixture::projectAndMap() {
if (indexV >= leds->mappingTable.size()) {
for (size_t i = leds->mappingTable.size(); i <= indexV; i++) {
// USER_PRINTF("mapping %d,%d,%d add physMap before %d %d\n", pixel.y, pixel.y, pixel.z, indexV, leds->mappingTable.size());
std::vector<unsigned16> physMap;
leds->mappingTable.push_back(physMap); //abort() was called at PC 0x40191473 on core 1 std::allocator<unsigned short> >&&)
leds->mappingTable.push_back(nullptr); //abort() was called at PC 0x40191473 on core 1 std::allocator<unsigned short> >&&)
}
}
//indexV is within the square
leds->mappingTable[indexV].push_back(indexP); //add the current led in the right physMap
if (!leds->mappingTable[indexV])
leds->mappingTable[indexV] = new std::vector<unsigned16>;
leds->mappingTable[indexV]->push_back(indexP); //add the current led in the right physMap
}
else
USER_PRINTF("dev post [%d] indexP too high %d>=%d or %d (p:%d m:%d) p:%d,%d,%d\n", rowNr, indexP, nrOfLeds, NUM_LEDS_Max, leds->mappingTable.size(), indexP, pixel.x, pixel.y, pixel.z);
Expand Down Expand Up @@ -364,7 +369,7 @@ void Fixture::projectAndMap() {
after = strtok(NULL, " ");
unsigned16 startLed = atoi(before);
unsigned16 nrOfLeds = atoi(after) - atoi(before) + 1;
print->fFormat(details, sizeof(details)-1, "%d-%d", min(prevIndexP, startLed), max((unsigned16)(indexP - 1), nrOfLeds)); //careful: AppModEffects:loop uses this to assign to FastLed
print->fFormat(details, sizeof(details)-1, "%d-%d", min(prevIndexP, startLed), max((unsigned16)(indexP - 1), nrOfLeds)); //careful: LedModEffects:loop uses this to assign to FastLed
USER_PRINTF("pins extend leds %d: %s\n", currPin, details);
//tbd: more check

Expand All @@ -373,7 +378,7 @@ void Fixture::projectAndMap() {
}
else {//allocate new pin
//tbd: check if free
print->fFormat(details, sizeof(details)-1, "%d-%d", prevIndexP, indexP - 1); //careful: AppModEffects:loop uses this to assign to FastLed
print->fFormat(details, sizeof(details)-1, "%d-%d", prevIndexP, indexP - 1); //careful: LedModEffects:loop uses this to assign to FastLed
USER_PRINTF("pins %d: %s\n", currPin, details);
pins->allocatePin(currPin, "Leds", details);
}
Expand Down Expand Up @@ -402,19 +407,19 @@ void Fixture::projectAndMap() {

} else {

if (leds->mappingTable.size() < leds->size.x * leds->size.y * leds->size.z)
USER_PRINTF("mapping add extra physMap %d to %d size: %d,%d,%d\n", leds->mappingTable.size(), leds->size.x * leds->size.y * leds->size.z, leds->size.x, leds->size.y, leds->size.z);
for (size_t i = leds->mappingTable.size(); i < leds->size.x * leds->size.y * leds->size.z; i++) {
std::vector<unsigned16> physMap;
// physMap.push_back(0);
leds->mappingTable.push_back(physMap);
}
// if (leds->mappingTable.size() < leds->size.x * leds->size.y * leds->size.z)
// USER_PRINTF("mapping add extra physMap %d to %d size: %d,%d,%d\n", leds->mappingTable.size(), leds->size.x * leds->size.y * leds->size.z, leds->size.x, leds->size.y, leds->size.z);
// for (size_t i = leds->mappingTable.size(); i < leds->size.x * leds->size.y * leds->size.z; i++) {
// std::vector<unsigned16> physMap;
// // physMap.push_back(0);
// leds->mappingTable.push_back(physMap);
// }

leds->nrOfLeds = leds->mappingTable.size();

unsigned16 indexV = 0;
for (std::vector<std::vector<unsigned16>>::iterator physMap=leds->mappingTable.begin(); physMap!=leds->mappingTable.end(); ++physMap) {
if (physMap->size()) {
for (std::vector<unsigned16>* physMap:leds->mappingTable) {
if (physMap && physMap->size()) {
// USER_PRINTF("ledV %d mapping: #ledsP (%d):", indexV, physMap->size());

for (unsigned16 indexP:*physMap) {
Expand Down
4 changes: 2 additions & 2 deletions src/App/AppFixture.h → src/App/LedFixture.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
@title StarMod
@file AppFixture.h
@file LedFixture.h
@date 20240228
@repo https://github.com/ewowi/StarMod
@Authors https://github.com/ewowi/StarMod/commits/main
Expand All @@ -13,7 +13,7 @@

#include "../Sys/SysModModel.h" //for Coord3D

#include "AppLeds.h"
#include "LedLeds.h"

#define NUM_LEDS_Max 4096

Expand Down
Loading

0 comments on commit b222055

Please sign in to comment.