Leds work simultanously. Version 3.1
Dependents: bertl_led bertl_led bertl_led bertl_led ... more
Fork of Bertl by
BULME HTL Graz-Gösting
FSST - Hardwarenahe Programmierung
Created by Prof.Dr. Franz Pucher
Inhalt
Start mit folgendem Code in main.cpp eines neuen Projektes mbed_blinky:
#include "mbed.h" #include "const.h" #include "Robot.h" Robot bertl; int main() { bertl.NibbleLeds(0x0F); wait(1); bertl.NibbleLeds(0x00); while(1) { if(bertl.IsButtonPressed(BTN_BL)) { bertl.TurnLedOn(LED_BL1); } if(bertl.IsButtonPressed(BTN_BR)) { bertl.TurnLedOff(LED_BL1); } } }
Diff: ur_Bertl.cpp
- Revision:
- 17:308802267a62
- Parent:
- 15:43d6a7e6e64a
- Child:
- 18:e9bb4513ae3a
diff -r 9ec833d98d0d -r 308802267a62 ur_Bertl.cpp --- a/ur_Bertl.cpp Thu Nov 12 09:05:05 2015 +0000 +++ b/ur_Bertl.cpp Thu Nov 12 19:05:56 2015 +0000 @@ -29,6 +29,7 @@ _interrupt.rise(this, &ur_Bertl::increment); // attach increment function of this counter instance ie. motor sensor _count = 0; beepersInBag = 0; + TurnLedOff(0xFF); } ur_Bertl::ur_Bertl(PinName pin) : _interrupt(pin) // create the InterruptIn on the pin specified to Counter @@ -42,6 +43,7 @@ _interrupt.rise(this, &ur_Bertl::increment); // attach increment function of this counter instance ie. motor sensor _count = 0; beepersInBag = 0; + TurnLedOff(0xFF); } // Pulblic methodes @@ -146,6 +148,7 @@ void ur_Bertl::TurnLedOn(int16_t led) { + leds = leds | led; char cmd[3]; if(led == 0xBB) { @@ -156,13 +159,14 @@ LED_blue=0; } cmd[0] = 0x02; - cmd[1] = ~led; + cmd[1] = ~leds; i2c.write(addr, cmd, 2); wait(0.5); } void ur_Bertl::TurnLedOff(int16_t led) { + leds = leds & ~led; char cmd[3]; if(led == 0xBB) { LED_blue=1; @@ -172,7 +176,7 @@ LED_blue=1; } cmd[0] = 0x02; - cmd[1] = led; + cmd[1] = ~leds; i2c.write(addr, cmd, 2); wait(0.5); }