EZ
Up Prev Next Contents


3.25.2 Interaction Routines

void EZ_SetLcdString(EZ_Widget *lcd, char *str)

void EZ_ClearLcd(EZ_Widget *lcd)

void EZ_SetLcdInteger(EZ_Widget *lcd, int n)

void EZ_SetLcdFloat(EZ_Widget *lcd, float f)

void EZ_SetLcdNDigits(EZ_Widget *lcd, int n)

void EZ_SetLcdFontSize(EZ_Widget *lcd, int n)

void EZ_SetLcdBackground(EZ_Widget *lcd, char *clr)

void EZ_SetLcdForeground(EZ_Widget *lcd, char *clr)

\subsection*An Example Here is a simple example that uses the LCD widget to implements a digital clock.

/*********************** EZ colck ************************/
#include 
#include  
#include  
#include 
#include "EZ.h"

void timer_callback(EZ_Timer *timer, void *pdata)
{
  static int second = -1;
  static int show = 0;
  long      cur_t;
  struct tm *tmptr;
  int       sec, min, hr;
      
  time(&cur_t);
  tmptr = localtime(&cur_t);
  sec = tmptr->tm_sec;
  min = tmptr->tm_min;
  hr = tmptr->tm_hour;      
  if(sec != second)
    {
      char   str[16];
      if(show){   sprintf(str, "%02d:%02d",hr,min); show = 0;}
      else    {   sprintf(str, "%02d %02d",hr,min); show = 1;}
      second = sec;
      EZ_SetLcdString((EZ_Widget *)pdata, str);
    }
}

main(int ac, char **av)
{
  int i;
  EZ_Widget *ezclock;
  EZ_Timer *timer;

  EZ_Initialize(ac,av,0);
  ezclock= EZ_CreateWidget(EZ_WIDGET_LCD, NULL, 
                           EZ_LCD_NDIGITS,    5,
                           EZ_LCD_FONT_SIZE, 30,
                           0);
  for(i = 1; i < ac; )
    {
      if(!strcmp(av[i], "-bg"))
        { if(i+1 < ac) EZ_ConfigureWidget(ezclock, 
                                          EZ_LCD_BACKGROUND, av[(++i)],
                                          0);}
      if(!strcmp(av[i], "-fg"))
        { if(i+1 < ac) EZ_ConfigureWidget(ezclock, 
                                          EZ_LCD_FOREGROUND, av[(++i)],
                                          0); }
      i++;
    }
  EZ_DisplayWidget(ezclock);
  timer = EZ_CreateTimer(0, 500000, -1, timer_callback, ezclock, 0);
  EZ_EventMainLoop();
}
/****************************************************************/



HTML Documentation Maintainance:Arturo Espinosa <arturo@nuclecu.unam.mx>