Lumitronix_Iflex_Pro_Workshop
Library to interact with the iFlexPro
LUMITRONIX_iFlexWorkshop_Display.h
Go to the documentation of this file.
1 #ifndef HEADER_LUMITRONIX_IFLEX_WORKSHOP_DISPLAY
2 #define HEADER_LUMITRONIX_IFLEX_WORKSHOP_DISPLAY
3 
4 
5 #include <Arduino.h>
6 #include <LiquidCrystal.h>
7 #include <Print.h>
8 
9 
14 static constexpr auto LUMITRONIX_IFLEX_WORKSHOP_DISPLAY_RS_PIN{16};
15 static constexpr auto LUMITRONIX_IFLEX_WORKSHOP_DISPLAY_EN_PIN{17};
16 static constexpr auto LUMITRONIX_IFLEX_WORKSHOP_DISPLAY_D4_PIN{18};
17 static constexpr auto LUMITRONIX_IFLEX_WORKSHOP_DISPLAY_D5_PIN{19};
18 static constexpr auto LUMITRONIX_IFLEX_WORKSHOP_DISPLAY_D6_PIN{7};
19 static constexpr auto LUMITRONIX_IFLEX_WORKSHOP_DISPLAY_D7_PIN{6};
20 static constexpr auto LUMITRONIX_IFLEX_WORKSHOP_DISPLAY_COLUMNS{16};
21 static constexpr auto LUMITRONIX_IFLEX_WORKSHOP_DISPLAY_ROWS{2};
22 
23 
25 private:
26  LiquidCrystal lcd;
27  String oldLineOne{""};
28  String oldLineTwo{""};
29 
30 public:
32  LUMITRONIX_IFLEX_WORKSHOP_DISPLAY_RS_PIN,
33  LUMITRONIX_IFLEX_WORKSHOP_DISPLAY_EN_PIN,
34  LUMITRONIX_IFLEX_WORKSHOP_DISPLAY_D4_PIN,
35  LUMITRONIX_IFLEX_WORKSHOP_DISPLAY_D5_PIN,
36  LUMITRONIX_IFLEX_WORKSHOP_DISPLAY_D6_PIN,
37  LUMITRONIX_IFLEX_WORKSHOP_DISPLAY_D7_PIN
38  } {}
39 
40  void Begin() {
41  lcd.begin(
42  LUMITRONIX_IFLEX_WORKSHOP_DISPLAY_COLUMNS,
43  LUMITRONIX_IFLEX_WORKSHOP_DISPLAY_ROWS
44  );
45  lcd.clear();
46  }
47 
48 
49  /* Clears the display and prints the text while making sure to only
50  * refresh when necessary
51  */
52  void Set(String const& newLineOne, String const& newLineTwo) {
53 
54  /* Skip unnecessary refreshes
55  */
56  if ((oldLineOne == newLineOne) && (oldLineTwo == newLineTwo)) {
57  return;
58  }
59 
60  lcd.clear();
61 
62  lcd.setCursor(0, 0);
63  lcd.print(newLineOne);
64 
65  lcd.setCursor(0, 1);
66  lcd.print(newLineTwo);
67 
68  oldLineOne = newLineOne;
69  oldLineTwo = newLineTwo;
70  }
71 
72  void Set(char const* newLineOne, char const* newLineTwo) {
73  Set(String{newLineOne}, String{newLineTwo});
74  }
75 
76  void Set(String const& lineOne) {
77  Set(lineOne, String{""});
78  }
79 
80  void Set(char const* lineOne) {
81  Set(lineOne, "");
82  }
83 
84 
85  /* Changes the contents of line one while keeping the contents of line
86  * two unchanged
87  */
88  void SetLineOne(String const& newLineOne) {
89  Set(newLineOne, oldLineTwo);
90  }
91 
92  void SetLineOne(char const* newLineOne) {
93  Set(String{newLineOne}, oldLineTwo);
94  }
95 
96 
97  /* Changes the contents of line tow while keeping the contents of line
98  * one unchanged
99  */
100  void SetLineTwo(String const& newLineTwo) {
101  Set(oldLineOne, newLineTwo);
102  }
103 
104  void SetLineTwo(char const* newLineTwo) {
105  Set(oldLineOne, String{newLineTwo});
106  }
107 };
108 
109 
110 #endif
111 
Definition: LUMITRONIX_iFlexWorkshop_Display.h:24
void Set(String const &lineOne)
Definition: LUMITRONIX_iFlexWorkshop_Display.h:76
void SetLineTwo(String const &newLineTwo)
Definition: LUMITRONIX_iFlexWorkshop_Display.h:100
void Set(char const *newLineOne, char const *newLineTwo)
Definition: LUMITRONIX_iFlexWorkshop_Display.h:72
void SetLineTwo(char const *newLineTwo)
Definition: LUMITRONIX_iFlexWorkshop_Display.h:104
void Set(char const *lineOne)
Definition: LUMITRONIX_iFlexWorkshop_Display.h:80
LUMITRONIX_iFlexWorkshop_Display()
Definition: LUMITRONIX_iFlexWorkshop_Display.h:31
void SetLineOne(char const *newLineOne)
Definition: LUMITRONIX_iFlexWorkshop_Display.h:92
void Begin()
Definition: LUMITRONIX_iFlexWorkshop_Display.h:40
void SetLineOne(String const &newLineOne)
Definition: LUMITRONIX_iFlexWorkshop_Display.h:88
void Set(String const &newLineOne, String const &newLineTwo)
Definition: LUMITRONIX_iFlexWorkshop_Display.h:52