示例#1
0
static void menu_update(void)
{
	start_time = xTaskGetTickCount();
	
    unsigned char ii;
    uint16_t bgCol = COL_BG_NORM;    	

	lcd_lock();
	lcd_background(0);

    // clear menu bg
    lcd_fill(0, CRUMB_H, LCD_W, LCD_H - CRUMB_H, bgCol);

    // draw the crumbs
    char crumbs[90] = "Brewbot";
    for (ii = 1; ii <= g_index; ii++)
    {
        strcat(crumbs, ":");
        strcat(crumbs, g_menu[ii-1][g_crumbs[ii-1]].text);
    }
    lcd_fill(0, 0, LCD_W, CRUMB_H, 0x0);
    lcd_text(0, 0, crumbs);
	lcd_fill(0, CRUMB_H - 2, LCD_W, 2, 0xFFFF);

    // how big is the menu?
    g_entries = 0;
    for (ii = 0; g_menu[g_index][ii].text; ii++)
    {
    	g_entries++;
    }

    // if above a certain size draw in two columns
    if (g_entries > 4)
    {
    	menu_two_column();
    }
    else
    {
    	g_rows = g_entries;
    	g_rowh = (240 - CRUMB_H) / g_entries;

    	for (ii = 0; g_menu[g_index][ii].text; ii++)
    	{
    		menu_paint_cell(ii);
    		if (ii != g_entries - 1)
    			lcd_fill(0,  CRUMB_H + (ii +1) * (g_rowh) - 1, LCD_W, 1,    0xFFFF);
    	}
    }

    lcd_printf(30, 0, 10, "%dms", (xTaskGetTickCount() - start_time));
    lcd_release();
}
示例#2
0
static void menu_two_column()
{
    unsigned char ii;   
    unsigned char row = 0;
    unsigned char col = 0;
    uint16_t bgCol = COL_BG_NORM;

    g_rows = (g_entries / 2) + ((g_entries % 2) != 0);    
    g_rowh = (LCD_H - CRUMB_H) / g_rows;

    //printf("Rows: %d rowh: %d entries: %d\r\n", g_rows, g_rowh, g_entries);
    
    // draw the grid
    lcd_fill(COL_W, CRUMB_H, 1, LCD_H - CRUMB_H, 0xFFFF);
    for (ii = 0; ii < g_rows - 1; ii++)
		lcd_fill(0,  CRUMB_H + (ii +1) * (g_rowh) - 1, LCD_W, 1,    0xFFFF);
    
    for (ii = 0; g_menu[g_index][ii].text; ii++)
    {
    	menu_paint_cell(ii);
    }	
}
示例#3
0
void menu_touch(int xx, int yy)
{
    if (g_menu_applet) {
    	if (g_menu_applet(xx, yy))
    		menu_back_after_applet();
        return;
    }

    menu_touch_y = yy;
    menu_touch_x = xx;    
    //menu_update();       

    int old = g_item;
    g_item = menu_get_selected();

    lcd_lock();

    if (old != -1)
    	menu_paint_cell(old);
    if (g_item != -1)
    	menu_paint_cell(g_item);

    lcd_release();

    if (xx == -1 || yy == -1 || g_item == -1)
    {
    	if (old != -1)
    	{
    		if (g_menu[g_index][old].press_handler)
    		{
    			g_menu[g_index][old].press_handler(0);
    		}

    	    void (*callback)(int) = g_menu[g_index][old].activate;
    	    g_crumbs[g_index] = old;

    	    if (g_menu[g_index][old].next && g_index < MAX_DEPTH)
    	    {
    	        g_index++;
    	        g_menu[g_index] = g_menu[g_index-1][old].next;
    	        menu_update();
    	    }
    	    else if (g_menu[g_index][old].touch_handler)
    	    {
    	        g_menu_applet = g_menu[g_index][old].touch_handler;
    	        g_item = old;
    	        menu_clear();
    	    }
    	    else if (strcmp(g_menu[g_index][old].text, "Back") == 0)
    	    {
    	        menu_run_callback(0);    	

    	        if (g_index > 0)
    	            g_index--;
    	        menu_update();
    	        menu_run_callback(1);    	
    	    }
    	    
    	    // run the callback which should start the applet or update the display
    	    if (callback)
    	    {
    	        callback(1);
    	    }
    	}
    	return;
    }
    
    menu_touch_y = 0;
    menu_touch_x = 0;

    if (g_menu[g_index][g_item].press_handler)
    {
    	g_menu[g_index][g_item].press_handler(1);
    }
}
示例#4
0
void menu_touch(int xx, int yy)
{
  //char c[15];
  vConsolePrint("Menu Touch Called\r\n");
  //sprintf(c, "x %d y %d\r\n", xx, yy);
   //vConsolePrint(c);


    if (g_menu_applet) {
    	if (g_menu_applet(xx, yy))
    		menu_back_after_applet();
        return;
    }

    menu_touch_y = yy;
    menu_touch_x = xx;    
    //menu_update();       
    char bb[30];
    int old = g_item;
    if (g_incoming_command == 1)
      {
       g_item = g_command_item;

      }
    else
      {
        g_item = menu_get_selected();
      }
      g_incoming_command=0;

   // sprintf(bb, "Item Selected is: %u\r\n", g_item);
  //  vConsolePrint(bb);
  //  fflush(stdout);
    lcd_lock();

    if (old != -1)
    	menu_paint_cell(old);
    if (g_item != -1)
    	menu_paint_cell(g_item);

    lcd_release();

    if (xx == -1 || yy == -1 || g_item == -1)
    {
    	if (old != -1)
    	{
    		if (g_menu[g_index][old].press_handler)
    		{
    			g_menu[g_index][old].press_handler(0);
    		}

    	    void (*callback)(int) = g_menu[g_index][old].activate;
    	    g_crumbs[g_index] = old;

    	    if (g_menu[g_index][old].next && g_index < MAX_DEPTH)
    	    {
    	        g_index++;
    	        g_menu[g_index] = g_menu[g_index-1][old].next;
    	        menu_update();
    	    }
    	    else if (g_menu[g_index][old].touch_handler)
    	    {
    	        g_menu_applet = g_menu[g_index][old].touch_handler;
    	        g_item = old;
    	        menu_clear();
    	    }
    	    else if (strcmp(g_menu[g_index][old].text, "Back") == 0)
    	    {
    	        menu_run_callback(0);    	

    	        if (g_index > 0)
    	            g_index--;
    	        menu_update();
    	        menu_run_callback(1);    	
    	    }
    	    
    	    // run the callback which should start the applet or update the display
    	    if (callback)
    	    {
    	        callback(1);
    	    }
    	}
    	return;
    }
    
    menu_touch_y = 0;
    menu_touch_x = 0;

    if (g_menu[g_index][g_item].press_handler)
    {
    	g_menu[g_index][g_item].press_handler(1);
    }
}