Skip to content

Commit

Permalink
removed brt from begin(), added setBrightness function
Browse files Browse the repository at this point in the history
  • Loading branch information
so1der committed Jul 26, 2023
1 parent 34640d4 commit 3c38105
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
38 changes: 21 additions & 17 deletions PT6314.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,14 @@ void PT6314::init(uint8_t sck, uint8_t stb, uint8_t si)
_displayfunction = VFD_FUNCTIONSET | VFD_8BITMODE | VFD_1LINE | VFD_BRT_100;
}

void PT6314::begin(uint8_t cols, uint8_t rows, uint8_t brt)
void PT6314::begin(uint8_t cols, uint8_t rows)
{
_brt = brt;
_numlines = rows;
if (_numlines > 1)
{
_displayfunction |= VFD_2LINE;
}

switch (_brt)
{
case 100:
_displayfunction |= VFD_BRT_100;
case 75:
_displayfunction |= VFD_BRT_75;
break;
case 50:
_displayfunction |= VFD_BRT_50;
break;
case 25:
_displayfunction |= VFD_BRT_25;
break;
}

_displaycontrol = VFD_DISPLAYCONTROL | VFD_DISPLAYON | VFD_CURSOROFF | VFD_BLINKOFF;

_displaymode = VFD_ENTRYMODESET | VFD_INCREMENT | VFD_CURSORSHIFTENABLED;
Expand Down Expand Up @@ -140,6 +124,26 @@ void PT6314::setCursor(uint8_t col, uint8_t row)
send(COMMAND, VFD_SETDDRAMADDR | position);
}

void PT6314::setBrightness(uint8_t brt)
{
switch (brt)
{
case 100:
_displayfunction |= VFD_BRT_100;
break;
case 75:
_displayfunction |= VFD_BRT_75;
break;
case 50:
_displayfunction |= VFD_BRT_50;
break;
case 25:
_displayfunction |= VFD_BRT_25;
break;
}
send(COMMAND, _displayfunction);
}

inline size_t PT6314::write(uint8_t value)
{
send(DATA, value);
Expand Down
4 changes: 2 additions & 2 deletions PT6314.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class PT6314 : public Print
public:
PT6314(uint8_t sck, uint8_t stb, uint8_t si);
void init(uint8_t sck, uint8_t stb, uint8_t si);
void begin(uint8_t cols, uint8_t rows, uint8_t brt = 100);
void begin(uint8_t cols, uint8_t rows);

void clear();
void home();
Expand All @@ -65,9 +65,9 @@ class PT6314 : public Print
void noCursor();
void cursor();
void setCursor(uint8_t, uint8_t);
void setBrightness(uint8_t brt);
void createChar(uint8_t, uint8_t[]);

void sendtoVFD(uint8_t);
virtual size_t write(uint8_t);

using Print::write;
Expand Down

0 comments on commit 3c38105

Please sign in to comment.