latest
掌控板文档
mPython X 使用说明
软件安装
更新日志
0.6.1
0.6.0
0.5.2
0.5.1
0.5.0
0.3.5
0.3.4
0.3.3
0.3.2
0.3.1
0.3.0
0.2.2
0.2.1
0.2.0
0.1.2
0.1.1
0.1.0
接入硬件
图形编辑区
保存
模块提示
帮助文档
切换图形/代码模式
改变图形区/代码区大小
代码编辑区
运行/刷入
运行/刷入
代码查错
读出上一次刷入的代码
恢复固件
图形块 API
显示
oled.DispChar()
oled.show()
oled.fill()
oled.invert()
oled.pixel()
oled.circle()
oled.fill_circle()
oled.triangle()
oled.fill_triangle()
oled.hline()
oled.vline()
oled.line()
oled.rect()
oled.fill_rect()
oled.RoundRect()
oled.Bitmap()
UI.ProgressBar()
UI.stripBar()
按键
button_[a,b].value()
touchPad_[P,Y,T,H,O,N].read()
声音
sound.read()
光线
light.read()
加速度
accelerometer.get_x()
accelerometer.get_y()
accelerometer.get_z()
板载RGB
rgb[n] = (r, g, b)
rgb.write()
rgb.fill( (r, g, b) )
外部RGB
class NeoPixel(pin, n, bpp=3, timing=0)
NeoPixel.write()
NeoPixel.fill( (r, g, b) )
bme280
bme280.temperature()
bme280.pressure()
bme280.humidity()
模拟时钟
class UI.Clock(x, y, radius)
UI.settime()
UI.drawClock()
UI.clear()
wifi
示例
引脚
pin.read_digital()
pin.write_digital()
pin.read_analog()
pin.write_analog()
无线广播
radio.on()
radio.off()
radio.config(channel)
radio.receive()
radio.receive_bytes()
radio.send()
radio.send_bytes()
音乐
music.pitch()
range()
music.play()
music.set_tempo()
music.get_tempo()
music.reset()
music.stop()
音频
audio.player_init()
audio.play(url)
audio.set_volume(vol)
audio.stop()
audio.pause()
audio.resume()
audio.player_status()
audio.player_deinit()
事件
button_[a,b].irq(handler=None, trigger=(Pin.IRQ_FALLING | Pin.IRQ_RISING), priority=1, wake=None)
class machine.Timer(id, …)
Timer.init(*, mode=Timer.PERIODIC, period=-1, callback=None)
Timer.deinit()
Timer.value()
Pin.irq(handler=None, trigger=(Pin.IRQ_FALLING | Pin.IRQ_RISING))
_thread.start_new_thread(function, args [, kwargs])
循环
break
continue
逻辑
and
or
not
None
return
try…except…finally
type(object)
eval(expression[, globals[, locals]])
数学
math.sqrt(x)
math.fabs(x)
math.log(x)
math.log10(x)
math.exp(x)
math.pow(x, y[, z])
math.sin(x)
math.cos(x)
math.tan(x)
math.radians(x)
math.asin(x)
math.acos(x)
math.atan(x)
round(x [, n])
math.ceil(x)
math.floor(x)
random.randint(a, b)
random.randrange(start, stop[, step])
random.random()
‘~’
‘&’
‘|’
‘^’
‘<<’
‘>>’
文本
%.2f
{:.2}
str.isdigit()
str.isalpha()
str.find(str, beg=0, end=len(string))
str.rfind(str, beg=0 end=len(string))
str.lower()
str.upper()
str.strip([chars])
bytes([source[, encoding[, errors]]])
bytes.decode(encoding=”utf-8”, errors=”strict”)
ujson.dumps(obj)
ujson.loads(str)
列表
list.append(obj)
list.extend(seq)
list.clear()
list.insert(index, obj)
list.pop([index=-1])
str.split(str=””, num=string.count(str))
str.join(seq)
元组
tuple(seq)
字典
示例
集合
set.intersection_update(set1, set2 … etc)
set.update(set)
set.difference_update(set)
set.issubset(set)
set.issuperset(set)
set.pop()
文件
open(file, mode=’r’)
file.close()
file.read([size])
file.write(str)
网络
usocket.socket(af=AF_INET, type=SOCK_STREAM, proto=IPPROTO_TCP)
usocket.getaddrinfo(host, port)
socket.close()
socket.bind(address)
socket.listen([backlog])
socket.accept()
socket.connect(address)
socket.send(bytes)
socket.sendall(bytes)
socket.recv(bufsize)
socket.sendto(bytes, address)
socket.recvfrom(bufsize)
socket.setsockopt(level, optname, value)
socket.settimeout(value)
socket.setblocking(flag)
socket.read([size])
socket.readinto(buf[, nbytes])
socket.readline()
socket.write(buf)
urequests.get(url, data=None, json=None, headers={}, params=None)
串口
class machine.UART(id, baudrate, bits, parity, stop, tx, rx, rts, cts, timeout)
UART.init(baudrate, bits, parity, stop, tx, rx, rts, cts, timeout)
UART.any()
UART.read([nbytes])
UART.readinto(buf[, nbytes])
UART.readline()
UART.write(buf)
bluebit 模块
class bluebit.SHT20(i2c=i2c)
SHT20.temperature()
SHT20.humidity()
class bluebit.Color(i2c=i2c)
Color.getRGB()
Color.getHSV()
class bluebit.AmbientLight(i2c=i2c)
AmbientLight.getLight()
class bluebit.Ultrasonic(i2c=i2c)
Ultrasonic.distance()
class bluebit.SEGdisplay(i2c=i2c)
SEGdisplay.numbers(x)
SEGdisplay.Clear()
class Matrix(i2c=i2c)
Matrix.blink_rate(rate=None)
Matrix.brightness(brightness)
Matrix.fill(color)
Matrix.bitmap(bitmap)
Matrix.show()
class bluebit.LCD1602(i2c=i2c)
LCD1602.LEFT_TO_RIGHT
LCD1602.RIGHT_TO_LEFT
LCD1602.Init()
LCD1602.Print(str)
LCD1602.Clear()
LCD1602.setCursor(col, row)
LCD1602.Cursor(show)
LCD1602.Blink(blink)
LCD1602.display(enable)
LCD1602.move_left()
LCD1602.move_right()
LCD1602.text_direction
class bluebit.MIDI(tx)
MIDI.volume
MIDI.instrument
MIDI.note(note, on_off)
class bluebit.MP3(tx)
MP3.play_song(num)
MP3.play()
MP3.playDir(dir, songNo)
MP3.playNext()
MP3.playPrev()
MP3.pause()
MP3.stop()
MP3.loop(songNo)
MP3.loopDir(dir)
MP3.singleLoop(onOff)
MP3.volume
MP3.volumeInc()
MP3.volumeDec()
MP3.resetDevice()
class bluebit.OLEDBit(rx, tx)
OLEDBit.font_5x7
OLEDBit.font_song16
OLEDBit.font_song24
OLEDBit.font_consol32
OLEDBit.Print(str, x, y, font)
OLEDBit.clear(x0=0, y0=0, x1=127, y1=63)
OLEDBit.show()
OLEDBit.Bitmap(x, y, bitmap, w, h, c)
class bluebit.IRRecv(rx, uart_id=1)
IRRecv.recv()
class bluebit.IRTrans(tx, uart_id=2)
IRTrans.transmit(byte)
parrot.MOTOR_1
parrot.MOTOR_2
parrot.set_speed(motor_no, speed)
parrot.get_speed(motor_no)
parrot.led_on(no, brightness=50)
parrot.led_off(no)
Yeelight 智能灯
示例
MQTT
class MQTTClient(client_id, server, port=0, user=None, password=None, keepalive=0, ssl=False, ssl_params={})
MQTTClient.set_callback(f)
MQTTClient.set_last_will(topic, msg, retain=False, qos=0)
MQTTClient.connect(clean_session=True)
MQTTClient.disconnect()
MQTTClient.ping()
MQTTClient.publish(topic, msg, retain=False, qos=0)
MQTTClient.subscribe(topic, qos=0)
MQTTClient.wait_msg()
MQTTClient.check_msg()
自定义图形块
项目
mPythonX 帮助文档
Docs
»
图形块 API
»
元组
Edit on GitHub
元组
¶
Python 的元组与列表类似,不同之处在于元组的元素不能修改
tuple(seq)
¶
描述:
将列表转换为元组
示例
¶
点击下载图形化示例
Read the Docs
v: latest
Versions
latest
Downloads
html
epub
On Read the Docs
Project Home
Builds
Free document hosting provided by
Read the Docs
.