Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

develop a touch interface to provide control over the brightness of various displays on a control surface. Guide me pls

I would like to develop a touch interface to provide control over the brightness of various displays on a control surface ie image, guidance please where do I start

There are three variable brightness settings for different components of the control surface: Buttons, small Display & big display. Each brightness control ranges from 0-100% Each brightness control will indicate its value numerically and visually There is a button that can be used to manually enter Surface Sleep call “Sleep Now”

I do not fully understand your question.

Are you refering to a virtual control surface on a website or app? Or are you referring to a physical control surface that you want to control its inbuilt settings with a website or app?

2 Answers

This is how I would go about doing this:

  • Create a jQuery range slider from 0-100 (Like this for example: https://andreruffert.github.io/rangeslider.js/ )
  • Create a default screen for value 50%.
  • Overlay a div with white background over this screen.
  • Overlay a div with black background also over this screen.
  • When the range slider is at 50% set both overlays opacity to 0%.
  • For every unit under 50% adjust the opacity of the black overlay by 2% (so for example if the range slider is 40% set the black overlay to 20% opacity).
  • Vice versa for the white overlay, increase the opacity by 2% for every 1% the range slider goes over 50%.
  • onClick button that sets the values of the black overlay to 100% for sleep mode will make the screen go completely black.

The above example goes from complete white to black in brightness, but you can adjust the values if you only want it to dim and brighten by for example only increasing the opacity by 1% or less for each 1% above and below 50%, meaning that the overlays will never go to 100% causing complete black or white.

You could go even further and add a screensaver overlay that triggers if no user input has been detected within a set amount of time.

There are many different ways you could go about this, for example if you had a black background screen you could effect the brightness of the font by using RGB color. For example:

p {
   color: rgb(0,255,0);
}

The above would output green font, you could adjust the brightness of the green by adjusting the red and blue value in uniform.

The following is a brighter green.

p {
   color: rgb(100,255,100);
}

The following would be full brightness to white.

p {
   color: rgb(255,255,255);
}

and if you want to make the green darker you can just reduce the green value and leave the red and blue at 0.

Hope this helps :)

I'm referring to a virtual control surface on a website or app.