PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
1.9KB

  1. /*
  2. Receives and visualizes OSCBundles sent over UDP
  3. Use with /examples/UDPSendBundle
  4. or with /examples/SerialSendBundle in conjunction
  5. with /Applicaitons/Processing/SLIPSerialToUDP
  6. */
  7. import oscP5.*;
  8. import netP5.*;
  9. OscP5 oscP5;
  10. void setup() {
  11. size(600,300);
  12. frameRate(30);
  13. //set this to the receiving port
  14. oscP5 = new OscP5(this,9001);
  15. }
  16. void draw() {
  17. background(0);
  18. //draw the analog values
  19. float analog0Height = map(analogValue0, 0, 1024, 0, 200);
  20. float analog1Height = map(analogValue1, 0, 1024, 0, 200);
  21. fill(255);
  22. rect(50, 250, 50, -analog0Height);
  23. rect(150, 250, 50, -analog1Height);
  24. //and the labels
  25. textSize(12);
  26. text("/analog/0", 50, 270);
  27. text("/analog/1", 150, 270);
  28. //and the digital pin label
  29. text("/digital/5", 250, 270);
  30. textSize(25);
  31. text(digitalValue5, 250, 250);
  32. //now do the mouse part
  33. //add the label
  34. textSize(12);
  35. text("/mouse/step", 350, 270);
  36. //make a box where it should go
  37. noFill();
  38. stroke(255);
  39. rect(350, 50, 200, 200);
  40. //and a square where the mouse is
  41. fill(255);
  42. float mouseXPos = map(mouseStepX, 0, 1024, 350, 530);
  43. float mouseYPos = map(mouseStepY, 0, 1024, 50, 230);
  44. rect(mouseXPos, mouseYPos, 20, 20);
  45. }
  46. int analogValue0 = 50;
  47. int analogValue1 = 50;
  48. String digitalValue5 = "LOW";
  49. int mouseStepX = 0;
  50. int mouseStepY = 0;
  51. // incoming osc message are forwarded to the oscEvent method.
  52. void oscEvent(OscMessage theOscMessage) {
  53. //println(theOscMessage.addrPattern());
  54. if (theOscMessage.addrPattern().equals("/analog/0")){
  55. analogValue0 = theOscMessage.get(0).intValue();
  56. } else if(theOscMessage.addrPattern().equals("/analog/1")){
  57. analogValue1 = theOscMessage.get(0).intValue();
  58. } else if(theOscMessage.addrPattern().equals("/digital/5")){
  59. digitalValue5 = theOscMessage.get(0).stringValue();
  60. } else if(theOscMessage.addrPattern().equals("/mouse/step")){
  61. mouseStepX = theOscMessage.get(0).intValue();
  62. mouseStepY = theOscMessage.get(1).intValue();
  63. }
  64. }