nesnes / teleplot-vscode

Teleplot's VSCode extension

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Repository deprecated

This repository has been merged with the main Teleplot repo and won't be updated anymore.

The VSCode extension of teleplot will now be maintained from the main Teleplot repo

Please go there instead.

Teleplot for VSCode

Plots telemetry sent over Serial or UDP Packets.

From an Arduino (Serial)

#include <Arduino.h>

void setup() {
  Serial.begin(115200);
  // Print log
  Serial.println("setup");
}

float i=0;
void loop() {
  i+=0.1;

  // Print log
  Serial.print("loop");
  Serial.println(i);
  
  // Plot a sinus
  Serial.print(">sin:");
  Serial.println(sin(i));

  // Plot a cosinus
  Serial.print(">cos:");
  Serial.println(cos(i));
    
  delay(50);
}

Every serial message formated >varName:1234\n will be ploted in teleplot. Other messages will be printed in the teleplot console.

Serial port needs to be selected and connected at the top-left on Teleplot.

This format is specific to Serial messages to enhance ease of use on microcontrollers.

From any program (UDP)

Teleplot listen to UDP packects on port 47269, allowing any type of software to post telemetry messages.

  • varName:1234|g adds or update the varName variable value on Teleplot plots.
  • varName:1627551892437:1234|g does the same but specifies the value's timestamp in milliseconds for more accurate ploting.
  • varName:1627551892444:1;1627551892555:2;1627551892666:3|g does the same as above but publishes multiple values in a single packet.

For more details on the format, check the original Teleplot repository

Bash

echo "myValue:1234|g" | nc -u -w0 127.0.0.1 47269

C++

Grab clients/cpp/Teleplot.h from the Teleplot repository.

#include <math.h>
#include "Teleplot.h"
Teleplot teleplot("127.0.0.1");

int main(int argc, char* argv[])
{
    for(float i=0;i<1000;i+=0.1)
    {
        // Use instanciated object
        teleplot.update("sin", sin(i));
        teleplot.update("cos", cos(i), 10); // Limit at 10Hz

        // Use static localhost object
        Teleplot::localhost().update("tan", tan(i));
        
        usleep(10000);
    }
    return 0;
}

Python

import socket
import math
import time

teleplotAddr = ("127.0.0.1",47269)
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

def sendTelemetry(name, value):
	now = time.time() * 1000
	msg = name+":"+str(now)+":"+str(value)+"|g"
	sock.sendto(msg.encode(), teleplotAddr)

i=0
while i < 1000:
	
	sendTelemetry("sin", math.sin(i))
	sendTelemetry("cos", math.cos(i))

	i+=0.1
	time.sleep(0.01)

Not listed?

You just need to send a UDP packet with the proper text in it. Open your web browser, search for my_language send UDP packet, and copy-paste the first sample you find before editing it with the following options:

  • address: 127.0.0.1
  • port: 47269
  • your test message: myValue:1234|g

About

Teleplot's VSCode extension

License:MIT License


Languages

Language:JavaScript 92.1%Language:HTML 4.4%Language:CSS 2.0%Language:TypeScript 1.4%Language:C++ 0.1%