2
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
4
* Use is subject to the GNU Lesser General Public License, Version 2.1,
5
* February 1999, which is contained in the read-me file named
6
* "README_GNU_LGPL." This library is free software; you can
7
* redistribute it and/or modify it under the terms of the GNU
8
* Lesser General Public License as published by the Free Software
9
* Foundation; either version 2.1 of the License, or (at your
10
* option) any later version. This library is distributed in the
11
* hope that it will be useful, but WITHOUT ANY WARRANTY; without
12
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13
* PARTICULAR PURPOSE. See the GNU Lesser General Public License
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this library; if not, write to the Free
18
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21
* read functions for the lcd. we handle both buttons and
22
* reading from the panel. */
27
#include <sys/types.h>
30
#include "lcd_private.h"
32
void lcd_rev_format( char *in ) {
33
int one, two, three, four;
35
sscanf(in,"%d.%d.%d.%d", &one, &two, &three, &four);
36
if (one > 255) one = 0;
37
if (two > 255) two = 0;
38
if (three > 255) three = 0;
39
if (four > 255) four = 0;
40
sprintf(in,"%03d.%03d.%03d.%03d",one,two,three,four);
44
int lcd_netbutton(void *lcd) {
48
lcd_set(lcd, LCD_Cursor_On);
50
button = lcd_readbutton(lcd) & 0x00FF;
51
if ( (button != BUTTON_NONE) && (button != BUTTON_NONE_B) ) {
53
if ( (ctr==lcd_button_debounce(lcd)) ) {
57
i = lcd_getcursorpos(lcd);
59
lcd_set(lcd, LCD_Cursor_Left);
60
i = lcd_getcursor(lcd);
62
lcd_set(lcd, LCD_Cursor_Left);
68
i = lcd_getcursorpos(lcd);
70
lcd_set(lcd, LCD_Cursor_Right);
71
i = lcd_getcursor(lcd);
73
lcd_set(lcd, LCD_Cursor_Right);
79
i = lcd_getcursorpos(lcd);
81
firstdigit = ( i == 0x40 ) || ( i == 0x44 ) || ( i == 0x48 ) || ( i == 0x4C );
82
i = lcd_getcursor(lcd);
85
else if ((i == '2') && (firstdigit))
89
lcd_setcursor(lcd, i);
94
i = lcd_getcursorpos(lcd);
96
firstdigit = ( i == 0x40 ) || ( i == 0x44 ) || ( i == 0x48 ) || ( i == 0x4C );
97
i = lcd_getcursor(lcd);
98
if ((i == '0') && (!firstdigit))
100
else if ((i == '0') && (firstdigit))
104
lcd_setcursor(lcd, i);
113
lcd_getdisplay(lcd, NULL, NULL, &i);
119
if (ctr==lcd_button_sense(lcd)) {
129
static void mangle_num(char *line) {
130
char *first = line + 1, *second = line + 2;
132
if ( *line == '2' ) {
135
else if ( *first > '5' )
137
else if (*first == '5') {
140
else if (*second > '5')
146
void lcd_netcorrect(void *lcd) {
148
char *line1, last_line1[LCD_CHARS_PER_LINE];
149
char *line2, last_line2[LCD_CHARS_PER_LINE];
151
last_address = lcd_getcursorpos(lcd);
152
lcd_getdisplay(lcd, &line1, &line2, NULL);
153
strcpy(last_line1, line1);
154
strcpy(last_line2, line2);
157
mangle_num(last_line2);
158
mangle_num(last_line2 + 4);
159
mangle_num(last_line2 + 8);
160
mangle_num(last_line2 + 12);
161
lcd_write(lcd, last_line1, last_line2);
162
lcd_setcursorpos(lcd, last_address);
163
lcd_set(lcd, LCD_Cursor_On);