Skip to content

Commit

Permalink
Merge branch 'main' of github.com:davepl/NightDriverStrip into main
Browse files Browse the repository at this point in the history
  • Loading branch information
davepl committed Jul 15, 2023
2 parents 3c277f6 + f8713ac commit e842a8a
Show file tree
Hide file tree
Showing 43 changed files with 102,590 additions and 1,033 deletions.
Binary file added 3DModel/Example.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
101,522 changes: 101,522 additions & 0 deletions 3DModel/LEDFrame-1-06_0.15mm_PLA_MK3_4h17m.gcode

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions 3DModel/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This is a 3D Model of a stand that holds the matrix, as pictured in the "Example.JPG" file in this folder.

This is the GCODE model for my Prusa printer, which I presume can be imported into other systems as well.


25 changes: 14 additions & 11 deletions REST_API.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
- [Copy effect](#copy-effect)
- [Delete effect](#delete-effect)
- [Get effect configuration information](#get-effect-configuration-information)
- [Device setting specifications](#device-setting-specifications)
- [Get device setting specifications](#get-device-setting-specifications)
- [Device settings](#device-settings)
- [Set setting with validation](#set-setting-with-validation)
- [Effect setting specifications](#effect-setting-specifications)
- [Get effect setting specifications](#get-effect-setting-specifications)
- [Effect settings](#effect-settings)
- [Reset configuration and/or device](#reset-configuration-andor-device)
- [Postman collection](#postman-collection)
Expand All @@ -27,9 +27,12 @@
On devices with WiFi and the webserver enabled, NightDriverStrip publishes a REST-like API. The API includes a number of endpoints to:

- Retrieve information about the device and the effects it runs
- Changing the effect that's running
- Change the effect that's running
- Disable and enable effects
- Move, copy and delete effects
- Retrieve setting specifications
- Retrieve and change settings
- Reset configuration and/or the device itself

A subset of the endpoints is used by the NightDriverStrip [web UI](site/README.md).

Expand Down Expand Up @@ -128,7 +131,7 @@ With this endpoint an effect in the effect list can be copied. The created copy
| URL | `/copyEffect` |
| Method | POST | |
| Parameters | `effectIndex` | The (zero-based) integer index of the effect of which a copy should be made. |
| | | Zero, one or more settings that have been returned by the [Effect setting specifications endpoint](#effect-setting-specifications); also refer to the [Change effect settings endpoint](#change-effect-settings) for more information. |
| | | Zero, one or more settings that have been returned by the [Get effect setting specifications endpoint](#get-effect-setting-specifications); also refer to the [Change effect settings endpoint](#change-effect-settings) for more information. |
| Response | 200 (OK) | A JSON blob with the values for the copied effect's configuration settings, after applying the values in the request's POST parameters. |

### Delete effect
Expand All @@ -154,7 +157,7 @@ This endpoint returns a JSON document with information about the detailed config
| Parameters | | |
| Response | 200 (OK) | A JSON blob with detailed configuration information about the device's effects. |

### Device setting specifications
### Get device setting specifications

This endpoint can be used to retrieve the list of known device configuration settings.

Expand All @@ -163,7 +166,7 @@ This endpoint can be used to retrieve the list of known device configuration set
| URL | `/settings/specs` |
| Method | GET | |
| Parameters | | |
| Response | 200 (OK) | A JSON array with the known device configuration settings. The specifications include the name, description, type identifier and type name for each setting. |
| Response | 200 (OK) | A JSON array with the known device configuration settings. The specifications include for each setting the name, description, type identifier, type name, if validation is available, and lower and upper value boundaries if applicable. |

### Device settings

Expand Down Expand Up @@ -192,7 +195,7 @@ When changing settings:
|-|-|-|
| URL | `/settings` |
| Method | POST | |
| Parameters | | One or more settings that have been returned by the [Device setting specifications endpoint](#device-setting-specifications). |
| Parameters | | One or more settings that have been returned by the [Get device setting specifications endpoint](#get-device-setting-specifications). |
| Response | 200 (OK) | A JSON blob with the current values for the device's configuration settings, after applying the values in the request's POST parameters. |

### Set setting with validation
Expand All @@ -205,11 +208,11 @@ Note that validation is not implemented for all settings; the validation step is
|-|-|-|
| URL | `/settings/validated` |
| Method | POST | |
| Parameters | | Exactly one setting that has been returned by the [Device setting specifications endpoint](#device-setting-specifications). |
| Parameters | | Exactly one setting that has been returned by the [Get dvice setting specifications endpoint](#get-device-setting-specifications). |
| Response | 200 (OK) | Validation succeeded and the provided value has been set. |
| | 400 (Bad Request) | More than one known setting was provided, or validation failed. The applicable message is returned in a JSON blob. |

### Effect setting specifications
### Get effect setting specifications

This endpoint can be used to retrieve the list of known effect-specific configuration settings for an individual effect.

Expand All @@ -218,7 +221,7 @@ This endpoint can be used to retrieve the list of known effect-specific configur
| URL | `/settings/effect/specs` |
| Method | GET | |
| Parameters | `effectIndex` | The (zero-based) integer index in the device's effect list of the effect to retrieve the setting specifications for. |
| Response | 200 (OK) | A JSON array with the known effect-specific configuration settings for the effect with index `effectIndex`. The specifications include the name, description, type identifier and type name for each setting. |
| Response | 200 (OK) | A JSON array with the known effect-specific configuration settings for the effect with index `effectIndex`. The specifications include for each setting the name, description, type identifier, type name, if validation is available, and lower and upper value boundaries if applicable. |

### Effect settings

Expand Down Expand Up @@ -248,7 +251,7 @@ When changing settings:
| URL | `/settings` |
| Method | POST | |
| Parameters | `effectIndex` | The (zero-based) integer index in the device's effect list of the effect to change settings for. |
| | | One or more settings that have been returned by the [Effect setting specifications endpoint](#effect-setting-specifications). |
| | | One or more settings that have been returned by the [Get effect setting specifications endpoint](#get-effect-setting-specifications). |
| Response | 200 (OK) | A JSON blob with the current values for the effect's configuration settings, after applying the values in the request's POST parameters. |

### Reset configuration and/or device
Expand Down
77 changes: 0 additions & 77 deletions include/YouTubeSight.h

This file was deleted.

4 changes: 1 addition & 3 deletions include/deviceconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,4 @@ class DeviceConfig : public IJSONSerializable
{
SetAndSave(rememberCurrentEffect, newRememberCurrentEffect);
}
};

extern DRAM_ATTR std::unique_ptr<DeviceConfig> g_ptrDeviceConfig;
};
4 changes: 1 addition & 3 deletions include/effectfactories.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,4 @@ class EffectFactories
{
defaultFactories.clear();
}
};

extern DRAM_ATTR EffectFactories g_EffectFactories;
};
25 changes: 12 additions & 13 deletions include/effectmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ bool ReadCurrentEffectIndex(size_t& index);
std::shared_ptr<LEDStripEffect> GetSpectrumAnalyzer(CRGB color);
std::shared_ptr<LEDStripEffect> GetSpectrumAnalyzer(CRGB color, CRGB color2);
extern DRAM_ATTR std::shared_ptr<GFXBase> g_aptrDevices[NUM_CHANNELS];
extern DRAM_ATTR std::unique_ptr<EffectFactories> g_ptrEffectFactories;

// EffectManager
//
Expand Down Expand Up @@ -105,7 +106,7 @@ class EffectManager : public IJSONSerializable
std::set<int> loadedEffectNumbers;

// Create effects from JSON objects, using the respective factories in g_EffectFactories
auto& jsonFactories = g_EffectFactories.GetJSONFactories();
auto& jsonFactories = g_ptrEffectFactories->GetJSONFactories();

for (auto effectObject : effectsArray)
{
Expand All @@ -127,7 +128,7 @@ class EffectManager : public IJSONSerializable
}

// Now add missing effects from the default factory list
auto &defaultFactories = g_EffectFactories.GetDefaultFactories();
auto &defaultFactories = g_ptrEffectFactories->GetDefaultFactories();

// We iterate manually, so we can use where we are as the starting point for a later inner loop
for (auto iter = defaultFactories.begin(); iter != defaultFactories.end(); iter++)
Expand Down Expand Up @@ -217,10 +218,10 @@ class EffectManager : public IJSONSerializable
{
_newFrameAvailable = available;
}

void LoadDefaultEffects()
{
for (auto &numberedFactory : g_EffectFactories.GetDefaultFactories())
for (auto &numberedFactory : g_ptrEffectFactories->GetDefaultFactories())
{
auto pEffect = numberedFactory.Factory();
if (pEffect)
Expand Down Expand Up @@ -377,7 +378,7 @@ class EffectManager : public IJSONSerializable

virtual bool IsVUVisible() const
{
return _bShowVU && GetCurrentEffect()->CanDisplayVUMeter();
return _bShowVU && GetCurrentEffect().CanDisplayVUMeter();
}

// SetGlobalColor
Expand Down Expand Up @@ -557,7 +558,7 @@ class EffectManager : public IJSONSerializable
SerializeWithBufferSize(ptrJsonDoc, jsonBufferSize,
[&sourceEffect](JsonObject &jsonObject) { return sourceEffect->SerializeToJSON(jsonObject); });

auto jsonEffectFactories = g_EffectFactories.GetJSONFactories();
auto jsonEffectFactories = g_ptrEffectFactories->GetJSONFactories();
auto factoryEntry = jsonEffectFactories.find(sourceEffect->EffectNumber());

if (factoryEntry == jsonEffectFactories.end())
Expand Down Expand Up @@ -655,9 +656,9 @@ class EffectManager : public IJSONSerializable
return _iCurrentEffect;
}

const std::shared_ptr<LEDStripEffect> GetCurrentEffect() const
LEDStripEffect& GetCurrentEffect() const
{
return _tempEffect ? _tempEffect : _vEffects[_iCurrentEffect];
return *(_tempEffect ? _tempEffect : _vEffects[_iCurrentEffect]);
}

const String & GetCurrentEffectName() const
Expand Down Expand Up @@ -702,14 +703,14 @@ class EffectManager : public IJSONSerializable
uint GetInterval() const
{
// This allows you to return a MaximumEffectTime and your effect won't be shown longer than that
return min((_effectInterval == 0 ? std::numeric_limits<uint>::max() : _effectInterval), GetCurrentEffect()->MaximumEffectTime());
return min((_effectInterval == 0 ? std::numeric_limits<uint>::max() : _effectInterval), GetCurrentEffect().MaximumEffectTime());
}

void CheckEffectTimerExpired()
{
// If interval is zero, the current effect never expires unless it thas a max effect time set

if (_effectInterval == 0 && !GetCurrentEffect()->HasMaximumEffectTime())
if (_effectInterval == 0 && !GetCurrentEffect().HasMaximumEffectTime())
return;

if (GetTimeUsedByCurrentEffect() >= GetInterval()) // See if it's time for a new effect yet
Expand Down Expand Up @@ -841,6 +842,4 @@ class EffectManager : public IJSONSerializable
g_Fader = 255; // No fade, not at start or end
}
}
};

extern DRAM_ATTR std::unique_ptr<EffectManager<GFXBase>> g_ptrEffectManager;
};
4 changes: 2 additions & 2 deletions include/effects/matrix/PatternBounce.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ class PatternBounce : public LEDStripEffect
{
// dim all pixels on the display

// Blue columns only. Skip the first row of each column if the VU meter is being shown, so we don't blend it onto ourselves
g()->blurColumns(g()->leds, MATRIX_WIDTH, MATRIX_HEIGHT, g_ptrEffectManager->IsVUVisible() ? 1 : 0, 200);
// Blue columns only, and skip the first row of each column if the VU meter is being shown so we don't blend it onto ourselves
g()->blurColumns(g()->leds, MATRIX_WIDTH, MATRIX_HEIGHT, g_ptrSystem->EffectManager().IsVUVisible() ? 1 : 0, 200);
g()->DimAll(250);

for (int i = 0; i < count; i++)
Expand Down
3 changes: 2 additions & 1 deletion include/effects/matrix/PatternCircuit.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ class PatternCircuit : public LEDStripEffect
virtual void Draw() override
{
// Reset after 20 seconds
if (millis() - msStart > 20000)
const auto kResetEveryNSeconds = 20;
if (millis() - msStart > kResetEveryNSeconds * MILLIS_PER_SECOND)
start();

for (int i = 0; i < MATRIX_WIDTH * MATRIX_HEIGHT / 10; i++)
Expand Down
18 changes: 9 additions & 9 deletions include/effects/matrix/PatternMaze.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
#ifndef PatternMaze_H
#define PatternMaze_H

class PatternMaze : public LEDStripEffect
class PatternMaze : public LEDStripEffect
{
private:
enum Directions {
Expand Down Expand Up @@ -119,7 +119,7 @@ class PatternMaze : public LEDStripEffect

static const int width = MATRIX_WIDTH / 4;
static const int height = MATRIX_HEIGHT / 2;


Directions grid[width][height];

Expand Down Expand Up @@ -160,7 +160,7 @@ class PatternMaze : public LEDStripEffect
return point;
}

CRGB chooseColor(int index)
CRGB chooseColor(int index)
{
switch (algorithm) {
case 0:
Expand All @@ -170,8 +170,8 @@ class PatternMaze : public LEDStripEffect
return CHSV(hue + 128, 255, 200);
}
}
int chooseIndex(int max)

int chooseIndex(int max)
{
switch (algorithm) {
case 0:
Expand All @@ -195,7 +195,7 @@ class PatternMaze : public LEDStripEffect
}
}

void drawNextCell()
void drawNextCell()
{
int index = chooseIndex(cellCount);

Expand All @@ -212,12 +212,12 @@ class PatternMaze : public LEDStripEffect
g()->drawPixel(imagePoint.x, imagePoint.y, color);
g()->drawPixel(MATRIX_WIDTH - 1 - imagePoint.x, imagePoint.y, color);

for (int i = 0; i < 4; i++)
for (int i = 0; i < 4; i++)
{
Directions direction = directions[i];

Point newPoint = point.Move(direction);
if (newPoint.x >= 0 && newPoint.y >= 0 && newPoint.x < width && newPoint.y < height && grid[newPoint.y][newPoint.x] == None)
if (newPoint.x >= 0 && newPoint.y >= 0 && newPoint.x < width && newPoint.y < height && grid[newPoint.y][newPoint.x] == None)
{
grid[point.y][point.x] = (Directions) ((int) grid[point.y][point.x] | (int) direction);
grid[newPoint.y][newPoint.x] = (Directions) ((int) grid[newPoint.y][newPoint.x] | (int) point.Opposite(direction));
Expand Down Expand Up @@ -257,7 +257,7 @@ class PatternMaze : public LEDStripEffect

virtual void Draw() override
{
if (cellCount < 1)
if (cellCount < 1)
{
hue = random(256);
g()->Clear();
Expand Down
Loading

0 comments on commit e842a8a

Please sign in to comment.