1+ /* *
2+ **************************************************
3+ * @file Frontlight.cpp
4+ * @brief Basic funtions for controling inkplate frontlight
5+ *
6+ * https://github.com/e-radionicacom/Inkplate-Arduino-library
7+ * For support, please reach over forums: forum.e-radionica.com/en
8+ * For more info about the product, please check: www.inkplate.io
9+ *
10+ * This code is released under the GNU Lesser General Public
11+ *License v3.0: https://www.gnu.org/licenses/lgpl-3.0.en.html Please review the
12+ *LICENSE file included with this example. If you have any questions about
13+ *licensing, please contact [email protected] Distributed as-is; no 14+ *warranty is given.
15+ *
16+ * @authors Soldered
17+ ***************************************************/
18+
19+ #include " Frontlight.h"
20+ #include " Inkplate.h"
21+
22+ #if defined(ARDUINO_INKPLATE6PLUS) || defined(ARDUINO_INKPLATE6PLUSV2) || defined(ARDUINO_INKPLATE4TEMPERA) || \
23+ defined (ARDUINO_INKPLATE6FLICK)
24+
25+ /* *
26+ * @brief setFrontlight function sets frontlight intensity for inkplate
27+ *
28+ * @param uint8_t _v
29+ * value to set frontlight to
30+ *
31+ * @note can only be used in inkplate 6PLUS and 4TEMPERA, others don't suport
32+ * frontlight
33+ */
34+ void Frontlight::setBrightness(uint8_t _v)
35+ {
36+ Wire.beginTransmission (0x2E );
37+ Wire.write (0 );
38+ Wire.write (63 - (_v & 0b00111111 ));
39+ Wire.endTransmission ();
40+ }
41+
42+ /* *
43+ * @brief setState function turns frontlight on/off
44+ *
45+ * @param bool _e
46+ * enable value, 1 turns on, 0 off
47+ */
48+ void Frontlight::setState (bool _e)
49+ {
50+ if (_e)
51+ {
52+ _inkplate->internalIO .digitalWrite (FRONTLIGHT_EN, HIGH);
53+ }
54+ else
55+ {
56+ _inkplate->internalIO .digitalWrite (FRONTLIGHT_EN, LOW);
57+ }
58+ }
59+
60+ /* *
61+ * @brief begin function forwards the current inkplate instance to be used inside the class
62+ *
63+ * @param Inkplate* inkplatePtr
64+ * pointer to the instance of the current Inkplate display object
65+ */
66+ void Frontlight::begin (Inkplate* inkplatePtr)
67+ {
68+ _inkplate = inkplatePtr;
69+ }
70+
71+ #endif
0 commit comments