Documentation for Pimoroni version of Micropython for Pico W

I have bought a selection of boards, displays and add-ons from Pimoroni but I do not know anything about Python as all of my previous projects have been in C on Microchip devices.

I may have been looking in the wrong places but I cannot find a comprehensive manual for the Pimoroni version of Micropython for the Pico and Pico W. I have seen the standard Micropython manual from Raspberry Pi org but some commands are different or missing.

For example, I am not sure of the full parameter lists for commands seen in the code examples:
display.text( )
from adcfft import ADCFFT
adcfft.update()
adcfft = ADCFFT()

Does anyone know if there is Is there a comprehensive manual available which explains all of the commands as used in the Pimoroni board examples.

Thanks for looking

I am far from any kind of expert on this, and don’t work for Pimoroni.
As far as I know the Micro Python used is the one released by the Pi Foundation.
Then they add their custom libraries to the uf2 file. The various examples use those custom libraries. Pico Graphics for example.
pimoroni-pico/micropython/modules/picographics at main · pimoroni/pimoroni-pico (github.com)
What commands you use depends on what module is imported for the hardware in question. Something like that anyway. And a lot of it is in flux. I don’t think there is “one” document / manual for “How this all works”.

That being said, I don’t think they remove anything from Micro Python. I’m thinking if you import the correct module, the standard commands should work.
@hel or @Matt should know how this works.

Hi SteveA,

I’m new here to (so don’t take this as 100% accurate) but I’ve been trying to make as much sence of the documentation side as I can, so here is what I thick it is:

Documentation for the MicroPython language is held on gitHub Overview — MicroPython latest documentation, as the language is evolving continiously.
It uses some python moduals as written by Python.org and incorporates drivers written in C/++ that Adafruit create for some of the sensors and displays, Raspberry Pi have ported a version of MicroPython and their keywords are essentially the same but use a “u” in front to designate its from their port.
I hope this is of use to you.

The Pimoroni libraries are basically C wrapped in Micro Python. .
Adafruit went there own way with Circuit Python.
Its what they came up with when there was basically nothing.

Thank you alphanuneric and Kids Taxi for the backround and promptly pointing me in the right direction. I just need to sort out the ADCFFT commands.

Regards
Steve

Hi SteveA,
Ive not used the ADC so I can’t help with the command, thogh I would suggest lookin on YouTube at the MicroPython videos for it.

Good Luck

Thanks Kids Taxi, I can see how to use the standard ADC from the pins but not how to handle the ADCFFT lib so as suggested I will look out for a YouTube using that lib. It’s another world from when you did everything yourself using assembler upwards beginning in the 70s with 4004/6500/6800 devices with eproms erased by UV!

Hi SteveA
I did the ZX81 basic and AtariST both machine language programming and a lot of discrete electronic component projects, then started on PicMicrochip programming but stopped through work and family commitments and lost a lot of the knowledge. I’m starting to relearn though it’s slow and frustrating sometimes. Whilst exploring on the net I found the DroneBotWorkshop site, it’s quite informative with good explanations though many of the projects are Arduino there are a significant number of RPi and Pico, its worth a look. The ADC is used reasonably regularly you might find some answers there.

Thanks KT for the DroneBotWorkshop website which looks interesting. I will keep a lookout for the FFT lib. The demos are extremely good and for me it would be great to see the odd link included as a comment in the source pointing to where the parameters of a newly created or ‘rare’ lib was listed.

All the best
Steve

The ADCs on the Pico are a more than a bit iffy at the bottom end. You are supposed to get values in range 0 to 65535 inclusive but you seldom get zero. The lower end can move between 300 and 800 while to potentiometer is turned to zero. You usually want a different range.

This code allows you to get a consistent zero as the bottom value and whatever you want for the maximum.

# Better input from a 10 K Ohm potentiometer
# Tony Goodhew Feb 2023 
# Import the libraries
from machine import ADC, Pin
import time
    
# Set up button on GP15 as INPUT with PULL_DOWN
button = Pin(15, Pin.IN, Pin.PULL_DOWN)

# Set up built-in LED on GP25 of Pi Pico
led = Pin(16, Pin.OUT)

# Set up the potentiometer on ADC pin 26, ADC0
potentiometer = ADC(Pin(26))

pot_min = 800         # Normal minimum raw value - adjust as necessary
pot_range = 65535 - pot_min

def get_ADC(max): # Define a function to read the potentiometer
    # Read the potentiometer value
    pot = potentiometer.read_u16()

    # rescale: new = adjusted_raw * max / original_range
    result = int((pot - pot_min) * max / pot_range) # Integer – whole number

    # Adjust end points as necessary
    if result < 0:             # Bottom end – negative values set to zero
        result = 0
    if result > max:  # Top end – Over sized set to max
        result = max
    return result
    
# === Loop until the button is pressed ===
running = True
led.value(1) # Turn on LED
while running: # Loop start
    pot_value = get_ADC(100) # Get pot reading in range 0 - 100
    print(pot_value)

    if button.value() == 1: # If button is pressed STOP looping
        running = False
    time.sleep(0.2)
    
led.value(0) # Turn off LED

Hope this helps.
The LED is ON while the loop runs. Stop looping by pressing the button.

Hi Tony thanks for showing the method you use to set the span range when reading the adc. I was actually looking for details on the ADC FFT lib (which is seen in one of the pimoroni demos, but there is no information on how to use it and what the params are.) I was hoping someone knew where all the notes were kept as originally mentioned in the post.

Thanks, Steve