Documentation ¶
Overview ¶
Package b6max provides for communication to SkyRC iMAX and compatible battery chargers.
Tested on SkyRC iMAX B6V2. May work with others.
Index ¶
- Constants
- type B6Max
- func (b *B6Max) Close() error
- func (b *B6Max) Open() error
- func (b *B6Max) ReadDevInfo() (*DevInfo, error)
- func (b *B6Max) ReadProgramState() (*ProgramState, error)
- func (b *B6Max) ReadSysInfo() (*SysInfo, error)
- func (b *B6Max) Start(p *ProgramStart) error
- func (b *B6Max) Stop() (*ProgramStop, error)
- type BatteryType
- type CycleType
- type DevInfo
- type ProgramStart
- type ProgramState
- type ProgramStop
- type ProgramType
- type State
- type SysInfo
Constants ¶
const ( ChargeDischarge = iota DischargeCharge )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type B6Max ¶
type B6Max struct { // UsbInfo is the underlying USB information. UsbInfo usb.DeviceInfo // UsbDevice is the opened USB connection. UsbDevice usb.Device }
B6Max represents a B6Max device.
func (*B6Max) ReadDevInfo ¶
ReadDevInfo reads device hardware and software parameters.
func (*B6Max) ReadProgramState ¶
func (b *B6Max) ReadProgramState() (*ProgramState, error)
ReadProgramState reads the current (dis)charging status.
func (*B6Max) ReadSysInfo ¶
ReadSysInfo reads the system config information from the device.
func (*B6Max) Start ¶
func (b *B6Max) Start(p *ProgramStart) error
Start tells the device to start a program per the provided parameters.
func (*B6Max) Stop ¶
func (b *B6Max) Stop() (*ProgramStop, error)
Stop sends a stop command to the device.
type BatteryType ¶
type BatteryType uint8
BatteryType is the battery type connected.
const ( LiPo BatteryType = iota LiIo LiFe // LiHv slots in here for newer chargers (changes const values) NiMh NiCd Pb )
func (BatteryType) String ¶
func (b BatteryType) String() string
type DevInfo ¶
type DevInfo struct { // CoreType is the core type of the device. CoreType [6]byte // UpgradeType is ?? UpgradeType uint8 // IsEncrypt is ?? IsEncrypt uint8 // CustomerID is ?? CustomerID uint16 // LanguageID is ?? LanguageID uint8 // SwVersion is the current software version. SwVersion uint16 // HwVersion is the current hardware version. HwVersion uint8 // contains filtered or unexported fields }
DevInfo represents device hardware configuration.
type ProgramStart ¶
type ProgramStart struct { // The battery type connected. BatteryType BatteryType // Number of cells. Cells byte // Program type requested. PwmMode ProgramType // Maximum charge current requested. ChargeCurrent uint16 // Maximum discharge current requested. DischargeCurrent uint16 // Discharge cutoff voltage, millivolts. DischargeCutoff uint16 // Cutoff voltage for charging. // For Ni* batteries, this is the delta-v end-of-charge detection (typically 4mv) ChargeCutoff uint16 // Thie field depends on the charge mode. If RePeak, it's the number of // cycles to perform. If Cycle, it's the cycle type. RePeakCycleInfo uint8 // Number of charge/discharge cycles in Cycle mode. 1-5 CycleCount uint8 // Trickle charge (mA). Trickle uint16 // contains filtered or unexported fields }
ProgramStart is a request to start a program.
type ProgramState ¶
type ProgramState struct { // WorkState is the current device state. WorkState State // ErrorCode is the error code, if WorkState is StateError. // If not errored, the total (dis)charge current at this moment. ErrorCodeMah uint16 // Number of seconds the program has been running. Time uint16 // The voltage at this moment. MilliVolt uint16 // The current at this moment. MilliAmp uint16 // Temperature of the external sensor. TemperatureExternal uint8 // Temperature of the internal sensor. TemperatureInternal uint8 // Impedance of the attached battery. Impedance uint16 // Voltage of the attached cells at the balance port. Cells [6]uint16 // contains filtered or unexported fields }
ProgramState represents current program info.
func (*ProgramState) Header ¶
func (p *ProgramState) Header() string
Header returns a header string for displaying ProgramState.
func (*ProgramState) String ¶
func (p *ProgramState) String() string
String returns a string of the current ProgramState.
type ProgramType ¶
type ProgramType uint8
ProgramType is the requested program type.
const ( Charge ProgramType = iota Discharge Storage FastCharge Balance AutoCharge RePeak Cycle )
func (ProgramType) String ¶
func (p ProgramType) String() string
type State ¶
type State uint8
State is the current operating state.
const ( StateRunning State StateIdle StateFinish StateError )
type SysInfo ¶
type SysInfo struct { // CycleTime is the rest time between charge->discharge cycles (minutes, max 60). CycleTime uint8 // TimeLimitOn is whether the time limit is enabled. TimeLimitOn uint8 // TimeLimit is the maximum duration of a program (minutes). TimeLimit uint16 // CapLimitOn is whether the Cap limit is enabled. CapLimitOn uint8 // CapLimit is the maximum charge mAh for a program. CapLimit uint16 // KeyBuzz is whether the keypress sound is enabled. KeyBuzz uint8 // SysBuzz is whether system sounds are enabled. SysBuzz uint8 // InDCLow is the lower DC input voltage limit. InDCLowLimit uint16 // TempLimit is the maximum allowed operating temperature (Celcius). TemperatureLimit uint8 // Voltage represents the current voltage of ?? Millivolts uint16 // Cells are the current voltages of the cells at the balance port. Cells [6]uint16 // contains filtered or unexported fields }
SysInfo represents system configuration information.