Fix PEP8 compliance
This commit is contained in:
parent
0da6d60d5b
commit
c7086527c4
8 changed files with 45 additions and 44 deletions
|
|
@ -1,6 +1,7 @@
|
|||
# CircuitPython demo - NeoPixel RGBW
|
||||
|
||||
import time
|
||||
|
||||
import board
|
||||
import neopixel
|
||||
|
||||
|
|
@ -8,7 +9,8 @@ pixel_pin = board.A1
|
|||
num_pixels = 8
|
||||
|
||||
pixels = neopixel.NeoPixel(pixel_pin, num_pixels,
|
||||
brightness=0.3, auto_write=False, pixel_order=(1, 0, 2, 3))
|
||||
brightness=0.3, auto_write=False,
|
||||
pixel_order=(1, 0, 2, 3))
|
||||
|
||||
|
||||
def wheel(pos):
|
||||
|
|
|
|||
|
|
@ -9,5 +9,5 @@ for pin_name in dir(board):
|
|||
print("PWM on:", pin_name) # Prints the valid, PWM-capable pins!
|
||||
except ValueError: # This is the error returned when the pin is invalid.
|
||||
print("No PWM on:", pin_name) # Prints the invalid pins.
|
||||
except RuntimeError: # This is the error returned when there is a timer conflict.
|
||||
except RuntimeError: # Timer conflict error.
|
||||
print("Timers in use:", pin_name) # Prints the timer conflict pins.
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ pixel_pin = board.A1
|
|||
num_pixels = 8
|
||||
|
||||
pixels = neopixel.NeoPixel(pixel_pin, num_pixels,
|
||||
brightness=0.3, auto_write=False, pixel_order=(1, 0, 2, 3))
|
||||
brightness=0.3, auto_write=False,
|
||||
pixel_order=(1, 0, 2, 3))
|
||||
|
||||
|
||||
def wheel(pos):
|
||||
|
|
|
|||
|
|
@ -9,5 +9,5 @@ for pin_name in dir(board):
|
|||
print("PWM on:", pin_name) # Prints the valid, PWM-capable pins!
|
||||
except ValueError: # This is the error returned when the pin is invalid.
|
||||
print("No PWM on:", pin_name) # Prints the invalid pins.
|
||||
except RuntimeError: # This is the error returned when there is a timer conflict.
|
||||
except RuntimeError: # Timer conflict error.
|
||||
print("Timers in use:", pin_name) # Prints the timer conflict pins.
|
||||
|
|
|
|||
|
|
@ -42,8 +42,10 @@ while True:
|
|||
print("Humidity:", humidity)
|
||||
print("VBat voltage: {:.2f}".format(battery_voltage))
|
||||
print()
|
||||
sdc.write("{}, {}, {}, {:.2f}\n".format(int(time_stamp), temperature,
|
||||
humidity, battery_voltage))
|
||||
sdc.write("{}, {}, {}, {:.2f}\n".format(
|
||||
int(time_stamp), temperature,
|
||||
humidity, battery_voltage)
|
||||
)
|
||||
time.sleep(3)
|
||||
except OSError:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -59,16 +59,16 @@ print("Waiting for button presses")
|
|||
|
||||
|
||||
def pressbutton(i):
|
||||
l = leds[i] # find the switch LED
|
||||
switch_led = leds[i] # find the switch LED
|
||||
k = buttonkeys[i] # get the corresp. keycode/str
|
||||
l.value = True # turn on LED
|
||||
switch_led.value = True # turn on LED
|
||||
kbd.press(k) # send keycode
|
||||
|
||||
|
||||
def releasebutton(i):
|
||||
l = leds[i] # find the switch LED
|
||||
switch_led = leds[i] # find the switch LED
|
||||
k = buttonkeys[i] # get the corresp. keycode/str
|
||||
l.value = False # turn on LED
|
||||
switch_led.value = False # turn on LED
|
||||
kbd.release(k) # send keycode
|
||||
|
||||
|
||||
|
|
@ -98,15 +98,15 @@ while True:
|
|||
# check each button
|
||||
for button in buttons:
|
||||
i = buttons.index(button)
|
||||
if button.value == False: # button is pressed?
|
||||
if button.value is False: # button is pressed?
|
||||
buttonspressed[i] = True # save pressed button
|
||||
# was button not pressed last time?
|
||||
if buttonspressedlast[i] == False:
|
||||
if buttonspressedlast[i] is False:
|
||||
print("Pressed #%d" % i)
|
||||
pressbutton(i)
|
||||
else:
|
||||
buttonspressed[i] = False # button was not pressed
|
||||
if buttonspressedlast[i] == True: # was button pressed last time?
|
||||
if buttonspressedlast[i] is True: # was button pressed last time?
|
||||
print("Released #%d" % i)
|
||||
releasebutton(i)
|
||||
lightneopixels()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
###############################################
|
||||
# Minecraft Gesture Controller
|
||||
#
|
||||
# Written by <jenfoxbot@gmail.com>
|
||||
|
|
@ -7,11 +6,9 @@
|
|||
# Super awesome thanks to:
|
||||
# Richard Albritton, Tony DiCola, John Parker
|
||||
# All the awesome people who wrote the libraries
|
||||
################################################
|
||||
|
||||
##########################
|
||||
## Libraries ##
|
||||
##########################
|
||||
# Libraries
|
||||
|
||||
|
||||
import time
|
||||
|
||||
|
|
@ -27,9 +24,7 @@ from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
|
|||
from adafruit_hid.keycode import Keycode
|
||||
from adafruit_hid.mouse import Mouse
|
||||
|
||||
#######################
|
||||
# CPX Setup #
|
||||
#######################
|
||||
# CPX Setup
|
||||
touch_a1 = touchio.TouchIn(board.A1)
|
||||
touch_a1.threshold = 2000
|
||||
touch_a2 = touchio.TouchIn(board.A2)
|
||||
|
|
@ -39,9 +34,8 @@ touch_a3.threshold = 2000
|
|||
touch_a4 = touchio.TouchIn(board.A4)
|
||||
touch_a4.threshold = 2000
|
||||
|
||||
############################
|
||||
# Keyboard & Mouse Setup #
|
||||
############################
|
||||
# Keyboard & Mouse Setup
|
||||
|
||||
# The keyboard object!
|
||||
kbd = Keyboard()
|
||||
# we're americans :)
|
||||
|
|
@ -49,25 +43,23 @@ layout = KeyboardLayoutUS(kbd)
|
|||
# The mouse object!
|
||||
mouse = Mouse()
|
||||
|
||||
#######################
|
||||
# Accelerometer Setup #
|
||||
#######################
|
||||
# Accelerometer Setup
|
||||
|
||||
# Initialize Accelerometer
|
||||
i2c = busio.I2C(board.ACCELEROMETER_SCL, board.ACCELEROMETER_SDA)
|
||||
lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c, address=25)
|
||||
# Set range of accelerometer (can be RANGE_2_G, RANGE_4_G, RANGE_8_G or RANGE_16_G).
|
||||
# Set range of accelerometer
|
||||
# (can be RANGE_2_G, RANGE_4_G, RANGE_8_G or RANGE_16_G).
|
||||
lis3dh.range = adafruit_lis3dh.RANGE_8_G
|
||||
|
||||
|
||||
###########################
|
||||
## Controller Functions ##
|
||||
###########################
|
||||
# Controller Functions
|
||||
|
||||
# A helper to 'remap' an input range to an output range
|
||||
|
||||
|
||||
def Map(x, in_min, in_max, out_min, out_max):
|
||||
return int((x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min)
|
||||
return int(
|
||||
(x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min
|
||||
)
|
||||
|
||||
|
||||
def Move(upDown_axis, isBackward):
|
||||
|
|
@ -158,9 +150,7 @@ def readAxes():
|
|||
return (x / 9.806, y / 9.806, z / 9.806) # 9.806 m/s^2 per G
|
||||
|
||||
|
||||
###########################
|
||||
## Main Function ##
|
||||
###########################
|
||||
# Main Function
|
||||
while True:
|
||||
# Read accelerometer values (in G). Returns a 3-tuple of x, y, x axis
|
||||
pos_x, pos_y, pos_z = readAxes()
|
||||
|
|
@ -184,11 +174,13 @@ while True:
|
|||
Jump(pos_y)
|
||||
Give(pos_y, pos_x)
|
||||
|
||||
# Small delay to keep things responsive but give time for interrupt processing.
|
||||
# Small delay to keep things responsive but
|
||||
# give time for interrupt processing.
|
||||
time.sleep(0.01)
|
||||
|
||||
## Debugging Ahead!! ##
|
||||
# Use the following 2 lines to figure out which axis is upDown, frontBack, or LeftRight
|
||||
# Debugging Ahead!!
|
||||
# Use the following 2 lines to figure out which
|
||||
# axis is upDown, frontBack, or LeftRight
|
||||
# and also for debugging!
|
||||
# print('x = {}G, y = {}G, z = {}G'.format(x, y, z))
|
||||
# time.sleep(0.3)
|
||||
|
|
|
|||
|
|
@ -61,7 +61,8 @@ draw.rectangle((0, 0, width, height), outline=0, fill=0)
|
|||
padding = -2
|
||||
top = padding
|
||||
bottom = height - padding
|
||||
# Move left to right keeping track of the current x position for drawing shapes.
|
||||
# Move left to right keeping track of the current x position
|
||||
# for drawing shapes.
|
||||
x = 0
|
||||
|
||||
# Load nice silkscreen font
|
||||
|
|
@ -77,11 +78,14 @@ while True:
|
|||
IP = subprocess.check_output(cmd, shell=True)
|
||||
cmd = "hostname"
|
||||
HOST = subprocess.check_output(cmd, shell=True)
|
||||
cmd = "top -bn1 | grep load | awk '{printf \"CPU Load: %.2f\", $(NF-2)}'"
|
||||
cmd = "top -bn1 | grep load | awk " \
|
||||
"'{printf \"CPU Load: %.2f\", $(NF-2)}'"
|
||||
CPU = subprocess.check_output(cmd, shell=True)
|
||||
cmd = "free -m | awk 'NR==2{printf \"Mem: %s/%sMB %.2f%%\", $3,$2,$3*100/$2 }'"
|
||||
cmd = "free -m | awk 'NR==2{printf " \
|
||||
"\"Mem: %s/%sMB %.2f%%\", $3,$2,$3*100/$2 }'"
|
||||
MemUsage = subprocess.check_output(cmd, shell=True)
|
||||
cmd = "df -h | awk '$NF==\"/\"{printf \"Disk: %d/%dGB %s\", $3,$2,$5}'"
|
||||
cmd = "df -h | awk '$NF==\"/\"{printf " \
|
||||
"\"Disk: %d/%dGB %s\", $3,$2,$5}'"
|
||||
Disk = subprocess.check_output(cmd, shell=True)
|
||||
|
||||
# Pi Hole data!
|
||||
|
|
|
|||
Loading…
Reference in a new issue