Browse Source

Add RedGreenBlueLight, tweaks to light implementation

tags/v0.5.0
Andrew Belt 7 years ago
parent
commit
6bee6ade42
2 changed files with 11 additions and 5 deletions
  1. +8
    -4
      include/components.hpp
  2. +3
    -1
      src/engine.cpp

+ 8
- 4
include/components.hpp View File

@@ -454,8 +454,15 @@ struct GreenRedLight : ColorLightWidget {
}
};

struct RedGreenBlueLight : ColorLightWidget {
RedGreenBlueLight() {
addColor(COLOR_RED);
addColor(COLOR_GREEN);
addColor(COLOR_BLUE);
}
};


/** 5mm diameter */
template <typename BASE>
struct LargeLight : BASE {
LargeLight() {
@@ -463,7 +470,6 @@ struct LargeLight : BASE {
}
};

/** 3mm diameter */
template <typename BASE>
struct MediumLight : BASE {
MediumLight() {
@@ -471,7 +477,6 @@ struct MediumLight : BASE {
}
};

/** 2mm diameter */
template <typename BASE>
struct SmallLight : BASE {
SmallLight() {
@@ -479,7 +484,6 @@ struct SmallLight : BASE {
}
};

/** 1mm diameter */
template <typename BASE>
struct TinyLight : BASE {
TinyLight() {


+ 3
- 1
src/engine.cpp View File

@@ -35,10 +35,12 @@ static float smoothValue;


float Light::getBrightness() {
return sqrtf(fmaxf(0.0, value));
// Scale by sqrt(2) since the RMS of a rectified sine is 1 / sqrt(2)
return sqrtf(fmaxf(0.0, value) * 2.0);
}

void Light::setBrightnessSmooth(float brightness) {
// lambda = 3 * framerate
value += (brightness * brightness - value) * sampleTime * (60.0 * 3.0);
}



Loading…
Cancel
Save