Subversion Repositories idreammicro-arduino

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
21 jlesech 1
/*
2
 * Deuligne.h
3
 *
4
 * copyleft 2011 snootlab
5
 * free software, have fun !
6
 *
7
 */
8
#ifndef SNOOTLCDI2C_h
9
#define SNOOTLCDI2C_h
10
 
11
#if defined(ARDUINO) && ARDUINO >= 100
12
#define SNOOT_RETURN size_t
13
#define SNOOT_WIREWRITE Wire.write
14
#else
15
#define SNOOT_RETURN void
16
#define SNOOT_WIREWRITE Wire.send
17
#endif
18
 
19
 
20
 
21
#include <inttypes.h>
22
#include <Print.h>
23
 
24
 
25
// commands
26
#define LCD_CLEARDISPLAY 0x01
27
#define LCD_RETURNHOME 0x02
28
#define LCD_ENTRYMODESET 0x04
29
#define LCD_DISPLAYCONTROL 0x08
30
#define LCD_CURSORSHIFT 0x10
31
#define LCD_FUNCTIONSET 0x20
32
#define LCD_SETCGRAMADDR 0x40
33
#define LCD_SETDDRAMADDR 0x80
34
 
35
// flags for display entry mode
36
#define LCD_ENTRYRIGHT 0x00
37
#define LCD_ENTRYLEFT 0x02
38
#define LCD_ENTRYSHIFTINCREMENT 0x01
39
#define LCD_ENTRYSHIFTDECREMENT 0x00
40
 
41
// flags for display on/off control
42
#define LCD_DISPLAYON 0x04
43
#define LCD_DISPLAYOFF 0x00
44
#define LCD_CURSORON 0x02
45
#define LCD_CURSOROFF 0x00
46
#define LCD_BLINKON 0x01
47
#define LCD_BLINKOFF 0x00
48
 
49
// flags for display/cursor shift
50
#define LCD_DISPLAYMOVE 0x08
51
#define LCD_CURSORMOVE 0x00
52
#define LCD_MOVERIGHT 0x04
53
#define LCD_MOVELEFT 0x00
54
 
55
// flags for function set
56
#define LCD_8BITMODE 0x10
57
#define LCD_4BITMODE 0x00
58
#define LCD_2LINE 0x08
59
#define LCD_1LINE 0x00
60
#define LCD_5x11DOTS 0x04
61
#define LCD_5x8DOTS 0x00
62
 
63
 
64
// overclcking I2C
65
#define CPU_FREQ 16000000L // (...) - a discuter, car fonction vitesse clock cpu
66
#define TWI_FREQ_MCP23008 400000L
67
 
68
// IMPORTANT! Wire. must have a begin() before calling init()
69
 
70
 
71
class Deuligne : public Print {
72
public:
73
  Deuligne(int devI2CAddress=0xA7, int num_lines=2, int lcdwidth=16, int bufferwidth= 40);
74
  void commandWrite(int command);
75
  void init();
76
  void clear();
77
  void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);
78
  virtual SNOOT_RETURN write(uint8_t);
79
  //  virtual void print(uint8_t);
80
  //  virtual void printIn(uint8_t*);
81
  void backLight( bool turnOn );
82
 
83
  //non-core---------------
84
  //void cursorTo(int line_num, int x);
85
  void setCursor(uint8_t col, uint8_t row);
86
  //{cursorTo(n,x);}
87
 
88
  //void leftScroll(int chars, int delay_time);
89
  //end of non-core--------
90
 
91
  //4bit only, therefore ideally private but may be needed by user
92
  //void commandWriteNibble(int nibble);
93
 
94
  //  virtual void print(int value){print((uint8_t)value);}
95
  //  virtual void printIn(char value[]){print((uint8_t*)value);}
96
 
97
  /**
98
   * from LiquidCrystal (official arduino) Library
99
   ***/
100
  void createChar(uint8_t, uint8_t[]);
101
  void command(uint8_t);
102
 
103
  void home();
104
 
105
  void noDisplay();
106
  void display();
107
  void noBlink();
108
  void blink();
109
  void noCursor();
110
  void cursor();
111
  void scrollDisplayLeft();
112
  void scrollDisplayRight();
113
  void leftToRight();
114
  void rightToLeft();
115
  void autoscroll();
116
  void noAutoscroll();
117
 
118
  int get_key();
119
 
120
private:
121
  //void pulseEnablePin();
122
  //void pushNibble(int nibble);
123
  //void pushByte(int value);
124
 
125
 
126
  int myNumLines;
127
  int myWidth;
128
  int myAddress;
129
  int myBufferwidth;
130
  int adc_key_in;
131
  //  int adc_key_val[5];
132
  int NUM_KEYS;
133
 
134
  uint8_t _displayfunction;
135
  uint8_t _displaycontrol;
136
  uint8_t _displaymode;
137
 
138
 
139
};
140
#endif