from lib_tft24T import TFT24T
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

import spidev
from time import sleep

DC = 24
RST = 25
LED = 15
PEN = 26



TFT = TFT24T(spidev.SpiDev(), GPIO, landscape=False)



# Initialize display.
TFT.initLCD(DC, RST, LED)

TFT.initTOUCH(PEN)

draw = TFT.draw()

TFT.clear((255, 255, 255))
print "Draw on the screen with a pen/stylus"

while 1:
    while not TFT.penDown():
import spidev
from time import sleep

DC = 22
RST = 18
LED = 23
PEN = 24

print("First pass may show penprint not tracking well on the red lines.")
print(
    "Don't worry. Keep the stylus strictly on the red lines. Follow prompts below."
)
print
sleep(3)

TFT = TFT24T(spidev.SpiDev(), GPIO)

# Initialize display and touch.
TFT.initLCD(DC, RST, LED)
TFT.initTOUCH(PEN)

draw = TFT.draw()

TFT.clear((255, 255, 255))

draw.line((30, 1, 30, 318),
          fill="red")  # These lines are 30 pixels from each edge
draw.line((1, 30, 238, 30), fill="red")
draw.line((210, 1, 210, 318), fill="red")
draw.line((1, 290, 238, 290), fill="red")
font = ImageFont.truetype('FreeSans.ttf', 26)
Пример #3
0
from PIL import ImageFont

from lib_tft24T import TFT24T
import Adafruit_BBIO.GPIO as GPIO
#GPIO.setmode(GPIO.BCM)
#GPIO.setwarnings(False)

from Adafruit_BBIO.SPI import SPI
from time import sleep

DC = "P9_15"
RST = "P9_14"
LED = "P9_26"
PEN = "P9_16"

TFT = TFT24T(SPI, GPIO, landscape=False)

# Initialize display.
TFT.initLCD(DC, RST, LED)
TFT.initTOUCH(PEN)
draw = TFT.draw()

TFT.load_wallpaper("calc.png")  # Image of calculator !!!
TFT.display()

# Let's define all "hotspots" on the display. Remember display is showing an image of calculator.
# We examine the image carefully (an image utility on PC?)
# and determine the coordinate points for all corners of the "buttons".
# The array allows us easily to assign a digit or operator to each "button".
hotspots = [
    (195, 10, 222, 37, "exit"),  # even the window exit button gets a hotspot !
Пример #4
0
import spidev

import RPi.GPIO as GPIO
from PIL import ImageFont

from Class.RedisDatabase import RedisDatabase
from lib_tft24T import TFT24T

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

DC = 22
RST = 18
LED = 23

TFT = TFT24T(spidev.SpiDev(), GPIO, landscape=True)

TFT.initLCD(DC, RST, LED, ce=1)
draw = TFT.draw()
TFT.clear((255, 255, 255))
database = RedisDatabase()
database.test_connect()
#  # Image of calculator !!!
font = ImageFont.truetype('THSarabunNew.ttf', 22)
i = 1
while True:
    TFT.load_wallpaper("bg.jpg")
    text = u'ระดับน้ำ : 2 '

    text1 = u'อุณหภูมิ :'
    draw.text((10, 80), text1, fill=(32, 32, 32), font=font)