util

package
v0.0.0-...-d12e797 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DevMode ...
	DevMode = "dev"
	// PrdMode ...
	PrdMode = "prd"
)

Variables

View Source
var ErrEmpty = errors.New("empty")

ErrEmpty ...

Functions

func DelayMs

func DelayMs(ms int)

DelayMs ...

func GetIP

func GetIP() string

GetIP ...

func PlayMp3

func PlayMp3(mp3 string) error

PlayMp3 play mp3 audio using mpg123 you need to install mpg123 first

func PlayWav

func PlayWav(wav string) error

PlayWav plays wav audio using aplay

func Record

func Record(sec int, saveTo string) error

Record records voice using arecord you need to setup a micro-phone and set it as default device arecord usage: -D: device, use commond "$arecord -l" for viewing card number and device number like 1,0 -d 3: 3 seconds -t wav: wav type -r 16000: Rate 16000 Hz -c 1: 1 channel -f S16_LE: Signed 16 bit Little Endian

func Reverse

func Reverse(s string) string

Reverse reverses the string

func SetVolume

func SetVolume(v int) error

SetVolume sets the volume using amixer

func StartMotion

func StartMotion(config ...string) error

StartMotion start the Motion Service if config file doesn't be provided, the default config file will be used the default config file locates /etc/motion/motion.conf

func StopMotion

func StopMotion() error

StopMotion ...

func StopMp3

func StopMp3() error

StopMp3 stops to play mp3

func StopWav

func StopWav() error

StopWav stops to play wav

func WaitQuit

func WaitQuit(beforeQuitFunc func())

WaitQuit ...

Types

type Email

type Email struct {
	SMTP     string
	SMTPPort int
	POP      string
	POPPort  int
	Address  string
	Password string
}

Email ...

func NewEmail

func NewEmail(cfg *EmailConfig) *Email

NewEmail ...

func (*Email) Send

func (e *Email) Send(info *EmailInfo) error

Send ...

type EmailConfig

type EmailConfig struct {
	SMTP     string `json:"smtp"`
	SMTPPort int    `json:"smtp_port"`
	POP      string `json:"pop"`
	POPPort  int    `json:"pop_port"`
	Address  string `json:"addr"`
	Password string `json:"password"`
}

EmailConfig ...

type EmailInfo

type EmailInfo struct {
	To      []string
	Subject string
	Body    string
}

EmailInfo ...

type GPSLogger

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

GPSLogger ...

func NewGPSLogger

func NewGPSLogger() *GPSLogger

NewGPSLogger ...

func (*GPSLogger) AddPoint

func (l *GPSLogger) AddPoint(pt *geo.Point)

AddPoint ...

func (*GPSLogger) Close

func (l *GPSLogger) Close()

Close ...

type History

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

History ...

func NewHistory

func NewHistory(size int) *History

NewHistory ...

func (*History) Add

func (h *History) Add(v interface{})

Add ...

func (*History) Avg

func (h *History) Avg() (float64, error)

Avg ...

type Mode

type Mode string

Mode ...

type Point

type Point struct {
	Lat float32 `json:"lat"`
	Lon float32 `json:"lon"`
}

Point is GPS point

func (*Point) String

func (p *Point) String() string

type RpiModel

type RpiModel string

RpiModel ...

const (
	// RpiUnknown ...
	RpiUnknown RpiModel = "Raspberry Pi X Model"
	// Rpi0 ...
	Rpi0 RpiModel = "Raspberry Pi Zero Model"
	// RpiA ...
	RpiA RpiModel = "Raspberry Pi A Model"
	// RpiB ...
	RpiB RpiModel = "Raspberry Pi B Model"
	// Rpi2 ...
	Rpi2 RpiModel = "Raspberry Pi 2 Model"
	// Rpi3 ...
	Rpi3 RpiModel = "Raspberry Pi 3 Model"
	// Rpi4 ...
	Rpi4 RpiModel = "Raspberry Pi 4 Model"
)

func GetRpiModel

func GetRpiModel() RpiModel

GetRpiModel ...

Directories

Path Synopsis
cv

Jump to

Keyboard shortcuts

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