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:
- 7:e7f74f072564
- Parent:
- 6:df6830254e8b
- Child:
- 12:cedc088eaf05
diff -r df6830254e8b -r e7f74f072564 ur_Bertl.cpp --- a/ur_Bertl.cpp Fri Apr 10 09:31:54 2015 +0000 +++ b/ur_Bertl.cpp Mon Apr 13 15:28:10 2015 +0000 @@ -1,11 +1,12 @@ /*********************************** -name: ur_Bertl.cpp Version: 2.0 +name: ur_Bertl.cpp Version: 2.1 author: PE HTL BULME email: pe@bulme.at WIKI: https://developer.mbed.org/teams/BERTL_CHEL_18/code/ur_Bertl/ description: Implementation portion of class ur_Bertl The Robot - boolean commands added for if/else, while, ... + boolean commands added for if/else, while, ... + int ReturnButtonPressed() added which returns the int value of button pressed ***********************************/ #include "mbed.h" #include "config.h" @@ -282,6 +283,22 @@ return wert; } +int ur_Bertl::ReturnButtonPressed() +{ + char cmd[3]; // array for I2C + int16_t btns; + + cmd[0] = 0x06; + cmd[1] = 0x00; + i2c.write(addr, cmd, 2); + + cmd[0]=0x01; + i2c.write(addr, cmd, 1); + i2c.read(addr|1, cmd, 1); + btns = cmd[0]; + DEBUG_PRINT("Button: %d", btns); + return btns; +} // Protected methodes int ur_Bertl::bottomIsBlack()