gotogen

package module
v0.0.0-...-43e2d86 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2023 License: BSD-3-Clause Imports: 14 Imported by: 2

README

Gotogen

Protogen, the Go way.

Highly volatile during active development. For ease of my own development, there are replace directives in go.mod to use relative paths for the related modules (go.work wasn't working for me). I will attempt to keep all the repositories up to date. You will need to either remove the replace directives, or have all the repositories checked out next to each other.

Documentation

Index

Constants

View Source
const (
	// SensorStatusUnavailable indicates that the sensor is never available (not implemented in hardware).
	SensorStatusUnavailable = iota
	// SensorStatusAvailable indicates that the returned value(s) is/are accurate.
	SensorStatusAvailable
	// SensorStatusBusy indicates that the sensor is temporarily unavailable e.g. due to bus contention.
	SensorStatusBusy
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionItem

type ActionItem struct {
	Name   string
	Invoke func()
}

type Blinker

type Blinker interface {
	Low()
	High()
}

type Display

type Display interface {
	drivers.Displayer

	// CanUpdateNow indicates that the device is able to take a new frame right now. This is useful if the device is
	// driven by a DMA transfer, and the previous transfer has not yet completed. Displays should still support Display
	// being called before they are ready to update; in this case, they should block until the next update is possible.
	CanUpdateNow() bool
}

type Driver

type Driver interface {
	// EarlyInit initializes secondary devices after the primary menu display has been initialized for boot
	// messages. Hardware drivers shall configure any buses (SPI, etc.) that are required to communicate with these
	// devices at this point, and should only configure the bare minimum to call New.
	EarlyInit() (faceDisplay Display, err error)

	// LateInit performs any late initialization (e.g. connecting to wifi to set the clock). The failure of anything in
	// LateInit should not cause the failure of the entire process. Boot messages may be freely logged.
	//
	// TODO interface
	LateInit(buffer *textbuf.Buffer)

	// PressedButton returns the currently-pressed menu button. The implementation is responsible for prioritizing
	// multiple buttons being pressed at the same time however it sees fit (or implement some buttons as a chord of
	// multiple physical buttons), as well as handling debouncing (if needed) and button repeating. Basically, this
	// should only return a value when that value should be acted upon.
	//
	// This function should expect to be called at the main loop framerate.
	PressedButton() MenuButton

	// MenuItems is invoked every time the menu is displayed to retrieve the current menu items for the driver.
	// The driver may return different menu items depending on current state.
	MenuItems() []Item

	// BoopDistance is a normalized value for the closeness of a boop. TODO define the normalization
	// The second return value indicates the status of the boop sensor: does not exist, valid data, or busy.
	BoopDistance() (uint8, SensorStatus)

	// Accelerometer is a normalized value for accelerometer values. TODO define the scale of the normalized values
	// When not in motion, all values should be approximately zero. TODO actually implement that
	// Drivers should provide a calibration option to zero out the sensor.
	// The second return value indicates the status of the accelerometer: does not exist, valid data, or busy.
	Accelerometer() (x, y, z int32, status SensorStatus)

	// Talking indicates if the driver has detected speech and the face should animate talking.
	Talking() bool

	// StatusLine returns a textual status indicator that the driver may use for whatever it wishes.
	//
	// For the current hardware implementation of a 128x64 OLED display with the 6x8 font, this cannot be more than 21
	// characters. Other hardware implementations may have different limits, but since the hardware implementation is
	// what is returning this line, it should know better.
	StatusLine() string
}

type Gotogen

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

func New

func New(framerate uint, status Display, blinker Blinker, driver Driver) (*Gotogen, error)

func (*Gotogen) Busy

func (g *Gotogen) Busy(f func(buffer *textbuf.Buffer))

func (*Gotogen) Display

func (g *Gotogen) Display() error

func (*Gotogen) Init

func (g *Gotogen) Init() error

func (*Gotogen) Run

func (g *Gotogen) Run()

Run does not return. It attempts to run the main loop at the framerate specified in New.

func (*Gotogen) RunTick

func (g *Gotogen) RunTick() error

RunTick runs a single iteration of the main loop.

func (*Gotogen) SetPixel

func (g *Gotogen) SetPixel(x, y int16, c color.RGBA)

func (*Gotogen) Size

func (g *Gotogen) Size() (x, y int16)

func (*Gotogen) Talking

func (g *Gotogen) Talking() bool

type Item

type Item interface {
	// contains filtered or unexported methods
}
type Menu struct {
	Name  string
	Items []Item
	// contains filtered or unexported fields
}
func (m *Menu) Len() uint8
func (m *Menu) Prev() Menuable
func (m *Menu) Render(buf *textbuf.Buffer)
func (m *Menu) Selected() uint8
func (m *Menu) SetPrev(p Menuable)
func (m *Menu) SetSelected(s uint8)
func (m *Menu) SetTop(t uint8)
func (m *Menu) Top() uint8
type MenuButton uint8
const (
	MenuButtonNone MenuButton = iota
	MenuButtonMenu
	MenuButtonBack
	MenuButtonUp
	MenuButtonDown
	// MenuButtonDefault is for resetting a specific setting to its default value. Drivers may wish to require this
	// button to be held down for a second before triggering it, or perhaps make it be a chord of up and down.
	MenuButtonDefault
)
func (b MenuButton) String() string
type MenuProvider interface {
	GetMenu() Menu
}
type Menuable interface {
	Top() uint8
	SetTop(uint8)
	Selected() uint8
	SetSelected(uint8)
	Render(*textbuf.Buffer)
	Len() uint8
	Prev() Menuable
	SetPrev(Menuable)
}

type SensorStatus

type SensorStatus uint8

type SettingItem

type SettingItem struct {
	Name    string
	Options []string
	Default uint8
	Active  uint8

	Apply func(selected uint8)
	// contains filtered or unexported fields
}

func (*SettingItem) Len

func (si *SettingItem) Len() uint8

func (*SettingItem) Prev

func (si *SettingItem) Prev() Menuable

func (*SettingItem) Render

func (si *SettingItem) Render(buf *textbuf.Buffer)

func (*SettingItem) Selected

func (si *SettingItem) Selected() uint8

func (*SettingItem) SetPrev

func (si *SettingItem) SetPrev(p Menuable)

func (*SettingItem) SetSelected

func (si *SettingItem) SetSelected(s uint8)

func (*SettingItem) SetTop

func (si *SettingItem) SetTop(t uint8)

func (*SettingItem) Top

func (si *SettingItem) Top() uint8

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

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