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