Skip to content

Commit 7a3a1aa

Browse files
gsurkovskotopes
andauthored
[FL-3057] Allow use of any suitable pin for 1-Wire devices (#2350)
* Add 1-wire thermometer example app stub * Working 1-wire thermometer app * Refactor app to use threads * Clean up code, add comments * Add CRC checking * Increase update period * Fix error in fbt * Revert the old update period * Use settable pin in onewire_host * Use settable pin for onewire_slave * Clear EXTI flag after callback, make private methods static in onewire_slave * Do not hardcode GPIO pin number * Remove iButton hal from furi_hal_rfid * Remove most of furi_hal_ibutton * Add some of furi_hal_ibutton back * Slightly neater code * Fix formatting * Fix PVS-studio warnings * Update CODEOWNERS * Add furi_hal_gpio_get_ext_pin_number * Create README.md * FuriHal: move furi_hal_gpio_get_ext_pin_number to resources --------- Co-authored-by: Aleksandr Kutuzov <[email protected]>
1 parent e3d473b commit 7a3a1aa

22 files changed

+590
-182
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242

4343
/applications/debug/unit_tests/ @skotopes @DrZlo13 @hedger @nminaylov @gornekich @Astrrra @gsurkov @Skorpionm
4444

45+
/applications/examples/example_thermo/ @skotopes @DrZlo13 @hedger @gsurkov
46+
4547
# Assets
4648
/assets/resources/infrared/ @skotopes @DrZlo13 @hedger @gsurkov
4749

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# 1-Wire Thermometer
2+
This example application demonstrates the use of the 1-Wire library with a DS18B20 thermometer.
3+
It also covers basic GUI, input handling, threads and localisation.
4+
5+
## Electrical connections
6+
Before launching the application, connect the sensor to Flipper's external GPIO according to the table below:
7+
| DS18B20 | Flipper |
8+
| :-----: | :-----: |
9+
| VDD | 9 |
10+
| GND | 18 |
11+
| DQ | 17 |
12+
13+
*NOTE 1*: GND is also available on pins 8 and 11.
14+
15+
*NOTE 2*: For any other pin than 17, connect an external 4.7k pull-up resistor to pin 9.
16+
17+
## Launching the application
18+
In order to launch this demo, follow the steps below:
19+
1. Make sure your Flipper has an SD card installed.
20+
2. Connect your Flipper to the computer via a USB cable.
21+
3. Run `./fbt launch_app APPSRC=example_thermo` in your terminal emulator of choice.
22+
23+
## Changing the data pin
24+
It is possible to use other GPIO pin as a 1-Wire data pin. In order to change it, set the `THERMO_GPIO_PIN` macro to any of the options listed below:
25+
26+
```c
27+
/* Possible GPIO pin choices:
28+
- gpio_ext_pc0
29+
- gpio_ext_pc1
30+
- gpio_ext_pc3
31+
- gpio_ext_pb2
32+
- gpio_ext_pb3
33+
- gpio_ext_pa4
34+
- gpio_ext_pa6
35+
- gpio_ext_pa7
36+
- ibutton_gpio
37+
*/
38+
39+
#define THERMO_GPIO_PIN (ibutton_gpio)
40+
```
41+
Do not forget about the external pull-up resistor as these pins do not have one built-in.
42+
43+
With the changes been made, recompile and launch the application again.
44+
The on-screen text should reflect it by asking to connect the thermometer to another pin.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
App(
2+
appid="example_thermo",
3+
name="Example: Thermometer",
4+
apptype=FlipperAppType.EXTERNAL,
5+
entry_point="example_thermo_main",
6+
requires=["gui"],
7+
stack_size=1 * 1024,
8+
fap_icon="example_thermo_10px.png",
9+
fap_category="Examples",
10+
)

0 commit comments

Comments
 (0)