From c8c586fdd4140e89c41eaab6ffb2e81f369fe83c Mon Sep 17 00:00:00 2001
From: Kyrre Sjobak <kyrre.ness.sjoebaek@cern.ch>
Date: Tue, 23 Mar 2021 15:02:25 +0100
Subject: [PATCH] TXTserver: Send a leading '+' for positive numbers, ensuring
 that all numbers stay the same length.

---
 PositionGaugeServer.ino | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/PositionGaugeServer.ino b/PositionGaugeServer.ino
index 0ed8e10..7ffd700 100644
--- a/PositionGaugeServer.ino
+++ b/PositionGaugeServer.ino
@@ -557,6 +557,10 @@ void TXTserver (uint8_t ch) {
           //clients[i].println(ch);
   
           //Feed the new client some data right away
+          if(measData[ch] >= 0) {
+            //Add the '+' so that the string is always the same length
+            clients[i].print('+');
+          }
           clients[i].print(measData[ch],3);
           if (measDataIsValid[ch]) {
             if (measDataIsMm[ch]) {
@@ -595,6 +599,10 @@ void TXTserver (uint8_t ch) {
   if (measDataFresh[ch]) {
     for (byte i = 0; i < MAX_SOCK_NUM; i++) {
       if (clients[i] && (clients_ch[i]==ch)) {
+        if(measData[ch] >= 0) {
+          //Add the '+' so that the string is always the same length
+          clients[i].print('+');
+        }
         clients[i].print(measData[ch],3);
         if (measDataIsValid[ch]) {
           if (measDataIsMm[ch]) {
-- 
GitLab