LoginSignup
0
0

WeAct STM32F411CEU6 Core Board で遊ぶ - Micropython編 追記あり

Last updated at Posted at 2021-11-25

情報少ないですし,自分の過去記事と重複する内容もありますが...

まずはファームを書き込み

Macでの見え方

image.png
image.png

Thonnyで操る

無題の画像.png

Board定義

pyboardに似ていますが,ピン名は本家STMに合わせてあるようです。以下が参考になります。

せっかくなので拙いサンプルを...

main.py
# https://github.com/WeActTC/MiniSTM32F4x1
# https://micropython-docs-ja.readthedocs.io/ja/latest/pyboard/quickref.html

# GPIO demo includes LED drive

from pyb import Pin
C13 = Pin('PC13',Pin.OUT_PP,Pin.PULL_NONE)
print(C13) # print C13 definition
C13.low()
print(C13.value())

# Alternate LED access

pyb.delay(1000)
pyb.LED(1).off()

for i in range(11):
    pyb.delay(100)
    pyb.LED(1).toggle()

# [KEY] Access for WeAct Board

from pyb import Switch
sw=Switch()
sw.callback(lambda:pyb.LED(1).toggle())

Switchはチャタリング処理もしているようです。

STM32 Bootloaderを起動する

import machine
machine.bootloader() 

Bootloaderを起動して,他のfirmwareを書くとき用。

SSD1306を使ってみる

image.png

64_string.py
# SSD1306 128x64

# driver
# https://github.com/SuperThunder/STM32F411CEU6-BlackPill-MicroPython-Examples

# text 16(w)*8(h) letters  

from machine import I2C
import time
import ssd1306

i2c=I2C(1,freq=400000) # hardware I2C1 SCL-PB6, SDA-PB7
oled=ssd1306.SSD1306_I2C(128,64,i2c)

def printText(s,l):
    # s:string l:line 0-7
    oled.fill_rect(0,l*8,128,8,0)
    oled.text(s, 0, l*8)
    oled.show()

printText("Hello World!", 0)

time.sleep(2)
printText("Loooooong text", 2)

time.sleep(1)
printText("0123456789012345678901234567890123456789", 4)
printText("0         1         2         3", 5)

time.sleep(2)
printText("Speed text", 2)
printText("", 4)
printText("", 5)

time.sleep(1)
for i in range(100):
    printText("  count "+str(i),4)

printText(" Done.",6)

参考URL

以上です!

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