Created GUI window with output
- now you can see the serial output in the graphical user interface - main and gui packages were updated - readme edit
This commit is contained in:
parent
b37eea2577
commit
895f56c581
59
README.md
59
README.md
@ -1,32 +1,53 @@
|
|||||||
# CobraV2
|
# CobraV2
|
||||||
|
|
||||||
|
## Table of contents
|
||||||
|
|
||||||
|
- [CobraV2](#cobrav2)
|
||||||
|
- [Table of contents](#table-of-contents)
|
||||||
|
- [Installation and compilation](#installation-and-compilation)
|
||||||
|
- [Serial monitor tool](#serial-monitor-tool)
|
||||||
|
- [Monitoring tool](#monitoring-tool)
|
||||||
|
- [Overview](#overview)
|
||||||
|
- [Arduino Sender Format](#arduino-sender-format)
|
||||||
|
- [Modules](#modules)
|
||||||
|
- [10 DOF IMU](#10-dof-imu)
|
||||||
|
- [L76K GPS](#l76k-gps)
|
||||||
|
- [NMEA Sentence](#nmea-sentence)
|
||||||
|
- [NRF24L01+](#nrf24l01)
|
||||||
|
- [Wiring](#wiring)
|
||||||
|
- [10 DOF IMU Sensor](#10-dof-imu-sensor)
|
||||||
|
- [L76K GPS Module](#l76k-gps-module)
|
||||||
|
- [NRF24L01+ Module](#nrf24l01-module)
|
||||||
|
- [Issues / features](#issues--features)
|
||||||
|
- [Sources](#sources)
|
||||||
|
|
||||||
## Installation and compilation
|
## Installation and compilation
|
||||||
|
|
||||||
### Serial monitor tool
|
### Serial monitor tool
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
git clone https://www.github.com/foglar/cobraV2.git
|
git clone https://www.github.com/foglar/cobraV2.git
|
||||||
cd cobraV2/serial_read
|
cd cobraV2/serial_read
|
||||||
|
|
||||||
go get "github.com/tarm/serial"
|
|
||||||
|
|
||||||
# Building serial read code yourself
|
|
||||||
go build .
|
go build .
|
||||||
```
|
```
|
||||||
|
|
||||||
### Monitor tool
|
> [!TIP]
|
||||||
|
> You may have to delete `go.mod` file (if you have other go version) and `go mod init` the project.
|
||||||
|
> To install all dependencies you can use `go mod tidy` command or you can mannualy install them by `go get [package]` command.
|
||||||
|
|
||||||
```bash
|
### Monitoring tool
|
||||||
|
|
||||||
|
```shell
|
||||||
git clone https://www.github.com/foglar/cobraV2.git
|
git clone https://www.github.com/foglar/cobraV2.git
|
||||||
cd cobraV2/monitor
|
cd cobraV2/monitor
|
||||||
|
|
||||||
# Installing required packages
|
|
||||||
go get "github.com/tarm/serial"
|
|
||||||
# go get "github.com/gopxl/pixel/v2"
|
|
||||||
|
|
||||||
go build .
|
go build .
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> For cross-compiling you will need to specify a `CC` to compile c-based libraries for pixel2 library.
|
||||||
|
> Example command: `CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 CGO_ENABLED=1 go build .`
|
||||||
|
> For more information see: [Pixel2 Wiki | Cross Compiling](https://github.com/gopxl/pixel/wiki/%5BWIP%5D-Cross-Compiling)
|
||||||
|
|
||||||
Upload sender and reciever code on the 2 arduino's
|
Upload sender and reciever code on the 2 arduino's
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
@ -83,13 +104,12 @@ $GPGAA,HHMMSS.SS,llll.ll,a,yyyyy.yy,a,x,xx,x.x,x.x,M,x.x,M,x.x,xxxx
|
|||||||
| $GPGAA | HHMMSS.SS | llll.ll a | yyyyy.yy a | x | xx | x.x | x.x M | x.x M | x.x | xxxx | *hh |
|
| $GPGAA | HHMMSS.SS | llll.ll a | yyyyy.yy a | x | xx | x.x | x.x M | x.x M | x.x | xxxx | *hh |
|
||||||
| $GPGAA | 170834 | 4124.8963, N | 08151.6838, W | 1 | 05 | 1.5 | 280.2, M | -34.0, M | blank | blank | *75 |
|
| $GPGAA | 170834 | 4124.8963, N | 08151.6838, W | 1 | 05 | 1.5 | 280.2, M | -34.0, M | blank | blank | *75 |
|
||||||
|
|
||||||
Fix Quality:
|
> [!TIP]
|
||||||
|
> Fix Quality:
|
||||||
- 0 = Invalid
|
> 0 = Invalid;
|
||||||
- 1 = GPS fix
|
> 1 = GPS fix;
|
||||||
- 2 = DGPS fix
|
> 2 = DGPS fix;
|
||||||
|
> [more about nmea sentences](https://aprs.gids.nl/nmea/)
|
||||||
[more about nmea sentences](https://aprs.gids.nl/nmea/)
|
|
||||||
|
|
||||||
### NRF24L01+
|
### NRF24L01+
|
||||||
|
|
||||||
@ -153,3 +173,4 @@ Datasheets, documentation and sources
|
|||||||
- [NRF24L01+ Guide - Guide](https://navody.dratek.cz/navody-k-produktum/arduino-wifi-modul-nrf24l01.html)
|
- [NRF24L01+ Guide - Guide](https://navody.dratek.cz/navody-k-produktum/arduino-wifi-modul-nrf24l01.html)
|
||||||
- [NRF24L01+ PA/LNA - Datasheet](doc/nrf24lo1-datasheet.pdf)
|
- [NRF24L01+ PA/LNA - Datasheet](doc/nrf24lo1-datasheet.pdf)
|
||||||
- [NRF24L01+ PA/LNA - Demo code](https://img.gme.cz/files/eshop_data/eshop_data/10/775-034/prg.775-034.1.zip)
|
- [NRF24L01+ PA/LNA - Demo code](https://img.gme.cz/files/eshop_data/eshop_data/10/775-034/prg.775-034.1.zip)
|
||||||
|
- [Pixel2 (gui library)](https://github.com/gopxl/pixel)
|
||||||
|
|||||||
@ -5,17 +5,25 @@ package gui
|
|||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/golang/freetype/truetype"
|
"github.com/golang/freetype/truetype"
|
||||||
"github.com/gopxl/pixel"
|
|
||||||
"github.com/gopxl/pixel/pixelgl"
|
|
||||||
"github.com/gopxl/pixel/text"
|
"github.com/gopxl/pixel/text"
|
||||||
"golang.org/x/image/colornames"
|
|
||||||
"golang.org/x/image/font"
|
"golang.org/x/image/font"
|
||||||
)
|
)
|
||||||
|
|
||||||
func loadTTF(path string, size float64) (font.Face, error) {
|
// Declare default font and font size
|
||||||
|
const FONT string = "gui/JetBrainsMonoNerdFont-Medium.ttf"
|
||||||
|
const SIZE float64 = 36
|
||||||
|
|
||||||
|
func LoadFont() (*text.Atlas, error) {
|
||||||
|
face, err := LoadTTF(FONT, SIZE)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return text.NewAtlas(face, text.ASCII), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func LoadTTF(path string, size float64) (font.Face, error) {
|
||||||
file, err := os.Open(path)
|
file, err := os.Open(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -37,39 +45,3 @@ func loadTTF(path string, size float64) (font.Face, error) {
|
|||||||
GlyphCacheEntries: 1,
|
GlyphCacheEntries: 1,
|
||||||
}), nil
|
}), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func run() {
|
|
||||||
cfg := pixelgl.WindowConfig{
|
|
||||||
Title: "Cobra Monitor",
|
|
||||||
Bounds: pixel.R(0, 0, 1024, 768),
|
|
||||||
}
|
|
||||||
win, err := pixelgl.NewWindow(cfg)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
face, err := loadTTF("gui/JetBrainsMonoNerdFont-Medium.ttf", 36)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
atlas := text.NewAtlas(face, text.ASCII)
|
|
||||||
txt := text.New(pixel.V(100, 500), atlas)
|
|
||||||
|
|
||||||
fps := time.Tick(time.Second / 120)
|
|
||||||
|
|
||||||
for !win.Closed() {
|
|
||||||
|
|
||||||
//txt.WriteString(data)
|
|
||||||
|
|
||||||
win.Clear(colornames.Black)
|
|
||||||
txt.Draw(win, pixel.IM)
|
|
||||||
win.Update()
|
|
||||||
|
|
||||||
<-fps
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func GUI() {
|
|
||||||
pixelgl.Run(run)
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,33 +1,60 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
//"fmt"
|
"log"
|
||||||
|
|
||||||
gui "foglar/monitor/gui"
|
gui "foglar/monitor/gui"
|
||||||
//p "foglar/monitor/parse"
|
"foglar/monitor/serial_read"
|
||||||
//"foglar/monitor/serial_read"
|
|
||||||
//"log"
|
"github.com/gopxl/pixel"
|
||||||
|
"github.com/gopxl/pixel/pixelgl"
|
||||||
|
"github.com/gopxl/pixel/text"
|
||||||
|
"golang.org/x/image/colornames"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func run() {
|
||||||
// // Initialize serial connection
|
// Initialize serial connection
|
||||||
// serialHandler, err := serial_read.NewSerialHandler()
|
serialHandler, err := serial_read.NewSerialHandler()
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// log.Fatal(err)
|
log.Fatal(err)
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// defer serialHandler.Close()
|
defer serialHandler.Close()
|
||||||
//
|
|
||||||
// for {
|
// Create window
|
||||||
// // Read serial data
|
cfg := pixelgl.WindowConfig{
|
||||||
// data, err := serialHandler.ReadSerial()
|
Title: "Cobra Monitor",
|
||||||
// if err != nil {
|
Bounds: pixel.R(0, 0, 1024, 768),
|
||||||
// log.Fatal(err)
|
}
|
||||||
// }
|
win, err := pixelgl.NewWindow(cfg)
|
||||||
//
|
if err != nil {
|
||||||
// fmt.Println("Received data:", data)
|
panic(err)
|
||||||
// fmt.Println(p.Parser(data))
|
}
|
||||||
// }
|
|
||||||
|
// Load font
|
||||||
// Testing GUI interface
|
atlas, err := gui.LoadFont()
|
||||||
gui.GUI()
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
txt := text.New(pixel.V(100, 500), atlas)
|
||||||
|
|
||||||
|
// Window update
|
||||||
|
for !win.Closed() {
|
||||||
|
|
||||||
|
data, err := serialHandler.ReadSerial()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
txt.WriteString(data)
|
||||||
|
|
||||||
|
win.Clear(colornames.Black)
|
||||||
|
txt.Draw(win, pixel.IM)
|
||||||
|
win.Update()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
pixelgl.Run(run)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
module main
|
module foglar/serial_read
|
||||||
|
|
||||||
go 1.21.6
|
go 1.20
|
||||||
|
|
||||||
require github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07
|
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
github.com/mitchellh/go-homedir v1.1.0
|
||||||
golang.org/x/sys v0.16.0 // indirect
|
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07
|
||||||
)
|
)
|
||||||
|
|
||||||
|
require golang.org/x/sys v0.17.0 // indirect
|
||||||
|
|||||||
@ -2,5 +2,5 @@ github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG
|
|||||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||||
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07 h1:UyzmZLoiDWMRywV4DUYb9Fbt8uiOSooupjTq10vpvnU=
|
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07 h1:UyzmZLoiDWMRywV4DUYb9Fbt8uiOSooupjTq10vpvnU=
|
||||||
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
|
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
|
||||||
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
|
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
|
||||||
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user