summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn S <shawnshen@google.com>2015-10-08 10:39:42 -0700
committerShawn S <shawnshen@google.com>2015-10-08 18:52:31 -0700
commit83a316758591e349595e408940a1b42bd42c9972 (patch)
tree64cfd47328a2bc390daf5cee721ef39c76c337f7
parent5a94ba1b6b3694bc431796df4bbee3f2371ecf91 (diff)
downloadexample-ledflasher-83a316758591e349595e408940a1b42bd42c9972.tar.gz
Added control for boot LED #4 in the sample
Change-Id: I764e2dddf11e05bb5878983e9c630b153167fffc
-rw-r--r--src/ledflasher/animation.h2
-rw-r--r--src/ledflasher/etc/weaved/commands/ledflasher.json4
-rw-r--r--src/ledservice/ledstatus.cc11
-rw-r--r--src/ledservice/ledstatus.h2
4 files changed, 12 insertions, 7 deletions
diff --git a/src/ledflasher/animation.h b/src/ledflasher/animation.h
index 3613765..63cd209 100644
--- a/src/ledflasher/animation.h
+++ b/src/ledflasher/animation.h
@@ -39,7 +39,7 @@ class Animation {
const std::string& type,
const base::TimeDelta& duration);
- static const size_t num_leds = 3;
+ static const size_t num_leds = 4;
protected:
virtual void DoAnimationStep() = 0;
diff --git a/src/ledflasher/etc/weaved/commands/ledflasher.json b/src/ledflasher/etc/weaved/commands/ledflasher.json
index 04da109..08fe6e5 100644
--- a/src/ledflasher/etc/weaved/commands/ledflasher.json
+++ b/src/ledflasher/etc/weaved/commands/ledflasher.json
@@ -2,13 +2,13 @@
"_ledflasher": {
"_set": {
"parameters": {
- "_led": {"minimum": 1, "maximum": 3},
+ "_led": {"minimum": 1, "maximum": 4},
"_on": "boolean"
}
},
"_toggle": {
"parameters": {
- "_led": {"minimum": 1, "maximum": 3}
+ "_led": {"minimum": 1, "maximum": 4}
}
},
"_animate": {
diff --git a/src/ledservice/ledstatus.cc b/src/ledservice/ledstatus.cc
index fdbcc4f..e2a17fe 100644
--- a/src/ledservice/ledstatus.cc
+++ b/src/ledservice/ledstatus.cc
@@ -31,9 +31,14 @@ namespace {
chromeos::StreamPtr GetLEDDataStream(size_t index, bool write) {
CHECK(index < LedStatus::num_leds);
- base::FilePath dev_path{
- base::StringPrintf("/sys/class/leds/led%" PRIuS "/brightness",
- index + 1)};
+ std::string led_path;
+ if( index == 3 ) {
+ led_path = "/sys/class/leds/boot/brightness";
+ } else {
+ led_path = base::StringPrintf("/sys/class/leds/led%" PRIuS "/brightness",
+ index + 1);
+ }
+ base::FilePath dev_path{led_path};
auto access_mode = chromeos::stream_utils::MakeAccessMode(!write, write);
return chromeos::FileStream::Open(
dev_path, access_mode, chromeos::FileStream::Disposition::OPEN_EXISTING,
diff --git a/src/ledservice/ledstatus.h b/src/ledservice/ledstatus.h
index 8101d82..f12e958 100644
--- a/src/ledservice/ledstatus.h
+++ b/src/ledservice/ledstatus.h
@@ -29,7 +29,7 @@ class LedStatus final {
bool IsLedOn(size_t index) const;
void SetLedStatus(size_t index, bool on);
- static const size_t num_leds = 3;
+ static const size_t num_leds = 4;
private: