Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
lampda::modes::draw::grid::LineRule< ConfigTy > Struct Template Reference

Implement a line-based grid pattern, update line per line. More...

#include <grid_rule.hpp>

Public Types

using LineTy = std::array< uint32_t, width >
 Type of a line array.
 

Public Member Functions

void reset (LampTy &lamp, LineTy &firstLine)
 To be called in the parent .reset() to set firstLine as first line.
 
void LMBD_INLINE reset (LampTy &lamp)
 Reset grip with an empty (black) first line.
 
void update (LampTy &lamp, auto &callback)
 When called, pass before and after line to callback for processing.
 
void display (LampTy &lamp, bool reversed=false)
 Display the line-rule grid onto screen (if reversed reverse it)
 
void LMBD_INLINE smoothUpdate (LampTy &lamp, auto &callback)
 Same as .update() but uses two buffers, required for smoothDisplay()
 
void LMBD_INLINE smoothDisplay (LampTy &lamp, float phasis)
 Display grid buffers as an in-between frame, at phasis (from 0 to 1)
 
void LMBD_INLINE smoothDisplay (LampTy &lamp, uint16_t counter, uint16_t maxCounter, uint16_t maxValue=256)
 For a counter between 0 and maxCounter display a smooth frame.
 
LineTy LMBD_INLINE lineAtIndex (LampTy &lamp, uint16_t lineIndex)
 Return a copy of line at lineAtIndex (may be empty if out of screen)
 
void scrollBy (LampTy &lamp, uint8_t amount, bool skewed)
 Scroll grid by amount upward (optionnaly skewed to the left)
 
template<bool hasCustomRamp, uint8_t rampSubstitute = 70, uint8_t baseSmooth = 4>
void LMBD_INLINE loop (auto &ctx, auto &callback)
 Default loop function, update and display, smooth display if fast.
 

Public Attributes

LineTy currentLine
 Current line being processed.
 
uint16_t lastLine = 0
 latest treated line
 
uint32_t lastUpdate = 0
 latest update time, in milliseconds
 
bool isResetted = false
 flag to signal that the grid just been resetted
 

Static Public Attributes

static constexpr uint16_t nbLines = LampTy::maxHeight
 Number of lines in grid.
 

Detailed Description

template<typename ConfigTy = LineRuleConfig>
struct lampda::modes::draw::grid::LineRule< ConfigTy >

Implement a line-based grid pattern, update line per line.

Typical usage is:

static void loop(auto& ctx)
{
auto cb = [&](const auto& before, auto& after) {
// read array "before" for previous line, write updated line to "after" array
};
ctx.state.grid.update(ctx.lamp, cb);
ctx.state.grid.display(ctx.lamp);
}
void LMBD_INLINE loop(auto &ctx, auto &callback)
Default loop function, update and display, smooth display if fast.
Definition: grid_rule.hpp:213

See examples to learn more about the behavior of this.

Member Function Documentation

◆ loop()

template<typename ConfigTy = LineRuleConfig>
template<bool hasCustomRamp, uint8_t rampSubstitute = 70, uint8_t baseSmooth = 4>
void LMBD_INLINE lampda::modes::draw::grid::LineRule< ConfigTy >::loop ( auto &  ctx,
auto &  callback 
)
inline

Default loop function, update and display, smooth display if fast.

If hasCustomRamp is True, uses internally custom ramp to configure update speed of the grid. If fast and high luminosity, try smoothing the display, if slow or low luminosity, disable smoothing to avoid user seeing a blurry "marching effect" between updates.

If hasCustomRamp is False, use rampSubstitute as value, higher being slower (from 0 to 256). Use baseSmooth to configure how fast the smooth mode can go, value 0 being the fastest, and 10 disabling smoothing.


The documentation for this struct was generated from the following file: