Added a heartbeat function to the driver code. Both the
MatrixOrbital driver and the curses driver now have their own heartbeat functions.
This commit is contained in:
+28
-5
@@ -25,6 +25,7 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include "render.h"
|
||||
#include "lcd.h"
|
||||
#include "lcd_lib.h"
|
||||
#include "MtxOrb.h"
|
||||
@@ -383,6 +384,7 @@ MtxOrb_init (lcd_logical_driver * driver, char *args)
|
||||
|
||||
driver->getkey = MtxOrb_getkey;
|
||||
driver->getinfo = MtxOrb_getinfo;
|
||||
driver->heartbeat = MtxOrb_heartbeat;
|
||||
|
||||
return fd;
|
||||
}
|
||||
@@ -1265,12 +1267,33 @@ MtxOrb_ask_bar (int type)
|
||||
/////////////////////////////////////////////////////////////
|
||||
// Does the heartbeat...
|
||||
//
|
||||
static char
|
||||
MtxOrb_heartbeat (int timer)
|
||||
static void
|
||||
MtxOrb_heartbeat (int type)
|
||||
{
|
||||
MtxOrb_icon (!((timer + 4) & 5), 0);
|
||||
MtxOrb_chr (MtxOrb->wid, 1, 0);
|
||||
return (char) 0;
|
||||
static int timer = 0;
|
||||
int whichIcon;
|
||||
static int saved_type = HEARTBEAT_ON;
|
||||
|
||||
if (type)
|
||||
saved_type = type;
|
||||
|
||||
if (type == HEARTBEAT_ON) {
|
||||
// Set this to pulsate like a real heart beat...
|
||||
whichIcon = (! ((timer + 4) & 5));
|
||||
|
||||
// This defines a custom character EVERY time...
|
||||
// not efficient... is this necessary?
|
||||
MtxOrb_icon (whichIcon, 0);
|
||||
|
||||
// Put character on screen...
|
||||
MtxOrb_chr (MtxOrb->wid, 1, 0);
|
||||
|
||||
// change display...
|
||||
MtxOrb_flush ();
|
||||
}
|
||||
|
||||
timer++;
|
||||
timer &= 0x0f;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -23,6 +23,7 @@ static void MtxOrb_icon (int which, char dest);
|
||||
static void MtxOrb_draw_frame (char *dat);
|
||||
static char MtxOrb_getkey ();
|
||||
static char * MtxOrb_getinfo ();
|
||||
static void MtxOrb_heartbeat (int type);
|
||||
|
||||
static int MtxOrb_ask_bar (int type);
|
||||
static void MtxOrb_set_known_char (int car, int type);
|
||||
|
||||
@@ -26,9 +26,10 @@
|
||||
|
||||
#include "shared/str.h"
|
||||
|
||||
#include "render.h"
|
||||
#include "lcd.h"
|
||||
#include "curses_drv.h"
|
||||
#include "drv_base.h"
|
||||
//#include "drv_base.h"
|
||||
|
||||
lcd_logical_driver *curses_drv;
|
||||
|
||||
@@ -258,6 +259,7 @@ curses_drv_init (struct lcd_logical_driver *driver, char *args)
|
||||
driver->draw_frame = curses_drv_draw_frame;
|
||||
|
||||
driver->getkey = curses_drv_getkey;
|
||||
driver->heartbeat = curses_drv_heartbeat;
|
||||
|
||||
// Change the character used for "..."
|
||||
ELLIPSIS = '~';
|
||||
@@ -519,6 +521,38 @@ curses_drv_icon (int which, char dest)
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// Does the heartbeat...
|
||||
//
|
||||
static void
|
||||
curses_drv_heartbeat (int type)
|
||||
{
|
||||
static int timer = 0;
|
||||
int whichIcon;
|
||||
static int saved_type = HEARTBEAT_ON;
|
||||
|
||||
if (type)
|
||||
saved_type = type;
|
||||
|
||||
if (type == HEARTBEAT_ON) {
|
||||
// Set this to pulsate like a real heart beat...
|
||||
whichIcon = (! ((timer + 4) & 5));
|
||||
|
||||
// This defines a custom character EVERY time...
|
||||
// not efficient... is this necessary?
|
||||
curses_drv_icon (whichIcon, 0);
|
||||
|
||||
// Put character on screen...
|
||||
curses_drv_chr (curses_drv->wid, 1, 0);
|
||||
|
||||
// change display...
|
||||
curses_drv_flush ();
|
||||
}
|
||||
|
||||
timer++;
|
||||
timer &= 0x0f;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Flushes all output to the lcd...
|
||||
//
|
||||
|
||||
@@ -19,5 +19,6 @@ void curses_drv_draw_frame (char *dat);
|
||||
char curses_drv_getkey ();
|
||||
void curses_drv_init_num ();
|
||||
void curses_drv_num (int x, int num);
|
||||
void curses_drv_heartbeat (int type);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -58,6 +58,7 @@ static void lcd_drv_draw_frame ();
|
||||
static char lcd_drv_getkey ();
|
||||
static char lcd_drv_getkey_loop ();
|
||||
static char *lcd_drv_getinfo ();
|
||||
static void lcd_drv_heartbeat (int type);
|
||||
|
||||
/*
|
||||
* Add all of the driver's header files in...
|
||||
@@ -306,6 +307,7 @@ lcd_drv_init (struct lcd_logical_driver *driver, char *args)
|
||||
|
||||
driver->getkey = lcd_drv_getkey;
|
||||
driver->getinfo = lcd_drv_getinfo;
|
||||
driver->heartbeat = lcd_drv_heartbeat;
|
||||
|
||||
return 1; // 1 is arbitrary. (must be 1 or more)
|
||||
}
|
||||
@@ -340,6 +342,7 @@ lcd_drv_patch_init (struct lcd_logical_driver *driver)
|
||||
|
||||
ChkNull(getkey, lcd_drv_getkey, "getkey");
|
||||
ChkNull(getinfo, lcd_drv_getinfo, "getinfo");
|
||||
ChkNull(heartbeat, lcd_drv_heartbeat, "heartbeat");
|
||||
|
||||
// Now check for base driver entries...;
|
||||
ChkBaseDrv(clear, lcd_drv_clear, "clear");
|
||||
@@ -365,6 +368,7 @@ lcd_drv_patch_init (struct lcd_logical_driver *driver)
|
||||
|
||||
ChkBaseDrv(getkey, lcd_drv_getkey, "getkey");
|
||||
ChkBaseDrv(getinfo, lcd_drv_getinfo, "getinfo");
|
||||
ChkBaseDrv(heartbeat, lcd_drv_heartbeat, "heartbeat");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -692,3 +696,9 @@ lcd_drv_getkey_loop () {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
lcd_drv_heartbeat (int type)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,8 @@ typedef struct lcd_logical_driver {
|
||||
// Returns pointer to static string.
|
||||
char * (*getinfo) ();
|
||||
|
||||
// Puts up a heartbeat...
|
||||
void (*heartbeat) (int type);
|
||||
// more?
|
||||
|
||||
} lcd_logical_driver;
|
||||
|
||||
Reference in New Issue
Block a user