HexLeds
Revision 0:be215ed59257, committed 2018-06-22
- Comitter:
- martwerl
- Date:
- Fri Jun 22 08:53:25 2018 +0000
- Commit message:
- TINF_HexLeds
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HexLeds.cpp Fri Jun 22 08:53:25 2018 +0000 @@ -0,0 +1,28 @@ +#include "mbed.h" +#include "HexLeds.h" + +void HexLeds::input(void) +{ + int temp = 0; + scanf ("%d", &temp); + if(temp < 16) + _Hexwert = temp; + else + _Hexwert = 0; +} + +void HexLeds::output(void) +{ + printf("Wert = %d\n", _Hexwert); +} + +void HexLeds::hexOut(void) +{ + _Leds = _Hexwert; +} + +void HexLeds::printStatus(void) +{ + printf("LED Status:\n LED1: %d\n LED2: %d\n LED3: %d\n LED4: %d\n", + _pin1.read(), _pin2.read(), _pin3.read(), _pin4.read()); +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HexLeds.h Fri Jun 22 08:53:25 2018 +0000 @@ -0,0 +1,29 @@ +#include "mbed.h" +#ifndef HEXLEDS_H +#define HEXLEDS_H + +class HexLeds +{ +public: + HexLeds(PinName pin1, PinName pin2, PinName pin3, PinName pin4) : _pin1(pin1), _pin2(pin2), _pin3(pin3), _pin4(pin4), _Leds(pin1, pin2, pin3, pin4) + { + _pin1 = 0; + _pin2 = 0; + _pin3 = 0; + _pin4 = 0; + _Leds = 0; + } + void input(void); + void output(void); + void hexOut(void); + void printStatus(void); + +private: + BusOut _Leds; + DigitalOut _pin1; + DigitalOut _pin2; + DigitalOut _pin3; + DigitalOut _pin4; + int _Hexwert; +}; +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jun 22 08:53:25 2018 +0000 @@ -0,0 +1,12 @@ +#include "mbed.h" +#include "HexLeds.h" + +HexLeds hexleds(LED1, LED2, LED3, LED4); + +int main() +{ + hexleds.input(); + hexleds.output(); + hexleds.hexOut(); + hexleds.printStatus(); +} \ No newline at end of file