forked from adafruit/Adafruit_SHARP_Memory_Display
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Adafruit_SharpMem.h
74 lines (61 loc) · 2.12 KB
/
Adafruit_SharpMem.h
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
/*********************************************************************
This is an Arduino library for our Monochrome SHARP Memory Displays
Pick one up today in the adafruit shop!
------> http://www.adafruit.com/products/1393
These displays use SPI to communicate, 3 pins are required to
interface
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, check license.txt for more information
All text above, and the splash screen must be included in any redistribution
*********************************************************************/
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#if defined(RAMSTART) && defined(RAMEND) && ((RAMEND-RAMSTART) < 4096)
#warning "Display may not work on devices with less than 4K RAM"
#endif
#include <Adafruit_GFX.h>
#ifdef __AVR
#include <avr/pgmspace.h>
#elif defined(ESP8266)
#include <pgmspace.h>
#endif
#if defined(ARDUINO_STM32_FEATHER)
typedef volatile uint32 RwReg;
//#define USE_FAST_PINIO
#elif defined(ARDUINO_FEATHER52) || defined (ESP8266) || defined (ESP32) || defined(__SAM3X8E__) || defined(ARDUINO_ARCH_SAMD)
typedef volatile uint32_t RwReg;
#define USE_FAST_PINIO // tested!
#elif defined (__AVR__) || defined(TEENSYDUINO)
typedef volatile uint8_t RwReg;
#define USE_FAST_PINIO
#else
#undef USE_FAST_PINIO
#endif
// LCD Dimensions
#define SHARPMEM_LCDWIDTH (128)
#define SHARPMEM_LCDHEIGHT (128)
#define SHARPMEM_LCDDEPTH (3)
class Adafruit_SharpMem : public Adafruit_GFX {
public:
Adafruit_SharpMem(uint8_t clk, uint8_t mosi, uint8_t ss);
boolean begin();
void drawPixel(int16_t x, int16_t y, uint16_t color);
uint8_t getPixel(uint16_t x, uint16_t y);
void clearDisplay();
void refresh(void);
private:
uint8_t _ss, _clk, _mosi;
uint32_t _sharpmem_vcom;
#ifdef USE_FAST_PINIO
volatile RwReg *dataport, *clkport;
uint32_t datapinmask, clkpinmask;
#endif
void sendbyte(uint8_t data);
void sendbyteLSB(uint8_t data);
};