Atm_Teenstep_OSC.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #include "Atm_Teenstep_OSC.h"
  2. Atm_Teenstep_OSC& Atm_Teenstep_OSC::begin(Atm_Teenstep& stepperMachineRef, EthernetUDP& udpRef, OSCBundle& bndl, const char* address) {
  3. this-> stepperMachine = &stepperMachineRef;
  4. _adress = address;
  5. this->_udpRef = &udpRef;
  6. this->_bndl = &bndl ;
  7. //stepperMachine->onChangeposition( sendPosition, 0);
  8. return *this;
  9. }
  10. Atm_Teenstep_OSC& Atm_Teenstep_OSC::onOSC(OSCMessage& msg ){
  11. Serial.println("OSC");
  12. int patternOffset = msg.match(_adress) ;
  13. if(patternOffset){
  14. if(msg.fullMatch("/speedAcc", patternOffset)){
  15. stepperMachine->motor->setMaxSpeed(msg.getInt(0));
  16. stepperMachine->motor->setAcceleration(msg.getInt(1));
  17. }
  18. if(msg.fullMatch("/enable", patternOffset)){msg.getInt(0) ? stepperMachine->trigger(stepperMachine->EVT_ENABLE) : stepperMachine->trigger(stepperMachine->EVT_DISABLE);}
  19. //if(msg.fullMatch("/home", patternOffset)){home(msg.getInt(0));}
  20. if(msg.fullMatch("/move", patternOffset)){stepperMachine->move(msg.getInt(0));Serial.println(msg.getInt(0));}
  21. if(msg.fullMatch("/moveTo", patternOffset)){stepperMachine->moveTo(msg.getInt(0));}
  22. if(msg.fullMatch("/stop", patternOffset)){stepperMachine->stop();}
  23. if(msg.fullMatch("/emergencyStop", patternOffset)){stepperMachine->emergencystop();}
  24. if(msg.fullMatch("/home", patternOffset)){stepperMachine->homing(msg.getInt(0));}
  25. return *this;
  26. }
  27. }
  28. void Atm_Teenstep_OSC::sendPosition(int idx, int v, int up) {
  29. _bndl->add(_adress).add(v);
  30. }