Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
make-42-2 committed Jun 19, 2022
1 parent 09d45a3 commit 78b9b7c
Show file tree
Hide file tree
Showing 162 changed files with 19,907 additions and 27 deletions.
4 changes: 4 additions & 0 deletions .gitignore
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/*
Binary file added Blender/freestyle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Blender/freestyle2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Blender/pihon_demo.mp4
Binary file not shown.
Binary file added Blender/rasppi/source/untitled.blend
Binary file not shown.
Binary file added Blender/rasppi/textures/back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Blender/rasppi/textures/front.png
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 added Blender/untitled.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Blender/untitled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Blender/v1-freestyle.blend
Binary file not shown.
Binary file added Blender/v1-freestyle.blend1
Binary file not shown.
Binary file added Blender/v1.blend
Binary file not shown.
Binary file added Blender/v1.blend1
Binary file not shown.
Binary file added Blender/v2.blend
Binary file not shown.
Binary file added Blender/v2.blend1
Binary file not shown.
1 change: 1 addition & 0 deletions Client/gpiod-dev/cross-compile-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GOOS=linux GOARCH=arm GOARM=6 go build -ldflags="-s -w"
5 changes: 5 additions & 0 deletions Client/gpiod-dev/go.mod
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
181 changes: 181 additions & 0 deletions Client/gpiod-dev/go.sum

Large diffs are not rendered by default.

Binary file added Client/gpiod-dev/gpioddev
Binary file not shown.
67 changes: 67 additions & 0 deletions Client/gpiod-dev/main.go
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...")
}
2 changes: 2 additions & 0 deletions Client/links.txt
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
39 changes: 39 additions & 0 deletions Client/pihon-client/appdata/appdata.go
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
}
1 change: 1 addition & 0 deletions Client/pihon-client/cross-compile-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GOOS=linux GOARCH=arm GOARM=6 go build -ldflags="-s -w"
1 change: 1 addition & 0 deletions Client/pihon-client/cross-compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GOOS=linux GOARCH=arm GOARM=6 go build
55 changes: 55 additions & 0 deletions Client/pihon-client/extras/extras.go
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
}
}
12 changes: 12 additions & 0 deletions Client/pihon-client/go.mod
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
)
Loading

0 comments on commit 78b9b7c

Please sign in to comment.