diff --git a/devices/bme280/bme280.go b/devices/bme280/bme280.go index e89d2cb..f638960 100644 --- a/devices/bme280/bme280.go +++ b/devices/bme280/bme280.go @@ -51,11 +51,11 @@ const oversamplingName = "Off1x2x4x8x16x" var oversamplingIndex = [...]uint8{0, 3, 5, 7, 9, 11, 14} -func (i Oversampling) String() string { - if i >= Oversampling(len(oversamplingIndex)-1) { - return fmt.Sprintf("Oversampling(%d)", i) +func (o Oversampling) String() string { + if o >= Oversampling(len(oversamplingIndex)-1) { + return fmt.Sprintf("Oversampling(%d)", o) } - return oversamplingName[oversamplingIndex[i]:oversamplingIndex[i+1]] + return oversamplingName[oversamplingIndex[o]:oversamplingIndex[o+1]] } func (o Oversampling) asValue() int { diff --git a/devices/devicestest/display.go b/devices/devicestest/display.go index e7cc0fb..2a56311 100644 --- a/devices/devicestest/display.go +++ b/devices/devicestest/display.go @@ -23,6 +23,7 @@ func (d *Display) String() string { return "Display" } +// Halt implements devices.Device. It is a noop. func (d *Display) Halt() error { return nil } diff --git a/devices/ds248x/ds248x.go b/devices/ds248x/ds248x.go index 4162878..de3398b 100644 --- a/devices/ds248x/ds248x.go +++ b/devices/ds248x/ds248x.go @@ -113,7 +113,7 @@ func (d *Dev) makeDev(opts *Opts) error { return fmt.Errorf("ds248x: error while reading status register: %s", err) } if stat[0] != 0x18 { - return fmt.Errorf("ds248x: invalid status register value: %#x, expected 0x18\n", stat[0]) + return fmt.Errorf("ds248x: invalid status register value: %#x, expected 0x18", stat[0]) } // Write the device configuration register to get the chip out of reset state, immediately diff --git a/devices/lepton/cci/cci.go b/devices/lepton/cci/cci.go index 8214ee1..5b114ed 100644 --- a/devices/lepton/cci/cci.go +++ b/devices/lepton/cci/cci.go @@ -117,15 +117,15 @@ const ( type FFCState uint8 const ( - // No FFC was requested. + // FFCNever means no FFC was requested. FFCNever FFCState = 0 - // FFC is in progress. It lasts 23 frames (at 27fps) so it lasts less than a second. + // FFCInProgress means a FFC is in progress. It lasts 23 frames (at 27fps) so it lasts less than a second. FFCInProgress FFCState = 1 - // FFC was completed successfully. + // FFCComplete means FFC was completed successfully. FFCComplete FFCState = 2 ) -// FFCMode +// FFCMode describes the various self-calibration settings and state. type FFCMode struct { FFCShutterMode FFCShutterMode // Default: FFCShutterModeExternal ShutterTempLockoutState ShutterTempLockoutState // Default: ShutterTempLockoutStateInactive diff --git a/devices/lepton/cci/strings_gen.go b/devices/lepton/cci/strings_gen.go index 35a58b2..4b1b55b 100644 --- a/devices/lepton/cci/strings_gen.go +++ b/devices/lepton/cci/strings_gen.go @@ -1,138 +1,136 @@ // Code generated by "stringer -output=strings_gen.go -type=CameraStatus,command,FFCShutterMode,FFCState,ShutterPos,ShutterTempLockoutState"; DO NOT EDIT. +// then manually modified to remove golint errors. :) package cci import "fmt" -const _CameraStatus_name = "SystemReadySystemInitializingSystemInLowPowerModeSystemGoingIntoStandbySystemFlatFieldInProcess" +const cameraStatusName = "SystemReadySystemInitializingSystemInLowPowerModeSystemGoingIntoStandbySystemFlatFieldInProcess" -var _CameraStatus_index = [...]uint8{0, 11, 29, 49, 71, 95} +var cameraStatusIndex = [...]uint8{0, 11, 29, 49, 71, 95} func (i CameraStatus) String() string { - if i >= CameraStatus(len(_CameraStatus_index)-1) { + if i >= CameraStatus(len(cameraStatusIndex)-1) { return fmt.Sprintf("CameraStatus(%d)", i) } - return _CameraStatus_name[_CameraStatus_index[i]:_CameraStatus_index[i+1]] + return cameraStatusName[cameraStatusIndex[i]:cameraStatusIndex[i+1]] } -const _command_name = "agcEnableagcRoiSelectagcHistogramStatsagcHeqDampFactoragcHeqClipLimitHighagcHeqClipLimitLowagcHeqEmptyCountsagcHeqOutputScaleFactoragcCalculationEnablesysPingsysStatussysSerialNumbersysUptimesysHousingTemperaturesysTemperaturesysTelemetryEnablesysTelemetryLocationsysExecuteFrameAveragesysFlatFieldFramessysCustomSerialNumbersysRoiSceneStatssysRoiSceneSelectsysThermalShutdownCountsysShutterPositionsysFFCModesysFCCRunNormalizationsysFCCStatusvidColorLookupSelectvidColorLookupTransfervidFocusCalculationEnablevidFocusRoiSelectvidFocusMetricThresholdvidFocusMetricGetvidVideoFreezeEnableoemShutterProfileoemPowerDownoemPartNumberoemSoftwareRevisionoemVideoOutputEnableoemVideoOutputFormatoemVideoOutputSourceoemCustomerPartNumberoemVideoOutputConstoemCameraRebootoemFCCNormalizationTargetoemStatusoemFrameMeanIntensityoemGPIOModeSelectoemGPIOVSyncPhaseDelayoemUserDefaultsoemRestoreUserDefaultsoemThermalShutdownEnableoemBadPixeloemTemporalFilteroemColumnNoiseFilteroemPixelNoiseFilter" - -var _command_map = map[command]string{ - 256: _command_name[0:9], - 264: _command_name[9:21], - 268: _command_name[21:38], - 292: _command_name[38:54], - 300: _command_name[54:73], - 304: _command_name[73:91], - 316: _command_name[91:108], - 324: _command_name[108:131], - 328: _command_name[131:151], - 512: _command_name[151:158], - 516: _command_name[158:167], - 520: _command_name[167:182], - 524: _command_name[182:191], - 528: _command_name[191:212], - 532: _command_name[212:226], - 536: _command_name[226:244], - 540: _command_name[244:264], - 544: _command_name[264:286], - 548: _command_name[286:304], - 552: _command_name[304:325], - 556: _command_name[325:341], - 560: _command_name[341:358], - 564: _command_name[358:381], - 568: _command_name[381:399], - 572: _command_name[399:409], - 576: _command_name[409:431], - 580: _command_name[431:443], - 772: _command_name[443:463], - 776: _command_name[463:485], - 780: _command_name[485:510], - 784: _command_name[510:527], - 788: _command_name[527:550], - 792: _command_name[550:567], - 804: _command_name[567:587], - 16484: _command_name[587:604], - 18432: _command_name[604:616], - 18460: _command_name[616:629], - 18464: _command_name[629:648], - 18468: _command_name[648:668], - 18472: _command_name[668:688], - 18476: _command_name[688:708], - 18488: _command_name[708:729], - 18492: _command_name[729:748], - 18496: _command_name[748:763], - 18500: _command_name[763:788], - 18504: _command_name[788:797], - 18508: _command_name[797:818], - 18516: _command_name[818:835], - 18520: _command_name[835:857], - 18524: _command_name[857:872], - 18528: _command_name[872:894], - 18536: _command_name[894:918], - 18540: _command_name[918:929], - 18544: _command_name[929:946], - 18548: _command_name[946:966], - 18552: _command_name[966:985], +const commandName = "agcEnableagcRoiSelectagcHistogramStatsagcHeqDampFactoragcHeqClipLimitHighagcHeqClipLimitLowagcHeqEmptyCountsagcHeqOutputScaleFactoragcCalculationEnablesysPingsysStatussysSerialNumbersysUptimesysHousingTemperaturesysTemperaturesysTelemetryEnablesysTelemetryLocationsysExecuteFrameAveragesysFlatFieldFramessysCustomSerialNumbersysRoiSceneStatssysRoiSceneSelectsysThermalShutdownCountsysShutterPositionsysFFCModesysFCCRunNormalizationsysFCCStatusvidColorLookupSelectvidColorLookupTransfervidFocusCalculationEnablevidFocusRoiSelectvidFocusMetricThresholdvidFocusMetricGetvidVideoFreezeEnableoemShutterProfileoemPowerDownoemPartNumberoemSoftwareRevisionoemVideoOutputEnableoemVideoOutputFormatoemVideoOutputSourceoemCustomerPartNumberoemVideoOutputConstoemCameraRebootoemFCCNormalizationTargetoemStatusoemFrameMeanIntensityoemGPIOModeSelectoemGPIOVSyncPhaseDelayoemUserDefaultsoemRestoreUserDefaultsoemThermalShutdownEnableoemBadPixeloemTemporalFilteroemColumnNoiseFilteroemPixelNoiseFilter" + +var commandMap = map[command]string{ + 256: commandName[0:9], + 264: commandName[9:21], + 268: commandName[21:38], + 292: commandName[38:54], + 300: commandName[54:73], + 304: commandName[73:91], + 316: commandName[91:108], + 324: commandName[108:131], + 328: commandName[131:151], + 512: commandName[151:158], + 516: commandName[158:167], + 520: commandName[167:182], + 524: commandName[182:191], + 528: commandName[191:212], + 532: commandName[212:226], + 536: commandName[226:244], + 540: commandName[244:264], + 544: commandName[264:286], + 548: commandName[286:304], + 552: commandName[304:325], + 556: commandName[325:341], + 560: commandName[341:358], + 564: commandName[358:381], + 568: commandName[381:399], + 572: commandName[399:409], + 576: commandName[409:431], + 580: commandName[431:443], + 772: commandName[443:463], + 776: commandName[463:485], + 780: commandName[485:510], + 784: commandName[510:527], + 788: commandName[527:550], + 792: commandName[550:567], + 804: commandName[567:587], + 16484: commandName[587:604], + 18432: commandName[604:616], + 18460: commandName[616:629], + 18464: commandName[629:648], + 18468: commandName[648:668], + 18472: commandName[668:688], + 18476: commandName[688:708], + 18488: commandName[708:729], + 18492: commandName[729:748], + 18496: commandName[748:763], + 18500: commandName[763:788], + 18504: commandName[788:797], + 18508: commandName[797:818], + 18516: commandName[818:835], + 18520: commandName[835:857], + 18524: commandName[857:872], + 18528: commandName[872:894], + 18536: commandName[894:918], + 18540: commandName[918:929], + 18544: commandName[929:946], + 18548: commandName[946:966], + 18552: commandName[966:985], } func (i command) String() string { - if str, ok := _command_map[i]; ok { + if str, ok := commandMap[i]; ok { return str } return fmt.Sprintf("command(%d)", i) } -const _FFCShutterMode_name = "FFCShutterModeManualFFCShutterModeAutoFFCShutterModeExternal" +const ffcShutterModeName = "FFCShutterModeManualFFCShutterModeAutoFFCShutterModeExternal" -var _FFCShutterMode_index = [...]uint8{0, 20, 38, 60} +var ffcShutterModeIndex = [...]uint8{0, 20, 38, 60} func (i FFCShutterMode) String() string { - if i >= FFCShutterMode(len(_FFCShutterMode_index)-1) { + if i >= FFCShutterMode(len(ffcShutterModeIndex)-1) { return fmt.Sprintf("FFCShutterMode(%d)", i) } - return _FFCShutterMode_name[_FFCShutterMode_index[i]:_FFCShutterMode_index[i+1]] + return ffcShutterModeName[ffcShutterModeIndex[i]:ffcShutterModeIndex[i+1]] } -const _FFCState_name = "FFCNeverFFCInProgressFFCComplete" +const ffcStateName = "FFCNeverFFCInProgressFFCComplete" -var _FFCState_index = [...]uint8{0, 8, 21, 32} +var ffcStateIndex = [...]uint8{0, 8, 21, 32} func (i FFCState) String() string { - if i >= FFCState(len(_FFCState_index)-1) { + if i >= FFCState(len(ffcStateIndex)-1) { return fmt.Sprintf("FFCState(%d)", i) } - return _FFCState_name[_FFCState_index[i]:_FFCState_index[i+1]] + return ffcStateName[ffcStateIndex[i]:ffcStateIndex[i+1]] } const ( - _ShutterPos_name_0 = "ShutterPosIdleShutterPosOpenShutterPosClosedShutterPosBrakeOn" - _ShutterPos_name_1 = "ShutterPosUnknown" + shutterPosName0 = "ShutterPosIdleShutterPosOpenShutterPosClosedShutterPosBrakeOn" + shutterPosName1 = "ShutterPosUnknown" ) -var ( - _ShutterPos_index_0 = [...]uint8{0, 14, 28, 44, 61} - _ShutterPos_index_1 = [...]uint8{0, 17} -) +var shutterPosIndex0 = [...]uint8{0, 14, 28, 44, 61} func (i ShutterPos) String() string { switch { case 0 <= i && i <= 3: - return _ShutterPos_name_0[_ShutterPos_index_0[i]:_ShutterPos_index_0[i+1]] + return shutterPosName0[shutterPosIndex0[i]:shutterPosIndex0[i+1]] case i == 4294967295: - return _ShutterPos_name_1 + return shutterPosName1 default: return fmt.Sprintf("ShutterPos(%d)", i) } } -const _ShutterTempLockoutState_name = "ShutterTempLockoutStateInactiveShutterTempLockoutStateHighShutterTempLockoutStateLow" +const shutterTempLockoutStateName = "ShutterTempLockoutStateInactiveShutterTempLockoutStateHighShutterTempLockoutStateLow" -var _ShutterTempLockoutState_index = [...]uint8{0, 31, 58, 84} +var shutterTempLockoutStateIndex = [...]uint8{0, 31, 58, 84} func (i ShutterTempLockoutState) String() string { - if i >= ShutterTempLockoutState(len(_ShutterTempLockoutState_index)-1) { + if i >= ShutterTempLockoutState(len(shutterTempLockoutStateIndex)-1) { return fmt.Sprintf("ShutterTempLockoutState(%d)", i) } - return _ShutterTempLockoutState_name[_ShutterTempLockoutState_index[i]:_ShutterTempLockoutState_index[i+1]] + return shutterTempLockoutStateName[shutterTempLockoutStateIndex[i]:shutterTempLockoutStateIndex[i+1]] } diff --git a/devices/lepton/internal/internal.go b/devices/lepton/internal/internal.go index f5c8226..a3d5f22 100644 --- a/devices/lepton/internal/internal.go +++ b/devices/lepton/internal/internal.go @@ -25,6 +25,7 @@ const ( // It is an implementation detail of the protocol. type DurationMS uint32 +// ToD converts a millisecond based timing to time.Duration. func (d DurationMS) ToD() time.Duration { return time.Duration(d) * time.Millisecond } @@ -34,6 +35,7 @@ func (d DurationMS) ToD() time.Duration { // It is an implementation detail of the protocol. type CentiK uint16 +// ToC converts a Kelvin measurement to Celsius. func (c CentiK) ToC() devices.Celsius { v := (int(c) - 27315) * 10 return devices.Celsius(v) @@ -46,7 +48,7 @@ type Status struct { Reserved uint16 } -// FFCMode +// FFCMode describes the various self-calibration settings and state. type FFCMode struct { FFCShutterMode uint32 // Default: FFCShutterModeExternal ShutterTempLockoutState uint32 // Default: ShutterTempLockoutStateInactive diff --git a/devices/lepton/lepton.go b/devices/lepton/lepton.go index d9804c7..040898e 100644 --- a/devices/lepton/lepton.go +++ b/devices/lepton/lepton.go @@ -315,7 +315,7 @@ func (m *Metadata) parseTelemetry(data []byte) error { m.FFCTemp = rowA.FPATempLastFFC.ToC() m.FFCTempHousing = rowA.HousingTempLastFFC.ToC() if rowA.StatusBits&statusMaskNil != 0 { - return fmt.Errorf("\n(Status: 0x%08X) & (Mask: 0x%08X) = (Extra: 0x%08X) in 0x%08X\n", rowA.StatusBits, statusMask, rowA.StatusBits&statusMaskNil, statusMaskNil) + return fmt.Errorf("lepton: (Status: 0x%08X) & (Mask: 0x%08X) = (Extra: 0x%08X) in 0x%08X", rowA.StatusBits, statusMask, rowA.StatusBits&statusMaskNil, statusMaskNil) } m.FFCDesired = rowA.StatusBits&statusFFCDesired != 0 m.Overtemp = rowA.StatusBits&statusOvertemp != 0