| 89 | } |
| 90 | |
| 91 | bool UnPhoneFeatures::initNavButtons() { |
| 92 | if (!initGpioExpander()) { |
| 93 | LOGGER.error("GPIO expander init failed"); |
| 94 | return false; |
| 95 | } |
| 96 | |
| 97 | interruptQueue = xQueueCreate(4, sizeof(int)); |
| 98 | |
| 99 | buttonHandlingThread.setName("unphone_buttons"); |
| 100 | buttonHandlingThread.setPriority(tt::Thread::Priority::High); |
| 101 | buttonHandlingThread.setStackSize(3072); |
| 102 | buttonHandlingThread.setMainFunction( |
| 103 | [this] { |
| 104 | return buttonHandlingThreadMain(&this->buttonHandlingThreadInterruptRequest); |
| 105 | } |
| 106 | ); |
| 107 | buttonHandlingThread.start(); |
| 108 | |
| 109 | uint64_t pin_mask = |
| 110 | BIT64(pin::BUTTON1) | |
| 111 | BIT64(pin::BUTTON2) | |
| 112 | BIT64(pin::BUTTON3); |
| 113 | |
| 114 | gpio_config_t config = { |
| 115 | .pin_bit_mask = pin_mask, |
| 116 | .mode = GPIO_MODE_INPUT, |
| 117 | .pull_up_en = GPIO_PULLUP_ENABLE, |
| 118 | .pull_down_en = GPIO_PULLDOWN_DISABLE, |
| 119 | /** |
| 120 | * We have to listen to the button release (= positive signal). |
| 121 | * If we listen to button press, the buttons might create more than 1 signal |
| 122 | * when they are continuously pressed. |
| 123 | */ |
| 124 | .intr_type = GPIO_INTR_POSEDGE, |
| 125 | }; |
| 126 | |
| 127 | if (gpio_config(&config) != ESP_OK) { |
| 128 | LOGGER.error("Nav button pin init failed"); |
| 129 | return false; |
| 130 | } |
| 131 | |
| 132 | if ( |
| 133 | gpio_install_isr_service(0) != ESP_OK || |
| 134 | gpio_isr_handler_add(pin::BUTTON1, navButtonInterruptHandler, reinterpret_cast<void*>(pin::BUTTON1)) != ESP_OK || |
| 135 | gpio_isr_handler_add(pin::BUTTON2, navButtonInterruptHandler, reinterpret_cast<void*>(pin::BUTTON2)) != ESP_OK || |
| 136 | gpio_isr_handler_add(pin::BUTTON3, navButtonInterruptHandler, reinterpret_cast<void*>(pin::BUTTON3)) != ESP_OK |
| 137 | ) { |
| 138 | LOGGER.error("Nav buttons ISR init failed"); |
| 139 | return false; |
| 140 | } |
| 141 | |
| 142 | return true; |
| 143 | } |
| 144 | |
| 145 | bool UnPhoneFeatures::initOutputPins() { |
| 146 | uint64_t output_pin_mask = |
nothing calls this directly
no test coverage detected