@@ -19,6 +19,8 @@ public class LCD extends JFrame implements ActionListener {
19
19
20
20
boolean graphicalCursorBlinkFlag = false ;
21
21
22
+ boolean debug = false ;
23
+
22
24
//Internal flags
23
25
int cursorPos = 0 ;
24
26
boolean increment = true ;
@@ -106,7 +108,8 @@ public void write(boolean regSel, byte data) {
106
108
} else {
107
109
fourBitMode = true ;
108
110
}
109
- System .out .println ("Function: Four Bit Mode: " +fourBitMode );
111
+ if (debug )
112
+ System .out .println ("Function: Four Bit Mode: " +fourBitMode );
110
113
} else if ((data & 0b00010000) == 0b00010000) {
111
114
//SHIFT
112
115
boolean rightleft = false ;
@@ -121,21 +124,24 @@ public void write(boolean regSel, byte data) {
121
124
//SCREEN
122
125
char [] newCharArray = new char [40 ];
123
126
Arrays .fill (newCharArray , ' ' );
124
- System .out .println ("Shifted screen to the " +(rightleft ? "right." : "left." ));
127
+ if (debug )
128
+ System .out .println ("Shifted screen to the " +(rightleft ? "right." : "left." ));
125
129
} else {
126
130
//CURSOR
127
131
cursorPos += (rightleft ? 1 : -1 );
128
132
if (cursorPos < 0 )
129
133
cursorPos = 0 ;
130
- System .out .println ("Shifted cursor to the " +(rightleft ? "right." : "left." ));
134
+ if (debug )
135
+ System .out .println ("Shifted cursor to the " +(rightleft ? "right." : "left." ));
131
136
}
132
137
} else if ((data & 0b00001000) == 0b00001000) {
133
138
//DISPLAY CONTROL
134
139
if ((data & 0b00000100) == 0b00000100) {
135
140
displayPower = true ;
136
141
} else {
137
142
displayPower = false ;
138
- System .out .println ("Turned the Display off! | " +Integer .toBinaryString (Byte .toUnsignedInt (data )));
143
+ if (debug )
144
+ System .out .println ("Turned the Display off! | " +Integer .toBinaryString (Byte .toUnsignedInt (data )));
139
145
}
140
146
if ((data & 0b00000010) == 0b00000010) {
141
147
cursor = true ;
@@ -147,34 +153,39 @@ public void write(boolean regSel, byte data) {
147
153
} else {
148
154
cursorBlink = false ;
149
155
}
150
- System .out .println ("Display Control: Power: " +displayPower +" Cursor: " +cursor +" Blink: " +cursorBlink );
156
+ if (debug )
157
+ System .out .println ("Display Control: Power: " +displayPower +" Cursor: " +cursor +" Blink: " +cursorBlink );
151
158
} else if ((data & 0b00000100) == 0b00000100) {
152
159
//ENTRY MODE SET
153
160
if ((data & 0b00000010) == 0b00000010) {
154
161
increment = true ;
155
162
} else {
156
163
increment = false ;
157
164
}
158
- System .out .println ("Set Entry Mode: Increment: " +increment );
165
+ if (debug )
166
+ System .out .println ("Set Entry Mode: Increment: " +increment );
159
167
} else if ((data & 0b00000010) == 0b00000010) {
160
168
//RETURN HOME
161
169
cursorPos = 0 ;
162
- System .out .println ("Return Home" );
170
+ if (debug )
171
+ System .out .println ("Return Home" );
163
172
} else if (data == 0b00000001) {
164
173
//CLEAR
165
174
cursorPos = 0 ;
166
175
text = new char [0x50 ];
167
176
for (int i = 0 ; i < 0x50 ; i ++) {
168
177
text [i ] = ' ' ;
169
178
}
170
- System .out .println ("Cleared!" );
179
+ if (debug )
180
+ System .out .println ("Cleared!" );
171
181
}
172
182
} else {
173
183
//DATA
174
184
text [cursorPos ] = (char )data ;
175
185
int prevCursorPos = cursorPos ;
176
186
cursorPos += increment ? 1 : -1 ;
177
- System .out .println ("Data: Wrote " +(char )data +" at " +prevCursorPos );
187
+ if (debug )
188
+ System .out .println ("Data: Wrote " +(char )data +" at " +prevCursorPos );
178
189
}
179
190
}
180
191
0 commit comments