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:
+27
-4
@@ -25,6 +25,7 @@
|
|||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "render.h"
|
||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
#include "lcd_lib.h"
|
#include "lcd_lib.h"
|
||||||
#include "MtxOrb.h"
|
#include "MtxOrb.h"
|
||||||
@@ -383,6 +384,7 @@ MtxOrb_init (lcd_logical_driver * driver, char *args)
|
|||||||
|
|
||||||
driver->getkey = MtxOrb_getkey;
|
driver->getkey = MtxOrb_getkey;
|
||||||
driver->getinfo = MtxOrb_getinfo;
|
driver->getinfo = MtxOrb_getinfo;
|
||||||
|
driver->heartbeat = MtxOrb_heartbeat;
|
||||||
|
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
@@ -1265,12 +1267,33 @@ MtxOrb_ask_bar (int type)
|
|||||||
/////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////
|
||||||
// Does the heartbeat...
|
// Does the heartbeat...
|
||||||
//
|
//
|
||||||
static char
|
static void
|
||||||
MtxOrb_heartbeat (int timer)
|
MtxOrb_heartbeat (int type)
|
||||||
{
|
{
|
||||||
MtxOrb_icon (!((timer + 4) & 5), 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);
|
MtxOrb_chr (MtxOrb->wid, 1, 0);
|
||||||
return (char) 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 void MtxOrb_draw_frame (char *dat);
|
||||||
static char MtxOrb_getkey ();
|
static char MtxOrb_getkey ();
|
||||||
static char * MtxOrb_getinfo ();
|
static char * MtxOrb_getinfo ();
|
||||||
|
static void MtxOrb_heartbeat (int type);
|
||||||
|
|
||||||
static int MtxOrb_ask_bar (int type);
|
static int MtxOrb_ask_bar (int type);
|
||||||
static void MtxOrb_set_known_char (int car, int type);
|
static void MtxOrb_set_known_char (int car, int type);
|
||||||
|
|||||||
@@ -26,9 +26,10 @@
|
|||||||
|
|
||||||
#include "shared/str.h"
|
#include "shared/str.h"
|
||||||
|
|
||||||
|
#include "render.h"
|
||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
#include "curses_drv.h"
|
#include "curses_drv.h"
|
||||||
#include "drv_base.h"
|
//#include "drv_base.h"
|
||||||
|
|
||||||
lcd_logical_driver *curses_drv;
|
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->draw_frame = curses_drv_draw_frame;
|
||||||
|
|
||||||
driver->getkey = curses_drv_getkey;
|
driver->getkey = curses_drv_getkey;
|
||||||
|
driver->heartbeat = curses_drv_heartbeat;
|
||||||
|
|
||||||
// Change the character used for "..."
|
// Change the character used for "..."
|
||||||
ELLIPSIS = '~';
|
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...
|
// Flushes all output to the lcd...
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -19,5 +19,6 @@ void curses_drv_draw_frame (char *dat);
|
|||||||
char curses_drv_getkey ();
|
char curses_drv_getkey ();
|
||||||
void curses_drv_init_num ();
|
void curses_drv_init_num ();
|
||||||
void curses_drv_num (int x, int num);
|
void curses_drv_num (int x, int num);
|
||||||
|
void curses_drv_heartbeat (int type);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ static void lcd_drv_draw_frame ();
|
|||||||
static char lcd_drv_getkey ();
|
static char lcd_drv_getkey ();
|
||||||
static char lcd_drv_getkey_loop ();
|
static char lcd_drv_getkey_loop ();
|
||||||
static char *lcd_drv_getinfo ();
|
static char *lcd_drv_getinfo ();
|
||||||
|
static void lcd_drv_heartbeat (int type);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add all of the driver's header files in...
|
* 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->getkey = lcd_drv_getkey;
|
||||||
driver->getinfo = lcd_drv_getinfo;
|
driver->getinfo = lcd_drv_getinfo;
|
||||||
|
driver->heartbeat = lcd_drv_heartbeat;
|
||||||
|
|
||||||
return 1; // 1 is arbitrary. (must be 1 or more)
|
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(getkey, lcd_drv_getkey, "getkey");
|
||||||
ChkNull(getinfo, lcd_drv_getinfo, "getinfo");
|
ChkNull(getinfo, lcd_drv_getinfo, "getinfo");
|
||||||
|
ChkNull(heartbeat, lcd_drv_heartbeat, "heartbeat");
|
||||||
|
|
||||||
// Now check for base driver entries...;
|
// Now check for base driver entries...;
|
||||||
ChkBaseDrv(clear, lcd_drv_clear, "clear");
|
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(getkey, lcd_drv_getkey, "getkey");
|
||||||
ChkBaseDrv(getinfo, lcd_drv_getinfo, "getinfo");
|
ChkBaseDrv(getinfo, lcd_drv_getinfo, "getinfo");
|
||||||
|
ChkBaseDrv(heartbeat, lcd_drv_heartbeat, "heartbeat");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -692,3 +696,9 @@ lcd_drv_getkey_loop () {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
lcd_drv_heartbeat (int type)
|
||||||
|
{
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ typedef struct lcd_logical_driver {
|
|||||||
// Returns pointer to static string.
|
// Returns pointer to static string.
|
||||||
char * (*getinfo) ();
|
char * (*getinfo) ();
|
||||||
|
|
||||||
|
// Puts up a heartbeat...
|
||||||
|
void (*heartbeat) (int type);
|
||||||
// more?
|
// more?
|
||||||
|
|
||||||
} lcd_logical_driver;
|
} lcd_logical_driver;
|
||||||
|
|||||||
+3
-1
@@ -5,6 +5,8 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "render.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
contains a few things that other parts of the program might want
|
contains a few things that other parts of the program might want
|
||||||
to know about...
|
to know about...
|
||||||
@@ -28,7 +30,7 @@ typedef struct screen_size {
|
|||||||
|
|
||||||
#define DEFAULT_SCREEN_PRIORITY 128
|
#define DEFAULT_SCREEN_PRIORITY 128
|
||||||
#define DEFAULT_SCREEN_DURATION 32
|
#define DEFAULT_SCREEN_DURATION 32
|
||||||
#define DEFAULT_HEARTBEAT 1
|
#define DEFAULT_HEARTBEAT HEARTBEAT_ON
|
||||||
#define DEFAULT_ADDR "127.0.0.1"
|
#define DEFAULT_ADDR "127.0.0.1"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+5
-4
@@ -116,13 +116,14 @@ draw_screen (screen * s, int timer)
|
|||||||
//debug("draw_screen done\n");
|
//debug("draw_screen done\n");
|
||||||
|
|
||||||
if (heartbeat) {
|
if (heartbeat) {
|
||||||
if ((s->heartbeat == HEART_ON) || heartbeat == HEART_ON) {
|
lcd_ptr->heartbeat(s->heartbeat);
|
||||||
|
//if ((s->heartbeat == HEART_ON) || heartbeat == HEART_ON) {
|
||||||
// Set this to pulsate like a real heart beat...
|
// Set this to pulsate like a real heart beat...
|
||||||
// (binary is fun... :)
|
// (binary is fun... :)
|
||||||
// lcd_ptr->heartbeat ();
|
// lcd_ptr->heartbeat ();
|
||||||
lcd_ptr->icon (!((timer + 4) & 5), 0);
|
//lcd_ptr->icon (!((timer + 4) & 5), 0);
|
||||||
lcd_ptr->chr (lcd_ptr->wid, 1, 0);
|
//lcd_ptr->chr (lcd_ptr->wid, 1, 0);
|
||||||
}
|
//}
|
||||||
// else
|
// else
|
||||||
// This seems unnecessary... heartbeat is nicer...
|
// This seems unnecessary... heartbeat is nicer...
|
||||||
// if ((s->heartbeat == HEART_OPEN) && heartbeat != HEART_OFF) {
|
// if ((s->heartbeat == HEART_OPEN) && heartbeat != HEART_OFF) {
|
||||||
|
|||||||
+7
-3
@@ -3,9 +3,13 @@
|
|||||||
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
#define HEART_OFF 0
|
#define HEART_OFF 1
|
||||||
#define HEART_ON 1
|
#define HEART_ON 2
|
||||||
#define HEART_OPEN 2
|
#define HEART_OPEN 3
|
||||||
|
|
||||||
|
#define HEARTBEAT_OFF HEART_OFF
|
||||||
|
#define HEARTBEAT_ON HEART_ON
|
||||||
|
#define HEARTBEAT_OPEN HEART_OPEN
|
||||||
|
|
||||||
#define BACKLIGHT_OFF 0
|
#define BACKLIGHT_OFF 0
|
||||||
#define BACKLIGHT_ON 1
|
#define BACKLIGHT_ON 1
|
||||||
|
|||||||
+3
-2
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "widget.h"
|
#include "widget.h"
|
||||||
|
#include "render.h"
|
||||||
|
|
||||||
char *types[] = { "none",
|
char *types[] = { "none",
|
||||||
"string",
|
"string",
|
||||||
@@ -164,7 +165,7 @@ widget_add (screen * s, char *id, char *type, char *in, int sock)
|
|||||||
list = s->widgets;
|
list = s->widgets;
|
||||||
|
|
||||||
if (0 == strcmp (id, "heartbeat")) {
|
if (0 == strcmp (id, "heartbeat")) {
|
||||||
s->heartbeat = 1;
|
s->heartbeat = HEARTBEAT_ON; // was 1
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,7 +261,7 @@ widget_remove (screen * s, char *id, int sock)
|
|||||||
list = s->widgets;
|
list = s->widgets;
|
||||||
|
|
||||||
if (0 == strcmp (id, "heartbeat")) {
|
if (0 == strcmp (id, "heartbeat")) {
|
||||||
s->heartbeat = 0;
|
s->heartbeat = HEARTBEAT_OFF; // was 0
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// Make sure this screen *does* exist...
|
// Make sure this screen *does* exist...
|
||||||
|
|||||||
Reference in New Issue
Block a user