From ad18313705b442c980bd2f3680ec726a28a1a734 Mon Sep 17 00:00:00 2001 From: foglar Date: Mon, 18 Mar 2024 11:36:05 +0100 Subject: [PATCH] added values that are printed in gui --- README.md | 16 ++++----- monitor/main.go | 45 +++++++++++++++++++++++--- monitor/parse/.null-ls_529603_parse.go | 34 ------------------- monitor/serial_read/serial.go | 2 +- receiver_module/receiver_module.ino | 1 - 5 files changed, 50 insertions(+), 48 deletions(-) delete mode 100644 monitor/parse/.null-ls_529603_parse.go diff --git a/README.md b/README.md index bee621c..c3932fc 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/monitor/main.go b/monitor/main.go index 0f2e337..167a390 100644 --- a/monitor/main.go +++ b/monitor/main.go @@ -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() } diff --git a/monitor/parse/.null-ls_529603_parse.go b/monitor/parse/.null-ls_529603_parse.go deleted file mode 100644 index d4b63f7..0000000 --- a/monitor/parse/.null-ls_529603_parse.go +++ /dev/null @@ -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 -} diff --git a/monitor/serial_read/serial.go b/monitor/serial_read/serial.go index 965a10e..24c1471 100644 --- a/monitor/serial_read/serial.go +++ b/monitor/serial_read/serial.go @@ -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 { diff --git a/receiver_module/receiver_module.ino b/receiver_module/receiver_module.ino index bd3de43..bc80ee0 100644 --- a/receiver_module/receiver_module.ino +++ b/receiver_module/receiver_module.ino @@ -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);