rgb blink (#223)

This commit is contained in:
DrZlo13 2020-11-07 11:42:00 +03:00 committed by GitHub
parent 76e3fd3060
commit f4d4604a03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,20 +1,44 @@
#include "flipper.h" #include "flipper.h"
#include "flipper_v2.h" #include "flipper_v2.h"
void rgb_set(bool r, bool g, bool b, GpioPin* led_r, GpioPin* led_g, GpioPin* led_b) {
gpio_write(led_r, !r);
gpio_write(led_g, !g);
gpio_write(led_b, !b);
}
void application_blink(void* p) { void application_blink(void* p) {
// create pin // create pin
GpioPin led = led_gpio[0]; GpioPin led_r = led_gpio[0];
GpioPin led_g = led_gpio[1];
GpioPin led_b = led_gpio[2];
// TODO open record // TODO open record
GpioPin* led_record = &led; GpioPin* led_r_record = &led_r;
GpioPin* led_g_record = &led_g;
GpioPin* led_b_record = &led_b;
// configure pin // configure pin
gpio_init(led_record, GpioModeOutputOpenDrain); gpio_init(led_r_record, GpioModeOutputOpenDrain);
gpio_init(led_g_record, GpioModeOutputOpenDrain);
gpio_init(led_b_record, GpioModeOutputOpenDrain);
while(1) { while(1) {
gpio_write(led_record, true); rgb_set(1, 0, 0, led_r_record, led_g_record, led_b_record);
delay(500); delay(500);
gpio_write(led_record, false); rgb_set(0, 1, 0, led_r_record, led_g_record, led_b_record);
delay(500);
rgb_set(1, 1, 0, led_r_record, led_g_record, led_b_record);
delay(500);
rgb_set(0, 0, 1, led_r_record, led_g_record, led_b_record);
delay(500);
rgb_set(1, 0, 1, led_r_record, led_g_record, led_b_record);
delay(500);
rgb_set(0, 1, 1, led_r_record, led_g_record, led_b_record);
delay(500);
rgb_set(1, 1, 1, led_r_record, led_g_record, led_b_record);
delay(500);
rgb_set(0, 0, 0, led_r_record, led_g_record, led_b_record);
delay(500); delay(500);
} }
} }