New
#1661
Just a head's up. The CAN bus is hard to hack and you can screw up your car with a bug. (I know, I have been fiddling)
The alternative is to use a bluetooth ODB reader. The info is fairly well documented and it has all of the parameters of your car available. Just have a bluetooth module on your Pico or Pi or whatever you use. I found some cheap at AliExpress. If I have time later today I will look one up for you.
Was tinkering with this today.
It's a test setup so I can code for the encoder wheel. Tinkering with planed changes to my desktop RGB LED light setup.
So far I have the encoder wheel moving a marker corresponding to the wheel position. And adjust the brightness as the wheel is moved. The buttons on the Encoder Wheel set the color and rotating the wheel sets the brightness.
Saves me from having to actually mess with my Plasma Stick 2040 W working Code. Plus I can use the desktop lighting to actually see what I'm doing while coding. I was at it at 3AM this morning. I couldn't seep so I got up. Was at it until about 6:30 AM.
My current setup does adjust the brightness with the Encoder Wheel. But for now, it lights up to match what was selected. Up gets you a full white circle on the Encoder Wheel that gets brighter or dimmer as the wheel is turned. I'd rather a marker with an arch/trail of lit LED's behind it. Going to be fun "I hope" and a nice distraction from what ails me.
Last edited by alphanumeric; 4 Days Ago at 03:43.
@caperjack You may have gotten that from me in one of our tech bits & bytes swaps.
Sorted out my Rotary Encoder Switch code. Fabed up a new test setup and borrowed my OLED form the other one.
As I turn the ring on the encoder the LED's light up one by one in a string going clockwise. And as I turn the ring they get brighter and brighter. My LED String on the Plasma Sticks Brightness will follow what the ring does. Turn it counter clockwise and it goes down. At the same time the arch on the Encoder gets shorter and dimmer.
The Position is the rotary switch position from 0 to 23 going clockwise. It's at Position 8. The Level is the brightness from 0 to 1.0. I use this as the V in HSV.
Code:import time import plasma import machine import micropython from plasma import plasma_stick from pimoroni_i2c import PimoroniI2C i2c = PimoroniI2C(4, 5) from breakout_encoder_wheel import BreakoutEncoderWheel, UP, DOWN, LEFT, RIGHT, CENTRE, NUM_BUTTONS, NUM_LEDS from plasma import plasma_stick from picographics import PicoGraphics, DISPLAY_I2C_OLED_128X128 display = PicoGraphics(display=DISPLAY_I2C_OLED_128X128, bus=i2c) display.set_font("bitmap8") display.set_pen(0) display.clear() red = (1 / 360) green = (130 / 360) blue = (250 / 360) yellow = (60 / 360) orange = (30 / 360) white = (1.0) wheel = BreakoutEncoderWheel(i2c) BUTTON_NAMES = ["Up", "Down", "Left", "Right", "Centre"] last_pressed = [False] * NUM_BUTTONS pressed = [False] * NUM_BUTTONS #wheel = BreakoutEncoderWheel(i2c) # Variables #position = 1 #brightness = 0 # Set the first LED wheel.clear() wheel.set_hsv(0, 1.0, 0, 1.0) wheel.set_hsv(6, red, 1.0, 1.0) wheel.set_hsv(12, green, 1.0, 1.0) wheel.set_hsv(18, blue, 1.0, 1.0) wheel.show() display.set_pen(15) display.text("Position 0", 0, 10, scale = 2) display.text("Level 0", 0, 40, scale = 2) display.text("Color White", 0, 70, scale = 2) display.update() # Simple function to clamp a value between 0.0 and 1.0 def clamp01(value): return max(min(value, 1.0), 0.0) def clamp02(value): return max(min(value, 24.0), 0.0) # Loop forever while True: # Has the dial been turned since the last time we checked? change = wheel.delta() if change != 0: print("Count =", wheel.count()) # Record the new position (from 0 to 23) LED = wheel.step() + 1 print("LED =", LED) #hue = wheel.revolutions() % 1.0 brightness = (wheel.step() * 4) / 100 #brightness = clamp01(brightness) #position = clamp02(position) display.set_pen(0) display.clear() display.set_pen(15) display.text("Position {:.0f}".format(wheel.step()), 0, 10, scale = 2) display.text("Level {:.4f}".format ((wheel.step() * 4) / 100), 0, 40, scale = 2) display.text("Color White", 0, 70, scale = 2) display.update() # Set the LED at the new position to the new hue wheel.clear() for w in range(LED): wheel.set_hsv(w, 1.0, 0, brightness) #wheel.set_hsv(position, 1.0, 0, brightness) wheel.show()
Last edited by alphanumeric; 4 Days Ago at 16:00.
I think you might be right .You may have gotten that from me in one of or tech bits & bytes swaps.
[/CODE]