annotate service/arduinoNode/arduino-libraries/ST7565/ST7565.h @ 1543:ab985b87043e

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