-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lcd.java
122 lines (107 loc) · 3.2 KB
/
Lcd.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package ev3.exercises.library;
import lejos.hardware.Brick;
import lejos.hardware.BrickFinder;
import lejos.hardware.lcd.Font;
import lejos.hardware.lcd.TextLCD;;
public class Lcd
{
private static Brick brick = BrickFinder.getLocal();
private static TextLCD lcd = brick.getTextLCD(Font.getFont(0, 0, Font.SIZE_MEDIUM));
//private static GraphicsLCD g = brick.getGraphicsLCD();
public static final int MAXCHARS = lcd.getTextWidth();
public static final int MAXLINES = lcd.getTextHeight();
// Private constructor means this class cannot be instantiated. All access is static.
private Lcd()
{
}
/**
* Returns reference to underlying TextLCD object.
* @return Refernce to internal TextLCD object.
*/
public static TextLCD getTextLCD()
{
return lcd;
}
/**
* Clear the LCD of any text. Does not clear data written with
* System.out.println.
*/
public static void clear()
{
lcd.clear();
lcd.refresh();
}
/**
* Shift text lines up one line.
*/
public static void scroll()
{
lcd.scroll();
}
/**
* Clear LCD text line. Does not clear data written with
* System.out.println.
* @param line Line to clear, 1-based.
*/
public static void clear(int line)
{
lcd.clear(line - 1);
lcd.refresh();
}
/**
* Clears specific characters in an LCD text line. Does not clear data written with
* System.out.println.
* @param line Line to clear, 1-based.
* @param col Column to start clearing, 1-based.
* @param len Number of columns to clear.
*/
public static void clear(int line, int col, int len)
{
lcd.clear(col - 1, line - 1, len);
lcd.refresh();
}
/**
* Print a String to specified text line.
* @param line Line to print on, 1-based.
* @param message String to print.
*/
public static void print(int line, String message)
{
lcd.drawString(message, 0, line - 1);
lcd.refresh();
}
/**
* Print a String to specified text line.
* @param line Line to print on, 1-based.
* @param message String to print with optional format specifiers for listed parameters.
* @param parms Parameter list matching format specifiers.
*/
public static void print(int line, String message, Object... parms)
{
lcd.drawString(String.format(message, parms), 0, line - 1);
lcd.refresh();
}
/**
* Print a String to the specified text line starting at the specified column.
* @param line Line to print on, 1-based
* @param col Column to start printing on, 1-based.
* @param message String to print.
*/
public static void print(int line, int col, String message)
{
lcd.drawString(message, col - 1, line - 1);
lcd.refresh();
}
/**
* Print a String to the specified text line starting at the specified column.
* @param line Line to print on, 1-based
* @param col Column to start printing on, 1-based.
* @param message String to print with optional format specifiers for listed parameters.
* @param parms Parameter list matching format specifiers.
*/
public static void print(int line, int col, String message, Object... parms)
{
lcd.drawString(String.format(message, parms), col - 1, line - 1);
lcd.refresh();
}
}