-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package wingPi | ||
|
||
import ( | ||
"fmt" | ||
"github.com/commander-cli/cmd" | ||
"github.com/wingofsky/wingPi/utils" | ||
) | ||
|
||
func TakePicture(fileName, rootDir string) { | ||
// 质量为5的文件,不显示预览 | ||
cl := "raspistill -o " | ||
cl += rootDir + "/" | ||
cl += fileName | ||
cl += "." | ||
cl += utils.PointNow() | ||
cl += ".jpg -q 5 -n" | ||
|
||
fmt.Println(cl) | ||
|
||
c := cmd.NewCommand(cl) | ||
utils.CheckERR(c.Execute()) | ||
//fmt.Println(c.Stdout()) | ||
//fmt.Println(c.Stderr()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package wingPi | ||
|
||
import ( | ||
"bufio" | ||
"github.com/shopspring/decimal" | ||
"log" | ||
"os" | ||
) | ||
|
||
func ReadTemp() float64 { | ||
p, _ := decimal.NewFromString("0.001") | ||
|
||
file, err := os.Open("/sys/class/thermal/thermal_zone0/temp") | ||
if err != nil { | ||
log.Fatalf("open file failed: %s \n", err.Error()) | ||
} | ||
defer file.Close() | ||
scanner := bufio.NewScanner(file) | ||
//i := 0 | ||
for scanner.Scan() { | ||
temp, _ := decimal.NewFromString(scanner.Text()) | ||
tempReal, _ := temp.Mul(p).Float64() | ||
return tempReal | ||
} | ||
return 100.00 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module github.com/wingofsky/wingPi | ||
|
||
go 1.15 | ||
|
||
require ( | ||
github.com/commander-cli/cmd v1.3.0 | ||
github.com/shopspring/decimal v1.2.0 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
github.com/commander-cli/cmd v1.3.0 h1:9h3OKDKgTXGx+m9ulSjMgE5zmiXtDHMlIe7Nwt/NZPI= | ||
github.com/commander-cli/cmd v1.3.0/go.mod h1:0cuDhCU4dmkhdAp1AFMKeQhes11x0f2+5DJhw/QQnFs= | ||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= | ||
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= | ||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= | ||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package utils | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"time" | ||
) | ||
|
||
func CheckERR(err error) { | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
|
||
func PointNow() string { | ||
return time.Now().Format("2006.01.02.15.04.05") | ||
} | ||
|
||
func GetDirNow() string { | ||
// 获取程序所在目录 | ||
dirNow, _ := filepath.Abs(filepath.Dir(os.Args[0])) | ||
return dirNow | ||
} |