#include <ctype.h>
#include "wl_api.h"
#include "intc.h"
#include "board.h"
#include "printf-stdarg.h"
#include "print_funcs.h"
#include "console.h"
#include "timer.h"
#include "wl_util.h"
#include "gui.h"
#include "et024006dhu.h"
Go to the source code of this file.
Defines | |
#define | CURSOR_BG_COLOR BLUE |
#define | CURSOR_FG_COLOR WHITE |
#define | GS_MAX_ROWS 4 |
#define | MAX_LINE_LEN 37 |
#define | SCROLL_BG_COLOR WHITE |
#define | SCROLL_DISP_LINES 11 |
#define | SCROLL_FG_COLOR BLACK |
#define | SCROLL_H 160 |
#define | SCROLL_W 320 |
#define | SCROLL_X 0 |
#define | SCROLL_Y 40 |
Functions | |
static void | gs_button_0 () |
static void | gs_button_1 () |
static void | gs_button_2 () |
static void | gs_button_3 () |
static void | gs_button_4 () |
void | gui_display_getstring (void) |
Bool | gui_getstring (char *string, int max_len) |
void | poll (uint8_t flags) |
Variables | |
char | char_array [][30] |
char | func_row [][16] |
struct { | |
int col | |
int colstart | |
int escape | |
int ready | |
int row | |
int rowstart | |
} | get_string_data |
char * | getstring |
int | gs_idx = 0 |
int | gs_max_len |
short | mod |
short | redisplay = FALSE |
#define CURSOR_BG_COLOR BLUE |
Definition at line 52 of file gui_getstring.c.
#define CURSOR_FG_COLOR WHITE |
Definition at line 53 of file gui_getstring.c.
#define GS_MAX_ROWS 4 |
Definition at line 55 of file gui_getstring.c.
Referenced by gs_button_2(), gs_button_3(), gs_button_4(), and gui_display_getstring().
#define MAX_LINE_LEN 37 |
Definition at line 78 of file gui_getstring.c.
#define SCROLL_BG_COLOR WHITE |
Definition at line 50 of file gui_getstring.c.
#define SCROLL_DISP_LINES 11 |
Definition at line 77 of file gui_getstring.c.
#define SCROLL_FG_COLOR BLACK |
Definition at line 51 of file gui_getstring.c.
#define SCROLL_H 160 |
Definition at line 49 of file gui_getstring.c.
#define SCROLL_W 320 |
Definition at line 48 of file gui_getstring.c.
#define SCROLL_X 0 |
Definition at line 46 of file gui_getstring.c.
#define SCROLL_Y 40 |
Definition at line 47 of file gui_getstring.c.
static void gs_button_0 | ( | ) | [static] |
Definition at line 99 of file gui_getstring.c.
References char_array, get_string_data, MAX_LINE_LEN, mod, redisplay, and TRUE.
Referenced by gui_getstring().
00100 { 00101 /* Left */ 00102 get_string_data.col--; 00103 00104 if (get_string_data.col < 0) { 00105 get_string_data.col = strlen(char_array[get_string_data.row]) - 1; 00106 if (get_string_data.colstart < get_string_data.col - MAX_LINE_LEN + 1) { 00107 get_string_data.colstart = get_string_data.col - MAX_LINE_LEN + 1 ; 00108 redisplay = TRUE; 00109 } 00110 } 00111 00112 if (get_string_data.col < get_string_data.colstart) { 00113 get_string_data.colstart--; 00114 redisplay = TRUE; 00115 } 00116 mod = TRUE; 00117 }
static void gs_button_1 | ( | ) | [static] |
Definition at line 119 of file gui_getstring.c.
References char_array, get_string_data, MAX_LINE_LEN, mod, redisplay, and TRUE.
Referenced by gui_getstring().
00120 { 00121 /* Right */ 00122 get_string_data.col++; 00123 00124 if (get_string_data.col >= strlen(char_array[get_string_data.row])) { 00125 get_string_data.col = 0; 00126 if (get_string_data.colstart > 0) { 00127 get_string_data.colstart = 0; 00128 redisplay = TRUE; 00129 } 00130 } 00131 00132 if (get_string_data.col >= get_string_data.colstart + MAX_LINE_LEN) { 00133 get_string_data.colstart++; 00134 redisplay = TRUE; 00135 } 00136 mod = TRUE; 00137 }
static void gs_button_2 | ( | ) | [static] |
Definition at line 139 of file gui_getstring.c.
References char_array, get_string_data, GS_MAX_ROWS, MAX_LINE_LEN, mod, redisplay, SCROLL_DISP_LINES, and TRUE.
Referenced by gui_getstring().
00140 { 00141 /* up */ 00142 get_string_data.row--; 00143 00144 if (get_string_data.row < 0) 00145 get_string_data.row = GS_MAX_ROWS; 00146 00147 if (get_string_data.row < get_string_data.rowstart) { 00148 get_string_data.rowstart--; 00149 redisplay = TRUE; 00150 } 00151 00152 if (get_string_data.row > get_string_data.rowstart + SCROLL_DISP_LINES) { 00153 get_string_data.rowstart = get_string_data.row - SCROLL_DISP_LINES; 00154 redisplay = TRUE; 00155 } 00156 00157 if (get_string_data.col >= strlen(char_array[get_string_data.row])) { 00158 get_string_data.col = strlen(char_array[get_string_data.row]) - 1; 00159 if (get_string_data.col < MAX_LINE_LEN) { 00160 get_string_data.colstart = 0; 00161 redisplay = TRUE; 00162 } 00163 } 00164 00165 mod = TRUE; 00166 }
static void gs_button_3 | ( | ) | [static] |
Definition at line 168 of file gui_getstring.c.
References char_array, get_string_data, GS_MAX_ROWS, MAX_LINE_LEN, mod, redisplay, SCROLL_DISP_LINES, and TRUE.
Referenced by gui_getstring().
00169 { 00170 /* dwn */ 00171 00172 get_string_data.row++; 00173 00174 if (get_string_data.row > GS_MAX_ROWS) { 00175 get_string_data.row = 0; 00176 get_string_data.rowstart = 0; 00177 redisplay = TRUE; 00178 } 00179 if (get_string_data.row > get_string_data.rowstart + SCROLL_DISP_LINES) { 00180 get_string_data.rowstart = get_string_data.row - SCROLL_DISP_LINES; 00181 redisplay = TRUE; 00182 } 00183 00184 if (get_string_data.col >= strlen(char_array[get_string_data.row])) { 00185 get_string_data.col = strlen(char_array[get_string_data.row]) - 1; 00186 if (get_string_data.col < MAX_LINE_LEN) { 00187 get_string_data.colstart = 0; 00188 redisplay = TRUE; 00189 } 00190 } 00191 00192 mod = TRUE; 00193 }
static void gs_button_4 | ( | ) | [static] |
Definition at line 195 of file gui_getstring.c.
References char_array, FALSE, get_string_data, getstring, gs_idx, gs_max_len, GS_MAX_ROWS, gui_set_title(), mod, and TRUE.
Referenced by gui_getstring().
00196 { 00197 /* enter */ 00198 00199 char chr; 00200 00201 if (get_string_data.row == GS_MAX_ROWS) 00202 { 00203 /* Edit function row */ 00204 if (get_string_data.col == 0) /* back */ 00205 { 00206 get_string_data.ready = TRUE; 00207 get_string_data.escape = TRUE; 00208 } 00209 else if (get_string_data.col == 1) /* delete */ 00210 { 00211 gs_idx--; 00212 if (gs_idx < 0) gs_idx = 0; 00213 getstring[gs_idx] = 0; 00214 gui_set_title(getstring, 1); 00215 } 00216 else if (get_string_data.col == 2) /* accept */ 00217 { 00218 get_string_data.ready = TRUE; 00219 get_string_data.escape = FALSE; 00220 } 00221 } 00222 else 00223 { 00224 /* add current char */ 00225 chr = char_array[get_string_data.row][get_string_data.col]; 00226 getstring[gs_idx] = chr; 00227 gs_idx++; 00228 if (gs_idx > gs_max_len) gs_idx = gs_max_len; 00229 getstring[gs_idx] = 0; 00230 } 00231 #if BOARD == EVK1100 00232 dip204_set_cursor_position(1,1); /* col,line */ 00233 dip204_write_string(getstring); 00234 dip204_set_cursor_position(get_string_data.col + 1 - get_string_data.colstart, 00235 get_string_data.row + 2 - get_string_data.rowstart); /* col,line */ 00236 #else 00237 gui_set_title(getstring, 1); 00238 #endif 00239 mod = TRUE; 00240 }
void gui_display_getstring | ( | void | ) |
Definition at line 289 of file gui_getstring.c.
References bg_color, char_array, CURSOR_BG_COLOR, CURSOR_FG_COLOR, FALSE, func_row, get_string_data, getstring, GS_MAX_ROWS, MAX_LINE_LEN, redisplay, SCROLL_BG_COLOR, SCROLL_DISP_LINES, SCROLL_FG_COLOR, SCROLL_X, SCROLL_Y, and str.
Referenced by gui_draw().
00290 { 00291 int j; 00292 int i; 00293 #if BOARD != EVK1100 00294 int fg_color, bg_color; 00295 #endif 00296 char str[22]; 00297 00298 #if BOARD == EVK1100 00299 if (redisplay) { 00300 dip204_clear_display(); 00301 for (j = 0; j <= SCROLL_DISP_LINES; j++) { 00302 strncpy(str, &(char_array[get_string_data.rowstart+j][get_string_data.colstart]), MAX_LINE_LEN); 00303 str[MAX_LINE_LEN] = '\0'; 00304 dip204_set_cursor_position(1,j+2); /* col,line */ 00305 dip204_write_string(str); 00306 } 00307 } 00308 #else 00309 for (j = 0; j < GS_MAX_ROWS; j++) { 00310 for (i = 0; i < strlen(char_array[j]); i++) { 00311 if (get_string_data.row == j && get_string_data.col == i) { 00312 fg_color = CURSOR_FG_COLOR; 00313 bg_color = CURSOR_BG_COLOR; 00314 } else { 00315 fg_color = SCROLL_FG_COLOR; 00316 bg_color = SCROLL_BG_COLOR; 00317 } 00318 str[0] = char_array[j][i]; 00319 str[1] = 0; 00320 et024006_PrintString(str, 00321 (const unsigned char*)&FONT8x8, 00322 (i+1)*10+SCROLL_X + 10, 00323 (j+1)*12+SCROLL_Y, 00324 fg_color, 00325 bg_color); 00326 } 00327 } 00328 #endif 00329 00330 #if BOARD == EVK1100 00331 if (redisplay){ 00332 if (get_string_data.rowstart == GS_MAX_ROWS - SCROLL_DISP_LINES) { 00333 dip204_set_cursor_position(1,1); /* col,line */ 00334 dip204_write_string(" "); 00335 j = 1; 00336 for (i = 0; i < (sizeof func_row/sizeof func_row[0]); i++) { 00337 dip204_set_cursor_position(j,get_string_data.rowstart + SCROLL_DISP_LINES); /* col,line */ 00338 dip204_write_string(func_row[i]); 00339 j += strlen(func_row[i]); 00340 } 00341 } 00342 redisplay = FALSE; 00343 } 00344 00345 dip204_set_cursor_position(1,1); /* col,line */ 00346 dip204_write_string(" "); 00347 dip204_set_cursor_position(1,1); /* col,line */ 00348 dip204_write_string(getstring); 00349 if (get_string_data.row == GS_MAX_ROWS) { 00350 dip204_set_cursor_position(get_string_data.col * strlen(func_row[0]) + 2, GS_MAX_ROWS); /* col,line */ 00351 } else { 00352 dip204_set_cursor_position(get_string_data.col + 1 - get_string_data.colstart, 00353 get_string_data.row + 2 - get_string_data.rowstart); /* col,line */ 00354 } 00355 dip204_show_cursor(); 00356 #else 00357 j = 1; 00358 for (i = 0; i < (sizeof func_row/sizeof func_row[0]); i++) { 00359 if (get_string_data.row == GS_MAX_ROWS && get_string_data.col == i) { 00360 fg_color = CURSOR_FG_COLOR; 00361 bg_color = CURSOR_BG_COLOR; 00362 } else { 00363 fg_color = SCROLL_FG_COLOR; 00364 bg_color = SCROLL_BG_COLOR; 00365 } 00366 et024006_PrintString(func_row[i], 00367 (const unsigned char*)&FONT8x8, 00368 j*10 + SCROLL_X + 10, 00369 5*12+SCROLL_Y, 00370 fg_color, 00371 bg_color); 00372 j += strlen(func_row[i])-1; 00373 } 00374 #endif 00375 }
Bool gui_getstring | ( | char * | string, | |
int | max_len | |||
) |
Definition at line 245 of file gui_getstring.c.
References FALSE, get_string_data, getstring, gs_button_0(), gs_button_1(), gs_button_2(), gs_button_3(), gs_button_4(), gs_max_len, gui_draw(), gui_getstring_onoff(), gui_restore_buttons(), gui_save_buttons(), gui_set_button(), gui_set_title(), poll(), redisplay, and TRUE.
Referenced by gui_connect_cb().
00246 { 00247 00248 getstring = string; 00249 gs_max_len = max_len; 00250 00251 gui_save_buttons(); 00252 #if BOARD == EVK1100 00253 dip204_clear_display(); 00254 redisplay = TRUE; 00255 #endif 00256 gui_draw(1); 00257 gui_set_title("Enter preshared key", 0); 00258 gui_set_title(getstring, 1); 00259 gui_set_button(0, "Left", sizeof "Left",gs_button_0); 00260 gui_set_button(1, "Right", sizeof "Right", gs_button_1); 00261 gui_set_button(2, "Up", sizeof "Up", gs_button_2); 00262 gui_set_button(3, "Down", sizeof "Down", gs_button_3); 00263 gui_set_button(4, "Enter", sizeof "Enter", gs_button_4); 00264 00265 get_string_data.col = 0; 00266 get_string_data.row = 0; 00267 get_string_data.colstart = 0; 00268 get_string_data.rowstart = 0; 00269 get_string_data.ready = FALSE; 00270 get_string_data.escape = FALSE; 00271 00272 gui_getstring_onoff(TRUE); 00273 while(!get_string_data.ready) 00274 poll(0); 00275 00276 gui_getstring_onoff(FALSE); 00277 gui_restore_buttons(); 00278 if (get_string_data.escape) 00279 return FALSE; 00280 else 00281 return TRUE; 00282 00283 }
void poll | ( | uint8_t | flags | ) |
Referenced by gui_getstring(), and main().
char char_array[][30] |
Initial value:
{ "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz", "0123456789", "!\"#$%&'()*+,-./:;<=>?@", "XXX" }
Definition at line 57 of file gui_getstring.c.
Referenced by gs_button_0(), gs_button_1(), gs_button_2(), gs_button_3(), gs_button_4(), and gui_display_getstring().
int col |
int colstart |
Definition at line 86 of file gui_getstring.c.
int escape |
Definition at line 83 of file gui_getstring.c.
char func_row[][16] |
Initial value:
{ "<BAC>", "<DEL>", "<ACC>" }
Definition at line 66 of file gui_getstring.c.
Referenced by gui_display_getstring().
struct { ... } get_string_data |
Referenced by gs_button_0(), gs_button_1(), gs_button_2(), gs_button_3(), gs_button_4(), gui_display_getstring(), and gui_getstring().
char* getstring |
Definition at line 94 of file gui_getstring.c.
Referenced by gs_button_4(), gui_display_getstring(), and gui_getstring().
int gs_idx = 0 |
int gs_max_len |
short mod |
Definition at line 129 of file gui.c.
Referenced by gs_button_0(), gs_button_1(), gs_button_2(), gs_button_3(), and gs_button_4().
int ready |
Definition at line 82 of file gui_getstring.c.
short redisplay = FALSE |
Definition at line 92 of file gui_getstring.c.
Referenced by gs_button_0(), gs_button_1(), gs_button_2(), gs_button_3(), gui_display_getstring(), and gui_getstring().
int row |
Definition at line 85 of file gui_getstring.c.
int rowstart |
Definition at line 84 of file gui_getstring.c.