emulator

package
v0.0.0-...-34b6f37 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2025 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DisplayWidth         = C.PINETIME_LCD_WIDTH
	DisplayHeight        = C.PINETIME_LCD_HEIGHT
	DisplayBytesPerPixel = C.BYTES_PER_PIXEL
)
View Source
const (
	PinCharging           = 12
	PinCst816sReset       = 10
	PinButton             = 13
	PinButtonEnable       = 15
	PinCst816sIrq         = 28
	PinPowerPresent       = 19
	PinBma421Irq          = 8
	PinMotor              = 16
	PinLcdBacklightLow    = 14
	PinLcdBacklightMedium = 22
	PinLcdBacklightHigh   = 23
	PinSpiSck             = 2
	PinSpiMosi            = 3
	PinSpiMiso            = 4
	PinSpiFlashCsn        = 5
	PinSpiLcdCsn          = 25
	PinLcdDataCommand     = 18
	PinLcdReset           = 26
	PinTwiScl             = 7
	PinTwiSda             = 6
)
View Source
const BaseFrequencyHZ = 64_000_000

Variables

This section is empty.

Functions

func ConvertImage

func ConvertImage(raw []byte) *image.RGBA

Types

type Brightness

type Brightness int
const (
	BrightnessOff Brightness = iota
	BrightnessLow
	BrightnessMedium
	BrightnessHigh
	BrightnessInvalid
)

func (Brightness) String

func (b Brightness) String() string

type ByteState

type ByteState uint8
const (
	ByteStateNone ByteState = (1 << iota) >> 1
	ByteStateUsed
	ByteStateFreed
)

type Emulator

type Emulator struct {
	Heap *HeapTracker
	// contains filtered or unexported fields
}

func NewEmulator

func NewEmulator(program *Program, spiFlash []byte, big bool) *Emulator

func (*Emulator) Brightness

func (e *Emulator) Brightness() Brightness

func (*Emulator) Close

func (e *Emulator) Close()

func (*Emulator) CloseRunlog

func (e *Emulator) CloseRunlog()

func (*Emulator) DidSPIFlashChange

func (e *Emulator) DidSPIFlashChange() bool

func (*Emulator) DisableHeapTracker

func (e *Emulator) DisableHeapTracker()

func (*Emulator) DoTouch

func (e *Emulator) DoTouch(gesture TouchGesture, x, y int)

func (*Emulator) EnableHeapTracker

func (e *Emulator) EnableHeapTracker()

func (*Emulator) FindFreeHeapBlocks

func (e *Emulator) FindFreeHeapBlocks()

func (*Emulator) InstructionsPerSecond

func (e *Emulator) InstructionsPerSecond() uint64

func (*Emulator) IsDisplaySleeping

func (e *Emulator) IsDisplaySleeping() bool

func (*Emulator) IsPinSet

func (e *Emulator) IsPinSet(pin int) bool

func (*Emulator) LoadState

func (e *Emulator) LoadState(state []byte) bool

func (*Emulator) NumRTC

func (e *Emulator) NumRTC() int

func (*Emulator) PinClear

func (e *Emulator) PinClear(pin int)

func (*Emulator) PinSet

func (e *Emulator) PinSet(pin int)

func (*Emulator) RTCTrackers

func (e *Emulator) RTCTrackers() []*RTCTracker

func (*Emulator) ReadDisplayBuffer

func (e *Emulator) ReadDisplayBuffer(p []byte)

func (*Emulator) ReadMemory

func (e *Emulator) ReadMemory(addr uint32) uint32

func (*Emulator) ReadVariable

func (e *Emulator) ReadVariable(name string, offset uint32) (value uint64, found bool)

func (*Emulator) RecordRunlog

func (e *Emulator) RecordRunlog(path string) error

func (*Emulator) ReleaseTouch

func (e *Emulator) ReleaseTouch()

func (*Emulator) RunIterations

func (e *Emulator) RunIterations(iterations uint64, iterations_per_us uint64) int

func (*Emulator) SPIFlash

func (e *Emulator) SPIFlash() []byte

func (*Emulator) SaveState

func (e *Emulator) SaveState() []byte

func (*Emulator) SetFrequency

func (e *Emulator) SetFrequency(hz uint)

func (*Emulator) SetHeartrateValue

func (e *Emulator) SetHeartrateValue(val uint32)

func (*Emulator) Start

func (e *Emulator) Start(mode RunMode)

func (*Emulator) Stop

func (e *Emulator) Stop() RunMode

func (*Emulator) WriteVariable

func (e *Emulator) WriteVariable(name string, offset uint32, value uint64)

type Function

type Function struct {
	Name        string
	Definitions []FunctionDefinition
	Declaration *dwarf.Entry

	DWARF *dwarf.Data
}

func (*Function) GetLineAtPC

func (f *Function) GetLineAtPC(pc uint32) (*dwarf.LineEntry, bool)

type FunctionDefinition

type FunctionDefinition struct {
	CompilationUnit *dwarf.Entry
	Entry           *dwarf.Entry
	Location        *SourceLocation
	StartPC, EndPC  uint32
}

type HeapAllocation

type HeapAllocation struct {
	PC      uint32
	Address uint32
	Size    uint
	Freed   bool
}

type HeapTracker

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

func (*HeapTracker) GetAll

func (h *HeapTracker) GetAll() []HeapAllocation

func (*HeapTracker) GetBytes

func (h *HeapTracker) GetBytes() []ByteState

func (*HeapTracker) GetInUse

func (h *HeapTracker) GetInUse() []HeapAllocation

func (*HeapTracker) HeapSize

func (h *HeapTracker) HeapSize() int

func (*HeapTracker) HeapStart

func (h *HeapTracker) HeapStart() uint32

type Program

type Program struct {
	FilePath  string // only used to allow GDB to load the program from disk and can thus be left empty
	Sections  []Section
	Symbols   map[string]Symbol
	Functions map[string]*Function
}

func LoadBinary

func LoadBinary(r io.Reader) (*Program, error)

func LoadELF

func LoadELF(r io.ReaderAt, loadSymbols bool) (*Program, error)

func LoadProgram

func LoadProgram(r ReadReaderAt) (*Program, error)

func (*Program) Flatten

func (p *Program) Flatten() []byte

func (*Program) GetFunctionAtPC

func (p *Program) GetFunctionAtPC(pc uint32) (*Function, bool)

func (*Program) GetPCAtFunction

func (p *Program) GetPCAtFunction(name string) (uint32, bool)

type RTCTracker

type RTCTracker struct {
	TicksPerSecond       uint32
	TargetTicksPerSecond uint32
	Running              bool
	// contains filtered or unexported fields
}

type ReadReaderAt

type ReadReaderAt interface {
	io.ReaderAt
	io.ReadSeeker
}

type RunMode

type RunMode int
const (
	RunModeLoop RunMode = iota
	RunModeScheduled
	RunModeGDB
)

type Section

type Section struct {
	Start uint32
	Data  []byte
}

type SourceLocation

type SourceLocation struct {
	File         string
	Line, Column int
}

type Symbol

type Symbol struct {
	Name, PrettyName string
	Start, Length    uint32
	Type             SymbolType
}

type SymbolType

type SymbolType byte
const (
	SymbolTypeObject SymbolType = iota + 1
	SymbolTypeFunction
)

type TouchGesture

type TouchGesture int
const (
	GestureNone       TouchGesture = C.GESTURE_NONE
	GestureSlideDown  TouchGesture = C.GESTURE_SLIDEDOWN
	GestureSlideUp    TouchGesture = C.GESTURE_SLIDEUP
	GestureSlideLeft  TouchGesture = C.GESTURE_SLIDELEFT
	GestureSlideRight TouchGesture = C.GESTURE_SLIDERIGHT
	GestureSingleTap  TouchGesture = C.GESTURE_SINGLETAP
	GestureDoubleTap  TouchGesture = C.GESTURE_DOUBLETAP
	GestureLongPress  TouchGesture = C.GESTURE_LONGPRESS
)

Jump to

Keyboard shortcuts

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