boardctrl

package
v0.0.0-...-d4ca6eb Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2025 License: AGPL-3.0 Imports: 10 Imported by: 0

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

View Source
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 -----------------------------------------------------------------------------

View Source
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
)
View Source
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

func NewLensCtrl(bn string, a uint16) *LensCtrl

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) Read

func (lc *LensCtrl) Read(reg byte) (byte, error)

Read reads a byte from the specified register of the MAX14515

func (*LensCtrl) Right

func (lc *LensCtrl) Right()

Right selects the right lens driver by setting the select pin to low

func (*LensCtrl) SetLensCtrl

func (lc *LensCtrl) SetLensCtrl(value byte)

SetLensCtrl sets the lens control of the MAX14515

func (*LensCtrl) SetPowerMode

func (lc *LensCtrl) SetPowerMode(mode byte)

SetPowerMode sets the power mode of the MAX14515 LENSE_MODE_SLEEP = 0x00 // Sleep mode LENSE_MODE_NORMAL = 0x01 // Active mode

func (*LensCtrl) Write

func (lc *LensCtrl) Write(reg byte, value byte) error

Write writes a byte to the specified register of the MAX14515

type MerlinHAL

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

func NewMerlinHAL

func NewMerlinHAL() *MerlinHAL

func (*MerlinHAL) GetFocusBoth

func (hal *MerlinHAL) GetFocusBoth() (byte, byte)

GetFocusBoth gets the focus of both lenses

func (*MerlinHAL) GetFocusLeft

func (hal *MerlinHAL) GetFocusLeft() byte

GetFocusLeft gets the focus of the left lens

func (*MerlinHAL) GetFocusRight

func (hal *MerlinHAL) GetFocusRight() byte

GetFocusRight gets the focus of the right lens

func (*MerlinHAL) Get_fixleds

func (hal *MerlinHAL) Get_fixleds() (int, int)

get_fixleds returns the state of the right and left fixation LEDs on the Merlin board.

func (*MerlinHAL) Get_fixleft

func (hal *MerlinHAL) Get_fixleft() int

get_fixleft returns the state of the left fixation LED on the Merlin board.

func (*MerlinHAL) Get_fixright

func (hal *MerlinHAL) Get_fixright() int

get_fixright returns the state of the right fixation LED on the Merlin board.

func (*MerlinHAL) Get_irleds

func (hal *MerlinHAL) Get_irleds() (int, int)

get_irleds returns the state of the right and left IR LEDs on the Merlin board.

func (*MerlinHAL) Get_irleft

func (hal *MerlinHAL) Get_irleft() int

get_irleft returns the state of the left IR LEDs on the Merlin board.

func (*MerlinHAL) Get_irright

func (hal *MerlinHAL) Get_irright() int

get_irright returns the state of the right IR LEDs on the Merlin board.

func (*MerlinHAL) Get_laser

func (hal *MerlinHAL) Get_laser() int

get_laser returns the state of the laser on the Merlin board.

func (*MerlinHAL) Init

func (hal *MerlinHAL) Init()

func (*MerlinHAL) SetFocusBoth

func (hal *MerlinHAL) SetFocusBoth(right byte, left byte)

SetFocusBoth sets the focus of both lenses

func (*MerlinHAL) SetFocusLeft

func (hal *MerlinHAL) SetFocusLeft(value byte)

SetFocusLeft sets the focus of the left lens

func (*MerlinHAL) SetFocusRight

func (hal *MerlinHAL) SetFocusRight(value byte)

SetFocusRight sets the focus of the right lens

func (*MerlinHAL) Set_fixleds

func (hal *MerlinHAL) Set_fixleds(stateR byte, stateL byte)

set_fixleds controls the right and left fixation LEDs on the Merlin board.

func (*MerlinHAL) Set_fixleft

func (hal *MerlinHAL) Set_fixleft(state byte)

set_fixleft controls the left fixation LED on the Merlin board.

func (*MerlinHAL) Set_fixright

func (hal *MerlinHAL) Set_fixright(state byte)

set_fixright controls the right fixation LED on the Merlin board.

func (*MerlinHAL) Set_irleds

func (hal *MerlinHAL) Set_irleds(stateR byte, stateL byte)

set_irleds controls the right and left IR LEDs on the Merlin board.

func (*MerlinHAL) Set_irleft

func (hal *MerlinHAL) Set_irleft(state byte)

set_irleft controls the left IR LEDs on the Merlin board.

func (*MerlinHAL) Set_irright

func (hal *MerlinHAL) Set_irright(state byte)

set_irright controls the right IR LEDs on the Merlin board.

func (*MerlinHAL) Set_laser

func (hal *MerlinHAL) Set_laser(state byte)

set_laser controls the laser 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

func NewPCA9557(bn string, a uint16) *PCA9557

NewPCA9557 creates a new PCA9557 struct and initializes the PCA9557

func (*PCA9557) ClearBitInReg

func (pca *PCA9557) ClearBitInReg(reg byte, bit byte) error

ClearBitInReg clears a bit in the specified register

func (*PCA9557) ClearConfigBit

func (pca *PCA9557) ClearConfigBit(bit byte)

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

func (pca *PCA9557) ClearOutputPin(bit byte)

ClearOutputPin clears a pin in the output register

func (*PCA9557) ClearPinPolarity

func (pca *PCA9557) ClearPinPolarity(bit byte)

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

func (pca *PCA9557) GetConfigBit(bit byte) (bool, error)

GetConfigBit reads a pin from the configuration register

func (*PCA9557) GetInputPin

func (pca *PCA9557) GetInputPin(bit byte) (bool, error)

GetInputPin reads a pin from the input register

func (*PCA9557) GetOutputPin

func (pca *PCA9557) GetOutputPin(bit byte) (bool, error)

GetOutputPin reads a pin from the output register

func (*PCA9557) GetPolarityBit

func (pca *PCA9557) GetPolarityBit(bit byte) (bool, error)

GetPolarityBit reads a pin from the polarity register

func (*PCA9557) ReadReg

func (pca *PCA9557) ReadReg(reg byte) (byte, error)

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

func (pca *PCA9557) SetBitInReg(reg byte, bit byte) error

SetBitInReg sets a bit in the specified register

func (*PCA9557) SetConfigBit

func (pca *PCA9557) SetConfigBit(bit byte)

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

func (pca *PCA9557) SetOutputPin(bit byte)

SetOutputPin sets a pin in the output register

func (*PCA9557) SetPinPolarity

func (pca *PCA9557) SetPinPolarity(bit byte)

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.

func (*PCA9557) WriteReg

func (pca *PCA9557) WriteReg(reg byte, value byte) error

WriteReg writes a byte to the specified register

type UserLEDs

type UserLEDs struct {
	User1 *bcm283x.Pin // User LED 1
	User2 *bcm283x.Pin // User LED 2
}

UserLEDs is a struct to handle the user LEDs on the Merlin PCB

func NewUserLEDs

func NewUserLEDs() *UserLEDs

NewUserLEDs creates a new UserLEDs struct and initializes the user LEDs

func (*UserLEDs) SetLED1

func (leds *UserLEDs) SetLED1(state gpio.Level)

SetLED1 sets the state of User LED 1

func (*UserLEDs) SetLED2

func (leds *UserLEDs) SetLED2(state gpio.Level)

SetLED2 sets the state of User LED 2

Jump to

Keyboard shortcuts

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