From 9f33789202a82e9a7e9421c2723d1e66b6b6a789 Mon Sep 17 00:00:00 2001 From: Philipp Kramer Date: Thu, 12 Jan 2023 12:19:29 +0100 Subject: [PATCH] add position capture and simple viewer processing software --- positionCapture/positionCapture.pde | 161 ++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 positionCapture/positionCapture.pde diff --git a/positionCapture/positionCapture.pde b/positionCapture/positionCapture.pde new file mode 100644 index 0000000..1648450 --- /dev/null +++ b/positionCapture/positionCapture.pde @@ -0,0 +1,161 @@ +import processing.serial.*; +String serial_port="COM3"; +Serial serial; +String serialString=""; //last read string +int serial_endchar=10; //10=ASCII Linefeed + +static int SERVO_COUNT=5; +int servoPositionsActual[]=new int[SERVO_COUNT]; + +PrintWriter fileoutput; +String recorddir="recordings/"; + +boolean recording=false; +String filename=""; +int recordingStartTime; +int linesWritten; + +void setup() { + size(800,600); + background(0); + + + printArray(Serial.list()); + // Open the port you are using at the rate you want: + serial = new Serial(this, serial_port, 57600); + + serial.clear(); + // Throw out the first reading, in case we started reading + // in the middle of a string from the sender. + println("readUntil"); + serialString = serial.readStringUntil(serial_endchar); + println("read:"+serialString); + serialString = null; + + + +} + +void draw() { + clear(); + int valRange=1024; //maximum value for bargraph scale + + String[] list=readSerial(); + if (list!=null) { + + if (list[0].equalsIgnoreCase("dxlgp")) { //is position message + + boolean firstValueWritten=false; + for (int i=1;i 0) { + serialString = serial.readStringUntil(serial_endchar); + //println("read:"+serialString); + if (serialString != null) { + println(serialString); + String[] list = split(serialString, ','); + return list; + } + } + return null; +}