util

package
v0.0.0-...-a3207ce Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Epsilon ...
	Epsilon = 1e-9

	// DevMode ...
	DevMode = "dev"
	// PrdMode ...
	PrdMode = "prd"
)

Variables

This section is empty.

Functions

func AlmostEqual

func AlmostEqual(a, b float64) bool

func DelayMin

func DelayMin(d time.Duration)

DelayMin ...

func DelayMs

func DelayMs(d time.Duration)

DelayMs ...

func DelaySec

func DelaySec(d time.Duration)

DelaySec ...

func DelayUs

func DelayUs(d time.Duration)

DelayUs ...

func GetIP

func GetIP() string

GetIP ...

func GetVolume

func GetVolume() (int, error)

GetVolume gets the volume using amixer

command line: amixer -M get PCM output: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Simple mixer control 'PCM',0

Capabilities: pvolume pvolume-joined pswitch pswitch-joined
Playback channels: Mono
Limits: Playback 0 - 255
Mono: Playback 115 [45%] [-127.55dB] [on]

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

func IncludedAngle

func IncludedAngle(from, to float64) float64

IncludedAngle caculates the included angle betweet fromAngle to toAngle

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(file string) (*GPSLogger, error)

NewGPSLogger ...

func (*GPSLogger) Close

func (l *GPSLogger) Close()

Close ...

func (*GPSLogger) Printf

func (l *GPSLogger) Printf(format string, v ...interface{})

type Logger

type Logger interface {
	Printf(format string, v ...interface{})
	Close()
}

type MapRender

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

func NewMapRender

func NewMapRender() *MapRender

func (*MapRender) AddMarker

func (m *MapRender) AddMarker(marker *sm.Marker)

func (*MapRender) ClearMarker

func (m *MapRender) ClearMarker()

func (*MapRender) Render

func (m *MapRender) Render() ([]byte, error)

func (*MapRender) RenderImg

func (m *MapRender) RenderImg() (*image.Image, error)

func (*MapRender) SetCache

func (m *MapRender) SetCache(cache sm.TileCache)

func (*MapRender) SetCenter

func (m *MapRender) SetCenter(pt *geo.Point)

func (*MapRender) SetSize

func (m *MapRender) SetSize(width, height int)

func (*MapRender) SetTileProvider

func (m *MapRender) SetTileProvider(tileProvider *sm.TileProvider)

func (*MapRender) SetZoom

func (m *MapRender) SetZoom(zoom int)

type Mode

type Mode string

Mode ...

type NoopLogger

type NoopLogger struct{}

func NewNoopLogger

func NewNoopLogger() *NoopLogger

func (*NoopLogger) Close

func (l *NoopLogger) Close()

func (*NoopLogger) Printf

func (n *NoopLogger) Printf(format string, v ...interface{})

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 Streamer

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

Streamer ...

func NewStreamer

func NewStreamer(url string) (*Streamer, error)

NewStream ...

func (*Streamer) Push

func (s *Streamer) Push(img []byte)

SetImage ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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