diff options
author | Slávek Banko <slavek.banko@axis.cz> | 2013-07-02 18:32:11 +0200 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2013-07-02 18:32:11 +0200 |
commit | 5ec5bc2080bbc41e025fb98e6571a2c281b775cb (patch) | |
tree | a73cf2c57d306e6ce092996f70b29b8fbc0a006b /kbiff/led.cpp | |
download | kbiff-5ec5bc2080bbc41e025fb98e6571a2c281b775cb.tar.gz kbiff-5ec5bc2080bbc41e025fb98e6571a2c281b775cb.zip |
Initial import
Diffstat (limited to 'kbiff/led.cpp')
-rw-r--r-- | kbiff/led.cpp | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/kbiff/led.cpp b/kbiff/led.cpp new file mode 100644 index 0000000..cc27d71 --- /dev/null +++ b/kbiff/led.cpp @@ -0,0 +1,81 @@ +/*************************************************************************** + led.cpp - description + ------------------- + begin : do okt 9 2003 + copyright : (C) 2003 by Roeland Merks + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "led.h" + +#ifdef HAVE_MLED +#include <fstream> +#include <string> +#include <fstream> +#include <iostream> +using namespace std; + +const char *ASUS_ACPI="/proc/acpi/asus/"; + +Led::Led() +{ + Led("wled"); +} + +Led::Led(const char *ledname) +{ + string fname(string(ASUS_ACPI)+string(ledname)); + + led=new ofstream(fname.c_str()); + + // If there is no LED, just give a one time warning on cerr + if (!(*led)) { + static bool error_given=false; + if (!error_given) { + cerr << "Warning: trying to use Asus LED, but no ACPI-entry found.\n"; + error_given=true; + } + } +} + +Led::~Led() +{ + Off(); + delete led; +} + + +void Led::On() +{ + if (*led) { + *led << 1; + led->flush(); + } +} + +void Led::Off() +{ + if (*led) { + *led << 0; + led->flush(); + } +} +#else +Led::Led() {} +Led::Led(const char *) {} +Led::~Led() {} +void Led::On() {} +void Led::Off() {} +#endif |