From 4345f657818890b8885464845d6607238bfa6f36 Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Wed, 30 Oct 2013 08:26:27 +0100 Subject: [PATCH] Add led patch by dingo35 --- ledraspberry.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ledraspberry.cc b/ledraspberry.cc index bda573a..6269546 100644 --- a/ledraspberry.cc +++ b/ledraspberry.cc @@ -20,6 +20,8 @@ #include "ledraspberry.h" +#define GREEN_LED "/sys/class/leds/led0/brightness" + LedRaspberry::LedRaspberry() { initted = 0; @@ -32,6 +34,11 @@ LedRaspberry::~LedRaspberry() int LedRaspberry::init(int tdevice) { if (initted) return 0; + FILE *led=fopen(GREEN_LED,"w"); + if (led) { + fputc('0',led); + fclose(led); + } initted = 1; return 1; } @@ -46,11 +53,21 @@ int LedRaspberry::shutdown() int LedRaspberry::on() { if (!initted) return 0; + FILE *led=fopen(GREEN_LED,"w"); + if (led) { + fputc('1',led); + fclose(led); + } return 0; } int LedRaspberry::off() { if (!initted) return 0; + FILE *led=fopen(GREEN_LED,"w"); + if (led) { + fputc('0',led); + fclose(led); + } return 0; } -- 2.39.2