Skip to content

Commit

Permalink
Clean up usages (#619)
Browse files Browse the repository at this point in the history
  • Loading branch information
NoSloppy authored Jan 6, 2024
1 parent 28db174 commit e9f7486
Show file tree
Hide file tree
Showing 39 changed files with 93 additions and 38 deletions.
2 changes: 2 additions & 0 deletions functions/alt.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ using AltF = SingleValueAdapter<AltSVF>;
// return value: INTEGER (always zero)
// Enables Bidirectional synchronization between ALT and VARIANCE.
// If variance changes, so does alt, if alt changes, so does variance.

class SyncAltToVarianceSVF : private Looper {
public:
FunctionRunResult run(BladeBase* blade) {
Expand Down Expand Up @@ -62,6 +63,7 @@ using SyncAltToVarianceF = SingleValueAdapter<SyncAltToVarianceSVF>;
// Usage: SyncAltToVarianceL
// return value: LAYER (transparent)
// Synchronizes alt to variance, just put it somewhere in the layer stack. (but not first)

using SyncAltToVarianceL = AlphaL<Black, SyncAltToVarianceF>;

#endif
2 changes: 1 addition & 1 deletion functions/blade_angle.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// So if MIN=16484 and MAX=32768, BladeAngle will return zero when you
// point the blade towards the horizon and 32768 when you point it
// straight up. Any angle below the horizon will also return zero.
// returned value: FUNCTION, same for all leds
// returned value: FUNCTION, same for all LEDs.

#include "svf.h"

Expand Down
6 changes: 3 additions & 3 deletions functions/blast.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
// WAVE_MS: a number (defaults to 400)
// EFFECT: a BladeEffectType (defaults to EFFECT_BLAST)
// returned value: FUNCTION
// This function is intended to Mix<> or AlphaL<>, when a
// a blast occurs, it makes a wave starting at the blast.
// This function is intended to be used in a Mix<> or AlphaL<>
// When a blast occurs, it makes a wave starting at the blast
// location (which is currently random) and travels out
// from that direction. At the peak, this function returns
// 32768 and when there is no blash it returns zero.
// 32768 and when there is no blast it returns zero.
// The FADOUT_MS controls how long it takes the wave to
// fade out. The WAVE_SIZE controls the width of the wave.
// The WAVE_MS parameter controls the speed of the waves.
Expand Down
1 change: 1 addition & 0 deletions functions/brown_noise.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class BrownNoiseF {
// Returns a value between 0 and 32768 which changes randomly up and
// down over time. All pixels gets the same value.
// SPEED controls how quickly the value changes.

template<class SPEED>
class SlowNoise {
public:
Expand Down
5 changes: 3 additions & 2 deletions functions/bullet_count.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@

int prop_GetBulletCount();

// usage: BulletCount
// Usage: BulletCount
// Return 0-N (number of bullets in the magazine.)
// Will cause compilation error if your prop doesn't have bullets.
// You must define BLASTER_SHOTS_UNTIL_EMPTY for this to be available.

class BulletCountSVF {
public:
void run(BladeBase* blade) {}
Expand All @@ -23,7 +24,7 @@ class SingleValueAdapter<BulletCountSVF> : public BulletCountSVF {};
using BulletCountF = SingleValueAdapter<BulletCountSVF>;


// usage: BlasterCharge
// Usage: BlasterCharge
// Return 0-32768 based on the fullness of the clip / magazine.
// Will cause compilation error if your prop doesn't have bullets.
// You must define BLASTER_SHOTS_UNTIL_EMPTY for this to be available.
Expand Down
1 change: 1 addition & 0 deletions functions/circular_section.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// Example: If POSITION = 0 and FRACTION = 16384, then this function
// will return 32768 for the first 25% and the last 25% of the blade
// and 0 for the rest of the LEDs.

class BladeBase;
template<class POSITION, class FRACTION>
class CircularSectionF {
Expand Down
4 changes: 4 additions & 0 deletions functions/effect_increment.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// Usage: EffectPulse<EFFECT>
// EFFECT: BladeEffectType
// Returns 32768 once for each time the given effect occurs.

template<BladeEffectType EFFECT>
class EffectPulseSVF {
public:
Expand All @@ -24,6 +25,7 @@ using EffectPulseF = SingleValueAdapter<EffectPulseSVF<EFFECT>>;
// Usage: LockupPulseF<LOCKUP_TYPE>
// LOCKUP_TYPE: a SaberBase::LockupType
// Returns 32768 once for each time the given lockup occurs.

template<SaberBase::LockupType LOCKUP_TYPE>
class LockupPulseSVF {
public:
Expand All @@ -50,6 +52,7 @@ using LockupPulseF = SingleValueAdapter<LockupPulseSVF<LOCKUP_TYPE>>;
// Starts at zero, increments by I each time the PULSE occurse.
// If it reaches MAX it stays there.
// Resets back to zero when RESET_PULSE occurs.

template<class PULSE, class RESET_PULSE=Int<0>, class MAX = Int<32768>, class I = Int<1>>
class IncrementWithResetSVF {
public:
Expand Down Expand Up @@ -88,6 +91,7 @@ class SingleValueAdapter<IncrementWithResetSVF<PULSE, RESET_PULSE, MAX, I>> : pu
// If adding I exceeds MAX, the function returns 0 + any remainder in excesss of MAX
// I, MAX = numbers
// return value: INTEGER

template<BladeEffectType EFFECT, class MAX = Int<32768>, class I = Int<1>>
using EffectIncrementF = IncrementModuloF<EffectPulseF<EFFECT>, MAX, I>;

Expand Down
2 changes: 1 addition & 1 deletion functions/ifon.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Ifon {
bool on_;
};

// InOutFunc<OUT_MILLIS, IN_MILLIS>
// Usage: InOutFunc<OUT_MILLIS, IN_MILLIS>
// IN_MILLIS, OUT_MILLIS: a number
// RETURN VALUE: FUNCTION
// 0 when off, 32768 when on, takes OUT_MILLIS to go from 0 to 32768
Expand Down
3 changes: 3 additions & 0 deletions functions/increment.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// INCREMENT: FUNCTION defaults to Int<1>
// Increments by I each time PULSE occurs wraps around when
// it reaches MAX.

template<class PULSE, class MAX = Int<32768>, class INCREMENT = Int<1>>
class IncrementModuloFSVF {
public:
Expand Down Expand Up @@ -43,6 +44,7 @@ class SingleValueAdapter<IncrementModuloFSVF<PULSE, MAX, INCREMENT>> : public In
// Returns 32768 once when F > THRESHOLD, then waits until
// F < THRESHOLD * HYST_PERCENT / 100 before going back
// to the initial state (waiting for F > THRESHOLD).

template<class F, class THRESHOLD = Int<32768>, class HYST_PERCENT = Int<66> >
class ThresholdPulseFSVF {
public:
Expand Down Expand Up @@ -87,6 +89,7 @@ using ThresholdPulseF = SingleValueAdapter<ThresholdPulseFSVF<F, THRESHOLD, HYST

// NOTE: this function is designed to separate "events" for use with *Select styles.
// This function may break up SwingSpeed effects or other continuous responsive functions.

template<class F, class V = Int<32768>, class MAX = Int<32768>, class I = Int<1>, class HYST_PERCENT = Int<66>>
using IncrementF = IncrementModuloF<ThresholdPulseF<F, V, HYST_PERCENT>, MAX, I>;

Expand Down
2 changes: 1 addition & 1 deletion functions/int_select.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Usage: IntSelect<SELECTION, Int1, Int2...>
// SELECTION: FUNCTION
// Returns SELECTION of N
// If SELECTION is 0, the first integer is returned, if SELECTIOn is 1, the second and so forth.
// If SELECTION is 0, the first integer is returned, if SELECTION is 1, the second and so forth.
// N: numbers
// return value: INTEGER

Expand Down
1 change: 1 addition & 0 deletions functions/marble.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// track and returns the position of that marble.
// Meant to be used with CircularSectionF to turn the marble
// position into a lighted up section.

class BladeBase;
template<class OFFSET,
class FRICTION,
Expand Down
7 changes: 4 additions & 3 deletions functions/ramp.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#ifndef FUNCTIONS_RAMP_H
#define FUNCTIONS_RAMP_H

// Returns led as value between 0 ~ 32768
// Keeps existing mapping for pixels when used with Remap<>
// Example: Remap<RampF,COLOR>
// Usage: RampF
// Returns 0 at base and 32768 at tip.
// Example: Mix<RampF, COLOR1, COLOR2, COLOR3>
// This would do the same thing as Gradient<COLOR1, COLOR2, COLOR3>

class RampF {
public:
Expand Down
5 changes: 3 additions & 2 deletions functions/readpin.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "../common/analog_read.h"

// usage: ReadPinF<PIN>
// Usage: ReadPinF<PIN>
// or: ReadPinF<PIN, PIN_MODE>
// returns INTEGER, 0 if pin is low and 32768 if pin is high
// PIN: int, pin you want your style to respond to
Expand All @@ -25,7 +25,7 @@ template<int pin, int pin_mode = INPUT>
using ReadPinF = SingleValueAdapter<ReadPinSVF<pin, pin_mode>>;


// usage: AnalogReadPinF<PIN>
// Usage: AnalogReadPinF<PIN>
// or: AnalogReadPinF<PIN, PIN_MODE>
// returns INTEGER, 0-32768 depending on input reading.
// PIN: int, pin you want your style to respond to
Expand All @@ -35,6 +35,7 @@ using ReadPinF = SingleValueAdapter<ReadPinSVF<pin, pin_mode>>;
// * may not update every run() call
// * pin modes other than INPUT may not be supported,
// * Only analog-capable pins will work.

template<int pin, int pin_mode = INPUT>
class AnalogReadPinSVF {
public:
Expand Down
1 change: 1 addition & 0 deletions functions/slice.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// This is very similar to how the POV blade works, but instead of
// using a large data blob as input, it just uses another function
// as input.

class SmokeDF {
public:
float iTime = 0.0;
Expand Down
3 changes: 3 additions & 0 deletions functions/sound_level.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Usage: SmoothSoundLevel
// Returns 0-32768 based on sound level.
// returned value: INTEGER

class SmoothSoundLevelSVF {
public:
void run(BladeBase* blade) {}
Expand All @@ -18,6 +19,7 @@ using SmoothSoundLevel = SingleValueAdapter<SmoothSoundLevelSVF>;
// Usage: NoisySoundLevel
// Returns 0-32768 based on sound level.
// returned value: INTEGER

class NoisySoundLevelSVF {
public:
void run(BladeBase* blade) {}
Expand All @@ -33,6 +35,7 @@ using NoisySoundLevel = SingleValueAdapter<NoisySoundLevelSVF>;
// This function is now used to implement the
// AudioFlicker<> style, don't change it.
// returned value: INTEGER

class NoisySoundLevelCompatSVF {
public:
void run(BladeBase* blade) {}
Expand Down
2 changes: 2 additions & 0 deletions functions/swing_speed.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// Usage: SwingSpeed<MAX>
// Returns 0-32768 based on swing speed
// returned value: INTEGER

template<class MAX>
class SwingSpeedSVF {
public:
Expand All @@ -29,6 +30,7 @@ using SwingSpeed = SwingSpeedX<Int<MAX>>;
// Returns 0-32768 based on swing acceleration
// MAX defaults to 150
// returned value: INTEGER

template<class MAX = Int<130>>
class SwingAccelerationSVF {
public:
Expand Down
2 changes: 0 additions & 2 deletions styles/.cvsignore

This file was deleted.

5 changes: 3 additions & 2 deletions styles/inout_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "../transitions/base.h"


// InOutHelperX<BASE, EXTENSION, OFF_COLOR>
// Usage: InOutHelperX<BASE, EXTENSION, OFF_COLOR>
// BASE, OFF_COLOR: COLOR
// EXTENSION: FUNCTION
// return value: COLOR
Expand Down Expand Up @@ -40,7 +40,8 @@ template<class T, int OUT_MILLIS, int IN_MILLIS, int EXPLODE_MILLIS, class OFF_C
using InOutHelperTD = InOutHelperX<T, InOutFuncTD<OUT_MILLIS, IN_MILLIS, EXPLODE_MILLIS>, OFF_COLOR>;


// InOutTr<BASE, OUT_TRANSITION, IN_TRANSITION, OFF_COLOR>
// Usage: InOutTr<BASE, OUT_TRANSITION, IN_TRANSITION, OFF_COLOR>
// OR: InOutTrL<OUT_TRANSITION, IN_TRANSITION, OFF_COLOR>
// BASE, OFF_COLOR: COLOR
// OUT_TRANSITION, IN_TRANSITION: TRANSITION
// return value: COLOR
Expand Down
4 changes: 2 additions & 2 deletions styles/inout_sparktip.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef STYLES_INOUT_SPARKTIP_H
#define STYLES_INOUT_SPARKTIP_H
// Usage: InOutHelper<BASE, OUT_MILLIS, IN_MILLIS>
// or: InOutHelper<BASE, OUT_MILLIS, IN_MILLIS, SPARK_COLOR>

// Usage: InOutSparkTip<BASE, OUT_MILLIS, IN_MILLIS, SPARK_COLOR>
// BASE, SPARK_COLOR: COLOR
// OUT_MILLIS, IN_MILLIS: a number
// return value: COLOR
Expand Down
8 changes: 5 additions & 3 deletions styles/pixelate.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#ifndef STYLES_PIXELATE_H
#define STYLES_PIXELATE_H

// Pixelate a style

// Usage: PixelateX<COLOR, PIXEL_SIZE_FUNC>
// Usage: Pixelate<COLOR, PIXEL_SIZE>
// OR: Pixelate<COLOR, PIXEL_SIZE>
// COLOR: COLOR - color values to pixelate
// PIXEL_SIZE_FUNC: FUNCTION size of pixelation (defaults to 2)
// PIXEL_SIZE: NUMBER size of pixelation (defaults to 2)
// Returns: COLOR

// Pixelate a style.
// If you have a blade that has too many LEDs to run fast, you
// cause Pixelate<COLOR> to make it run faster, since it will
// can use Pixelate<COLOR> to make it run faster, since it will
// only calculate "COLOR" half as many times.
// It can also be used as an effect of course.

Expand Down
1 change: 1 addition & 0 deletions styles/pov.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// TODO(hubbe): Make it work with FastLED
#if defined(ENABLE_WS2811)


/*
This style draws images in the air if you swing the saber
carefully back and forth. Unfortunately you can't really see
Expand Down
2 changes: 1 addition & 1 deletion styles/random_blink.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef STYLES_RANDOM_BLINK_H
#define STYLES_RANDOM_BLINK_H

// usage: RandomBlink<MILLIHZ, COLOR1, COLOR2>
// Usage: RandomBlink<MILLIHZ, COLOR1, COLOR2>
// or: RandomBlinkX<MILLIHZ_CLASS, COLOR1, COLOR2>
// or: RandomBlinkL<MILLIHZ_CLASS, COLOR1>
// MILLIHZ: integer
Expand Down
4 changes: 3 additions & 1 deletion styles/remap.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#ifndef STYLES_REMAP_H
#define STYLES_REMAP_H

// Remap, remap LED positions

// Usage: Remap<F,COLOR>
// F: FUNCTION - the remapping function
// COLOR: COLOR - color values to remap
// Returns: COLOR

// Remap LED positions
// F is a function which returns values between 0 and 32768
// For each pixel, we'll call F and read the corresponding
// location COLOR, with interpolation.
Expand Down
Loading

0 comments on commit e9f7486

Please sign in to comment.