blucontrol 0.4.0.0 → 0.4.1.0
raw patch · 7 files changed
+50/−33 lines, 7 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Blucontrol: [coerceValue] :: ConfigControl m g r -> GammaValue g -> RecolorValue r
- Blucontrol.Main: [coerceValue] :: ConfigControl m g r -> GammaValue g -> RecolorValue r
- Blucontrol.RGB: mapRGB :: (a -> b) -> RGB a -> RGB b
- Blucontrol.RGB: word8ToFloat :: Word8 -> Float
- Blucontrol.RGB.Temperature: toRGBWord8 :: Temperature -> RGB Word8
+ Blucontrol.CompatibleValues: class CompatibleValues a b
+ Blucontrol.CompatibleValues: convertValue :: CompatibleValues a b => a -> b
+ Blucontrol.CompatibleValues: instance Blucontrol.CompatibleValues.CompatibleValues a a
+ Blucontrol.RGB: instance Blucontrol.CompatibleValues.CompatibleValues (Blucontrol.RGB.RGB GHC.Word.Word8) (Blucontrol.RGB.RGB GHC.Types.Float)
+ Blucontrol.RGB.Temperature: instance Blucontrol.CompatibleValues.CompatibleValues (Blucontrol.RGB.RGB GHC.Word.Word8) a => Blucontrol.CompatibleValues.CompatibleValues Blucontrol.RGB.Temperature.Temperature a
- Blucontrol: ConfigControl :: (forall a. m a -> IO a) -> (forall a. g a -> IO (StM g a)) -> (forall a. r a -> IO (StM r a)) -> (GammaValue g -> RecolorValue r) -> ConfigControl m g r
+ Blucontrol: ConfigControl :: (forall a. m a -> IO a) -> (forall a. g a -> IO (StM g a)) -> (forall a. r a -> IO (StM r a)) -> ConfigControl m g r
- Blucontrol: type BlucontrolConstraints m g r = (ControlConstraint m (StM g (StM r ())), MonadControl m, MonadBaseControl IO g, MonadBaseControl IO r, MonadGamma g, MonadRecolor r)
+ Blucontrol: type BlucontrolConstraints m g r = (ControlConstraint m (StM g (StM r ())), MonadControl m, MonadBaseControl IO g, MonadBaseControl IO r, MonadGamma g, MonadRecolor r, CompatibleValues (GammaValue g) (RecolorValue r))
- Blucontrol.Main: ConfigControl :: (forall a. m a -> IO a) -> (forall a. g a -> IO (StM g a)) -> (forall a. r a -> IO (StM r a)) -> (GammaValue g -> RecolorValue r) -> ConfigControl m g r
+ Blucontrol.Main: ConfigControl :: (forall a. m a -> IO a) -> (forall a. g a -> IO (StM g a)) -> (forall a. r a -> IO (StM r a)) -> ConfigControl m g r
- Blucontrol.Main: type BlucontrolConstraints m g r = (ControlConstraint m (StM g (StM r ())), MonadControl m, MonadBaseControl IO g, MonadBaseControl IO r, MonadGamma g, MonadRecolor r)
+ Blucontrol.Main: type BlucontrolConstraints m g r = (ControlConstraint m (StM g (StM r ())), MonadControl m, MonadBaseControl IO g, MonadBaseControl IO r, MonadGamma g, MonadRecolor r, CompatibleValues (GammaValue g) (RecolorValue r))
Files
- CHANGELOG.md +5/−0
- Main.hs +0/−2
- blucontrol.cabal +2/−1
- src/Blucontrol/CompatibleValues.hs +9/−0
- src/Blucontrol/Main.hs +3/−2
- src/Blucontrol/RGB.hs +5/−4
- src/Blucontrol/RGB/Temperature.hs +26/−24
CHANGELOG.md view
@@ -1,5 +1,10 @@ # Revision history for blucontrol +## 0.4.1.0 *08 Jun 2021*++* Remove field `coerceValue` from `ConfigControl`.+* Add `CompatibleValues` class.+ ## 0.4.0.0 *06 Jun 2021* * Remove `RGB` class.
Main.hs view
@@ -8,7 +8,6 @@ import Blucontrol.Control.Wait import Blucontrol.Gamma.Linear import Blucontrol.Recolor.X-import Blucontrol.RGB import Blucontrol.RGB.Temperature main :: IO ()@@ -16,7 +15,6 @@ where configControl = ConfigControl { runControl = runControlPrintT !> runControlCountT def !> runControlWaitT def , runGamma = runGammaLinearT @Temperature rgbMap , runRecolor = runRecolorXTIO def- , coerceValue = mapRGB word8ToFloat . toRGBWord8 } rgbMap = 00:.00 ==> 4000 :| [ 08:.00 ==> 4600
blucontrol.cabal view
@@ -1,5 +1,5 @@ name: blucontrol-version: 0.4.0.0+version: 0.4.1.0 synopsis: Configurable blue light filter description: This application is a blue light filter, with the main focus on configurability.@@ -25,6 +25,7 @@ library exposed-modules: Blucontrol+ Blucontrol.CompatibleValues Blucontrol.Control Blucontrol.Control.Concat Blucontrol.Control.Count
+ src/Blucontrol/CompatibleValues.hs view
@@ -0,0 +1,9 @@+module Blucontrol.CompatibleValues (+ CompatibleValues (..)+) where++class CompatibleValues a b where+ convertValue :: a -> b++instance CompatibleValues a a where+ convertValue = id
src/Blucontrol/Main.hs view
@@ -6,6 +6,7 @@ import Control.Monad.Trans.Control +import Blucontrol.CompatibleValues import Blucontrol.Main.Control import Blucontrol.Main.CLI import Blucontrol.Control@@ -19,16 +20,16 @@ , MonadBaseControl IO r , MonadGamma g , MonadRecolor r+ , CompatibleValues (GammaValue g) (RecolorValue r) ) blucontrol :: BlucontrolConstraints m g r => ConfigControl m g r -> IO () blucontrol c = do launch- runControl c $ loopRecolor (runGamma c) (runRecolor c) (coerceValue c)+ runControl c $ loopRecolor (runGamma c) (runRecolor c) convertValue data ConfigControl m g r = ConfigControl { runControl :: forall a. m a -> IO a , runGamma :: forall a. g a -> IO (StM g a) , runRecolor :: forall a. r a -> IO (StM r a)- , coerceValue :: GammaValue g -> RecolorValue r }
src/Blucontrol/RGB.hs view
@@ -2,8 +2,6 @@ module Blucontrol.RGB ( RGB (..)-, mapRGB-, word8ToFloat ) where import Control.DeepSeq@@ -11,6 +9,8 @@ import Data.Word import GHC.Generics +import Blucontrol.CompatibleValues+ -- | Values for the colors 'red', 'green' and 'blue' data RGB a = RGB { red :: a , green :: a@@ -47,5 +47,6 @@ , blue = f $ blue rgb } -word8ToFloat :: Word8 -> Float-word8ToFloat = (/ fromIntegral (maxBound @Word8)) . fromIntegral+instance CompatibleValues (RGB Word8) (RGB Float) where+ convertValue = mapRGB word8ToFloat+ where word8ToFloat = (/ fromIntegral (maxBound @Word8)) . fromIntegral
src/Blucontrol/RGB/Temperature.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE RecordWildCards, UndecidableInstances #-} module Blucontrol.RGB.Temperature ( Temperature-, toRGBWord8 ) where import Control.DeepSeq@@ -10,6 +9,7 @@ import Data.Word import GHC.Generics +import Blucontrol.CompatibleValues import Blucontrol.RGB -- | Arbitrary precision temperature in Kelvin@@ -25,25 +25,27 @@ instance Default Temperature where def = 6600 --- TODO: Test and implement more accurately. Currently based on blugon. Don't enforce Word8.-toRGBWord8 :: Temperature -> RGB Word8-toRGBWord8 (Temperature temp) = RGB {..}- where red = round . inBounds $- if t <= 66- then 255- else 329.698727446 * ((t - 60) ** (-0.1332047592))- green = round . inBounds $- if t <= 66- then 99.4708025861 * log t - 161.1195681661- else 288.1221695283 * ((t - 60) ** (-0.0755148492))- blue = round . inBounds $- if t <= 0- then 0- else if t >= 66- then 255- else 138.5177312231 * log (t - 10) - 305.0447927307- t = fromRational $ temp / 100 :: Double- inBounds x- | x < 0 = 0- | x > 255 = 255- | otherwise = x+instance CompatibleValues (RGB Word8) a => CompatibleValues Temperature a where+ -- TODO: Test and implement more accurately. Currently based on blugon.+ convertValue = convertValue . toRGBWord8+ where toRGBWord8 :: Temperature -> RGB Word8+ toRGBWord8 (Temperature temp) = RGB {..}+ where red = round . inBounds $+ if t <= 66+ then 255+ else 329.698727446 * ((t - 60) ** (-0.1332047592))+ green = round . inBounds $+ if t <= 66+ then 99.4708025861 * log t - 161.1195681661+ else 288.1221695283 * ((t - 60) ** (-0.0755148492))+ blue = round . inBounds $+ if t <= 0+ then 0+ else if t >= 66+ then 255+ else 138.5177312231 * log (t - 10) - 305.0447927307+ t = fromRational $ temp / 100 :: Double+ inBounds x+ | x < 0 = 0+ | x > 255 = 255+ | otherwise = x