-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.py
More file actions
51 lines (43 loc) · 1.22 KB
/
code.py
File metadata and controls
51 lines (43 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import time
import board
import busio
import adafruit_trellism4
import adafruit_adxl34x
import usb_hid
from adafruit_hid.mouse import Mouse
# neotrellis NeoPixel Button UI
trellis = adafruit_trellism4.TrellisM4Express()
trellis.pixels.brightness = 0.33
LEFT_BUTTON = (0, 0)
RIGHT_BUTTON = (7, 0)
trellis.pixels[LEFT_BUTTON] = 0xFF00FF
trellis.pixels[RIGHT_BUTTON] = 0xFF00FF
# Accelerometer configuration:
# TODO
# i2c =
# accelerometer =
# USB HID configuration
# TODO
# mouse =
# Convert the x and y acceleration values into left/right up/down mouse velocity values
# The mouse moves at a rate of ??
def get_mouse_deltas(x_acc, y_acc):
# TODO
return (round(dx), round(dy))
# Main loop TODO
# Track button states, read accelerometer, and send the proper values over USB
left_button_state = False
right_button_state = False
while True:
(_x, _y, _z) = accelerometer.acceleration
x_acc = round(_x) / 2
y_acc = round(_y) / 2
z_acc = round(_z) / 2
# print("x: %d" % x_acc)
# print("y: %d" % y_acc)
(dx, dy) = get_mouse_deltas(x_acc, y_acc)
mouse.move(x=dx)
mouse.move(y=dy)
# Button logic
pressed = set(trellis.pressed_keys)
# TODO write logic to read and debounce a button press