def run(): io = mcpnew.MCP23017(i2c, address=0x20) # 32 for a in pinz: io.setup(a, mcpnew.IN) io.pullup(a, True) display.erase() display.set_pos(0, 0) display.width = 240 display.height = 320 display.fill_rectangle(0, 0, 240, 320, color565n(0, 0, 30)) tilemngr = tilemanager(display) tilemngr.generatelevel() tilemngr.renderlevel() while io.input(BUTTON_UP): if not io.input(PIN_UP): tilemngr.scroll(1) if not io.input(BUTTON_DOWN): display._write(0x21) #inverts display colors if not io.input(BUTTON_LEFT): display._write(0x20) #normal display colors
def run(): io = mcpnew.MCP23017(i2c, address=0x20) # 32 for a in pinz: io.setup(a, mcpnew.IN) io.pullup(a, True) display.erase() display.set_pos(0, 0) display.width = 240 display.height = 320 display.fill_rectangle(0, 0, 240, 320, color565n(0, 0, 30)) omraad = area(display) snek = snake(display, omraad) snek.initsnake() while True: if not io.input(PIN_LEFT): snek.changedirection(DIR_LEFT) if not io.input(PIN_RIGHT): snek.changedirection(DIR_RIGHT) if not io.input(PIN_DOWN): snek.changedirection(DIR_DOWN) if not io.input(PIN_UP): snek.changedirection(DIR_UP) #if not io.input(BUTTON_UP): # break snek.movesnake()
BUTTON_LEFT = 5 BUTTON_RIGHT = 6 BUTTON_UP = 7 BUTTON_DOWN = 4 PIN_LEFT = 9 PIN_RIGHT = 10 PIN_UP = 8 PIN_DOWN = 11 pinz = [ PIN_LEFT, PIN_RIGHT, PIN_UP, PIN_DOWN, BUTTON_LEFT, BUTTON_RIGHT, BUTTON_UP, BUTTON_DOWN ] io = mcpnew.MCP23017(i2c, address=0x20) class area(object): def __init__(self, disp): self.display = disp self.blocksize = 14 self.asizex = 10 self.asizey = 20 self.gg = False self.ablocksflipped = 0
BUTTON_LEFT = 5 BUTTON_RIGHT = 6 BUTTON_UP = 7 BUTTON_DOWN = 4 PIN_LEFT = 9 #gucci PIN_RIGHT = 10 #gucci PIN_UP = 8 #gucci PIN_DOWN = 11 #gucci pinz = [ PIN_LEFT, PIN_RIGHT, PIN_UP, PIN_DOWN, BUTTON_LEFT, BUTTON_RIGHT, BUTTON_UP, BUTTON_DOWN ] io = mcpnew.MCP23017(i2c, address=0x20) #, gpioScl=I2C_SCL, gpioSda=I2C_SDA) # 32 def run(): for a in pinz: io.setup(a, mcpnew.IN) io.pullup(a, True) bme = bme280_int.BME280(i2c=i2c) display.erase() display.set_pos(0, 0) display.width = 240 display.height = 320 display.fill_rectangle(0, 0, 240, 320, color565n(0, 0, 70))
import utime from the_pad.ili934xhax import ILI9341, color565, color565n import the_pad.mcpnew as mcpnew from machine import ADC, Pin, SPI, I2C from math import sqrt, tan, cos, sin, floor, pi import array as arr import ustruct as struct import framebuf spi = SPI(2, baudrate=40000000, miso=Pin(19), mosi=Pin(23), sck=Pin(18)) display = ILI9341(spi, cs=Pin(0), dc=Pin(15), rst=Pin(5)) I2C_SCL = 27 I2C_SDA = 32 i2c = I2C(scl=Pin(I2C_SCL), sda=Pin(I2C_SDA)) BUTTON_LEFT = 5 BUTTON_RIGHT = 6 BUTTON_UP = 7 BUTTON_DOWN = 4 PIN_LEFT = 9 PIN_RIGHT = 10 PIN_UP = 8 PIN_DOWN = 11 pinz = [ PIN_LEFT, PIN_RIGHT, PIN_UP, PIN_DOWN, BUTTON_LEFT, BUTTON_RIGHT, BUTTON_UP, BUTTON_DOWN ] DIR_LEFT = 3 DIR_RIGHT = 4 DIR_UP = 5 DIR_DOWN = 6 directions = [(-1, 0), (1, 0), (0, -1), (0, 1)]