Beispiel #1
0
portTASK_FUNCTION( vGUITask, pvParameters )
{
	portTickType xLastWakeTime;

	foutf(&debugOS, "xTask GUI started.\n");

	xLastWakeTime = xTaskGetTickCount();

	u8 timer_drawMap = 0;

	for(;;)
	{
		//foutf(&debugOS, "Watermark gui: %i\n", uxTaskGetStackHighWaterMark( NULL ));

		gui_handler(gui_element);

		if(STM_EVAL_PBGetState(BUTTON_USER))
		{
			menu = MENU_CALIBRATION;
		}

		if(battery.percent != batt_percent_old) //Redraw statusbar if battery value changes
		{
			gui_drawAREAstatusbar(&gui_element[GUI_EL_AREA_STATUSBAR_TOP]);
			batt_percent_old = battery.percent;
		}

		switch (menu) {
		case MENU_INIT:
			LCD_Fill(LCD_COLOR_WHITE);
			gui_drawAREAstatusbar(&gui_element[GUI_EL_AREA_STATUSBAR_TOP]);
			gui_drawMBTN(&gui_element[GUI_EL_MBTN_MAP]);
			gui_drawMBTN(&gui_element[GUI_EL_MBTN_VIEW]);
			gui_drawMBTN(&gui_element[GUI_EL_MBTN_SETTINGS]);

			menu = MENU_INIT_IDLE;

		case MENU_INIT_IDLE: //Wait for events...

			if(gui_element[GUI_EL_MBTN_MAP].state == MBTN_ACTIVE)
				menu = MENU_MAP_INIT;
			else if(gui_element[GUI_EL_MBTN_VIEW].state == MBTN_ACTIVE)
				menu = MENU_VIEW_INIT;
			else if(gui_element[GUI_EL_MBTN_SETTINGS].state == MBTN_ACTIVE)
				menu = MENU_SETTINGS_INIT;

			break;

		case MENU_MAP_INIT:

			//Area Map
			//SW Startmapping
			//SW Show scan
			//BTN Clear map
			//BTN Set waypoint

			gui_element[GUI_EL_AREA_MAP].state = GUI_EL_INTOUCHABLE;
			gui_element[GUI_EL_SW_STARTMAPPING].state =		mapping			? SW_ON : SW_OFF;
			gui_element[GUI_EL_SW_SHOWSCAN].state =			show_scan		? SW_ON : SW_OFF;
			gui_element[GUI_EL_SW_PROCESSEDVIEW].state =	processedView	? SW_ON : SW_OFF;

			gui_element[GUI_EL_AREA_MAP].state = MAP_ACTIVE;

			gui_element[GUI_EL_BTN_CLEARMAP].state = BTN_NOT_ACTIVE;

			if(setWaypoints)	gui_element[GUI_EL_BTN_SETWP].state = BTN_ACTIVE;
			else				gui_element[GUI_EL_BTN_SETWP].state = BTN_NOT_ACTIVE;

			gui_drawSW(&gui_element[GUI_EL_SW_STARTMAPPING]);
			gui_drawSW(&gui_element[GUI_EL_SW_SHOWSCAN]);
			gui_drawSW(&gui_element[GUI_EL_SW_PROCESSEDVIEW]);
			gui_drawBTN(&gui_element[GUI_EL_BTN_CLEARMAP]);
			gui_drawBTN(&gui_element[GUI_EL_BTN_SETWP]);

			timer_drawMap = 0;

			menu = MENU_MAP_IDLE;

		case MENU_MAP_IDLE:

			if(timer_drawMap == 0)
			{
				gui_drawAREAmap(&gui_element[GUI_EL_AREA_MAP]);
				timer_drawMap = MAP_REFRESHTIME;
			}
			timer_drawMap --;

			break; //Map idle (waiting for touch events)

		case MENU_VIEW_INIT:
			//Draw View
			menu = MENU_VIEW_IDLE;

		case MENU_VIEW_IDLE:
			break; //View idle (waiting for touch events)
		case MENU_SETTINGS_INIT: //Settings active

			switch (xv11_state(XV11_GETSTATE)) { //Lidar state?
			case XV11_OFF:		gui_element[GUI_EL_SW_LIDAR].state = SW_OFF;	break;
			case XV11_STARTING:	gui_element[GUI_EL_SW_LIDAR].state = SW_BUSY;	break;
			case XV11_ON:		gui_element[GUI_EL_SW_LIDAR].state = SW_ON;		break;
			default:															break;
			}
			gui_drawSW(&gui_element[GUI_EL_SW_LIDAR]);

			gui_element[GUI_EL_SW_STRLIDAR].state =		strlidar.active	? SW_ON : SW_OFF; //Streams on/off?
			gui_drawSW(&gui_element[GUI_EL_SW_STRLIDAR]);
			gui_element[GUI_EL_SW_STRDEBUG].state =		debug.active	? SW_ON : SW_OFF;
			gui_drawSW(&gui_element[GUI_EL_SW_STRDEBUG]);
			gui_element[GUI_EL_SW_STRDEBUGOS].state =	debugOS.active	? SW_ON : SW_OFF;
			gui_drawSW(&gui_element[GUI_EL_SW_STRDEBUGOS]);
			gui_element[GUI_EL_SW_STRERR].state =		error.active	? SW_ON : SW_OFF;
			gui_drawSW(&gui_element[GUI_EL_SW_STRERR]);
			gui_element[GUI_EL_SW_STRSLAMUI].state =	slamUI.active	? SW_ON : SW_OFF;
			gui_drawSW(&gui_element[GUI_EL_SW_STRSLAMUI]);

			gui_element[GUI_EL_BTN_CALTOUCH].state = BTN_NOT_ACTIVE; //Calibrate Touchscreen?
			gui_drawBTN(&gui_element[GUI_EL_BTN_CALTOUCH]);

			gui_element[GUI_EL_BTN_RESET].state = BTN_NOT_ACTIVE; //Reset system!
			gui_drawBTN(&gui_element[GUI_EL_BTN_RESET]);

			menu = MENU_SETTINGS_IDLE;

		case MENU_SETTINGS_IDLE:

			if(gui_element[GUI_EL_SW_LIDAR].state != GUI_EL_INVISIBLE)
			{
				if(xv11_state(XV11_GETSTATE) == XV11_STARTING)
				{
					if(gui_element[GUI_EL_SW_LIDAR].state != SW_BUSY)
					{
						gui_element[GUI_EL_SW_LIDAR].state = SW_BUSY;
						gui_drawSW(&gui_element[GUI_EL_SW_LIDAR]);
					}
				}
				else if(xv11_state(XV11_GETSTATE) == XV11_ON)
				{
					if(gui_element[GUI_EL_SW_LIDAR].state != SW_ON)
					{
						gui_element[GUI_EL_SW_LIDAR].state = SW_ON;
						gui_drawSW(&gui_element[GUI_EL_SW_LIDAR]);
					}
				}
			}
			break; //Settings idle (waiting for touch events)

		case MENU_CALIBRATION: //Calibration mode:
			if(UB_Touch_Calibrate() == 1)
			{
				menu = MENU_INIT;
			}
			break;

		default: menu = MENU_INIT;
			break;
		}

		vTaskDelayUntil( &xLastWakeTime, ( 50 / portTICK_RATE_MS ) );
	}
}
Beispiel #2
0
int main( int argc, char *argv[] )
{
#ifdef __linux__
  if (!gtk_init_check(&argc, &argv))
  {
    printf("GTK is sad :-(\n");
    return 0;
  }
#endif  

  #ifdef __HAIKU__
    // Fix for haiku not starting apps in their home directory
	find_home();
  #endif

  if( hively_init() )
  {
    SDL_Flip(ssrf);
    quitting = FALSE;
    while( !quitting )
    {
      if (needaflip)
      {
        SDL_Flip(ssrf);
        needaflip = FALSE;
      }

      if( !SDL_WaitEvent( &event ) ) break;
  
      do
      {
        switch( event.type )
        {
          case SDL_QUIT:
            quitting = gui_maybe_quit();
            break;

          default:
            if (aboutwin_open)
              about_handler(0);
            else
              gui_handler(0);
            break;
        }
      }
      while (SDL_PollEvent(&event));

      if( pref_dorestart )
      {
        if( !gui_restart() )
          quitting = TRUE;
        pref_dorestart = FALSE;
      }   
    }
    
    rp_stop();
  }

  hively_shutdown();
  return 0;
}