⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 n6100.h

📁 N6100彩屏显示器的MSP430F425驱动程序
💻 H
字号:
/*
 *      	MSP430FE425中与I/O操作相关的一些宏定义.
 *
 * 		作者:匿名
 *
 *		本软件为自由软件,你可以自由修改和发布.期望它能对你有所益处.
 *               
 *		最后修正时间:2008/7/20
 *		
 *		版权所有:中文中国
 */
#ifndef __N6100__
#define __N6100__
#include "ctype.h"


#define COMMAND   0x00     // Indicates a "command" byte was writed
#define DATA      0x01     // Indicates a "DATA" byte was writed

#define ROWSET    0x2A     // Row address set  (command 0x2B) 
#define CLUSET    0x2B     // Column address set  (command 0x2A) 
#define RAMWRITE  0x2C     // Write Memory  (command  0x2C)
#define SLEEPOUT  0x11     // Sleep out  (command 0x11) 
#define INVON     0x20     // Inversion on  (command 0x20) , seems to be required for this controller 
#define MOMACCTL  0x3A     // Memory access controller  (command 0x36).
#define SETCON    0x25     // Write contrast  (command 0x25) 
#define CONTRAST  0x30     //contrast 0x30
#define DISPLAYON 0x29     // Display On  (command 0x29)

#define COLORMOD  0x36     //Color Interface Pixel Format  (command 0x3A) 
#define COLOR8    0x02     // 8 bits-per-pixel (data 0x02) 
#define COLOR12   0x03     // 12 bits-per-pixel (data 0x03)
#define COLOR16   0x05     // 16 bits-per-pixel (data 0x05)
#define N6100 1
#define endl '\n'

#define ZERO 0
#define ONE  10
#define TWO  100
#define THREE 1000
#define FOUR  10000

typedef enum{ForGColor=1,BackGColor,XCurrent,YCurrent,ScrGColor,Left=125,Right,Center,Precision}Set;
typedef enum {left=125,right=126,center=127}Alignment;
/*以下为设置类,当设置不同的参数时,其设置值只能取系统规定的值,否则的话将出现无法预测的结果,
  其对应设置参数的取值如下:
  Left,Right,Center:无跟随参数值,即系统有预留的默认值
  ForGColor,BackGColor,ScrGColor:Color::*,也可取任意的16位整数值,强烈建议取系统规定的色彩值
  Precision:ZERO,ONE,TWO,THREE,FOUR
  XCurrent,YCurrent:取0-131之间的整数值
*/

class set{
public:
      Set name;
      unsigned int color;
      int position;

public:
      set(Set str,unsigned int color=0){
           name=str;
           switch(str){
                 case ForGColor:case BackGColor:case ScrGColor:case Precision: this->color=color;break;
                 case XCurrent:case YCurrent:this->position=color;break;
           }
          
      }
};
class invalidate{
public:
      int xstart;
      int ystart;
      int width;
      int height;
public:
      invalidate(int xstart=0,int ystart=0,int width=131,int height=131){
            this->xstart=xstart;
            this->ystart=ystart;
            this-> width= width;
            this->height=height;
      }
};

class clear:public invalidate{
     
};
class Color{
public:
      static const unsigned int Blue=0x00f0;
      static const unsigned int Green=0x000f;
      static const unsigned int Black=0x00ff;
      static const unsigned int White=0x0000;
      static const unsigned int Red=0x00f0;
      static const unsigned int Orange=0x000f;
      static const unsigned int Mental=0x00f0;
      static const unsigned int Purple=0x000f;
};
class _N6100{
public:
      _N6100(unsigned int BackGroundColor=0xff,unsigned int ForGroundColor=0xf0,unsigned int ScrGroundColor=0x00);
      //void setForGroundColor(unsigned char FGC);//该函数已经不再使用,可通过(_N6100对象)<<set(parameter,value),parameter和value的具体取值请见说明文档
      //void setBackGroundColor(unsigned char BGC);//同上
      virtual void waveLine();
      void clear();
      void drawimage(const char* image,int xstart,int ystart,int width,int height);
private:
      //以下各函数的参数均是基于像素点为单位的
      void line(int xstart,int ystart,int xstop,int ystop);
      void circle(int xstart,int ystart,int radius,float linewidth=0.5);//linewidth:线宽,该值会影响画圆的速度
      void rectangle(int xstart,int ystart,int width,int height,unsigned char fill);
      void printf(char *str,int xstart=0,int ystart=0);
      void printf(float mod,char *str);//这样定义是没有实在意义的,其作用主要在于用来解决重载带来的问题
      void drawimage( const char* image,Rectangle rec);
      //void drawimage( const char* image,int xstart,int ystart, int width, int height);
      void setBox(int xstart,int xstop,int ystart,int ystop);
      void write(unsigned char datatemp,unsigned char mod);     
      void init();//初始化函数,能常被构造函数调用,对lcd进行一些初参数设置.
      
private:
      //以下为Lcd的全部属性值,它描述了lcd当前的显示环境
      int xcurrent;
      int ycurrent;
      Alignment alignment;        //该属性用于描述字符输出的显示议,如左对齐,右对齐,居中等
      unsigned int precision;     //该属性用于描述所要显示小数点后的数字的位数(即显示精度),该值仅对浮点数的显示输出有影响
      unsigned int BackGroundColor;//显示图形或汉字的背景色
      unsigned int ForGroundColor;//显示图形或汉字的前景色
      unsigned int ScrGroundColor;//与BackGroundColor不同,它是整个屏幕的背景色
      struct{char buffer[50];int length;int position;}buffer;
public:
      
      _N6100 & operator <<(char *str); //字符输函数
      _N6100 & operator <<(char ch);
      _N6100 & operator <<(int num);
      _N6100 & operator <<(float num);
      _N6100 & operator >>(char *str);
      _N6100 & operator <<(_N6100 *);
      
      _N6100 & operator <<(Point point);//作图函数
      _N6100 & operator <<(Line lin); 
      _N6100 & operator <<(WaveLine wavlin); 
      _N6100 & operator <<(Rectangle rec);
      _N6100 & operator <<(Circle cir); 
      
      _N6100 & operator <<(set setp); //设置函数
      _N6100 & operator <<(invalidate inv); 
};

extern _N6100 cout;

#endif

⌨️ 快捷键说明

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