|
From: <ane...@us...> - 2006-11-14 08:41:51
|
Revision: 138
http://svn.sourceforge.net/g15daemon/?rev=138&view=rev
Author: aneurysm9
Date: 2006-11-14 00:41:46 -0800 (Tue, 14 Nov 2006)
Log Message:
-----------
Convert g15_plugin_clock to use libg15render
Remove gfx_primitives.c
Modified Paths:
--------------
trunk/g15daemon-wip/g15daemon/Makefile.am
trunk/g15daemon-wip/g15daemon/g15daemon.h
trunk/g15daemon-wip/g15daemon/utility_funcs.c
trunk/g15daemon-wip/plugins/g15_plugin_clock.c
Removed Paths:
-------------
trunk/g15daemon-wip/g15daemon/gfx_primitives.c
Modified: trunk/g15daemon-wip/g15daemon/Makefile.am
===================================================================
--- trunk/g15daemon-wip/g15daemon/Makefile.am 2006-11-14 07:34:50 UTC (rev 137)
+++ trunk/g15daemon-wip/g15daemon/Makefile.am 2006-11-14 08:41:46 UTC (rev 138)
@@ -3,8 +3,7 @@
sbin_PROGRAMS = g15daemon
noinst_PROGRAMS = g15daemontest
noinst_HEADERS = g15logo.h
-g15daemon_SOURCES = utility_funcs.c \
- g15daemon.h main.c linked_lists.c gfx_primitives.c g15_plugins.c
+g15daemon_SOURCES = utility_funcs.c g15daemon.h main.c linked_lists.c g15_plugins.c
g15daemon_LDADD = -ldl
g15daemon_LDFLAGS = -rdynamic
g15daemontest_SOURCES = lcdclient_test.c
Modified: trunk/g15daemon-wip/g15daemon/g15daemon.h
===================================================================
--- trunk/g15daemon-wip/g15daemon/g15daemon.h 2006-11-14 07:34:50 UTC (rev 137)
+++ trunk/g15daemon-wip/g15daemon/g15daemon.h 2006-11-14 08:41:46 UTC (rev 138)
@@ -196,15 +196,6 @@
/* the following functions are available for use by plugins */
-/* set or unset a pixel in the provided lcd's buffer */
-void g15daemon_setpixel (lcd_t * lcd, unsigned int x1, unsigned int y1, unsigned int color);
-/* draw large number <num> with the dimensions provided */
-void g15daemon_draw_bignum (lcd_t * lcd, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int color, int num);
-/* draw a line */
-void g15daemon_line (lcd_t * lcd, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int colour);
-/* draw filled or unfilled rectangle */
-void g15daemon_rectangle (lcd_t * lcd, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, int filled, unsigned int colour);
-
/* send event to foreground client's eventlistener */
int g15daemon_send_event(void *caller, unsigned int event, unsigned long value);
/* open named plugin */
Deleted: trunk/g15daemon-wip/g15daemon/gfx_primitives.c
===================================================================
--- trunk/g15daemon-wip/g15daemon/gfx_primitives.c 2006-11-14 07:34:50 UTC (rev 137)
+++ trunk/g15daemon-wip/g15daemon/gfx_primitives.c 2006-11-14 08:41:46 UTC (rev 138)
@@ -1,199 +0,0 @@
-/*
- This file is part of g15daemon.
-
- g15daemon is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- g15daemon is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with g15daemon; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
- (c) 2006 Mike Lampard, Philip Lawatsch, and others
-
- $Revision$ - $Date$ $Author$
-
- This daemon listens on localhost port 15550 for client connections,
- and arbitrates LCD display. Allows for multiple simultaneous clients.
- Client screens can be cycled through by pressing the 'L1' key.
-*/
-#define G15DAEMON_BUILD 1
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "g15daemon.h"
-#include <libg15.h>
-
-/* set a pixel in a libg15 buffer */
-void g15daemon_setpixel(lcd_t *lcd, unsigned int x, unsigned int y, unsigned int val)
-{
- unsigned int curr_row = y;
- unsigned int curr_col = x;
-
- unsigned int pixel_offset = curr_row * LCD_WIDTH + curr_col;
- unsigned int byte_offset = pixel_offset / 8;
- unsigned int bit_offset = 7-(pixel_offset % 8);
-
- if (val)
- lcd->buf[byte_offset] = lcd->buf[byte_offset] | 1 << bit_offset;
- else
- lcd->buf[byte_offset] = lcd->buf[byte_offset] & ~(1 << bit_offset);
-}
-
-
-void g15daemon_line (lcd_t * lcd, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int colour) {
-
- int d, sx, sy, dx, dy;
- unsigned int ax, ay;
-
- x1 = x1 - 1;
- y1 = y1 - 1;
- x2 = x2 - 1;
- y2 = y2 - 1;
-
- dx = x2 - x1;
- ax = abs (dx) << 1;
- if (dx < 0)
- sx = -1;
- else
- sx = 1;
-
- dy = y2 - y1;
- ay = abs (dy) << 1;
- if (dy < 0)
- sy = -1;
- else
- sy = 1;
-
- /* set the pixel */
- g15daemon_setpixel (lcd, x1, y1, colour);
-
- if (ax > ay)
- {
- d = ay - (ax >> 1);
- while (x1 != x2)
- {
- if (d >= 0)
- {
- y1 += sy;
- d -= ax;
- }
- x1 += sx;
- d += ay;
- g15daemon_setpixel (lcd, x1, y1, colour);
- }
- }
- else
- {
- d = ax - (ay >> 1);
- while (y1 != y2)
- {
- if (d >= 0)
- {
- x1 += sx;
- d -= ay;
- }
- y1 += sy;
- d += ax;
- g15daemon_setpixel (lcd, x1, y1, colour);
- }
- }
-}
-
-
-void g15daemon_rectangle (lcd_t * lcd, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, int filled, unsigned int colour) {
-
- int y;
-
- if (x1 != x2 && y1 != y2)
- {
- if (!filled)
- {
- g15daemon_line (lcd, x1, y1, x2, y1, colour);
- g15daemon_line (lcd, x1, y1, x1, y2, colour);
- g15daemon_line (lcd, x1, y2, x2, y2, colour);
- g15daemon_line (lcd, x2, y1, x2, y2, colour);
- }
- else
- {
- for (y = y1; y <= y2; y++)
- {
- g15daemon_line(lcd,x1,y,x2,y,colour);
- }
- }
- }
-}
-
-
-void g15daemon_draw_bignum (lcd_t * lcd, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int colour, int num) {
- x1 += 2;
- x2 -= 2;
-
- switch(num){
- case 45:
- g15daemon_rectangle (lcd, x1, y1+((y2/2)-2), x2, y1+((y2/2)+2), 1, BLACK);
- break;
- case 46:
- g15daemon_rectangle (lcd, x2-5, y2-5, x2, y2 , 1, BLACK);
- break;
- case 48:
- g15daemon_rectangle (lcd, x1, y1, x2, y2 , 1, BLACK);
- g15daemon_rectangle (lcd, x1 +5, y1 +5, x2 -5, y2 - 6, 1, WHITE);
- break;
- case 49:
- g15daemon_rectangle (lcd, x2-5, y1, x2, y2 , 1, BLACK);
- g15daemon_rectangle (lcd, x1, y1, x2 -5, y2, 1, WHITE);
- break;
- case 50:
- g15daemon_rectangle (lcd, x1, y1, x2, y2 , 1, BLACK);
- g15daemon_rectangle (lcd, x1, y1+5, x2 -5, y1+((y2/2)-3), 1, WHITE);
- g15daemon_rectangle (lcd, x1+5, y1+((y2/2)+3), x2 , y2-6, 1, WHITE);
- break;
- case 51:
- g15daemon_rectangle (lcd, x1, y1, x2, y2 , 1, BLACK);
- g15daemon_rectangle (lcd, x1, y1+5, x2 -5, y1+((y2/2)-3), 1, WHITE);
- g15daemon_rectangle (lcd, x1, y1+((y2/2)+3), x2-5 , y2-6, 1, WHITE);
- break;
- case 52:
- g15daemon_rectangle (lcd, x1, y1, x2, y2 , 1, BLACK);
- g15daemon_rectangle (lcd, x1, y1+((y2/2)+3), x2 -5, y2, 1, WHITE);
- g15daemon_rectangle (lcd, x1+5, y1, x2-5 , y1+((y2/2)-3), 1, WHITE);
- break;
- case 53:
- g15daemon_rectangle (lcd, x1, y1, x2, y2 , 1, BLACK);
- g15daemon_rectangle (lcd, x1+5, y1+5, x2 , y1+((y2/2)-3), 1, WHITE);
- g15daemon_rectangle (lcd, x1, y1+((y2/2)+3), x2-5 , y2-6, 1, WHITE);
- break;
- case 54:
- g15daemon_rectangle (lcd, x1, y1, x2, y2 , 1, BLACK);
- g15daemon_rectangle (lcd, x1+5, y1+5, x2 , y1+((y2/2)-3), 1, WHITE);
- g15daemon_rectangle (lcd, x1+5, y1+((y2/2)+3), x2-5 , y2-6, 1, WHITE);
- break;
- case 55:
- g15daemon_rectangle (lcd, x1, y1, x2, y2 , 1, BLACK);
- g15daemon_rectangle (lcd, x1, y1+5, x2 -5, y2, 1, WHITE);
- break;
- case 56:
- g15daemon_rectangle (lcd, x1, y1, x2, y2 , 1, BLACK);
- g15daemon_rectangle (lcd, x1+5, y1+5, x2-5 , y1+((y2/2)-3), 1, WHITE);
- g15daemon_rectangle (lcd, x1+5, y1+((y2/2)+3), x2-5 , y2-6, 1, WHITE);
- break;
- case 57:
- g15daemon_rectangle (lcd, x1, y1, x2, y2 , 1, BLACK);
- g15daemon_rectangle (lcd, x1+5, y1+5, x2-5 , y1+((y2/2)-3), 1, WHITE);
- g15daemon_rectangle (lcd, x1, y1+((y2/2)+3), x2-5 , y2, 1, WHITE);
- break;
- case 58:
- g15daemon_rectangle (lcd, x2-5, y1+5, x2, y1+10 , 1, BLACK);
- g15daemon_rectangle (lcd, x2-5, y2-10, x2, y2-5 , 1, BLACK);
- break;
-
- }
-}
-
Modified: trunk/g15daemon-wip/g15daemon/utility_funcs.c
===================================================================
--- trunk/g15daemon-wip/g15daemon/utility_funcs.c 2006-11-14 07:34:50 UTC (rev 137)
+++ trunk/g15daemon-wip/g15daemon/utility_funcs.c 2006-11-14 08:41:46 UTC (rev 138)
@@ -149,10 +149,21 @@
void g15daemon_convert_buf(lcd_t *lcd, unsigned char * orig_buf)
{
- unsigned int x,y;
+ unsigned int x,y,val;
for(x=0;x<160;x++)
for(y=0;y<43;y++)
- g15daemon_setpixel(lcd,x,y,orig_buf[x+(y*160)]);
+ {
+ unsigned int pixel_offset = y * LCD_WIDTH + x;
+ unsigned int byte_offset = pixel_offset / 8;
+ unsigned int bit_offset = 7-(pixel_offset % 8);
+
+ val = orig_buf[x+(y*160)];
+
+ if (val)
+ lcd->buf[byte_offset] = lcd->buf[byte_offset] | 1 << bit_offset;
+ else
+ lcd->buf[byte_offset] = lcd->buf[byte_offset] & ~(1 << bit_offset);
+ }
}
/* wrap the libg15 function */
Modified: trunk/g15daemon-wip/plugins/g15_plugin_clock.c
===================================================================
--- trunk/g15daemon-wip/plugins/g15_plugin_clock.c 2006-11-14 07:34:50 UTC (rev 137)
+++ trunk/g15daemon-wip/plugins/g15_plugin_clock.c 2006-11-14 08:41:46 UTC (rev 138)
@@ -36,8 +36,74 @@
#include <config.h>
#include <g15daemon.h>
+#include <libg15render.h>
+void draw_bignum (g15canvas * canvas, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, int num) {
+ x1 += 2;
+ x2 -= 2;
+ switch(num){
+ case 45:
+ g15r_pixelBox (canvas, x1, y1+((y2/2)-2), x2, y1+((y2/2)+2), G15_COLOR_BLACK, 1, 1);
+ break;
+ case 46:
+ g15r_pixelBox (canvas, x2-5, y2-5, x2, y2 , G15_COLOR_BLACK, 1, 1);
+ break;
+ case 48:
+ g15r_pixelBox (canvas, x1, y1, x2, y2 , G15_COLOR_BLACK, 1, 1);
+ g15r_pixelBox (canvas, x1 +5, y1 +5, x2 -5, y2 - 6, G15_COLOR_WHITE, 1, 1);
+ break;
+ case 49:
+ g15r_pixelBox (canvas, x2-5, y1, x2, y2 , G15_COLOR_BLACK, 1, 1);
+ g15r_pixelBox (canvas, x1, y1, x2 -5, y2, G15_COLOR_WHITE, 1, 1);
+ break;
+ case 50:
+ g15r_pixelBox (canvas, x1, y1, x2, y2 , G15_COLOR_BLACK, 1, 1);
+ g15r_pixelBox (canvas, x1, y1+5, x2 -5, y1+((y2/2)-3), G15_COLOR_WHITE, 1, 1);
+ g15r_pixelBox (canvas, x1+5, y1+((y2/2)+3), x2 , y2-6, G15_COLOR_WHITE, 1, 1);
+ break;
+ case 51:
+ g15r_pixelBox (canvas, x1, y1, x2, y2 , G15_COLOR_BLACK, 1, 1);
+ g15r_pixelBox (canvas, x1, y1+5, x2 -5, y1+((y2/2)-3), G15_COLOR_WHITE, 1, 1);
+ g15r_pixelBox (canvas, x1, y1+((y2/2)+3), x2-5 , y2-6, G15_COLOR_WHITE, 1, 1);
+ break;
+ case 52:
+ g15r_pixelBox (canvas, x1, y1, x2, y2 , G15_COLOR_BLACK, 1, 1);
+ g15r_pixelBox (canvas, x1, y1+((y2/2)+3), x2 -5, y2, G15_COLOR_WHITE, 1, 1);
+ g15r_pixelBox (canvas, x1+5, y1, x2-5 , y1+((y2/2)-3), G15_COLOR_WHITE, 1, 1);
+ break;
+ case 53:
+ g15r_pixelBox (canvas, x1, y1, x2, y2 , G15_COLOR_BLACK, 1, 1);
+ g15r_pixelBox (canvas, x1+5, y1+5, x2 , y1+((y2/2)-3), G15_COLOR_WHITE, 1, 1);
+ g15r_pixelBox (canvas, x1, y1+((y2/2)+3), x2-5 , y2-6, G15_COLOR_WHITE, 1, 1);
+ break;
+ case 54:
+ g15r_pixelBox (canvas, x1, y1, x2, y2 , G15_COLOR_BLACK, 1, 1);
+ g15r_pixelBox (canvas, x1+5, y1+5, x2 , y1+((y2/2)-3), G15_COLOR_WHITE, 1, 1);
+ g15r_pixelBox (canvas, x1+5, y1+((y2/2)+3), x2-5 , y2-6, G15_COLOR_WHITE, 1, 1);
+ break;
+ case 55:
+ g15r_pixelBox (canvas, x1, y1, x2, y2 , G15_COLOR_BLACK, 1, 1);
+ g15r_pixelBox (canvas, x1, y1+5, x2 -5, y2, G15_COLOR_WHITE, 1, 1);
+ break;
+ case 56:
+ g15r_pixelBox (canvas, x1, y1, x2, y2 , G15_COLOR_BLACK, 1, 1);
+ g15r_pixelBox (canvas, x1+5, y1+5, x2-5 , y1+((y2/2)-3), G15_COLOR_WHITE, 1, 1);
+ g15r_pixelBox (canvas, x1+5, y1+((y2/2)+3), x2-5 , y2-6, G15_COLOR_WHITE, 1, 1);
+ break;
+ case 57:
+ g15r_pixelBox (canvas, x1, y1, x2, y2 , G15_COLOR_BLACK, 1, 1);
+ g15r_pixelBox (canvas, x1+5, y1+5, x2-5 , y1+((y2/2)-3), G15_COLOR_WHITE, 1, 1);
+ g15r_pixelBox (canvas, x1, y1+((y2/2)+3), x2-5 , y2, G15_COLOR_WHITE, 1, 1);
+ break;
+ case 58:
+ g15r_pixelBox (canvas, x2-5, y1+5, x2, y1+10 , G15_COLOR_BLACK, 1, 1);
+ g15r_pixelBox (canvas, x2-5, y2-10, x2, y2-5 , G15_COLOR_BLACK, 1, 1);
+ break;
+
+ }
+}
+
static int *lcdclock(lcd_t *lcd)
{
unsigned int col = 0;
@@ -45,29 +111,37 @@
int narrows=0;
int totalwidth=0;
char buf[10];
-
+ g15canvas *canvas = (g15canvas *) malloc (sizeof (g15canvas));
+
+ if (canvas != NULL)
+ {
+ memset(canvas->buffer, 0, G15_BUFFER_LEN);
+ canvas->mode_cache = 0;
+ canvas->mode_reverse = 0;
+ canvas->mode_xor = 0;
+ }
+
time_t currtime = time(NULL);
- memset(lcd->buf,0,1024);
- memset(buf,0,10);
- strftime(buf,6,"%H:%M",localtime(&currtime));
+ memset(lcd->buf,0,G15_BUFFER_LEN);
+ memset(buf,0,10);
+ strftime(buf,6,"%H:%M",localtime(&currtime));
- if(buf[0]==49)
- narrows=1;
+ if(buf[0]==49)
+ narrows=1;
- len = strlen(buf);
+ len = strlen(buf);
- if(narrows)
- totalwidth=(len*20)+(15);
- else
- totalwidth=len*20;
+ if(narrows)
+ totalwidth=(len*20)+(15);
+ else
+ totalwidth=len*20;
- for (col=0;col<len;col++)
- {
- g15daemon_draw_bignum (lcd, (80-(totalwidth)/2)+col*20, 1,(80-(totalwidth)/2)+(col+1)*20, LCD_HEIGHT, BLACK, buf[col]);
+ for (col=0;col<len;col++)
+ draw_bignum (canvas, (80-(totalwidth)/2)+col*20, 1,(80-(totalwidth)/2)+(col+1)*20, G15_LCD_HEIGHT, buf[col]);
- }
- lcd->ident = currtime+100;
+ memcpy (lcd->buf, canvas->buffer, G15_BUFFER_LEN);
+ lcd->ident = currtime+100;
return G15_PLUGIN_OK;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|