MCPcopy Create free account
hub / github.com/bmorcelli/Launcher / _setBrightness

Function _setBrightness

boards/elecrow/interface.cpp:49–65  ·  view source on GitHub ↗

** Function: setBrightness ** location: settings.cpp ** set brightness value **********************************************************************/

Source from the content-addressed store, hash-verified

47** set brightness value
48**********************************************************************/
49void _setBrightness(uint8_t brightval) {
50 int dutyCycle;
51 if (brightval == 100) dutyCycle = 250;
52 else if (brightval == 75) dutyCycle = 130;
53 else if (brightval == 50) dutyCycle = 70;
54 else if (brightval == 25) dutyCycle = 20;
55 else if (brightval == 0) dutyCycle = 0;
56 else dutyCycle = ((brightval * 250) / 100);
57
58 log_i("dutyCycle for bright 0-255: %d", dutyCycle);
59 if (!ledcWrite(TFT_BL, dutyCycle)) {
60 launcherConsolePrintf("%s\n", String("Failed to set brightness").c_str());
61 ledcDetach(TFT_BL);
62 ledcAttach(TFT_BL, TFT_BRIGHT_FREQ, TFT_BRIGHT_Bits);
63 ledcWrite(TFT_BL, dutyCycle);
64 }
65}
66
67/*********************************************************************
68** Function: InputHandler

Callers

nothing calls this directly

Calls 1

launcherConsolePrintfFunction · 0.85

Tested by

no test coverage detected