#include <string.h>
static u8g_t u8g_data;
#if (BSP430_U8GLIB_REFRESH_INTERVAL_MS - 0)
#ifndef REFRESH_ALARM_CCIDX
#define REFRESH_ALARM_CCIDX 1
#endif
typedef struct sRefreshTimerState {
unsigned long interval_tck;
u8g_t * u8g;
} sRefreshTimerState;
static sRefreshTimerState refresh_state;
static int
{
sRefreshTimerState * rtsp = (sRefreshTimerState *)alarm;
unsigned long setting_tck;
int rc;
int rv;
do {
setting_tck += rtsp->interval_tck;
} while (0 < rc);
return rv;
}
static int
enableRefreshTimer ()
{
int rc = 0;
if (0 == refresh_state.interval_tck) {
cprintf(
"Refresh timer defined but empty interval?");
return -1;
}
cprintf(
"Enable refresh every %lu ticks\n", refresh_state.interval_tck);
refresh_state.u8g = &u8g_data;
REFRESH_ALARM_CCIDX,
refresh_cb_ni);
if (ah) {
do {
if (0 == rc) {
}
} while (0);
}
if (0 != rc) {
cprintf(
"Failed to initialize alarm\n");
}
return rc;
}
#else
static int
enableRefreshTimer ()
{
cprintf(
"No refresh timer required\n");
return 0;
}
#endif
void main ()
{
int w;
int h;
int rc;
unsigned long t0;
unsigned long t1;
u8g_t * u8g = &u8g_data;
cprintf(
"\nBuild " __DATE__
" " __TIME__
"\n");
cprintf(
"U8G device initialization got %d\n", rc);
if (0 != enableRefreshTimer()) {
cprintf(
"ERROR: Unable to configure refresh timer\n");
return;
}
cprintf(
"Device size %u x %u, mode %d\n", u8g_GetWidth(u8g), u8g_GetHeight(u8g), u8g_GetMode(u8g));
u8g_SetDefaultForegroundColor(u8g);
u8g_SetFont(u8g, u8g_font_10x20);
w = u8g_GetFontBBXWidth(u8g);
h = u8g_GetFontBBXHeight(u8g);
cprintf(
"Font cell %u x %u\n", w, h);
u8g_FirstPage(u8g);
do {
u8g_DrawLine(u8g, 0, 0, u8g_GetWidth(u8g), u8g_GetHeight(u8g));
u8g_DrawStr(u8g, 0, h, __DATE__);
u8g_DrawStr(u8g, 0, 3*h, __TIME__);
} while (u8g_NextPage(u8g));
cprintf(
"Write screen took %lu ticks\n", t1-t0);
#if 0
{
unsigned int contrast;
cprintf(
"Cycling through contrast levels\n");
for (contrast = 0; contrast < 256; contrast += 16) {
u8g_SetContrast(u8g, contrast);
}
u8g_SetContrast(u8g, 22 << 2);
}
#endif
while (1) {
u8g_SleepOff(u8g);
u8g_SleepOn(u8g);
}
}