app_defines.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #ifndef APP_DEFINES_H
  2. #define APP_DEFINES_H
  3. #define GPIO_PIN_COUNT 8
  4. #define ANIMATE_FRAME_TIME_MS 133
  5. #define FRAME_TIME 66.666666
  6. typedef void (*DrawView)(Canvas* canvas, void* ctx);
  7. typedef void (*HandleInput)(InputEvent* event, void* ctx);
  8. typedef enum {
  9. MAIN_VIEW,
  10. CONFIG_MENU_VIEW
  11. } enum_view;
  12. typedef enum {
  13. GPIO_MODE_INPUT,
  14. GPIO_MODE_INPUT_PULLUP,
  15. GPIO_MODE_OUTPUT,
  16. GPIO_MODE_UNSET
  17. } GpioUserMode;
  18. typedef enum {
  19. GPIO_VALUE_TRUE,
  20. GPIO_VALUE_FALSE,
  21. GPIO_VALUE_INPUT,
  22. GPIO_VALUE_NONE
  23. } GpioUserValue;
  24. typedef enum {
  25. CONFIG_MENU_MODE,
  26. CONFIG_MENU_VALUE,
  27. CONFIG_MENU_INPUT
  28. } ConfigMenuOptions;
  29. typedef struct {
  30. GpioUserMode mode;
  31. GpioUserValue value;
  32. int gp_idx_input;
  33. bool changed;
  34. GpioUserMode prev_mode;
  35. } GPIOPinUserSelection;
  36. typedef struct {
  37. int selected;
  38. enum_view view;
  39. int wiggle_frame;
  40. size_t prev_frame_time;
  41. size_t elapsed_time;
  42. double result;
  43. double freq_var;
  44. double elapsed_var;
  45. ConfigMenuOptions config_menu_selected;
  46. } ViewerState;
  47. // 5V A7 A6 A4 B3 B2 C3 GND SET
  48. //
  49. //
  50. // 3V SWC GND SIO TX RX C1 C0 1W GND
  51. typedef enum {
  52. PIN_5V = 0,
  53. PIN_A7,
  54. PIN_A6,
  55. PIN_A4,
  56. PIN_B3,
  57. PIN_B2,
  58. PIN_C3,
  59. GEARIC,
  60. PIN_3V,
  61. PIN_SWC,
  62. PIN_SIO,
  63. PIN_TX,
  64. PIN_RX,
  65. PIN_C1,
  66. PIN_C0,
  67. PIN_1W,
  68. PIN_GND_08,
  69. PIN_GND_11,
  70. PIN_GND_18,
  71. NONE
  72. } enum_view_element;
  73. typedef struct {
  74. enum_view_element element;
  75. enum_view_element opposite;
  76. bool selectable;
  77. bool editable;
  78. bool top_row;
  79. bool pull_out;
  80. int gp_idx;
  81. uint8_t x_pos;
  82. uint8_t y_pos;
  83. const char* name;
  84. Icon* icon;
  85. Icon* selected_icon;
  86. } ViewElement;
  87. typedef struct {
  88. uint8_t element_idx;
  89. const GpioPin* pin;
  90. GpioMode mode;
  91. GpioPull pull;
  92. GpioSpeed speed;
  93. double value;
  94. const char* name;
  95. bool unset;
  96. bool found;
  97. bool input;
  98. GPIOPinUserSelection user;
  99. } GPIOPin;
  100. // GPIO enums from firmware/targets/f7/furi_hal/furi_hal_gpio.h
  101. // /**
  102. // * Gpio modes
  103. // */
  104. // typedef enum {
  105. // *GpioModeInput,
  106. // *GpioModeOutputPushPull,
  107. // GpioModeOutputOpenDrain,
  108. // GpioModeAltFunctionPushPull,
  109. // GpioModeAltFunctionOpenDrain,
  110. // *GpioModeAnalog,
  111. // GpioModeInterruptRise,
  112. // GpioModeInterruptFall,
  113. // GpioModeInterruptRiseFall,
  114. // GpioModeEventRise,
  115. // GpioModeEventFall,
  116. // GpioModeEventRiseFall,
  117. // } GpioMode;
  118. // /**
  119. // * Gpio pull modes
  120. // */
  121. // typedef enum {
  122. // GpioPullNo,
  123. // GpioPullUp,
  124. // GpioPullDown,
  125. // } GpioPull;
  126. #endif