Update per bunni feedback

This commit is contained in:
Derek Jamison 2023-07-01 08:45:06 -05:00
parent a0eff12f17
commit d536cf1101
2 changed files with 11 additions and 11 deletions

View File

@ -1,10 +1,10 @@
# GPIO_BLINK # GPIO_BLINK
This is the classic "Hello World" of GPIO, where we blink an LED. You will need an LED (any color is fine) and a resistor (220 ohms - 1K should be fine). Connect the long side of the LED into pin A7. Connect the short size of the LED to one side of the resistor (doesn't matter which side). Connect the other side of the resistor to any of the pin GND. This is the classic "Hello World" of GPIO, where we blink an LED. You will need an LED (any color is fine) and a resistor (220 ohms - 1 kiliohm should be fine). Connect the long side of the LED into pin A7. Connect the short size of the LED to one side of the resistor (doesn't matter which side). Connect the other side of the resistor to any of the pin GND.
Run the application and the LED should start blinking. Hold the back button to exit. Run the application and the LED should start blinking. Hold the back button to exit.
## How it works ## How it works
- For list of pins see \firmware\targets\f18\furi_hal\furi_hal_resources.c - For list of pins see [/firmware/targets/f7/furi_hal/furi_hal_resources.c](https://github.com/flipperdevices/flipperzero-firmware/blob/dev/firmware/targets/f7/furi_hal/furi_hal_resources.c) in your firmware repo.
- We define a variable for our LED... - We define a variable for our LED...
```c ```c
@ -12,28 +12,28 @@ Run the application and the LED should start blinking. Hold the back button to
``` ```
- We initialize the pin for output. - We initialize the pin for output.
- GpioModeOutputPushPull means true = +3.3V, false = 0V. - ``GpioModeOutputPushPull`` means true = 3.3 volts, false = 0 volts.
- GpioModeOutputOpenDrain means true = floating, false = 0V. - ``GpioModeOutputOpenDrain`` means true = floating, false = 0 volts.
```c ```c
furi_hal_gpio_init_simple(pin_led, GpioModeOutputOpenDrain); furi_hal_gpio_init_simple(pin_led, GpioModeOutputOpenDrain);
``` ```
- We turn the LED on (3v3 volts on the pin). - We turn the LED on (3.3 volts on the pin).
```c ```c
furi_hal_gpio_write(pin_led, true); furi_hal_gpio_write(pin_led, true);
``` ```
- We wait 500ms. - We wait 500 ms.
```c ```c
furi_delay_ms(500); furi_delay_ms(500);
``` ```
- We turn the LED off (GND volts on the pin). - We turn the LED off (0 volts on the pin).
```c ```c
furi_hal_gpio_write(pin_led, false); furi_hal_gpio_write(pin_led, false);
``` ```
- We wait 500ms. - We wait 500 ms.
```c ```c
furi_delay_ms(500); furi_delay_ms(500);
``` ```

View File

@ -1,7 +1,7 @@
#include <furi.h> #include <furi.h>
#include <gui/gui.h> #include <gui/gui.h>
// For list of pins see \firmware\targets\f18\furi_hal\furi_hal_resources.c // For list of pins see https://github.com/flipperdevices/flipperzero-firmware/blob/dev/firmware/targets/f7/furi_hal/furi_hal_resources.c
const GpioPin* const pin_led = &gpio_ext_pa7; const GpioPin* const pin_led = &gpio_ext_pa7;
const GpioPin* const pin_back = &gpio_button_back; const GpioPin* const pin_back = &gpio_button_back;
@ -26,8 +26,8 @@ int gpio_blink_app(void* p) {
gui_add_view_port(gui, view_port, GuiLayerFullscreen); gui_add_view_port(gui, view_port, GuiLayerFullscreen);
// Initialize the LED pin as output. // Initialize the LED pin as output.
// GpioModeOutputPushPull means true = +3.3V, false = 0V. // GpioModeOutputPushPull means true = 3.3 volts, false = 0 volts.
// GpioModeOutputOpenDrain means true = floating, false = 0V. // GpioModeOutputOpenDrain means true = floating, false = 0 volts.
furi_hal_gpio_init_simple(pin_led, GpioModeOutputOpenDrain); furi_hal_gpio_init_simple(pin_led, GpioModeOutputOpenDrain);
do { do {
furi_hal_gpio_write(pin_led, true); furi_hal_gpio_write(pin_led, true);