Usually I’d be trying to light up an LED, but simply printing runs slowly too.
Mind the choppiness, wanted to share the relevant bits, and the code is a work in progress.
Thanks again!
#!/usr/bin/python3
#Dotstar Board Stuff
import time
import board
import adafruit_dotstar as dotstar
from gpiozero import Button
import os
import qwiic_icm20948 as ninedof
from subprocess import check_call
import math
import random
#Dotstar Setup=========================================================================================
IMU = ninedof.QwiicIcm20948()
#IMU.setSampleMode(ICM_20948_Internal_Mag, ICM_20948_Sample_Mode_Continuous)
numPixels = 120
order = dotstar.BGR # I think this is right?
strip = dotstar.DotStar(board.SCK, board.MOSI, numPixels,
brightness=0.25, auto_write=False, pixel_order=order)
#Predefined Colors========================================================================================
black = 0x000000
white = 0xffffff
red0 = 0xff0000
green0 = 0x00ff00
blue0 = 0x0000ff
magenta0 = 0xff00ff
yellow0 = 0xffff00
cyan0 = 0x00ffff
gold0 = 0xffd700
orange0 = 0xff4400
orange1 = 0xff3300
orange2 = 0xff2200
orange3 = 0xff1100
#Interface Setup (1 button)=============================================================================================
trigger = Button(12, hold_time = 3)
triggerState=0
ninedofState=0
#Interface========================================================================================
while True:
IMU.begin()
if triggerState == 0:
if trigger.is_pressed:
ninedofState = 1
if ninedofState == 1:
if IMU.dataReady():
IMU.getAgmt()
Mx=IMU.mxRaw
My=IMU.myRaw
Mz=IMU.mzRaw
p=int(30+30*(math.atan2(Mx,My))/math.pi)
print(p)