def initDisplay(): width = display.get_width() height = display.get_height() display_buffer = bytearray(width * height * 2) # 2-bytes per pixel (RGB565) display.init(display_buffer) display.set_backlight(1) clearDisplay()
def initDisplay(): width = display.get_width() height = display.get_height() display_buffer = bytearray(width * height * 2) # 2-bytes per pixel (RGB565) display.init(display_buffer) display.set_backlight(1) display.set_pen(0, 0, 0) # black display.clear() display.set_pen(100, 100, 100) # white
# This example shows how to read the voltage from a LiPo battery connected to a Raspberry Pi Pico via our Pico Lipo SHIM... # ...and uses this reading to calculate how much charge is left in the battery. # It then displays the info on the screen of Pico Display or Pico Explorer. # Remember to save this code as main.py on your Pico if you want it to run automatically! from machine import ADC, Pin import time # Uncomment one of these lines, depending on what display you have import picodisplay as display # import picodisplay2 as display # import picoexplorer as display # Set up and initialise display buf = bytearray(display.get_width() * display.get_height() * 2) display.init(buf) display.set_backlight( 0.8 ) # comment out this line if you have a Pico Explorer as it doesn't have a controllable backlight vsys = ADC(29) # reads the system input voltage charging = Pin( 24, Pin.IN) # reading GP24 tells us whether or not USB power is connected conversion_factor = 3 * 3.3 / 65535 full_battery = 4.2 # these are our reference voltages for a full/empty battery, in volts empty_battery = 2.8 # the values could vary by battery size/manufacturer so you might need to adjust them while True: # convert the raw ADC read into a voltage, and then a percentage voltage = vsys.read_u16() * conversion_factor
import time, random import picodisplay as display # based on initial code demo for the PiMoroni PicoDisplay for the RaspberyPiPico width = display.get_width() height = display.get_height() display_buffer = bytearray(width * height * 2) # 2-bytes per pixel (RGB565) display.init(display_buffer) display.set_backlight(1.0) class Ball: def __init__(self, x, y, r, dx, dy, pen): self.x = x self.y = y self.r = r self.dx = dx self.dy = dy self.pen = pen class Bat: def __init__(self, y): self.y = y # initialise shapes balls = []
import framebuf import picodisplay as display from struct import * # for 'unpack_from' import utime # for timer # This is the converted image result you should have on your Pico from Botw128 import * # Create an object from the image class of the converted image. The class name is always image name + Class botw128 = Botw128Class() # Init screen stuff screenWidth = display.get_width() screenHeight = display.get_height() display_buffer = bytearray(screenWidth * screenHeight * 2) display.init(display_buffer) display.set_backlight(1.0) display.clear() # Init timers startTime = utime.ticks_ms() stopTime = utime.ticks_ms() # Sets drawing color to given RGB values def SetPen(rgb): display.set_pen(rgb[0], rgb[1], rgb[2])
return None player.update() # move enemy every 5 steps if count % 5 == 0: enemy_row.move(step_size) if projectiles: for projectile in projectiles: projectile.move(step_size) count = count + 1 if count < 256 else 0 display.update() sleep(step_time) if __name__ == "__main__": global WIDTH, HEIGHT WIDTH = display.get_width() HEIGHT = display.get_height() display_buffer = bytearray(WIDTH * HEIGHT * 2) display.init(display_buffer) display.set_backlight(1.0) clear_display() # Game_loop while True: game_loop(0.2, 5)
def pixel(self, x, y): if (x >= 0) and (x <= display.get_width()): if (y >= 0) and (y <= display.get_height()): display.pixel(x, y)
# rasberry pico with pimoroni display pack # https://shop.pimoroni.com/products/pico-display-pack # micropython import picodisplay as display import utime import math # Initialise display with a bytearray display buffer buf = bytearray(display.get_width() * display.get_height() * 2) display.init(buf) display.set_backlight(0.5) class Turtle: """A simple example class""" x = 67 y = 120 heading = 0 def __init__(self): self.x = 67 self.y = 120 self.heading = 0 def clear(self): display.set_pen(0, 0, 0) display.clear() display.update() def setPen(self, color):
import time import picodisplay from Blinky import LCD from Blinky import Blink from Blinky import Buttons from Blinky import FileManage from copy import copy # Initialise Picodisplay with a bytearray display buffer buf = bytearray(picodisplay.get_width() * picodisplay.get_height() * 2) picodisplay.init(buf) picodisplay.set_backlight(1) #set colors blue = (0, 0, 255) orange = (255, 102, 0) gray = (125, 128, 128) white = (200, 255, 255) red = (255, 0, 0) #set variables buttons = (picodisplay.BUTTON_A, picodisplay.BUTTON_B, picodisplay.BUTTON_X, picodisplay.BUTTON_Y) led_orange = (picodisplay.set_led, orange) led_blue = (picodisplay.set_led, blue) led_gray = (picodisplay.set_led, gray) led_white = (picodisplay.set_led, white) led_red = (picodisplay.set_led, red) #save stuff last_save = time.ticks_ms()
def setup_screen(): # Set up the display screen buf = bytearray(display.get_width() * display.get_height() * 2) display.init(buf) display.set_backlight(1.0)
import random import picodisplay as display import time, _thread, machine from machine import Timer tim = Timer() width = display.get_width() height = display.get_height() + 10 #hack display_buffer = bytearray(width * height * 2) # 2-bytes per pixel (RGB565) display.init(display_buffer) display.set_backlight(1.0) display.set_pen(255, 255, 255) display.clear() radius = 2 s = 60000 def tick(timer): global display display.update() tim.init(period=200, mode=Timer.PERIODIC, callback=tick) def task(s, radius, pen):