changeset 15:61de3195b19d

Use a different IR library
author Radomir Dopieralski <sheep-devel@sheep.art.pl>
date Sun, 12 Oct 2014 10:54:09 +0200
parents 2d8033ee54af
children 7c312f2f6291
files katka/ir.ino katka/katka.ino
diffstat 2 files changed, 27 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/katka/ir.ino	Mon Sep 15 20:40:45 2014 +0200
+++ b/katka/ir.ino	Sun Oct 12 10:54:09 2014 +0200
@@ -1,48 +1,37 @@
 #include "creep.h"
 
-// TV remote support
-static IRrecv irrecv(2);
-
-
 void ir_setup() {
-    irrecv.enableIRIn();
+    IRLbegin<IR_ALL>(0); // Sensor on PIN 2
     pinMode(13, OUTPUT);
     digitalWrite(13, LOW);
 }
 
 void ir() {
-    static unsigned long last = 0;
-    decode_results ir_results;
+    // digitalWrite(13, LOW);
+}
+
+void IREvent(uint8_t protocol, uint16_t address, uint32_t command) {
+    static uint32_t last=0;
 
-    if (irrecv.decode(&ir_results)) {
-        if (ir_results.value == 0xFFFFFF) {
-            ir_results.value = last;
-        }
-        switch (ir_results.value) {
-            case 0xFF02FD:
-                creep_speed = min(1.0, creep_speed + 0.25);
-                digitalWrite(13, HIGH);
-                break;
-            case 0xFF9867:
-                creep_speed = max(-1.0, creep_speed - 0.25);
-                digitalWrite(13, HIGH);
-                break;
-            case 0xFFE01F:
-                creep_rotation = min(1.0, creep_rotation + 0.25);
-                digitalWrite(13, HIGH);
-                break;
-            case 0xFF906F:
-                creep_rotation = max(-1.0, creep_rotation - 0.25);
-                digitalWrite(13, HIGH);
-                break;
-            case 0xFFA857:
-                creep_speed = 0.0;
-                creep_rotation = 0.0;
-                digitalWrite(13, HIGH);
-                break;
-        }
-        irrecv.resume();
-    } else {
-        digitalWrite(13, LOW);
+    if (command == 0xFFFFFF) {
+        command = last;
+    }
+    switch (command) {
+        case 0x02FD:
+            creep_speed = min(1.0, creep_speed + 0.25);
+            break;
+        case 0x9867:
+            creep_speed = max(-1.0, creep_speed - 0.25);
+            break;
+        case 0xE01F:
+            creep_rotation = min(1.0, creep_rotation + 0.25);
+            break;
+        case 0x906F:
+            creep_rotation = max(-1.0, creep_rotation - 0.25);
+            break;
+        case 0xA857:
+            creep_speed = 0.0;
+            creep_rotation = 0.0;
+            break;
     }
 }
--- a/katka/katka.ino	Mon Sep 15 20:40:45 2014 +0200
+++ b/katka/katka.ino	Sun Oct 12 10:54:09 2014 +0200
@@ -1,6 +1,6 @@
 /* Katka creeping around autonomously. */
 
-#include <IRremote.h>
+#include <IRLremote.h>
 #include <Servo.h>
 
 #include "servos.h"