forked from OnionIoT/smart-plant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oledHelper.py
51 lines (43 loc) · 1.4 KB
/
oledHelper.py
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
import os
from OmegaExpansion import oledExp
# initialze the OLED Expansion and set it up for use with the program
def init(dirName):
oledExp.setVerbosity(-1)
status = oledExp.driverInit()
if status != 0:
print 'ERROR initializing OLED Expansion'
## setup the display
# draw the plant image to the screen
imgFile = dirName + "/plant.oled"
if os.path.exists(imgFile):
status = oledExp.drawFromFile(imgFile)
## write the default text
# write the first word on the second line and the right side of the screen
oledExp.setTextColumns()
oledExp.setCursor(1,12)
oledExp.write('Moisture')
# write the second word on the third line and the right side of the screen
oledExp.setTextColumns()
oledExp.setCursor(2,12)
oledExp.write('Level:')
# write out the soil moisture value
def writeMeasurements(value):
# set the cursor the fifth line and the right side of the screen
oledExp.setTextColumns()
oledExp.setCursor(4,12)
# write out the text
oledExp.write( str(value) + "% " )
# clear the screen, write a message indicating no new measurements are coming in
def setDoneScreen():
# clear the screen
oledExp.clear()
# set the cursor the middle line
oledExp.setTextColumns()
oledExp.setCursor(2,0)
# write out the text
oledExp.write( " SMART PLANT OFFLINE" )
# set the cursor the middle line
oledExp.setTextColumns()
oledExp.setCursor(4,0)
# write out the text
oledExp.write( "Just a regular plant " )