api-hal-light.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include <api-hal-light.h>
  2. #include <lp5562.h>
  3. #define LED_CURRENT_RED 50
  4. #define LED_CURRENT_GREEN 50
  5. #define LED_CURRENT_BLUE 50
  6. #define LED_CURRENT_WHITE 150
  7. void api_hal_light_init() {
  8. lp5562_reset();
  9. lp5562_set_channel_current(LP5562ChannelRed, LED_CURRENT_RED);
  10. lp5562_set_channel_current(LP5562ChannelGreen, LED_CURRENT_GREEN);
  11. lp5562_set_channel_current(LP5562ChannelBlue, LED_CURRENT_BLUE);
  12. lp5562_set_channel_current(LP5562ChannelWhite, LED_CURRENT_WHITE);
  13. lp5562_set_channel_value(LP5562ChannelRed, 0x00);
  14. lp5562_set_channel_value(LP5562ChannelGreen, 0x00);
  15. lp5562_set_channel_value(LP5562ChannelBlue, 0x00);
  16. lp5562_set_channel_value(LP5562ChannelWhite, 0x00);
  17. lp5562_enable();
  18. lp5562_configure();
  19. }
  20. void api_hal_light_set(Light light, uint8_t value) {
  21. switch(light) {
  22. case LightRed:
  23. lp5562_set_channel_value(LP5562ChannelRed, value);
  24. break;
  25. case LightGreen:
  26. lp5562_set_channel_value(LP5562ChannelGreen, value);
  27. break;
  28. case LightBlue:
  29. lp5562_set_channel_value(LP5562ChannelBlue, value);
  30. break;
  31. case LightBacklight:
  32. lp5562_set_channel_value(LP5562ChannelWhite, value);
  33. break;
  34. default:
  35. break;
  36. }
  37. }