gui

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: Unlicense Imports: 30 Imported by: 0

Documentation

Overview

package gui implements the SeedHammer controller user interface.

Index

Constants

This section is empty.

Variables

View Source
var (
	EngraveFirstSideA = []Instruction{
		{
			Body: "Make sure the fingerprint above represents the intended share.",
			Lead: "seedhammer.com/tip#1",
		},
		{
			Body: "Turn off the engraver and disconnect it from this device.",
			Lead: "seedhammer.com/tip#2",
		},
		{
			Body: "Manually move the hammerhead to the far upper left position.",
			Lead: "seedhammer.com/tip#3",
		},
		{
			Body:  "Place a {{.Name}} on the machine.",
			Image: assets.Sh02,
			Lead:  "seedhammer.com/tip#4",
		},
		{
			Body: "Tighten the nuts firmly.",
			Lead: "seedhammer.com/tip#4",
		},
		{
			Body: "Loosen the hammerhead finger screw. Adjust needle distance to ~1.5 mm above the plate.",
			Lead: "seedhammer.com/tip#5",
		},
		{
			Body: "Tighten the hammerhead finger screw and make sure the depth selector is set to \"Strong\".",
			Lead: "seedhammer.com/tip#6",
		},
		{
			Body: "Turn on the engraving machine and connect this device via the middle port.",
			Lead: "seedhammer.com/tip#7",
		},
		{
			Body: "Hold button to start the engraving process. The process is loud, use hearing protection.",
			Type: ConnectInstruction,
			Lead: "seedhammer.com/tip#8",
		},
		{
			Lead: "Engraving plate",
			Type: EngraveInstruction,
			Side: 0,
		},
	}

	EngraveSideA = []Instruction{
		{
			Body: "Make sure the fingerprint above represents the intended share.",
			Lead: "seedhammer.com/tip#1",
		},
		{
			Body:  "Place a {{.Name}} on the machine.",
			Image: assets.Sh02,
			Lead:  "seedhammer.com/tip#4",
		},
		{
			Body: "Tighten the nuts firmly.",
			Lead: "seedhammer.com/tip#4",
		},
		{
			Body: "Hold button to start the engraving process. The process is loud, use hearing protection.",
			Type: ConnectInstruction,
			Lead: "seedhammer.com/tip#8",
		},
		{
			Lead: "Engraving plate",
			Type: EngraveInstruction,
			Side: 0,
		},
	}

	EngraveSideB = []Instruction{
		{
			Body: "Unscrew the 4 nuts and flip the top metal plate horizontally.",
		},
		{
			Body: "Tighten the nuts firmly.",
		},
		{
			Body: "Hold button to start the engraving process. The process is loud, use hearing protection.",
			Type: ConnectInstruction,
		},
		{
			Lead: "Engraving plate",
			Type: EngraveInstruction,
			Side: 1,
		},
	}

	EngraveSuccess = []Instruction{
		{
			Body: "Engraving completed successfully.",
		},
	}
)

Functions

This section is empty.

Types

type AddressesScreen added in v0.12.0

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

func NewAddressesScreen added in v0.12.0

func NewAddressesScreen(desc urtypes.OutputDescriptor) *AddressesScreen

func (*AddressesScreen) Show added in v1.3.0

func (s *AddressesScreen) Show(ctx *Context, ops op.Ctx, th *Colors)

type App

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

func NewApp

func NewApp(pl Platform, version string) (*App, error)

func (*App) Frame

func (a *App) Frame()

type Button added in v1.2.0

type Button int
const (
	Up Button = iota
	Down
	Left
	Right
	Center
	Button1
	Button2
	Button3
	CCW
	CW
	// Synthetic keys only generated in debug mode.
	Rune // Enter rune.
)

func (Button) String added in v1.3.0

func (b Button) String() string

type ButtonEvent added in v1.2.0

type ButtonEvent struct {
	Button  Button
	Pressed bool
	// Rune is only valid if Button is Rune.
	Rune rune
}

func (ButtonEvent) Event added in v1.3.0

func (b ButtonEvent) Event() Event

type ButtonStyle

type ButtonStyle int
const (
	StyleNone ButtonStyle = iota
	StyleSecondary
	StylePrimary
)

type ChoiceScreen

type ChoiceScreen struct {
	Title   string
	Lead    string
	Choices []string
	// contains filtered or unexported fields
}

func (*ChoiceScreen) Choose added in v1.3.0

func (s *ChoiceScreen) Choose(ctx *Context, ops op.Ctx, th *Colors) (int, bool)

func (*ChoiceScreen) Draw added in v1.3.0

func (s *ChoiceScreen) Draw(ctx *Context, ops op.Ctx, th *Colors, dims image.Point)

type Colors

type Colors struct {
	Background color.NRGBA
	Text       color.NRGBA
	Primary    color.NRGBA
}

type ConfirmDelay

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

func (*ConfirmDelay) Progress

func (c *ConfirmDelay) Progress(ctx *Context) float32

func (*ConfirmDelay) Start

func (c *ConfirmDelay) Start(ctx *Context, delay time.Duration)

type ConfirmResult

type ConfirmResult int
const (
	ConfirmNone ConfirmResult = iota
	ConfirmNo
	ConfirmYes
)

type ConfirmWarningScreen

type ConfirmWarningScreen struct {
	Title string
	Body  string
	Icon  image.RGBA64Image
	// contains filtered or unexported fields
}

func (*ConfirmWarningScreen) Layout

func (s *ConfirmWarningScreen) Layout(ctx *Context, ops op.Ctx, th *Colors, dims image.Point) ConfirmResult

type Context

type Context struct {
	Platform Platform
	Styles   Styles
	Wakeup   time.Time
	Frame    func()

	// Global UI state.
	Version        string
	Calibrated     bool
	EmptySDSlot    bool
	RotateCamera   bool
	LastDescriptor *urtypes.OutputDescriptor
	// contains filtered or unexported fields
}

func NewContext

func NewContext(pl Platform) *Context

func (*Context) Events

func (c *Context) Events(evts ...Event)

func (*Context) FrameEvent added in v1.3.0

func (c *Context) FrameEvent() (FrameEvent, bool)

func (*Context) Next

func (c *Context) Next(btns ...Button) (ButtonEvent, bool)

func (*Context) Reset added in v1.2.0

func (c *Context) Reset()

func (*Context) WakeupAt added in v1.2.0

func (c *Context) WakeupAt(t time.Time)

type DescriptorScreen

type DescriptorScreen struct {
	Descriptor urtypes.OutputDescriptor
	Mnemonic   bip39.Mnemonic
}

func (*DescriptorScreen) Confirm added in v1.3.0

func (s *DescriptorScreen) Confirm(ctx *Context, ops op.Ctx, th *Colors) (int, bool)

func (*DescriptorScreen) Draw added in v1.3.0

func (s *DescriptorScreen) Draw(ctx *Context, ops op.Ctx, th *Colors, dims image.Point)

type EngraveScreen

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

func NewEngraveScreen

func NewEngraveScreen(ctx *Context, plate Plate) *EngraveScreen

func (*EngraveScreen) Engrave added in v1.3.0

func (s *EngraveScreen) Engrave(ctx *Context, ops op.Ctx, th *Colors) bool

type Engraver added in v1.3.0

type Engraver interface {
	Engrave(sz backup.PlateSize, plan engrave.Plan, quit <-chan struct{}) error
	Close()
}

type ErrorScreen

type ErrorScreen struct {
	Title string
	Body  string
	// contains filtered or unexported fields
}

func NewErrorScreen

func NewErrorScreen(err error) *ErrorScreen

func (*ErrorScreen) Layout

func (s *ErrorScreen) Layout(ctx *Context, ops op.Ctx, th *Colors, dims image.Point) bool

type Event

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

func (Event) AsButton added in v1.3.0

func (e Event) AsButton() (ButtonEvent, bool)

func (Event) AsFrame added in v1.3.0

func (e Event) AsFrame() (FrameEvent, bool)

func (Event) AsSDCard added in v1.3.0

func (e Event) AsSDCard() (SDCardEvent, bool)

type FrameEvent added in v1.2.0

type FrameEvent struct {
	Error error
	Image image.Image
}

func (FrameEvent) Event added in v1.3.0

func (f FrameEvent) Event() Event

type InputTracker added in v1.3.0

type InputTracker struct {
	Pressed [nbuttons]bool
	// contains filtered or unexported fields
}

func (*InputTracker) Clicked added in v1.3.0

func (t *InputTracker) Clicked(b Button) bool

func (*InputTracker) Next added in v1.3.0

func (t *InputTracker) Next(c *Context, btns ...Button) (ButtonEvent, bool)

type Instruction

type Instruction struct {
	Body  string
	Lead  string
	Type  InstructionType
	Side  int
	Image image.RGBA64Image
	// contains filtered or unexported fields
}

type InstructionType

type InstructionType int
const (
	PrepareInstruction InstructionType = iota
	ConnectInstruction
	EngraveInstruction
)

type Keyboard

type Keyboard struct {
	Word string
	// contains filtered or unexported fields
}

func NewKeyboard

func NewKeyboard(ctx *Context) *Keyboard

func (*Keyboard) Clear

func (k *Keyboard) Clear()

func (*Keyboard) Complete

func (k *Keyboard) Complete() (bip39.Word, bool)

func (*Keyboard) Layout

func (k *Keyboard) Layout(ctx *Context, ops op.Ctx, th *Colors) image.Point

func (*Keyboard) Update added in v1.2.0

func (k *Keyboard) Update(ctx *Context)

func (*Keyboard) Valid

func (k *Keyboard) Valid(r rune) bool
type NavButton struct {
	Button   Button
	Style    ButtonStyle
	Icon     image.Image
	Progress float32
}

type Plate added in v1.2.0

type Plate struct {
	Size              backup.PlateSize
	MasterFingerprint uint32
	Sides             []engrave.Plan
}

type Platform

type Platform interface {
	Events(deadline time.Time) []Event
	Wakeup()
	PlateSizes() []backup.PlateSize
	Engraver() (Engraver, error)
	EngraverParams() engrave.Params
	CameraFrame(size image.Point)
	Now() time.Time
	DisplaySize() image.Point
	// Dirty begins a refresh of the content
	// specified by r.
	Dirty(r image.Rectangle) error
	// NextChunk returns the next chunk of the refresh.
	NextChunk() (draw.RGBA64Image, bool)
	ScanQR(qr *image.Gray) ([][]byte, error)
	Debug() bool
}

type ProgressImage

type ProgressImage struct {
	Progress float32
	Src      image.RGBA64Image
}

func (ProgressImage) At

func (p ProgressImage) At(x, y int) color.Color

func (ProgressImage) Bounds

func (p ProgressImage) Bounds() image.Rectangle

func (ProgressImage) ColorModel

func (p ProgressImage) ColorModel() color.Model

func (ProgressImage) RGBA64At

func (p ProgressImage) RGBA64At(x, y int) color.RGBA64

type QRDecoder added in v1.3.0

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

func (*QRDecoder) Progress added in v1.3.0

func (d *QRDecoder) Progress() int

type SDCardEvent added in v1.2.0

type SDCardEvent struct {
	Inserted bool
}

func (SDCardEvent) Event added in v1.3.0

func (s SDCardEvent) Event() Event

type ScanScreen

type ScanScreen struct {
	Title string
	Lead  string
}

func (*ScanScreen) Scan added in v1.3.0

func (s *ScanScreen) Scan(ctx *Context, ops op.Ctx) (any, bool)

type SeedScreen

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

func (*SeedScreen) Confirm added in v1.3.0

func (s *SeedScreen) Confirm(ctx *Context, ops op.Ctx, th *Colors, mnemonic bip39.Mnemonic) bool

func (*SeedScreen) Draw added in v1.3.0

func (s *SeedScreen) Draw(ctx *Context, ops op.Ctx, th *Colors, dims image.Point, mnemonic bip39.Mnemonic)

type Styles

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

func NewStyles

func NewStyles() Styles

type Warning added in v1.2.0

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

func (*Warning) Layout added in v1.2.0

func (w *Warning) Layout(ctx *Context, ops op.Ctx, th *Colors, dims image.Point, title, txt string) image.Point

Directories

Path Synopsis
Code generated by gui/assets/gen.go; DO NOT EDIT.
Code generated by gui/assets/gen.go; DO NOT EDIT.

Jump to

Keyboard shortcuts

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