- piatto -> sx
- piatto -> dx
-
+Note:
TODO:
* clean up magic numbers
const byte chPin2 = 3; // PIN per la calibrazione
int mid_point2 = 1500;
+// LEDS
+Pwm motore = 7;
-// Variabili:
-unsigned long currentMillis; // timestamp reference per millis per tutto il loop
-
-Pwm motore = 11;
-
-// Un LED RGB
+//RGB
RGBLed ailerons(11,10,9,255); // Common Cat
-
-// Transizione: Pwm
-Lampeggiatore sxLamp(10); // Lampeggiatore
-Lampeggiatore dxLamp(9); // Lampeggiatore
+ // Transizione: lampeggiatori sui PIN RGB
+ Lampeggiatore sxLamp(10); // Lampeggiatore
+ Lampeggiatore dxLamp(9); // Lampeggiatore
// Variabili per lettura canale servo
// Vars FSM
unsigned long FSM_lastMillis = 0 ; // Timestamp per la FSM degli alettoni
-unsigned long pausa = 500; // Pausa per la transizione durante gli stati 2, 4 della FSM
+unsigned long pausa = 600; // Pausa per la transizione durante gli stati 2, 4 della FSM
+
+// Variabili comuni:
+unsigned long currentMillis; // timestamp reference per millis per tutto il loop
+
///////////////////////////////////////////////////////////
void setup() {
void loop() {
currentMillis = millis(); // Timestamp per tutto il loop
- switch (ailstate) {
+ switch (ailstate) {
case middle:
ailerons.White();
// Alettoni piatti
if (ail > mid_point + deviation + deviation /3) {
// extra margine per avere un po' di gioco
ailstate = sxin;
+ ailerons.Off();
FSM_lastMillis = currentMillis;
}
else if (ail < mid_point - deviation - deviation / 3) {
ailstate = dxin;
+ ailerons.Off();
FSM_lastMillis = currentMillis ;
} ;
break;
case sxin:
// Transizione a sx
- sxLamp.Blink(200);
+ sxLamp.Blink(150);
if (currentMillis - pausa > FSM_lastMillis ) {
ailstate = sx;
}
case dxin:
// Transizione a dx
- dxLamp.Blink(200);
+ dxLamp.Blink(150);
if (currentMillis - pausa > FSM_lastMillis ) {
ailstate = dx;
}
Serial.println(ailstate);
#endif
}
-// Functions
+// ISRs
void chRise2() {
attachInterrupt(0, chFall2, FALLING);
chStart2 = micros();