CustomEffects as usermod: step 4: modify wledv123.json, add drawLine/Arc

General (for CE, but also used by M12_pArc)
- add drawArc

Custom Effects
- add WLEDSR Custom Effects comment to places in WLED where it is hooked in
- move from wled.json to wledv123.json
- rename matrixWidth/Heigth to width/height and use virtualWidth/Height
- remove setPixels
- add drawLine / drawArc
This commit is contained in:
Ewowi
2022-08-31 13:14:51 +02:00
parent 717d755969
commit 06c0c0edfb
13 changed files with 97 additions and 70 deletions

View File

@@ -596,6 +596,8 @@ typedef struct Segment {
void fill_circle(uint16_t cx, uint16_t cy, uint8_t radius, CRGB c);
void drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint32_t c);
void drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, CRGB c) { drawLine(x0, y0, x1, y1, RGBW32(c.r,c.g,c.b,0)); } // automatic inline
void drawArc(uint16_t x0, uint16_t y0, uint16_t radius, uint32_t color, uint32_t fillColor = 0);
void drawArc(uint16_t x0, uint16_t y0, uint16_t radius, CRGB color, CRGB fillColor = BLACK) { drawArc(x0, y0, radius, RGBW32(color.r,color.g,color.b,0), RGBW32(fillColor.r,fillColor.g,fillColor.b,0)); } // automatic inline
void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, uint32_t color);
void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, CRGB c) { drawCharacter(chr, x, y, w, h, RGBW32(c.r,c.g,c.b,0)); } // automatic inline
void wu_pixel(uint32_t x, uint32_t y, CRGB c);

View File

@@ -459,6 +459,29 @@ void Segment::drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint3
}
}
void Segment::drawArc(uint16_t x0, uint16_t y0, uint16_t radius, uint32_t color, uint32_t fillColor) {
// float step = degrees / (2.85f*MAX(radius,1));
// for (float rad = 0.0f; rad <= degrees+step/2; rad += step) {
// // may want to try float version as well (with or without antialiasing)
// int x = roundf(sin_t(rad) * radius);
// int y = roundf(cos_t(rad) * radius);
// setPixelColorXY(x+x0, y+y0, c);
// }
float minradius = radius - .5;
float maxradius = radius + .5;
for (int x=0; x<virtualWidth(); x++) for (int y=0; y<virtualHeight(); y++) {
int newX = x - x0;
int newY = y - y0;
if (newX*newX + newY*newY >= minradius * minradius && newX*newX + newY*newY <= maxradius * maxradius)
setPixelColorXY(x, y, color);
if (fillColor != 0)
if (newX*newX + newY*newY < minradius * minradius)
setPixelColorXY(x, y, fillColor);
}
}
#include "console_font_5x8.h"
#include "console_font_5x12.h"
#include "console_font_6x8.h"

View File

@@ -466,15 +466,8 @@ void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col)
// expand in circular fashion from center
if (i==0)
setPixelColorXY(0, 0, col);
else {
float step = HALF_PI / (2.85f*i);
for (float rad = 0.0f; rad <= HALF_PI+step/2; rad += step) {
// may want to try float version as well (with or without antialiasing)
int x = roundf(sin_t(rad) * i);
int y = roundf(cos_t(rad) * i);
setPixelColorXY(x, y, col);
}
}
else
drawArc(0, 0, i, col);
break;
case M12_pCorner:
for (int x = 0; x <= i; x++) setPixelColorXY(x, i, col);

View File

@@ -80,7 +80,7 @@
#define USERMOD_ID_SI7021_MQTT_HA 29 //Usermod "usermod_si7021_mqtt_ha.h"
#define USERMOD_ID_BME280 30 //Usermod "usermod_bme280.h
#define USERMOD_ID_AUDIOREACTIVE 31 //Usermod "audioreactive.h"
#define USERMOD_ID_CUSTOMEFFECTS 32 //Usermod "usermod_v2_customeffects.h"
#define USERMOD_ID_CUSTOMEFFECTS 32 //Usermod "usermod_v2_customeffects.h" WLEDSR Custom Effects
//Access point behavior
#define AP_BEHAVIOR_BOOT_NO_CONN 0 //Open AP when no connection after boot

View File

@@ -51,7 +51,7 @@
setTimeout(()=>{h.appendChild(l)},100);
</script>
<link rel="stylesheet" href="index.css">
<link rel="stylesheet" href="../../usermods/customeffects/customeffects.css">
<link rel="stylesheet" href="../../usermods/customeffects/customeffects.css"> <!--WLEDSR Custom Effects -->
</head>
<body>
@@ -386,6 +386,6 @@
</div>
<i id="roverstar" class="icons huge" onclick="setLor(0)">&#xe410;</i><br>
<script src="index.js"></script>
<script src="../../usermods/customeffects/customeffects.js"></script>
<script src="../../usermods/customeffects/customeffects.js"></script> <!--WLEDSR Custom Effects-->
</body>
</html>

View File

@@ -728,6 +728,7 @@ function populateSegments(s)
<option value="3" ${inst.ssim==3?' selected':''}>U14_3</option>
</select></div>
</div>`;
//WLEDSR Custom Effects
let cusEff = `<button class="btn" onclick="toggleCEEditor('${inst.n?inst.n:"default"}', ${i})">Custom Effect Editor</button><br>`;
cn += `<div class="seg lstI ${i==s.mainseg ? 'selected' : ''} ${exp ? "expanded":""}" id="seg${i}">
<label class="check schkl">

View File

@@ -7,7 +7,7 @@
*/
// Autogenerated from wled00/data/index.htm, do not edit!!
const uint16_t PAGE_index_L = 31018;
const uint16_t PAGE_index_L = 31025;
const uint8_t PAGE_index[] PROGMEM = {
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x13, 0xd4, 0xbd, 0x69, 0x7a, 0xdb, 0xba,
0xd2, 0x30, 0xf8, 0xdf, 0xab, 0x60, 0x98, 0x73, 0x13, 0xe9, 0x88, 0x96, 0xa8, 0xd1, 0x1a, 0x22,
@@ -1923,29 +1923,30 @@ const uint8_t PAGE_index[] PROGMEM = {
0xed, 0xa0, 0x23, 0xf0, 0x32, 0x08, 0xbf, 0x0a, 0x43, 0xad, 0x7f, 0xbe, 0x4b, 0x0d, 0xe0, 0x80,
0xcf, 0x92, 0x1c, 0x97, 0x71, 0xd4, 0x82, 0x97, 0xaf, 0x49, 0x09, 0x8c, 0xe2, 0xa0, 0xa0, 0x57,
0xe2, 0x61, 0xc7, 0x68, 0xf4, 0xcf, 0xaf, 0x11, 0x17, 0xf3, 0x3e, 0xbe, 0xcd, 0x51, 0x97, 0xb8,
0x28, 0x2c, 0x05, 0x2f, 0x35, 0x74, 0x2a, 0x91, 0xfc, 0x67, 0xd7, 0x07, 0x85, 0xa6, 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8, 0x50, 0x34, 0xc6, 0x9b, 0x22, 0xbb, 0x95, 0xf7, 0x3d, 0x8d,
0x27, 0xf4, 0xc3, 0x17, 0x19, 0x51, 0x81, 0xf5, 0x65, 0x6d, 0xee, 0x94, 0xf6, 0x91, 0x28, 0x14,
0xff, 0xbd, 0xa9, 0x6e, 0x93, 0x61, 0xe7, 0x7f, 0x01, 0xaf, 0x15, 0x69, 0x9e, 0xcf, 0x82, 0x01,
0x00
};

View File

@@ -139,6 +139,7 @@
#include "../usermods/audioreactive/audio_reactive.h"
#endif
//WLEDSR Custom Effects
#ifdef USERMOD_CUSTOMEFFECTS
#include "../usermods/customeffects/usermod_v2_customeffects.h"
#endif
@@ -270,6 +271,7 @@ void registerUsermods()
usermods.add(new AudioReactive());
#endif
//WLEDSR Custom Effects
#ifdef USERMOD_CUSTOMEFFECTS
usermods.add(new CustomEffectsUserMod());
#endif