Add the 4.37inch e-Paper (G) Python program
This commit is contained in:
parent
023a5759e3
commit
77c499d749
11 changed files with 348 additions and 83 deletions
|
@ -18,18 +18,13 @@ logging.basicConfig(level=logging.DEBUG)
|
|||
try:
|
||||
logging.info("epd3in0g Demo")
|
||||
|
||||
BLACK = 0x00
|
||||
WHITE = 0x55
|
||||
YELLOW = 0xAA
|
||||
RED = 0xFF
|
||||
epd = epd3in0g.EPD()
|
||||
logging.info("init and Clear")
|
||||
epd.init()
|
||||
epd.Clear(WHITE)
|
||||
epd.Clear()
|
||||
font24 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24)
|
||||
font18 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 18)
|
||||
font30 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 40)
|
||||
|
||||
font40 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 40)
|
||||
|
||||
# Drawing on the image
|
||||
epd.init()
|
||||
|
@ -38,9 +33,9 @@ try:
|
|||
draw = ImageDraw.Draw(Himage)
|
||||
draw.text((5, 0), 'hello world', font = font18, fill = epd.RED)
|
||||
draw.text((5, 20), '3inch e-Paper', font = font24, fill = epd.YELLOW)
|
||||
draw.text((5, 45), u'微雪电子', font = font30, fill = epd.BLACK)
|
||||
draw.text((5, 85), u'微雪电子', font = font30, fill = epd.YELLOW)
|
||||
draw.text((5, 125), u'微雪电子', font = font30, fill = epd.RED)
|
||||
draw.text((5, 45), u'微雪电子', font = font40, fill = epd.BLACK)
|
||||
draw.text((5, 85), u'微雪电子', font = font40, fill = epd.YELLOW)
|
||||
draw.text((5, 125), u'微雪电子', font = font40, fill = epd.RED)
|
||||
draw.line((5, 170, 80, 245), fill = epd.RED)
|
||||
draw.line((80, 170, 5, 245), fill = epd.YELLOW)
|
||||
draw.rectangle((5, 170, 80, 245), outline = epd.BLACK)
|
||||
|
@ -50,17 +45,16 @@ try:
|
|||
epd.display(epd.getbuffer(Himage))
|
||||
time.sleep(3)
|
||||
|
||||
|
||||
# Switch width and height for landscape display
|
||||
epd.init()
|
||||
logging.info("1.Drawing on the image...")
|
||||
Himage = Image.new('RGB', (epd.height, epd.width), 0xffffff)
|
||||
Himage = Image.new('RGB', (epd.height, epd.width), epd.WHITE)
|
||||
draw = ImageDraw.Draw(Himage)
|
||||
draw.text((5, 0), 'hello world', font = font18, fill = epd.RED)
|
||||
draw.text((5, 20), '3inch e-Paper', font = font24, fill = epd.YELLOW)
|
||||
draw.text((5, 45), u'微雪电子', font = font30, fill = epd.BLACK)
|
||||
draw.text((5, 85), u'微雪电子', font = font30, fill = epd.YELLOW)
|
||||
draw.text((5, 125), u'微雪电子', font = font30, fill = epd.RED)
|
||||
draw.text((5, 45), u'微雪电子', font = font40, fill = epd.BLACK)
|
||||
draw.text((5, 85), u'微雪电子', font = font40, fill = epd.YELLOW)
|
||||
draw.text((5, 125), u'微雪电子', font = font40, fill = epd.RED)
|
||||
draw.line((205, 5, 295, 65), fill = epd.RED)
|
||||
draw.line((295, 5, 205, 65), fill = epd.YELLOW)
|
||||
draw.rectangle((205, 5, 295, 65), outline = epd.BLACK)
|
||||
|
@ -91,7 +85,7 @@ try:
|
|||
|
||||
epd.init()
|
||||
logging.info("Clear...")
|
||||
epd.Clear(WHITE)
|
||||
epd.Clear()
|
||||
|
||||
logging.info("Goto Sleep...")
|
||||
epd.sleep()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue