Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* This class extends the standard LCD20x4 class to add extra functionality,
- * currently the only one writes text to the LCD not line by line.
- * You can still use the LCD as you would if you used the standard class.
- */
- public class BrickletLCD20x4Writer extends com.tinkerforge.BrickletLCD20x4
- {
- private boolean debug = false;
- public BrickletLCD20x4Writer(String uid) {
- super(uid);
- }
- public void writeText(String text)
- {
- String regex_pattern = "(?<=\\G.{20})";
- int chars = text.length();
- if (chars <= 20)
- {
- this.writeLine((short) 0, (short) 0, text);
- } else
- {
- String[] lines;
- lines = text.split(regex_pattern);
- for (int i = 0; i < lines.length; i++)
- {
- if (i <= 3)
- {
- this.writeLine((short) i, (short) 0, lines[i]);
- } else
- {
- if (debug = true)
- {
- System.out.println("Error: No more free lines to write to.");
- System.out.println("Data: " + lines[i]);
- }
- }
- }
- }
- }
- private void setDebugStatus(boolean status) {
- debug = status;
- }
- private boolean getDebugStatus() {
- return debug;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment