Led-cpp BBB
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

33 lines
823 B

/*OOP in C++ example for LEDs
Gerardo Marx April/20/2020
g++ main.cpp -o main LED.cpp*/
#include<string>
#include"led.h"
using namespace std;
int main(int argc, char* argv[]){
if(argc!=2){
cout << "The usage is main mkLed" << endl;
cout << "mkLed is on, off flash or status" << endl;
cout << "e.g. main on" << endl;
return 2;
}
cout << "Starting program ..." << endl;
string cmd(argv[1]);
LED leds[4] = {LED(0), LED(1), LED(2), LED(3)};
for(int i=0; i<=3; i++){
if(cmd=="on")
leds[i].turnOn();
else if(cmd=="off")
leds[i].turnOff();
else if(cmd=="flash")
leds[i].flash("100");
else if(cmd=="status")
leds[i].outputState();
else
cout << "invalid command, please type main" << endl;
}
cout << "Program done, Thanks." << endl;
return 0;
}