metalsvm/apps/gfx_generic.c

123 lines
2.7 KiB
C

/*
* Copyright 2011 Sarah Fischer, Nicolas Berr, Pablo Reble
* Chair for Operating Systems, RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of MetalSVM.
*/
#include "gfx_client.h"
#include "gfx_generic.h"
#if defined(CONFIG_GFX) && defined(CONFIG_LWIP) && LWIP_SOCKET
int GFX_update()
{
return gfx_send(NULL, 0, GFX_UPDATE);
}
int GFX_usleep(int sleep_time)
{
int buf[1];
buf[0] = sleep_time;
return gfx_send((char*)buf, sizeof(int), GFX_USLEEP);
}
int GFX_set_rgb(int index, int r, int g, int b)
{
int buf[4];
buf[0] = index;
buf[1] = r;
buf[2] = g;
buf[3] = b;
return gfx_send((char*)buf, 4*sizeof(int), GFX_SET_RGB);
}
int GFX_set_xy(int x, int y)
{
int buf[2];
buf[0] = x;
buf[1] = y;
return gfx_send((char*)buf, 2*sizeof(int), GFX_SET_XY);
}
int GFX_set_hd(int height, int direction)
{
int buf[2];
buf[0] = height;
buf[1] = direction;
return gfx_send((char*)buf, 2*sizeof(int), GFX_SET_HD);
}
int GFX_draw_data(char *buf, int len)
{
return gfx_send(buf, len, GFX_DRAW_DATA);
}
int GFX_draw_pixel(int x, int y, int color)
{
int buf[3];
buf[0] = x;
buf[1] = y;
buf[2] = color;
return gfx_send((char*)buf, 3*sizeof(int), GFX_DRAW_PIXEL);
}
int GFX_draw_line(int x1, int y1, int x2, int y2, int color)
{
int buf[5];
buf[0] = x1;
buf[1] = y1;
buf[2] = x2;
buf[3] = y2;
buf[4] = color;
return gfx_send((char*)buf, 5*sizeof(int), GFX_DRAW_LINE);
}
int GFX_draw_box(int x, int y, int height, int width, int color)
{
int buf[5];
buf[0] = x;
buf[1] = y;
buf[2] = height;
buf[3] = width;
buf[4] = color;
return gfx_send((char*)buf, 5*sizeof(int), GFX_DRAW_BOX);
}
int GFX_draw_text(int x, int y, int color, char *text)
{
int buf[32];
buf[0] = x;
buf[1] = y;
buf[2] = color;
strcpy((char*)&(buf[3]), text);
return gfx_send((char*)buf, 32*sizeof(int), GFX_DRAW_TEXT);
}
int GFX_draw_points(int* points, int num)
{
return gfx_send((char*)points, num*3*sizeof(int), GFX_DRAW_POINTS);
}
int GFX_draw_poly(int* points, int num, int color)
{
int i;
for(i=0; i<num; i++) points[i*3+2] = color;
return gfx_send((char*)points, num*3*sizeof(int), GFX_DRAW_POLY);
}
#endif