Create an object of type Octofet
to communicate with a particular Octofet board. One Octofet board provides 8 power switches also known as "channels".
Constructs a new Octofet board object that uses the default hardware SPI bus.
pinCS
: the chip select (also known as slave select) pin used to control the shift-register latch. It is markedCS
on the Octofet board. Any GPIO pin of the controller may be used.deviceCount
: the number of Octofet boards connected in a daisy-chain. If omitted, defines a single Octofet board.
Constructs a new Octofet board object that uses a software SPI bus.
pinCS
: the chip select (also known as slave select) pin used to control the shift-register latch. It is markedCS
on the Octofet board. Any GPIO pin of the controller may be used.pinMOSI
: the MOSI (Master Out Slave In) pin used to send data to the peripherals. It is markedDI
on the Octofet board. Any GPIO pin of the controller may be used.pinSCK
: the clock pin used to clock pulses which synchronize data transmission generated by the master. It is markedП
on the Octofet board. Any GPIO pin of the controller may be used.deviceCount
: the number of Octofet boards connected in a daisy-chain. If omitted, defines a single Octofet board.
Difference between hardware and software SPI is speed. Software SPI runs slower than hardware SPI but hardware SPI works only on specific board pins: MOSI
, MISO
(not used in Octofet) and SCK
.
Initializes the given interface, prepares the board for communication. All power switches are set to the turned-off state.
Call this method before interfacing with Octofet. For example, in your setup()
.
Sets the state ("on" or "off") of one power switch.
channel
: the power switch index. Ranges from0
to7
.value
: defines the desired switch state. Valid values:HIGH
/1
/true
to turn on orLOW
/0
/false
to turn off.device
: the index of the affected Octofet in the daisy-chain. Ranges from0
ton - 1
, wheren
is the number of Octofets in the chain. If omitted, targets Octofet nearest to the controller.
Sets the state ("on" or "off") of all power switches at once.
value
: 8-bit value for all of 8 power switches. One bit for one channel: 1 is "on" and 0 is "off". For example:0b10101010
.device
: the index of the affected Octofet in the daisy-chain. Ranges from0
ton - 1
, wheren
is the number of Octofets in the chain. If omitted, targets Octofet nearest to the controller.
Returns the last (i.e., current) set state for one power switch of the device. Returns true
if turned on or false
otherwise.
channel
: the power switch index. Ranges from0
to7
.device
: the index of the affected Octofet in the daisy-chain. Ranges from0
ton - 1
, wheren
is the number of Octofets in the chain. If omitted, targets Octofet nearest to the controller.
Returns 8-bit value of the last (i.e., current) set state for all 8 power switches of the device at once. One bit for one channel: 1 is "on" and 0 is "off". For example: 0b10101010
. The argument device
is the index of the affected Octofet in the daisy-chain. Ranges from 0
to n - 1
, where n
is the number of Octofets in the chain. If omitted, targets Octofet nearest to the controller.