示例#1
0
文件: i_video.c 项目: bigzed/uGFX
//
// I_FinishUpdate
//
void I_FinishUpdate (void)
{
	register byte		*p;
	register coord_t	x, y;

	gdispStreamStart(0, 0, w*multiply, h*multiply);

	if (multiply == 1) {
		for(p = screens[0], y=0; y < h; y++, p+=ldiff) {
			for(x = 0; x < w; x++, p++)
				gdispStreamColor(colors[*p]);
		}
	} else {
		for(p = screens[0], y=0; y < h; y++, p+=ldiff) {
			for(x = 0; x < w; x++, p++) {
				gdispStreamColor(colors[*p]);
				gdispStreamColor(colors[*p]);
			}
			for(p -= w, x = 0; x < w; x++, p++) {
				gdispStreamColor(colors[*p]);
				gdispStreamColor(colors[*p]);
			}
		}
	}
	gdispStreamStop();

	// Force a display update if the controller supports it
	gdispFlush();
}
示例#2
0
bool keyframe_display_layer_text(keyframe_animation_t* animation, visualizer_state_t* state) {
    (void)animation;
    gdispClear(White);
    gdispDrawString(0, 10, state->layer_text, state->font_dejavusansbold12, Black);
    gdispFlush();
    return false;
}
示例#3
0
bool keyframe_display_layer_bitmap(keyframe_animation_t* animation, visualizer_state_t* state) {
    (void)animation;
    const char* layer_help = "1=On D=Default B=Both";
    char layer_buffer[16 + 4]; // 3 spaces and one null terminator
    gdispClear(White);
    gdispDrawString(0, 0, layer_help, state->font_fixed5x8, Black);
    format_layer_bitmap_string(state->status.default_layer, state->status.layer, layer_buffer);
    gdispDrawString(0, 10, layer_buffer, state->font_fixed5x8, Black);
    format_layer_bitmap_string(state->status.default_layer >> 16, state->status.layer >> 16, layer_buffer);
    gdispDrawString(0, 20, layer_buffer, state->font_fixed5x8, Black);
    gdispFlush();
    return false;
}
示例#4
0
bool keyframe_display_mods_bitmap(keyframe_animation_t* animation, visualizer_state_t* state) {
    (void)animation;

    const char* title = "Modifier states";
    const char* mods_header = " CSAG CSAG ";
    char status_buffer[12]; 
    
    gdispClear(White);
    gdispDrawString(0, 0, title, state->font_fixed5x8, Black);
    gdispDrawString(0, 10, mods_header, state->font_fixed5x8, Black);
    format_mods_bitmap_string(state->status.mods, status_buffer);
    gdispDrawString(0, 20, status_buffer, state->font_fixed5x8, Black);

    gdispFlush();
    return false;
}
示例#5
0
文件: main.c 项目: bhdminh/uGFX
/**
 * Our main function.
 * There are two prototypes - one for systems with a command line and one for embedded systems without one.
 */
int main(proto_args) {
	uint16_t			cmd[5];
	unsigned			cnt;


	// Initialize and clear the display
	gfxInit();
	font = gdispOpenFont("UI2");

	// Open the connection
	gdispDrawStringBox(0, 0, gdispGetWidth(), gdispGetHeight(), "Connecting to host...", font, White, justifyCenter);
	StartSockets();
	netfd = doConnect(cmd_args);
	if (netfd == (SOCKET_TYPE)-1)
		gfxHalt("Could not connect to the specified server");
	gdispClear(Black);

	// Get the initial packet from the host
	if (!getpkt(cmd, 2)) goto alldone;
	if (cmd[0] != GNETCODE_INIT || cmd[1] != GNETCODE_VERSION)
		gfxHalt("Oops - The protocol doesn't look like one we understand");

	// Get the rest of the initial arguments
	if (!getpkt(cmd, 4)) goto alldone;						// cmd[] = width, height, pixelformat, hasmouse

	// We will ignore size mismatches but the pixel format must match
	if (cmd[2] != GDISP_PIXELFORMAT)
		gfxHalt("Oops - The remote display is using a different pixel format to us.\nTry defining GDISP_PIXELFORMAT in your gfxconf.h file.");

	#if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
		// Start the mouse thread if needed
		if (cmd[3])
			gfxThreadClose(gfxThreadCreate(waNetThread, sizeof(waNetThread), HIGH_PRIORITY, NetThread, 0));
	#endif

	// Process incoming instructions
	while(getpkt(cmd, 1)) {
		switch(cmd[0]) {
		case GNETCODE_FLUSH:
			gdispFlush();
			break;
		case GNETCODE_PIXEL:
			if (!getpkt(cmd, 3)) goto alldone;				// cmd[] = x, y, color
			gdispDrawPixel(cmd[0], cmd[1], cmd[2]);
			break;
		case GNETCODE_FILL:
			if (!getpkt(cmd, 5)) goto alldone;				// cmd[] = x, y, cx, cy, color
			gdispFillArea(cmd[0], cmd[1], cmd[2], cmd[3], cmd[4]);
			break;
		case GNETCODE_BLIT:
			if (!getpkt(cmd, 4)) goto alldone;				// cmd[] = x, y, cx, cy		- Followed by cx * cy pixels
			gdispStreamStart(cmd[0],cmd[1],cmd[2],cmd[3]);
			for(cnt = (unsigned)cmd[2] * cmd[3]; cnt; cnt--) {
				if (!getpkt(cmd, 1)) goto alldone;
				gdispStreamColor(cmd[0]);
			}
			gdispStreamStop();
			break;
		#if GDISP_NEED_PIXELREAD
			case GNETCODE_READ:
				if (!getpkt(cmd, 2)) goto alldone;				// cmd[] = x, y				- Response is GNETCODE_READ,color
				cmd[1] = gdispGetPixelColor(cmd[0], cmd[1]);
				cmd[0] = GNETCODE_READ;
				if (!sendpkt(cmd, 2)) goto alldone;
				break;
		#endif
		#if GDISP_NEED_SCROLL
			case GNETCODE_SCROLL:
				if (!getpkt(cmd, 5)) goto alldone;				// cmd[] = x, y, cx, cy, lines
				gdispVerticalScroll(cmd[0], cmd[1], cmd[2], cmd[3], cmd[4], Black);
				break;
		#endif
		case GNETCODE_CONTROL:
			if (!getpkt(cmd, 2)) goto alldone;				// cmd[] = what,data		- Response is GNETCODE_CONTROL, 0x0000 (fail) or GNETCODE_CONTROL, 0x0001 (success)
			gdispControl(cmd[0], (void *)(unsigned)cmd[1]);
			switch(cmd[0]) {
			case GDISP_CONTROL_ORIENTATION:
				cmd[1] = (uint16_t)gdispGetOrientation() == cmd[1] ? 1 : 0;
				break;
			case GDISP_CONTROL_POWER:
				cmd[1] = (uint16_t)gdispGetPowerMode() == cmd[1] ? 1 : 0;
				break;
			case GDISP_CONTROL_BACKLIGHT:
				cmd[1] = (uint16_t)gdispGetBacklight() == cmd[1] ? 1 : 0;
				break;
			default:
				cmd[1] = 0;
				break;
			}
			cmd[0] = GNETCODE_CONTROL;
			if (!sendpkt(cmd, 2)) goto alldone;
			break;
		default:
			gfxHalt("Oops - The host has sent invalid commands");
			break;
		}
	}

alldone:
	closesocket(netfd);
	gfxHalt("Connection closed");
	return 0;
}