-
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
162 changed files
with
19,907 additions
and
27 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,4 @@ | ||
Client/pihon-client/library/* | ||
Client/python-pihon-converter/input/* | ||
Client/python-pihon-converter/output/* | ||
Client/ui-dev (deprecated)/library/* |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 @@ | ||
GOOS=linux GOARCH=arm GOARM=6 go build -ldflags="-s -w" |
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,5 @@ | ||
module gpioddev | ||
|
||
go 1.18 | ||
|
||
require github.com/warthog618/gpiod v0.8.0 |
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
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,67 @@ | ||
// SPDX-FileCopyrightText: 2020 Kent Gibson <[email protected]> | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
//go:build linux | ||
// +build linux | ||
|
||
// A simple example that watches an input pin and reports edge events. | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"syscall" | ||
"time" | ||
|
||
"github.com/warthog618/gpiod" | ||
"github.com/warthog618/gpiod/device/rpi" | ||
) | ||
|
||
func eventHandler(evt gpiod.LineEvent) { | ||
t := time.Now() | ||
edge := "rising" | ||
if evt.Type == gpiod.LineEventFallingEdge { | ||
edge = "falling" | ||
} | ||
if evt.Seqno != 0 { | ||
// only uAPI v2 populates the sequence numbers | ||
fmt.Printf("event: #%d(%d)%3d %-7s %s (%s)\n", | ||
evt.Seqno, | ||
evt.LineSeqno, | ||
evt.Offset, | ||
edge, | ||
t.Format(time.RFC3339Nano), | ||
evt.Timestamp) | ||
} else { | ||
fmt.Printf("event:%3d %-7s %s (%s)\n", | ||
evt.Offset, | ||
edge, | ||
t.Format(time.RFC3339Nano), | ||
evt.Timestamp) | ||
} | ||
} | ||
|
||
// Watches GPIO 23 (Raspberry Pi J8-16) and reports when it changes state. | ||
func main() { | ||
offset := rpi.J8p11 | ||
l, err := gpiod.RequestLine("gpiochip0", offset, | ||
gpiod.WithPullUp, | ||
gpiod.WithBothEdges, | ||
gpiod.WithEventHandler(eventHandler)) | ||
if err != nil { | ||
fmt.Printf("RequestLine returned error: %s\n", err) | ||
if err == syscall.Errno(22) { | ||
fmt.Println("Note that the WithPullUp option requires kernel V5.5 or later - check your kernel version.") | ||
} | ||
os.Exit(1) | ||
} | ||
defer l.Close() | ||
|
||
// In a real application the main thread would do something useful. | ||
// But we'll just run for a minute then exit. | ||
fmt.Printf("Watching Pin %d...\n", offset) | ||
time.Sleep(time.Minute) | ||
fmt.Println("exiting...") | ||
} |
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,2 @@ | ||
https://crates.io/crates/ssd1306 | ||
https://github.com/rust-embedded/awesome-embedded-rust#other |
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,39 @@ | ||
package appdata | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"io/ioutil" | ||
"log" | ||
"os" | ||
"strconv" | ||
) | ||
|
||
var DataPath string | ||
|
||
func checkError(error error) { | ||
if error != nil { | ||
log.Fatal(error) | ||
} | ||
} | ||
|
||
func SaveBookData(bookHash string, bookPosition int) { | ||
_ = os.Remove(DataPath + bookHash) | ||
f, err := os.Create(DataPath + bookHash) | ||
checkError(err) | ||
defer f.Close() | ||
f.WriteString(fmt.Sprintf("%d", bookPosition)) | ||
fmt.Printf("Saving current position : %d\n", bookPosition) | ||
} | ||
|
||
func ReadBookData(bookHash string) int { | ||
if _, err := os.Stat(DataPath + bookHash); errors.Is(err, os.ErrNotExist) { | ||
SaveBookData(bookHash, 0) | ||
return 0 | ||
} | ||
content, err := ioutil.ReadFile(DataPath + bookHash) | ||
checkError(err) | ||
i, err := strconv.Atoi(string(content)) | ||
checkError(err) | ||
return i | ||
} |
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 @@ | ||
GOOS=linux GOARCH=arm GOARM=6 go build -ldflags="-s -w" |
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 @@ | ||
GOOS=linux GOARCH=arm GOARM=6 go build |
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,55 @@ | ||
package extras | ||
|
||
import ( | ||
"log" | ||
"os" | ||
"strings" | ||
"time" | ||
|
||
"github.com/go-ping/ping" | ||
) | ||
|
||
var LeftButtonState = false | ||
var RightButtonState = false | ||
var LeftButtonPressedTime time.Time | ||
var NavigationHoldDuration float64 | ||
var CloudflareIP string | ||
|
||
func checkError(error error) { | ||
if error != nil { | ||
log.Fatal(error) | ||
} | ||
} | ||
|
||
func GetCWD() string { | ||
path, err := os.Getwd() | ||
checkError(err) | ||
dirname, err := os.UserHomeDir() | ||
checkError(err) | ||
return strings.Replace(path+"/", dirname, "~", 1) | ||
} | ||
|
||
func FitWithinCharacterLimits(characterLimit int, stringToFit string) string { | ||
if characterLimit > len(stringToFit) { | ||
return stringToFit | ||
} | ||
return string(stringToFit[:characterLimit-1]) | ||
} | ||
|
||
func PingCloudflare() bool { | ||
pinger, err := ping.NewPinger(CloudflareIP) | ||
if err != nil { | ||
panic(err) | ||
} | ||
pinger.Count = 1 | ||
err = pinger.Run() // Blocks until finished. | ||
if err != nil { | ||
panic(err) | ||
} | ||
stats := pinger.Statistics() | ||
if stats.PacketLoss == 0 { | ||
return true | ||
} else { | ||
return false | ||
} | ||
} |
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,12 @@ | ||
module pihonclient | ||
|
||
go 1.14 | ||
|
||
require ( | ||
github.com/go-ping/ping v1.0.0 | ||
github.com/pbnjay/pixfont v0.0.0-20200714042608-33b744692567 | ||
github.com/warthog618/gpiod v0.8.0 | ||
periph.io/x/conn/v3 v3.6.10 | ||
periph.io/x/devices/v3 v3.6.13 | ||
periph.io/x/host/v3 v3.7.2 | ||
) |
Oops, something went wrong.