]> git.piffa.net Git - aerei/commitdiff
Aero
authorAndrea Manni <andrea@piffa.net>
Wed, 15 Mar 2017 11:46:53 +0000 (12:46 +0100)
committerAndrea Manni <andrea@piffa.net>
Wed, 15 Mar 2017 11:46:53 +0000 (12:46 +0100)
libraries/aero [deleted submodule]
libraries/aero/aero.cpp [new file with mode: 0644]
libraries/aero/aero.h [new file with mode: 0644]
libraries/aero/examples/tog_func/tog_func.ino [new file with mode: 0644]
libraries/aero/keywords.txt [new file with mode: 0644]
libraries/aero/library.properties [new file with mode: 0644]

diff --git a/libraries/aero b/libraries/aero
deleted file mode 160000 (submodule)
index 5d8011d..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 5d8011da088d10d3baf1804159b19aead3c06f3a
diff --git a/libraries/aero/aero.cpp b/libraries/aero/aero.cpp
new file mode 100644 (file)
index 0000000..1def2d7
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+  Aero 
+
+Autore: Andrea Manni
+
+Link: http://aero.piffa.net
+Licenza:    GPLv3
+
+*/
+
+#include "Arduino.h"
+#include "aero.h"
+
+#define dEBUG
+
+//////////////////
+// Funzioni
+
+boolean toggleRead (byte togglePin, const unsigned int freq ) {
+// Variabili Toggle
+long static unsigned toggleTime ; // Timestamp per switch
+static int toggleValue = 0 ; // Valore catturato
+static int toggleIn = 0 ; // Valore filtrato
+const int soglia = 1400; // soglia per scatto toggle a 2 posizioni
+// const unsigned int freq = 500 ; // Ogni quanti millisecondi leggere il valore
+
+    if (millis() - toggleTime > freq) {
+
+        toggleIn = pulseIn(togglePin, HIGH, 25000);
+        if (toggleIn != 0 && toggleIn > 1000 && toggleIn <2000)  {
+            // get only resonable values
+            toggleValue = toggleIn;
+            toggleTime = millis() ;
+        } ;
+    };
+#ifdef DEBUG
+    Serial.print(toggleIn);
+    Serial.print(" - Filtrato: ");
+    Serial.println(toggleValue);
+#endif
+
+if (toggleValue > soglia) {
+    return 1;
+} else {
+    return 0;
+} ;
+
+}
diff --git a/libraries/aero/aero.h b/libraries/aero/aero.h
new file mode 100644 (file)
index 0000000..d946e22
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+  Aero 
+
+Autore: Andrea Manni
+
+Link: http://aero.piffa.net
+Licenza:    GPLv3
+
+*/
+
+#include "Arduino.h"
+#include <avr/pgmspace.h>
+
+#ifndef aero_h
+#define aero_h
+
+//////////////////////
+// Funzioni
+
+boolean toggleRead(byte togglePin, const unsigned int freq = 500) ;
+
+#endif
diff --git a/libraries/aero/examples/tog_func/tog_func.ino b/libraries/aero/examples/tog_func/tog_func.ino
new file mode 100644 (file)
index 0000000..c13a91c
--- /dev/null
@@ -0,0 +1,42 @@
+/* Toggle con transizioni tra On | OFF con pulseIn
+   Funzione
+
+
+Sketch di esempio per accensione spegnimento di tutto l'impianto luci
+tramite un interruttore a due posizioni della radio utilizzando 
+la funzione toggleRead(pin) basata su pulseIn.
+
+
+Input:
+   1 pulseIn su A0 per accensione / spegnimento luci
+
+
+   Il codice e' blocking fin tanto che il segnale passa da RISE a FALL
+   quindi blocca per 1-2ms a ogni esecuzione. Con la variabile freq
+   si imposta ogni quanto fare una lettura (default = 500ms).
+
+
+*/
+
+#define dEBUG
+#include <common.h>
+#include <aero.h>
+
+void setup() {
+   Serial.begin(9600);
+} ;
+
+void loop() {
+
+
+if (toggleRead(A0)) { // Numero del PIN a cui e' collegato il canale dell'interruttore
+//if (toggleRead(A0,100)) { // Numero del PIN, frequenza di aggiornamento in milli sec
+    // Luci accese
+    Serial.println("Luci On ");
+} else {
+    // luci spente
+    Serial.println("Luci Off ");
+} ;
+
+
+}
diff --git a/libraries/aero/keywords.txt b/libraries/aero/keywords.txt
new file mode 100644 (file)
index 0000000..591e203
--- /dev/null
@@ -0,0 +1 @@
+toggleRead                     KEYWORD2        
diff --git a/libraries/aero/library.properties b/libraries/aero/library.properties
new file mode 100644 (file)
index 0000000..c6edb67
--- /dev/null
@@ -0,0 +1,9 @@
+name=Aero
+version=1.0
+author=Andrea Manni <andrea@piffa.net>
+maintainer=Andrea Manni <andrea@piffa.net>
+sentence=Funzioni specifiche per aerei
+paragraph=Funzioni da richiamare negli sketch per aerei rc
+category=Display
+url=https://aerei.piffa.net
+architectures=*