本文整理汇总了Python中machine.Pin.low方法的典型用法代码示例。如果您正苦于以下问题:Python Pin.low方法的具体用法?Python Pin.low怎么用?Python Pin.low使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类machine.Pin
的用法示例。
在下文中一共展示了Pin.low方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import low [as 别名]
def main(use_stream=False):
s = socket.socket()
# Binding to all interfaces - server will be accessible to other hosts!
ai = socket.getaddrinfo("0.0.0.0", 8080)
print("Bind address info:", ai)
addr = ai[0][-1]
#prepping LED pin
p = Pin(2,Pin.OUT)
# p.high()
# time.sleep(1)
# p.low()
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(addr)
s.listen(5)
print("Listening, connect your browser to http://<this_host>:8080/")
counter = 0
while True:
res = s.accept()
client_s = res[0]
client_addr = res[1]
print("Client address:", client_addr)
print("Client socket:", client_s)
print("Request:")
if use_stream:
# MicroPython socket objects support stream (aka file) interface
# directly.
#print(client_s.read(4096))
val = client_s.read(4096)
print(val)
client_s.write(CONTENT % counter)
else:
#print(client_s.recv(4096))
val = client_s.recv(4096)
print(val)
client_s.send(CONTENT % counter)
if "GET /toggle" in val:
print("Toggling!")
p.high()
time.sleep(1)
p.low()
machine.reset()
client_s.close()
counter += 1
print()
示例2: __init__
# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import low [as 别名]
#.........这里部分代码省略.........
# Power control
self.write_cmd(0xC1)
# SAP[2:0];BT[3:0]
self.write_data(bytearray([0x10]))
# VCM control
self.write_cmd(0xC5)
self.write_data(bytearray([0x3F, 0x3C]))
# VCM control2
self.write_cmd(0xC7)
self.write_data(bytearray([0xB7]))
# Memory Access Control
self.write_cmd(0x36)
self.write_data(bytearray([0x08]))
self.write_cmd(0x3A)
self.write_data(bytearray([0x55]))
self.write_cmd(0xB1)
self.write_data(bytearray([0x00, 0x1B]))
# Display Function Control
self.write_cmd(0xB6)
self.write_data(bytearray([0x0A, 0xA2]))
# 3Gamma Function Disable
self.write_cmd(0xF2)
self.write_data(bytearray([0x00]))
# Gamma curve selected
self.write_cmd(0x26)
self.write_data(bytearray([0x01]))
# Set Gamma
self.write_cmd(0xE0)
self.write_data(bytearray([0x0F, 0x2A, 0x28, 0x08, 0x0E, 0x08, 0x54, 0XA9, 0x43, 0x0A, 0x0F, 0x00, 0x00, 0x00, 0x00]))
# Set Gamma
self.write_cmd(0XE1)
self.write_data(bytearray([0x00, 0x15, 0x17, 0x07, 0x11, 0x06, 0x2B, 0x56, 0x3C, 0x05, 0x10, 0x0F, 0x3F, 0x3F, 0x0F]))
# Exit Sleep
self.write_cmd(0x11)
time.sleep_ms(120)
# Display on
self.write_cmd(0x29)
time.sleep_ms(500)
self.fill(0)
def show(self):
# set col
self.write_cmd(0x2A)
self.write_data(bytearray([0x00, 0x00]))
self.write_data(bytearray([0x00, 0xef]))
# set page
self.write_cmd(0x2B)
self.write_data(bytearray([0x00, 0x00]))
self.write_data(bytearray([0x01, 0x3f]))
self.write_cmd(0x2c);
num_of_pixels = self.height * self.width
for row in range(0, self.pages):
for pixel_pos in range(0, 8):
for col in range(0, self.width):
compressed_pixel = self.buffer[row * 240 + col]
if ((compressed_pixel >> pixel_pos) & 0x1) == 0:
self.write_data(bytearray([0x00, 0x00]))
else:
self.write_data(bytearray([0xFF, 0xFF]))
def fill(self, col):
self.framebuf.fill(col)
def pixel(self, x, y, col):
self.framebuf.pixel(x, y, col)
def scroll(self, dx, dy):
self.framebuf.scroll(dx, dy)
def text(self, string, x, y, col=1):
self.framebuf.text(string, x, y, col)
def write_cmd(self, cmd):
self.dc.low()
self.cs.low()
self.spi.write(bytearray([cmd]))
self.cs.high()
def write_data(self, buf):
self.dc.high()
self.cs.low()
self.spi.write(buf)
self.cs.high()
示例3: Pin
# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import low [as 别名]
from machine import Pin, SPI
import time
import ubinascii
vref = 3.3
cs = Pin(15, Pin.OUT)
cs.high()
hspi = SPI(1, baudrate=1600000, polarity=0, phase=0)
value = bytearray(2)
while True:
data = bytearray(2)
wget = b'\xA0\x00'
cs.low()
hspi.write(b'\x01')
hspi.write(b'\xA0')
data = hspi.read(1)
# data = hspi.write_readinto(wget, data)
cs.high()
print(str(int(ubinascii.hexlify(data & b'\x0fff'))*vref/4096))
time.sleep(1)
# data = data*vref/4096
# time.sleep(1)
# print(str(data & b'\x0fff'))
示例4: close
# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import low [as 别名]
p.high()
response = RestServer.Response()
response.code(200)
response.contentType("text/plain")
response.data("Aberto")
return response.build()
def close():
p.low()
response = RestServer.Response()
response.code(200)
response.contentType("text/plain")
response.data("Fechado")
return response.build()
paths = {"/open":open,
"/close":close}
p.high()
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect('Vilar', 'defarias')
while not wlan.isconnected():
pass
p.low()
server = RestServer.Server(8000)
server.auth("YTpi")
server.start(paths)
示例5: led_on
# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import low [as 别名]
def led_on():
led = Pin(PIN_LED, Pin.OUT)
led.low()