Advertisement
Guest User

Untitled

a guest
Oct 17th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. /* ================= REQUIRED LIBRARIES =============== */
  2. /*
  3. *
  4. *
  5. */
  6. #include <SerialCommand.h>
  7. #include <SoftwareSerial.h>
  8. #include "FocheggiatoreLib.h"
  9. #include "config.h"
  10.  
  11. SerialCommand SCmd;
  12.  
  13. /* ====================================================== */
  14. /* =================== CLASS DEFINE =================== */
  15. /* ====================================================== */
  16.  
  17. // FOC_LIB_INI
  18.  
  19. Focheggiatore foc = Focheggiatore( PIN_FOC_ENABLE, PIN_FOC_DIR, PIN_FOC_STEP, PIN_FOC_SELECT, PIN_FOC_FC_UP, PIN_FOC_FC_DOWN, PIN_FOC_HOME, PIN_MOSI, PIN_MISO, PIN_SCK );
  20.  
  21.  
  22. void setup()
  23. {
  24.  
  25. // Inizializzo Seriale
  26. Serial.begin( SERIAL_BOUND_RATE );
  27.  
  28.  
  29. // Inizializzo Focheggiatore
  30. foc.begin();
  31.  
  32.  
  33. /* =================== SERIAL COMANDS =================== */
  34.  
  35. // MOTORI
  36. SCmd.addCommand("CMI",infinito);
  37.  
  38. /*
  39. *
  40. * MAIN LOOP FUNC
  41. *
  42. */
  43. void loop()
  44. {
  45. // Handler comandi seriale
  46. SCmd.readSerial();
  47.  
  48. // Routine per Focheggiatore
  49. foc.singleSteps();
  50.  
  51. }
  52.  
  53.  
  54.  
  55.  
  56. /* ================================================================== */
  57. /* ======================== CAMANDS CALLBACKS ====================== */
  58. /* ================================================================== */
  59.  
  60.  
  61.  
  62. /* =========================== MOTORI ============================= */
  63. /*
  64. *
  65. *
  66. *
  67. */
  68.  
  69. /* =============== INFINITY MOVE ============ */
  70.  
  71. /*
  72. *
  73. *
  74. */
  75. void infinito(){
  76.  
  77. char* id = SCmd.next();
  78. char* dir = SCmd.next();
  79. if( *id == FOC_MOT_ID ){
  80. foc.move( *dir, 200 , 1 );
  81. }
  82. Serial.println("ok-CMI");
  83. }
  84.  
  85.  
  86. /* ====== HELPERS ====== */
  87.  
  88. long int convertToInt( char* vett ) {
  89. String appoString = vett;
  90. long int num = appoString.toInt();
  91. return num;
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement