europi

package module
v0.0.0-...-5f6ddb0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2022 License: MIT Imports: 8 Imported by: 0

README

EuroPiGo

Alternate firmware for the Allen Synthesis EuroPi written in Go.

Getting started

Install Go

https://go.dev/doc/install

Install TinyGo

https://tinygo.org/getting-started/install

Install the TinyGo VSCode plugin

https://marketplace.visualstudio.com/items?itemName=tinygo.vscode-tinygo

Build the example

Use the tinygo flash command while your pico is in BOOTSEL mode to compile the script and copy it to your attached EuroPi pico.

tinygo flash --target pico examples/diagnostics.go

NOTE: After the first time you flash your TinyGo program you will no longer need to reboot in BOOTSEL mode to flash your script. Sweet!

Serial printing

When your EuroPi pico is connected via USB you can view printed serial output using a tool like minicom.

For example, a line in your code like:

println(fmt.Sprintf("K1: %2.2f", e.K1.ReadVoltage()))

NOTE: Using the println function handles newlines better than fmt.Println in minicom output.

You can launch minicom to view the printed output:

minicom -b 115200 -o -D /dev/ttyACM0

VSCode build task

Add the TinyGo flash command as your default build task:

Ctrl + Shift + P > Tasks: Configure Default Build Task

Use the following example task configuration to set tinygo flash as your default build command:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "tinygo flash",
            "type": "shell",
            "command": "tinygo flash --target pico -size short -opt 1 ${workspaceRoot}/examples",
            "group": {
                "kind": "build",
                "isDefault": true
            },
        }
    ]
}

Now you can build and flash your project using Ctrl + Shift + B or search for the command:

Ctrl + Shift + P > Tasks: Run Build Task

Debugging using picoprobe

TODO

Why should I use this?

You probably shouldn't. This is my passion project because I love Go. You should probably be using the official EuroPi firmware. But if you are interested in writing a dedicated script for the EuroPi that requires concurrency and faster performance than MicroPython can offer, then maybe this is the right firmware for you!

Documentation

Index

Constants

View Source
const (
	// Calibrated[Min|Max]AI was calculated using the EuroPi calibration program:
	// https://github.com/Allen-Synthesis/EuroPi/blob/main/software/programming_instructions.md#calibrate-the-module
	CalibratedMinAI = 384
	CalibratedMaxAI = 44634

	DefaultSamples = 1000
)
View Source
const (
	OLEDFreq   = machine.TWI_FREQ_400KHZ
	OLEDAddr   = 0x3C
	OLEDWidth  = 128
	OLEDHeight = 32
)
View Source
const (
	MaxVoltage = 10.0
	MinVoltage = 0.0
)
View Source
const (
	// Manually calibrated to best match expected voltages. Additional info:
	// https://github.com/Allen-Synthesis/EuroPi/blob/main/software/programming_instructions.md#calibrate-the-module
	CalibratedOffset = 32
	// The default PWM Top of MaxUint16 caused noisy output. Dropping this down to a 12bit value resulted in much smoother cv output.
	CalibratedTop = 0xfff - CalibratedOffset
)

Variables

View Source
var (
	DefaultChannel = machine.I2C0
	DefaultFont    = &proggy.TinySZ8pt7b
	White          = color.RGBA{255, 255, 255, 255}
)
View Source
var DefaultDebounceDelay time.Duration

Functions

func Clamp

func Clamp(value, low, high int) int

Types

type AnalogInput

type AnalogInput struct {
	machine.ADC
	// contains filtered or unexported fields
}

func NewAI

func NewAI(pin machine.Pin) *AnalogInput

func (*AnalogInput) Percent

func (a *AnalogInput) Percent() float32

func (*AnalogInput) Range

func (a *AnalogInput) Range(steps int) int

func (*AnalogInput) ReadVoltage

func (a *AnalogInput) ReadVoltage() float32

func (*AnalogInput) Samples

func (a *AnalogInput) Samples(samples int)

type AnalogReader

type AnalogReader interface {
	Samples(samples int)
	ReadVoltage() float32
	Percent() float32
	Range(steps int) int
}

type Button

type Button struct {
	Pin machine.Pin
	// contains filtered or unexported fields
}

func NewButton

func NewButton(pin machine.Pin) *Button

func (*Button) Handler

func (b *Button) Handler(handler func(p machine.Pin))

func (*Button) LastInput

func (b *Button) LastInput() time.Time

func (*Button) Value

func (b *Button) Value() bool

type DigitalInput

type DigitalInput struct {
	Pin machine.Pin
	// contains filtered or unexported fields
}

func NewDI

func NewDI(pin machine.Pin) *DigitalInput

func (*DigitalInput) Handler

func (d *DigitalInput) Handler(handler func(p machine.Pin))

func (*DigitalInput) LastInput

func (d *DigitalInput) LastInput() time.Time

func (*DigitalInput) Value

func (d *DigitalInput) Value() bool

type DigitalReader

type DigitalReader interface {
	Handler(func(machine.Pin))
	LastInput() time.Time
	Value() bool
}

type Display

type Display struct {
	ssd1306.Device
	// contains filtered or unexported fields
}

func NewDisplay

func NewDisplay(channel *machine.I2C, sdaPin, sclPin machine.Pin) *Display

func (*Display) Font

func (d *Display) Font(font *tinyfont.Font)

func (*Display) WriteLine

func (d *Display) WriteLine(text string, x, y int16)

type EuroPi

type EuroPi struct {
	DI DigitalReader
	AI AnalogReader

	// Display is a wrapper around ssd1306.Device
	Display *Display

	B1 DigitalReader
	B2 DigitalReader

	K1 AnalogReader
	K2 AnalogReader

	CV1 Outputer
	CV2 Outputer
	CV3 Outputer
	CV4 Outputer
	CV5 Outputer
	CV6 Outputer
}

func New

func New() EuroPi

type Knob

type Knob struct {
	machine.ADC
	// contains filtered or unexported fields
}

func NewKnob

func NewKnob(pin machine.Pin) *Knob

func (*Knob) Percent

func (k *Knob) Percent() float32

func (*Knob) Range

func (k *Knob) Range(steps int) int

func (*Knob) ReadVoltage

func (k *Knob) ReadVoltage() float32

func (*Knob) Samples

func (k *Knob) Samples(samples int)

type Output

type Output struct {
	// contains filtered or unexported fields
}

func NewOutput

func NewOutput(pin machine.Pin, pwm PWMer) *Output

func (*Output) Get

func (o *Output) Get() uint32

func (*Output) Off

func (o *Output) Off()

func (*Output) On

func (o *Output) On()

func (*Output) Voltage

func (o *Output) Voltage(v float32)

type Outputer

type Outputer interface {
	Get() (value uint32)
	Voltage(v float32)
	On()
	Off()
}

type PWMer

type PWMer interface {
	Configure(config machine.PWMConfig) error
	Channel(pin machine.Pin) (channel uint8, err error)
	Top() uint32
	SetTop(top uint32)
	Get(channel uint8) (value uint32)
	Set(channel uint8, value uint32)
	SetPeriod(period uint64) error
}

PWMer is an interface for interacting with a machine.pwmGroup

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL