PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

power_mgt.h 3.6KB

3 år sedan
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #ifndef POWER_MGT_H
  2. #define POWER_MGT_H
  3. #include "FastLED.h"
  4. #include "pixeltypes.h"
  5. FASTLED_NAMESPACE_BEGIN
  6. ///@defgroup Power Power management functions
  7. /// functions used to limit the amount of power used by FastLED
  8. ///@{
  9. // Power Control setup functions
  10. //
  11. // Example:
  12. // set_max_power_in_volts_and_milliamps( 5, 400);
  13. //
  14. /// Set the maximum power used in milliamps for a given voltage
  15. /// @deprecated - use FastLED.setMaxPowerInVoltsAndMilliamps()
  16. void set_max_power_in_volts_and_milliamps( uint8_t volts, uint32_t milliamps);
  17. /// Set the maximum power used in watts
  18. /// @deprecated - use FastLED.setMaxPowerInMilliWatts
  19. void set_max_power_in_milliwatts( uint32_t powerInmW);
  20. /// Select a pin with an led that will be flashed to indicate that power management
  21. /// is pulling down the brightness
  22. void set_max_power_indicator_LED( uint8_t pinNumber); // zero = no indicator LED
  23. // Power Control 'show' and 'delay' functions
  24. //
  25. // These are drop-in replacements for FastLED.show() and FastLED.delay()
  26. // In order to use these, you have to actually replace your calls to
  27. // FastLED.show() and FastLED.delay() with these two functions.
  28. //
  29. // Example:
  30. // // was: FastLED.show();
  31. // // now is:
  32. // show_at_max_brightness_for_power();
  33. //
  34. /// Similar to FastLED.show, but pre-adjusts brightness to keep below the power
  35. /// threshold.
  36. /// @deprecated this has now been moved to FastLED.show();
  37. void show_at_max_brightness_for_power();
  38. /// Similar to FastLED.delay, but pre-adjusts brightness to keep below the power
  39. /// threshold.
  40. /// @deprecated this has now been rolled into FastLED.delay();
  41. void delay_at_max_brightness_for_power( uint16_t ms);
  42. // Power Control internal helper functions
  43. /// calculate_unscaled_power_mW tells you how many milliwatts the current
  44. /// LED data would draw at brightness = 255.
  45. ///
  46. uint32_t calculate_unscaled_power_mW( const CRGB* ledbuffer, uint16_t numLeds);
  47. /// calculate_max_brightness_for_power_mW tells you the highest brightness
  48. /// level you can use and still stay under the specified power budget for
  49. /// a given set of leds. It takes a pointer to an array of CRGB objects, a
  50. /// count, a 'target brightness' which is the brightness you'd ideally like
  51. /// to use, and the max power draw desired in milliwatts. The result from
  52. /// this function will be no higher than the target_brightess you supply, but may be lower.
  53. uint8_t calculate_max_brightness_for_power_mW(const CRGB* ledbuffer, uint16_t numLeds, uint8_t target_brightness, uint32_t max_power_mW);
  54. /// calculate_max_brightness_for_power_mW tells you the highest brightness
  55. /// level you can use and still stay under the specified power budget for
  56. /// a given set of leds. It takes a pointer to an array of CRGB objects, a
  57. /// count, a 'target brightness' which is the brightness you'd ideally like
  58. /// to use, and the max power in volts and milliamps. The result from this
  59. /// function will be no higher than the target_brightess you supply, but may be lower.
  60. uint8_t calculate_max_brightness_for_power_vmA(const CRGB* ledbuffer, uint16_t numLeds, uint8_t target_brightness, uint32_t max_power_V, uint32_t max_power_mA);
  61. /// calculate_max_brightness_for_power_mW tells you the highest brightness
  62. /// level you can use and still stay under the specified power budget. It
  63. /// takes a 'target brightness' which is the brightness you'd ideally like
  64. /// to use. The result from this function will be no higher than the
  65. /// target_brightess you supply, but may be lower.
  66. uint8_t calculate_max_brightness_for_power_mW( uint8_t target_brightness, uint32_t max_power_mW);
  67. FASTLED_NAMESPACE_END
  68. ///@}
  69. // POWER_MGT_H
  70. #endif