Pimoroni pico breakout garden base no i2c devices found

Is this maybe the 4 boxes? I’d play around with those numbers and see what happens?

    b_0 = [8, 16, 32, 110]
    b_1 = [8, 16, 32, 50]
    b_x = [58, 71, 91, 10]
    b_y = [17, 15, 28, 69]

For me in Micro Python it goes something like this.
For the circle it’s position x,y, then how big
For the rectangle its position x,y then width and height. Something like that?

    # draw a barometer
    display.set_pen(125, 125, 125)
    display.circle(200, 190, 20)
    display.rectangle(190, 15, 23, 160)
    display.set_pen(presscolor)
    display.circle(200, 190, 10)
    barometerheight = int((pressuremb - 960) * 1.4)
    if barometerheight > 150:
        barometerheight = 150
    if barometerheight < 1:
        barometerheight = 1
    display.rectangle(196, 60 + 120 - barometerheight, 10, barometerheight)

The original script that I thouroughly modified is at:
https://learn.adafruit.com/adafruit-monochrome-1-12-in-128x128-oled/circuitpython

The original way of drawing the boxes is:

# Draw some white squares
small_bitmap = displayio.Bitmap(8, 8, 1)
small_square = displayio.TileGrid(small_bitmap, pixel_shader=color_palette, x=58, y=17)
splash.append(small_square)

medium_bitmap = displayio.Bitmap(16, 16, 1)
medium_square = displayio.TileGrid(
    medium_bitmap, pixel_shader=color_palette, x=71, y=15
)
splash.append(medium_square)

large_bitmap = displayio.Bitmap(32, 32, 1)
large_square = displayio.TileGrid(large_bitmap, pixel_shader=color_palette, x=91, y=28)
splash.append(large_square)

bottom_bitmap = displayio.Bitmap(110, 50, 1)
bottom_rectangle = displayio.TileGrid(
    bottom_bitmap, pixel_shader=color_palette, x=10, y=69
)
splash.append(bottom_rectangle)

As I, after ‘dividing’ the one-string-script’ into a ‘boxed’ type of script, using a main function calling a setup function and calling a draw function. One of the positive things of the ‘boxing’ is that it gives the opportunity to use local variables that are only known within the function (‘boxed’). Nevertheless, after some iterations of the script, it crashed with a lack of memory error. In an attempt to tackle that error I made several alterations. One of them: use less different variables. As you can see in the original way of drawing four boxes the script is using at least 8 different variables. From a teaching point of view this is OK: they gave the variables names that refer to the kind of box they were drawing. Besides using more variables. The original algorithm of the box-drawing also repeats four times the same set of three lines of code. I choose for a “for _ in range(le):” loop whereby avoiding use of multiple variables, instead re-use of variables. This for… loop only uses 2 variables bm (= bitmap) and sq (= square). An than, of course, the elements of the lists for the values that change. But there are also values used at those places in the original script. Sure, my way makes the script less readable, at first sight. On the other hand, my algorithm makes it better maintainable, less prone to errors. As you can see in my script: I use several lists of equal length containing the values that are particular to each box. The use of “_” in the for… loop heading is a method I read in a book about python. I don’t remember which one. I also don’t remember the name the author gave to it. I go to look for it. When I find it I’ll come back with it. Anyway it is a method to not having to use a variable as a counter/indexer inside the loop.

OK, your way ahead of me and my current skill level. I’m not bad Python wise, still learning Micro Python wise, and head scratching with Circuit Python.

OK, I also learn every day new things. That’s the interesting part of our hobby isn’t it? I wish you good luck with your experiments.

1 Like

I’m learning new stuff all the time. I find this a very interesting and very rewarding hobby.