
#include <vdr/thread.h>
#include <vdr/player.h>
#include <sys/time.h>

/* DEFINITIONS */

#define LCD_PORT "/dev/ttyS1"
#define MULTIVERSION "mLCD v0.3"

#define INIT 0xb0
#define SYM 0xb5
#define TEXT 0xb3
#define GRAPH 0xb4

#define FONTFILE "/etc/char.dat"

class mLCD : public cThread {
 private:
  unsigned int font[256][6];
  unsigned int oldmuster[10][6];
  char chline1[11], chline2[11];
  char line1[11], oldline1[11];
  char line2[11], oldline2[11];
  int oldmodus;
  int fd;
  int cardstate[4];
  int open_port(void);
  void close_port();
  int init_display();
  int set_char(int line, int pixel, unsigned int bitmuster[6]);
  void setup_port();
  int read_font();
  void clear_text();
  void print_line(int line, char text[11]);
  void test_display();
  int set_symbol(int symbol, int mode);
  void progressbar(int percent);
  void ReplaySymbols(int mode);
  virtual void Action(void);
  bool stop, running, title;
  int ProgressValue, OldProgressValue, DisplaySeconds;
  struct timeval now;
  struct timeval VolumeStartTime;
  cControl *PlayControl;

 public:
  mLCD();
  ~mLCD();
  void display_volume(int timeout, int volume, bool muted);
  void SetProgress(const char *HMSF,int percent);
  void SetChannelName(const char *Name);
  void SetChannel(int ChannelNumber);
  void SetChannelInfo(const char *Info);
  void ReplayControl(cControl *Control, const char *Name);
  void SetRecordingState(int card, const char *Name);
  bool starttest, refresh;
  int lcdmodus; // currently: 0=Channeldisplay
  int symbol[25], oldsymbol[25];

};
