user_light.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef __USER_LIGHT_H__
  2. #define __USER_LIGHT_H__
  3. /*pwm.h: function and macro definition of PWM API , driver level */
  4. /*user_light.h: user interface for light API, user level*/
  5. /*user_light_adj: API for color changing and lighting effects, user level*/
  6. #include "pwm.h"
  7. /* NOTICE !!! ---this is for 512KB spi flash.*/
  8. /* You can change to other sector if you use other size spi flash. */
  9. /* Refer to the documentation about OTA support and flash mapping*/
  10. #define PRIV_PARAM_START_SEC 0x3C
  11. #define PRIV_PARAM_SAVE 0
  12. /*Define the channel number of PWM*/
  13. /*In this demo, we can set 3 for 3 PWM channels: RED, GREEN, BLUE*/
  14. /*Or , we can choose 5 channels : RED,GREEN,BLUE,COLD-WHITE,WARM-WHITE*/
  15. #define PWM_CHANNEL 5 // 5:5channel ; 3:3channel
  16. #define LIGHT_RED 0
  17. #define LIGHT_GREEN 1
  18. #define LIGHT_BLUE 2
  19. #define LIGHT_COLD_WHITE 3
  20. #define LIGHT_WARM_WHITE 4
  21. /*Definition of GPIO PIN params, for GPIO initialization*/
  22. #define PWM_0_OUT_IO_MUX PERIPHS_IO_MUX_MTDI_U
  23. #define PWM_0_OUT_IO_NUM 12
  24. #define PWM_0_OUT_IO_FUNC FUNC_GPIO12
  25. #define PWM_1_OUT_IO_MUX PERIPHS_IO_MUX_MTDO_U
  26. #define PWM_1_OUT_IO_NUM 15
  27. #define PWM_1_OUT_IO_FUNC FUNC_GPIO15
  28. #define PWM_2_OUT_IO_MUX PERIPHS_IO_MUX_MTCK_U
  29. #define PWM_2_OUT_IO_NUM 13
  30. #define PWM_2_OUT_IO_FUNC FUNC_GPIO13
  31. #define PWM_3_OUT_IO_MUX PERIPHS_IO_MUX_MTMS_U
  32. #define PWM_3_OUT_IO_NUM 14
  33. #define PWM_3_OUT_IO_FUNC FUNC_GPIO14
  34. #define PWM_4_OUT_IO_MUX PERIPHS_IO_MUX_GPIO5_U
  35. #define PWM_4_OUT_IO_NUM 5
  36. #define PWM_4_OUT_IO_FUNC FUNC_GPIO5
  37. struct light_saved_param {
  38. uint32 pwm_period;
  39. uint32 pwm_duty[PWM_CHANNEL];
  40. };
  41. void user_light_init(void);
  42. uint32 user_light_get_duty(uint8 channel);
  43. void user_light_set_duty(uint32 duty, uint8 channel);
  44. uint32 user_light_get_period(void);
  45. void user_light_set_period(uint32 period);
  46. #endif