2 Copyright 2008 Lukas Kropatschek lukas.krop@gmail.com
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2 of
7 the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 //#include "StaticStrings.h"
23 #include <IOManager.h>
24 #include <core/defines.h>
25 #include <SolderManager.h>
27 #define clearViewArea() LCD.drawRect(21, 0, 109, 130, FILL, WHITE);
28 #define clearStatusMsgArea() LCD.drawRect(0,0,19,69,FILL,WHITE);
38 LCD
.putVariable("X:", SolderMgr
.curX
, 100, 5, RED
, WHITE
, 30);
39 LCD
.putVariable("Y:", SolderMgr
.curY
, 90, 5, BLUE
, WHITE
, 30);
49 void SBUI::drawCoordInput()
54 byte xArray
[] = { 0, 0, 0};
55 byte yArray
[] = { 0, 0, 0};
59 LCD
.putChar('X', 65, 5, RED
, WHITE
);
60 LCD
.putChar('Y', 50, 5, BLUE
, WHITE
);
62 LCD
.drawRect(49, 15, 75, 75, FILL
, WHITE
);
64 LCD
.drawRect(64, 15, 75, 75, 0, RED
);
65 LCD
.drawRect(49, 15, 60, 75, 0, GREY
);
69 // acquire PS2 keycode
70 byte ps2
= IOMgr
.getPS2Keycode();
72 // delete the last character and set cursor position accordingly
74 if (ps2
== KEYCODE_BACKSPACE
)
86 // clear with an space char
87 LCD
.putChar(' ', 65, (16 + (6 * xcursor
)), BLACK
, WHITE
);
100 LCD
.putChar(' ', 50, (16 + (6 * ycursor
)), BLACK
, WHITE
);
105 if (ps2
== KEYCODE_TAB
)
107 //Toogle current coordinate input (x/y)
111 LCD
.drawRect(64, 15, 75, 75, 0, GREY
);
112 LCD
.drawRect(49, 15, 60, 75, 0, RED
);
118 LCD
.drawRect(64, 15, 75, 75, 0, RED
);
119 LCD
.drawRect(49, 15, 60, 75, 0, GREY
);
123 if (ps2
== KEYCODE_ENTER
)
135 x
= xArray
[1] + (xArray
[2] * 10);
139 x
= xArray
[0] + (xArray
[1] * 10) + (xArray
[2] * 100);
155 y
= yArray
[1] + (yArray
[2] * 10);
159 y
= yArray
[0] + (yArray
[1] * 10) + (yArray
[2] * 10);
167 //LCD.putVariable("x:", x, 35, 5, BLACK, WHITE, 30);
168 //LCD.putVariable("y:", y, 25, 5, BLACK, WHITE, 30);
169 SolderMgr
.goTo(x
, y
);
171 // get out of the endless loop
177 if (ps2
!= 0 && ps2
!= KEYCODE_TAB
&& ps2
!= KEYCODE_BACKSPACE
&& ps2
!= KEYCODE_ENTER
)
179 // do work for the x field
184 // print char on screen
185 LCD
.putChar(ps2
, 65, (16 + (6 * xcursor
)), BLACK
, WHITE
);
186 // add value to data array
187 xArray
[xpos
] = ps2
- 48;
199 LCD
.putChar(ps2
, 50, (16 + (6 * ycursor
)), BLACK
, WHITE
);
200 yArray
[ypos
] = ps2
- 48;
213 void SBUI::drawStatusBar()
215 // draw a line and the current status text
216 LCD
.drawLine(20, 0, 20, 130, BLACK
);
218 LCD
.putVariable("SRAM:", availableSRAM(), 5, 70, BLACK
, WHITE
, 40);
220 // check whicht status message should be displayed
227 clearStatusMsgArea();
228 LCD.putString ( (const char*) getPGMStr (Idle), 5, 5, BLACK, WHITE);
233 // only draw status message if it is not the
234 // same as the currently displayed
236 if (lastStatusMsg != 1)
238 clearStatusMsgArea();
239 LCD.putString ( (const char*) getPGMStr (Solder), 5, 5, BLACK, WHITE);
248 if (lastStatusMsg != 2)
250 clearStatusMsgArea();
251 LCD.putString ( (const char*) getPGMStr (Moving), 5, 5, BLACK, WHITE);
260 if (lastStatusMsg != 3)
262 clearStatusMsgArea();
263 LCD.putString ( (const char*) getPGMStr (Loading), 5, 5, BLACK, WHITE);
274 void SBUI::drawShowTrack()
279 for (byte i
= 0; i
< 16; i
++)
281 LCD
.drawLine(35, 25 + (5 * i
), 105, 25 + (5 * i
), LIGHTGREY
);
284 LCD
.drawLine(35 + (5 * i
), 25, 35 + (5 * i
), 105, LIGHTGREY
);
288 LCD
.drawLine(35, 25, 105, 25, BLACK
);
291 LCD
.drawLine(35, 25, 35, 105, BLACK
);
293 // loop through all points / 2 doing 2 points each time
294 for (byte i
= 1; i
<= (total
/ 2); i
++)
301 x1
= IOMgr
.smap
[i
][1];
302 y1
= IOMgr
.smap
[i
][2];
303 x2
= IOMgr
.smap
[i
+1][1];
304 y2
= IOMgr
.smap
[i
+1][2];
306 //coordinate system finished draw points and lines now
308 // draw a line from point to point
309 LCD
.drawLine(35 + y1
, 25 + x1
, 35 + y2
, 25 + x2
, LIGHTBLUE
);
312 LCD
.drawX(35 + y1
, 25 + x1
, RED
);
313 LCD
.drawX(35 + y2
, 25 + x2
, RED
);
316 LCD
.putVariable("Points:", total
, 22, 5, BLACK
, WHITE
);
319 void SBUI::drawLoadTrack(byte count
, byte coord
, byte pos
)
321 // if we haven't started to receive
325 LCD
.putString("Waiting for SMap..", 100, 5, BLACK
, WHITE
);
328 if (count
> 0 && count
!= 101)
330 // display what we received yet and the percentage
331 LCD
.drawRect(100, 5, 110, 100, FILL
, WHITE
);
332 LCD
.putVariable("RX:", count
, 100, 5, BLACK
, WHITE
, 30);
333 LCD
.putVariable("/", total
, 100, 42, BLACK
, WHITE
, 30);
334 LCD
.putVariable("", ((count
* 100) / total
), 100, 70, BLACK
, WHITE
, 3);
335 LCD
.putChar('%', 100, 92, BLACK
, WHITE
);
341 LCD
.putVariable("LP(", coord
, 90, 5, BLACK
, WHITE
, 30);
348 LCD
.putVariable("/", coord
, 90, 42, BLACK
, WHITE
, 30);
349 LCD
.putChar(')', 90, 67, BLACK
, WHITE
);
354 // if we finished receiving the count is set to 101
358 LCD
.putString("Enter -> start", 70, 5, BLACK
, WHITE
);
359 LCD
.putString("V -> show track", 60, 5, BLACK
, WHITE
);
362 byte ps2
= IOMgr
.getPS2Keycode();
369 else if(ps2
== KEYCODE_ENTER
)
375 //TODO Add info message for start soldering
379 void SBUI::drawSolder()
383 LCD
.putString("Space -> Pause", 70, 5, BLACK
, WHITE
);
389 byte ps2
= IOMgr
.getPS2Keycode();
391 if(ps2
== KEYCODE_SPACE
)
395 byte pause
= IOMgr
.getPS2Keycode();
396 if(pause
== KEYCODE_SPACE
)
403 x
= IOMgr
.smap
[i
][1];
404 y
= IOMgr
.smap
[i
][2];