Initial revision

This commit is contained in:
William Ferrell
1999-12-09 23:15:14 +00:00
commit 2635c3085d
139 changed files with 24298 additions and 0 deletions
+156
View File
@@ -0,0 +1,156 @@
#include <stdlib.h>
#include <stdio.h>
#include "LL.h"
/* Tested functions:
LL_New();
LL_Rewind();
LL_AddNode();
LL_Next();
LL_Get();
LL_Push();
LL_Unshift();
LL_InsertNode();
LL_Roll();
LL_UnRoll();
LL_SwapNodes();
LL_Sort();
LL_Find();
*/
typedef struct my_struct
{
int num;
char str[16];
} my_struct;
int list_list(LL *list)
{
my_struct *foo;
if(!list) return -1;
printf("Listing the list contents...\n");
printf(" Items: %i\n", LL_Length(list));
LL_Rewind(list);
do{
foo = (my_struct *)LL_Get(list);
if(!foo)
{
printf("Can't read list data\n");
return -1;
}
printf("\tItem: %i\n", foo->num);
} while(LL_Next(list) == 0);
return 0;
}
int compare(void *one, void *two)
{
my_struct *a, *b;
if(!one || !two) return 0;
a = (my_struct *)one;
b = (my_struct *)two;
return (a->num - b->num);
}
int main()
{
LL *list = NULL;
my_struct *foo;
my_struct bar;
int i,j;
list = LL_new();
if(!list)
{
printf("Cannot create list.\n");
return -1;
}
for(i=0; i<10; i++)
{
foo = malloc(sizeof(my_struct));
if(!foo)
{
printf("Can't allocate new struct\n");
return -1;
}
foo->num = i;
LL_InsertNode(list, (void *)foo);
printf("Added node: %i\n", foo->num);
}
if(list_list(list) != 0) return -1;
printf("Sorting the list...\n");
if(LL_Sort(list, compare) < 0)
{
printf("Error sorting.\n");
return -1;
}
if(list_list(list) != 0) return -1;
bar.num = 5;
printf("Searching for item \"5\"\n");
LL_Rewind(list);
foo = LL_Find(list, compare, &bar);
if(foo)
{
printf(" Found... %i\n", foo->num);
}
printf("Deallocating list...\n");
LL_Rewind(list);
do{
foo = LL_Get(list);
free(foo);
} while(LL_Next(list) == 0);
if(LL_Destroy(list) == 0) return 0;
printf("Attempting to access list...\n");
printf("List = %x\n", list);
LL_Rewind(list);
do{
foo = LL_Get(list);
if(foo) printf(" Item: %i\n", foo->num);
} while(LL_Next(list) == 0);
return 0;
}
+128
View File
@@ -0,0 +1,128 @@
include ../Makefile.config
########################################################################
# Modify these variables to fit your system.
########################################################################
##################### Serial device
# This should be whatever your display is connected to.
# "make install" will create a link from /dev/lcd to DEVICE
DEVICE = /dev/ttyS0
##################### Operating System
# Uncomment the line for your OS.
OS=-DLINUX
#OS=-DIRIX
##################### Modescreen Options
##### Load Screen
# Max: Load Avg at which the backlight will start blinking
MISC += -DLOAD_MAX=1.3
# Min: Load Avg at which the backlight will turn off (asleep)
MISC += -DLOAD_MIN=0.05
##### Filesystems to display stats for... (comment out ones you don't want)
# NFS (Network File System)
MISC += -DSTAT_NFS
# SMBFS (Samba filesystem -- Windows drives)
MISC += -DSTAT_SMBFS
##################### Drivers
# Comment out each section you don't want.
# Matrix-Orbital displays
DRIVERS += -DMTXORB_DRV
OBJ += MtxOrb.o
# Curses text-based output
DRIVERS += -DCURSES_DRV
OBJ += curses_drv.o
LIB += -lncurses
# Regular text output (ugly)
DRIVERS += -DTEXT_DRV
OBJ += text.o
# Debugging output (very ugly)
DRIVERS += -DDEBUG_DRV
OBJ += debug.o
# HD44780 parallel port lcd displays
#DRIVERS += -DHD44780_DRV
#OBJ += hd44780.o
# Pick one of the following ports to use
#LPTPORT = 0x378
#LPTPORT = 0x278
#LPTPORT = 0x3bc
########################################################################
# You shouldn't need to touch anything below here.
########################################################################
#GCC = gcc -Wall -Wp,-lang-c-c++-comments -O6
#OBJ += main.o mode.o lcd.o sockets.o config.o drv_base.o
#MISC += $(OS) $(DRIVERS)
#VERSION = 0.4
###################################################################
# Compilation...
#
#MISC=-DCURSES_DRV -g -DDEBUG
test:
$(GCC) -c $(MISC) menutest.c
$(GCC) -c $(MISC) lcd.c
$(GCC) -c $(MISC) menu.c
$(GCC) -c $(MISC) drivers/curses_drv.c
$(GCC) -c $(MISC) drivers/drv_base.c
$(GCC) -o menutest curses_drv.o menutest.o lcd.o drv_base.o menu.o -lncurses
test2:
$(GCC) -c $(MISC) LL.c
$(GCC) -c $(MISC) LL_test.c
$(GCC) -o LL_test LL_test.o LL.o
test3:
$(GCC) -c $(MISC) config.c
$(GCC) -c $(MISC) config_test.c
$(GCC) -o config_test config.o config_test.o
driver_test:
$(GCC) -g -c $(MISC) drv_test.c
$(GCC) -g -o drv_test drv_test.o ../server/drivers/libLCDdrivers.a \
../shared/libLCDstuff.a -lncurses
socktest:
# $(GCC) -g -c $(MISC) socktest.c
# $(GCC) -g -o st socktest.o ../server/drivers/libLCDdrivers.a \
# ../shared/libLCDstuff.a -lncurses
$(GCC) -c $(MISC) srvtest.c
$(GCC) -c $(MISC) ../server/sock.c
$(GCC) $(MISC) -o srv srvtest.o ../server/*.o \
../server/drivers/libLCDdrivers.a \
../shared/libLCDstuff.a -lncurses
##################################################################
# Installation
#
install:
@echo Nothing to install in tests...
##################################################################
# Other stuff...
#
clean:
rm -f *.o core *~
edit:
emacs . &
+42
View File
@@ -0,0 +1,42 @@
hello
screen_add one
widget_add one v string
widget_set one v 1 1 "VBars"
widget_add one h string
widget_set one h 10 1 "HBars"
widget_add one h1 hbar
widget_add one h2 hbar
widget_add one h3 hbar
widget_set one h1 10 2 28
widget_set one h2 10 3 27
widget_set one h3 10 4 26
widget_add one v1 vbar
widget_add one v2 vbar
widget_add one v3 vbar
widget_add one v4 vbar
widget_set one v1 1 4 15
widget_set one v2 2 4 14
widget_set one v3 3 4 13
widget_set one v4 4 4 12
widget_add one v5 vbar
widget_set one v5 5 4 11
widget_set one v5 5 4 12
widget_set one v5 5 4 10
widget_set one v5 5 4 8
widget_set one v5 5 4 18
widget_set one v5 5 4 17
widget_set one v5 5 4 16
widget_set one v5 5 4 15
widget_set one v5 5 4 14
widget_set one v5 5 4 13
widget_set one v5 5 4 12
widget_set one v5 5 4 11
widget_del one h3
widget_add one h3 hbar
widget_set one h3 10 4 16
widget_set one h3 10 4 26
widget_set one h3 10 4 27
widget_set one h3 10 4 25
+30
View File
@@ -0,0 +1,30 @@
#include <curses.h>
void main()
{
char string[64];
int done=0;
int key=0;
initscr();
cbreak();
noecho();
nonl();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
while(!done)
{
key=getch();
if(key == KEY_BACKSPACE) done=1;
sprintf(string, "Key: %i", key);
mvaddstr(0,0,string);
}
}
+54
View File
@@ -0,0 +1,54 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "../server/drivers/lcd.h"
int main()
{
int err;
int len;
srand(time(NULL));
err = lcd_init("");
err = lcd_add_driver("joy", "");
err = lcd_add_driver("curses", "Booger");
// err = lcd_add_driver("text", "Booger");
err = lcd_add_driver("MtxOrb", "");
lcd.clear();
lcd.init_hbar();
lcd.string(1,1,"Booger!");
len = rand()%100;
lcd.hbar(1,2,len );
lcd.flush();
for(err=0; err!='Z'; err=lcd.getkey())
{
// if(err)
{
if(err == 'B') len--;
if(err == 'C') len++;
if(err == 'D') len--;
if(err == 'E') len-=5;
if(err == 'F') len+=5;
lcd.clear();
lcd.string(1,1,"Booger!");
lcd.hbar(1,2,len );
lcd.chr(1,3,(char)err);
lcd.flush();
}
usleep(125000);
}
// sleep(1);
lcd_shutdown();
return 0;
}
+638
View File
@@ -0,0 +1,638 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <termios.h>
#include <fcntl.h>
#include <string.h>
#include <sys/errno.h>
#include "LL.h"
#include "lcd.h"
#include "drv_base.h"
#ifdef MTXORB_DRV
#include "MtxOrb.h"
#endif
#ifdef TEXT_DRV
#include "text.h"
#endif
#ifdef DEBUG_DRV
#include "debug.h"
#endif
#ifdef CURSES_DRV
#include "curses_drv.h"
#endif
#ifdef HD44780_DRV
#include "hd44780.h"
#endif
// TODO: Make a Windows server, and clients...?
lcd_logical_driver lcd;
lcd_physical_driver drivers[] =
{
{ "base", drv_base_init, },
#ifdef MTXORB_DRV
{ "MtxOrb", MtxOrb_init, },
#endif
#ifdef HD44780_DRV
{ "HD44780", HD44780_init, },
#endif
#ifdef TEXT_DRV
{ "text", text_init, },
#endif
#ifdef DEBUG_DRV
{ "debug", debug_init, },
#endif
#ifdef CURSES_DRV
{ "curses", curses_drv_init, },
#endif
{ NULL, NULL, },
};
LL *list;
////////////////////////////////////////////////////////////
// This sets up which driver to use and initializes stuff.
//
int lcd_init(char *args)
{
// int i;
list = LL_new();
if(!list)
{
printf("Error allocating driver list.\n");
return -1;
}
lcd_drv_init(NULL, NULL);
return lcd_add_driver("base", args);
/*
drv_base_init(args);
for(i=0; drivers[i].name; i++)
{
if(!strcmp(driver, drivers[i].name))
{
return drivers[i].init(args);
}
}
printf("Invalid driver: %s\n", driver);
return -1;
*/
}
// TODO: lcd_remove_driver()
int lcd_add_driver(char *driver, char *args)
{
int i;
lcd_logical_driver *add;
for(i=0; drivers[i].name; i++)
{
//printf("Checking driver: %s\n", drivers[i].name);
if(0 == strcmp(driver, drivers[i].name))
{
//printf("Found driver: %s (%s)\n", drivers[i].name, driver);
add = malloc(sizeof(lcd_logical_driver));
if(!add)
{
printf("Couldn't allocate driver \"%s\".\n", driver);
return -1;
}
//printf("Allocated driver\n");
memset(add, 0, sizeof(lcd_logical_driver));
add->wid = lcd.wid; add->hgt = lcd.hgt;
add->cellwid = lcd.cellwid; add->cellhgt = lcd.cellhgt;
//printf("LCD driver info:\n\twid: %i\thgt: %i\n",
// add->wid, add->hgt);
add->framebuf = malloc(add->wid * add->hgt);
if(!add->framebuf)
{
printf("Couldn't allocate framebuffer for driver \"%s\".\n",
driver);
free(add);
return -1;
}
//printf("Allocated frame buffer\n");
LL_Push(list, (void *)add);
return drivers[i].init(add, args);
}
}
return -1;
}
// TODO: Put lcd_shutdown in the shutdown function...
int lcd_shutdown()
{
lcd_logical_driver *del;
LL_Rewind(list);
do {
del = (lcd_logical_driver *)LL_DeleteNode(list);
if(del->close) del->close();
free(del);
} while(LL_Length(list) > 0);
return 0;
}
int lcd_drv_init(struct lcd_logical_driver *driver, char *args)
{
// printf("lcd_drv_init()\n");
lcd.wid = 20;
lcd.hgt = 4;
lcd.framebuf = NULL;
/*
if(!lcd.framebuf)
lcd.framebuf = malloc(lcd.wid * lcd.hgt);
if(!lcd.framebuf)
{
lcd_drv_close();
return -1;
}
memset(lcd.framebuf, ' ', lcd.wid*lcd.hgt);
*/
// Debugging...
// if(lcd.framebuf) printf("Frame buffer: %i\n", (int)lcd.framebuf);
lcd.cellwid = 5;
lcd.cellhgt = 8;
// Set up these wrapper functions...
lcd.clear = lcd_drv_clear;
lcd.string = lcd_drv_string;
lcd.chr = lcd_drv_chr;
lcd.vbar = lcd_drv_vbar;
lcd.hbar = lcd_drv_hbar;
lcd.init_num = lcd_drv_init_num;
lcd.num = lcd_drv_num;
lcd.init = lcd_drv_init;
lcd.close = lcd_drv_close;
lcd.flush = lcd_drv_flush;
lcd.flush_box = lcd_drv_flush_box;
lcd.contrast = lcd_drv_contrast;
lcd.backlight = lcd_drv_backlight;
lcd.set_char = lcd_drv_set_char;
lcd.icon = lcd_drv_icon;
lcd.init_vbar = lcd_drv_init_vbar;
lcd.init_hbar = lcd_drv_init_hbar;
lcd.draw_frame = lcd_drv_draw_frame;
lcd.getkey = lcd_drv_getkey;
return 1; // 1 is arbitrary. (must be 1 or more)
}
//////////////////////////////////////////////////////////////////////
// All functions below here call their respective driver functions...
//
// The way it works is this:
// It loops through the list of drivers, calling each one to keep
// them all synchronized. During this loop...
// - First, set the framebuffer to point to the drivers' framebuffer.
// (this ensures that whatever driver gets called will operate on
// the correct buffer)
// - Then, it checks to see what sort of call to make.
// driver->func() > 0 means it should call the driver function.
// driver->func() == NULL means it should not make a call.
// driver->func() == -1 means it should call the generic driver.
//////////////////////////////////////////////////////////////////////
void lcd_drv_close()
{
lcd_logical_driver *driver;
LL_Rewind(list);
do {
driver = (lcd_logical_driver *)LL_Get(list);
if(driver)
{
lcd.framebuf = driver->framebuf;
if(driver->close > 0)
driver->close();
else if((int)driver->close == -1)
{
drv_base->close();
}
}
} while(LL_Next(list) == 0);
}
void lcd_drv_clear()
{
lcd_logical_driver *driver;
LL_Rewind(list);
do {
driver = (lcd_logical_driver *)LL_Get(list);
if(driver)
{
lcd.framebuf = driver->framebuf;
if(driver->clear > 0)
driver->clear();
else if((int)driver->clear == -1)
{
drv_base->clear();
}
}
} while(LL_Next(list) == 0);
}
void lcd_drv_flush()
{
lcd_logical_driver *driver;
LL_Rewind(list);
do {
driver = (lcd_logical_driver *)LL_Get(list);
if(driver)
{
lcd.framebuf = driver->framebuf;
if(driver->flush > 0)
driver->flush();
else if((int)driver->flush == -1)
{
drv_base->flush();
}
}
} while(LL_Next(list) == 0);
}
void lcd_drv_string(int x, int y, char string[])
{
lcd_logical_driver *driver;
LL_Rewind(list);
do {
driver = (lcd_logical_driver *)LL_Get(list);
if(driver)
{
lcd.framebuf = driver->framebuf;
if(driver->string > 0)
driver->string(x,y,string);
else if((int)driver->string == -1)
{
drv_base->string(x,y,string);
}
}
} while(LL_Next(list) == 0);
}
void lcd_drv_chr(int x, int y, char c)
{
lcd_logical_driver *driver;
LL_Rewind(list);
do {
driver = (lcd_logical_driver *)LL_Get(list);
if(driver)
{
lcd.framebuf = driver->framebuf;
if(driver->chr > 0)
driver->chr(x,y,c);
else if((int)driver->chr == -1)
{
drv_base->chr(x,y,c);
}
}
} while(LL_Next(list) == 0);
}
void lcd_drv_contrast(int contrast)
{
lcd_logical_driver *driver;
LL_Rewind(list);
do {
driver = (lcd_logical_driver *)LL_Get(list);
if(driver)
{
lcd.framebuf = driver->framebuf;
if(driver->contrast > 0)
driver->contrast(contrast);
else if((int)driver->contrast == -1)
{
drv_base->contrast(contrast);
}
}
} while(LL_Next(list) == 0);
}
void lcd_drv_backlight(int on)
{
lcd_logical_driver *driver;
LL_Rewind(list);
do {
driver = (lcd_logical_driver *)LL_Get(list);
if(driver)
{
lcd.framebuf = driver->framebuf;
if(driver->backlight > 0)
driver->backlight(on);
else if((int)driver->backlight == -1)
{
drv_base->backlight(on);
}
}
} while(LL_Next(list) == 0);
}
void lcd_drv_init_vbar()
{
lcd_logical_driver *driver;
LL_Rewind(list);
do {
driver = (lcd_logical_driver *)LL_Get(list);
if(driver)
{
lcd.framebuf = driver->framebuf;
if(driver->init_vbar > 0)
driver->init_vbar();
else if((int)driver->init_vbar == -1)
{
drv_base->init_vbar();
}
}
} while(LL_Next(list) == 0);
}
void lcd_drv_init_hbar()
{
lcd_logical_driver *driver;
LL_Rewind(list);
do {
driver = (lcd_logical_driver *)LL_Get(list);
if(driver)
{
lcd.framebuf = driver->framebuf;
if(driver->init_hbar > 0)
driver->init_hbar();
else if((int)driver->init_hbar == -1)
{
drv_base->init_hbar();
}
}
} while(LL_Next(list) == 0);
}
void lcd_drv_init_num()
{
lcd_logical_driver *driver;
LL_Rewind(list);
do {
driver = (lcd_logical_driver *)LL_Get(list);
if(driver)
{
lcd.framebuf = driver->framebuf;
if(driver->init_num > 0)
driver->init_num();
else if((int)driver->init_num == -1)
{
drv_base->init_num();
}
}
} while(LL_Next(list) == 0);
}
void lcd_drv_num(int x, int num)
{
lcd_logical_driver *driver;
LL_Rewind(list);
do {
driver = (lcd_logical_driver *)LL_Get(list);
if(driver)
{
lcd.framebuf = driver->framebuf;
if(driver->num > 0)
driver->num(x,num);
else if((int)driver->num == -1)
{
drv_base->num(x,num);
}
}
} while(LL_Next(list) == 0);
}
void lcd_drv_set_char(int n, char *dat)
{
lcd_logical_driver *driver;
LL_Rewind(list);
do {
driver = (lcd_logical_driver *)LL_Get(list);
if(driver)
{
lcd.framebuf = driver->framebuf;
if(driver->set_char > 0)
driver->set_char(n,dat);
else if((int)driver->set_char == -1)
{
drv_base->set_char(n,dat);
}
}
} while(LL_Next(list) == 0);
}
void lcd_drv_vbar(int x, int len)
{
lcd_logical_driver *driver;
LL_Rewind(list);
do {
driver = (lcd_logical_driver *)LL_Get(list);
if(driver)
{
lcd.framebuf = driver->framebuf;
if(driver->vbar > 0)
driver->vbar(x,len);
else if((int)driver->vbar == -1)
{
drv_base->vbar(x,len);
}
}
} while(LL_Next(list) == 0);
}
void lcd_drv_hbar(int x, int y, int len)
{
lcd_logical_driver *driver;
LL_Rewind(list);
do {
driver = (lcd_logical_driver *)LL_Get(list);
if(driver)
{
lcd.framebuf = driver->framebuf;
if(driver->hbar > 0)
driver->hbar(x,y,len);
else if((int)driver->hbar == -1)
{
drv_base->hbar(x,y,len);
}
}
} while(LL_Next(list) == 0);
}
void lcd_drv_icon(int which, char dest)
{
lcd_logical_driver *driver;
LL_Rewind(list);
do {
driver = (lcd_logical_driver *)LL_Get(list);
if(driver)
{
lcd.framebuf = driver->framebuf;
if(driver->icon > 0)
driver->icon(which,dest);
else if((int)driver->icon == -1)
{
drv_base->icon(which,dest);
}
}
} while(LL_Next(list) == 0);
}
void lcd_drv_flush_box(int lft, int top, int rgt, int bot)
{
lcd_logical_driver *driver;
LL_Rewind(list);
do {
driver = (lcd_logical_driver *)LL_Get(list);
if(driver)
{
lcd.framebuf = driver->framebuf;
if(driver->flush_box > 0)
driver->flush_box(lft,top,rgt,bot);
else if((int)driver->flush_box == -1)
{
drv_base->flush_box(lft,top,rgt,bot);
}
}
} while(LL_Next(list) == 0);
}
// TODO: Check whether lcd.draw_frame() should really take a framebuffer
// TODO: as an argument, or if it should always use lcd.framebuf
void lcd_drv_draw_frame(char *dat)
{
lcd_logical_driver *driver;
LL_Rewind(list);
do {
driver = (lcd_logical_driver *)LL_Get(list);
if(driver)
{
lcd.framebuf = driver->framebuf;
if(driver->draw_frame > 0)
driver->draw_frame(dat);
else if((int)driver->draw_frame == -1)
{
drv_base->draw_frame(dat);
}
}
} while(LL_Next(list) == 0);
}
char lcd_drv_getkey()
{
lcd_logical_driver *driver;
char key;
LL_Rewind(list);
do {
driver = (lcd_logical_driver *)LL_Get(list);
if(driver)
{
lcd.framebuf = driver->framebuf;
if(driver->getkey > 0)
{
key = driver->getkey();
if(key) return key;
}
else if((int)driver->getkey == -1)
{
key = drv_base->getkey();
if(key) return key;
}
}
} while(LL_Next(list) == 0);
return 0;
}
+88
View File
@@ -0,0 +1,88 @@
#include "lcd.h"
#include "menu.h"
extern menu_item MainMenu[];
extern menu_item OptionsMenu[];
extern int Shutdown_func();
extern int Close_func();
extern int OK_func();
extern int Time24_func();
extern int Contrast_func();
menu_item MainMenu[] = {
"MAIN MENU", 0, 0, // Title
"Options", TYPE_MENU, (void *)OptionsMenu,
"Kill LCDproc", TYPE_FUNC, (void *)Shutdown_func,
"OK", TYPE_FUNC, (void *)OK_func,
0, 0, 0,
};
menu_item OptionsMenu[] = {
"OPTIONS MENU", TYPE_TITL, 0, // Title
"24-hour Time", TYPE_CHEK, (void *)Time24_func,
"Contrast...", TYPE_SLID, (void *)Contrast_func,
"OK", TYPE_FUNC, (void *)OK_func,
"Close Menu", TYPE_FUNC, (void *)Close_func,
"Exit Program", TYPE_FUNC, (void *)Shutdown_func,
"Another Title",TYPE_TITL, 0,
0, 0, 0,
};
///////////////// Elsewhere, we declare these...
int Shutdown_func()
{
// Do something here...
return MENU_KILL;
}
int Close_func()
{
return MENU_CLOSE;
}
int OK_func()
{
return MENU_OK;
}
int Time24_func(int input)
{
static int status=0;
if(input == MENU_READ) return status;
if(input == MENU_CHECK) status ^= 1; // does something.
return (status | MENU_OK);
// The status is "or"-ed with the MENU value to let do_menu()
// know what to do after selecting the item. (two return
// values in one. :)
// Also, "MENU_OK" happens to be zero, so it does not matter
// unless you want something else (like MENU_CLOSE)
}
int Contrast_func(int input)
{
static int status=128;
if(input == MENU_READ) return status;
if(input == MENU_PLUS) status++; // does something.
if(input == MENU_MINUS) status--; // does something.
return (status | MENU_OK);
}
void main()
{
lcd_init("", "curses");
do_menu(MainMenu);
}
+20
View File
@@ -0,0 +1,20 @@
hello
screen_add_widget one w1 string
screen_add one
screen_add two
screen_add_widget one w1 string
screen_add_widget one w2 vbar
screen_add_widget two w1 hbar
screen_add_widget two w2 scroller
screen_del two
screen_add two
screen_del_widget w1
screen_del_widget two w1
screen_del_widget one w2
screen_add_widget two w1 icon
screen_add_widget two w2 title
screen_add three
screen_add_widget three w1 string
screen_add_widget three w2 hbar
screen_add_widget one w2 string
screen_add_widget one w2 hbar
+23
View File
@@ -0,0 +1,23 @@
hello
screen_add one
screen_widget_add one w1 string
screen_widget_set one w1 1 2 "Hello?"
screen_widget_add one title title
screen_widget_set one title "TEST SCREEN ONE"
screen_add two
screen_widget_add two title title
screen_widget_add two 0% string
screen_widget_add two 100% string
screen_widget_add two cpubar hbar
screen_widget_set two title "CPU: 57.6%"
screen_widget_set two 0% 1 4 0%
screen_widget_set two 100% 17 4 100%
screen_widget_set two cpubar 3 4 47
screen_add three
screen_widget_add three w1 string
screen_widget_set three w1 1 3 "Me too!"
screen_widget_add three title title
screen_widget_set three title "TEST THREE"
+11
View File
@@ -0,0 +1,11 @@
hello
screen_add one
screen_widget_add one w1 string
screen_widget_set one w1 7 2 CENTER
screen_widget_add one w2 string
screen_widget_set one w2 7 3 CENTER
screen_widget_add one title string
screen_widget_set one title 1 1 "## BOOGER! ##########"
screen_widget_set one title 1 1 "## BOOGER! #########"
screen_widget_set one w1 8 2 CENTER
screen_widget_set one w2 8 3 CENTER
+21
View File
@@ -0,0 +1,21 @@
hello
screen_add one
screen_add two
screen_add three
screen_add four
widget_add one title title
widget_add two title title
widget_add three title title
widget_add four title title
widget_set one title "One"
widget_set two title "Two"
widget_set three title "Three"
widget_set four title "Four"
widget_add one dot string
widget_add two dot string
widget_add three dot string
widget_add four dot string
widget_set one dot 1 2 .
widget_set two dot 2 2 .
widget_set three dot 3 2 .
widget_set four dot 4 2 .
+44
View File
@@ -0,0 +1,44 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#define LCDPORT 13667
#include "../shared/sockets.h"
int main()
{
char string[1024];
char string2[1024];
int sock;
int err;
memset(string, 0, 1024);
fcntl(stdin, F_SETFL, O_NONBLOCK);
sock = sock_connect("localhost", LCDPORT);
if(sock <= 0)
{
printf("Error opening socket.\n");
return 1;
}
while(string[0] != 'q')
{
do {
err = sock_recv(sock, string2, 1024);
if (err > 0) printf("Received message: %s\n", string2);
} while(err > 0);
printf("Enter a string to send:\n\t");
gets(string);
sock_send_string(sock, string);
}
sock_close(sock);
return 0;
}
+144
View File
@@ -0,0 +1,144 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
// For debugging purposes...
// ... should not be defined in a release.
// (defaults to 13666)
//#define LCDPORT 13667
#include "../server/drivers/lcd.h"
#include "../server/sock.h"
#include "../server/clients.h"
#include "../server/screenlist.h"
#include "../server/screen.h"
#include "../server/parse.h"
#include "../server/render.h"
#include "../server/serverscreens.h"
void exit_program(int val);
int main()
{
char string[1024];
int sock;
screen *s;
int timer=0;
// Ctrl-C will cause a clean exit...
signal(SIGINT, exit_program);
// and "kill"...
signal(SIGTERM, exit_program);
// and "kill -HUP" (hangup)...
signal(SIGHUP, exit_program);
// and just in case, "kill -KILL" (which cannot be trapped; but oh well)
signal(SIGKILL, exit_program);
memset(string, 0, 1024);
lcd_init("");
// Feel free to add as many drivers as you like... :)
//lcd_add_driver("joy", "");
//lcd_add_driver("curses", "Booger");
lcd_add_driver("MtxOrb", "");
sock = sock_create_server();
if(sock <= 0)
{
printf("Error opening socket.\n");
return 1;
}
if(client_init() < 0)
{
printf("Error initializing client list\n");
return 1;
}
if(screenlist_init() < 0)
{
printf("Error initializing screen list\n");
return 1;
}
// Make sure the server screen shows up every once in a while..
server_screen_init();
// Main loop...
while(1)
{
sock_poll_clients();
parse_all_client_messages();
// TODO: Check for and handle keypresses here...
//handle_input();
timer++;
if(timer >= 32)
{
timer = 0;
// TODO: Notify clients of "listen" and "ignore"
s = screenlist_next();
if(s)
{
printf("Screen: %s\n", s->id);
}
}
draw_server_screen(timer);
s = screenlist_current();
if(s)
{
// render something here...
draw_screen(s, timer);
}
else
{
no_screen_screen(timer);
}
usleep(125000);
}
// Say goodbye!
goodbye_screen();
// Can go anywhere...
lcd_shutdown();
// Must come before screenlist_shutdown
client_shutdown();
// Must come after client_shutdown
screenlist_shutdown();
// Should come after client_shutdown
sock_close_all();
return 0;
}
void exit_program(int val)
{
// Say goodbye!
goodbye_screen();
// Can go anywhere...
lcd_shutdown();
// Must come before screenlist_shutdown
client_shutdown();
// Must come after client_shutdown
screenlist_shutdown();
// Should come after client_shutdown
sock_close_all();
exit(0);
}
+75
View File
@@ -0,0 +1,75 @@
hello
screen_add one
widget_add one f frame
widget_set one f 1 2 10 3 20 4 v 2
widget_add one g frame -in f
widget_set one g 5 1 15 3 20 4 v 2
widget_add one s string
widget_add one s string -in f
widget_add one s string -in g
widget_set one s 1 1 "123456789012345678901234567890"
widget_set one s 1 2 "123456789012345678901234567890"
widget_set one s 1 3 "123456789012345678901234567890"
widget_set one s 1 4 "123456789012345678901234567890"
widget_del one s
widget_add one h hbar
widget_add one h hbar -in f
widget_add one h hbar -in g
widget_set one h 1 2 13
widget_set one h 1 2 43
widget_set one h 1 2 83
widget_del one h
widget_add one t title
widget_add one t title -in f
widget_add one t title -in g
widget_set one t Hello
widget_set one t "Hello there"
widget_set one t "Hi, there. Watch me scroll!"
widget_del one t
------------------------ Disk Screen test...
hello
screen_add D
widget_add D t title
widget_set D t "Disk Use"
widget_add D f frame
widget_set D f 1 2 20 4 20 8 v 8
widget_add D s1 string -in f
widget_add D s2 string -in f
widget_add D s3 string -in f
widget_add D s4 string -in f
widget_add D s5 string -in f
widget_add D s6 string -in f
widget_add D s7 string -in f
widget_add D s8 string -in f
widget_add D h1 hbar -in f
widget_add D h2 hbar -in f
widget_add D h3 hbar -in f
widget_add D h4 hbar -in f
widget_add D h5 hbar -in f
widget_add D h6 hbar -in f
widget_add D h7 hbar -in f
widget_add D h8 hbar -in f
widget_set D s1 1 1 /foo
widget_set D s2 1 2 /bar
widget_set D s3 1 3 /baz
widget_set D s4 1 4 /quux
widget_set D s5 1 5 /foobar
widget_set D s6 1 6 /tmp
widget_set D s7 1 7 /snot
widget_set D s8 1 8 /booger
widget_set D h1 10 1 3
widget_set D h2 10 2 6
widget_set D h3 10 3 9
widget_set D h4 10 4 12
widget_set D h5 10 5 15
widget_set D h6 10 6 18
widget_set D h7 10 7 21
widget_set D h8 10 8 24
---------------------------