Documentation
¶
Index ¶
- Constants
- Variables
- func IsValidTransition(from, to ConnectionState) bool
- type ConnectionState
- type MediaOperation
- type PictureManager
- type Reader
- func (*Reader) CancelWrite()
- func (*Reader) Capabilities() []readers.Capability
- func (r *Reader) Close() error
- func (r *Reader) Connected() bool
- func (r *Reader) Detect(connected []string) string
- func (r *Reader) Device() string
- func (*Reader) IDs() []string
- func (r *Reader) Info() string
- func (*Reader) Metadata() readers.DriverMetadata
- func (r *Reader) OnMediaChange(media *models.ActiveMedia) error
- func (r *Reader) Open(device config.ReadersConnect, _ chan<- readers.Scan) error
- func (*Reader) Write(string) (*tokens.Token, error)
- type StateManager
Constants ¶
const ( // Handshake command CmdHandshake = "QWERTZ" // Core display commands CmdCore = "CMDCOR" // CMDCOR,<corename>,<transition> CmdText = "CMDTXT" // CMDTXT,<font>,<color>,<bgcolor>,<x>,<y>,<text> CmdShowName = "CMDSNAM" // CMDSNAM - show centered system name (uses actCorename) CmdClearShow = "CMDCLS" // CMDCLS - clear display and update CmdClearNoUpd = "CMDCLSWU" // CMDCLSWU - clear display without update CmdContrast = "CMDCON" // CMDCON,<contrast> CmdRotate = "CMDROT" // CMDROT,1 CmdOrgLogo = "CMDSORG" // CMDSORG - show original logo after rotation CmdClear = "CMDCLEAR" // Clear display (custom command - deprecated) // Screensaver commands CmdScreensaver = "CMDSAVER" // CMDSAVER,<mode>,<interval>,<start> // Time/RTC commands CmdSetTime = "CMDSETTIME" // CMDSETTIME,<timestamp> // Hardware info command CmdHardwareInfo = "CMDHWINF" // CMDHWINF - request hardware info )
TTY2OLED Protocol Commands
const ( // Transition effects TransitionAuto = "-1" // Auto transition (shell script default) TransitionNone = "0" TransitionSlide = "1" TransitionFade = "2" // Contrast levels (0-255) ContrastMin = 0 ContrastMax = 255 ContrastDefault = 128 // Screensaver modes (legacy - for backward compatibility) ScreensaverOff = "0" ScreensaverClock = "1" ScreensaverBlank = "2" ScreensaverLogo = "3" // Communication settings CommandTerminator = "\n" WaitDuration = 200 * time.Millisecond // Shell script WAITSECS=0.2 )
Protocol parameters
const ( // Rotation settings DefaultRotation = false // false = normal, true = 180° flipped // Enhanced transitions DefaultTransition = TransitionAuto // Screensaver mode flags (bitwise OR combinations) ScreensaverModeTTY2OLED = 1 // Show tty2oled logo ScreensaverModeMister = 2 // Show MiSTer logo ScreensaverModeCore = 4 // Show core name ScreensaverModeTime = 8 // Show time ScreensaverModeDate = 16 // Show date ScreensaverModeStars = 32 // Starfield animation ScreensaverModeToast = 64 // Flying toaster animation // Screensaver timing (from shell script defaults) DefaultScreensaverStart = 120 // Start after 120 seconds DefaultScreensaverInterval = 10 // 10 second intervals DefaultScreensaverMode = ScreensaverModeTTY2OLED | ScreensaverModeMister | ScreensaverModeCore | ScreensaverModeTime | ScreensaverModeDate | ScreensaverModeStars | ScreensaverModeToast // Additional timing delays SleepModeDelay = 2 * time.Second // SLEEPMODEDELAY="2" )
Configuration constants from MiSTer shell script
Variables ¶
var DeviceIdentifiers = []string{
"tty2oled",
"TTY2OLED",
"Arduino",
"CH340",
"CP210",
"FTDI",
"ESP32",
}
Device identification strings that might indicate tty2oled devices
var PictureFormats = []string{
"GSC_US",
"XBM_US",
"GSC",
"XBM",
"XBM_TEXT",
}
Picture format priorities (in order of preference)
Functions ¶
func IsValidTransition ¶
func IsValidTransition(from, to ConnectionState) bool
IsValidTransition checks if transitioning from one state to another is valid
Types ¶
type ConnectionState ¶
type ConnectionState int32
ConnectionState represents the current state of the TTY2OLED device connection
const ( // StateDisconnected indicates the device is not connected StateDisconnected ConnectionState = iota // StateDetecting indicates we are attempting to detect the device StateDetecting // StateConnecting indicates we are establishing the serial connection StateConnecting // StateHandshaking indicates we are performing the initial handshake StateHandshaking // StateInitializing indicates we are sending initialization commands StateInitializing // StateConnected indicates the device is fully ready for operations StateConnected )
func (ConnectionState) String ¶
func (s ConnectionState) String() string
String returns a human-readable representation of the connection state
type MediaOperation ¶
type MediaOperation struct {
// contains filtered or unexported fields
}
MediaOperation represents a queued display operation
type PictureManager ¶
type PictureManager struct {
// contains filtered or unexported fields
}
func NewPictureManager ¶
func NewPictureManager(cfg *config.Instance, pl platforms.Platform) *PictureManager
func (*PictureManager) ClearCache ¶
func (pm *PictureManager) ClearCache() error
ClearCache removes all cached pictures
func (*PictureManager) FindPictureOnDisk ¶
func (pm *PictureManager) FindPictureOnDisk(systemID string) (string, bool)
FindPictureOnDisk checks if a picture is immediately available on disk without downloading
func (*PictureManager) GetCacheInfo ¶
func (pm *PictureManager) GetCacheInfo() (map[string]int, error)
GetCacheInfo returns information about the picture cache
func (*PictureManager) GetPictureForSystem ¶
func (pm *PictureManager) GetPictureForSystem(systemID string) (string, error)
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader represents a tty2oled display reader
func (*Reader) CancelWrite ¶
func (*Reader) CancelWrite()
func (*Reader) Capabilities ¶
func (*Reader) Capabilities() []readers.Capability
func (*Reader) Metadata ¶
func (*Reader) Metadata() readers.DriverMetadata
func (*Reader) OnMediaChange ¶
func (r *Reader) OnMediaChange(media *models.ActiveMedia) error
type StateManager ¶
type StateManager struct {
// contains filtered or unexported fields
}
StateManager provides thread-safe state management for the connection
func NewStateManager ¶
func NewStateManager() *StateManager
NewStateManager creates a new state manager initialized to StateDisconnected
func (*StateManager) ForceState ¶
func (sm *StateManager) ForceState(newState ConnectionState)
ForceState atomically sets the connection state without validation This should only be used in exceptional cases where the state machine needs to be reset to a known state
func (*StateManager) GetState ¶
func (sm *StateManager) GetState() ConnectionState
GetState returns the current connection state
func (*StateManager) SetState ¶
func (sm *StateManager) SetState(newState ConnectionState) bool
SetState atomically sets the connection state if the transition is valid