diff options
| author | Franklin Wei <frankhwei536@gmail.com> | 1970-01-01 01:45:37 +0100 |
|---|---|---|
| committer | Franklin Wei <frankhwei536@gmail.com> | 1970-01-01 01:45:37 +0100 |
| commit | 3b33d88f5621a8d40ccf4c0177c98f63a5c19c38 (patch) | |
| tree | b9fcb18e466817b2256c5b86eb56d2a2c7003efb /led.cpp | |
| download | pish-3b33d88f5621a8d40ccf4c0177c98f63a5c19c38.zip pish-3b33d88f5621a8d40ccf4c0177c98f63a5c19c38.tar.gz pish-3b33d88f5621a8d40ccf4c0177c98f63a5c19c38.tar.bz2 pish-3b33d88f5621a8d40ccf4c0177c98f63a5c19c38.tar.xz | |
Initial commit
Diffstat (limited to 'led.cpp')
| -rw-r--r-- | led.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -0,0 +1,23 @@ +#include <fstream> +#include <leds.h> +using namespace std; +bool isLightOn() +{ + ifstream ifs("/sys/class/leds/led0/brightness"); + int brightness; + ifs >> brightness; + if(brightness==0) + return false; + else + return true; +} +void setLight(bool on) +{ + ofstream ofs("/sys/class/leds/led0/brightness"); + int val; + if(on) + val=255; + else + val=0; + ofs << val << flush; +} |