bootstrap

package module
v0.0.0-...-0cb7d88 Latest Latest
Warning

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

Go to latest
Published: May 6, 2023 License: MIT Imports: 13 Imported by: 0

README

europi-bootstrap

Bootstrap functionality for the TinyGo EuroPi firmware components (see https://github.com/awonak/EuroPiGo)

Documentation

Index

Constants

View Source
const (
	DefaultAppMainLoopInterval time.Duration = time.Millisecond * 100
)
View Source
const (
	DefaultEnableDisplayLogger bool = false
)
View Source
const (
	DefaultInitRandom bool = true
)
View Source
const (
	DefaultUIRefreshRate time.Duration = time.Millisecond * 100
)
View Source
const LongPressDuration = time.Millisecond * 650

LongPressDuration is the amount of time a button is in a held/pressed state before it is considered to be a 'long' press. TODO: This is eventually intended to be a persisted setting, configurable by the user.

Variables

View Source
var DefaultPanicHandler func(e europi.Hardware, reason any)

DefaultPanicHandler is the default handler for panics This will be set by the build flag `onscreenpanic` to `handlePanicOnScreenLog` Not setting the build flag will set it to `handlePanicDisplayCrash`

Functions

func Bootstrap

func Bootstrap(pi europi.Hardware, options ...BootstrapOption) error

Bootstrap will set up a global runtime environment (see europi.Pi)

func DefaultBootstrapCompleted

func DefaultBootstrapCompleted(e europi.Hardware)

func DefaultMainLoop

func DefaultMainLoop(e europi.Hardware, deltaTime time.Duration)

DefaultMainLoop is the default main loop used if a new one is not specified to Bootstrap()

func DefaultPostBootstrapInitialization

func DefaultPostBootstrapInitialization(e europi.Hardware)

func ForceRepaintUI

func ForceRepaintUI(e europi.Hardware)

ForceRepaintUI schedules a forced repaint of the UI (if it is configured and running)

func Shutdown

func Shutdown(e europi.Hardware, reason any) error

Types

type AppEndFunc

type AppEndFunc func(e europi.Hardware)

type AppMainLoopFunc

type AppMainLoopFunc func(e europi.Hardware, deltaTime time.Duration)

type AppStartFunc

type AppStartFunc func(e europi.Hardware)

type ApplicationEnd

type ApplicationEnd[THardware europi.Hardware] interface {
	End(e THardware)
}

type ApplicationMainLoop

type ApplicationMainLoop[THardware europi.Hardware] interface {
	MainLoop(e THardware, deltaTime time.Duration)
}

type ApplicationStart

type ApplicationStart[THardware europi.Hardware] interface {
	Start(e THardware)
}

type BeginDestroyFunc

type BeginDestroyFunc func(e europi.Hardware, reason any)

type BootstrapAppOption

type BootstrapAppOption func(o *bootstrapAppConfig) error

BootstrapAppOption is a single configuration parameter passed to the App() or AppOption() functions

func AppMainLoopInterval

func AppMainLoopInterval(interval time.Duration) BootstrapAppOption

AppMainLoopInterval sets the interval between calls to the configured app main loop function

type BootstrapCompletedFunc

type BootstrapCompletedFunc func(e europi.Hardware)

type BootstrapOption

type BootstrapOption func(o *bootstrapConfig) error

BootstrapOption is a single configuration parameter passed to the Bootstrap() function

func App

func App(app any, opts ...BootstrapAppOption) BootstrapOption

App sets the application handler interface with optional parameters

func AppEnd

func AppEnd(fn AppEndFunc) BootstrapOption

AppEnd sets the application function that's called right before the bootstrap destruction processing is performed.

func AppMainLoop

func AppMainLoop(fn AppMainLoopFunc) BootstrapOption

AppMainLoop sets the application main loop function to be called on interval. nil is not allowed - if you want to set the default, either do not specify a AppMainLoop() option or specify europi.DefaultMainLoop

func AppOptions

func AppOptions(option BootstrapAppOption, opts ...BootstrapAppOption) BootstrapOption

AppOptions adds optional parameters for setting up the application interface

func AppStart

func AppStart(fn AppStartFunc) BootstrapOption

AppStart sets the application function to be called before the main operating loop processing begins. At this point, the bootstrap configuration has completed and all bootstrap functionality may be used without fear of there being an incomplete operating state.

func AttachNonPicoWS

func AttachNonPicoWS(enabled bool) BootstrapOption

AttachNonPicoWS (if enabled and on non-Pico builds with build flags of `-tags=revision1` set) starts up a websocket interface and system debugger on port 8080

func BeginDestroy

func BeginDestroy(fn BeginDestroyFunc) BootstrapOption

BeginDestroy sets the function that receives the notification of shutdown of the bootstrap and is also the first stop within the `panic()` handler functionality. If the `reason` parameter is non-nil, then a critical failure has been detected and the bootstrap is in the last stages of complete destruction. If it is nil, then it can be assumed that proper functionality of the bootstrap is still available, but heading towards the last steps of unavailability once the function exits.

func BootstrapCompleted

func BootstrapCompleted(fn BootstrapCompletedFunc) BootstrapOption

BootstrapCompleted sets the function that receives notification of critical bootstrap operations being complete - this is the first point where functions within the bootstrap may be used without fear of there being an incomplete operating state.

func EnableDisplayLogger

func EnableDisplayLogger(enabled bool) BootstrapOption

EnableDisplayLogger enables (or disables) the logging of `log.Printf` (and similar) messages to the EuroPi's display. Enabling this will likely be undesirable except in cases where on-screen debugging is absoluely necessary.

func FinishDestroy

func FinishDestroy(fn FinishDestroyFunc) BootstrapOption

FinishDestroy sets the function that receives the final notification of shutdown of the bootstrap. The entire bootstrap is disabled, all timers, queues, and components are considered deactivated.

func InitRandom

func InitRandom(enabled bool) BootstrapOption

InitRandom enables (or disables) the initialization of the Go standard library's `rand` package Seed value. Disabling this will likely be undesirable except in cases where deterministic 'random' number generation is required, as the standard library `rand` package defaults to a seed of 1 instead of some pseudo-random number, like current time or thermal values. To generate a pseudo-random number for the random seed, the `machine.GetRNG` function is used.

func PostBootstrapConstruction

func PostBootstrapConstruction(fn PostBootstrapConstructionFunc) BootstrapOption

PostBootstrapConstruction sets the function that runs immediately after primary EuroPi bootstrap has finished, but before components have been initialized. Nearly none of the functionality of the bootstrap is ready or configured at this point.

func PostInitializeComponents

func PostInitializeComponents(fn PostInitializeComponentsFunc) BootstrapOption

PostInitializeComponents sets the function that recevies notification of when components of the bootstrap have completed their initialization phase and the bootstrap is nearly ready for full operation. Some operational functionality of the bootstrap might not be configured at this point.

func PreInitializeComponents

func PreInitializeComponents(fn PreInitializeComponentsFunc) BootstrapOption

PreInitializeComponents sets the function that recevies notification of when components of the bootstrap are about to start their initialization phase and the bootstrap is getting ready. Most operational functionality of the bootstrap is definitely not configured at this point.

func UI

UI sets the user interface handler interface

func UIOptions

func UIOptions(option BootstrapUIOption, opts ...BootstrapUIOption) BootstrapOption

UIOptions adds optional parameters for setting up the user interface

type BootstrapUIOption

type BootstrapUIOption func(o *bootstrapUIConfig) error

BootstrapOption is a single configuration parameter passed to the Bootstrap() function

func UIRefreshRate

func UIRefreshRate(interval time.Duration) BootstrapUIOption

UIRefreshRate sets the interval of refreshes of the user interface

type FinishDestroyFunc

type FinishDestroyFunc func(e europi.Hardware)

type PostBootstrapConstructionFunc

type PostBootstrapConstructionFunc func(e europi.Hardware)

type PostInitializeComponentsFunc

type PostInitializeComponentsFunc func(e europi.Hardware)

type PreInitializeComponentsFunc

type PreInitializeComponentsFunc func(e europi.Hardware)

type UserInterface

type UserInterface[THardware europi.Hardware] interface {
	Start(e THardware)
	Paint(e THardware, deltaTime time.Duration)
}

type UserInterfaceButton1

type UserInterfaceButton1[THardware europi.Hardware] interface {
	Button1(e THardware, deltaTime time.Duration)
}

type UserInterfaceButton1Debounce

type UserInterfaceButton1Debounce interface {
	Button1Debounce() time.Duration
}

type UserInterfaceButton1Ex

type UserInterfaceButton1Ex[THardware europi.Hardware] interface {
	Button1Ex(e THardware, value bool, deltaTime time.Duration)
}

type UserInterfaceButton1Long

type UserInterfaceButton1Long[THardware europi.Hardware] interface {
	Button1Long(e THardware, deltaTime time.Duration)
}

type UserInterfaceButton2

type UserInterfaceButton2[THardware europi.Hardware] interface {
	Button2(e THardware, deltaTime time.Duration)
}

type UserInterfaceButton2Debounce

type UserInterfaceButton2Debounce interface {
	Button2Debounce() time.Duration
}

type UserInterfaceButton2Ex

type UserInterfaceButton2Ex[THardware europi.Hardware] interface {
	Button2Ex(e THardware, value bool, deltaTime time.Duration)
}

type UserInterfaceButton2Long

type UserInterfaceButton2Long[THardware europi.Hardware] interface {
	Button2Long(e THardware, deltaTime time.Duration)
}

type UserInterfaceLogoPainter

type UserInterfaceLogoPainter[THardware europi.Hardware] interface {
}

Jump to

Keyboard shortcuts

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