-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtiny1106.h
More file actions
81 lines (57 loc) · 1.57 KB
/
tiny1106.h
File metadata and controls
81 lines (57 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Credits:
// http://www.technoblogy.com/show?23OS
#ifndef tiny1106_h
#define tiny1106_h
#include <Arduino.h>
#include <Wire.h>
#include "charMap.h"
#ifdef OLED_RU
#include "charMapRU.h"
#endif
#ifndef OLED_OFFSET
#define OLED_OFFSET 2
#endif
#define OLED_DISPLAY_ON 0xAF
#define OLED_DISPLAY_OFF 0xAE
#define OLED_DISPLAY_OFFSET_MODE 0xD3
#define OLED_COMMAND_MODE 0x00
#define OLED_ONE_COMMAND_MODE 0x80
#define OLED_DATA_MODE 0x40
#define OLED_ONE_DATA_MODE 0xC0
#define OLED_CONTRAST 0x81
#define OLED_NORMAL 0xA6
#define OLED_INVERTED 0xA7
#define OLED_NORMAL_V 0xC8
#define OLED_FLIP_V 0xC0
#define OLED_NORMAL_H 0xA1
#define OLED_FLIP_H 0xA0
#define OLED_READ_MODIFY_WRITE 0xE0
#define OLED_END 0xEE
#define OLED_PAGE 0xB0
#define OLED_COLUMN_HIGHER_BITS 0x10
#define OLED_COLUMN_LOWER_BITS 0x00
class Oled
{
public:
Oled(uint8_t address = 0x3C);
void init();
void setContrast(uint8_t contrast);
void clear();
void clear(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1);
void fill(uint8_t fill);
void drawPoint(uint8_t x, uint8_t y);
void drawLine(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1);
void drawLineV(uint8_t x, uint8_t y0, uint8_t y1);
void drawLineH(uint8_t y, uint8_t x0, uint8_t x1);
void print(char text[]);
void printFast(char text[]);
void setCursor(uint8_t x, uint8_t y);
void setTextScale(uint8_t scale);
void sendCommand(int8_t command);
private:
int _address;
uint8_t _textScale = 1, _x, _y;
void sendOneCommand(int8_t command);
uint32_t scaleByte(uint8_t data);
};
#endif