Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Project: Auto brightness
- Profiles
- Profile: Custom Auto Brightness
- Event: Any Sensor [ Output Variables:* Type:5 Interval (ms):3500 Interval Type (Check Help):Throttle Convert Orientation:Off ]
- State: Display State [ Is:On ]
- Enter Task: Anon
- Settings: Abort Existing Task
- A1: Perform Task [
- Name: Automatic Brightness
- Priority: %priority
- Local Variable Passthrough: On ]
- Tasks
- Task: Smooth Brightness Transition
- A1: If [ %LuxAlpha < 0.22 ]
- A2: Display Brightness [
- Level: %CalculatedBrightness ]
- A3: Else
- A4: Variable Set [
- Name: %cur
- To: %BRIGHT ]
- A5: Variable Set [
- Name: %maxSteps
- To: 13
- Do Maths: On
- Max Rounding Digits: 3 ]
- A6: Variable Set [
- Name: %loops
- To: round(1+%LuxAlpha*(%maxSteps-1))
- Do Maths: On
- Max Rounding Digits: 0 ]
- A7: Variable Set [
- Name: %minWait
- To: 50
- Do Maths: On
- Max Rounding Digits: 3 ]
- A8: Variable Set [
- Name: %maxWait
- To: 500
- Do Maths: On
- Max Rounding Digits: 3 ]
- A9: Variable Set [
- Name: %wait
- To: round((1 - %LuxAlpha) * (%maxWait - %minWait) + %minWait)
- Do Maths: On
- Max Rounding Digits: 3 ]
- A10: Variable Set [
- Name: %counter
- To: 0
- Structure Output (JSON, etc): On ]
- A11: Variable Set [
- Name: %CalculatedBrightnessSmooth
- To: %cur + (%counter/%loops) * (%CalculatedBrightness - %cur)
- Do Maths: On
- Max Rounding Digits: 3 ]
- A12: Display Brightness [
- Level: %CalculatedBrightnessSmooth
- Disable Safeguard: On ]
- A13: Wait [
- MS: %wait
- Seconds: 0
- Minutes: 0
- Hours: 0
- Days: 0 ]
- A14: Variable Set [
- Name: %counter
- To: %counter + 1
- Do Maths: On
- Max Rounding Digits: 3
- Structure Output (JSON, etc): On ]
- A15: Goto [
- Type: Action Number
- Number: 11 ]
- If [ %counter < %loops ]
- A16: Flash [
- Text: Loops: %loops, wait time: %wait ms
- Dismiss On Click: On ]
- If [ %Debug2 ~ on ]
- Task: Automatic Brightness
- A1: Multiple Variables Set [
- Names: %MinBrightness=0
- %MaxBrightness=255
- %BrightnessOffset=0
- %BrightnessScale=1
- Values Splitter: =
- Do Maths: On
- Max Rounding Digits: 1
- Keep Existing: On ]
- A2: Variable Set [
- Name: %SmoothedLux
- To: %as_values1
- Do Maths: On
- Max Rounding Digits: 3
- Structure Output (JSON, etc): On ]
- If [ %SmoothedLux !Set ]
- A3: Variable Set [
- Name: %LuxDelta
- To: abs(%as_values1 - %SmoothedLux)
- Do Maths: On
- Max Rounding Digits: 3
- Structure Output (JSON, etc): On ]
- A4: Variable Set [
- Name: %LuxAlpha
- To: 1-e^(-0.15*%LuxDelta^0.33)
- Do Maths: On
- Max Rounding Digits: 2
- Structure Output (JSON, etc): On ]
- A5: Variable Set [
- Name: %SmoothedLux
- To: (%as_values1 * %LuxAlpha) + (%SmoothedLux * (1 - %LuxAlpha))
- Do Maths: On
- Max Rounding Digits: 0
- Structure Output (JSON, etc): On ]
- A6: If [ %SmoothedLux < 50 ]
- A7: Variable Set [
- Name: %mapped_brightness
- To: 2*sqrt(%SmoothedLux)
- Do Maths: On
- Max Rounding Digits: 3
- Structure Output (JSON, etc): On ]
- A8: Else
- If [ %SmoothedLux < 15000 ]
- A9: Variable Set [
- Name: %mapped_brightness
- To: 14.19+8.5*((%SmoothedLux-42)^0.33-8^0.33)
- Do Maths: On
- Max Rounding Digits: 3
- Structure Output (JSON, etc): On ]
- A10: Else
- A11: Variable Set [
- Name: %mapped_brightness
- To: 255-(3200/(%SmoothedLux))*255
- Do Maths: On
- Max Rounding Digits: 3
- Structure Output (JSON, etc): On ]
- A12: End If
- A13: Variable Set [
- Name: %CalculatedBrightness
- To: %mapped_brightness * %BrightnessScale + %BrightnessOffset
- Do Maths: On
- Max Rounding Digits: 3 ]
- A14: If [ %CalculatedBrightness < %MinBrightness ]
- A15: Variable Set [
- Name: %CalculatedBrightness
- To: %MinBrightness ]
- A16: End If
- A17: If [ %CalculatedBrightness > %MaxBrightness ]
- A18: Variable Set [
- Name: %CalculatedBrightness
- To: %MaxBrightness ]
- A19: End If
- A20: Perform Task [
- Name: Smooth Brightness Transition
- Priority: %priority
- Structure Output (JSON, etc): On ]
- If [ %Debug neq on ]
- A21: Display Brightness [
- Level: %CalculatedBrightness
- Disable Safeguard: On ]
- If [ %Debug ~ on ]
- A22: Variable Set [
- Name: %BrightnessPercentage
- To: (%CalculatedBrightness/255)*100
- Do Maths: On
- Max Rounding Digits: 1
- Structure Output (JSON, etc): On ]
- A23: Flash [
- Text: Brightness: %BrightnessPercentage% | Smoothed: %SmoothedLux lux |
- Delta: %LuxDelta | Alpha: %LuxAlpha
- Long: On
- Tasker Layout: On
- Background Colour: #FF000000
- Continue Task Immediately: On
- Dismiss On Click: On
- Position: TopLeft,5,12 ]
- If [ %Debug ~ on ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement