lcd.h

来自「德州仪器(TI) 的超低功耗16 位RISC 混合信号处理器的MSP430 平台」· C头文件 代码 · 共 52 行

H
52
字号

#define kLcdOk     0
#define kLcdError -1

class Lcd
{
public:
  Lcd();
  Lcd( char* string, bool uppercase = true, bool flush = true );
 ~Lcd() {}
  
  // put one character, called from __dbg_XXWrite.c
  int  PutChar(char c, bool uppercase = true, bool flush = true );
  
  // Flush a buffer to the display
  void Flush( void ) { Clear14Seg(); UpdateDisplay(); }   
  
  // 7-seg small display
  void SevenSeg( int left, int right, bool colon = false );
  void SevenSeg( void );
    
  // special segment control
  void ArrowUp   ( bool on = true ) { SegmentControl( 2,  0x20, on ); }
  void ArrowDown ( bool on = true ) { SegmentControl( 2,  0x80, on ); }
  void ArrowLeft ( bool on = true ) { SegmentControl( 2,  0x10, on ); }
  void ArrowRight( bool on = true ) { SegmentControl( 2,  0x40, on ); }
  
  void Plus      ( bool on = true ) { SegmentControl( 20, 0x80, on ); }
  void Minus     ( bool on = true ) { SegmentControl( 20, 0x10, on ); }  
  void u         ( bool on = true ) { SegmentControl( 1,  0x80, on ); }
  void m         ( bool on = true ) { SegmentControl( 1,  0x40, on ); } 
  void H         ( bool on = true ) { SegmentControl( 1,  0x20, on ); }  
  void F         ( bool on = true ) { SegmentControl( 1,  0x10, on ); } 
  void Olimex    ( bool on = true ) { SegmentControl( 8,  0x80, on ); }

  // 
  void Clear7Seg( void );
  void Clear14Seg( void );
  void Clear( int No );
  void Clear( int first, int last );
  
private:
  void Init( void );
  void SegmentControl( unsigned char LCDMx, unsigned char regValue, bool on );
  void UpdateDisplay( long delay = 20000 );
  
  int   mPos;
  char  mBuffer[0xFF];
  
  static bool firstTime;
};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?