Beispiel #1
0
int main(void) {
  sei(); // enable interrupts
  leds_init();
  pwm_init();
  bot_init();
  i2c_init();

  if (display_init()!=0) {
    leds_set_displaylight(50);
    if (display_type==2) {
      gfx_init();
    }
  }
  
  gfx_fill(0x00);
  gfx_move(15, 0);
  gfx_set_proportional(1);
  gfx_print_text("nibo");
  gfx_set_proportional(0);

  uint8_t pos=0;
  uint8_t state=0;

  gfx_term_print("Move 0\n");
  nds3_move(0);
  while (nds3_get_busy()) {
    delay(1);
  }
  
  while (1) {
    gfx_draw_mode(GFX_DM_JAM2);

    check_voltage();

   
    //gfx_term_print("Measure 90, 15\n");
      delay(1);
    nds3_measure(180, 1);
    while (nds3_get_busy()) {
      delay(1);
    }

      delay(1);
    //gfx_term_print("Read -90, 15\n");
    do_plot();

      delay(1);
    nds3_measure(0, 1);
    while (nds3_get_busy()) {
      delay(1);
    }

      delay(1);
    //gfx_term_print("Read 90, 15\n");
    nds3_read(0, 15);
    do_plot();
    
    
  }
}
Beispiel #2
0
void run_printf_test( void )
{
    uint16_t uval = 0;
    int16_t ival = 0;

    hal_initialize();

    gfx_init();
    backlight_init();
    backlight_set_brightness(90);
    tty_enable_view(bTrue);

#ifdef TEST_FOREVER
    for(;;)
#endif
    {
        tiny_sprintf(buffer, "test: %u, %d, %x, %B", ival, ival, ival, ival);

        tiny_printf("uint: %u, int: %d, hex: %x or %X, bhex: %b or %B, escape: %%\n",
                uval, ival, uval, uval, uval, uval);

        tiny_printf("string test %d: %s (OK)\n", uval, buffer);

        uval++;
        ival = ival > 0 ? -uval : uval;

        delay_ms(500);
    }
}
Beispiel #3
0
void system_setup(void)
{
    clock_setup();
    mco_setup();
    usb_setup();
    systick_setup();
    rng_setup();
    battery_setup();

    speaker_setup();
    jack_setup();
    // setup pad and screen
    interface_setup();

    // setup and reset SAM2695
    sam2695_setup();
    wait_ms(100);
    sam2695_reset();

    usbmidi_setup();

    // init gfx and fill screen
    gfx_init(ssd1306_drawpixel, SSD1306_WIDTH, SSD1306_HEIGHT, GFX_FONT_SMALL);
    gfx_setRotation(GFX_ROT_180);
    gfx_fillScreen(OLED_BLACK);
    gfx_setTextColor(OLED_WHITE, OLED_BLACK);
//    gfx_setTextWrap(1);
    gfx_setTextSize(1);
    ssd1306_display();
}
Beispiel #4
0
/*
 * This generates a "pleasant" background which looks a bit
 * like graph paper.
 */
void
generate_background(void)
{
	int i, x, y;
	uint32_t *t;

	gfx_init(bg_draw_pixel, 800, 480, GFX_FONT_LARGE);
	for (i = 0, t = (uint32_t *)(BACKGROUND_FB); i < 800 * 480; i++, t++) {
		*t = 0xffffffff; /* clear to white */
	}
	/* draw a grid */
	t = (uint32_t *) BACKGROUND_FB;
	for (y = 1; y < 480; y++) {
		for (x = 1; x < 800; x++) {
			/* major grid line */
			if ((x % 50) == 0) {
				gfx_drawPixel(x-1, y, 2);
				gfx_drawPixel(x, y, 2);
				gfx_drawPixel(x+1, y, 2);
			} else if ((y % 50) == 0) {
				gfx_drawPixel(x, y-1, 2);
				gfx_drawPixel(x, y, 2);
				gfx_drawPixel(x, y+1, 2);
			} else if (((x % 25) == 0) || ((y % 25) == 0)) {
				gfx_drawPixel(x, y, 1);
			}
		}
	}
	gfx_drawRoundRect(0, 0, 800, 480, 15, 2);
	gfx_drawRoundRect(1, 1, 798, 478, 15, 2);
	gfx_drawRoundRect(2, 2, 796, 476, 15, 2);
}
Beispiel #5
0
void run_rtc_test(void)
{
    hal_initialize();

    gfx_init();
    backlight_init();
    backlight_set_brightness(90);
    tty_enable_view(bTrue);

    rtc_initialize();
    rtc_set(&setupTime);

#ifdef TEST_FOREVER
    for(;;)
#endif
    {
        tty_enable_view(bFalse);
        tty_reset();
        rtc_now(&nowTime);
        rtc_format_time(&nowTime, RTC_FMT_DATE | RTC_FMT_TIME | RTC_FMT_SECONDS | RTC_FMT_WEEK, tty_outchar);
        tty_enable_view(bTrue);

        delay_ms(200);
    }
} 
/**
 * \brief Main application function
 *
 * This function calls all the necessary initialization functions before
 * launching the calculator widget and entering the main work loop.
 *
 * The main work loop is responsible for handling the low level user input, so
 * it reads touch data from the mXT143E Xplained, translates and passes it on to
 * the window system's event queue.
 *
 * All the processing for the calculator is done by the calculator widget's
 * event handler function \ref app_calc_handler(). This function is called by
 * the window system when it maps a user input event to an interaction with the
 * calculator, i.e., a button press.
 */
int main(void)
{
	static struct mxt_device device;

	board_init();
	sysclk_init();
	membag_init();

	gfx_init();
	mxt_init(&device);
	win_init();

	setup_gui_root_window();
	win_reset_root_geometry();
	if (app_widget_launch() == false) {
		show_out_of_memory_error();
		for (;;);
	}

	while (true) {
		struct win_pointer_event win_touch_event;

		/* Queue touch events from the touchscreen if any are available */
		while (read_touch_event(&device, &win_touch_event)) {
			win_queue_pointer_event(&win_touch_event);
		}

		/* Process queued events in the windowing system */
		win_process_events();
	}
}
Beispiel #7
0
void run_touch_test( void )
{
    uint16_t ret = 0;

    hal_initialize();

    gfx_init();
    backlight_init();
    backlight_set_brightness(90);
    tty_enable_view(bTrue);

    tty_output_delayed("TOUCH test! Initialization... \n", 1000);

    ret = touch_initialize();
    guard(ret);

    touch_set_event_handler(touchEventFunc);

#ifdef TEST_FOREVER
    for(;;)
#endif
    {
        //tty_enable_view(False);
        //tty_reset();

        ret = touch_process();
        guard(ret);

        //tty_enable_view(True);
        delay_ms(100);
    }
}
Beispiel #8
0
static void show_console(int code) {
	u32 i, b;

	printf("ScummVM exited abnormally (%d).\n", code);

	gfx_frame_abort();
	gfx_init();

	if (!gfx_frame_start())
		return;

	gfx_con_draw();
	gfx_frame_end();

	for (i = 0; i < 60 * 3; ++i)
		VIDEO_WaitVSync();

#ifdef DEBUG_WII_GDB
	printf("attach gdb now\n");
	_break();
#endif

	printf("Press any key to continue.\n");

	if (!gfx_frame_start())
		return;

	gfx_con_draw();
	gfx_frame_end();
	VIDEO_WaitVSync();

	while (true) {
		b = 0;

		if (PAD_ScanPads() & 1)
			b = PAD_ButtonsDown(0);

#ifndef GAMECUBE
		WPAD_ScanPads();
		if (WPAD_Probe(0, NULL) == WPAD_ERR_NONE)
			b |= WPAD_ButtonsDown(0);
#endif

		if (b)
			break;

		VIDEO_WaitVSync();
	}

	printf("\n\nExiting...\n");

	if (!gfx_frame_start())
		return;

	gfx_con_draw();
	gfx_frame_end();
	VIDEO_WaitVSync();
}
Beispiel #9
0
/**
 * \brief Main application function
 *
 * This function executes the necessary initialization calls and displays the
 * demo widgets before entering the main work loop of the application.
 *
 * The main work loop reads out the touch events from the mXT143E Xplained and
 * enqueues the corresponding touch events in the window system, before
 * processing the window system's event queue.
 */
int main(void)
{
	static struct mxt_device device;

	board_init();
	sysclk_init();
	membag_init();
	gfx_init();
	mxt_init(&device);
	win_init();

	setup_root_window();
	app_widget_launch();

	while (true) {
		/* Process received messages from the maXTouch device */
		while (mxt_is_message_pending(&device)) {
			struct mxt_touch_event touch_event;
			struct win_pointer_event win_touch_event;

			/* Get the first touch event in queue */
			if (mxt_read_touch_event(&device,
					&touch_event) != STATUS_OK) {
				continue;
			}

			/* Translate touch event type into a WTK event type */
			if (touch_event.status & MXT_PRESS_EVENT) {
				win_touch_event.type = WIN_POINTER_PRESS;
			} else if (touch_event.status & MXT_MOVE_EVENT) {
				win_touch_event.type = WIN_POINTER_MOVE;
			} else if (touch_event.status & MXT_RELEASE_EVENT) {
				win_touch_event.type = WIN_POINTER_RELEASE;
			} else {
				continue;
			}

			/* Indicate the touch event is a non-relative movement
			 * with the virtual touch button pressed
			 */
			win_touch_event.is_relative = false;
			win_touch_event.buttons = WIN_TOUCH_BUTTON;

			/* Translate the touch X and Y position into a screen
			 * coordinate
			 */
			win_touch_event.pos.x =
					((uint32_t)(4096 - touch_event.x) * gfx_get_width()) / 4096;
			win_touch_event.pos.y =
					((uint32_t)(4096 - touch_event.y) * gfx_get_height()) / 4096;
			win_queue_pointer_event(&win_touch_event);
		}

		/* Process queued events in the windowing system */
		win_process_events();
	}
}
Beispiel #10
0
int main(int argc, char **argv)
{
	bool done = false;
	SDL_Event event;

	// init graphics
	gfx_init(WINDOW_X, WINDOW_Y, false);
	// get key state array
	keyStates = SDL_GetKeyState(NULL);

#define SPRITE_CNT 1
	Sprite *sprites[SPRITE_CNT+1];
	sprites[0] = NULL;
	sprites[1] = new Sprite();
	sprites[1]->init("1.bmp", false, 255, 255, 255);

	Sprite backGround;
	backGround.init("background.bmp", true);

	// load from file
	TileMap map;
	map.loadMap(MAPFILE_NAME);

	Player player(&map, "player.bmp", 0, 0, 0);

	Uint32 frameStart;
	while(!done)
	{
		frameStart = SDL_GetTicks();
		// event processing
		while(SDL_PollEvent(&event))
		{
			switch(event.type)
			{
			case SDL_QUIT:
				done = true;
			default:
				break;
			}
		}
		// player think
		player.think();

		// draw
		backGround.draw(0, 0);
		map.draw((const Sprite **)sprites, NULL);
		player.draw();

		// flip buffer
		SDL_Flip(screen);

		// Key to have smooth moving and jump animation
		while(SDL_GetTicks() - frameStart < FRAME_DURATION);
	}

	return 0;
}
Beispiel #11
0
void setscreenmode(void)
{
    if (!gfx_init(320,200,60,screenmode))
    {
        win_messagebox("Graphics init error!\n");
        saveconfig();
        exit(1);
    }
}
Beispiel #12
0
static void mango_hw_init(void)
{
	disable_interrupts();
	uart_init(1, 115200);
	lcd_init();
	gfx_init();
	mango_interrupt_init();
	mango_timer_init();
	enable_interrupts();
}
Beispiel #13
0
int
main(void)
{
  halInit();
  chSysInit();

  get_device_id();

  /* start stdout port */
  sdStart(SD_STDIO, NULL);

  xflash_init();
  cmdline_init();

  rngStart(&RNGD);

  app_cfg_init();

  check_for_faults();

  gfx_init();
  touch_init();

  sensor_init(SENSOR_1, SD_OW1);
  sensor_init(SENSOR_2, SD_OW2);

  temp_control_init(CONTROLLER_1);
  temp_control_init(CONTROLLER_2);

  ota_update_init();
  net_init();
  web_api_init();
  sntp_init();
  gui_init();
  thread_watchdog_init();

  create_home_screen();

  recovery_screen_create();

  screen_saver_create();

  if (palReadPad(PORT_SELF_TEST_EN, PAD_SELF_TEST_EN) == 0) {
    widget_t* self_test_screen = self_test_screen_create();
    gui_push_screen(self_test_screen);
  }

  recovery_img_init();

  while (TRUE) {
    cmdline_restart();

    toggle_LED1();
  }
}
Beispiel #14
0
void notmain() {
  led_init();
  gpio_init();
  gfx_init();

  unsigned int index = 0;
  char line[60];
  line[0] = 0;
  
  gpio_set_input(GPIO_PIN23);
  gpio_set_input(GPIO_PIN24);
  gpio_set_pullup(GPIO_PIN23);
  gpio_set_pullup(GPIO_PIN24);
  //  while (1) {}
  while (1) {
    wait_for_clock();
    line[index] = '+';
    line[++index] = 0;
    gfx_clear();
    gfx_draw_string(0xFFFFFFFF, 20, 20, "Button pushes: ");
    gfx_draw_string(0xFFFFFFFF, 210, 20, line);
    gfx_draw();
  }
  
  while (1) {
    unsigned char ch = 0;
    int pinval;

    wait_for_clock();
    pinval = gpio_pin_read(GPIO_PIN24);
    if (pinval != 0) {
      //continue;
    }    

    int i;
    for (i = 0; i < 8; i++) {
      wait_for_clock();
      ch |= gpio_pin_read(GPIO_PIN24) << i;
    }

    wait_for_clock();
    wait_for_clock();

    ch = 'z'; //lookup_table[ch];
    if (index < LINE_SIZE) {
      line[index] = ch;
      line[index++] = 0;
    }
    gfx_clear();
    gfx_draw_string(0xFFFFFFFF, 20, 20, line);
    gfx_draw();
  }
 
}
Beispiel #15
0
void OSystem_Wii::switchVideoMode(int mode) {
	static const struct {
		gfx_video_mode_t mode;
		bool filter;
	} map[] = {
		{ GFX_MODE_DEFAULT, false },
		{ GFX_MODE_DEFAULT, true },
		{ GFX_MODE_DS, false },
		{ GFX_MODE_DS, true }
	};

	if (_gameHeight > 240) {
		if (mode == gmDoubleStrike)
			mode = gmStandard;
		else if (mode == gmDoubleStrikeFiltered)
			mode = gmStandardFiltered;
	}

	printf("switchVideoMode %d\n", mode);

	if (map[_actualGraphicsMode].mode != map[mode].mode) {
		GXRModeObj obj;

		gfx_video_deinit();
		gfx_video_get_modeobj(&obj, GFX_STANDARD_AUTO, map[mode].mode);
		gfx_video_init(&obj);
		gfx_init();
		gfx_con_init(NULL);
	}

	_actualGraphicsMode = mode;

	_bilinearFilter = map[mode].filter;
	gfx_tex_set_bilinear_filter(&_texGame, _bilinearFilter);
	gfx_tex_set_bilinear_filter(&_texMouse, _bilinearFilter);

	u16 usx, usy;
	if (map[mode].mode == GFX_MODE_DS) {
		usx = ConfMan.getInt("wii_video_ds_underscan_x",
								Common::ConfigManager::kApplicationDomain);
		usy = ConfMan.getInt("wii_video_ds_underscan_y",
								Common::ConfigManager::kApplicationDomain);
	} else {
		usx = ConfMan.getInt("wii_video_default_underscan_x",
								Common::ConfigManager::kApplicationDomain);
		usy = ConfMan.getInt("wii_video_default_underscan_y",
								Common::ConfigManager::kApplicationDomain);
	}

	gfx_set_underscan(usx, usy);
	gfx_coords(&_coordsOverlay, &_texOverlay, GFX_COORD_FULLSCREEN);
	gfx_coords(&_coordsGame, &_texGame, GFX_COORD_FULLSCREEN);
	updateScreenResolution();
}
Beispiel #16
0
/**
 * \brief Create the GFX task.
 *
 * \param stack_depth_words Task stack size in 32 bits word.
 * \param task_priority Task priority.
 */
void create_gfx_task(uint16_t stack_depth_words,
		unsigned portBASE_TYPE task_priority)
{
	/* Initialize display. */
	gfx_init();

	/* Create the task as described above. */
	xTaskCreate(gfx_task, (const signed char *const) "GFX",
			stack_depth_words, NULL, task_priority,
			NULL);
}
Beispiel #17
0
int main(int argc, char **argv)
{
	gfx_context *ctx = NULL;
	GtkWidget *window = NULL;
	gfx_text_layout* text = NULL;
	int r;

	/* Initialization */

	gfx_init(&argc, &argv);
	gtk_init(&argc, &argv);
	ctx = gfx_context_new(NULL);
	gfx_context_make_current(ctx);

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	canvas = gtk_drawing_area_new();
	gtk_window_set_default_size(GTK_WINDOW(window), 640,480);
	gtk_widget_set_double_buffered(canvas, FALSE);

	gtk_widget_set_events(canvas, GDK_EXPOSURE_MASK);
	gtk_widget_realize(GTK_WIDGET(window));
	gtk_container_add(GTK_CONTAINER(window), canvas);
	gtk_widget_show_all(GTK_WIDGET(window));

	/* Create a new framebuffer to draw */

	fb = gfx_framebuffer_new(640, 480, GFX_PIXELFORMAT_BGRA32, 0, 0);
	gfx_framebuffer_bind(fb);
	text = gfx_text_layout_new(640, 480);

	gfx_framebuffer_attach_texture(GFX_ATTACH_COLOR_BUFFER, (gfx_texture*)text);

	gfx_text_layout_set_pango_markup(text, "<span font='Sans 32'>あいうえお\nかきくけこ</span>");
	gfx_text_layout_set_background(text, 0.0, 0.0, 1.0, 1.0);
	gfx_text_layout_set_foreground(text, 1.0, 1.0, 0.0, 1.0);
	gfx_text_layout_set_alignment(text, PANGO_ALIGN_CENTER);
	gfx_text_layout_set_indent(text, 100);
	gfx_text_layout_set_line_spacing(text, 100);
	gfx_text_layout_render(text);

	g_signal_connect(window, "destroy", gtk_main_quit, NULL);
	g_signal_connect(canvas, "expose-event", G_CALLBACK(glcanvas_handler), NULL);

	gtk_main();

	/* Release resource */

	gfx_text_layout_delete(&text);
	gfx_framebuffer_delete(&fb);
	gfx_context_delete(&ctx);

	return EXIT_SUCCESS;
}
Beispiel #18
0
sl_def(t_main, void)
{
  gfx_init();
  gfx_resize(8, 8);

  unsigned long x;
  for (x = 0; x < 64; ++x)
    gfx_fb_set(x, ((x + x/8)%2) ? 0xffffff : 0);

  gfx_dump(0, 1, 0, 0);
  gfx_close();
}
Beispiel #19
0
int main(int argc, char **argv) {
	Gfx gfx;
	Model model;
	
	if(argc != 2) {
		printf("Invalid count of arguments!\nUsage %s FILENAME\n", argv[0]);
		return 1;
	}

	if(load_map(argv[1], &model))
		return 1;
	model_static_field(&model);
	gfx_init(&gfx, model.w, model.h);
	double t = SDL_GetTicks()/1000.-0.016;
	while(1) {
		int i;
		int nsteps = 5;

		if(gfx_event(&gfx) < 0)
			break;

		double dt = SDL_GetTicks()/1000.-t;
		dt = 0.06;
		if(nsteps < dt*C/DX*5) {
			nsteps = dt*C/DX*5+0.5;
			printf("nsteps %d\n", nsteps);
			if(nsteps > 30)
				nsteps = 30;
		}

		for(i = 0; i < nsteps; i++)
			model_update(&model, dt/nsteps);
		
		double rho = 0;
		int x, y;
		for(x = 0; x < model.w; x++) {
			for(y = 0; y < model.h; y++) {
				rho += model.rho[y*model.w+x];
			}
		}		
		double tdt = SDL_GetTicks()/1000.-t;
		t = SDL_GetTicks()/1000.;
		printf("%f fps aval = %g\n", 1./tdt, model.phi[model.tp][model.h/2*model.w+model.w*8/10-2]);
		gfx_draw(&gfx, &model);
	}

	gfx_deinit(&gfx);
	model_free(&model);

	return 0;
}
Beispiel #20
0
/*
 * And this is where we will generate our digits
 * when we copy them with the DMA2D device we can
 * use the color lookup table to set the values.
 * in this case we'll use 0, 1, and 2 for background
 * foreground, and outline color.
 *
 * While the digits are kerned in the display they are
 * drawn here with a box that is DISP_WIDTH + SKEW_MAX
 * pixels wide, but DISP_HEIGHT pixels high.
 */
void
generate_digits(void)
{
	uint32_t i;
	gfx_init(digit_draw_pixel, DIGIT_FB_WIDTH, DIGIT_FB_HEIGHT, GFX_FONT_LARGE);
	/* Cleared to zero (background) */
	for (i = 0; i < sizeof(digit_fb); i++) {
		digit_fb[i] = 0;
	}
	for (i = 0; i < 10; i++) {
		draw_digit(i * (DISP_WIDTH + SKEW_MAX), 0, i, 1, 2);
	}
	draw_colon(10 * (DISP_WIDTH + SKEW_MAX), 0, 1, 2);
	draw_dp(10 * (DISP_WIDTH + SKEW_MAX) + SEG_THICK + SKEW_MAX, 0, 1, 2);
	/* now the digit_fb memory has the 10 digits 0-9, : and . in it */
}
Beispiel #21
0
int main() {
  sei(); // enable interrupts
  bot_init();
  spi_init();
  display_init();                       /* Displayansteuerung initialisieren */
  gfx_init();                           /* Grafikdisplay initialisieren */
  leds_init();
  floor_init();
  
  gfx_move(62, 0);
  gfx_set_proportional(1);
  gfx_print_text("floor stop");
  gfx_set_proportional(0);

  delay(50);
  copro_ir_startMeasure();
  copro_setSpeedParameters(5, 6, 7);

  copro_update();  
  uint8_t go = 0;
  
  while (1) {
    sei();
    _delay_ms(1);
    floor_update();
    if (go==0) {
      if ((floor_relative[FLOOR_LEFT]>THRESHOLD) && (floor_relative[FLOOR_RIGHT]>THRESHOLD)) {
        // Boden links und rechts vorhanden -> losfahren!
        go=1;
        copro_setSpeed(40, 40);
        IO_LEDS_RED_PORT=0x00;
        IO_LEDS_GREEN_PORT=0x84;
      }
    } else {
      if ((floor_relative[FLOOR_LEFT]<THRESHOLD) || (floor_relative[FLOOR_RIGHT]<THRESHOLD)) {
        // Boden links oder rechts verloren -> sofort stoppen!
        go=0;
        copro_stopImmediate();
        IO_LEDS_RED_PORT=0x84;
        IO_LEDS_GREEN_PORT=0x00;
      }
    }
    
  }
  return 0;
}
Beispiel #22
0
int32_t st_changeOutputMode(videoOutput_t *p_videoOutput, const char *newOutputFormat)
{
	uint32_t	old_height;
	uint32_t	new_height;
	uint32_t	len;

	if(!p_videoOutput || !newOutputFormat)
		return -1;
	old_height = stHelper_getFormatHeight(p_videoOutput->currentFormat);
	new_height = stHelper_getFormatHeight(newOutputFormat);

	if (old_height != new_height) {
		gfx_stopEventThread();
		gfx_terminate();
		stHelper_sendToElcd("deinitfb");
		st_setVideoFormat(p_videoOutput->name, newOutputFormat);
		stHelper_sendToElcd("initfb");
		stHelper_waitForFBdevice("/dev/fb0");
		if(p_videoOutput->isMajor) {
			if (new_height < 720 && interfaceInfo.screenHeight >= 720) {
				// Reset graphics mode for small resolutions
				appControlInfo.outputInfo.graphicsMode[0] = 0;
				saveAppSettings();
			}
			if (appControlInfo.outputInfo.graphicsMode[0] == 0) {
				stHelper_setDirectFBMode(stHelper_getFormatWidth(new_height), new_height);
			}
		}
		gfx_init(0, NULL);
		interface_resize();
		gfx_startEventThread();
		needRestart = 1;
	} else {
		st_setVideoFormat(p_videoOutput->name, newOutputFormat);
	}

	len = sizeof(p_videoOutput->currentFormat);
	strncpy(p_videoOutput->currentFormat, newOutputFormat, len);
	p_videoOutput->currentFormat[len - 1] = 0;

#ifdef ENABLE_FUSION
	fusion_fakeRestart();
#endif

	return 0;
}
Beispiel #23
0
int main(int argc, char **argv)
{
	gfx_context *ctx = NULL;
	GtkWidget *window = NULL;
	gfx_texture *tex = NULL;
	int r;

	/* Initialization */

	gfx_init(&argc, &argv);
	gtk_init(&argc, &argv);
	ctx = gfx_context_new(NULL);
	gfx_context_make_current(ctx);

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	canvas = gtk_drawing_area_new();
	gtk_window_set_default_size(GTK_WINDOW(window), 640,480);
	gtk_widget_set_double_buffered(canvas, FALSE);

	gtk_widget_set_events(canvas, GDK_EXPOSURE_MASK);
	gtk_widget_realize(GTK_WIDGET(window));
	gtk_container_add(GTK_CONTAINER(window), canvas);
	gtk_widget_show_all(GTK_WIDGET(window));

	/* Create a new framebuffer to draw */

	fb = gfx_framebuffer_new(480, 480, GFX_PIXELFORMAT_BGRA32, 0, 0);
	gfx_framebuffer_bind(fb);
	tex = gfx_texture_new_from_file(GFX_PIXELFORMAT_BGR24, GFX_IMAGE_FORMAT_BMP, "test.bmp");

	gfx_framebuffer_attach_texture(GFX_ATTACH_COLOR_BUFFER, tex);

	g_signal_connect(window, "destroy", gtk_main_quit, NULL);
	g_signal_connect(canvas, "expose-event", G_CALLBACK(glcanvas_handler), NULL);

	gtk_main();

	/* Release resource */

	gfx_texture_delete(&tex);
	gfx_framebuffer_delete(&fb);
	gfx_context_delete(&ctx);

	return EXIT_SUCCESS;
}
Beispiel #24
0
void notmain() {
  led_init();
  gpio_init();
  gfx_init();
  
  gpio_set_input(GPIO_PIN23); 
  gpio_set_pullup(GPIO_PIN23); 
  gpio_set_input(GPIO_PIN24); 
  gpio_set_pullup(GPIO_PIN24); 

  string[0] = 'Z';
  string[1] = 0;
  len = 1;
  gfx_draw_letter(0xFFFFFFFF, 200, 20, '!');
  
  while (1) {
    /* Code removed as it's part of assignment 6. */
  }

}
Beispiel #25
0
/* Entry from cache-as-ram.inc. */
void * asmlinkage romstage_main(unsigned long bist,
                                uint32_t tsc_low, uint32_t tsc_hi)
{
	struct romstage_params rp = {
		.bist = bist,
		.mrc_params = NULL,
	};

	/* Save initial timestamp from bootblock. */
	timestamp_init((((uint64_t)tsc_hi) << 32) | (uint64_t)tsc_low);

	/* Save romstage begin */
	timestamp_add_now(TS_START_ROMSTAGE);

	program_base_addresses();

	tco_disable();

	byt_config_com1_and_enable();

	console_init();

	spi_init();

	set_max_freq();

	punit_init();

	gfx_init();

#if CONFIG_EC_GOOGLE_CHROMEEC
	/* Ensure the EC is in the right mode for recovery */
	google_chromeec_early_init();
#endif

	/* Call into mainboard. */
	mainboard_romstage_entry(&rp);

	return setup_stack_and_mttrs();
}
Beispiel #26
0
/* Entry from cache-as-ram.inc. */
void *asmlinkage romstage_main(unsigned long bist, uint32_t tsc_low,
			       uint32_t tsc_hi)
{
	struct romstage_params rp = {
		.bist = bist,
		.mrc_params = NULL,
	};

	/* Save initial timestamp from bootblock. */
	timestamp_init((((uint64_t)tsc_hi) << 32) | (uint64_t)tsc_low);

	/* Save romstage begin */
	timestamp_add_now(TS_START_ROMSTAGE);

	program_base_addresses();

	tco_disable();

	byt_config_com1_and_enable();

	console_init();

	spi_init();

	set_max_freq();

	punit_init();

	gfx_init();

	/* Call into mainboard. */
	mainboard_romstage_entry(&rp);

	platform_enter_postcar();

	/* We don't return here */
	return NULL;
}
/**
 * \brief Main application loop
 *
 * This is the main application function, which runs all the initialization
 * code, clears the display and enters a loop in which it continuously polls for
 * new messages from the maXTouch device. If one or more messages are pending,
 * the maXTouch message handler is invoked.
 */
int main(void)
{
	/* maXTouch data structure */
	static struct mxt_device device;

	/* Basic init routines */
	board_init();
	sysclk_init();
	gfx_init();
	mxt_init(&device);

	/* Clear the display */
	gfx_draw_filled_rect(0, 0, gfx_get_width(), gfx_get_height(),
			DISPLAY_COLOR);

	while (true) {
		/* Check for any pending messages and run message handler if any
		 * message is found in the queue */
		if (mxt_is_message_pending(&device)) {
			mxt_handler(&device);
		}
	}
}
Beispiel #28
0
/**
 * \brief Main application loop
 *
 * This is the main application function, which runs all the initialization
 * code, clears the display and enters a loop in which it continuously polls
 * for new messages from the maXTouch device. If one or more messages are
 *  pending, the maXTouch message handler is invoked.
 */
int main(void)
{
	/* maXTouch data structure */
	static struct mxt_device device;

	/* Basic init routines */
	board_init();
	sysclk_init();
	gfx_init();
	mxt_init(&device);

	/* Draw the paint pallet to the display */
	draw_paint_pallet();

	/* Draw instructions to the display */
	gfx_draw_string_aligned(
			"Select a color from the pallet below, and\n"
			"use your finger(s) to draw onto the display.\n\n"
			"Multiple simultaneous fingers are supported,\n"
			"and the drawing size varies according to the\n"
			"pressure of the touch.\n\n"
			"Select MUL to draw using multiple colors.\n\n"
			"Select CLR to clear the display.",
			gfx_get_width() / 2,
			(gfx_get_height() - PALLET_HEIGHT) / 2,
			&sysfont, GFX_COLOR_TRANSPARENT, GFX_COLOR_WHITE,
			TEXT_POS_CENTER, TEXT_ALIGN_LEFT);

	while (true) {
		/* Check for any pending messages and run message handler if any
		 * message is found in the queue */
		if (mxt_is_message_pending(&device)) {
			mxt_handler(&device);
		}
	}
}
Beispiel #29
0
// TODO this is just my console test app, clean up this mess!
int main(int argc, char *argv[]) {
	(void) argc;
	(void) argv;

	VIDEO_Init();
	PAD_Init();

	SYS_SetResetCallback(stmcb);
	SYS_SetPowerCallback(stmcb);

	gfx_video_init(NULL);
	gfx_init();
	gfx_con_init(NULL);

	printf("startup\n");

	gfx_tex_t tex;
	memset(&tex, 0, sizeof(gfx_tex_t));
	if (!gfx_tex_init(&tex, GFX_TF_RGB565, 0, 16, 16)) {
		printf("failed to init tex!\n");
		return 1;
	}
	memset(tex.pixels, 0xe070, 16 * 16 * 2);
	gfx_tex_flush_texture(&tex);

	gfx_screen_coords_t coords_bg;
	gfx_coords(&coords_bg, &tex, GFX_COORD_FULLSCREEN);

	srand(gettime());

	u64 frame = 0;
	u16 b;
	bool pf = false;
	u32 retries;
	u8 fg = 7, bg = 0;
	u32 i;
	char buf[32];

	while (!quit) {
		b = 0;
		if (PAD_ScanPads() & 1) {
			b = PAD_ButtonsDown(0);
		
			gfx_con_set_alpha(0xff - PAD_TriggerR(0), 0xff - PAD_TriggerL(0));
		}

		if (b & PAD_BUTTON_A)
			quit = true;

		if (b & PAD_BUTTON_B)
			pf = !pf;

		if (b & PAD_BUTTON_X)
			printf(S_RED("Hello") " " S_BLUE("world") "!\n");

		if (pf) {
			for (i = 0; i < gfx_con_get_columns() * gfx_con_get_rows(); ++i) {
				printf(CON_ESC "%u;1m" CON_ESC "%um%c", 30 + IRAND(8),
						40 + IRAND(8), 0x20 + IRAND(16 * 9));
			}
		}

		if (b & PAD_TRIGGER_Z) {
			gfx_con_reset();
			fg = 7;
			bg = 0;
		}

		if (b & 15) {
			if (b & PAD_BUTTON_LEFT) {
				fg = (fg + 8 - 1) % 8;
				gfx_con_set_foreground_color(fg, true);
			}
			if (b & PAD_BUTTON_RIGHT) {
				fg = (fg + 1) % 8;
				gfx_con_set_foreground_color(fg, true);
			}
			if (b & PAD_BUTTON_UP) {
				bg = (bg + 8 - 1) % 8;
				gfx_con_set_background_color(bg, false);
			}
			if (b & PAD_BUTTON_DOWN) {
				bg = (bg + 1) % 8;
				gfx_con_set_background_color(bg, false);
			}

			printf("new color selected: %u %u\n", fg, bg);
		}

		sprintf(buf, "frame: %llu", frame);
		gfx_con_save_attr();
		gfx_con_set_pos(1, gfx_con_get_columns() - strlen(buf) + 1);
		printf(CON_COLRESET "%s", buf);
		gfx_con_restore_attr();

		retries = 0;
		while (!gfx_frame_start()) {
			retries++;
			if (retries > 1000) {
				printf("gx hates you\n");
				gfx_frame_abort();
				return -1;
			}

			usleep(50);
		}

		gfx_draw_tex(&tex, &coords_bg);
		gfx_con_draw();

		gfx_frame_end();

		frame++;
	}

	printf("shutdown\n");

	gfx_tex_deinit(&tex);
	gfx_con_deinit();
	gfx_deinit();
	gfx_video_deinit();

	return 0;
}
Beispiel #30
0
int main (int argc, const char **argv)
{
#ifdef WIN32
	{
		// set the console to accept escape sequences (Win10+)
		HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);

		if (console != INVALID_HANDLE_VALUE)
		{
			DWORD consoleMode = 0;
			GetConsoleMode(console, &consoleMode);

			consoleMode |= 4; // ENABLE_VIRTUAL_TERMINAL_PROCESSING; but that isn't available in our current SDK target

			SetConsoleMode(console, consoleMode);
		}
	}
#endif

    int exit_code = EXIT_SUCCESS;

    try {

        // Experiment with floating point masks.
        // #ifdef FE_NOMASK_ENV
        // feenableexcept(FE_INVALID);
        // feenableexcept(FE_DIVBYZERO | FE_INVALID);
        // #endif

        bgl = new BackgroundLoader();

        size_t winid = gfx_init(cb);

        debug_drawer = new BulletDebugDrawer(ogre_sm); // FIXME: hack

        #ifdef WIN32
        mouse = new MouseDirectInput8(winid);
        bool use_dinput = getenv("GRIT_DINPUT")!=NULL;
        keyboard = use_dinput ? (Keyboard *)new KeyboardDirectInput8(winid)
                      : (Keyboard *)new KeyboardWinAPI(winid);
        #else
        mouse = new MouseX11(winid);
        keyboard = new KeyboardX11(winid);
        #endif
        clipboard_init();

        physics_init();

        net_init();

        core_option_init();
        streamer_init();

        navigation_init();

        // audio_init(getenv("GRIT_AUDIO_DEV"));
        audio_init(NULL);

        std::vector<std::string> args;
        for (int i=0 ; i<argc ; i++) {
            args.push_back(argv[i]);
        }

        try {
            const char *init_file = getenv("GRIT_INIT");
            if (init_file == nullptr) init_file = "/system/init.lua";
            init_lua(init_file, args, core_L);
        } catch (Exception &e) {
            CERR << "Fatal error: " << e << std::endl;
            exit_code = EXIT_FAILURE;
        }

        // Lua returns - we quit.
        
        CVERB << "Shutting down Lua net subsystem..." << std::endl;

        net_shutdown(core_L);

        navigation_shutdown();

        object_all_del(core_L);  // Will remove all demands from background loader.

        CVERB << "Shutting down Lua graphics subsystem..." << std::endl;

        gfx_shutdown_lua(core_L);

        CVERB << "Shutting down Background Loader..." << std::endl;

        bgl->shutdown();

        CVERB << "Shutting down Mouse & Keyboard..." << std::endl;

        if (mouse) delete mouse;
        if (keyboard) delete keyboard;

        CVERB << "Shutting down clipboard..." << std::endl;
        clipboard_shutdown();

        CVERB << "Shutting down Lua VM..." << std::endl;
        if (core_L) shutdown_lua(core_L);

        CVERB << "Shutting down audio subsystem..." << std::endl;
        audio_shutdown(); //close AL device

        CVERB << "Shutting down physics subsystem..." << std::endl;
        physics_shutdown();

        CVERB << "Shutting down the physics debug drawer..." << std::endl;
        if (debug_drawer) delete debug_drawer;

        CVERB << "Shutting down the Graphics subsystem..." << std::endl;
        gfx_shutdown();

        delete bgl;

    } catch (Exception &e) {
        std::cerr << "TOP LEVEL ERROR: " << e << std::endl;
        return EXIT_FAILURE;
    }

    return exit_code;
}