app_defines.h 2.7 KB

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