Armando Montanez | 196b0cd | 2020-11-06 11:43:27 -0800 | [diff] [blame] | 1 | // Copyright 2020 The Pigweed Authors |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 4 | // use this file except in compliance with the License. You may obtain a copy of |
| 5 | // the License at |
| 6 | // |
| 7 | // https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | // License for the specific language governing permissions and limitations under |
| 13 | // the License. |
| 14 | |
| 15 | #include "pw_board_led/led.h" |
| 16 | |
| 17 | #include <cinttypes> |
| 18 | |
| 19 | #include "pw_log/log.h" |
| 20 | |
Anthony DiGirolamo | 1682d53 | 2024-05-14 17:45:29 +0000 | [diff] [blame] | 21 | // pw::board_led API implementation for the a host machine using log statements |
| 22 | // to simulate blinking an LED. |
Armando Montanez | 196b0cd | 2020-11-06 11:43:27 -0800 | [diff] [blame] | 23 | namespace pw::board_led { |
| 24 | namespace { |
| 25 | |
| 26 | bool led_on = false; |
| 27 | |
| 28 | } // namespace |
| 29 | |
| 30 | void Init() { TurnOff(); } |
| 31 | |
| 32 | void TurnOff() { |
| 33 | PW_LOG_INFO("[ ]"); |
| 34 | led_on = false; |
| 35 | } |
| 36 | |
| 37 | void TurnOn() { |
| 38 | PW_LOG_INFO("[*]"); |
| 39 | led_on = true; |
| 40 | } |
| 41 | |
| 42 | void Toggle() { |
| 43 | // Check if the LED is on. If so, turn it off. |
| 44 | if (led_on) { |
| 45 | TurnOff(); |
| 46 | } else { |
| 47 | TurnOn(); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | } // namespace pw::board_led |