0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

TTGO T-Display で MicroPython を使ってみた

Last updated at Posted at 2021-10-22

目的

  • MicroPythonを自分の TTGO T-Display で使ってみる。
  • T-Display の TFT で何か表示できるようにする。

thanks to

https://kreier.github.io/t-display/
https://github.com/kreier/t-display
https://qiita.com/ganessa/items/8938e8e0ac6118ace9b1
https://blog.goediy.com/?p=905

setup

  • install python3
  • install esptool.py
$ pip install esptool
  • download firmware

  • burn it
$ esptool.py --port /dev/cu.SLAB_USBtoUART flash_id
$ esptool.py --port /dev/cu.SLAB_USBtoUART erase_flash
$ esptool.py --chip esp32 --port /dev/cu.SLAB_USBtoUART --baud 460800 write_flash -z 0x1000 firmware.bin

demo run

  • execute thonny.app
  • open device MicroPython (ESP32)
  • open script ttgo_hello.py or hello_world.py
  • run the script.

memo

  • another method for uploading script:
$ pip install adafruit-ampy
$ ampy -p /dev/cu.SLAB_USBtoUART put main.py 

追記

こちらのページの情報でもセットアップできた。

この方がフォントが私好みだった。main.pyはほんの少し書き直させてもらった。

main.py
import machine, display

tft = display.TFT()

tft.init(tft.ST7789,bgr=False,rot=tft.LANDSCAPE, miso=17,backl_pin=4,backl_on=1, mosi=19, clk=18, cs=5, dc=16)

tft.setwin(40,52,320,240)

for i in range(0,241):
    color=0xFFFFFF-tft.hsb2rgb(i/241*360, 1, 1)
    tft.line(i,0,i,135,color)
    tft.set_fg(0x000000)
    tft.ellipse(120,67,120,67)
    tft.line(0,0,240,135)
#    tft.font(tft.FONT_Default, rotate=0)
    tft.font(tft.FONT_DejaVu18, rotate=0)
#    tft.font(tft.FONT_DejaVu24, rotate=0)
#    tft.font(tft.FONT_Ubuntu, rotate=0)
#    tft.font(tft.FONT_Tooney, rotate=0)
    text="ST7789 with micropython!"
    tft.text(120-int(tft.textWidth(text)/2),67-int(tft.fontSize()[1]/2),text,0xFFFFFF)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?