Exemplo n.º 1
0
void brew_resume(int init)
{
	if (init)
	{
		g_state.in_alarm = 0;
		lcd_lock();
	    lcd_fill(0, 0, LCD_W, CRUMB_H, 0x0);
	    lcd_text(0, 0, "Brewbot:Resume at step");
		lcd_fill(0, CRUMB_H - 2, LCD_W, 2, 0xFFFF);
		lcd_fill(0, CRUMB_H, LCD_W, LCD_H - CRUMB_H - 2 * HH, COL_BG_NORM);
		lcd_fill(0, LCD_H - 2 * HH - 2, LCD_W, 1, 0xFFFF);
		lcd_fill(0, LCD_H - 1 * HH - 1, LCD_W, 1, 0xFFFF);
		lcd_fill(LCD_W / 2, LCD_H - 2 * HH - 1, 1, 2 * HH, 0xFFFF);
		
		button_paint(resume_buttons);		
		lcd_background(COL_BG_NORM);
		lcd_printf(10, 4, 30, "%d. %s", g_state.step + 1, brew_step_name(g_state.step));
		lcd_release();
	}
	else
	{
		log_brew(&g_state.log_file, "%.2d:%.2d Brew stopped\n", g_state.total_runtime / 60, g_state.total_runtime % 60);
		brewTaskStop(&brew_task);
	}
}
Exemplo n.º 2
0
static void brew_run_step()
{
	g_state.step_start_tick = xTaskGetTickCount();
	g_state.step_runtime = 0; // iterate will update this

	lcd_lock();
    lcd_fill(0, 0, LCD_W, CRUMB_H, 0x0);
	lcd_background(0x0);
    lcd_text(0, 0, "Brewbot:Brewing");
	lcd_fill(0, CRUMB_H - 2, LCD_W, 2, 0xFFFF);
	lcd_fill(0, CRUMB_H, LCD_W, LCD_H - CRUMB_H, COL_BG_NORM);
	lcd_fill(0, LCD_H - 1 * HH - 1, LCD_W / 2, 1, 0xFFFF);
	lcd_fill(LCD_W / 2, LCD_H - 1 * HH - 1, 1, HH, 0xFFFF);
	
	button_paint(brew_buttons);		
	if (g_steps[g_state.step].buttons)
		button_paint(g_steps[g_state.step].buttons);
	lcd_background(COL_BG_NORM);
	lcd_printf(17, 0, 20, "%d.%s", g_state.step, g_steps[g_state.step].name);
	lcd_release();
	log_brew(&g_state.log_file, "%.2d:%.2d Run step %d.%s\n",
			g_state.total_runtime / 60, g_state.total_runtime % 60,
			g_state.step, g_steps[g_state.step].name);

	g_steps[g_state.step].method(1);
}
Exemplo n.º 3
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();
}
Exemplo n.º 4
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);
    }
}
Exemplo n.º 5
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);
    }
}