Skip to content

Instantly share code, notes, and snippets.

@fionera
Last active July 1, 2021 20:19
Show Gist options
  • Save fionera/d8d804154c5af5a828937843e9e5b286 to your computer and use it in GitHub Desktop.
Save fionera/d8d804154c5af5a828937843e9e5b286 to your computer and use it in GitHub Desktop.
RunCam 5 QR Code Generator
module RCFiveGenerator
go 1.16
require (
github.com/yeqown/go-qrcode v1.5.5
golang.org/x/tools v0.1.4
)
replace github.com/yeqown/go-qrcode => ./go-qrcode
package main
import (
"fmt"
"log"
"time"
"github.com/yeqown/go-qrcode"
)
//go:generate stringer -type=VideoResolution,VideoQuality,Bool,VideoISO,VideoEXPT,DistortionCorrection,TimeRange,DateStamp,Exposure,RangeValue,MeteringMode,WhiteBalance,LowLightImageEnhancement,PowerSupplyFrequency,VolumeLevel,UserColor,DigitalIs,UsbMulti -output string.go
type VideoResolution int
const (
VideoResolution4k30 VideoResolution = iota
VideoResolution27K60
VideoResolution27K50
VideoResolution1440P60
VideoResolution1080P120
VideoResolution1080P60
VideoResolution4k30SV
VideoResolution4k30XV
VideoResolution1080P60SV
VideoResolution1080P60XV
)
type VideoQuality int
const (
VideoQualityHigh VideoQuality = iota
VideoQualityMedium
VideoQualityLow
)
type Bool int
const (
BoolYes Bool = iota
BoolNo
)
type TimeRange int
const (
TimeRangeOff TimeRange = iota
TimeRange1Min
TimeRange3Min
TimeRange5Min
)
type VideoISO int
const (
VideoISOTest VideoISO = iota
)
type VideoEXPT int
const (
VideoEXPTTest VideoEXPT = iota
)
type DistortionCorrection int
const (
DistortionCorrectionTest DistortionCorrection = iota
)
type DateStamp int
const (
DateStampOff DateStamp = iota
DateStampDate
DateStampDateTime
)
type Exposure int
const (
ExposureMinus2 Exposure = iota
ExposureMinus17
ExposureMinus13
ExposureMinus1
ExposureMinus07
ExposureMinus03
ExposureZero
ExposurePlus03
ExposurePlus07
ExposurePlus1
ExposurePlus13
ExposurePlus17
ExposurePlus2
)
type RangeValue int
const (
RangeValue1 RangeValue = iota
RangeValue2
RangeValue3
)
type MeteringMode int
const (
MeteringModeCenter MeteringMode = iota
MeteringModeAverage
MeteringModeSpot
)
type WhiteBalance int
const (
WhiteBalanceAuto WhiteBalance = iota
WhiteBalanceDaylight
WhiteBalanceCloudy
WhiteBalanceTungsten
WhiteBalanceFluorescent
)
type LowLightImageEnhancement int
const (
LowLightImageEnhancementTest LowLightImageEnhancement = iota
)
type PowerSupplyFrequency int
const (
PowerSupplyFrequency50PAL PowerSupplyFrequency = iota
PowerSupplyFrequency60NTSC
)
type VolumeLevel int
const (
VolumeLevelLow VolumeLevel = iota
VolumeLevelMedium
VolumeLevelHigh
)
type UserColor int
const (
UserColorTest UserColor = iota
)
type DigitalIs int
const (
DigitalIsTest DigitalIs = iota
)
type UsbMulti int
const (
UsbMultiTest UsbMulti = iota
)
// Stabilizitation and LowLight testing
type CameraSettings struct {
VideoQuality VideoQuality
LoopRecordingInterval TimeRange
Resolution VideoResolution
VideoISO VideoISO
VideoEXPT VideoEXPT
AutoRecording Bool
DistortionCorrection Bool
DateStamp DateStamp
LogoStamp Bool
ImageFlip Bool
Saturation RangeValue
Exposure Exposure
Contrast RangeValue
Sharpness RangeValue
MeteringMode MeteringMode
WhiteBalance WhiteBalance
LowLightImageEnhancement LowLightImageEnhancement
PowerSavingMode TimeRange
PowerSupplyFrequency PowerSupplyFrequency
VolumeLevel VolumeLevel
UserColor UserColor
DigitalIs DigitalIs
Time time.Time
UsbMulti UsbMulti
}
func (c CameraSettings) MarshalText() (text []byte, err error) {
return []byte(fmt.Sprintf("0401%d%d%d%d%d%d%d%d%d%d%d%02d%d%d%d%d%d%d%d%d%d%d%s%d",
c.VideoQuality,
c.LoopRecordingInterval,
c.Resolution,
c.VideoISO,
c.VideoEXPT,
c.AutoRecording,
c.DistortionCorrection,
c.DateStamp,
c.LogoStamp,
c.ImageFlip,
c.Saturation,
c.Exposure,
c.Contrast,
c.Sharpness,
c.MeteringMode,
c.WhiteBalance,
c.LowLightImageEnhancement,
c.PowerSavingMode,
c.PowerSupplyFrequency,
c.VolumeLevel,
c.UserColor,
c.DigitalIs,
c.Time.Format("20060102150405"),
c.UsbMulti)), nil
}
func main() {
c := CameraSettings{
VideoQuality: VideoQualityHigh,
LoopRecordingInterval: TimeRangeOff,
Resolution: VideoResolution4k30,
VideoISO: 0,
VideoEXPT: 0,
AutoRecording: BoolNo,
DistortionCorrection: BoolYes,
DateStamp: DateStampOff,
LogoStamp: BoolNo,
ImageFlip: BoolNo,
Saturation: RangeValue2,
Exposure: ExposureZero,
Contrast: RangeValue2,
Sharpness: RangeValue2,
MeteringMode: MeteringModeAverage,
WhiteBalance: WhiteBalanceCloudy,
LowLightImageEnhancement: 1,
PowerSavingMode: TimeRangeOff,
PowerSupplyFrequency: PowerSupplyFrequency50PAL,
VolumeLevel: VolumeLevelLow,
UserColor: 1,
DigitalIs: 0,
Time: time.Now(),
UsbMulti: 0,
}
data, err := c.MarshalText()
if err != nil {
log.Fatal(err)
}
qrc, err := qrcode.New(string(data), qrcode.WithErrorCorrectionLevel(qrcode.Highest), qrcode.WithEncodingMode(qrcode.EncModeNumeric))
if err != nil {
log.Fatalf("could not generate QRCode: %v", err)
}
if err := qrc.Save("./qrcode.jpeg"); err != nil {
log.Fatalf("could not save image: %v", err)
}
}
// Code generated by "stringer -type=VideoResolution,VideoQuality,Bool,VideoISO,VideoEXPT,DistortionCorrection,TimeRange,DateStamp,Exposure,RangeValue,MeteringMode,WhiteBalance,LowLightImageEnhancement,PowerSupplyFrequency,VolumeLevel,UserColor,DigitalIs,UsbMulti -output string.go"; DO NOT EDIT.
package main
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[VideoResolution4k30-0]
_ = x[VideoResolution27K60-1]
_ = x[VideoResolution27K50-2]
_ = x[VideoResolution1440P60-3]
_ = x[VideoResolution1080P120-4]
_ = x[VideoResolution1080P60-5]
_ = x[VideoResolution4k30SV-6]
_ = x[VideoResolution4k30XV-7]
_ = x[VideoResolution1080P60SV-8]
_ = x[VideoResolution1080P60XV-9]
}
const _VideoResolution_name = "VideoResolution4k30VideoResolution27K60VideoResolution27K50VideoResolution1440P60VideoResolution1080P120VideoResolution1080P60VideoResolution4k30SVVideoResolution4k30XVVideoResolution1080P60SVVideoResolution1080P60XV"
var _VideoResolution_index = [...]uint8{0, 19, 39, 59, 81, 104, 126, 147, 168, 192, 216}
func (i VideoResolution) String() string {
if i < 0 || i >= VideoResolution(len(_VideoResolution_index)-1) {
return "VideoResolution(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _VideoResolution_name[_VideoResolution_index[i]:_VideoResolution_index[i+1]]
}
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[VideoQualityHigh-0]
_ = x[VideoQualityMedium-1]
_ = x[VideoQualityLow-2]
}
const _VideoQuality_name = "VideoQualityHighVideoQualityMediumVideoQualityLow"
var _VideoQuality_index = [...]uint8{0, 16, 34, 49}
func (i VideoQuality) String() string {
if i < 0 || i >= VideoQuality(len(_VideoQuality_index)-1) {
return "VideoQuality(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _VideoQuality_name[_VideoQuality_index[i]:_VideoQuality_index[i+1]]
}
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[BoolYes-0]
_ = x[BoolNo-1]
}
const _Bool_name = "BoolYesBoolNo"
var _Bool_index = [...]uint8{0, 7, 13}
func (i Bool) String() string {
if i < 0 || i >= Bool(len(_Bool_index)-1) {
return "Bool(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _Bool_name[_Bool_index[i]:_Bool_index[i+1]]
}
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[VideoISOTest-0]
}
const _VideoISO_name = "VideoISOTest"
var _VideoISO_index = [...]uint8{0, 12}
func (i VideoISO) String() string {
if i < 0 || i >= VideoISO(len(_VideoISO_index)-1) {
return "VideoISO(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _VideoISO_name[_VideoISO_index[i]:_VideoISO_index[i+1]]
}
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[VideoEXPTTest-0]
}
const _VideoEXPT_name = "VideoEXPTTest"
var _VideoEXPT_index = [...]uint8{0, 13}
func (i VideoEXPT) String() string {
if i < 0 || i >= VideoEXPT(len(_VideoEXPT_index)-1) {
return "VideoEXPT(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _VideoEXPT_name[_VideoEXPT_index[i]:_VideoEXPT_index[i+1]]
}
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[DistortionCorrectionTest-0]
}
const _DistortionCorrection_name = "DistortionCorrectionTest"
var _DistortionCorrection_index = [...]uint8{0, 24}
func (i DistortionCorrection) String() string {
if i < 0 || i >= DistortionCorrection(len(_DistortionCorrection_index)-1) {
return "DistortionCorrection(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _DistortionCorrection_name[_DistortionCorrection_index[i]:_DistortionCorrection_index[i+1]]
}
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[TimeRangeOff-0]
_ = x[TimeRange1Min-1]
_ = x[TimeRange3Min-2]
_ = x[TimeRange5Min-3]
}
const _TimeRange_name = "TimeRangeOffTimeRange1MinTimeRange3MinTimeRange5Min"
var _TimeRange_index = [...]uint8{0, 12, 25, 38, 51}
func (i TimeRange) String() string {
if i < 0 || i >= TimeRange(len(_TimeRange_index)-1) {
return "TimeRange(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _TimeRange_name[_TimeRange_index[i]:_TimeRange_index[i+1]]
}
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[DateStampOff-0]
_ = x[DateStampDate-1]
_ = x[DateStampDateTime-2]
}
const _DateStamp_name = "DateStampOffDateStampDateDateStampDateTime"
var _DateStamp_index = [...]uint8{0, 12, 25, 42}
func (i DateStamp) String() string {
if i < 0 || i >= DateStamp(len(_DateStamp_index)-1) {
return "DateStamp(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _DateStamp_name[_DateStamp_index[i]:_DateStamp_index[i+1]]
}
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[ExposureMinus2-0]
_ = x[ExposureMinus17-1]
_ = x[ExposureMinus13-2]
_ = x[ExposureMinus1-3]
_ = x[ExposureMinus07-4]
_ = x[ExposureMinus03-5]
_ = x[ExposureZero-6]
_ = x[ExposurePlus03-7]
_ = x[ExposurePlus07-8]
_ = x[ExposurePlus1-9]
_ = x[ExposurePlus13-10]
_ = x[ExposurePlus17-11]
_ = x[ExposurePlus2-12]
}
const _Exposure_name = "ExposureMinus2ExposureMinus17ExposureMinus13ExposureMinus1ExposureMinus07ExposureMinus03ExposureZeroExposurePlus03ExposurePlus07ExposurePlus1ExposurePlus13ExposurePlus17ExposurePlus2"
var _Exposure_index = [...]uint8{0, 14, 29, 44, 58, 73, 88, 100, 114, 128, 141, 155, 169, 182}
func (i Exposure) String() string {
if i < 0 || i >= Exposure(len(_Exposure_index)-1) {
return "Exposure(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _Exposure_name[_Exposure_index[i]:_Exposure_index[i+1]]
}
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[RangeValue1-0]
_ = x[RangeValue2-1]
_ = x[RangeValue3-2]
}
const _RangeValue_name = "RangeValue1RangeValue2RangeValue3"
var _RangeValue_index = [...]uint8{0, 11, 22, 33}
func (i RangeValue) String() string {
if i < 0 || i >= RangeValue(len(_RangeValue_index)-1) {
return "RangeValue(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _RangeValue_name[_RangeValue_index[i]:_RangeValue_index[i+1]]
}
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[MeteringModeCenter-0]
_ = x[MeteringModeAverage-1]
_ = x[MeteringModeSpot-2]
}
const _MeteringMode_name = "MeteringModeCenterMeteringModeAverageMeteringModeSpot"
var _MeteringMode_index = [...]uint8{0, 18, 37, 53}
func (i MeteringMode) String() string {
if i < 0 || i >= MeteringMode(len(_MeteringMode_index)-1) {
return "MeteringMode(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _MeteringMode_name[_MeteringMode_index[i]:_MeteringMode_index[i+1]]
}
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[WhiteBalanceAuto-0]
_ = x[WhiteBalanceDaylight-1]
_ = x[WhiteBalanceCloudy-2]
_ = x[WhiteBalanceTungsten-3]
_ = x[WhiteBalanceFluorescent-4]
}
const _WhiteBalance_name = "WhiteBalanceAutoWhiteBalanceDaylightWhiteBalanceCloudyWhiteBalanceTungstenWhiteBalanceFluorescent"
var _WhiteBalance_index = [...]uint8{0, 16, 36, 54, 74, 97}
func (i WhiteBalance) String() string {
if i < 0 || i >= WhiteBalance(len(_WhiteBalance_index)-1) {
return "WhiteBalance(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _WhiteBalance_name[_WhiteBalance_index[i]:_WhiteBalance_index[i+1]]
}
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[LowLightImageEnhancementTest-0]
}
const _LowLightImageEnhancement_name = "LowLightImageEnhancementTest"
var _LowLightImageEnhancement_index = [...]uint8{0, 28}
func (i LowLightImageEnhancement) String() string {
if i < 0 || i >= LowLightImageEnhancement(len(_LowLightImageEnhancement_index)-1) {
return "LowLightImageEnhancement(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _LowLightImageEnhancement_name[_LowLightImageEnhancement_index[i]:_LowLightImageEnhancement_index[i+1]]
}
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[PowerSupplyFrequency50PAL-0]
_ = x[PowerSupplyFrequency60NTSC-1]
}
const _PowerSupplyFrequency_name = "PowerSupplyFrequency50PALPowerSupplyFrequency60NTSC"
var _PowerSupplyFrequency_index = [...]uint8{0, 25, 51}
func (i PowerSupplyFrequency) String() string {
if i < 0 || i >= PowerSupplyFrequency(len(_PowerSupplyFrequency_index)-1) {
return "PowerSupplyFrequency(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _PowerSupplyFrequency_name[_PowerSupplyFrequency_index[i]:_PowerSupplyFrequency_index[i+1]]
}
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[VolumeLevelLow-0]
_ = x[VolumeLevelMedium-1]
_ = x[VolumeLevelHigh-2]
}
const _VolumeLevel_name = "VolumeLevelLowVolumeLevelMediumVolumeLevelHigh"
var _VolumeLevel_index = [...]uint8{0, 14, 31, 46}
func (i VolumeLevel) String() string {
if i < 0 || i >= VolumeLevel(len(_VolumeLevel_index)-1) {
return "VolumeLevel(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _VolumeLevel_name[_VolumeLevel_index[i]:_VolumeLevel_index[i+1]]
}
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[UserColorTest-0]
}
const _UserColor_name = "UserColorTest"
var _UserColor_index = [...]uint8{0, 13}
func (i UserColor) String() string {
if i < 0 || i >= UserColor(len(_UserColor_index)-1) {
return "UserColor(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _UserColor_name[_UserColor_index[i]:_UserColor_index[i+1]]
}
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[DigitalIsTest-0]
}
const _DigitalIs_name = "DigitalIsTest"
var _DigitalIs_index = [...]uint8{0, 13}
func (i DigitalIs) String() string {
if i < 0 || i >= DigitalIs(len(_DigitalIs_index)-1) {
return "DigitalIs(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _DigitalIs_name[_DigitalIs_index[i]:_DigitalIs_index[i+1]]
}
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[UsbMultiTest-0]
}
const _UsbMulti_name = "UsbMultiTest"
var _UsbMulti_index = [...]uint8{0, 12}
func (i UsbMulti) String() string {
if i < 0 || i >= UsbMulti(len(_UsbMulti_index)-1) {
return "UsbMulti(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _UsbMulti_name[_UsbMulti_index[i]:_UsbMulti_index[i+1]]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment