Documentation ¶
Overview ¶
Package fpanels provides an interface to Logitech/Saitek flight panels.
Use the New*Panel() functions to create an instance of the specific panel type. When you are done, call the panel's Close() function.
Index ¶
- Constants
- Variables
- func LEDString(s string) (byte, error)
- type DisplayID
- type LEDDisplayer
- type MultiPanel
- func (panel *MultiPanel) Close()
- func (panel *MultiPanel) DisplayInt(display DisplayID, n int)
- func (panel *MultiPanel) DisplayString(display DisplayID, s string)
- func (panel *MultiPanel) ID() PanelID
- func (panel *MultiPanel) IsSwitchSet(id SwitchID) bool
- func (panel *MultiPanel) LEDs(leds byte)
- func (panel *MultiPanel) LEDsOff(leds byte)
- func (panel *MultiPanel) LEDsOn(leds byte)
- func (panel *MultiPanel) LEDsOnOff(leds byte, val float64)
- func (panel *MultiPanel) SwitchCh() chan SwitchState
- type PanelID
- type PanelSwitches
- type RadioPanel
- func (panel *RadioPanel) Close()
- func (panel *RadioPanel) DisplayFloat(display DisplayID, n float64, decimals int)
- func (panel *RadioPanel) DisplayInt(display DisplayID, n int)
- func (panel *RadioPanel) DisplayOff()
- func (panel *RadioPanel) DisplayString(display DisplayID, s string)
- func (panel *RadioPanel) ID() PanelID
- func (panel *RadioPanel) IsSwitchSet(id SwitchID) bool
- func (panel *RadioPanel) SwitchCh() chan SwitchState
- type StringDisplayer
- type SwitchID
- type SwitchPanel
- func (panel *SwitchPanel) Close()
- func (panel *SwitchPanel) ID() PanelID
- func (panel *SwitchPanel) IsSwitchSet(id SwitchID) bool
- func (panel *SwitchPanel) LEDs(leds byte)
- func (panel *SwitchPanel) LEDsOff(leds byte)
- func (panel *SwitchPanel) LEDsOn(leds byte)
- func (panel *SwitchPanel) LEDsOnOff(leds byte, val float64)
- func (panel *SwitchPanel) SwitchCh() chan SwitchState
- type SwitchState
Constants ¶
const ( LEDAP byte = 1 << iota LEDHDG LEDNAV LEDIAS LEDALT LEDVS LEDAPR LEDREV )
Multi panel button LED lights
const ( USBVendorPanel = 0x06a3 USBProductRadio = 0x0d05 USBProductMulti = 0x0d06 USBProductSwitch = 0x0d67 )
USB vendor and product IDs
const ( LEDNGreen byte = 1 << iota LEDLGreen LEDRGreen LEDNRed LEDLRed LEDRRed LEDNYellow = LEDNGreen | LEDNRed LEDLYellow = LEDLGreen | LEDLRed LEDRYellow = LEDRGreen | LEDRRed LEDAllGreen = LEDNGreen | LEDLGreen | LEDRGreen LEDAllRed = LEDNRed | LEDLRed | LEDRRed LEDAllYellow = LEDNYellow | LEDLYellow | LEDRYellow LEDNAll = LEDNYellow LEDLAll = LEDLYellow LEDRAll = LEDRYellow LEDAll = LEDAllYellow )
Switch panel landing gear lights
Variables ¶
var DisplayMap = map[string]DisplayID{ "ACTIVE_1": Display1Active, "STANDBY_1": Display1Standby, "ACTIVE_2": Display2Active, "STANDBY_2": Display2Standby, "ROW_1": Row1, "ROW_2": Row2, }
DisplayMap maps the display names to a DisplayID
var LEDMap = map[string]byte{ "N_GREEN": LEDNGreen, "L_GREEN": LEDLGreen, "R_GREEN": LEDRGreen, "N_RED": LEDNRed, "L_RED": LEDLRed, "R_RED": LEDRRed, "N_YELLOW": LEDNGreen | LEDNRed, "L_YELLOW": LEDLGreen | LEDLRed, "R_YELLOW": LEDRGreen | LEDRRed, "LED_AP": LEDAP, "LED_HDG": LEDHDG, "LED_NAV": LEDNAV, "LED_IAS": LEDIAS, "LED_ALT": LEDALT, "LED_VS": LEDVS, "LED_APR": LEDAPR, "LED_REV": LEDREV, }
LEDMap maps a LED Id string to the corresponding LED bits
var PanelIDMap = map[string]PanelID{ "RADIO": Radio, "MULTI": Multi, "SWITCH": Switch, }
PanelIDMap maps a panel Id string to a PanelID
var SwitchIDMap = map[string]SwitchID{ "COM1_1": Rot1COM1, "COM2_1": Rot1COM2, "NAV1_1": Rot1NAV1, "NAV2_1": Rot1NAV2, "ADF_1": Rot1ADF, "DME_1": Rot1DME, "XPDR_1": Rot1XPDR, "COM1_2": Rot2Com1, "COM2_2": Rot2Com2, "NAV1_2": Rot2NAV1, "NAV2_2": Rot2NAV2, "ADF_2": Rot2ADF, "DME_2": Rot2DME, "XPDR_2": Rot2XPDR, "ACT_1": SwAct1, "ACT_2": SwAct2, "ENC1_CW_1": Enc1CW1, "ENC1_CCW_1": Enc1CCW1, "ENC2_CW_1": Enc2CW1, "ENC2_CCW_1": Enc2CCW1, "ENC1_CW_2": Enc1CW2, "ENC1_CCW_2": Enc1CCW2, "ENC2_CW_2": Enc2CW2, "ENC2_CCW_2": Enc2CCW2, "ALT": RotALT, "VS": RotVS, "IAS": RotIAS, "HDG": RotHDG, "CRS": RotCRS, "ENC_CW": EncCW, "ENC_CCW": EncCCW, "BTN_AP": BtnAP, "BTN_HDG": BtnHDG, "BTN_NAV": BtnNAV, "BTN_IAS": BtnIAS, "BTN_ALT": BtnALT, "BTN_VS": BtnVS, "BTN_APR": BtnAPR, "BTN_REV": BtnREV, "AUTO_THROTTLE": AutoThrottle, "FLAPS_UP": FlapsUp, "FLAPS_DOWN": FlapsDown, "TRIM_DOWN": TrimDown, "TRIM_UP": TrimUp, "BAT": SwBat, "ALTERNATOR": SwAlternator, "AVIONICS": SwAvionics, "FUEL": SwFuel, "DEICE": SwDeice, "PITOT": SwPitot, "COWL": SwCowl, "PANEL": SwPanel, "BEACON": SwBeacon, "NAV": SwNav, "STROBE": SwStrobe, "TAXI": SwTaxi, "LANDING": SwLanding, "ENG_OFF": RotOff, "ALT_R": RotR, "ALT_L": RotL, "ALT_BOTH": RotBoth, "ENG_START": RotStart, "GEAR_UP": GearUp, "GEAR_DOWN": GearDown, }
SwitchIDMap maps a switch ID string to a SwitchID
Functions ¶
Types ¶
type DisplayID ¶
type DisplayID uint
DisplayID identifies a display on a panel
Radio panel displays
func DisplayIDString ¶
DisplayIDString maps a Display name to the DisplayID. The string s is case insesitive.
type LEDDisplayer ¶
type LEDDisplayer interface { LEDs(leds byte) LEDsOn(leds byte) LEDsOff(leds byte) LEDsOnOff(leds byte, val float64) }
LEDDisplayer priovides an interface to panels that has LEDs
type MultiPanel ¶
type MultiPanel struct {
// contains filtered or unexported fields
}
MultiPanel represents a Saitek/Logitech multi panel. The panel has:
- A five position switch
- Eight push buttons with individually controlable backlight.
- A rotary encoder
- A two position switch
- A two position momentary switch
- A pitch trim rotary encoder
- A two row segment display with five numbers on each row. Use DisplayString or DisplayInt to display text on the panels. The displays are identified by the Row1 and Row2 constants.
func NewMultiPanel ¶
func NewMultiPanel() (*MultiPanel, error)
NewMultiPanel creates a new instances of the Logitech/Saitek multipanel
func (*MultiPanel) DisplayInt ¶
func (panel *MultiPanel) DisplayInt(display DisplayID, n int)
DisplayInt will display the integer n on the given display
func (*MultiPanel) DisplayString ¶
func (panel *MultiPanel) DisplayString(display DisplayID, s string)
DisplayString displays the string given by s on the display given by display. The string is limited to the numbers 0-9 and spaces. Row2 can additionally show a dash/minus '-'. If any other char is used the underlying previous character is left intact. This allows you to update different areas of the dislay in sepeate calls. For example:
panel.DisplayString(Row1, "12 ") panel.DisplayString(Row1, "** 34") panel.DisplayString(Row1, "** 56")
will display the the following sequence on the upper display:
12 12 34 12 56
func (*MultiPanel) IsSwitchSet ¶
func (*MultiPanel) LEDs ¶
func (panel *MultiPanel) LEDs(leds byte)
LEDs turns on/off the LEDs given by leds. See the LED* constants. For example calling
panel.LEDs(LEDAP | LEDVS)
will turn on the AP and VS LEDs and turn off all other LEDs.
func (*MultiPanel) LEDsOff ¶
func (panel *MultiPanel) LEDsOff(leds byte)
LEDsOff turns off the LEDs given by leds and leaves all other LED states intact. See the LED* constants. Multiple LEDs can be ORed together. For example
panel.LEDsOff(LEDAP | LEDVS)
func (*MultiPanel) LEDsOn ¶
func (panel *MultiPanel) LEDsOn(leds byte)
LEDsOn turns on the LEDs given by leds and leaves all other LED states intact. See the LED* constants. Multiple LEDs can be ORed together, for example
panel.LEDsOn(LEDAP | LEDVS)
func (*MultiPanel) LEDsOnOff ¶
func (panel *MultiPanel) LEDsOnOff(leds byte, val float64)
LEDsOnOff turns on or off the LEDs given by leds. If val is 0 then the LEDs will be turned offm else they will be turned on. All other LEDs are left intact. See the LED* constants. Multiple LEDs can be ORed together, for example
panel.LEDsOnOff(LEDAP | LEDVS, 1)
func (*MultiPanel) SwitchCh ¶
func (panel *MultiPanel) SwitchCh() chan SwitchState
SwitchCh returns a channel for switch events
type PanelID ¶
type PanelID int
PanelID identifies the panel type
func PanelIDString ¶
PanelIDString maps a panel string to a PanelID. The string s is case insensitive.
type PanelSwitches ¶
type PanelSwitches uint32
PanelSwitches is the state of all switches on a panel, one bit per switch
func (PanelSwitches) IsSet ¶
func (switches PanelSwitches) IsSet(id SwitchID) bool
IsSet returns true if the switch id is set.
func (PanelSwitches) SwitchState ¶
func (switches PanelSwitches) SwitchState(id SwitchID) uint
SwitchState returns the statee of the switch with ID id, 0 or 1
type RadioPanel ¶
type RadioPanel struct {
// contains filtered or unexported fields
}
RadioPanel represents a Saitek/Logitech radio panel. The panel has:
- Two seven position function switches
- Two dual rotary encoders
- Two momentary push buttons
- Four five number segment displays
func NewRadioPanel ¶
func NewRadioPanel() (*RadioPanel, error)
NewRadioPanel creats a new instance of the radio panel
func (*RadioPanel) DisplayFloat ¶
func (panel *RadioPanel) DisplayFloat(display DisplayID, n float64, decimals int)
DisplayFloat displays the floating point number n with the given number of decimals on the given display
func (*RadioPanel) DisplayInt ¶
func (panel *RadioPanel) DisplayInt(display DisplayID, n int)
DisplayInt displays the integer n on the given display
func (*RadioPanel) DisplayOff ¶
func (panel *RadioPanel) DisplayOff()
DisplayOff turns the display off
func (*RadioPanel) DisplayString ¶
func (panel *RadioPanel) DisplayString(display DisplayID, s string)
DisplayString displays the string s on the given display. The string is limited to the numbers 0-9, a dot '.', dash/minus '-' and space, with a length of max five characters. If any other character is used then the underlying previous character is left intact. This allows you to update different areas of the dislay in separate calls. For example:
panel.DisplayString(Display1Active, "12 ") panel.DisplayString(Display1Active, "** 34") panel.DisplayString(Display1Active, "** 56")
will display the the following sequence on the upper left display:
12 12 34 12 56
func (*RadioPanel) IsSwitchSet ¶
func (*RadioPanel) SwitchCh ¶
func (panel *RadioPanel) SwitchCh() chan SwitchState
SwitchCh returns a channel for switch events
type StringDisplayer ¶
StringDisplayer provides an interface to panels that can display strings
type SwitchID ¶
type SwitchID uint
SwitchID identifies a switch on a panel
const ( RotALT SwitchID = iota RotVS RotIAS RotHDG RotCRS EncCW EncCCW BtnAP BtnHDG BtnNAV BtnIAS BtnALT BtnVS BtnAPR BtnREV AutoThrottle FlapsUp FlapsDown TrimDown TrimUp )
Multi panel switches and buttons
const ( Rot1COM1 SwitchID = iota Rot1COM2 Rot1NAV1 Rot1NAV2 Rot1ADF Rot1DME Rot1XPDR Rot2Com1 Rot2Com2 Rot2NAV1 Rot2NAV2 Rot2ADF Rot2DME Rot2XPDR SwAct1 SwAct2 Enc1CW1 Enc1CCW1 Enc2CW1 Enc2CCW1 Enc1CW2 Enc1CCW2 Enc2CW2 Enc2CCW2 )
Radio panel switches
const ( SwBat SwitchID = iota SwAlternator SwAvionics SwFuel SwDeice SwPitot SwCowl SwPanel SwBeacon SwStrobe SwTaxi SwLanding RotOff RotR RotL RotBoth RotStart GearUp GearDown )
Switch panel switches
func SwitchIDString ¶
SwitchIDString maps a Switch ID string to a SwitchID. The ID string s is case insensitive.
type SwitchPanel ¶
type SwitchPanel struct {
// contains filtered or unexported fields
}
SwitchPanel represents a Saitek/Logitech switch panel. The panel has:
- A five position switch
- Thirteen two position switches
- A two position landing gear lever
- Three red/green landing gear indicator LEDs
func NewSwitchPanel ¶
func NewSwitchPanel() (*SwitchPanel, error)
NewSwitchPanel create a new instance of the Logitech/Saitek switch panel
func (*SwitchPanel) IsSwitchSet ¶
func (*SwitchPanel) LEDs ¶
func (panel *SwitchPanel) LEDs(leds byte)
LEDs turns on/off the LEDs given by leds. See the LED* constants. For example calling
panel.LEDs(LEDLGreen | LEDRGreen)
will turn on the left and right green landing gear LEDs and turn off all other LEDs
func (*SwitchPanel) LEDsOff ¶
func (panel *SwitchPanel) LEDsOff(leds byte)
LEDsOff turn off the LEDs given by leds and leaves all other LED states instact. See the switch panel LED constants. Multiple LEDs can be ORed together. For example:
panel.LEDsOff(LEDLGreen | LEDRGreen)
func (*SwitchPanel) LEDsOn ¶
func (panel *SwitchPanel) LEDsOn(leds byte)
LEDsOn turns on the ELDS given by leds and leaves the other LED states intact. See the switch panel LED constants. Multiple LEDs can be ORed together. For example:
panel.LEDsOn(LEDLGreen | LEDRGreen)
func (*SwitchPanel) LEDsOnOff ¶
func (panel *SwitchPanel) LEDsOnOff(leds byte, val float64)
LEDsOnOff turns on or off the LEDs given by leds. If val is 0 then the LEDs will be turned off, else they will be turned on. All other LEDs are left intact. See the switch panel LED constants. Multiple LEDs can be ORed togethe, for example:
panel.LEDsOnOff(LEDLGreen | LEDRGreen, 1)
func (*SwitchPanel) SwitchCh ¶
func (panel *SwitchPanel) SwitchCh() chan SwitchState
SwitchCh returns a channel for switch events
type SwitchState ¶
SwitchState contains the state of a switch on a panel