tinygo-org / drivers

TinyGo drivers for sensors, displays, wireless adaptors, and other devices that use I2C, SPI, GPIO, ADC, and UART interfaces.
https://tinygo.org
BSD 3-Clause "New" or "Revised" License
622 stars 196 forks source link

package machine is not in GOROOT #697

Open budzonmichal opened 4 months ago

budzonmichal commented 4 months ago

Regardint his thread: https://github.com/golang/go/issues/43079

Some time passed, but this issue still appears:

$ go build
../../pkg/mod/tinygo.org/x/drivers@v0.28.0/st7789/st7789.go:10:2: package machine is not in GOROOT (/usr/local/go/src/machine)
../../pkg/mod/github.com/tinygo-org/tinygo@v0.32.0/src/machine/buffer.go:4:2: package runtime/volatile is not in GOROOT (/usr/local/go/src/runtime/volatile)

What is the way, any woarkaround maybe, to builds and use tinygo drivers in my project ?

use case:


package main

import (
    "image/color"

    "github.com/tinygo-org/tinygo/src/machine" // suggested workaround
// anyway I got error while importing github.com/tinygo-org/tinygo/src/machine: package runtime/volatile is not in GOROOT (/usr/local/go/src/runtime/volatile)compiler

    "tinygo.org/x/drivers/st7789"
)

func main() {

    // Example configuration for Adafruit Clue
    // machine.SPI1.Configure(machine.SPIConfig{
    //  Frequency: 8000000,
    //  SCK:       machine.TFT_SCK,
    //  SDO:       machine.TFT_SDO,
    //  SDI:       machine.TFT_SDO,
    //  Mode:      0,
    // })
    // display := st7789.New(machine.SPI1,
    //  machine.TFT_RESET,
    //  machine.TFT_DC,
    //  machine.TFT_CS,
    //  machine.TFT_LITE)

    machine.SPI0.Configure(machine.SPIConfig{
        Frequency: 8000000,
        Mode:      0,
    })
    display := st7789.New(machine.SPI0,
        machine.P6, // TFT_RESET
        machine.P7, // TFT_DC
        machine.P8, // TFT_CS
        machine.P9) // TFT_LITE

    (...)
}```