Pico Explorer - TinyGo

I have recently started to try TinyGo (www.tinygo.org : A Go Compiler For Small Places) on the Pico Explorer which is an excellent starter board for exploring the RPI Pico features. I have a Blinky and CPU access details working but found it impossible to raise a smile from the ST7789 display. I used the example from the TinyGo Github (drivers/examples/st7789 at release · tinygo-org/drivers · GitHub ) but I am confused by the pin labelling (e.g. reset, dc, cs, bl,) in the functions. Is there a working example that exists of “Hello World” on the ST7789 using TinyGo on the Pico Explorer? Python examples work so I am sure the ST7789 is OK.

Why TinyGo? It produces very small executables (my initial Blinky used less that 10KB of Flash and less than 3KB of RAM) and has performance comparable to C/C++ with a syntax that anyone using Python can easily learn. I think TinyGo language support would make an excellent addition to the Pimoroni offering.

you probably have to manually define your spi. On a pico, spi can be on multiple pins, so there is no fixed spi0 or spi1.

I think I am on the right track with using SPI0 using pins 16,17,18 and 19 as these are written for use on the back of the Pico Explorer. I used the following function from the TinyGo website to configure SPI0:

machine.SPI0.Configure(machine.SPIConfig{
Frequency: 115200,
DataBits: 8,
SCK: machine.GP18, // SCK
SDO: machine.GP19, // TX MOSI
SDI: machine.GP16, // RX MISO
})

but I must also set up the display and for this I have the following where it seems to want machine.pins but which ones I can’t get other than GP17 for CS on the Pico Explorer. (btw … everything after // are just comments in Go.)

display := st7789.New(machine.SPI0,
?, // resetPin
?, // dcPin
machine.GP17, // csPin
?) // blPin

I have configure the display as follows:

display.Configure(st7789.Config{
	Width:        240,                                          // int16
	Height:       240,                                         // int16
	Rotation:     st7789.NO_ROTATION,         // Rotation
	RowOffset:    0,                                          // int16
	ColumnOffset: 0,                                        // int16
	FrameRate:    st7789.FRAMERATE_111   // framerate
	VSyncLines:   st7789.MAX_VSYNC_SCANLINES,  // int16
})

Any ideas/pointers welcome as I am sure I am just on a different wavelength.

I have the following pins set:

machine.SPI0.Configure(machine.SPIConfig{
Frequency: 115200,
DataBits: 8,
SCK: machine.GP18, // SCK
SDO: machine.GP19, // TX MOSI
SDI: machine.GP16, // RX MISO
})

(“//” are just comments in Go)

but there is also a set up function for the display.

display := st7789.New(machine.SPI0,
?, // resetPin
?, // dcPin
machine.GP17, // csPin
?) // blPin

I have tried various pins but the Pico Explorer (apart from CS) doesn’t mention any of these on the pin labels and I can find nothin in the various documentation etc.

Any pointers/ideas welcome.

Take a look at the schematic. This will tell you the correct SPI-pins. You will also see that there is neither a backlight (BL) pin nor a reset pin. But that should be no problem unless your driver insists on these pins.

I think the D/C pin is labeled as MISO in the schematic, which is not correct.

Many thanks. That gives me a clue. I will look at the driver and see what it actually does with the D/C and BL pins . There appear to only 4 racks on the board to the display so I am guessing it only ever uses 16…19 (SPI MISO, LCD CS, SPI SCK,SPI MOSI) and that I can somehow get it to ignore the other pins. This may take me a few days to ge to but I’ll update this post on how I get on.

Again, thanks for your help.

Yes, and for this display you only need four wires. D/C is data/command, and that tells the display controller if you are sending a command or data. Since the display (in old terms “slave”) does not “talk” to the Pico (in old terms “master”) there is no classical SPI MISO (master in, slave out). That is why I think it is just mislabeled.

The BL (backlight) pin usually is a PWM-pin to control the backlight of the display. It is not strictly necessary. When I wire my displays I usually connect the LEDs of the display to Vcc or use a trim-poti to control brightness.

But I took a quick look at your go-driver and that driver actually expects and uses the backlight and reset pins. So what you can do is try to fool the driver by providing two of the spare pins of the pico which are then “controlled” by the driver but actually do nothing.