Documentation ¶
Overview ¶
----------------------------------------------------------------------------- Copyright (c) 2024-2025 Sven C. Zeisberg, Zeisberg GmbH, Germany. All rights reserved. Description: This package contains the HAL (Hardware Abstraction Layer) for the Merlin board. It provides functions to control the hardware of the Merlin board. HAL defines simple functions to control the hardware of the Merlin board: - irleft:
----------------------------------------------------------------------------- Copyright (c) 2024-2025 Sven C. Zeisberg, Zeisberg GmbH, Germany. All rights reserved. Description: This file handles IRLEDs on the Merlin board. There are two IR LEDs for each eye on the current version of the Merlin board. The IR LEDs are controlled by the PCA9557 I2C GPIO expander U350 on the Merlin board. IR LEDs 0 = all leds off 1 = led1 on 2 = led2 on 3 = both leds on ... on future boards, the number of LEDs might increase. The return value is a binary encoded value, where the least significant bit represents the state of the first LED, the second least significant bit represents the state of the second LED, and so on. The functions take care of the correct mapping between the binary encoded value and the actual hardware. -----------------------------------------------------------------------------
----------------------------------------------------------------------------- Copyright (c) 2024-2025 Sven C. Zeisberg, Zeisberg GmbH, Germany. All rights reserved. Description: halLense.go provides control functions to query and set the focus of the lenses. -----------------------------------------------------------------------------
----------------------------------------------------------------------------- Copyright (c) 2024-2025 Sven C. Zeisberg, Zeisberg GmbH, Germany. All rights reserved. Description: This file handles the power for the Cams on the Merlin board. There are two cams on the Merlin board. The power for the cams is controlled by the PCA9557 I2C GPIO expander U350 on the Merlin board. Cams: 0 = cams off 1 = cams on -----------------------------------------------------------------------------
----------------------------------------------------------------------------- Copyright (c) 2024-2025 Sven C. Zeisberg, Zeisberg GmbH, Germany. All rights reserved. Description: This file handles fixation LEDs on the Merlin board. There is one fixation LED on each side of the board. The fixation LEDs are controlled by the PCA9557 I2C GPIO expander U350 on the Merlin board. Fixation LEDs: 0 = led off 1 = led on -----------------------------------------------------------------------------
----------------------------------------------------------------------------- Copyright (c) 2024-2025 Sven C. Zeisberg, Zeisberg GmbH, Germany. All rights reserved. Description: This file handles the Laser Module on the Merlin board. There is central Laser on the board. The Laser is controlled by the PCA9557 I2C GPIO expander U350 on the Merlin board. Laser: 0 = laser off 1 = laser on -----------------------------------------------------------------------------
----------------------------------------------------------------------------- Copyright (c) 2024-2025 Sven C. Zeisberg, Zeisberg GmbH, Germany. All rights reserved. Description: This file contains the MAX14515 I2C lens controller driver. max4515 provides control for the Varioptic Liquid Lenses via MAX14515. See below for more information. https://zeisberg.atlassian.net/wiki/spaces/SUP/pages/2534539269/Merlin+lens+control https://www.analog.com/en/products/max14515.html -----------------------------------------------------------------------------
----------------------------------------------------------------------------- Copyright (c) 2024-2025 Sven C. Zeisberg, Zeisberg GmbH, Germany. All rights reserved. Description: This file contains the PCA9557 I2C GPIO expander driver. -----------------------------------------------------------------------------
----------------------------------------------------------------------------- Copyright (c) 2024-2025 Sven C. Zeisberg, Zeisberg GmbH, Germany. All rights reserved. Description: This file provides access to the user LEDs on the Merlin PCB. See below for more information. https://zeisberg.atlassian.net/wiki/spaces/SUP/pages/2534539294/Merlin+User+LEDs -----------------------------------------------------------------------------
Index ¶
- Constants
- type LensCtrl
- func (lc *LensCtrl) Disable()
- func (lc *LensCtrl) Enable()
- func (lc *LensCtrl) Left()
- func (lc *LensCtrl) Read(reg byte) (byte, error)
- func (lc *LensCtrl) Right()
- func (lc *LensCtrl) SetLensCtrl(value byte)
- func (lc *LensCtrl) SetPowerMode(mode byte)
- func (lc *LensCtrl) Write(reg byte, value byte) error
- type MerlinHAL
- func (hal *MerlinHAL) GetFocusBoth() (byte, byte)
- func (hal *MerlinHAL) GetFocusLeft() byte
- func (hal *MerlinHAL) GetFocusRight() byte
- func (hal *MerlinHAL) Get_fixleds() (int, int)
- func (hal *MerlinHAL) Get_fixleft() int
- func (hal *MerlinHAL) Get_fixright() int
- func (hal *MerlinHAL) Get_irleds() (int, int)
- func (hal *MerlinHAL) Get_irleft() int
- func (hal *MerlinHAL) Get_irright() int
- func (hal *MerlinHAL) Get_laser() int
- func (hal *MerlinHAL) Init()
- func (hal *MerlinHAL) SetFocusBoth(right byte, left byte)
- func (hal *MerlinHAL) SetFocusLeft(value byte)
- func (hal *MerlinHAL) SetFocusRight(value byte)
- func (hal *MerlinHAL) Set_fixleds(stateR byte, stateL byte)
- func (hal *MerlinHAL) Set_fixleft(state byte)
- func (hal *MerlinHAL) Set_fixright(state byte)
- func (hal *MerlinHAL) Set_irleds(stateR byte, stateL byte)
- func (hal *MerlinHAL) Set_irleft(state byte)
- func (hal *MerlinHAL) Set_irright(state byte)
- func (hal *MerlinHAL) Set_laser(state byte)
- type PCA9557
- func (pca *PCA9557) ClearBitInReg(reg byte, bit byte) error
- func (pca *PCA9557) ClearConfigBit(bit byte)
- func (pca *PCA9557) ClearOutputPin(bit byte)
- func (pca *PCA9557) ClearPinPolarity(bit byte)
- func (pca *PCA9557) GetConfigBit(bit byte) (bool, error)
- func (pca *PCA9557) GetInputPin(bit byte) (bool, error)
- func (pca *PCA9557) GetOutputPin(bit byte) (bool, error)
- func (pca *PCA9557) GetPolarityBit(bit byte) (bool, error)
- func (pca *PCA9557) ReadReg(reg byte) (byte, error)
- func (pca *PCA9557) SetBitInReg(reg byte, bit byte) error
- func (pca *PCA9557) SetConfigBit(bit byte)
- func (pca *PCA9557) SetOutputPin(bit byte)
- func (pca *PCA9557) SetPinPolarity(bit byte)
- func (pca *PCA9557) WriteReg(reg byte, value byte) error
- type UserLEDs
Constants ¶
const ( // --- general constants ----------------------------------------------------- ENABLED = gpio.High // Lens enabled DISABLED = gpio.Low // Lens disabled RIGHT = gpio.High // Lens_driver 0 (right) selected LEFT = gpio.Low // Lens_driver 1 (left) selected ON = 1 // LED on OFF = 0 // LED off LED1 = 0x01 // First LED on on a side LED2 = 0x02 // Second LED on a side )
----------------------------------------------------------------------------- Constants -----------------------------------------------------------------------------
const ( LENS_IDC = 0x76 // I2C address of MAX14515 LENS_I2CBUS = "/dev/i2c-1" // I2C bus name LENSE_REG_POWERMODE = 0x00 // Power mode register LENSE_REG_LENSCTRL = 0x01 // Lens control register LENSE_MODE_SLEEP = 0x00 // Sleep mode LENSE_MODE_NORMAL = 0x01 // Active mode )
const ( PCA9557_I2CBUS = "/dev/i2c-1" PCA9557_ADR = 0x18 // I2C address of PCA9557 PCA9557_REG_INPUT = 0x00 // Input register PCA9557_REG_OUTPUT = 0x01 // Output register PCA9557_REG_POLARITY = 0x02 // Polarity inversion register PCA9557_REG_CONFIG = 0x03 // Configuration register // --- PCA9557 pin assignments ----------------------------------------------- IR1_RIGHT = 0x00 // Right IR LED #1 IR1_LEFT = 0x01 // Left IR LED #1 FIX_LEFT = 0x02 // Left fixation LED FIX_RIGHT = 0x03 // Right fixation LED IR2_LEFT = 0x04 // Left IR LED #2 IR2_RIGHT = 0x05 // Right IR LED #2 CAM_PWR = 0x06 // Camera power LASER = 0x07 // Laser )
Define Bus, Address and Registers for PCA9557 U350 on Merlin PCB
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LensCtrl ¶
type LensCtrl struct { EnablePin *bcm283x.Pin // Enable pin on MAX14515 SelectPin *bcm283x.Pin // Select pin on MAX14515 Status gpio.Level // 0 = disabled, 1 = enabled Side gpio.Level // 0 = Lens_driver 0 selected, 1 = Lens_driver 1 selected BusName string // I2C bus name Addr uint16 // I2C address Device *i2c.Dev // I2C device // contains filtered or unexported fields }
LensCtrl is a struct to handle the MAX14515 I2C lens controller on the Merlin PCB incl. GPIO pins for enable and select.
func NewLensCtrl ¶
NewLensCtrl creates a new LensCtrl struct and initializes the MAX14515 The lenses are set to power down mode initially. The hal will set the power mode to normal mode when the lenses are used (read or written).
func (*LensCtrl) Disable ¶
func (lc *LensCtrl) Disable()
Disable disables the lens by setting the enable pin to low
func (*LensCtrl) Enable ¶
func (lc *LensCtrl) Enable()
Enable enables the lens by setting the enable pin to high
func (*LensCtrl) Left ¶
func (lc *LensCtrl) Left()
Left selects the left lens driver by setting the select pin to high
func (*LensCtrl) Right ¶
func (lc *LensCtrl) Right()
Right selects the right lens driver by setting the select pin to low
func (*LensCtrl) SetLensCtrl ¶
SetLensCtrl sets the lens control of the MAX14515
func (*LensCtrl) SetPowerMode ¶
SetPowerMode sets the power mode of the MAX14515 LENSE_MODE_SLEEP = 0x00 // Sleep mode LENSE_MODE_NORMAL = 0x01 // Active mode
type MerlinHAL ¶
type MerlinHAL struct {
// contains filtered or unexported fields
}
func NewMerlinHAL ¶
func NewMerlinHAL() *MerlinHAL
func (*MerlinHAL) GetFocusBoth ¶
GetFocusBoth gets the focus of both lenses
func (*MerlinHAL) GetFocusLeft ¶
GetFocusLeft gets the focus of the left lens
func (*MerlinHAL) GetFocusRight ¶
GetFocusRight gets the focus of the right lens
func (*MerlinHAL) Get_fixleds ¶
get_fixleds returns the state of the right and left fixation LEDs on the Merlin board.
func (*MerlinHAL) Get_fixleft ¶
get_fixleft returns the state of the left fixation LED on the Merlin board.
func (*MerlinHAL) Get_fixright ¶
get_fixright returns the state of the right fixation LED on the Merlin board.
func (*MerlinHAL) Get_irleds ¶
get_irleds returns the state of the right and left IR LEDs on the Merlin board.
func (*MerlinHAL) Get_irleft ¶
get_irleft returns the state of the left IR LEDs on the Merlin board.
func (*MerlinHAL) Get_irright ¶
get_irright returns the state of the right IR LEDs on the Merlin board.
func (*MerlinHAL) SetFocusBoth ¶
SetFocusBoth sets the focus of both lenses
func (*MerlinHAL) SetFocusLeft ¶
SetFocusLeft sets the focus of the left lens
func (*MerlinHAL) SetFocusRight ¶
SetFocusRight sets the focus of the right lens
func (*MerlinHAL) Set_fixleds ¶
set_fixleds controls the right and left fixation LEDs on the Merlin board.
func (*MerlinHAL) Set_fixleft ¶
set_fixleft controls the left fixation LED on the Merlin board.
func (*MerlinHAL) Set_fixright ¶
set_fixright controls the right fixation LED on the Merlin board.
func (*MerlinHAL) Set_irleds ¶
set_irleds controls the right and left IR LEDs on the Merlin board.
func (*MerlinHAL) Set_irleft ¶
set_irleft controls the left IR LEDs on the Merlin board.
func (*MerlinHAL) Set_irright ¶
set_irright controls the right IR LEDs on the Merlin board.
type PCA9557 ¶
type PCA9557 struct { BusName string // I2C bus name Addr uint16 // I2C address Device *i2c.Dev // I2C device // contains filtered or unexported fields }
PCA9557 is a struct to handle the PCA9557 I2C GPIO expander
func NewPCA9557 ¶
NewPCA9557 creates a new PCA9557 struct and initializes the PCA9557
func (*PCA9557) ClearBitInReg ¶
ClearBitInReg clears a bit in the specified register
func (*PCA9557) ClearConfigBit ¶
ClearConfigBit clears a bit in the configuration register If a bit in this register is cleared, the corresponding port pin is enabled as an output.
func (*PCA9557) ClearOutputPin ¶
ClearOutputPin clears a pin in the output register
func (*PCA9557) ClearPinPolarity ¶
ClearPinPolarity clears a pin in the polarity register If a bit in this register is cleared (written with logic 0), the corresponding port pin’s original polarity is retained.
func (*PCA9557) GetConfigBit ¶
GetConfigBit reads a pin from the configuration register
func (*PCA9557) GetInputPin ¶
GetInputPin reads a pin from the input register
func (*PCA9557) GetOutputPin ¶
GetOutputPin reads a pin from the output register
func (*PCA9557) GetPolarityBit ¶
GetPolarityBit reads a pin from the polarity register
func (*PCA9557) ReadReg ¶
ReadReg reads a byte from the specified register and returns the byte read If the I2C device is not initialized, the function panics
func (*PCA9557) SetBitInReg ¶
SetBitInReg sets a bit in the specified register
func (*PCA9557) SetConfigBit ¶
SetConfigBit sets a bit in the configuration register If a bit in this register is set, the corresponding port pin is enabled as an input with high-impedance output driver.
func (*PCA9557) SetOutputPin ¶
SetOutputPin sets a pin in the output register
func (*PCA9557) SetPinPolarity ¶
SetPinPolarity sets a pin in the polarity register If a bit in this register is set (written with logic 1), the corresponding port pin’s polarity is inverted.