util

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2018 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Overview

Go Language Raspberry Pi Interface
(c) Copyright David Thorpe 2016
All Rights Reserved

For Licensing and Usage information, please see LICENSE.md

PPI

These methods provide support for calculating the pixels-per-inch (PPI) of a display. The function ParseLengthString parses a string to return a diaganol length in inches. Typically you will call the function with one of the following forms:

99 in
99 mm
99 cm
99 x 99 in
99 x 99 mm
99 x 99 cm

Index

Constants

View Source
const (
	R_OK = 4
	W_OK = 2
	X_OK = 1
)
View Source
const (
	UNITS_IN_PER_MM float64 = 0.0393701
	UNITS_IN_PER_CM float64 = 0.393701
)

Variables

View Source
var (
	ErrUnsupportedType = errors.New("Unsupported type")
	ErrParseError      = errors.New("Syntax error in input")
)
View Source
var (
	REGEXP_PPI_D  *regexp.Regexp = regexp.MustCompile("^\\s*([0-9\\.]+)\\s*(in|mm|cm)\\s*$")
	REGEXP_PPI_WH *regexp.Regexp = regexp.MustCompile("^\\s*([0-9\\.]+)\\s*(x|X)\\s*([0-9\\.]+)\\s*(in|mm|cm)\\s*$")
)

Functions

func ParseLengthString

func ParseLengthString(value string) (float64, error)

Return the length of the diagnol, in inches. On syntax error, ErrParseError is returned. On success, the number of inches on the screen diagnanol is returned.

Types

type Dict

type Dict struct {
	// Require ability to marshall and unmarshall XML
	xml.Marshaler
	xml.Unmarshaler
	// contains filtered or unexported fields
}

Dict defines a dictionary of values, somewhat similar to Apple property lists

func CopyDict

func CopyDict(src *Dict) *Dict

CopyDict copies values from one dictionary into a new dictionary

func NewDict

func NewDict(capacity uint) *Dict

NewDict creates a new empty dictionary. Use the capacity argument to provide a hint on how many items the dictionary will contain

func (*Dict) GetBool

func (this *Dict) GetBool(key string) (bool, bool)

func (*Dict) GetData

func (this *Dict) GetData(key string) ([]byte, bool)

func (*Dict) GetDate

func (this *Dict) GetDate(key string) (time.Time, bool)

func (*Dict) GetDict

func (this *Dict) GetDict(key string) (*Dict, bool)

func (*Dict) GetDuration

func (this *Dict) GetDuration(key string) (time.Duration, bool)

func (*Dict) GetFloat32

func (this *Dict) GetFloat32(key string) (float32, bool)

func (*Dict) GetFloat64

func (this *Dict) GetFloat64(key string) (float64, bool)

func (*Dict) GetInt

func (this *Dict) GetInt(key string) (int, bool)

func (*Dict) GetString

func (this *Dict) GetString(key string) (string, bool)

func (*Dict) GetUint

func (this *Dict) GetUint(key string) (uint, bool)

func (*Dict) IsEmpty

func (this *Dict) IsEmpty() bool

func (*Dict) Keys

func (this *Dict) Keys() []string

Keys returns the keys associated with the dictionary

func (*Dict) MarshalXML

func (this *Dict) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*Dict) SetBool

func (this *Dict) SetBool(key string, value bool)

SetBool sets bool value for key

func (*Dict) SetData

func (this *Dict) SetData(key string, value []byte)

SetData sets []byte value for key

func (*Dict) SetDate

func (this *Dict) SetDate(key string, value time.Time)

SetDate sets time.Time value for key

func (*Dict) SetDict

func (this *Dict) SetDict(key string, value *Dict)

SetDict sets dict value for key

func (*Dict) SetDuration

func (this *Dict) SetDuration(key string, value time.Duration)

SetDuration sets time.Duration value for key

func (*Dict) SetFloat32

func (this *Dict) SetFloat32(key string, value float32)

SetFloat32 sets float32 value for key

func (*Dict) SetFloat64

func (this *Dict) SetFloat64(key string, value float64)

SetFloat64 sets float64 value for key

func (*Dict) SetInt

func (this *Dict) SetInt(key string, value int)

SetInt sets int value for key

func (*Dict) SetString

func (this *Dict) SetString(key string, value string)

SetString sets string value for key

func (*Dict) SetUint

func (this *Dict) SetUint(key string, value uint)

SetUint sets uint value for key

func (*Dict) String

func (this *Dict) String() string

func (*Dict) UnmarshalXML

func (this *Dict) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

Directories

Path Synopsis
Merge multiple incoming events into one, and fan out to subscribers Publish, Subscribe and Emit package for gopi.Publisher interface
Merge multiple incoming events into one, and fan out to subscribers Publish, Subscribe and Emit package for gopi.Publisher interface
Provide a way to count metrics and provide total and rates
Provide a way to count metrics and provide total and rates

Jump to

Keyboard shortcuts

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