Advertisement
Guest User

Tasker automatic brightness

a guest
Jun 11th, 2025
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.02 KB | Software | 0 0
  1. Project: Auto brightness
  2.  
  3. Profiles
  4. Profile: Custom Auto Brightness
  5. Event: Any Sensor [ Output Variables:* Type:5 Interval (ms):3500 Interval Type (Check Help):Throttle Convert Orientation:Off ]
  6. State: Display State [ Is:On ]
  7.  
  8.  
  9.  
  10. Enter Task: Anon
  11. Settings: Abort Existing Task
  12.  
  13. A1: Perform Task [
  14. Name: Automatic Brightness
  15. Priority: %priority
  16. Local Variable Passthrough: On ]
  17.  
  18.  
  19.  
  20. Tasks
  21. Task: Smooth Brightness Transition
  22.  
  23. A1: If [ %LuxAlpha < 0.22 ]
  24.  
  25. A2: Display Brightness [
  26. Level: %CalculatedBrightness ]
  27.  
  28. A3: Else
  29.  
  30. A4: Variable Set [
  31. Name: %cur
  32. To: %BRIGHT ]
  33.  
  34. A5: Variable Set [
  35. Name: %maxSteps
  36. To: 13
  37. Do Maths: On
  38. Max Rounding Digits: 3 ]
  39.  
  40. A6: Variable Set [
  41. Name: %loops
  42. To: round(1+%LuxAlpha*(%maxSteps-1))
  43. Do Maths: On
  44. Max Rounding Digits: 0 ]
  45.  
  46. A7: Variable Set [
  47. Name: %minWait
  48. To: 50
  49. Do Maths: On
  50. Max Rounding Digits: 3 ]
  51.  
  52. A8: Variable Set [
  53. Name: %maxWait
  54. To: 500
  55. Do Maths: On
  56. Max Rounding Digits: 3 ]
  57.  
  58. A9: Variable Set [
  59. Name: %wait
  60. To: round((1 - %LuxAlpha) * (%maxWait - %minWait) + %minWait)
  61. Do Maths: On
  62. Max Rounding Digits: 3 ]
  63.  
  64. A10: Variable Set [
  65. Name: %counter
  66. To: 0
  67. Structure Output (JSON, etc): On ]
  68.  
  69. A11: Variable Set [
  70. Name: %CalculatedBrightnessSmooth
  71. To: %cur + (%counter/%loops) * (%CalculatedBrightness - %cur)
  72. Do Maths: On
  73. Max Rounding Digits: 3 ]
  74.  
  75. A12: Display Brightness [
  76. Level: %CalculatedBrightnessSmooth
  77. Disable Safeguard: On ]
  78.  
  79. A13: Wait [
  80. MS: %wait
  81. Seconds: 0
  82. Minutes: 0
  83. Hours: 0
  84. Days: 0 ]
  85.  
  86. A14: Variable Set [
  87. Name: %counter
  88. To: %counter + 1
  89. Do Maths: On
  90. Max Rounding Digits: 3
  91. Structure Output (JSON, etc): On ]
  92.  
  93. A15: Goto [
  94. Type: Action Number
  95. Number: 11 ]
  96. If [ %counter < %loops ]
  97.  
  98. A16: Flash [
  99. Text: Loops: %loops, wait time: %wait ms
  100. Dismiss On Click: On ]
  101. If [ %Debug2 ~ on ]
  102.  
  103.  
  104.  
  105. Task: Automatic Brightness
  106.  
  107. A1: Multiple Variables Set [
  108. Names: %MinBrightness=0
  109. %MaxBrightness=255
  110. %BrightnessOffset=0
  111. %BrightnessScale=1
  112. Values Splitter: =
  113. Do Maths: On
  114. Max Rounding Digits: 1
  115. Keep Existing: On ]
  116.  
  117. A2: Variable Set [
  118. Name: %SmoothedLux
  119. To: %as_values1
  120. Do Maths: On
  121. Max Rounding Digits: 3
  122. Structure Output (JSON, etc): On ]
  123. If [ %SmoothedLux !Set ]
  124.  
  125. A3: Variable Set [
  126. Name: %LuxDelta
  127. To: abs(%as_values1 - %SmoothedLux)
  128. Do Maths: On
  129. Max Rounding Digits: 3
  130. Structure Output (JSON, etc): On ]
  131.  
  132. A4: Variable Set [
  133. Name: %LuxAlpha
  134. To: 1-e^(-0.15*%LuxDelta^0.33)
  135. Do Maths: On
  136. Max Rounding Digits: 2
  137. Structure Output (JSON, etc): On ]
  138.  
  139. A5: Variable Set [
  140. Name: %SmoothedLux
  141. To: (%as_values1 * %LuxAlpha) + (%SmoothedLux * (1 - %LuxAlpha))
  142. Do Maths: On
  143. Max Rounding Digits: 0
  144. Structure Output (JSON, etc): On ]
  145.  
  146. A6: If [ %SmoothedLux < 50 ]
  147.  
  148. A7: Variable Set [
  149. Name: %mapped_brightness
  150. To: 2*sqrt(%SmoothedLux)
  151. Do Maths: On
  152. Max Rounding Digits: 3
  153. Structure Output (JSON, etc): On ]
  154.  
  155. A8: Else
  156. If [ %SmoothedLux < 15000 ]
  157.  
  158. A9: Variable Set [
  159. Name: %mapped_brightness
  160. To: 14.19+8.5*((%SmoothedLux-42)^0.33-8^0.33)
  161. Do Maths: On
  162. Max Rounding Digits: 3
  163. Structure Output (JSON, etc): On ]
  164.  
  165. A10: Else
  166.  
  167. A11: Variable Set [
  168. Name: %mapped_brightness
  169. To: 255-(3200/(%SmoothedLux))*255
  170. Do Maths: On
  171. Max Rounding Digits: 3
  172. Structure Output (JSON, etc): On ]
  173.  
  174. A12: End If
  175.  
  176. A13: Variable Set [
  177. Name: %CalculatedBrightness
  178. To: %mapped_brightness * %BrightnessScale + %BrightnessOffset
  179. Do Maths: On
  180. Max Rounding Digits: 3 ]
  181.  
  182. A14: If [ %CalculatedBrightness < %MinBrightness ]
  183.  
  184. A15: Variable Set [
  185. Name: %CalculatedBrightness
  186. To: %MinBrightness ]
  187.  
  188. A16: End If
  189.  
  190. A17: If [ %CalculatedBrightness > %MaxBrightness ]
  191.  
  192. A18: Variable Set [
  193. Name: %CalculatedBrightness
  194. To: %MaxBrightness ]
  195.  
  196. A19: End If
  197.  
  198. A20: Perform Task [
  199. Name: Smooth Brightness Transition
  200. Priority: %priority
  201. Structure Output (JSON, etc): On ]
  202. If [ %Debug neq on ]
  203.  
  204. A21: Display Brightness [
  205. Level: %CalculatedBrightness
  206. Disable Safeguard: On ]
  207. If [ %Debug ~ on ]
  208.  
  209. A22: Variable Set [
  210. Name: %BrightnessPercentage
  211. To: (%CalculatedBrightness/255)*100
  212. Do Maths: On
  213. Max Rounding Digits: 1
  214. Structure Output (JSON, etc): On ]
  215.  
  216. A23: Flash [
  217. Text: Brightness: %BrightnessPercentage% | Smoothed: %SmoothedLux lux |
  218. Delta: %LuxDelta | Alpha: %LuxAlpha
  219. Long: On
  220. Tasker Layout: On
  221. Background Colour: #FF000000
  222. Continue Task Immediately: On
  223. Dismiss On Click: On
  224. Position: TopLeft,5,12 ]
  225. If [ %Debug ~ on ]
Tags: Tasker
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement