1
1
from Adafruit_EPD import *
2
+ from micropython import const
3
+
4
+ IL91874_PANEL_SETTING = const (0x00 )
5
+ IL91874_POWER_SETTING = const (0x01 )
6
+ IL91874_POWER_OFF = const (0x02 )
7
+ IL91874_POWER_OFF_SEQUENCE = const (0x03 )
8
+ IL91874_POWER_ON = const (0x04 )
9
+ IL91874_POWER_ON_MEASURE = const (0x05 )
10
+ IL91874_BOOSTER_SOFT_START = const (0x06 )
11
+ IL91874_DEEP_SLEEP = const (0x07 )
12
+ IL91874_DTM1 = const (0x10 )
13
+ IL91874_DATA_STOP = const (0x11 )
14
+ IL91874_DISPLAY_REFRESH = const (0x12 )
15
+ IL91874_DTM2 = const (0x13 )
16
+ IL91874_PDTM1 = const (0x14 )
17
+ IL91874_PDTM2 = const (0x15 )
18
+ IL91874_PDRF = const (0x16 )
19
+ IL91874_LUT1 = const (0x20 )
20
+ IL91874_LUTWW = const (0x21 )
21
+ IL91874_LUTBW = const (0x22 )
22
+ IL91874_LUTWB = const (0x23 )
23
+ IL91874_LUTBB = const (0x24 )
24
+ IL91874_PLL = const (0x30 )
25
+ IL91874_CDI = const (0x50 )
26
+ IL91874_RESOLUTION = const (0x61 )
27
+ IL91874_VCM_DC_SETTING = const (0x82 )
2
28
3
29
class Adafruit_IL91874_base (Adafruit_EPD ):
4
- IL91874_PANEL_SETTING = 0x00
5
- IL91874_POWER_SETTING = 0x01
6
- IL91874_POWER_OFF = 0x02
7
- IL91874_POWER_OFF_SEQUENCE = 0x03
8
- IL91874_POWER_ON = 0x04
9
- IL91874_POWER_ON_MEASURE = 0x05
10
- IL91874_BOOSTER_SOFT_START = 0x06
11
- IL91874_DEEP_SLEEP = 0x07
12
- IL91874_DTM1 = 0x10
13
- IL91874_DATA_STOP = 0x11
14
- IL91874_DISPLAY_REFRESH = 0x12
15
- IL91874_DTM2 = 0x13
16
- IL91874_PDTM1 = 0x14
17
- IL91874_PDTM2 = 0x15
18
- IL91874_PDRF = 0x16
19
- IL91874_LUT1 = 0x20
20
- IL91874_LUTWW = 0x21
21
- IL91874_LUTBW = 0x22
22
- IL91874_LUTWB = 0x23
23
- IL91874_LUTBB = 0x24
24
- IL91874_PLL = 0x30
25
- IL91874_CDI = 0x50
26
- IL91874_RESOLUTION = 0x61
27
- IL91874_VCM_DC_SETTING = 0x82
28
30
29
- def __init__ (self , width , height , rst , dc , busy , sclk = None , mosi = None , cs = None , gpio = None , spi = None ):
31
+ def __init__ (self , width , height , rst , dc , busy , srcs = None , cs = None , spi = None ):
30
32
31
- super (Adafruit_IL91874_base , self ).__init__ (width , height , rst , dc , busy , sclk , mosi , cs , gpio , spi )
32
-
33
- self .bw_buffer = [0xFF ]* (width * height >> 3 )
34
- self .red_buffer = [0xFF ]* (width * height >> 3 )
33
+ super (Adafruit_IL91874_base , self ).__init__ (width , height , rst , dc , busy , srcs , cs , spi )
35
34
36
35
def begin (self , reset = True ):
37
36
super (Adafruit_IL91874_base , self ).begin (reset )
38
37
39
- self .command (self .IL91874_POWER_SETTING , [0x07 , 0x00 , 0x0A , 0x00 ])
40
- self .command (self .IL91874_BOOSTER_SOFT_START , [0x07 , 0x07 , 0x07 ])
41
-
42
38
def update (self ):
43
- self .command (self . IL91874_DISPLAY_REFRESH )
39
+ self .command (IL91874_DISPLAY_REFRESH )
44
40
45
- while self ._gpio . is_high ( self . _busy ) :
41
+ while self ._busy . value == True :
46
42
pass
47
43
48
44
time .sleep (10 )
49
45
50
- self .command (self . IL91874_CDI , [0x17 ])
51
- self .command (self . IL91874_VCM_DC_SETTING , [0x00 ])
52
- self .command (self . IL91874_POWER_SETTING , [0x02 , 0x00 , 0x00 , 0x00 ])
53
- self .command (self . IL91874_POWER_OFF )
46
+ self .command (IL91874_CDI , bytearray ( [0x17 ]) )
47
+ self .command (IL91874_VCM_DC_SETTING , bytearray ( [0x00 ]) )
48
+ self .command (IL91874_POWER_SETTING , bytearray ( [0x02 , 0x00 , 0x00 , 0x00 ]) )
49
+ self .command (IL91874_POWER_OFF )
54
50
55
51
time .sleep (10 )
56
52
57
53
def power_up (self ):
58
- self .command (self .IL91874_POWER_ON )
59
- while self ._gpio .is_high (self ._busy ):
54
+ self .command (IL91874_BOOSTER_SOFT_START , bytearray ([0x07 , 0x07 , 0x07 ]))
55
+ self .command (IL91874_POWER_SETTING , bytearray ([0x07 , 0x00 , 0x0A , 0x00 ]))
56
+ self .command (IL91874_POWER_ON )
57
+
58
+ while self ._busy .value == True :
60
59
pass
61
60
62
61
time .sleep (.2 )
63
62
64
- self .command (self . IL91874_PANEL_SETTING , [0xCF ])
65
- self .command (self . IL91874_CDI , [0x37 ])
66
- self .command (self . IL91874_PLL , [0x29 ])
67
- self .command (self . IL91874_VCM_DC_SETTING , [0x0A ])
63
+ self .command (IL91874_PANEL_SETTING , bytearray ( [0xCF ]) )
64
+ self .command (IL91874_CDI , bytearray ( [0x37 ]) )
65
+ self .command (IL91874_PLL , bytearray ( [0x29 ]) )
66
+ self .command (IL91874_VCM_DC_SETTING , bytearray ( [0x0A ]) )
68
67
69
68
def display (self ):
70
69
self .power_up ()
71
70
72
- self .command (self .IL91874_DTM1 , end = False )
73
- self ._gpio .set_high (self ._dc )
74
- for i in range (len (self .bw_buffer )):
75
- self ._spi .write ([self .bw_buffer [i ]])
76
- self ._gpio .set_high (self ._cs )
77
-
78
- self .command (self .IL91874_DTM2 , end = False )
79
- self ._gpio .set_high (self ._dc )
80
- for i in range (len (self .red_buffer )):
81
- self ._spi .write ([self .red_buffer [i ]])
82
- self ._gpio .set_high (self ._cs )
71
+ #TODO: write data when we get duplex transfer support
72
+
83
73
self .update ()
84
74
75
+ """
85
76
def image(self, image):
86
- """ Set buffer to value of Python Imaging Library image. The image should
77
+ ''' Set buffer to value of Python Imaging Library image. The image should
87
78
be in RGB mode and a size equal to the display size.
88
- """
79
+ '''
89
80
if image.mode != 'RGB':
90
81
raise ValueError('Image must be in mode RGB.')
91
82
imwidth, imheight = image.size
@@ -110,7 +101,9 @@ def image(self, image):
110
101
else:
111
102
#WHITE
112
103
self.bw_buffer[addr] |= (1 << (7 - (y%8)))
104
+ """
113
105
114
106
def clear_buffer (self ):
115
- self .bw_buffer = [0xFF ]* (width * height >> 3 )
116
- self .red_buffer = [0xFF ]* (width * height >> 3 )
107
+ #self.bw_buffer = [0xFF]* (width*height >> 3)
108
+ #self.red_buffer = [0xFF]* (width*height >> 3)
109
+ pass
0 commit comments