The Raspberry Pi Thread [6]


  1. Posts : 5,707
    insider build 10586.3 win10 pro 64
       #691

    I read with envy ! I'm lucky if can just learn the basics ! but I will trudge on, lol
    alphanumeric said:
    I have one of these on the way in that last order.
    IO Expander Breakout – Pimoroni

    It's the same one used in that new weather hat to read the wind vane and rain sensor. Already nabbed the schematic on the weather hat. With that info I should be able to reproduce the weather hat in equivalent breakout garden stuff. And run that new fancy code on it, with only minor edits.

    I have everything else I need already.
      My Computer


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

    I just did my edits to the file I'm running on the V1 Display Pack for the V2 Display Pack upgrade. Got bored and didn't feel like soldering or messing with working hardware. The edit gets saved as new file to test when the hardware arrives.
    Big change width and height wise.
    V1 is 240 wide by 135 high.
    V2 is 320 wide by 240 high.

    EDIT: This is the current working V1 file.
    Code:
    '''
        Weather Display
    Pico + Lipo Shim
    Pico Display Pack V1
    BME280 Breakout - Temperature, Pressure, Humidity Sensor
    
    '''
    import machine
    import utime
    import gc
    
    from machine import ADC, Pin
    
    from breakout_bme280 import BreakoutBME280
    from pimoroni_i2c import PimoroniI2C
    
    # Pico Display boilerplate
    import picodisplay as display  # Comment this line out to use PicoDisplay2
    # import picodisplay2 as display  # Uncomment this line to use PicoDisplay2
    
    width = display.get_width()
    height = display.get_height()
    gc.collect()
    display_buffer = bytearray(width * height * 2)
    display.init(display_buffer)
    display.set_backlight(0.5)
    
    PINS_BREAKOUT_GARDEN = {"sda": 4, "scl": 5}
    PINS_PICO_EXPLORER = {"sda": 20, "scl": 21}
    i2c = PimoroniI2C(**PINS_BREAKOUT_GARDEN)
    
    bme = BreakoutBME280(i2c)
    
    vsys = ADC(29)              # reads the system input voltage
    charging = Pin(24, Pin.IN)  # reading GP24 tells us whether or not USB power is connected
    conversion_factor = 3 * 3.3 / 65535
    
    full_battery = 4.2                  # these are our reference voltages for a full/empty battery, in volts
    empty_battery = 2.8                 # the values could vary by battery size/manufacturer so you might need to adjust them
    
    # lets set up some pen colors to make drawing easier
    tempcolor = display.create_pen(0, 255, 0)  # this colour will get changed in a bit
    humidcolor = display.create_pen(0, 255, 0)  # this colour will get changed in a bit
    presscolor = display.create_pen(0, 255, 0)  # this colour will get changed in a bit
    white = display.create_pen(255, 255, 255)
    black = display.create_pen(0, 0, 0)
    red = display.create_pen(255, 0, 0)
    green = display.create_pen(0, 255, 0)
    blue = display.create_pen(0, 0, 255)
    yellow = display.create_pen(255, 255, 0)
    orange = display.create_pen(255, 140, 0)
    
    
    # converts the temperature into a description and pen colour
    def describe_temperature(temperature):
        global tempcolor
        if temperature < 0:
            description = "very cold"
            tempcolor = blue
        elif 0 <= temperature < 12:
            description = "cold"
            tempcolor = yellow
        elif 12 <= temperature < 17:
            description = "cool"
            tempcolor = green
        elif 17 <= temperature < 25:
            description = "warm"
            tempcolor = green      
        elif 25 <= temperature < 30:
            description = "hot"
            tempcolor = orange
        elif temperature >= 30:
            description = "very hot"
            tempcolor = red
        else:
            description = ""
            tempcolor = black
        return description
    
    min_temp = None
    max_temp = None
    
    
    # converts humidity into good/bad description and pen color
    def describe_humidity(humidity):
        global humidcolor
        if humidity < 30:
            description = "low dry"
            humidcolor = orange
        elif 30 <= humidity < 61:
            description = "ok"
            humidcolor = green
        elif 61 <= humidity < 81:
            description = "high"
            humidcolor = yellow
        elif humidity >= 81:
            description = "very high"
            humidcolor = red        
        else:
            description = ""
            humidcolor = black        
        return description
    
    
    # converts pressure into barometer-type description and pen color
    def describe_pressure(pressure):
        global presscolor
        if pressure < 982:
            description = "very low"
            presscolor = red
        elif 982 <= pressure < 1004:
            description = "low"
            presscolor = yellow
        elif 1004 <= pressure < 1026:
            description = "unsettled"
            presscolor = green
        elif 1026 <= pressure < 1048:
            description = "high"
            presscolor = blue
        elif pressure >= 1048:
            description = "very high"
            presscolor = orange
        else:
            description = ""
            presscolor = black
        return description
    
    
    start_time = utime.time()
    
    while True:
        
        # fills the screen with black
        display.set_pen(0, 0, 0)
        display.clear()    
        
        time_elapsed = utime.time() - start_time
        
        # read the sensors
        temperature, pressure, humidity = bme.read() 
                
        # convert pressure to mb
        pressuremb = pressure / 100
     
        #240x135 pixel IPS display
             
        # draw the temperature reading
        display.set_pen(tempcolor)
        display.text('{:.1f}'.format(temperature) + '`c', 10, 10, 240, 3)
        display.set_pen(white)
        display.text(describe_temperature(temperature), 10, 30, 240, 3)
        
        # and the humidity reading
        display.set_pen(humidcolor)
        display.text('{:.0f}'.format(int(humidity)) + '%', 10, 50, 240, 3)
        display.set_pen(white)
        display.text(describe_humidity(int(humidity)), 10, 70, 240, 3)
        
        # drawing the pressure reading
        display.set_pen(presscolor)
        display.text('{:.0f}'.format(pressuremb) + 'mb', 10, 90, 240, 3)
        display.set_pen(white)
        display.text(describe_pressure(pressuremb), 10, 110, 240, 3)
        
        voltage = vsys.read_u16() * conversion_factor
        percentage = 100 * ((voltage - empty_battery) / (full_battery - empty_battery))
        if percentage > 100:
            percentage = 100.00
            
        # adding text
        display.set_pen(0, 255, 0)
        if charging.value() == 1:         # if it's plugged into USB power...
            display.text("Charging!", 110, 10, 240, 3)
            display.set_led(0,0,125)
        else:                             # if not, display the battery stats
            display.text("Battery!", 110, 10, 240, 3)
            display.set_led(125,0,0)
            
        display.text('{:.2f}'.format(voltage) + "v", 135, 30, 240, 3)
        display.text('{:.0f}%'.format(percentage), 140, 50, 240, 3)
            
        
        # time to update the display
        display.update()
    
        # waits for 1 second and clears to black
        utime.sleep(1)
        display.set_pen(black)
        display.clear()
      My Computer


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

    caperjack said:
    I read with envy ! I'm lucky if can just learn the basics ! but I will trudge on, lol
    I almost always start with a working Pimoroni example. Something that is close to what I want to do with said device. Then I break it, fix it, wash rinse and repeat, lol. Until I get what I wanted when I started. There is a lot of code I use that I know what it does, I just have no clue how it does it. Put it in the right place and it works, which works for me.
      My Computer


  4. Posts : 5,707
    insider build 10586.3 win10 pro 64
       #694

    all i can say is great job,what i do best is make a mess doing stuff and then cleanup . lol
    alphanumeric said:
    I almost always start with a working Pimoroni example. Something that is close to what I want to do with said device. Then I break it, fix it, wash rinse and repeat, lol. Until I get what I wanted when I started. There is a lot of code I use that I know what it does, I just have no clue how it does it. Put it in the right place and it works, which works for me.
      My Computer


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

    New Pi OS images released dated 2022-01-28:
    * rc_gui - add combo box to allow resolution to be set for VNC connections
    * rc_gui - camera interface switch removed
    * lxpanel - remove appearance settings from preferences dialog; instead add menu option to open general Appearance Settings application
    * lxpanel - add ellipses to menu items which open dialogs
    * lxinput - read current mouse acceleration directly from xinput
    * lxinput - use device IDs rather than names to cope with devices changing when powered-down
    * lxinput - remove redundant changes to openbox config file
    * plymouth - set KillMode to mixed to suppress warning message
    * raspi-config - add option to switch composite video
    * raspi-config - add option to switch to legacy camera mode
    * raspi-config - add option to set resolution for headless connections
    * raspberrypi-ui-mods - disable mutter when VNC server is running and fall back to openbox
    * pipanel - add command-line option to open on arbitrary tab
    * lxplug-network - suppress ’scan received’ logging message
    * raspberrypi-ui-mods - set hover colour for taskbar items based on taskbar colour, not system highlight colour
    * Legacy camera applications and libraries reinstalled
    * Bug fix - lxinput - lxsession config file not being written on first attempt
    * Bug fix - lxinput - set timer for file write to prevent slider slowing down
    * Bug fix - lxinput - write values to gsettings as well as xinput and xsettings to take effect within mutter
    * Bug fix - lxinput - fix failure to parse and write non-English numeric formats
    * Bug fix - arandr - various fixes to parsing of non-standard EDID blocks to enable model and serial to be correctly extracted
    * Bug fix - arandr - refresh rate calculated to 3 decimal places for monitors which require it
    * Bug fix - arandr - enable setting of left and right orientation
    * Bug fix - arandr - add compatibility with new touchscreen driver
    * Bug fix - arandr - apply settings correctly to DSI and composite displays
    * Bug fix - lxplug-magnifier - fix crash when opening preferences without required magnifier package installed
    * Bug fix - piwiz - launch screen reader install prompt as a new process to prevent audio lockups crashing wizard
    * Bug fix - lxpanel - not loading some plugins (cpufreq, minimise all windows) due to icon loading code not compatible with GTK+3
    * Bug fix - gtk+3 - disabled new GDK touch events to enable double-clicks to be detected on touchscreen
    * Bug fix - xrdp - included backports from bookworm version of xrdp and xorgxrdp to restore window frames with mutter over xrdp connections
    * Update various translations
    * udisks2 added to lite image
    * mkvtoolnix added to lite image
    * 7z and zip support added to lite image
    * gnome-keyring added to desktop images
    * Raspberry Pi firmware c6d56567ff6ef17fd85159770f22abcf2c5953ed
    * Linux kernel 5.10.92

    Operating system images – Raspberry Pi
      My Computer


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

    ok, got the link, Whats your OS of choice for a daily user Pi 4
      My Computer


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

    caperjack said:
    ok, got the link, Whats your OS of choice for a daily user Pi 4
    I'm running Bullseye, Raspberry Pi OS with desktop, on my Pi 400. The one issue I had is fixed in this latest release. I do some Breakout Garden tinkering on the Pi 400 and coding to a PICO on it. I have one other Pi 4B running Bullseye, and the rest are still running Buster.

    That being said, there are some hats etc that don't work as intended on Bullseye. Broken installers because of things that were in Buster, that are no longer in Bullseye, or replaced with newer versions.

    EDIT: If you have a spare SD card, flash One with Bullseye and one with the Legacy Buster version. Then just swap them if you hit a glitch you think is because of Bullseye.
    Last edited by alphanumeric; 01 Feb 2022 at 05:28.
      My Computer


  8. Posts : 5,707
    insider build 10586.3 win10 pro 64
       #698

    will do ,thanks
    alphanumeric said:
    I'm running Bullseye, Raspberry Pi OS with desktop, on my Pi 400. The one issue I had is fixed in this latest release. I do some Breakout Garden tinkering on the Pi 400 and coding to a PICO on it. I have one other Pi 4B running Bullseye, and the rest are still running Buster.

    That being said, there are some hats etc that don't work as intended on Bullseye. Broken installers because of things that were in Buster, that are no longer in Bullseye, or replaced with newer versions.

    EDIT: If you have a spare SD card, flash One with Bullseye and one with the Legacy Buster version. Then just swap them if you hit a glitch you think is because of Bullseye.
      My Computer


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

    Totally missed that 64 bit is official now. It's listed in that link I posted, if you scroll down far enough. Not sure if I'm going to try it or not? Only just got my Pi 400 back to where I like it with the new 32 bit release.
      My Computer


  10. Posts : 5,707
    insider build 10586.3 win10 pro 64
       #700

    I dont think i'll notice any difference with 64 bit, but i'll install it and take a peak.
    alphanumeric said:
    Totally missed that 64 bit is official now. It's listed in that link I posted, if you scroll down far enough. Not sure if I'm going to try it or not? Only just got my Pi 400 back to where I like it with the new 32 bit release.
      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 22:57.
Find Us




Windows 10 Forums