led blink example

* led blink example

* restore tests

* Update FURI_and_examples.md
This commit is contained in:
coreglitch
2020-08-26 07:56:33 +06:00
committed by GitHub
parent 2e023ffcda
commit bee159f435
14 changed files with 211 additions and 101 deletions

View File

@@ -1,81 +0,0 @@
#include <stdio.h>
#include "flipper.h"
#include "debug.h"
void furi_widget(void* param);
void furi_test_app(void* param);
void furi_next_test_app(void* param);
/*
widget simply print ping message
*/
void furi_widget(void* param) {
FILE* debug_uart = get_debug();
fprintf(debug_uart, "start furi widget: %s\n", (char*)param);
while(1) {
fprintf(debug_uart, "furi widget\n");
delay(10);
}
}
/*
it simply start, then start child widget, wait about 1 sec (with ping evey 200 ms),
kill the widget, continue with 500 ms ping.
*/
void furi_test_app(void* param) {
uint8_t cnt = 0;
while(1) {
fprintf(debug_uart, "furi test app %d\n", cnt);
delay(10);
if(cnt == 2) {
fprintf(debug_uart, "go to next app\n");
furiac_switch(furi_next_test_app, "next_test", NULL);
fprintf(debug_uart, "unsuccessful switch\n");
while(1) {
delay(1000);
}
}
cnt++;
}
}
void furi_next_test_app(void* param) {
FILE* debug_uart = get_debug();
fprintf(debug_uart, "start next test app\n");
delay(10);
fprintf(debug_uart, "exit next app\n");
furiac_exit(NULL);
while(1) {
// this code must not be called
fprintf(debug_uart, "next app: something went wrong\n");
delay(10);
}
}
/*
FILE* debug_uart = get_debug();
fprintf(debug_uart, "hello Flipper!\n");
GpioPin red_led = {LED_RED_GPIO_Port, LED_RED_Pin};
app_gpio_init(red_led, GpioModeOutput);
while(1) {
delay(100);
app_gpio_write(red_led, true);
delay(100);
app_gpio_write(red_led, false);
}
*/

View File

@@ -1,2 +0,0 @@
void furi_test_app(void*);

View File

@@ -0,0 +1,16 @@
#include "flipper.h"
void application_blink(void* p) {
// create pin
GpioPin led = {.pin = GPIO_PIN_8, .port = GPIOA};
// configure pin
pinMode(led, GpioModeOutput);
while(1) {
digitalWrite(led, HIGH);
delay(500);
digitalWrite(led, LOW);
delay(500);
}
}

View File

@@ -1,13 +1,24 @@
#pragma once
#include "furi.h"
#include "tests/test_index.h"
typedef struct {
FlipperApplication app;
const char* name;
} FlipperStartupApp;
#ifdef TEST
void flipper_test_app(void* p);
#endif
void application_blink(void* p);
const FlipperStartupApp FLIPPER_STARTUP[] = {
{.app = flipper_test_app, .name = "test app"}
#ifdef TEST
{.app = flipper_test_app, .name = "test app"},
#endif
#ifdef EXAMPLE_BLINK
{.app = application_blink, .name = "blink"},
#endif
};

View File

@@ -121,6 +121,8 @@ bool furi_ac_switch_exit(FILE* debug_uart) {
delay(10); // wait while task do its work
seq.sequence[seq.count] = '\0';
if(strcmp(seq.sequence, "ABA/") != 0) {
fprintf(debug_uart, "wrong sequence: %s\n", seq.sequence);
return false;

View File

@@ -1,2 +0,0 @@
void flipper_test_app(void* p);