Last active
March 1, 2019 16:55
-
-
Save ril3y/bc99ae8bbf600fa2c83e17a7678fb966 to your computer and use it in GitHub Desktop.
Notes on using the m5stack with micropython
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import machine | |
import display | |
import network | |
wifi = network.WLAN(network.STA_IF) | |
wifi.active(True) | |
tft = display.TFT() | |
tft.init(tft.M5STACK, width=320, height=320, rst_pin=33, backl_pin=32, miso=19, mosi=23, clk=18, cs=14, dc=27, bgr=True, backl_on=1) | |
tft.clear() | |
HEIGHT, WIDTH = tft.winsize() #Get the size of the lcd. | |
def network_report(): | |
networks = wifi.scan() | |
if len(networks) != 0: | |
for n in networks: | |
print("Network Name: {}".format(n[0)) | |
def create_popup(): | |
pass | |
tft.text(0,0,"MicroPython") | |
def push_button_a(btn): | |
print("Button A pushed") | |
def push_button_b(btn): | |
print("Button B pushed") | |
def push_button_c(btn): | |
print("Button C pushed") | |
#define buttons | |
btna = machine.Pin(39, mode=machine.Pin.IN, handler=push_button_a, trigger=machine.Pin.IRQ_FALLING) | |
btnb = machine.Pin(38, mode=machine.Pin.IN, handler=push_button_b, trigger=machine.Pin.IRQ_FALLING) | |
btnc = machine.Pin(37, mode=machine.Pin.IN, handler=push_button_c, trigger=machine.Pin.IRQ_FALLING) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment