]> git.piffa.net Git - rover/blobdiff - libraries/rover/rover.h
Primo oggetto per drive, con un solo metodo
[rover] / libraries / rover / rover.h
index acde54fcf86c59cc804a688e58a8c67044f23972..54463597e64987b87e8fe27ca79e18f117ce2cac 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  Rover 
+  Rover
 
 Autore: Andrea Manni
 
@@ -13,41 +13,55 @@ Licenza:    GPLv3
 #ifndef rover_h
 #define rover_h
 
-//////////////////////
-// OBJ
+// Global vars
+extern int enA ;
+extern int in1 ;
+extern int in2 ;
+extern byte speedA ;
+// motor two
+extern int enB ;
+extern int in3 ;
+extern int in4 ;
 
 
-class engine {
-// Gestione di un singolo motore
-private:
-    byte enablePIN1;
-    byte enablePIN2;
-    byte min;   // Minimo per partire
-    byte val;   // 8bit PWM
-
-public:
-    Engine (byte PIN1, byte PIN2, byte PINPWM);
-    void Forward ();
-    void Backward ();
-    void SetSpeed (); // imposta un valore preciso per il PWM
+// Funzioni
 
-}
+void abilita() ;
+void forwardA(); // speedA e' dato dalla variabile golabale speedA
+void forwardA(byte speedA); // Overloading
+void backwardA() ;
+void backwardA(byte speedA) ;
+void stopA() ;
+void forwardB() ;
+void forwardB(byte speedB) ;
+void backwardB() ;
+void backwardB(byte speedB) ;
+void stopB() ;
 
-class motors {
-// classe composta da due engines
-// Composition is better than inheritance here
+// Objects:
 
-public:
-    motors (engine enginesx, engine enginedx) {
-    void Forward ();
-    void Backward ();
-    void TurnLeft ();
-    void TurnRight ();
-    void TurnU ();
-}
-}
-//////////////////////
-// Funzioni
 
+class car {
+// Lettura delle variabili globali (per poter tenere un file
+// di configurazione con tutti i PIN)
+// motor one
+    const int _enA = enA ;
+    const int _in1 = in1 ;
+    const int _in2 = in2 ;
+// motor two
+    const int _enB = enB ;
+    const int _in3 = in3 ;
+    const int _in4 = in4 ;
 
+public:
+    car () ;
+    byte velA ;
+    byte velB ;
+    void avanti ();
+    void indietro ();
+    void stop ();
+    void giraSX ();
+    void giraDX ();
+    void setSpeed ();
+};
 #endif