From 6bee6ade422a0c8971bc20e13f338608d9dc861d Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sun, 29 Oct 2017 02:20:54 -0400 Subject: [PATCH] Add RedGreenBlueLight, tweaks to light implementation --- include/components.hpp | 12 ++++++++---- src/engine.cpp | 4 +++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/components.hpp b/include/components.hpp index 5eba281b..f80fa971 100644 --- a/include/components.hpp +++ b/include/components.hpp @@ -454,8 +454,15 @@ struct GreenRedLight : ColorLightWidget { } }; +struct RedGreenBlueLight : ColorLightWidget { + RedGreenBlueLight() { + addColor(COLOR_RED); + addColor(COLOR_GREEN); + addColor(COLOR_BLUE); + } +}; + -/** 5mm diameter */ template struct LargeLight : BASE { LargeLight() { @@ -463,7 +470,6 @@ struct LargeLight : BASE { } }; -/** 3mm diameter */ template struct MediumLight : BASE { MediumLight() { @@ -471,7 +477,6 @@ struct MediumLight : BASE { } }; -/** 2mm diameter */ template struct SmallLight : BASE { SmallLight() { @@ -479,7 +484,6 @@ struct SmallLight : BASE { } }; -/** 1mm diameter */ template struct TinyLight : BASE { TinyLight() { diff --git a/src/engine.cpp b/src/engine.cpp index c4a8009a..d587e575 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -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); }