#include "gui.h"
#include "intc.h"
#include "board.h"
#include "pm.h"
#include "gpio.h"
#include "printf-stdarg.h"
#include "print_funcs.h"
#include "delay.h"
#include "spi.h"
#include "conf_et024006dhu.h"
#include "et024006dhu.h"
#include "console.h"
#include "clocks.h"
#include <avr32/io.h>
#include <string.h>
#include "qt60168.h"
#include "conf_qt60168.h"
Go to the source code of this file.
Defines | |
#define | BUTTON_BG_COLOR BLACK |
#define | BUTTON_FG_COLOR WHITE |
#define | BUTTON_H 40 |
#define | BUTTON_SENSITIVITY_TICKS 3 |
#define | BUTTON_W 320 |
#define | BUTTON_X 0 |
#define | BUTTON_Y 200 |
#define | CURSOR_BG_COLOR BLUE |
#define | CURSOR_FG_COLOR WHITE |
#define | INFO_BG_COLOR BLACK |
#define | INFO_FG_COLOR WHITE |
#define | INFO_MAX_LINES 12 |
#define | MAX_LINE_LEN 37 |
#define | NUM_BUTTONS 5 |
#define | SCROLL_BG_COLOR WHITE |
#define | SCROLL_DISP_LINES 11 |
#define | SCROLL_FG_COLOR BLACK |
#define | SCROLL_H 160 |
#define | SCROLL_MAX_LINES 50 |
#define | SCROLL_W 320 |
#define | SCROLL_X 0 |
#define | SCROLL_Y 40 |
#define | TITLE_BG_COLOR BLACK |
#define | TITLE_FG_COLOR WHITE |
#define | TITLE_H 40 |
#define | TITLE_MAX_LINES 3 |
#define | TITLE_W 320 |
#define | TITLE_X 0 |
#define | TITLE_Y 0 |
#define | YELLOW 0xFFE0 |
Enumerations | |
enum | { GUI_LIST, GUI_INFOBOX, GUI_GETSTRING } |
Functions | |
void | gui_add_infobox_item (const char *str, int line) |
void | gui_add_scroll_box_item (const char *str, size_t len) |
void | gui_clear_infobox (short color) |
void | gui_clear_scroll_box (void) |
void | gui_dec_scroll_cursor (void) |
void | gui_del_scroll_box_item (const char *str, size_t len) |
void | gui_display_getstring (void) |
void | gui_display_infobox (void) |
void | gui_draw (int force_draw) |
void | gui_exec (uint32_t tick) |
int | gui_get_scroll_box_focused_item (char **str, size_t *len) |
void | gui_getstring_onoff (int state) |
void | gui_inc_scroll_cursor (void) |
void | gui_infobox_onoff (int state) |
int | gui_infobox_state (void) |
void | gui_init (const pm_freq_param_t *pm_freq_param) |
void | gui_restore_buttons () |
void | gui_save_buttons () |
int | gui_scroll_idx (void) |
void | gui_set_bg_color (short color) |
int | gui_set_button (short id, const char *label, size_t len, button_cb_t cb) |
void | gui_set_title (const char *str, unsigned char line) |
static __inline__ int | is_pressed (short idx) |
int | poll_button (uint32_t tick) |
static void | qt60168_resources_init (const pm_freq_param_t *pm_freq_param) |
Initializes QT60168 resources: GPIO and SPI. | |
Variables | |
struct { | |
button_cb_t cbs [NUM_BUTTONS] | |
char labels [NUM_BUTTONS][MAX_LINE_LEN] | |
} | button_contents |
enum { ... } | display_mode |
static short | idx_to_button_map [] |
struct { | |
char * data | |
size_t data_len | |
int height | |
int width | |
} | info_bitmap |
struct { | |
int bg_color | |
char lines [INFO_MAX_LINES][MAX_LINE_LEN] | |
} | infobox_contents |
int | led_array [4] = {LED0,LED1,LED2,LED3} |
short | mod = 0 |
struct { | |
button_cb_t cbs [NUM_BUTTONS] | |
char labels [NUM_BUTTONS][MAX_LINE_LEN] | |
} | saved_buttons |
struct { | |
int bg_color | |
int cnt | |
int cursor | |
int dispstart | |
char lines [SCROLL_MAX_LINES][MAX_LINE_LEN] | |
} | scroll_box_contents |
struct { | |
char title [TITLE_MAX_LINES][MAX_LINE_LEN] | |
} | title_contents |
#define BUTTON_BG_COLOR BLACK |
#define BUTTON_FG_COLOR WHITE |
#define BUTTON_H 40 |
#define BUTTON_SENSITIVITY_TICKS 3 |
#define BUTTON_W 320 |
#define BUTTON_X 0 |
#define BUTTON_Y 200 |
#define CURSOR_BG_COLOR BLUE |
#define CURSOR_FG_COLOR WHITE |
#define INFO_FG_COLOR WHITE |
#define INFO_MAX_LINES 12 |
Definition at line 158 of file gui.c.
Referenced by gui_add_infobox_item(), and gui_display_infobox().
#define MAX_LINE_LEN 37 |
Definition at line 136 of file gui.c.
Referenced by gs_button_0(), gs_button_1(), gs_button_2(), gs_button_3(), gui_display_getstring(), and gui_display_infobox().
#define NUM_BUTTONS 5 |
Definition at line 178 of file gui.c.
Referenced by gui_draw(), gui_set_button(), and poll_button().
#define SCROLL_BG_COLOR WHITE |
#define SCROLL_DISP_LINES 11 |
Definition at line 135 of file gui.c.
Referenced by gs_button_2(), gs_button_3(), gui_dec_scroll_cursor(), gui_display_getstring(), gui_draw(), and gui_inc_scroll_cursor().
#define SCROLL_FG_COLOR BLACK |
#define SCROLL_H 160 |
#define SCROLL_MAX_LINES 50 |
#define SCROLL_W 320 |
#define SCROLL_X 0 |
Definition at line 109 of file gui.c.
Referenced by gui_display_getstring(), gui_display_infobox(), and gui_draw().
#define SCROLL_Y 40 |
Definition at line 110 of file gui.c.
Referenced by gui_display_getstring(), gui_display_infobox(), and gui_draw().
#define TITLE_BG_COLOR BLACK |
#define TITLE_FG_COLOR WHITE |
#define TITLE_H 40 |
#define TITLE_W 320 |
#define TITLE_X 0 |
#define TITLE_Y 0 |
anonymous enum |
Definition at line 147 of file gui.c.
00147 { 00148 GUI_LIST, 00149 GUI_INFOBOX, 00150 GUI_GETSTRING 00151 } display_mode = GUI_LIST;
void gui_add_infobox_item | ( | const char * | str, | |
int | line | |||
) |
Definition at line 547 of file gui.c.
References INFO_MAX_LINES, and infobox_contents.
Referenced by gui_status_up_cb().
00548 { 00549 if (line < INFO_MAX_LINES) { 00550 strncpy(infobox_contents.lines[line], str, sizeof infobox_contents.lines[line]); 00551 mod = 1; 00552 } 00553 }
void gui_add_scroll_box_item | ( | const char * | str, | |
size_t | len | |||
) |
Definition at line 412 of file gui.c.
References cnt, scroll_box_contents, and SCROLL_MAX_LINES.
Referenced by gui_scan_cb(), and gui_start().
00412 { 00413 00414 int cnt = scroll_box_contents.cnt; 00415 int i; 00416 00417 if (cnt >= SCROLL_MAX_LINES) return; 00418 00419 for (i = 0; i < cnt; i++) { 00420 if (strncmp(str, scroll_box_contents.lines[i], len) == 0) { 00421 return; 00422 } 00423 } 00424 00425 if (len >= sizeof scroll_box_contents.lines[cnt]) { 00426 len = sizeof scroll_box_contents.lines[cnt] - 1; 00427 } 00428 strncpy(scroll_box_contents.lines[cnt], str, len); 00429 scroll_box_contents.cnt++; 00430 mod = 1; 00431 }
void gui_clear_infobox | ( | short | color | ) |
Definition at line 541 of file gui.c.
References infobox_contents.
Referenced by gui_status_up_cb().
00542 { 00543 memset(&infobox_contents, 0, sizeof infobox_contents); 00544 infobox_contents.bg_color = color; 00545 }
void gui_clear_scroll_box | ( | void | ) |
Definition at line 333 of file gui.c.
References scroll_box_contents.
Referenced by gui_scan_cb(), and gui_start().
00334 { 00335 00336 memset(&scroll_box_contents, 0, sizeof scroll_box_contents); 00337 scroll_box_contents.dispstart = 0; 00338 }
void gui_dec_scroll_cursor | ( | void | ) |
Definition at line 371 of file gui.c.
References printk(), scroll_box_contents, and SCROLL_DISP_LINES.
Referenced by gui_start().
00372 { 00373 #ifdef DEBUG 00374 printk("dec1: cur:%d,dstrt=%d\n", scroll_box_contents.cursor, 00375 scroll_box_contents.dispstart); 00376 #endif 00377 scroll_box_contents.cursor--; 00378 00379 if (scroll_box_contents.cursor <= 0) 00380 { 00381 scroll_box_contents.dispstart = scroll_box_contents.cnt - SCROLL_DISP_LINES; 00382 if (scroll_box_contents.dispstart < 0) scroll_box_contents.dispstart = 0; 00383 scroll_box_contents.cursor = scroll_box_contents.cnt - 1; 00384 } 00385 if (scroll_box_contents.cursor < scroll_box_contents.dispstart) 00386 { 00387 scroll_box_contents.dispstart--; 00388 } 00389 #ifdef DEBUG 00390 printk("dec2: cur:%d,dstrt=%d\n", scroll_box_contents.cursor, 00391 scroll_box_contents.dispstart); 00392 #endif 00393 mod = 1; 00394 }
void gui_del_scroll_box_item | ( | const char * | str, | |
size_t | len | |||
) |
Definition at line 435 of file gui.c.
References cnt, printk(), and scroll_box_contents.
00435 { 00436 00437 int cnt = scroll_box_contents.cnt; 00438 int i; 00439 int moving = 0; 00440 00441 printk("Delete %s\n", str); 00442 for (i = 0; i < cnt; i++) { 00443 if (! moving && strncmp(str, scroll_box_contents.lines[i], len) == 0) { 00444 printk("Found it at %d\n", i); 00445 /* Now move everything up */ 00446 moving = 1; 00447 } 00448 if (moving) { 00449 if (scroll_box_contents.lines[i+1][0] == '\0') { 00450 memset(scroll_box_contents.lines[i], 0, sizeof scroll_box_contents.lines[i]); 00451 break; 00452 } 00453 printk("Moving \"%s\" to %i\n", scroll_box_contents.lines[i+1], i); 00454 memcpy(scroll_box_contents.lines[i], scroll_box_contents.lines[i+1], 00455 strlen(scroll_box_contents.lines[i+1]) + 1); 00456 memset(scroll_box_contents.lines[i+1], 0, sizeof scroll_box_contents.lines[i+1]); 00457 } 00458 } 00459 if (i < cnt) { 00460 scroll_box_contents.cnt--; 00461 } 00462 00463 mod = 1; 00464 }
void gui_display_getstring | ( | void | ) |
Definition at line 310 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().
00311 { 00312 int j; 00313 int i; 00314 #if BOARD != EVK1100 00315 int fg_color, bg_color; 00316 #endif 00317 char str[22]; 00318 00319 #if BOARD == EVK1100 00320 if (redisplay) { 00321 dip204_clear_display(); 00322 for (j = 0; j <= SCROLL_DISP_LINES; j++) { 00323 strncpy(str, &(char_array[get_string_data.rowstart+j][get_string_data.colstart]), MAX_LINE_LEN); 00324 str[MAX_LINE_LEN] = '\0'; 00325 dip204_set_cursor_position(1,j+2); /* col,line */ 00326 dip204_write_string(str); 00327 } 00328 } 00329 #else 00330 for (j = 0; j < GS_MAX_ROWS; j++) { 00331 for (i = 0; i < strlen(char_array[j]); i++) { 00332 if (get_string_data.row == j && get_string_data.col == i) { 00333 fg_color = CURSOR_FG_COLOR; 00334 bg_color = CURSOR_BG_COLOR; 00335 } else { 00336 fg_color = SCROLL_FG_COLOR; 00337 bg_color = SCROLL_BG_COLOR; 00338 } 00339 str[0] = char_array[j][i]; 00340 str[1] = 0; 00341 et024006_PrintString(str, 00342 (const unsigned char*)&FONT8x8, 00343 (i+1)*10+SCROLL_X + 10, 00344 (j+1)*12+SCROLL_Y, 00345 fg_color, 00346 bg_color); 00347 } 00348 } 00349 #endif 00350 00351 #if BOARD == EVK1100 00352 if (redisplay){ 00353 if (get_string_data.rowstart == GS_MAX_ROWS - SCROLL_DISP_LINES) { 00354 dip204_set_cursor_position(1,1); /* col,line */ 00355 dip204_write_string(" "); 00356 j = 1; 00357 for (i = 0; i < (sizeof func_row/sizeof func_row[0]); i++) { 00358 dip204_set_cursor_position(j,get_string_data.rowstart + SCROLL_DISP_LINES); /* col,line */ 00359 dip204_write_string(func_row[i]); 00360 j += strlen(func_row[i]); 00361 } 00362 } 00363 redisplay = FALSE; 00364 } 00365 00366 dip204_set_cursor_position(1,1); /* col,line */ 00367 dip204_write_string(" "); 00368 dip204_set_cursor_position(1,1); /* col,line */ 00369 dip204_write_string(getstring); 00370 if (get_string_data.row == GS_MAX_ROWS) { 00371 dip204_set_cursor_position(get_string_data.col * strlen(func_row[0]) + 2, GS_MAX_ROWS); /* col,line */ 00372 } else { 00373 dip204_set_cursor_position(get_string_data.col + 1 - get_string_data.colstart, 00374 get_string_data.row + 2 - get_string_data.rowstart); /* col,line */ 00375 } 00376 dip204_show_cursor(); 00377 #else 00378 j = 1; 00379 for (i = 0; i < (sizeof func_row/sizeof func_row[0]); i++) { 00380 if (get_string_data.row == GS_MAX_ROWS && get_string_data.col == i) { 00381 fg_color = CURSOR_FG_COLOR; 00382 bg_color = CURSOR_BG_COLOR; 00383 } else { 00384 fg_color = SCROLL_FG_COLOR; 00385 bg_color = SCROLL_BG_COLOR; 00386 } 00387 et024006_PrintString(func_row[i], 00388 (const unsigned char*)&FONT8x8, 00389 j*10 + SCROLL_X + 10, 00390 5*12+SCROLL_Y, 00391 fg_color, 00392 bg_color); 00393 j += strlen(func_row[i])-1; 00394 } 00395 #endif 00396 }
void gui_display_infobox | ( | void | ) |
Definition at line 588 of file gui.c.
References col, info_bitmap, INFO_FG_COLOR, INFO_MAX_LINES, infobox_contents, MAX_LINE_LEN, printk(), SCROLL_H, SCROLL_W, SCROLL_X, and SCROLL_Y.
Referenced by gui_draw().
00589 { 00590 int i; 00591 00592 #if BOARD != EVK1100 00593 // Draw info box 00594 et024006_DrawFilledRect(SCROLL_X, 00595 SCROLL_Y, 00596 SCROLL_W, 00597 SCROLL_H, 00598 infobox_contents.bg_color); 00599 00600 for (i = 0; i < INFO_MAX_LINES; i++) 00601 { 00602 if (strlen(infobox_contents.lines[i])) 00603 { 00604 int x; 00605 x = 160 - ((strlen(infobox_contents.lines[i]) / 2)*10); 00606 if (x < 0) x = 10; 00607 et024006_PrintString(infobox_contents.lines[i], 00608 (const unsigned char*)&FONT8x8, 00609 x, 00610 (i+1)*12+SCROLL_Y, 00611 INFO_FG_COLOR, 00612 infobox_contents.bg_color); 00613 } 00614 } 00615 if (info_bitmap.data && info_bitmap.data_len) { 00616 printk("Displaying pixmap (size %d)\n", info_bitmap.data_len); 00617 et024006_PutPixmap( (et024006_color_t *)info_bitmap.data, 00618 info_bitmap.width, // Map width 00619 0, // map_x 00620 0, // map_y 00621 40, // x 00622 40, // y 00623 info_bitmap.width, // width 00624 info_bitmap.height); // height 00625 } 00626 else { 00627 printk("Not displaying picture\n"); 00628 } 00629 #else 00630 dip204_clear_display(); 00631 for (i = 0; i < INFO_MAX_LINES; i++) 00632 { 00633 int len = strlen(infobox_contents.lines[i]); 00634 int col = (MAX_LINE_LEN/2) - (len/2); 00635 if ( col <= 0) col = 1; 00636 dip204_set_cursor_position(col,i+1); /* col,line */ 00637 dip204_write_string(infobox_contents.lines[i]); 00638 dip204_hide_cursor(); 00639 } 00640 #endif 00641 }
void gui_draw | ( | int | force_draw | ) |
Definition at line 705 of file gui.c.
References BUTTON_BG_COLOR, button_contents, BUTTON_FG_COLOR, BUTTON_H, BUTTON_W, BUTTON_X, BUTTON_Y, CURSOR_BG_COLOR, display_mode, gui_display_getstring(), gui_display_infobox(), GUI_GETSTRING, GUI_INFOBOX, GUI_LIST, NUM_BUTTONS, scroll_box_contents, SCROLL_DISP_LINES, SCROLL_FG_COLOR, SCROLL_H, SCROLL_W, SCROLL_X, SCROLL_Y, TITLE_BG_COLOR, title_contents, TITLE_FG_COLOR, TITLE_H, TITLE_W, TITLE_X, and TITLE_Y.
Referenced by gui_exec(), and gui_start().
00705 { 00706 int i; 00707 00708 if (! mod) { 00709 return; 00710 } 00711 mod = 0; 00712 #if BOARD != EVK1100 00713 // Draw title box 00714 et024006_DrawFilledRect(TITLE_X, 00715 TITLE_Y, 00716 TITLE_W, 00717 TITLE_H, 00718 TITLE_BG_COLOR); 00719 if (title_contents.title[0][0]) { 00720 et024006_PrintString(title_contents.title[0], 00721 (const unsigned char*)&FONT8x8, 00722 TITLE_X + 10, 00723 TITLE_Y + 5, 00724 TITLE_FG_COLOR, 00725 TITLE_BG_COLOR); 00726 et024006_PrintString(title_contents.title[1], 00727 (const unsigned char*)&FONT8x8, 00728 TITLE_X + 10, 00729 TITLE_Y + 5 + 12, 00730 TITLE_FG_COLOR, 00731 TITLE_BG_COLOR); 00732 et024006_PrintString(title_contents.title[2], 00733 (const unsigned char*)&FONT8x8, 00734 TITLE_X + 10, 00735 TITLE_Y + 5 + 12 + 12, 00736 TITLE_FG_COLOR, 00737 TITLE_BG_COLOR); 00738 00739 } 00740 00741 00742 // Draw scroll box 00743 et024006_DrawFilledRect(SCROLL_X, 00744 SCROLL_Y, 00745 SCROLL_W, 00746 SCROLL_H, 00747 scroll_box_contents.bg_color); 00748 00749 #endif 00750 switch (display_mode) 00751 { 00752 case GUI_INFOBOX: 00753 gui_display_infobox(); 00754 break; 00755 00756 case GUI_GETSTRING: 00757 gui_display_getstring(); 00758 break; 00759 00760 case GUI_LIST: 00761 { 00762 #if BOARD == EVK1100 00763 dip204_clear_display(); 00764 #endif 00765 for (i = 0; i <= SCROLL_DISP_LINES; i++) 00766 { 00767 00768 #if BOARD == EVK1100 00769 00770 dip204_set_cursor_position(1,i+1); /* col,line */ 00771 00772 dip204_write_string(scroll_box_contents.lines[i+scroll_box_contents.dispstart]); 00773 00774 #else 00775 00776 if ((scroll_box_contents.cursor == i + scroll_box_contents.dispstart) && 00777 scroll_box_contents.cursor != 0) 00778 { 00779 /* Print cursor line. */ 00780 et024006_PrintString(scroll_box_contents.lines[i+scroll_box_contents.dispstart], 00781 (const unsigned char*)&FONT8x8, 00782 SCROLL_X + 10, 00783 (i+1)*12+SCROLL_Y, 00784 scroll_box_contents.bg_color, 00785 CURSOR_BG_COLOR); 00786 } 00787 else 00788 { 00789 et024006_PrintString(scroll_box_contents.lines[i+scroll_box_contents.dispstart], 00790 (const unsigned char*)&FONT8x8, 00791 SCROLL_X + 10, 00792 (i+1)*12+SCROLL_Y, 00793 SCROLL_FG_COLOR, 00794 scroll_box_contents.bg_color); 00795 } 00796 #endif 00797 } 00798 #if BOARD == EVK1100 00799 dip204_set_cursor_position(1, scroll_box_contents.cursor - scroll_box_contents.dispstart+1); 00800 dip204_show_cursor(); 00801 #endif 00802 } 00803 } /* switch */ 00804 // Draw buttons 00805 #if BOARD != EVK1100 00806 et024006_DrawFilledRect(BUTTON_X, 00807 BUTTON_Y, 00808 BUTTON_W, 00809 BUTTON_H, 00810 BUTTON_BG_COLOR); 00811 for (i = 0; i < NUM_BUTTONS-1; i++) { 00812 et024006_DrawVertLine(i*BUTTON_W/NUM_BUTTONS, 00813 BUTTON_Y, 00814 BUTTON_H, 00815 BUTTON_FG_COLOR); 00816 // Display button labels 00817 if (button_contents.labels[i]) { 00818 et024006_PrintString(button_contents.labels[i], 00819 (const unsigned char*)&FONT8x8, 00820 i*BUTTON_W/NUM_BUTTONS + 5, 00821 BUTTON_Y + 10, 00822 BUTTON_FG_COLOR, 00823 BUTTON_BG_COLOR); 00824 } 00825 } 00826 #endif 00827 }
void gui_exec | ( | uint32_t | tick | ) |
Definition at line 665 of file gui.c.
References button_contents, CMD_INPROGRESS, gui_draw(), gui_getstring(), and poll_button().
Referenced by poll().
00665 { 00666 00667 int i; 00668 static int pressed_button; 00669 static enum { INPUT, RUN } state = INPUT; 00670 00671 switch (state) 00672 { 00673 case INPUT: 00674 { 00675 i = poll_button(tick); 00676 if ( i < 0 ) { // No action required 00677 break; 00678 } 00679 else { 00680 if (button_contents.cbs[i]) { 00681 pressed_button = i; 00682 state = RUN; 00683 } 00684 } 00685 } 00686 break; 00687 00688 case RUN: 00689 { 00690 #ifdef GUI_COMPAT 00691 if (button_contents.cbs[pressed_button]() == CMD_INPROGRESS) 00692 return; 00693 #else 00694 button_contents.cbs[pressed_button](); 00695 #endif 00696 state = INPUT; 00697 pressed_button = -1; 00698 } 00699 } /* case */ 00700 // Poll gui_getstring 00701 gui_getstring(NULL, NULL); 00702 gui_draw(1); 00703 }
int gui_get_scroll_box_focused_item | ( | char ** | str, | |
size_t * | len | |||
) |
Definition at line 401 of file gui.c.
References FALSE, scroll_box_contents, and TRUE.
00401 { 00402 if (scroll_box_contents.cursor <= 0) { 00403 return FALSE; 00404 } 00405 *str = scroll_box_contents.lines[scroll_box_contents.cursor]; 00406 *len = strlen(*str); 00407 00408 return TRUE; 00409 }
void gui_getstring_onoff | ( | int | state | ) |
Definition at line 645 of file gui.c.
References display_mode, GUI_GETSTRING, and GUI_LIST.
Referenced by gui_getstring().
00646 { 00647 if (state) 00648 display_mode = GUI_GETSTRING; 00649 else 00650 display_mode = GUI_LIST; 00651 // display_infobox = state; 00652 mod = 1; 00653 }
void gui_inc_scroll_cursor | ( | void | ) |
Definition at line 345 of file gui.c.
References printk(), scroll_box_contents, and SCROLL_DISP_LINES.
Referenced by gui_scan_cb(), and gui_start().
00346 { 00347 00348 #ifdef DEBUG 00349 printk("inc1: cur=%d, dstrt=%d\n", scroll_box_contents.cursor, 00350 scroll_box_contents.dispstart); 00351 #endif 00352 scroll_box_contents.cursor++; 00353 if (scroll_box_contents.cursor > (scroll_box_contents.dispstart 00354 + SCROLL_DISP_LINES)) 00355 { 00356 scroll_box_contents.dispstart++; 00357 } 00358 if (scroll_box_contents.cursor >= scroll_box_contents.cnt) 00359 { 00360 scroll_box_contents.dispstart = 0; 00361 scroll_box_contents.cursor = 1; 00362 } 00363 #ifdef DEBUG 00364 printk("inc2: cur=%d, dstrt=%d\n", scroll_box_contents.cursor, 00365 scroll_box_contents.dispstart); 00366 #endif 00367 mod = 1; 00368 }
void gui_infobox_onoff | ( | int | state | ) |
Definition at line 526 of file gui.c.
References display_mode, GUI_INFOBOX, and GUI_LIST.
Referenced by gui_status_up_cb().
00527 { 00528 if (state) 00529 display_mode = GUI_INFOBOX; 00530 else 00531 display_mode = GUI_LIST; 00532 // display_infobox = state; 00533 mod = 1; 00534 }
int gui_infobox_state | ( | void | ) |
Definition at line 536 of file gui.c.
References display_mode, and GUI_INFOBOX.
00536 { 00537 return (GUI_INFOBOX == display_mode); 00538 }
void gui_init | ( | const pm_freq_param_t * | pm_freq_param | ) |
Definition at line 233 of file gui.c.
References button_contents, FPBA_HZ, info_bitmap, infobox_contents, qt60168_resources_init(), scroll_box_contents, title_contents, and TRUE.
Referenced by gui_start().
00233 { 00234 #if BOARD == EVK1100 00235 static const gpio_map_t DIP204_SPI_GPIO_MAP = 00236 { 00237 {DIP204_SPI_SCK_PIN, DIP204_SPI_SCK_FUNCTION }, // SPI Clock. 00238 {DIP204_SPI_MISO_PIN, DIP204_SPI_MISO_FUNCTION}, // MISO. 00239 {DIP204_SPI_MOSI_PIN, DIP204_SPI_MOSI_FUNCTION}, // MOSI. 00240 {DIP204_SPI_NPCS_PIN, DIP204_SPI_NPCS_FUNCTION} // Chip Select NPCS. 00241 }; 00242 spi_options_t spiOptions = 00243 { 00244 .reg = DIP204_SPI_NPCS, 00245 .baudrate = 1000000, 00246 .bits = 8, 00247 .spck_delay = 0, 00248 .trans_delay = 0, 00249 .stay_act = 1, 00250 .spi_mode = 3, 00251 .modfdis = 1 00252 }; 00253 #endif 00254 00255 memset(&scroll_box_contents, 0, sizeof scroll_box_contents); 00256 memset(&title_contents, 0, sizeof title_contents); 00257 memset(&button_contents, 0, sizeof button_contents); 00258 memset(&infobox_contents, 0, sizeof infobox_contents); 00259 memset(&info_bitmap, 0, sizeof info_bitmap); 00260 #if BOARD == EVK1104 00261 // Init touch sensor resources: GPIO, SPI and QT60168. 00262 qt60168_resources_init(pm_freq_param); 00263 // Initialize QT60168 component. 00264 qt60168_init(pm_freq_param->cpu_f); 00265 #endif 00266 #if BOARD == EVK1100 00267 // Assign I/Os to SPI 00268 gpio_enable_module(DIP204_SPI_GPIO_MAP, 00269 sizeof(DIP204_SPI_GPIO_MAP) / sizeof(DIP204_SPI_GPIO_MAP[0])); 00270 #if 0 00271 // Initialize as master 00272 spi_initMaster(DIP204_SPI, &spiOptions); 00273 00274 // Set selection mode: variable_ps, pcs_decode, delay 00275 spi_selectionMode(DIP204_SPI, 0, 0, 0); 00276 00277 // Enable SPI 00278 spi_enable(DIP204_SPI); 00279 #endif 00280 // setup chip registers 00281 spi_setupChipReg(DIP204_SPI, &spiOptions, FOSC0); 00282 00283 // initialize delay driver 00284 delay_init( FPBA_HZ ); 00285 00286 // initialize LCD 00287 dip204_init(backlight_PWM, TRUE); 00288 dip204_set_cursor_position(1,1); 00289 dip204_write_string("http server demo!"); 00290 #else 00291 // Init display 00292 et024006_Init( pm_freq_param->cpu_f, pm_freq_param->cpu_f /*HSB*/); 00293 // Turn on the display backlight 00294 gpio_set_gpio_pin(ET024006DHU_BL_PIN); 00295 #endif 00296 mod = 1; 00297 }
void gui_restore_buttons | ( | void | ) |
Definition at line 660 of file gui.c.
References button_contents.
Referenced by gui_getstring().
00661 { 00662 memcpy(&button_contents, &saved_buttons, sizeof button_contents); 00663 }
void gui_save_buttons | ( | void | ) |
Definition at line 655 of file gui.c.
References button_contents.
Referenced by gui_getstring(), and gui_status_up_cb().
00656 { 00657 memcpy(&saved_buttons, &button_contents, sizeof button_contents); 00658 }
int gui_scroll_idx | ( | void | ) |
Definition at line 396 of file gui.c.
References scroll_box_contents.
Referenced by gui_connect_cb().
00397 { 00398 return scroll_box_contents.cursor; 00399 }
void gui_set_bg_color | ( | short | color | ) |
Definition at line 340 of file gui.c.
References scroll_box_contents.
Referenced by gui_scan_cb(), and gui_start().
00341 { 00342 scroll_box_contents.bg_color = color; 00343 }
int gui_set_button | ( | short | id, | |
const char * | label, | |||
size_t | len, | |||
button_cb_t | cb | |||
) |
Definition at line 317 of file gui.c.
References button_contents, and NUM_BUTTONS.
Referenced by gui_getstring(), gui_start(), and gui_status_up_cb().
00318 { 00319 00320 if (id >= NUM_BUTTONS) { 00321 return 0; 00322 } 00323 if (len >= sizeof button_contents.labels[id]) { 00324 len = sizeof button_contents.labels[id] - 1; 00325 } 00326 button_contents.cbs[id] = cb; 00327 strncpy(button_contents.labels[id], label, len); 00328 mod = 1; 00329 00330 return 1; 00331 }
void gui_set_title | ( | const char * | str, | |
unsigned char | line | |||
) |
Definition at line 300 of file gui.c.
References title_contents.
Referenced by gs_button_4(), and gui_getstring().
00301 { 00302 int len; 00303 00304 Assert(line < 3); 00305 00306 memset(&title_contents.title[line], 0, sizeof title_contents.title[0]); 00307 len = strlen(str); 00308 00309 if (len >= sizeof title_contents.title[0]) { 00310 len = sizeof title_contents.title[0] - 1; 00311 } 00312 strncpy(title_contents.title[line], str, len); 00313 00314 mod = 1; 00315 }
static __inline__ int is_pressed | ( | short | idx | ) | [static] |
Definition at line 90 of file gui.c.
References idx_to_button_map.
Referenced by poll_button().
00090 { 00091 #if BOARD == EVK1104 00092 return qt60168_is_key_pressed(idx_to_button_map[idx]); 00093 #else 00094 return (gpio_get_pin_value(button[idx]) == BUTTON_PRESSED); 00095 #endif 00096 }
int poll_button | ( | uint32_t | tick | ) |
Definition at line 469 of file gui.c.
References BUTTON_SENSITIVITY_TICKS, is_pressed(), and NUM_BUTTONS.
Referenced by gui_exec().
00469 { 00470 static int pressed_button = -1; 00471 static int press_start_tick = 0; 00472 static int action_ok = 0; 00473 static int poll_limit_ts = 0; 00474 int ret, i; 00475 00476 /* Cases : 00477 * 1. Button pressed, but was not previously 00478 * Start waiting for the detect time 00479 * 2. Button pressed, and was previously 00480 * Check detect time. If expired, wait for release 00481 * 3. Button not pressed, but was previously 00482 * If waiting for release, reset and return 1 00483 * otherwise do nothing. 00484 */ 00485 if ( pressed_button >= 0 ) { // Button was held previously 00486 if ( is_pressed(pressed_button) ) { // Button is still held 00487 // Has it been held enough time? 00488 if ( tick - press_start_tick > BUTTON_SENSITIVITY_TICKS ) { // 00489 action_ok = 1; 00490 } 00491 return -1; // Wait for release 00492 } 00493 // Button was pressed but now released. Time for action 00494 ret = pressed_button; 00495 pressed_button = -1; 00496 press_start_tick = 0; 00497 if (action_ok) { 00498 action_ok = 0; 00499 return ret; 00500 } 00501 // If we switched button it will be detected next polling time 00502 return -1; 00503 } 00504 // If we end up here no button was held previously 00505 // So find out if one is pressed now 00506 /* Rate limit polling on the EVK1104 because is_pressed() 00507 * takes a huge amount of time. */ 00508 #if BOARD != EVK1104 00509 poll_limit_ts = 0; 00510 #endif 00511 if ( poll_limit_ts == 0 || tick - poll_limit_ts > 100 ) { 00512 for (i = 0; i < NUM_BUTTONS; i++) { 00513 // Check buttons 00514 if ( is_pressed(i) ) 00515 { 00516 pressed_button = i; 00517 press_start_tick = tick; 00518 break; 00519 } 00520 } 00521 poll_limit_ts = tick; 00522 } 00523 return -1; 00524 }
static void qt60168_resources_init | ( | const pm_freq_param_t * | pm_freq_param | ) | [static] |
Initializes QT60168 resources: GPIO and SPI.
Definition at line 190 of file gui.c.
References QT60168_SPI_BITS, and QT60168_SPI_MASTER_SPEED.
Referenced by gui_init().
00191 { 00192 static const gpio_map_t QT60168_SPI_GPIO_MAP = 00193 { 00194 {QT60168_SPI_SCK_PIN, QT60168_SPI_SCK_FUNCTION }, // SPI Clock. 00195 {QT60168_SPI_MISO_PIN, QT60168_SPI_MISO_FUNCTION }, // MISO. 00196 {QT60168_SPI_MOSI_PIN, QT60168_SPI_MOSI_FUNCTION }, // MOSI. 00197 {QT60168_SPI_NPCS0_PIN, QT60168_SPI_NPCS0_FUNCTION} // Chip Select NPCS. 00198 }; 00199 00200 // SPI options. 00201 spi_options_t spiOptions = 00202 { 00203 .reg = QT60168_SPI_NCPS, 00204 .baudrate = QT60168_SPI_MASTER_SPEED, // Defined in conf_qt60168.h. 00205 .bits = QT60168_SPI_BITS, // Defined in conf_qt60168.h. 00206 .spck_delay = 0, 00207 .trans_delay = 0, 00208 .stay_act = 0, 00209 .spi_mode = 3, 00210 .modfdis = 1 00211 }; 00212 00213 // Assign I/Os to SPI. 00214 gpio_enable_module(QT60168_SPI_GPIO_MAP, 00215 sizeof(QT60168_SPI_GPIO_MAP) / sizeof(QT60168_SPI_GPIO_MAP[0])); 00216 00217 // Initialize as master. 00218 spi_initMaster(QT60168_SPI, &spiOptions); 00219 00220 // Set selection mode: variable_ps, pcs_decode, delay. 00221 spi_selectionMode(QT60168_SPI, 0, 0, 0); 00222 00223 // Enable SPI. 00224 spi_enable(QT60168_SPI); 00225 00226 // Initialize QT60168 with SPI clock Osc0. 00227 spi_setupChipReg(QT60168_SPI, &spiOptions, pm_freq_param->cpu_f); 00228 }
int bg_color |
struct { ... } button_contents |
Referenced by gui_draw(), gui_exec(), gui_init(), gui_restore_buttons(), gui_save_buttons(), and gui_set_button().
button_cb_t cbs[NUM_BUTTONS] |
int cnt |
Definition at line 141 of file gui.c.
Referenced by find_best_candidate(), gui_add_scroll_box_item(), and gui_del_scroll_box_item().
char* data |
enum { ... } display_mode |
Referenced by gui_draw(), gui_getstring_onoff(), gui_infobox_onoff(), and gui_infobox_state().
short idx_to_button_map[] [static] |
Initial value:
{ QT60168_TOUCH_SENSOR_BUTTON_0, QT60168_TOUCH_SENSOR_BUTTON_1, QT60168_TOUCH_SENSOR_BUTTON_2, QT60168_TOUCH_SENSOR_BUTTON_3, QT60168_TOUCH_SENSOR_WHEEL_UP}
Definition at line 68 of file gui.c.
Referenced by is_pressed().
struct { ... } info_bitmap |
Referenced by gui_display_infobox(), and gui_init().
struct { ... } infobox_contents |
Referenced by gui_add_infobox_item(), gui_clear_infobox(), gui_display_infobox(), and gui_init().
short mod = 0 |
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().
struct { ... } saved_buttons |
struct { ... } scroll_box_contents |
struct { ... } title_contents |
Referenced by gui_draw(), gui_init(), and gui_set_title().
int width |