Led_Sysfs.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. Copyright (C) 2017 Emlid Ltd. All rights reserved.
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #include <AP_HAL/AP_HAL.h>
  15. #if CONFIG_HAL_BOARD == HAL_BOARD_LINUX
  16. #include "Led_Sysfs.h"
  17. #include <AP_HAL_Linux/Led_Sysfs.h>
  18. Led_Sysfs::Led_Sysfs(const char *red, const char *green, const char *blue,
  19. uint8_t off_brightness, uint8_t low_brightness, uint8_t medium_brightness, uint8_t high_brightness):
  20. RGBLed(off_brightness, high_brightness, medium_brightness, low_brightness),
  21. red_led(red),
  22. green_led(green),
  23. blue_led(blue)
  24. {
  25. }
  26. bool Led_Sysfs::hw_init()
  27. {
  28. if (red_led.init() && green_led.init() && blue_led.init()) {
  29. return true;
  30. }
  31. return false;
  32. }
  33. bool Led_Sysfs::hw_set_rgb(uint8_t red, uint8_t green, uint8_t blue)
  34. {
  35. red_led.set_brightness(red);
  36. green_led.set_brightness(green);
  37. blue_led.set_brightness(blue);
  38. return true;
  39. }
  40. #endif