The Raspberry Pi Thread [5]

Page 34 of 34 FirstFirst ... 24323334
  1.    #331

    This waht I had and was tested working fine.
    Code:
    def ledtemp():
        if sensor.get_sensor_data(): 
           t = sensor.data.temperature 
           t = round(t)
        if t > 28:                                         # Realy Hot 
            set_multiple_pixels(range(0,27), 255, 0, 0)    # Red
            set_multiple_pixels(range(27,28), 255,140, 0)  # Orange
            M = (t - 56) * (-1)
            # R R R R R R R R R R R R R R R R R R R R R R R R R R R O
        elif t > 0 and t <= 28:                            # Main
            set_multiple_pixels(range(0,3), 255, 140, 0)   # Orange
            set_multiple_pixels(range(3,16), 0, 255, 0)    # Green
            set_multiple_pixels(range(16,28), 255, 255, 0) # Yellow
            M = (28 - t)
            # O O O G G G G G G G G G G G G G Y Y Y Y Y Y Y Y Y Y Y Y
        elif t <= 0 and t >= -27:                          # Cold 
            ledshim.set_all(0, 0, 255)                     # Blue
            M = (t * (-1))
            # B B B B B B B B B B B B B B B B B B B B B B B B B B B B
        elif t < -27:                                      # Really cold
            set_multiple_pixels(range(0,3), 255, 255, 255) # Blue
            set_multiple_pixels(range(3,28), 0, 255, 255)  # Aqua
            M = ((28 + t) * (-1))
            # B B B A A A A A A A A A A A A A A A A A A A A A A A A A
        ledshim.set_pixel(M, 0, 0, 0)
        ledshim.show()
    And this is my new untested code

    Code:
    def ledtemp():
        if sensor.get_sensor_data(): 
           t = sensor.data.temperature 
           t = round(t)
        if t > 40:                                         # Realy Hot 
            set_multiple_pixels(range(0,28), 255, 0, 0)    # Red
            M = (t - 68) * (-1)
            # R R R R R R R R R R R R R R R R R R R R R R R R R R R R
        elif t > 12 and t <= 40:                           # Main
            set_multiple_pixels(range(0,11), 255, 0, 0)    # Red
            set_multiple_pixels(range(11,16), 255, 140, 0) # Orange
            set_multiple_pixels(range(16,28), 0, 255, 0)   # Green
            M = (40 - t)
            # R R R R R R R R R R R O O O O O G G G G G G G G G G G G
        elif t <= 12 and t >= 0:                          # Cold 
            set_multiple_pixels(range(0,12), 255, 255, 0) # Yellow
            set_multiple_pixels(range(12,28), 255, 255, 255)  # Aquat
            M = (12 - t)
            # Y Y Y Y Y Y Y Y Y Y Y Y B B B B B B B B B B B B B B B B
           
        elif t < 0 and t >= -15:                          # Cold 
            set_multiple_pixels(range(0,12), 255, 255, 0) # Yellow
            set_multiple_pixels(range(12,28), 255, 255, 255)  # Aquat
            M = (t * (-1)) + 12
            # Y Y Y Y Y Y Y Y Y Y Y Y B B B B B B B B B B B B B B B B
        elif t < -15:                                      # Really cold
            set_multiple_pixels(range(0,28), 0, 255, 255)  # Aqua
            M = ((t + 16) * (-1))
            # A A A A A A A A A A A A A A A A A A A A A A A A A A A A
        ledshim.set_pixel(M, 0, 0, 0)
        ledshim.show()
    Last edited by alphanumeric; 3 Days Ago at 10:29.
      My ComputerSystem Spec

  2. caperjack's Avatar
    Posts : 4,283
    insider build 10586.3 win10 pro 64
       #332

    still all greek to me . this is old i think but some neat looking tools for kids and young adults into learning Pi Installing the .NET Core 2.x SDK on a Raspberry Pi and Blinking an LED with System.Device.Gpio - Scott Hanselman
      My ComputerSystem Spec

  3.    #333

    Just tested my new LED Shim Temperature code. No errors, woot. This new scale should be ideal for my indoor weather clock. It goes from 13c at the bottom to 40c at the top. Unless we have a power failure in the middle of winter it should never leave that scale. Its green from 13 to 24, orange from 25 to 29, and red above 30c. I think I'm going to put this code on my portable too, just to be consistent.
    The ideal way to do this would be to have a static marker in the middle of the LED Shim that never moves. Then have a sliding scale that moves with the temperature. The colored bands would move up and down depending on the temperature. I'm thinking that would be really hard to code though. I may see if its doable at some point, not today though.
      My ComputerSystem Spec

  4.    #334

    Started redoing my LED Shim barometric Pressure code. I switch my indoor Weather Clock to show pressure in the winter. No real advantage to showing the temperature when all the doors are closed and the furnace is on. It just sits at 22c all day lol.
    I want to have one scale that goes from very low to very high. I'm going to lose a bit of accuracy but only on the LED shim. I only have 28 LED's to work with. The normal Sense Hat display is unaffected.
    This is what I have so far, and its not tested yet. Might still be a bug or two in my code. The first column is the color I want the LED. The next column is the LED number and then the pressure it represents.
    I used 30 LED's to make the math easier, the two end ones are only imaginary. The odds of the pressure getting that high or that low are very remote.

    R - 1069
    R - 0
    R
    R
    R
    R - 4 - 1048 - Very High
    B - 5 - 1047 - High
    B
    B
    B
    B
    B - 10 - 1026 - High
    G - 11 - 1025 - Mid
    G
    G
    G
    G
    G - 16 - 1004 - Mid
    Y - 17 - 1003 - Low
    Y -
    Y -
    Y -
    Y -
    Y - 22 - 982 - Low
    R - 23 - 981 - Very Low
    R -
    R -
    R -
    R - 27 -
    R - 960

    1069 - 960 = 109

    110 / 30 = 3.66666
    M1 = P - 961 << Gives me a number between 0 and 109
    M2 = M1 / 3.666 << Gives me a number between 30 and 0
    M3 = (M2 - 30) * -1 << Swaps the order, 30 becomes 0 and 0 becomes 30 as my LED shim is upside down / reversed.


    The actual python code is as follows. I'm going to try and test it sometime today.

    def ledpress():

    if sensor.get_sensor_data():
    p = sensor.data.pressure
    p = round(p)



    set_multiple_pixels(range(0,5), 255, 0, 0) # Red - Very High
    set_multiple_pixels(range(5,11), 0, 0, 255) # Blue - High
    set_multiple_pixels(range(11,17), 0, 255, 0) # Green - Mid Range
    set_multiple_pixels(range(17,23), 255, 255, 0) # Yellow - Low
    set_multiple_pixels(range(23,28), 255, 0, 0) # Red - Verry Low







    N = ((p- 961) / 3.666)
    M = ((N -30) * (-1))


    ledshim.set_pixel(M, 0, 0, 0)
    ledshim.show()
    Last edited by alphanumeric; 1 Day Ago at 09:54.
      My ComputerSystem Spec

  5.    #335

    Ended up with this, seems to work Ok.

    Code:
    def ledpress():
    
        if sensor.get_sensor_data(): 
           p = sensor.data.pressure 
           p = round(p)
    
    
        set_multiple_pixels(range(0,5), 255, 0, 0)         # Red    - Very High
        set_multiple_pixels(range(5,11), 0, 0, 255)        # Blue - High
        set_multiple_pixels(range(11,17), 0, 255, 0)       # Green  - Mid Range
        set_multiple_pixels(range(17,23), 255, 255, 0)     # Yellow   - Low
        set_multiple_pixels(range(23,28), 255, 0, 0)       # Red    - Verry Low
        
        N = ((p- 961) / 3.6) 
        N = round(N)
        M = ((N -30) * (-1))
        
        ledshim.set_pixel(M, 0, 0, 0)    
        ledshim.show()     
    EDIT: My pointer is a bit low, going to have to tweak my math a little bit I think. The actual barometer reading was just in the Mid Range. My pointer should have been on the lowest Green LED, but my pointer was in the top of the yellow bit. Having to round off my number likely has something to do with it. I think I need to divide by 3.7 or 3.8 instead of 3.6. The math actually kicked out 3.66666666...

    I'll play with it latter on today, I just put it all back together again. Maybe I'll grab my indoor one, its not in a case so plugging in cables is easy.
    Last edited by alphanumeric; 1 Day Ago at 10:22.
      My ComputerSystem Spec


 
Page 34 of 34 FirstFirst ... 24323334

Related Threads
The Raspberry Pi Thread [4] in Chillout Room
Continued from - The Raspberry Pi Thread - Windows 10 Forums Was intending to play around with the GPIO extender. Wrote up a quick little python file to flash some leds in sequence, like traffic lights. Looks like you have to use "pigpio". ...
The Raspberry Pi Thread [3] in Chillout Room
Continued From - The Raspberry Pi Thread - Page 208 - Windows 10 Forums A black version of the Pi Zero case would be nice. Or white even.
The Raspberry Pi Thread [2] in Chillout Room
Continued from - The Raspberry Pi Thread - Windows 10 Forums (200 page limit) Looks like my error message is Configuring network interfaces... ioctl: Operation not permitted. I also get a ioctl: invalid argument, I get two of them, whatever...
The Raspberry Pi Thread in Chillout Room
After spaming this thread , https://www.tenforums.com/windows-10-news/3950-new-raspberry-pi-2-now-windows-10-support.html I figured a new thread may be in order. I have a B+ and one of the new model 2 B's. I just fired up Raspbian on the new one to...
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 15:06.
Find Us