22
22
#include <one_wire/maxim_crc.h>
23
23
#include <one_wire/one_wire_host.h>
24
24
25
- #include <furi_hal_power .h>
25
+ #include <power/power_service/power .h>
26
26
27
27
#define UPDATE_PERIOD_MS 1000UL
28
28
#define TEXT_STORE_SIZE 64U
@@ -76,6 +76,7 @@ typedef struct {
76
76
FuriThread * reader_thread ;
77
77
FuriMessageQueue * event_queue ;
78
78
OneWireHost * onewire ;
79
+ Power * power ;
79
80
float temp_celsius ;
80
81
bool has_device ;
81
82
} ExampleThermoContext ;
@@ -273,7 +274,7 @@ static void example_thermo_input_callback(InputEvent* event, void* ctx) {
273
274
/* Starts the reader thread and handles the input */
274
275
static void example_thermo_run (ExampleThermoContext * context ) {
275
276
/* Enable power on external pins */
276
- furi_hal_power_enable_otg ( );
277
+ power_switch_otg ( context -> power , true );
277
278
278
279
/* Configure the hardware in host mode */
279
280
onewire_host_start (context -> onewire );
@@ -309,7 +310,7 @@ static void example_thermo_run(ExampleThermoContext* context) {
309
310
onewire_host_stop (context -> onewire );
310
311
311
312
/* Disable power on external pins */
312
- furi_hal_power_disable_otg ( );
313
+ power_switch_otg ( context -> power , false );
313
314
}
314
315
315
316
/******************** Initialisation & startup *****************************/
@@ -334,6 +335,8 @@ static ExampleThermoContext* example_thermo_context_alloc(void) {
334
335
335
336
context -> onewire = onewire_host_alloc (& THERMO_GPIO_PIN );
336
337
338
+ context -> power = furi_record_open (RECORD_POWER );
339
+
337
340
return context ;
338
341
}
339
342
@@ -348,6 +351,7 @@ static void example_thermo_context_free(ExampleThermoContext* context) {
348
351
view_port_free (context -> view_port );
349
352
350
353
furi_record_close (RECORD_GUI );
354
+ furi_record_close (RECORD_POWER );
351
355
}
352
356
353
357
/* The application's entry point. Execution starts from here. */
0 commit comments