Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ajout de la gestion du débug

  • Loading branch information...
commit b942713c8479df5e817643511506e565ca6915d9 1 parent 378091b
Rémi authored
Showing with 31 additions and 14 deletions.
  1. +31 −14 arduino_CUGN.ino
45 arduino_CUGN.ino
View
@@ -4,6 +4,15 @@
#include "DS1302.h"
#include "SimpleTimer.h"
+#define DEBUG
+
+#ifdef DEBUG
+ #define DEBUG_PRINT(x) Serial.println (x)
+#else
+ #define DEBUG_PRINT(x)
+#endif
+
+
//Création de l'objet Timer
SimpleTimer timer;
@@ -45,7 +54,8 @@ void print_time()
t.day,
t.yr, t.mon, t.date,
t.hr, t.min, t.sec);
- Serial.println(buf);
+ DEBUG_PRINT(buf);
+
}
@@ -55,7 +65,7 @@ void isr_btn1()
if(!btn1_state)
{
btn1_state=true;
- Serial.println("Pushed");
+ DEBUG_PRINT("Pushed");
//on met en place le timeout
timer.setTimeout(1000, clear_btn1);
}
@@ -68,8 +78,8 @@ void isr_btn2()
if(btn1_state)
{
btn1_state=false;
- Serial.println("Pushed 2");
- Serial.println("Bouteille");
+ DEBUG_PRINT("Pushed 2");
+ DEBUG_PRINT("Bouteille");
}
}
@@ -77,12 +87,28 @@ void isr_btn2()
//On enleve le flag quand le timeout du 1er btn est atteint
void clear_btn1()
{
+ if(btn1_state)
+ {
+ DEBUG_PRINT("Btn1 TimeOut");
btn1_state=false;
+ }
}
//Setup
void setup() {
+
+ pinMode(2, INPUT);
+ pinMode(3, INPUT);
+
+ //Activation Pull-up
+ digitalWrite(2, HIGH);
+ digitalWrite(3, HIGH);
+
+ // 0 = pin 2 ; 1 = pin 3
+ attachInterrupt(0, isr_btn1, FALLING);
+ attachInterrupt(1, isr_btn2, FALLING);
+
Serial.begin(9600);
rtc.write_protect(false);
@@ -94,21 +120,12 @@ void setup() {
/* Chargement de l'heure */
rtc.time(t);
- pinMode(2, INPUT);
- pinMode(3, INPUT);
-
- //Activation Pull-up
- digitalWrite(2, HIGH);
- digitalWrite(3, HIGH);
- // 0 = pin 2 ; 1 = pin 3
- attachInterrupt(0, isr_btn1, FALLING);
- attachInterrupt(1, isr_btn2, FALLING);
}
//Boucle principale
void loop() {
- // Serial.println( readVcc(), DEC );
+ DEBUG_PRINT(readVcc());
//print_time();
//delay(1000);
timer.run();
Please sign in to comment.
Something went wrong with that request. Please try again.