Skip to content

Commit 95a0834

Browse files
authored
Merge pull request #324 from felixkosmalla/LiquidCrystalAlternative
Added support for alternative LiquidCrystal I2C Library
2 parents 14486c6 + 93e014c commit 95a0834

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

src/menuIO/liquidCrystalOutI2C.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/* -*- C++ -*- */
2+
3+
//for using I2C LiquidCrystal Library provided by
4+
// https://gitlab.com/tandembyte/LCD_I2C
5+
6+
#ifndef RSITE_ARDUINO_MENU_LIQUIDCRYSTALOUT
7+
#define RSITE_ARDUINO_MENU_LIQUIDCRYSTALOUT
8+
#include "../menuDefs.h"
9+
#include <LiquidCrystal_I2C.h>
10+
11+
namespace Menu {
12+
13+
class liquidCrystalOut:public cursorOut {
14+
public:
15+
LiquidCrystal_I2C& device;
16+
inline liquidCrystalOut(LiquidCrystal_I2C& o,idx_t *t,panelsList &p,menuOut::styles s=minimalRedraw)
17+
:cursorOut(t,p,s),device(o) {}
18+
size_t write(uint8_t ch) override {return device.write(ch);}
19+
void clear() override {
20+
device.clear();
21+
panels.reset();
22+
}
23+
void setCursor(idx_t x,idx_t y,idx_t panelNr=0) override {
24+
const panel p=panels[panelNr];
25+
device.setCursor(p.x+x,p.y+y);
26+
}
27+
idx_t startCursor(navRoot& root,idx_t x,idx_t y,bool charEdit,idx_t panelNr=0) override {return 0;}
28+
idx_t endCursor(navRoot& root,idx_t x,idx_t y,bool charEdit,idx_t panelNr=0) override {return 0;}
29+
idx_t editCursor(navRoot& root,idx_t x,idx_t y,bool editing,bool charEdit,idx_t panelNr=0) override {
30+
//text editor cursor
31+
device.noBlink();
32+
device.noCursor();
33+
if (editing) {
34+
device.setCursor(x, y);
35+
if (charEdit) device.cursor();
36+
else device.blink();
37+
}
38+
return 0;
39+
}
40+
};
41+
42+
}//namespace Menu
43+
#endif

0 commit comments

Comments
 (0)