• Main Page
  • Classes
  • Files
  • File List
  • File Members

textlcd.h

Go to the documentation of this file.
00001 //
00002 // begin license header
00003 //  
00004 // This file is part of Terk and TerkOS.
00005 //
00006 // All Terk and TerkOS source code is provided under the terms of the 
00007 // GNU General Public License v2 (http://www.gnu.org/licenses/gpl-2.0.html).  
00008 // Those wishing to use Terk and TerkOS source code, software and/or
00009 // technologies under different licensing terms should contact us at 
00010 // [email protected]. Such licensing terms are available for
00011 // all portions of the Terk and TerkOS codebase presented here.
00012 //
00013 // end license header
00014 //
00015 
00016 #ifndef _TEXTLCD_H
00017 #define _TEXTLCD_H
00018 
00019 #include <stdio.h>
00020 #include <stdlib.h>
00021 #include <stdarg.h>
00022 #include <unistd.h>
00023 #include "singleton.h"
00024 #include "property.h"
00025 #include "9302hw.h"
00026 
00027 // Properties
00028 #define TL_OBJECT           1
00029 #define TL_PROP_BACKLIGHT   PROP_ID(TL_OBJECT, 0)
00030 #define TL_PROP_HEIGHT      PROP_ID(TL_OBJECT, 1)
00031 #define TL_PROP_WIDTH       PROP_ID(TL_OBJECT, 2)
00032 
00033 #define TL_CHAR_UP          0x01
00034 #define TL_CHAR_DOWN        0xf5
00035 #define TL_CHAR_LEFT        0xf7
00036 #define TL_CHAR_RIGHT       0xf6
00037 #define TL_CHAR_LOWBATT     0x02
00038 #define TL_CHAR_COPYRIGHT   0xcf 
00039 #define TL_CHAR_WSA0        0x03 // wireless strength (just antenna)
00040 #define TL_CHAR_WSA1        0x04 // wireless strength (antenna with 1 bar)
00041 #define TL_CHAR_WSB0        0x20 // wireless strength (2nd char, 0 bars)
00042 #define TL_CHAR_WSB1        0x05 // wireless strength (2nd char, 1 bar)
00043 #define TL_CHAR_WSB2        0x06 // wireless strength (2nd char, 2 bars)
00044 #define TL_CHAR_WSB3        0x07 // wireless strength (2nd char, 2 bars)
00045 
00046 
00047 #define TL_STRING_UP          "\x01"
00048 #define TL_STRING_DOWN        "\xf5"
00049 #define TL_STRING_LEFT        "\xf7"
00050 #define TL_STRING_RIGHT       "\xf6"
00051 #define TL_STRING_LOWBATT     "\x02"
00052 #define TL_STRING_COPYRIGHT   "\xcf" 
00053 #define TL_STRING_WSA0        "\x03" // wireless strength (just antenna)
00054 #define TL_STRING_WSA1        "\x04" // wireless strength (antenna with 1 bar)
00055 #define TL_STRING_WSB0        "\x20" // wireless strength (2nd char, 0 bars)
00056 #define TL_STRING_WSB1        "\x05" // wireless strength (2nd char, 1 bar)
00057 #define TL_STRING_WSB2        "\x06" // wireless strength (2nd char, 2 bars)
00058 #define TL_STRING_WSB3        "\x07" // wireless strength (2nd char, 2 bars)
00059 
00060 
00061 #define TL_DELAY()          Delay(20)
00062 #define TL_DELAYL()         Delay(2000)
00063 class CTextLcd : public IProperty
00079 {
00080 public:
00084   SINGLETON(CTextLcd);
00085 
00086   static const unsigned int NUM_ROWS;
00087   static const unsigned int NUM_COLUMNS;
00088 
00092   void Clear();
00093 
00099   void MoveCursor(const unsigned int row, const unsigned int col);
00100 
00106   int printf(const char *format, ...);
00111   void SetCharacter(const char character);
00112 
00113   // Save(CContext *context);
00114   // Restore(CContext context);
00115 
00120   virtual int GetProperty(int property, long *value);
00121 
00126   virtual int SetProperty(int property, long value);
00127 
00128 private:
00129   CTextLcd();
00130   virtual ~CTextLcd();
00131 
00132   void Init();
00133   void DefineChars();
00134   void PutNibble(unsigned char c);
00135   void PutByte(unsigned char c);
00136   void Delay(unsigned int us);
00137 
00138   const bool IsValidRow(const unsigned int row) const
00139   {
00140     return (row < CTextLcd::NUM_ROWS);
00141   }
00142 
00143   const bool IsValidColumn(const unsigned int col) const
00144   {
00145     return (col < CTextLcd::NUM_COLUMNS);
00146   }
00147 
00148   const bool IsValidPosition(const unsigned int row, const unsigned int col) const
00149   {
00150     return IsValidRow(row) && IsValidColumn(col);
00151   }
00152 
00153   C9302Hardware *m_p9302hw;
00154 };
00155 
00156 #endif

Generated on Mon Oct 3 2011 15:36:31 for libqwerk by  doxygen 1.7.1