seg_led_manager.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /** @file
  2. * @brief actions seg led manager APIs.
  3. */
  4. /*
  5. * Copyright (c) 2017 Intel Corporation
  6. *
  7. * SPDX-License-Identifier: Apache-2.0
  8. */
  9. #ifndef __SEG_LED_MANAGER_H
  10. #define __SEG_LED_MANAGER_H
  11. /**
  12. * @brief actions seg led manager APIs
  13. * @defgroup actions seg led manager APIs
  14. * @{
  15. */
  16. #include <stdio.h>
  17. #include <zephyr/types.h>
  18. #include <stdbool.h>
  19. #include <toolchain.h>
  20. #ifdef CONFIG_SEG_LED_DISPLAY
  21. #include <display/seg_led_display.h>
  22. #endif
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. enum seg_led_display_item {
  27. SLED_PLAY = 0,
  28. SLED_PAUSE,
  29. SLED_USB,
  30. SLED_SD,
  31. SLED_COL,
  32. SLED_AUX,
  33. SLED_FM,
  34. SLED_P1,
  35. SLED_NUMBER1,
  36. SLED_NUMBER2,
  37. SLED_NUMBER3,
  38. SLED_NUMBER4,
  39. };
  40. #define FLASH_ITEM(x) (1 << x)
  41. #define FLASH_2ITEM(x, y) ((1 << x) | (1 << y))
  42. #define FLASH_3ITEM(x, y, z) ((1 << x) | (1 << y) | (1 << z))
  43. #define FLASH_ALL_NUMER (0xf << SLED_NUMBER1)
  44. #define FLASH_FOREVER 0xFF
  45. enum seg_led_clear_mode {
  46. SLED_CLEAR_ALL = 0,
  47. SLED_CLEAR_NUM
  48. };
  49. typedef int (*seg_led_flash_callback)(void);
  50. typedef int (*seg_led_timeout_callback)(void);
  51. /**
  52. * @brief seg led display a number or letter
  53. *
  54. * This routine seg led display number or letter in num_add,0`9,A`Z
  55. *
  56. * @param num_addr addr of seg led
  57. * @param c number or letter
  58. * @param display display or not
  59. *
  60. * @return 0 if invoked succsess.
  61. * @return others if invoked failed.
  62. */
  63. int seg_led_display_number(uint8_t num_addr, uint8_t c, bool display);
  64. /**
  65. * @brief seg led display string
  66. *
  67. * This routine seg led display string,start from start_pos
  68. *
  69. * @param start_pos start position
  70. * @param str string
  71. * @param display display or not
  72. *
  73. * @return 0 if invoked succsess.
  74. * @return others if invoked failed.
  75. */
  76. int seg_led_display_string(uint8_t start_pos, const uint8_t *str, bool display);
  77. /**
  78. * @brief seg led display icon
  79. *
  80. * @param icon_idx addr of icon
  81. * @param display display or not
  82. *
  83. * @return 0 if invoked succsess.
  84. * @return others if invoked failed.
  85. */
  86. int seg_led_display_icon(uint8_t icon_idx, bool display);
  87. /**
  88. * @brief set seg led icon or numbers flashing
  89. *
  90. * @param flash_map flashing object of icon or numbers
  91. * @param flash_period flash period
  92. * @param flash_cnt flash count
  93. * @param cb callback when flash cnt overflow occur.
  94. *
  95. * @return 0 if invoked succsess.
  96. * @return others if invoked failed.
  97. */
  98. int seg_led_display_set_flash(uint16_t flash_map, uint16_t flash_period, uint16_t flash_cnt, seg_led_flash_callback cb);
  99. /**
  100. * @brief set timeout event lock
  101. *
  102. * @return 0 if invoked succsess.
  103. * @return others if invoked failed.
  104. */
  105. int seg_led_manager_set_timeout_event_start(void);
  106. /**
  107. * @brief set timeout event
  108. * @param timeout of current state
  109. * @param cb callback when timeout overflow occur.
  110. * @return 0 if invoked succsess.
  111. * @return others if invoked failed.
  112. */
  113. int seg_led_manager_set_timeout_event(int timeout, seg_led_flash_callback cb);
  114. /**
  115. * @brief save current seg led state
  116. *
  117. * @return 0 if invoked succsess.
  118. * @return others if invoked failed.
  119. */
  120. int seg_led_manager_store(void);
  121. /**
  122. * @brief restore seg led state from history
  123. *
  124. * @return 0 if invoked succsess.
  125. * @return others if invoked failed.
  126. */
  127. int seg_led_manager_restore(void);
  128. /**
  129. * @brief timeout restore seg led state from history
  130. * @param timeout of current state
  131. * @return 0 if invoked succsess.
  132. * @return others if invoked failed.
  133. */
  134. int seg_led_manager_set_timeout_restore(int timeout);
  135. /**
  136. * @brief set seg led mamager to wakeup mode,all seg led will restore history state before sleep
  137. *
  138. * @return 0 if invoked succsess.
  139. * @return others if invoked failed.
  140. */
  141. int seg_led_manager_wake_up(void);
  142. /**
  143. * @brief set seg led mamager to sleep mode, when sleep mode all led will off
  144. *
  145. * @return 0 if invoked succsess.
  146. * @return others if invoked failed.
  147. */
  148. int seg_led_manager_sleep(void);
  149. /**
  150. * @brief clear seg led state mode, when clear mode all or 4 numbers seg led will off
  151. * @param clr_mode clear all or 4 numbers
  152. *
  153. * @return 0 if invoked succsess.
  154. * @return others if invoked failed.
  155. */
  156. int seg_led_manager_clear_screen(uint8_t clr_mode);
  157. /**
  158. * @brief seg led manager init funcion
  159. *
  160. * This routine calls init seg led manager ,called by main
  161. *
  162. * @return 0 if invoked succsess.
  163. * @return others if invoked failed.
  164. */
  165. int seg_led_manager_init(void);
  166. /**
  167. * @brief seg led manager deinit funcion
  168. *
  169. * This routine calls deinit seg led manager ,called by main
  170. *
  171. * @return 0 if invoked succsess.
  172. * @return others if invoked failed.
  173. */
  174. int seg_led_manager_deinit(void);
  175. #ifdef __cplusplus
  176. }
  177. #endif
  178. /**
  179. * @}
  180. */
  181. #endif /* __SEG_LED_MANAGER_H */