Night Light Mode: Scaling the Night Light

Home

Current Objective: Scaling the Night Light

Requirements

  1. Ensure you understand each step before moving on.
  2. Write code for each step as you go.
  3. Cleanly format your code.
  4. Test your code at the end of each page.

Scaling the Dynamic Range of the Knob for Night Light Mode

Currently, the Night Light Mode mode knobValue goes from the variable (minimum value) to the variable (maximum value).

In the definition of getOnTimeUsingKnob:

  1. Declare a const float variable named scaledKnobValue and assign it to be the difference between knobValue and the nightLightMinValue with the statement
  2. Replace the value of knobRatio with the ratio of scaledKnobValue to nightLightRange so that the statement is now
  3. Test your code and notice that the brightness drops to 0 when entering nightLightMode.
  4. Fix this problem by inverting the knobRatio by adding the statement knobRatio = 1 - knobRatio;

Make sure you test your code!

Change gamma and see the result. Choose a gamma that you like.

Back