The Raspberry Pi Thread [6]


  1. Posts : 15,037
    Windows 10 IoT
    Thread Starter
       #1541

    Ah crap, the pads I thought were for the battery are for adding another on off switch.
    Had to go back to the stock plugged in setup for now. That means sticking it to the top of my case with double sided sticky tape. Not what I wanted to do.
      My Computer


  2. Posts : 5,707
    insider build 10586.3 win10 pro 64
       #1542

    alphanumeric said:
    Ah crap, the pads I thought were for the battery are for adding another on off switch.
    Had to go back to the stock plugged in setup for now. That means sticking it to the top of my case with double sided sticky tape. Not what I wanted to do.
    that sucks !
      My Computer


  3. Posts : 305
    Win 10 and 11
       #1543

    Oh my, a long afternoon of making graphics for my status display...

    Now that I have the screen orientation and holder sorted out, I am starting to build the Pi application that talks to the PC. I have them able to talk to each other, but the Pi doesn't do anything with the incoming data yet, it just lets the PC know it is there and listening. I have more work to do on the PC side before the Pi can accept the information on all of the sensors in the PC. Then I have to write the code for the Pi to be able to display the data in a nice looking format. That is going to take a while, I think, but today I just made the graphics icons for the display. I didn't feel like coding today, since I did it at work all day yesterday.

    Tomorrow I will look at the data stream from the PC and code some routines for the Pi to show me that it is receiving it all ok. Maybe I will just have it barf out on the screen so I can check it. Then I will worry about icons and formatting.
      My Computers


  4. Posts : 15,037
    Windows 10 IoT
    Thread Starter
       #1544

    @ Catnip, very very interesting stuff. Way above my skill level. I see similar stuff on the Hackaday site now and then.
    Hackaday | Fresh Hacks Every Day
      My Computer


  5. Posts : 15,037
    Windows 10 IoT
    Thread Starter
       #1545

    My main PC desk has two shelves. A narrow one that the monitor(s) sit on, and the main one that the keyboard and mouse sit on. I mounted my RGB LED strip to the underside on the upper shelf facing down. It illuminates the lower shelf.

    Mounting it may prove to be an issue. It came with a weatherproof cover that I have removed. It made it heavy and bulky. And the double sided sticky (carpet) tape wouldn't stick to it. It is currently stuck in place. Will have to see how it fairs when the LED's get warm. Might have to resort to silicon sealant. That would mean removing the shelf for a day and flipping it over while it cures.
      My Computer


  6. Posts : 5,707
    insider build 10586.3 win10 pro 64
       #1546

    I have one like this ,got it at a flea market in sydney river a few yrs ago ,never used it yet ,got it plugged in now to see if it heats up ,I will post back in a few hrs'

    rgb led lights - Yahoo Video Search Results
      My Computer


  7. Posts : 15,037
    Windows 10 IoT
    Thread Starter
       #1547

    Round two. I went and bought a roll of 3M double sided foam sticky tap. What I got was the perfect width for my RGB LED String. It's good for up to 15 lbs, and for just about any surface. Just finished attaching it. I'll let it stick for a while before I light it up.
      My Computer


  8. Posts : 15,037
    Windows 10 IoT
    Thread Starter
       #1548

    So far so good, its staying put. I'm not running at full brightness. (100, 100, 100) seems good. That's what I have it at now, and its just slightly warm to the touch. And more than bright enough to easily see my keyboard lettering. Black keyboard with white lettering.

    My original plan was going to be wiring up some buttons with an IO expander. Then I remembered I have an Encoder wheel that's waiting to be used for something. It has a nice RGB LED ring, encoder wheel, and 5 buttons. It will look nice sitting on my desk, and ne fun coding up different lighting patterns / options.


    The Raspberry Pi Thread [6]-capture.png

    RGB Encoder Wheel Breakout
      My Computer


  9. Posts : 15,037
    Windows 10 IoT
    Thread Starter
       #1549

    I've got some usable basic functionality coded in. I can light it up Red, Green, Blue, or White with a button press. And off of course. I saved it as main.py so no having to open Thorny to use it.

    Adjustable brightness via the wheel is next. That's going to be tricky as I have to use HSV, Hue, Saturation, Value. I did it on my i75 so I'll use that code as a reference. And get what else I need from one of the examples that use it. Also going to make up a nice looking custom i2c cable to go from the Encoder wheel to the Plasma Stick. A USB cable should work once I cut the connectors off. It will have 4 wires and at least one shielded pair for the SCL SDA.
      My Computer


  10. Posts : 15,037
    Windows 10 IoT
    Thread Starter
       #1550

    Getting close to how I want it to work. I can switch colors with the buttons, and adjust the brightness. I just can adjust the brightness on the fly. I have to turn the wheel and "then press a color section button" to have it change. The wheel also defaults to position 0.

    For example:
    On boot up all the LED's on the Encoder and LED strip are off.
    Press the Up button and the LED ring and LED strip turn on white at 0.5 (50%) brightness.
    If I turn the encoder wheel the brightness value is changed. It defaults to 0.0, which is another issue to sort out.
    It does not change the LED brightness until I press the up button again though.

    I'll take a break and have another go latter on.

    Code:
    import time
    import plasma
    import machine
    import micropython
    
    from plasma import plasma_stick
    from pimoroni_i2c import PimoroniI2C
    from pimoroni import BREAKOUT_GARDEN_I2C_PINS  # or PICO_EXPLORER_I2C_PINS or HEADER_I2C_PINS
    from breakout_encoder_wheel import BreakoutEncoderWheel, UP, DOWN, LEFT, RIGHT, CENTRE, NUM_BUTTONS, NUM_LEDS
    
    BUTTON_NAMES = ["Up", "Down", "Left", "Right", "Centre"]
    
    i2c = PimoroniI2C(plasma_stick.SDA, plasma_stick.SCL)
    
    wheel = BreakoutEncoderWheel(i2c)
    #position = 0
    last_pressed = [False] * NUM_BUTTONS
    pressed = [False] * NUM_BUTTONS
    
    GRB_LEDS = 144
    
    # WS2812 / NeoPixel™ LEDs
    led_strip = plasma.WS2812(GRB_LEDS, 0, 0, plasma_stick.DAT, color_order=plasma.COLOR_ORDER_GRB)
    led_strip.start()
    
    brightness = (0.5)
    
    '''
    black = hsv(0, 0, 0)
    red = hsv(1 / 360, 1.0, brightness)
    green = hsv(130 / 360, 1.0, brightness)
    blue = hsv(250 / 360, 1.0, brightness)
    yellow = hsv(60 / 360, 1.0, brightness)
    orange = hsv(30 / 360, 1.0, brightness)
    white = hsv(1.0, 0, brightness)
    '''
    
    while True:
        
        # Read all of the encoder wheel's buttons
        for b in range(NUM_BUTTONS):
            pressed[b] = wheel.pressed(b)
            if pressed[b] != last_pressed[b]:
                print(BUTTON_NAMES[b], "Pressed" if pressed[b] else "Released")
            last_pressed[b] = pressed[b]
    
        if pressed[UP]:
            wheel.clear()
            for i in range(NUM_LEDS):
                wheel.set_hsv(i, 1.0, 0, brightness)
            for s in range(GRB_LEDS):
                led_strip.set_hsv(s, 1.0,  0, brightness)
            wheel.set_hsv(0, 1.0, 0, brightness)
            wheel.set_hsv(6, 1 / 360, 1.0, brightness)
            wheel.set_hsv(12, 130 / 360, 1.0, brightness)
            wheel.set_hsv(18, 250 / 360, 1.0, brightness)            
    
        if pressed[RIGHT]:
            wheel.clear()
            for i in range(NUM_LEDS):
                wheel.set_hsv(i, 1 / 360, 1.0, brightness)
            for s in range(GRB_LEDS):
                led_strip.set_hsv(s, 1 / 360,  1.0, brightness) 
            wheel.set_hsv(0, 1.0, 0, brightness)
            wheel.set_hsv(6, 1 / 360, 1.0, brightness)
            wheel.set_hsv(12, 130 / 360, 1.0, brightness)
            wheel.set_hsv(18, 250 / 360, 1.0, brightness)
            
        if pressed[DOWN]:
            wheel.clear()
            for i in range(NUM_LEDS):
                wheel.set_hsv(i, 130 / 360, 1.0, brightness)
            for s in range(GRB_LEDS):
                led_strip.set_hsv(s, 130 / 360,  1.0, brightness)
            wheel.set_hsv(0, 1.0, 0, brightness)
            wheel.set_hsv(6, 1 / 360, 1.0, brightness)
            wheel.set_hsv(12, 130 / 360, 1.0, brightness)
            wheel.set_hsv(18, 250 / 360, 1.0, brightness)               
            
        if pressed[LEFT]:
            wheel.clear()
            for i in range(NUM_LEDS):
                wheel.set_hsv(i, 250 / 360, 1.0, brightness)
            for s in range(GRB_LEDS):
                led_strip.set_hsv(s, 250 / 360,  1.0, brightness)         
            wheel.set_hsv(0, 1.0, 0, brightness)
            wheel.set_hsv(6, 1 / 360, 1.0, brightness)
            wheel.set_hsv(12, 130 / 360, 1.0, brightness)
            wheel.set_hsv(18, 250 / 360, 1.0, brightness)
            
        if pressed[CENTRE]:
            wheel.clear()
            for s in range(GRB_LEDS):
                led_strip.set_hsv(s, 0, 0, 0)              
            wheel.set_hsv(0, 1.0, 0, brightness)
            wheel.set_hsv(6, 1 / 360, 1.0, brightness)
            wheel.set_hsv(12, 130 / 360, 1.0, brightness)
            wheel.set_hsv(18, 250 / 360, 1.0, brightness)
            
        # Has the dial been turned since the last time we checked?
        change = wheel.delta()
        if change != 0:
            # Print out the direction the dial was turned, and the count
            if change > 0:
                print("Clockwise, Count =", wheel.count())
            else:
                print("Counter Clockwise, Count =", wheel.count())
    
            # Record the new position (from 0 to 23)
            position = wheel.count()
            if position < 1:
                position = 1
                
            if position > 25:
                position = 25
            print ("Position =", position)
            # Record a colour hue from 0.0 to 1.0
            brightness = ((position * 4) / 100)
            if brightness < 0:
                brightness = 0
                
            if brightness > 1:
                brightness = 1
            
            print (brightness)
    
        wheel.show()
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 23:29.
Find Us




Windows 10 Forums