pwnagotchi.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. #pragma once
  2. #include <furi.h>
  3. #include <gui/canvas_i.h>
  4. #include <stdbool.h>
  5. #include "constants.h"
  6. #define PWNAGOTCHI_HEIGHT FLIPPER_SCREEN_HEIGHT
  7. #define PWNAGOTCHI_WIDTH FLIPPER_SCREEN_WIDTH
  8. #define PWNAGOTCHI_FACE_I 25
  9. #define PWNAGOTCHI_FACE_J 0
  10. #define PWNAGOTCHI_NAME_I 17
  11. #define PWNAGOTCHI_NAME_J 0
  12. #define PWNAGOTCHI_CHANNEL_I 7
  13. #define PWNAGOTCHI_CHANNEL_J 0
  14. #define PWNAGOTCHI_APS_I 7
  15. #define PWNAGOTCHI_APS_J 25
  16. #define PWNAGOTCHI_UPTIME_I 7
  17. #define PWNAGOTCHI_UPTIME_J 77
  18. #define PWNAGOTCHI_LINE1_START_I 8
  19. #define PWNAGOTCHI_LINE1_START_J 0
  20. #define PWNAGOTCHI_LINE1_END_I 8
  21. #define PWNAGOTCHI_LINE1_END_J 127
  22. #define PWNAGOTCHI_LINE2_START_I 54
  23. #define PWNAGOTCHI_LINE2_START_J 0
  24. #define PWNAGOTCHI_LINE2_END_I 54
  25. #define PWNAGOTCHI_LINE2_END_J 127
  26. #define PWNAGOTCHI_HANDSHAKES_I 63
  27. #define PWNAGOTCHI_HANDSHAKES_J 0
  28. #define PWNAGOTCHI_FRIEND_FACE_I 52
  29. #define PWNAGOTCHI_FRIEND_FACE_J 3
  30. #define PWNAGOTCHI_FRIEND_STAT_I 52
  31. #define PWNAGOTCHI_FRIEND_STAT_J 24
  32. #define PWNAGOTCHI_MODE_AI_I 63
  33. #define PWNAGOTCHI_MODE_AI_J 121
  34. #define PWNAGOTCHI_MODE_AUTO_I 63
  35. #define PWNAGOTCHI_MODE_AUTO_J 105
  36. #define PWNAGOTCHI_MODE_MANU_I 63
  37. #define PWNAGOTCHI_MODE_MANU_J 103
  38. #define PWNAGOTCHI_MESSAGE_I 17
  39. #define PWNAGOTCHI_MESSAGE_J 60
  40. #define PWNAGOTCHI_FONT FontSecondary
  41. /**
  42. * Enum to represent possible faces to save them locally rather than transmit every time
  43. */
  44. enum PwnagotchiFace {
  45. NoFace = 0,
  46. DefaultFace,
  47. Look_r,
  48. Look_l,
  49. Look_r_happy,
  50. Look_l_happy,
  51. Sleep,
  52. Sleep2,
  53. Awake,
  54. Bored,
  55. Intense,
  56. Cool,
  57. Happy,
  58. Grateful,
  59. Excited,
  60. Motivated,
  61. Demotivated,
  62. Smart,
  63. Lonely,
  64. Sad,
  65. Angry,
  66. Friend,
  67. Broken,
  68. Debug,
  69. Upload,
  70. Upload1,
  71. Upload2
  72. };
  73. /** All of the faces as macros so we don't have to worry about size */
  74. #define LOOK_R "( ⚆_⚆)"
  75. #define LOOK_L "(☉_☉ )"
  76. #define LOOK_R_HAPPY "( ◕‿◕)"
  77. #define LOOK_L_HAPPY "(◕‿◕ )"
  78. #define SLEEP "(⇀‿‿↼)"
  79. #define SLEEP2 "(≖‿‿≖)"
  80. #define AWAKE "(◕‿‿◕)"
  81. #define BORED "(-__-)"
  82. #define INTENSE "(°▃▃°)"
  83. #define COOL "(⌐■_■)"
  84. #define HAPPY "(•‿‿•)"
  85. #define GRATEFUL "(^‿‿^)"
  86. #define EXCITED "(ᵔ◡◡ᵔ)"
  87. #define MOTIVATED "(☼‿‿☼)"
  88. #define DEMOTIVATED "(≖__≖)"
  89. #define SMART "(✜‿‿✜)"
  90. #define LONELY "(ب__ب)"
  91. #define SAD "(╥☁╥ )"
  92. #define ANGRY "(-_-')"
  93. #define FRIEND "(♥‿‿♥)"
  94. #define BROKEN "(☓‿‿☓)"
  95. #define DEBUG "(#__#)"
  96. #define UPLOAD "(1__0)"
  97. #define UPLOAD1 "(1__1)"
  98. #define UPLOAD2 "(0__1)"
  99. /**
  100. * Enum for current mode of the pwnagotchi
  101. */
  102. enum PwnagotchiMode { PwnMode_Auto, PwnMode_Ai, PwnMode_Manual };
  103. typedef struct {
  104. /// Current face
  105. enum PwnagotchiFace face;
  106. // char* faceStr;
  107. /// CH channel display at top left
  108. char channel[PWNAGOTCHI_MAX_CHANNEL_LEN];
  109. /// AP text shown at the top
  110. char apStat[PWNAGOTCHI_MAX_APS_LEN];
  111. /// Uptime as text
  112. char uptime[PWNAGOTCHI_MAX_UPTIME_LEN];
  113. /// Hostname of the unit
  114. char hostname[PWNAGOTCHI_MAX_HOSTNAME_LEN];
  115. /// Message that is displayed
  116. char message[PWNAGOTCHI_MAX_MESSAGE_LEN];
  117. /// LAST SSID and other handshake information for the bottom
  118. char handshakes[PWNAGOTCHI_MAX_SSID_LEN];
  119. /// Current mode the pwnagotchi is in
  120. enum PwnagotchiMode mode;
  121. /// Friend face
  122. enum PwnagotchiFace friendFace;
  123. /// Name and aps of friend
  124. char friendStat[PWNAGOTCHI_MAX_FRIEND_STAT_LEN];
  125. } Pwnagotchi;
  126. /**
  127. * @brief Allocates and constructs a pwnagotchi struct
  128. *
  129. * @return Pwnagotchi* Constructed pwnagotchi pointer
  130. */
  131. Pwnagotchi* pwnagotchi_alloc();
  132. /**
  133. * @brief Destruct and free pwnagotchi
  134. *
  135. * @param pwn Pwnagotchi to destruct
  136. */
  137. void pwnagotchi_free(Pwnagotchi* pwn);
  138. /**
  139. * Draw the default display with no additional information provided
  140. *
  141. * @param pwn Pwnagotchi device to draw
  142. * @param canvas Canvas to draw on
  143. */
  144. void pwnagotchi_draw_blank(Pwnagotchi* pwn, Canvas* canvas);
  145. /**
  146. * Draw the stored pwnagotchi's face on the device
  147. *
  148. * @param pwn Pwnagotchi to draw
  149. * @param canvas Canvas to draw on
  150. */
  151. void pwnagotchi_draw_face(Pwnagotchi* pwn, Canvas* canvas);
  152. /**
  153. * Draw the name of the pwnagotchi
  154. *
  155. * @param pwn Pwnagotchi to draw
  156. * @param canvas Canvas to draw on
  157. */
  158. void pwnagotchi_draw_name(Pwnagotchi* pwn, Canvas* canvas);
  159. /**
  160. * Draw channel on pwnagotchi
  161. *
  162. * @param pwn Pwnagotchi to draw
  163. * @param canvas Canvas to draw on
  164. */
  165. void pwnagotchi_draw_channel(Pwnagotchi* pwn, Canvas* canvas);
  166. /**
  167. * Draw aps on pwnagotchi
  168. *
  169. * @param pwn Pwnagotchi to draw
  170. * @param canvas Canvas to draw on
  171. */
  172. void pwnagotchi_draw_aps(Pwnagotchi* pwn, Canvas* canvas);
  173. /**
  174. * Draw uptime on pwnagotchi
  175. *
  176. * @param pwn Pwnagotchi to draw
  177. * @param canvas Canvas to draw on
  178. */
  179. void pwnagotchi_draw_uptime(Pwnagotchi* pwn, Canvas* canvas);
  180. /**
  181. * Draw lines on pwnagotchi
  182. *
  183. * @param pwn Pwnagotchi to draw
  184. * @param canvas Canvas to draw on
  185. */
  186. void pwnagotchi_draw_lines(Pwnagotchi* pwn, Canvas* canvas);
  187. /**
  188. * Draw friend of pwnagotchi on screen
  189. *
  190. * @param pwn Pwnagotchi to draw
  191. * @param canvas Canvas to draw on
  192. */
  193. void pwnagotchi_draw_friend(Pwnagotchi* pwn, Canvas* canvas);
  194. /**
  195. * Draw current mode of pwnagotchi
  196. *
  197. * @param pwn Pwnagotchi to draw
  198. * @param canvas Canvas to draw on
  199. */
  200. void pwnagotchi_draw_mode(Pwnagotchi* pwn, Canvas* canvas);
  201. /**
  202. * Draw the number of handshakes in the PWND portion as well as the last handshake
  203. *
  204. * @param pwn Pwnagotchi to draw
  205. * @param canvas Canvas to draw on
  206. */
  207. void pwnagotchi_draw_handshakes(Pwnagotchi* pwn, Canvas* canvas);
  208. /**
  209. * Draw the message that the pwnagotchi is showing on the screen
  210. *
  211. * @param pwn Pwnagotchi to draw
  212. * @param canvas Canvas to draw on
  213. */
  214. void pwnagotchi_draw_message(Pwnagotchi* pwn, Canvas* canvas);
  215. /**
  216. * Runs all drawing functions to update the screen completely
  217. *
  218. * @param pwn Pwnagotchi to draw
  219. * @param canvas Canvas to draw on
  220. */
  221. void pwnagotchi_draw_all(Pwnagotchi* pwn, Canvas* canvas);
  222. /**
  223. * Clears the screen buffer of the pwnagotchi
  224. *
  225. * @param pwn Pwn to clear
  226. */
  227. void pwnagotchi_screen_clear(Pwnagotchi* pwn);