added values that are printed in gui

This commit is contained in:
foglar 2024-03-18 11:36:05 +01:00
parent 21512e3030
commit ad18313705
5 changed files with 50 additions and 48 deletions

View File

@ -94,12 +94,12 @@ Required library for antenna: [RF24](https://nrf24.github.io/RF24). Installation
| Identifier | Message Code | Value | Verificator |
| ---------- | ------------ | -------------------------------- | ------------|
| $ | **1**; | roll | * |
| $ | **2**; | pitch | * |
| $ | **3**; | yaw | * |
| $ | **4**; | temperature [degrees of Celsius] | * |
| $ | **5**; | pressure | * |
| $ | **6**; | altitude | * |
| $ | **1**; | roll [°] | * |
| $ | **2**; | pitch [°] | * |
| $ | **3**; | yaw [°] | * |
| $ | **4**; | temperature [°C] | * |
| $ | **5**; | pressure [hPa] | * |
| $ | **6**; | altitude [m] | * |
| $ | **7**; | gyroscope x | * |
| $ | **8**; | gyroscope y | * |
| $ | **9**; | gyroscope z | * |
@ -191,7 +191,6 @@ $GPGAA,HHMMSS.SS,llll.ll,a,yyyyy.yy,a,x,xx,x.x,x.x,M,x.x,M,x.x,xxxx
- [ ] create a version which will send data via **IOT 433MHz LoRa LPWAN SX1278**
- [ ] create a communication in both ways, `start`, `stop`, `system health check` commands
- [ ] detection of apogeum and recovery system launch
- [ ] if recieved data for the parameter don't correspond with our expectations, change colour of the value indicator
### Monitor app issues
@ -201,9 +200,10 @@ $GPGAA,HHMMSS.SS,llll.ll,a,yyyyy.yy,a,x,xx,x.x,x.x,M,x.x,M,x.x,xxxx
- [ ] sender code should be improved
- [x] gui window
- [ ] error messages as windows not terminal
- [ ] improve readability of code
- [ ] serial monitor setup port and baudrate
- [ ] create a gui way of sending commands
- [ ] values change colour if they are not what they should be, or what are expected to be
- [ ] if recieved data for the parameter don't correspond with our expectations, change colour of the value indicator
## Sources

View File

@ -20,8 +20,13 @@ const (
)
var (
LOG_POSITION = [2]float64{800, 10}
INFO_POSITION = [2]float64{100, 740}
LOG_POSITION = [2]float64{900, 10}
TEMP_POSITION = [2]float64{600, 100}
PRESSURE_POSITION = [2]float64{200, 100}
ATTITUDE_POSITION = [2]float64{50, 400}
ROLL_POSITION = [2]float64{50, 650}
PITCH_POSITION = [2]float64{350, 650}
YAW_POSITION = [2]float64{650, 650}
)
func run() {
@ -55,9 +60,21 @@ func run() {
// Text
logging_serial := text.New(pixel.V(LOG_POSITION[0], LOG_POSITION[1]), log_atlas)
temperature := text.New(pixel.V(INFO_POSITION[0], INFO_POSITION[1]), info_atlas)
temperature := text.New(pixel.V(TEMP_POSITION[0], TEMP_POSITION[1]), info_atlas)
pressure := text.New(pixel.V(PRESSURE_POSITION[0], PRESSURE_POSITION[1]), info_atlas)
attitude := text.New(pixel.V(ATTITUDE_POSITION[0], ATTITUDE_POSITION[1]), info_atlas)
roll := text.New(pixel.V(ROLL_POSITION[0], ROLL_POSITION[1]), info_atlas)
pitch := text.New(pixel.V(PITCH_POSITION[0], PITCH_POSITION[1]), info_atlas)
yaw := text.New(pixel.V(YAW_POSITION[0], YAW_POSITION[1]), info_atlas)
var temperature_gui string
var (
temperature_gui string
pressure_gui string
attitude_gui string
roll_gui string
pitch_gui string
yaw_gui string
)
// Window update
for !win.Closed() {
@ -74,10 +91,20 @@ func run() {
// Clear screen values
temperature.Clear()
pressure.Clear()
attitude.Clear()
roll.Clear()
pitch.Clear()
yaw.Clear()
// Update information if it is in the parsed block
if _, ok := info[1]; ok {
temperature_gui = info[4]
pressure_gui = info[5]
attitude_gui = info[6]
roll_gui = info[1]
pitch_gui = info[2]
yaw_gui = info[3]
}
win.Clear(colornames.Black)
@ -85,10 +112,20 @@ func run() {
// Print information to text blocks
logging_serial.WriteString(data)
temperature.WriteString("Temperature: " + temperature_gui)
pressure.WriteString("Pressure: [hPa] " + pressure_gui)
attitude.WriteString("Attitude: [m] " + attitude_gui)
roll.WriteString("Roll: " + roll_gui)
pitch.WriteString("Pitch: " + pitch_gui)
yaw.WriteString("Yaw: " + yaw_gui)
// Draw information to screen
logging_serial.Draw(win, pixel.IM)
temperature.Draw(win, pixel.IM)
pressure.Draw(win, pixel.IM)
attitude.Draw(win, pixel.IM)
roll.Draw(win, pixel.IM)
pitch.Draw(win, pixel.IM)
yaw.Draw(win, pixel.IM)
win.Update()
}

View File

@ -1,34 +0,0 @@
package parse
// TODO: finish reading serial input and parsing it and piping it to the gui component
import (
"log"
"strconv"
"strings"
)
func Parser(s string) map[int]string {
// TODO: check if line isn't comment
// improve reading data
lines := strings.Split(s, "\n")
data_structure := make(map[int]string)
for _, line := range lines {
// find $ and * in text and get value between them
startIndex := strings.Index(line, "$")
endIndex := strings.Index(line, "*")
if startIndex != -1 && endIndex != -1 {
value := line[startIndex+1 : endIndex]
data := strings.Split(strings.TrimSpace(value), ";")
ident, err := strconv.Atoi(strings.TrimSpace(data[0]))
if err != nil {
log.Print(err)
}
info := data[1]
data_structure[ident] = info
}
}
return data_structure
}

View File

@ -56,7 +56,7 @@ func inputPort() string {
var s_port string
for {
fmt.Print("Enter port ([Enter] - /dev/ttyACM0): ")
fmt.Print("Enter port (/dev/ttyACM0): ")
fmt.Scanln(&s_port)
if isPort(s_port) == true {

View File

@ -19,7 +19,6 @@ void setup() {
void loop() {
//Read the data if available in buffer
if (radio.available()) {
Serial.println("#200 Communication is available");
char text[64] = { 0 };
radio.read(&text, sizeof(text));
Serial.println(text);