Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 595890d

Browse files
authored
Merge pull request #7 from korstiaanS/add-backlight-function
Added LCD backlight function
2 parents 939a4a9 + 7f3176d commit 595890d

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/M5StamPLC.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,20 @@ void M5_STAMPLC::io_expander_a_init()
6262
ioe.setDirection(5, true);
6363
ioe.setPullMode(5, false);
6464
ioe.setHighImpedance(5, true);
65-
65+
6666
ioe.setDirection(6, true);
6767
ioe.setPullMode(6, false);
6868
ioe.setHighImpedance(6, true);
6969
}
7070

71+
void M5_STAMPLC::setBacklight(bool on)
72+
{
73+
auto& ioe = M5.getIOExpander(0);
74+
75+
ioe.setHighImpedance(7, !on);
76+
ioe.digitalWrite(7, !on); // backlight is active low
77+
}
78+
7179
void M5_STAMPLC::setStatusLight(const uint8_t& r, const uint8_t& g, const uint8_t& b)
7280
{
7381
auto& ioe = M5.getIOExpander(0);

src/M5StamPLC.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ class M5_STAMPLC {
5858
*/
5959
void setStatusLight(const uint8_t& r, const uint8_t& g, const uint8_t& b);
6060

61+
/**
62+
* @brief Control the LCD backlight
63+
*
64+
* @param on true to turn backlight ON, false to turn it OFF
65+
*/
66+
void setBacklight(bool on);
67+
6168
/**
6269
* @brief Read PLC Input
6370
*

0 commit comments

Comments
 (0)