kopia lustrzana https://github.com/pimoroni/pimoroni-pico
Add Python linting
rodzic
d69b10c4bc
commit
47be7e5f31
|
|
@ -0,0 +1,35 @@
|
|||
name: Python
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: ${{matrix.name}}
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-20.04
|
||||
name: Linux
|
||||
cache-key: linux
|
||||
apt-packages: python3 python3-pip
|
||||
python-packages: flake8
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
# Linux deps
|
||||
- name: Install deps
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
sudo apt update && sudo apt install ${{matrix.apt-packages}}
|
||||
|
||||
- name: Install Python Deps
|
||||
run: python3 -m pip install ${{matrix.python-packages}}
|
||||
|
||||
- name: Lint
|
||||
shell: bash
|
||||
run: |
|
||||
python3 -m flake8 --ignore E501 micropython/examples
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import time, random, math
|
||||
import time
|
||||
import math
|
||||
from breakout_roundlcd import BreakoutRoundLCD
|
||||
|
||||
width = BreakoutRoundLCD.WIDTH
|
||||
|
|
@ -11,6 +12,7 @@ display.set_backlight(1.0)
|
|||
|
||||
RADIUS = width // 2
|
||||
|
||||
|
||||
def hsv_to_rgb(h, s, v):
|
||||
if s == 0.0:
|
||||
return v, v, v
|
||||
|
|
@ -33,7 +35,9 @@ def hsv_to_rgb(h, s, v):
|
|||
if i == 5:
|
||||
return v, p, q
|
||||
|
||||
|
||||
t = 0
|
||||
|
||||
while True:
|
||||
display.set_pen(0, 0, 0)
|
||||
display.clear()
|
||||
|
|
@ -57,9 +61,9 @@ while True:
|
|||
x = RADIUS + int(distance * math.cos(angle))
|
||||
y = RADIUS + int(distance * math.sin(angle))
|
||||
|
||||
l = ((math.sin(t + angle) + 1) / 2.0) * 10
|
||||
radius = ((math.sin(t + angle) + 1) / 2.0) * 10
|
||||
display.set_pen(r, g, b)
|
||||
display.circle(int(x), int(y), int(l))
|
||||
display.circle(int(x), int(y), int(radius))
|
||||
|
||||
prev_x = x
|
||||
prev_y = y
|
||||
|
|
|
|||
|
|
@ -8,12 +8,14 @@ buf = bytearray(display.get_width() * display.get_height() * 2)
|
|||
display.init(buf)
|
||||
display.set_backlight(0.5)
|
||||
|
||||
|
||||
# sets up a handy function we can call to clear the screen
|
||||
def clear():
|
||||
display.set_pen(0, 0, 0)
|
||||
display.clear()
|
||||
display.update()
|
||||
|
||||
|
||||
while True:
|
||||
if display.is_pressed(display.BUTTON_A): # if a button press is detected then...
|
||||
clear() # clear to black
|
||||
|
|
@ -48,4 +50,3 @@ while True:
|
|||
display.text("Press any button!", 10, 10, 240, 4)
|
||||
display.update()
|
||||
utime.sleep(0.1) # this number is how frequently the Pico checks for button presses
|
||||
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import time, random
|
||||
import time
|
||||
import random
|
||||
import picodisplay as display
|
||||
|
||||
width = display.get_width()
|
||||
|
|
@ -19,6 +20,7 @@ class Ball:
|
|||
self.dy = dy
|
||||
self.pen = pen
|
||||
|
||||
|
||||
# initialise shapes
|
||||
balls = []
|
||||
for i in range(0, 100):
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
## This example borrows a CircuitPython hsv_to_rgb function to cycle through some rainbows on Pico Display's screen and RGB LED . If you're into rainbows, HSV (Hue, Saturation, Value) is very useful!
|
||||
# This example borrows a CircuitPython hsv_to_rgb function to cycle through some rainbows on Pico Display's screen and RGB LED . If you're into rainbows, HSV (Hue, Saturation, Value) is very useful!
|
||||
|
||||
import utime
|
||||
import picodisplay as display
|
||||
|
|
@ -8,6 +8,7 @@ buf = bytearray(display.get_width() * display.get_height() * 2)
|
|||
display.init(buf)
|
||||
display.set_backlight(0.8)
|
||||
|
||||
|
||||
# From CPython Lib/colorsys.py
|
||||
def hsv_to_rgb(h, s, v):
|
||||
if s == 0.0:
|
||||
|
|
@ -31,6 +32,7 @@ def hsv_to_rgb(h, s, v):
|
|||
if i == 5:
|
||||
return v, p, q
|
||||
|
||||
|
||||
h = 0
|
||||
|
||||
while True:
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
# I just changed the import statement to import picoexplorer instaead of picodisplay
|
||||
|
||||
|
||||
import time, random
|
||||
import time
|
||||
import random
|
||||
import picoexplorer as display
|
||||
|
||||
width = display.get_width()
|
||||
|
|
@ -25,6 +26,7 @@ class Ball:
|
|||
self.dy = dy
|
||||
self.pen = pen
|
||||
|
||||
|
||||
# initialise shapes
|
||||
balls = []
|
||||
for i in range(0, 100):
|
||||
|
|
@ -63,4 +65,5 @@ while True:
|
|||
display.circle(int(ball.x), int(ball.y), int(ball.r))
|
||||
|
||||
display.update()
|
||||
|
||||
time.sleep(0.01)
|
||||
|
|
|
|||
|
|
@ -7,12 +7,14 @@ import utime
|
|||
buf = bytearray(display.get_width() * display.get_height() * 2)
|
||||
display.init(buf)
|
||||
|
||||
|
||||
# sets up a handy function we can call to clear the screen
|
||||
def clear():
|
||||
display.set_pen(0, 0, 0)
|
||||
display.clear()
|
||||
display.update()
|
||||
|
||||
|
||||
while True:
|
||||
if display.is_pressed(display.BUTTON_A): # if a button press is detected then...
|
||||
clear() # clear to black
|
||||
|
|
@ -47,4 +49,3 @@ while True:
|
|||
display.text("Press any button!", 10, 10, 240, 4)
|
||||
display.update()
|
||||
utime.sleep(0.1) # this number is how frequently the Pico checks for button presses
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import time, random
|
||||
import time
|
||||
import picoexplorer as explorer
|
||||
|
||||
width = explorer.get_width()
|
||||
|
|
|
|||
|
|
@ -108,17 +108,21 @@ tones = {
|
|||
# put the notes for your song in here!
|
||||
song = ["F6", "F6", "E6", "F6", "F5", "P", "F5", "P", "C6", "AS5", "A5", "C6", "F6", "P", "F6", "P", "G6", "FS6", "G6", "G5", "P", "G5", "P", "G6", "F6", "E6", "D6", "C6", "P", "C6", "P", "D6", "E6", "F6", "E6", "D6", "C6", "D6", "C6", "AS5", "A5", "AS5", "A5", "G5", "F5", "G5", "F5", "E5", "D5", "C5", "D5", "E5", "F5", "G5", "AS5", "A5", "G5", "A5", "F5", "P", "F5"]
|
||||
|
||||
|
||||
def clear(): # this function clears Pico Explorer's screen to black
|
||||
explorer.set_pen(0, 0, 0)
|
||||
explorer.clear()
|
||||
explorer.update()
|
||||
|
||||
|
||||
def playtone(frequency): # this function tells your program how to make noise
|
||||
explorer.set_tone(frequency)
|
||||
|
||||
|
||||
def bequiet(): # this function tells your program how not to make noise
|
||||
explorer.set_tone(-1)
|
||||
|
||||
|
||||
def playsong(song): # this function plays your song
|
||||
a = 0 # this variable keeps track of the visualiser bars
|
||||
for i in range(len(song)):
|
||||
|
|
@ -136,6 +140,7 @@ def playsong(song): # this function plays your song
|
|||
utime.sleep(0.15) # change this number if you want to alter how long the notes play for
|
||||
bequiet()
|
||||
|
||||
|
||||
clear()
|
||||
playsong(song)
|
||||
clear()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
## This example borrows a CircuitPython hsv_to_rgb function to cycle through some rainbows on Pico Explorer's screen and RGB LED . If you're into rainbows, HSV (Hue, Saturation, Value) is very useful!
|
||||
# This example borrows a CircuitPython hsv_to_rgb function to cycle through some rainbows on Pico Explorer's screen and RGB LED . If you're into rainbows, HSV (Hue, Saturation, Value) is very useful!
|
||||
|
||||
import utime
|
||||
import picoexplorer as display
|
||||
|
|
@ -7,6 +7,7 @@ import picoexplorer as display
|
|||
buf = bytearray(display.get_width() * display.get_height() * 2)
|
||||
display.init(buf)
|
||||
|
||||
|
||||
# From CPython Lib/colorsys.py
|
||||
def hsv_to_rgb(h, s, v):
|
||||
if s == 0.0:
|
||||
|
|
@ -30,6 +31,7 @@ def hsv_to_rgb(h, s, v):
|
|||
if i == 5:
|
||||
return v, p, q
|
||||
|
||||
|
||||
h = 0
|
||||
|
||||
while True:
|
||||
|
|
@ -39,7 +41,7 @@ while True:
|
|||
display.clear() # Fill the screen with the colour
|
||||
display.set_pen(0, 0, 0) # Set pen to black
|
||||
display.text("pico disco!", 25, 20, 240, 6) # Add some text
|
||||
display.text("\o/ \o/ \o/ \o/ \o/ \o/ \o/ \o/ \o/", 25, 120, 240, 4) # and some more text
|
||||
display.text("\\o/ \\o/ \\o/ \\o/ \\o/ \\o/ \\o/ \\o/ \\o/", 25, 120, 240, 4) # and some more text
|
||||
display.text("oontz oontz oontz", 25, 220, 240, 2) # and a bit more tiny text
|
||||
display.update() # Update the display
|
||||
utime.sleep(1.0 / 60)
|
||||
|
|
@ -10,8 +10,9 @@ tail = 12
|
|||
|
||||
width = scroll.get_width()
|
||||
height = scroll.get_height()
|
||||
|
||||
while True:
|
||||
scroll.clear();
|
||||
scroll.clear()
|
||||
for y in range(0, height):
|
||||
for x in range(0, width):
|
||||
if x < 3 and y < 3 and scroll.is_pressed(scroll.BUTTON_A):
|
||||
|
|
@ -28,7 +29,6 @@ while True:
|
|||
if m == (i + (loop - b)) % loop and b < tail:
|
||||
scroll.set_pixel(x, y, br_mult * (tail - b))
|
||||
|
||||
|
||||
scroll.update()
|
||||
i += 1
|
||||
if i >= loop:
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
import math
|
||||
import time
|
||||
import picounicorn
|
||||
|
||||
picounicorn.init()
|
||||
|
||||
|
||||
# From CPython Lib/colorsys.py
|
||||
def hsv_to_rgb(h, s, v):
|
||||
if s == 0.0:
|
||||
|
|
@ -27,6 +26,7 @@ def hsv_to_rgb(h, s, v):
|
|||
if i == 5:
|
||||
return v, p, q
|
||||
|
||||
|
||||
w = picounicorn.get_width()
|
||||
h = picounicorn.get_height()
|
||||
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue