@@ -2136,6 +2136,20 @@ static void trade_block_free(TradeBlock* trade) {
2136
2136
free (trade );
2137
2137
}
2138
2138
2139
+ /* The MALVEKE board has an esp32 which is set to TX on the flipper's default
2140
+ * UART pins. If this pin shows signs of something connected, assume a MALVEKE
2141
+ * board is being used.
2142
+ */
2143
+ static bool detect_malveke (void ) {
2144
+ bool rc ;
2145
+
2146
+ furi_hal_gpio_init (& gpio_usart_rx , GpioModeInput , GpioPullDown , GpioSpeedVeryHigh );
2147
+ rc = furi_hal_gpio_read (& gpio_usart_rx );
2148
+ furi_hal_gpio_init_simple (& gpio_usart_rx , GpioModeAnalog );
2149
+
2150
+ return rc ;
2151
+ }
2152
+
2139
2153
PokemonFap * pokemon_alloc () {
2140
2154
PokemonFap * pokemon_fap = (PokemonFap * )malloc (sizeof (PokemonFap ));
2141
2155
@@ -2157,6 +2171,11 @@ PokemonFap* pokemon_alloc() {
2157
2171
// Set up defaults
2158
2172
pokemon_fap -> curr_pokemon = 0 ;
2159
2173
pokemon_fap -> curr_stats = 0 ;
2174
+ pokemon_fap -> malveke_detected = detect_malveke ();
2175
+ memcpy (
2176
+ & pokemon_fap -> pins ,
2177
+ & common_pinouts [pokemon_fap -> malveke_detected ],
2178
+ sizeof (struct gblink_pins ));
2160
2179
2161
2180
// Set up trade party struct
2162
2181
pokemon_fap -> trade_block = trade_block_alloc ();
@@ -2189,6 +2208,7 @@ PokemonFap* pokemon_alloc() {
2189
2208
pokemon_fap -> trade = trade_alloc (
2190
2209
pokemon_fap -> trade_block ,
2191
2210
pokemon_fap -> pokemon_table ,
2211
+ & pokemon_fap -> pins ,
2192
2212
pokemon_fap -> view_dispatcher ,
2193
2213
AppViewTrade );
2194
2214
0 commit comments