comparison service/arduinoNode/arduino-libraries/ST7565/ST7565.h @ 168:b2f909325bb2

core files from https://github.com/adafruit/ST7565-LCD Ignore-this: 8dfadccdfb732e632cf7221c2fb527e4
author drewp@bigasterisk.com
date Sun, 12 Apr 2015 03:43:20 -0700
parents
children
comparison
equal deleted inserted replaced
167:3dd84ac050d0 168:b2f909325bb2
1 /*
2 $Id:$
3
4 ST7565 LCD library!
5
6 Copyright (C) 2010 Limor Fried, Adafruit Industries
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22 // some of this code was written by <cstone@pobox.com> originally; it is in the public domain.
23 */
24
25 #if ARDUINO >= 100
26 #include "Arduino.h"
27 #else
28 #include "WProgram.h"
29 #endif
30
31 #define swap(a, b) { uint8_t t = a; a = b; b = t; }
32
33 #define BLACK 1
34 #define WHITE 0
35
36 #define LCDWIDTH 128
37 #define LCDHEIGHT 64
38
39 #define CMD_DISPLAY_OFF 0xAE
40 #define CMD_DISPLAY_ON 0xAF
41
42 #define CMD_SET_DISP_START_LINE 0x40
43 #define CMD_SET_PAGE 0xB0
44
45 #define CMD_SET_COLUMN_UPPER 0x10
46 #define CMD_SET_COLUMN_LOWER 0x00
47
48 #define CMD_SET_ADC_NORMAL 0xA0
49 #define CMD_SET_ADC_REVERSE 0xA1
50
51 #define CMD_SET_DISP_NORMAL 0xA6
52 #define CMD_SET_DISP_REVERSE 0xA7
53
54 #define CMD_SET_ALLPTS_NORMAL 0xA4
55 #define CMD_SET_ALLPTS_ON 0xA5
56 #define CMD_SET_BIAS_9 0xA2
57 #define CMD_SET_BIAS_7 0xA3
58
59 #define CMD_RMW 0xE0
60 #define CMD_RMW_CLEAR 0xEE
61 #define CMD_INTERNAL_RESET 0xE2
62 #define CMD_SET_COM_NORMAL 0xC0
63 #define CMD_SET_COM_REVERSE 0xC8
64 #define CMD_SET_POWER_CONTROL 0x28
65 #define CMD_SET_RESISTOR_RATIO 0x20
66 #define CMD_SET_VOLUME_FIRST 0x81
67 #define CMD_SET_VOLUME_SECOND 0
68 #define CMD_SET_STATIC_OFF 0xAC
69 #define CMD_SET_STATIC_ON 0xAD
70 #define CMD_SET_STATIC_REG 0x0
71 #define CMD_SET_BOOSTER_FIRST 0xF8
72 #define CMD_SET_BOOSTER_234 0
73 #define CMD_SET_BOOSTER_5 1
74 #define CMD_SET_BOOSTER_6 3
75 #define CMD_NOP 0xE3
76 #define CMD_TEST 0xF0
77
78 class ST7565 {
79 public:
80 ST7565(int8_t SID, int8_t SCLK, int8_t A0, int8_t RST, int8_t CS) :sid(SID), sclk(SCLK), a0(A0), rst(RST), cs(CS) {}
81 ST7565(int8_t SID, int8_t SCLK, int8_t A0, int8_t RST) :sid(SID), sclk(SCLK), a0(A0), rst(RST), cs(-1) {}
82
83
84 void st7565_init(void);
85 void begin(uint8_t contrast);
86 void st7565_command(uint8_t c);
87 void st7565_data(uint8_t c);
88 void st7565_set_brightness(uint8_t val);
89 void clear_display(void);
90 void clear();
91 void display();
92
93 void setpixel(uint8_t x, uint8_t y, uint8_t color);
94 uint8_t getpixel(uint8_t x, uint8_t y);
95 void fillcircle(uint8_t x0, uint8_t y0, uint8_t r,
96 uint8_t color);
97 void drawcircle(uint8_t x0, uint8_t y0, uint8_t r,
98 uint8_t color);
99 void drawrect(uint8_t x, uint8_t y, uint8_t w, uint8_t h,
100 uint8_t color);
101 void fillrect(uint8_t x, uint8_t y, uint8_t w, uint8_t h,
102 uint8_t color);
103 void drawline(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1,
104 uint8_t color);
105 void drawchar(uint8_t x, uint8_t line, char c);
106 void drawstring(uint8_t x, uint8_t line, char *c);
107 void drawstring_P(uint8_t x, uint8_t line, const char *c);
108
109 void drawbitmap(uint8_t x, uint8_t y,
110 const uint8_t *bitmap, uint8_t w, uint8_t h,
111 uint8_t color);
112
113 private:
114 int8_t sid, sclk, a0, rst, cs;
115 void spiwrite(uint8_t c);
116
117 void my_setpixel(uint8_t x, uint8_t y, uint8_t color);
118
119 //uint8_t buffer[128*64/8];
120 };