Rev 1347 | Rev 1389 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
/*
* Project: S.Ha.R.K.
*
* Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
*
* Authors : Mauro Marinoni <mauro.marinoni@unipv.it>
* (see authors.txt for full list of hartik's authors)
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
* http://retis.sssup.it
* http://shark.sssup.it
*/
/*
* Copyright (C) 2000 Paolo Gai
*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <kernel/kern.h>
#include <kernel/func.h>
#include <stdlib.h>
#include <string.h>
#include <drivers/shark_linuxc26.h>
#include <drivers/shark_fb26.h>
#include <drivers/shark_input26.h>
#include <drivers/shark_mouse26.h>
#include <drivers/shark_keyb26.h>
#include <drivers/shark_spk26.h>
#include <drivers/shark_joy26.h>
#define FRAME_BUFFER_DEVICE 0
#define RGB_BLACK rgb16( 0, 0, 0)
#define RGB_GRAY rgb16(127,127,127)
#define RGB_WHITE rgb16(255,255,255)
#define RGB_RED rgb16(255, 0, 0)
#define RGB_GREEN rgb16( 0,255, 0)
#define RGB_BLUE rgb16( 0, 0,255)
#define RGB_YELLOW rgb16(255,255, 0)
#define RGB_MAGENTA rgb16(255, 0,255)
#define RGB_CYAN rgb16( 0,255,255)
#define RGB_D_RED rgb16(127, 0, 0)
#define RGB_D_GREEN rgb16( 0,127, 0)
#define RGB_D_BLUE rgb16( 0, 0,127)
#define RGB_D_YELLOW rgb16(127,127, 0)
#define RGB_D_MAGENTA rgb16(127, 0,127)
#define RGB_D_CYAN rgb16( 0,127,127)
void my_sysclose(KEY_EVT *e)
{
mouse_grxcursor(DISABLE, 0);
FB26_close(FRAME_BUFFER_DEVICE);
MOUSE26_close();
KEYB26_close();
SPEAK26_close();
JOY26_close();
INPUT26_close();
kern_printf("S.Ha.R.K. closed.\n\n");
sys_end();
}
TASK my_getjoy(void *arg) {
int a0, a1, a2, a3, btn;
char st[20];
while (1) {
joy_getstatus(&a0, &a1, &a2, &a3, &btn);
sprintf(st, "X Axis : %6d ", a0);
grx_text(st, 100, 64, RGB_CYAN, RGB_BLACK);
sprintf(st, "Y Axis : %6d ", a1);
grx_text(st, 100, 114, RGB_CYAN, RGB_BLACK);
sprintf(st, "Buttons: %2x ", btn);
grx_text(st, 100, 164, RGB_CYAN, RGB_BLACK);
task_endcycle();
if (btn == 0xF)
my_sysclose(NULL);
}
}
TASK my_getch(void *arg) {
BYTE ch;
int i = 0;
char st[20];
while (1) {
ch = keyb_getch(NON_BLOCK);
if (ch) {
sprintf(st, "%c", ch);
grx_text(st, 340 + 10 * (i%25), 30 + 20 * (i/25), RGB_BLUE, RGB_BLACK);
if (++i >= 200)
i = 0;
}
task_endcycle();
}
}
void graph_init(void)
{
grx_rect( 4, 4, 634, 474, RGB_WHITE);
grx_rect( 14, 14, 304, 214, RGB_YELLOW);
grx_rect(314, 14, 624, 214, RGB_RED);
}
int main(int argc, char **argv)
{
SOFT_TASK_MODEL mp;
PID pid;
KEY_EVT ev;
ev.ascii = 'c';
ev.scan = KEY_C;
ev.status = KEY_PRESSED;
ev.flag = CNTL_BIT;
keyb_hook(ev, my_sysclose, FALSE);
ev.flag = CNTR_BIT;
keyb_hook(ev, my_sysclose, FALSE);
FB26_init();
FB26_open(FRAME_BUFFER_DEVICE);
FB26_use_grx(FRAME_BUFFER_DEVICE);
FB26_setmode(FRAME_BUFFER_DEVICE,"640x480-16");
graph_init();
mouse_grxlimits(639, 479);
mouse_setposition(319, 239, 0);
mouse_grxcursor(ENABLE, 2);
soft_task_default_model(mp);
soft_task_def_level(mp,2);
soft_task_def_ctrl_jet(mp);
soft_task_def_met(mp,700);
soft_task_def_period(mp,10000);
//soft_task_def_aperiodic(mp);
soft_task_def_usemath(mp);
pid = task_create("Joy_Print", my_getjoy, &mp, NULL);
if (pid == NIL) {
perror("Could not create task <Joy_Print>");
sys_end();
} else
task_activate(pid);
soft_task_default_model(mp);
soft_task_def_level(mp,2);
soft_task_def_ctrl_jet(mp);
soft_task_def_met(mp,700);
soft_task_def_period(mp,10000);
//soft_task_def_aperiodic(mp);
soft_task_def_usemath(mp);
pid = task_create("Key_Print", my_getch, &mp, NULL);
if (pid == NIL) {
perror("Could not create task <Key_Print>");
sys_end();
} else
task_activate(pid);
return 0;
}