[FL-873] Add F5 target, lp5562 driver and api-hal-light (#347)
* Add F5 target, lp5562 driver and api-hal-light. Update api-usage, switch to F5 by default. * API HAL: add i2c and hardware version api. Dolphin: show hardware version. * OTP version generator and flashing utility. * Assets script: fix code formatting * Backport F5 changes to F4 * F4: disable insomnia, prevent damage to BLE RX path * F5 HAL API Light: remove magic delay to fix magic BLE * Dolphin: HW target validation on start * invert RSSI indication in sub-1 * API HAL: rename board to body in version api * Gpio tester: detach and release viewport on exit Co-authored-by: aanper <mail@s3f.ru>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include <furi.h>
|
||||
#include <api-hal.h>
|
||||
|
||||
#define BACKLIGHT_TIME 10000
|
||||
#define BACKLIGHT_TIME 30000
|
||||
#define BACKLIGHT_FLAG_ACTIVITY 0x00000001U
|
||||
|
||||
static void event_cb(const void* value, void* ctx) {
|
||||
@@ -8,24 +9,19 @@ static void event_cb(const void* value, void* ctx) {
|
||||
}
|
||||
|
||||
int32_t backlight_control(void* p) {
|
||||
// TODO open record
|
||||
const GpioPin* backlight_record = &backlight_gpio;
|
||||
|
||||
// configure pin
|
||||
gpio_init(backlight_record, GpioModeOutputPushPull);
|
||||
gpio_write(backlight_record, true);
|
||||
|
||||
// open record
|
||||
PubSub* event_record = furi_record_open("input_events");
|
||||
subscribe_pubsub(event_record, event_cb, (void*)osThreadGetId());
|
||||
|
||||
api_hal_light_set(LightBacklight, 0xFF);
|
||||
|
||||
while(1) {
|
||||
// wait for event
|
||||
if(osThreadFlagsWait(BACKLIGHT_FLAG_ACTIVITY, osFlagsWaitAny, BACKLIGHT_TIME) ==
|
||||
BACKLIGHT_FLAG_ACTIVITY) {
|
||||
gpio_write(backlight_record, true);
|
||||
api_hal_light_set(LightBacklight, 0xFF);
|
||||
} else {
|
||||
gpio_write(backlight_record, false);
|
||||
api_hal_light_set(LightBacklight, 0x00);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "bt.h"
|
||||
|
||||
#include <furi.h>
|
||||
#include <api-hal.h>
|
||||
|
||||
#include <cli/cli.h>
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "cc1101.h"
|
||||
#include <furi.h>
|
||||
#include <api-hal.h>
|
||||
#include <gui/gui.h>
|
||||
#include <input/input.h>
|
||||
|
||||
@@ -409,12 +410,6 @@ extern "C" int32_t cc1101_workaround(void* p) {
|
||||
|
||||
printf("init ok\r\n");
|
||||
|
||||
// TODO open record
|
||||
GpioPin* led_record = (GpioPin*)&led_gpio[1];
|
||||
|
||||
// configure pin
|
||||
gpio_init(led_record, GpioModeOutputOpenDrain);
|
||||
|
||||
const int16_t RSSI_THRESHOLD = -60;
|
||||
|
||||
// setup_freq(&cc1101, &FREQ_LIST[1]);
|
||||
@@ -530,7 +525,7 @@ extern "C" int32_t cc1101_workaround(void* p) {
|
||||
// TOOD what about rssi offset
|
||||
state->last_rssi = rx_rssi(&cc1101, &FREQ_LIST[state->active_freq_idx]);
|
||||
|
||||
gpio_write(led_record, state->last_rssi < RSSI_THRESHOLD);
|
||||
api_hal_light_set(LightGreen, state->last_rssi > RSSI_THRESHOLD ? 0xFF : 0x00);
|
||||
} else if(!state->need_cc1101_conf && state->mode == ModeTx) {
|
||||
/*
|
||||
const uint8_t data = 0xA5;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include <furi.h>
|
||||
#include <api-hal.h>
|
||||
|
||||
#include "cc1101-workaround/cc1101.h"
|
||||
#include "spi.h"
|
||||
#include <math.h>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "cli.h"
|
||||
|
||||
#include <furi.h>
|
||||
#include <api-hal.h>
|
||||
|
||||
#include <m-dict.h>
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include <furi.h>
|
||||
#include <api-hal.h>
|
||||
|
||||
#include "u8g2/u8g2.h"
|
||||
|
||||
extern TIM_HandleTypeDef SPEAKER_TIM;
|
||||
|
||||
@@ -38,16 +38,16 @@ bool dolphin_view_idle_main_input(InputEvent* event, void* context) {
|
||||
with_value_mutex(
|
||||
dolphin->menu_vm, (Menu * menu) { menu_ok(menu); });
|
||||
} else if(event->key == InputKeyUp) {
|
||||
view_dispatcher_switch_to_view(dolphin->idle_view_dispatcher, DolphinViewIdleStats);
|
||||
view_dispatcher_switch_to_view(dolphin->idle_view_dispatcher, DolphinViewIdleUp);
|
||||
} else if(event->key == InputKeyDown) {
|
||||
view_dispatcher_switch_to_view(dolphin->idle_view_dispatcher, DolphinViewIdleDebug);
|
||||
view_dispatcher_switch_to_view(dolphin->idle_view_dispatcher, DolphinViewIdleDown);
|
||||
}
|
||||
}
|
||||
// All events consumed
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dolphin_view_idle_stats_input(InputEvent* event, void* context) {
|
||||
bool dolphin_view_idle_up_input(InputEvent* event, void* context) {
|
||||
furi_assert(event);
|
||||
furi_assert(context);
|
||||
Dolphin* dolphin = context;
|
||||
@@ -95,21 +95,27 @@ Dolphin* dolphin_alloc() {
|
||||
view_dispatcher_add_view(
|
||||
dolphin->idle_view_dispatcher, DolphinViewIdleMain, dolphin->idle_view_main);
|
||||
// Stats Idle View
|
||||
dolphin->idle_view_stats = view_alloc();
|
||||
view_set_context(dolphin->idle_view_stats, dolphin);
|
||||
dolphin->idle_view_up = view_alloc();
|
||||
view_set_context(dolphin->idle_view_up, dolphin);
|
||||
view_allocate_model(
|
||||
dolphin->idle_view_stats, ViewModelTypeLockFree, sizeof(DolphinViewIdleStatsModel));
|
||||
view_set_draw_callback(dolphin->idle_view_stats, dolphin_view_idle_stats_draw);
|
||||
view_set_input_callback(dolphin->idle_view_stats, dolphin_view_idle_stats_input);
|
||||
view_set_previous_callback(dolphin->idle_view_stats, dolphin_view_idle_back);
|
||||
dolphin->idle_view_up, ViewModelTypeLockFree, sizeof(DolphinViewIdleUpModel));
|
||||
view_set_draw_callback(dolphin->idle_view_up, dolphin_view_idle_up_draw);
|
||||
view_set_input_callback(dolphin->idle_view_up, dolphin_view_idle_up_input);
|
||||
view_set_previous_callback(dolphin->idle_view_up, dolphin_view_idle_back);
|
||||
view_dispatcher_add_view(
|
||||
dolphin->idle_view_dispatcher, DolphinViewIdleStats, dolphin->idle_view_stats);
|
||||
// Debug Idle View
|
||||
dolphin->idle_view_debug = view_alloc();
|
||||
view_set_draw_callback(dolphin->idle_view_debug, dolphin_view_idle_debug_draw);
|
||||
view_set_previous_callback(dolphin->idle_view_debug, dolphin_view_idle_back);
|
||||
dolphin->idle_view_dispatcher, DolphinViewIdleUp, dolphin->idle_view_up);
|
||||
// Down Idle View
|
||||
dolphin->idle_view_down = view_alloc();
|
||||
view_set_draw_callback(dolphin->idle_view_down, dolphin_view_idle_down_draw);
|
||||
view_set_previous_callback(dolphin->idle_view_down, dolphin_view_idle_back);
|
||||
view_dispatcher_add_view(
|
||||
dolphin->idle_view_dispatcher, DolphinViewIdleDebug, dolphin->idle_view_debug);
|
||||
dolphin->idle_view_dispatcher, DolphinViewIdleDown, dolphin->idle_view_down);
|
||||
// HW Mismatch
|
||||
dolphin->view_hw_mismatch = view_alloc();
|
||||
view_set_draw_callback(dolphin->view_hw_mismatch, dolphin_view_hw_mismatch_draw);
|
||||
view_set_previous_callback(dolphin->view_hw_mismatch, dolphin_view_idle_back);
|
||||
view_dispatcher_add_view(
|
||||
dolphin->idle_view_dispatcher, DolphinViewHwMismatch, dolphin->view_hw_mismatch);
|
||||
|
||||
return dolphin;
|
||||
}
|
||||
@@ -140,7 +146,7 @@ int32_t dolphin_task() {
|
||||
view_dispatcher_switch_to_view(dolphin->idle_view_dispatcher, DolphinViewFirstStart);
|
||||
}
|
||||
with_view_model(
|
||||
dolphin->idle_view_stats, (DolphinViewIdleStatsModel * model) {
|
||||
dolphin->idle_view_up, (DolphinViewIdleUpModel * model) {
|
||||
model->icounter = dolphin_state_get_icounter(dolphin->state);
|
||||
model->butthurt = dolphin_state_get_butthurt(dolphin->state);
|
||||
return true;
|
||||
@@ -148,13 +154,17 @@ int32_t dolphin_task() {
|
||||
|
||||
furi_record_create("dolphin", dolphin);
|
||||
|
||||
if(!api_hal_version_do_i_belong_here()) {
|
||||
view_dispatcher_switch_to_view(dolphin->idle_view_dispatcher, DolphinViewHwMismatch);
|
||||
}
|
||||
|
||||
DolphinEvent event;
|
||||
while(1) {
|
||||
furi_check(osMessageQueueGet(dolphin->event_queue, &event, NULL, osWaitForever) == osOK);
|
||||
if(event.type == DolphinEventTypeDeed) {
|
||||
dolphin_state_on_deed(dolphin->state, event.deed);
|
||||
with_view_model(
|
||||
dolphin->idle_view_stats, (DolphinViewIdleStatsModel * model) {
|
||||
dolphin->idle_view_up, (DolphinViewIdleUpModel * model) {
|
||||
model->icounter = dolphin_state_get_icounter(dolphin->state);
|
||||
model->butthurt = dolphin_state_get_butthurt(dolphin->state);
|
||||
return true;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "dolphin_views.h"
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
#include <api-hal.h>
|
||||
#include <gui/gui.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
#include <gui/canvas.h>
|
||||
@@ -37,8 +37,9 @@ struct Dolphin {
|
||||
ViewDispatcher* idle_view_dispatcher;
|
||||
View* idle_view_first_start;
|
||||
View* idle_view_main;
|
||||
View* idle_view_stats;
|
||||
View* idle_view_debug;
|
||||
View* idle_view_up;
|
||||
View* idle_view_down;
|
||||
View* view_hw_mismatch;
|
||||
};
|
||||
|
||||
Dolphin* dolphin_alloc();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "dolphin_state.h"
|
||||
#include <furi.h>
|
||||
#include <api-hal.h>
|
||||
|
||||
typedef struct {
|
||||
uint8_t magic;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include <gui/gui.h>
|
||||
#include <gui/elements.h>
|
||||
|
||||
#include <api-hal.h>
|
||||
|
||||
void dolphin_view_first_start_draw(Canvas* canvas, void* model) {
|
||||
DolphinViewFirstStartModel* m = model;
|
||||
canvas_clear(canvas);
|
||||
@@ -64,8 +66,8 @@ void dolphin_view_idle_main_draw(Canvas* canvas, void* model) {
|
||||
canvas_draw_str(canvas, 2, 52, "\\/: Version");
|
||||
}
|
||||
|
||||
void dolphin_view_idle_stats_draw(Canvas* canvas, void* model) {
|
||||
DolphinViewIdleStatsModel* m = model;
|
||||
void dolphin_view_idle_up_draw(Canvas* canvas, void* model) {
|
||||
DolphinViewIdleUpModel* m = model;
|
||||
canvas_clear(canvas);
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
@@ -80,7 +82,7 @@ void dolphin_view_idle_stats_draw(Canvas* canvas, void* model) {
|
||||
canvas_draw_str(canvas, 5, 40, "< > change icounter");
|
||||
}
|
||||
|
||||
void dolphin_view_idle_debug_draw(Canvas* canvas, void* model) {
|
||||
void dolphin_view_idle_down_draw(Canvas* canvas, void* model) {
|
||||
canvas_clear(canvas);
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
@@ -88,8 +90,31 @@ void dolphin_view_idle_debug_draw(Canvas* canvas, void* model) {
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
canvas_draw_str(canvas, 5, 22, TARGET " " BUILD_DATE);
|
||||
canvas_draw_str(canvas, 5, 32, GIT_BRANCH);
|
||||
canvas_draw_str(canvas, 5, 42, GIT_BRANCH_NUM);
|
||||
canvas_draw_str(canvas, 5, 52, GIT_COMMIT);
|
||||
canvas_draw_str(canvas, 5, 42, GIT_BRANCH_NUM " " GIT_COMMIT);
|
||||
|
||||
char buffer[64];
|
||||
snprintf(
|
||||
buffer,
|
||||
64,
|
||||
"HW: %d.F%dB%dC%d",
|
||||
api_hal_version_get_hw_version(),
|
||||
api_hal_version_get_hw_target(),
|
||||
api_hal_version_get_hw_body(),
|
||||
api_hal_version_get_hw_connect());
|
||||
canvas_draw_str(canvas, 5, 52, buffer);
|
||||
}
|
||||
|
||||
void dolphin_view_hw_mismatch_draw(Canvas* canvas, void* model) {
|
||||
canvas_clear(canvas);
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
canvas_draw_str(canvas, 2, 10, "!!!! HW Mismatch !!!!");
|
||||
|
||||
char buffer[64];
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
snprintf(buffer, 64, "HW target: F%d", api_hal_version_get_hw_target());
|
||||
canvas_draw_str(canvas, 5, 22, buffer);
|
||||
canvas_draw_str(canvas, 5, 32, "FW target: " TARGET);
|
||||
}
|
||||
|
||||
uint32_t dolphin_view_idle_back(void* context) {
|
||||
|
||||
@@ -10,8 +10,9 @@
|
||||
typedef enum {
|
||||
DolphinViewFirstStart,
|
||||
DolphinViewIdleMain,
|
||||
DolphinViewIdleStats,
|
||||
DolphinViewIdleDebug,
|
||||
DolphinViewIdleUp,
|
||||
DolphinViewIdleDown,
|
||||
DolphinViewHwMismatch,
|
||||
} DolphinViewIdle;
|
||||
|
||||
typedef struct {
|
||||
@@ -24,11 +25,14 @@ bool dolphin_view_first_start_input(InputEvent* event, void* context);
|
||||
typedef struct {
|
||||
uint32_t icounter;
|
||||
uint32_t butthurt;
|
||||
} DolphinViewIdleStatsModel;
|
||||
} DolphinViewIdleUpModel;
|
||||
|
||||
void dolphin_view_idle_main_draw(Canvas* canvas, void* model);
|
||||
bool dolphin_view_idle_main_input(InputEvent* event, void* context);
|
||||
void dolphin_view_idle_stats_draw(Canvas* canvas, void* model);
|
||||
bool dolphin_view_idle_stats_input(InputEvent* event, void* context);
|
||||
void dolphin_view_idle_debug_draw(Canvas* canvas, void* model);
|
||||
|
||||
void dolphin_view_idle_up_draw(Canvas* canvas, void* model);
|
||||
void dolphin_view_idle_down_draw(Canvas* canvas, void* model);
|
||||
|
||||
void dolphin_view_hw_mismatch_draw(Canvas* canvas, void* model);
|
||||
|
||||
uint32_t dolphin_view_idle_back(void* context);
|
||||
|
||||
@@ -1,44 +1,29 @@
|
||||
#include <furi.h>
|
||||
#include <api-hal.h>
|
||||
|
||||
void rgb_set(
|
||||
bool r,
|
||||
bool g,
|
||||
bool b,
|
||||
const GpioPin* led_r,
|
||||
const GpioPin* led_g,
|
||||
const GpioPin* led_b) {
|
||||
gpio_write(led_r, !r);
|
||||
gpio_write(led_g, !g);
|
||||
gpio_write(led_b, !b);
|
||||
void rgb_set(bool r, bool g, bool b) {
|
||||
api_hal_light_set(LightRed, r ? 0xFF : 0x00);
|
||||
api_hal_light_set(LightGreen, g ? 0xFF : 0x00);
|
||||
api_hal_light_set(LightBlue, b ? 0xFF : 0x00);
|
||||
}
|
||||
|
||||
int32_t application_blink(void* p) {
|
||||
// TODO open record
|
||||
const GpioPin* led_r_record = &led_gpio[0];
|
||||
const GpioPin* led_g_record = &led_gpio[1];
|
||||
const GpioPin* led_b_record = &led_gpio[2];
|
||||
|
||||
// configure pin
|
||||
gpio_init(led_r_record, GpioModeOutputOpenDrain);
|
||||
gpio_init(led_g_record, GpioModeOutputOpenDrain);
|
||||
gpio_init(led_b_record, GpioModeOutputOpenDrain);
|
||||
|
||||
while(1) {
|
||||
rgb_set(1, 0, 0, led_r_record, led_g_record, led_b_record);
|
||||
rgb_set(1, 0, 0);
|
||||
delay(500);
|
||||
rgb_set(0, 1, 0, led_r_record, led_g_record, led_b_record);
|
||||
rgb_set(0, 1, 0);
|
||||
delay(500);
|
||||
rgb_set(1, 1, 0, led_r_record, led_g_record, led_b_record);
|
||||
rgb_set(0, 0, 1);
|
||||
delay(500);
|
||||
rgb_set(0, 0, 1, led_r_record, led_g_record, led_b_record);
|
||||
rgb_set(1, 1, 0);
|
||||
delay(500);
|
||||
rgb_set(1, 0, 1, led_r_record, led_g_record, led_b_record);
|
||||
rgb_set(0, 1, 1);
|
||||
delay(500);
|
||||
rgb_set(0, 1, 1, led_r_record, led_g_record, led_b_record);
|
||||
rgb_set(1, 0, 1);
|
||||
delay(500);
|
||||
rgb_set(1, 1, 1, led_r_record, led_g_record, led_b_record);
|
||||
rgb_set(1, 1, 1);
|
||||
delay(500);
|
||||
rgb_set(0, 0, 0, led_r_record, led_g_record, led_b_record);
|
||||
rgb_set(0, 0, 0);
|
||||
delay(500);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <furi.h>
|
||||
#include <api-hal.h>
|
||||
#include <stdio.h>
|
||||
#include <input/input.h>
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <furi.h>
|
||||
#include <api-hal.h>
|
||||
#include <string.h>
|
||||
|
||||
int32_t application_uart_write(void* p) {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#include <furi.h>
|
||||
#include <api-hal.h>
|
||||
|
||||
#include <input/input.h>
|
||||
|
||||
typedef struct {
|
||||
GpioPin* led;
|
||||
GpioPin* vibro;
|
||||
} Ctx;
|
||||
|
||||
@@ -13,20 +14,18 @@ static void button_handler(const void* value, void* _ctx) {
|
||||
if(event->key != InputKeyOk) return;
|
||||
|
||||
if(event->type == InputTypePress) {
|
||||
gpio_write(ctx->led, false);
|
||||
api_hal_light_set(LightGreen, 0xFF);
|
||||
gpio_write(ctx->vibro, true);
|
||||
} else if(event->type == InputTypeRelease) {
|
||||
gpio_write(ctx->led, true);
|
||||
api_hal_light_set(LightGreen, 0x00);
|
||||
gpio_write(ctx->vibro, false);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t application_vibro(void* p) {
|
||||
Ctx ctx = {.led = (GpioPin*)&led_gpio[1], .vibro = (GpioPin*)&vibro_gpio};
|
||||
Ctx ctx = {.vibro = (GpioPin*)&vibro_gpio};
|
||||
|
||||
gpio_init(ctx.led, GpioModeOutputOpenDrain);
|
||||
gpio_init(ctx.vibro, GpioModeOutputPushPull);
|
||||
gpio_write(ctx.led, true);
|
||||
gpio_write(ctx.vibro, false);
|
||||
|
||||
// subscribe on buttons
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include <furi.h>
|
||||
#include <api-hal.h>
|
||||
|
||||
#include <gui/gui.h>
|
||||
#include <input/input.h>
|
||||
|
||||
@@ -84,8 +86,6 @@ int32_t app_gpio_test(void* p) {
|
||||
gpio_init((GpioPin*)&GPIO_PINS[i].pin, GpioModeOutputPushPull);
|
||||
}
|
||||
|
||||
gpio_init((GpioPin*)&led_gpio[1], GpioModeOutputOpenDrain);
|
||||
|
||||
AppEvent event;
|
||||
while(1) {
|
||||
osStatus_t event_status = osMessageQueueGet(event_queue, &event, NULL, osWaitForever);
|
||||
@@ -96,8 +96,13 @@ int32_t app_gpio_test(void* p) {
|
||||
if(event.value.input.type == InputTypeShort &&
|
||||
event.value.input.key == InputKeyBack) {
|
||||
printf("[gpio-tester] bye!\r\n");
|
||||
// TODO remove all view_ports create by app
|
||||
|
||||
api_hal_light_set(LightGreen, 0x00);
|
||||
|
||||
view_port_enabled_set(view_port, false);
|
||||
gui_remove_view_port(gui, view_port);
|
||||
view_port_free(view_port);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -118,10 +123,10 @@ int32_t app_gpio_test(void* p) {
|
||||
if(event.value.input.key == InputKeyOk) {
|
||||
if(event.value.input.type == InputTypePress) {
|
||||
gpio_write((GpioPin*)&GPIO_PINS[state->gpio_index].pin, true);
|
||||
gpio_write((GpioPin*)&led_gpio[1], false);
|
||||
api_hal_light_set(LightGreen, 0xFF);
|
||||
} else if(event.value.input.type == InputTypeRelease) {
|
||||
gpio_write((GpioPin*)&GPIO_PINS[state->gpio_index].pin, false);
|
||||
gpio_write((GpioPin*)&led_gpio[1], true);
|
||||
api_hal_light_set(LightGreen, 0x00);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "u8g2/u8g2.h"
|
||||
#include <furi.h>
|
||||
#include <api-hal.h>
|
||||
|
||||
#include <main.h>
|
||||
|
||||
extern SPI_HandleTypeDef SPI_D;
|
||||
|
||||
@@ -40,6 +40,7 @@ public:
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <api-hal.h>
|
||||
|
||||
void BlanksWriter::onewire_release(void) {
|
||||
gpio_write(gpio, true);
|
||||
|
||||
@@ -15,14 +15,6 @@ void AppiButton::run() {
|
||||
|
||||
switch_to_mode(0);
|
||||
|
||||
// TODO open record
|
||||
red_led_record = &led_gpio[0];
|
||||
green_led_record = &led_gpio[1];
|
||||
|
||||
// configure pin
|
||||
gpio_init(red_led_record, GpioModeOutputOpenDrain);
|
||||
gpio_init(green_led_record, GpioModeOutputOpenDrain);
|
||||
|
||||
api_hal_power_insomnia_enter();
|
||||
app_ready();
|
||||
|
||||
@@ -112,15 +104,15 @@ void AppiButton::render_cyfral_list(Canvas* canvas, AppiButtonState* state) {
|
||||
}
|
||||
|
||||
void AppiButton::blink_red() {
|
||||
gpio_write(red_led_record, 0);
|
||||
api_hal_light_set(LightRed, 0xFF);
|
||||
delay(10);
|
||||
gpio_write(red_led_record, 1);
|
||||
api_hal_light_set(LightRed, 0x00);
|
||||
}
|
||||
|
||||
void AppiButton::blink_green() {
|
||||
gpio_write(green_led_record, 0);
|
||||
api_hal_light_set(LightGreen, 0xFF);
|
||||
delay(10);
|
||||
gpio_write(green_led_record, 1);
|
||||
api_hal_light_set(LightGreen, 0x00);
|
||||
}
|
||||
|
||||
void AppiButton::increase_mode() {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <furi.h>
|
||||
#include <api-hal.h>
|
||||
#include <gui/gui.h>
|
||||
#include <input/input.h>
|
||||
|
||||
@@ -274,15 +275,6 @@ int32_t irda(void* p) {
|
||||
Gui* gui = furi_record_open("gui");
|
||||
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
|
||||
|
||||
// Red LED
|
||||
// TODO open record
|
||||
const GpioPin* red_led_record = &led_gpio[0];
|
||||
const GpioPin* green_led_record = &led_gpio[1];
|
||||
|
||||
// configure pin
|
||||
gpio_init(red_led_record, GpioModeOutputOpenDrain);
|
||||
gpio_init(green_led_record, GpioModeOutputOpenDrain);
|
||||
|
||||
// setup irda rx timer
|
||||
tim_irda_rx_init();
|
||||
|
||||
@@ -346,7 +338,7 @@ int32_t irda(void* p) {
|
||||
out.data_length = out_data_length;
|
||||
out.data = out_data;
|
||||
|
||||
gpio_write(red_led_record, event.value.rx.edge);
|
||||
api_hal_light_set(LightRed, event.value.rx.edge ? 0x00 : 0xFF);
|
||||
|
||||
bool decoded =
|
||||
process_decoder(decoder, event.value.rx.edge, &event.value.rx.lasted, 1, &out);
|
||||
@@ -378,8 +370,8 @@ int32_t irda(void* p) {
|
||||
view_port_update(view_port);
|
||||
|
||||
// blink anyway
|
||||
gpio_write(green_led_record, false);
|
||||
gpio_write(green_led_record, true);
|
||||
api_hal_light_set(LightGreen, 0xFF);
|
||||
api_hal_light_set(LightGreen, 0x00);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include <furi.h>
|
||||
#include <api-hal.h>
|
||||
|
||||
#include "irda_nec.h"
|
||||
#include "irda_protocols.h"
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include <furi.h>
|
||||
#include <api-hal.h>
|
||||
|
||||
#include "irda_samsung.h"
|
||||
#include "irda_protocols.h"
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <furi.h>
|
||||
#include <api-hal.h>
|
||||
|
||||
void prepare_data(uint32_t ID, uint32_t VENDOR, uint8_t* data) {
|
||||
uint8_t value[10];
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <furi.h>
|
||||
#include <api-hal.h>
|
||||
#include <gui/gui.h>
|
||||
|
||||
typedef enum { EventTypeTick, EventTypeKey, EventTypeRx } EventType;
|
||||
@@ -213,9 +214,6 @@ int32_t lf_rfid_workaround(void* p) {
|
||||
bool center = false;
|
||||
size_t symbol_cnt = 0;
|
||||
|
||||
GpioPin* led_record = (GpioPin*)&led_gpio[1];
|
||||
gpio_init(led_record, GpioModeOutputOpenDrain);
|
||||
|
||||
uint8_t buf[64];
|
||||
for(size_t i = 0; i < 64; i++) {
|
||||
buf[i] = 0;
|
||||
@@ -272,9 +270,9 @@ int32_t lf_rfid_workaround(void* p) {
|
||||
extract_data(&buf[9], &state->customer_id, &state->em_data);
|
||||
printf("customer: %02d, data: %010lu\n", state->customer_id, state->em_data);
|
||||
release_mutex(&state_mutex, state);
|
||||
gpio_write(led_record, false);
|
||||
api_hal_light_set(LightGreen, 0xFF);
|
||||
osDelay(100);
|
||||
gpio_write(led_record, true);
|
||||
api_hal_light_set(LightGreen, 0x00);
|
||||
}
|
||||
|
||||
symbol_cnt = 0;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include <furi.h>
|
||||
#include <api-hal.h>
|
||||
|
||||
#include <gui/gui.h>
|
||||
#include <input/input.h>
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "power_views.h"
|
||||
|
||||
#include <furi.h>
|
||||
#include <api-hal.h>
|
||||
|
||||
#include <menu/menu.h>
|
||||
#include <menu/menu_item.h>
|
||||
|
||||
@@ -43,8 +43,6 @@ public:
|
||||
class SdTest : public AppTemplate<SdTestState, SdTestEvent> {
|
||||
public:
|
||||
// vars
|
||||
GpioPin* red_led_record;
|
||||
GpioPin* green_led_record;
|
||||
const uint32_t benchmark_data_size = 4096;
|
||||
uint8_t* benchmark_data;
|
||||
FS_Api* fs_api;
|
||||
@@ -90,18 +88,6 @@ public:
|
||||
|
||||
// start app
|
||||
void SdTest::run() {
|
||||
// create pin
|
||||
GpioPin red_led = led_gpio[0];
|
||||
GpioPin green_led = led_gpio[1];
|
||||
|
||||
// TODO open record
|
||||
red_led_record = &red_led;
|
||||
green_led_record = &green_led;
|
||||
|
||||
// configure pin
|
||||
gpio_init(red_led_record, GpioModeOutputOpenDrain);
|
||||
gpio_init(green_led_record, GpioModeOutputOpenDrain);
|
||||
|
||||
app_ready();
|
||||
|
||||
fs_api = static_cast<FS_Api*>(furi_record_open("sdcard"));
|
||||
@@ -844,21 +830,21 @@ bool SdTest::ask(InputKey input_button_cancel, InputKey input_button_ok) {
|
||||
|
||||
// blink red led
|
||||
void SdTest::blink_red() {
|
||||
gpio_write(red_led_record, 0);
|
||||
api_hal_light_set(LightRed, 0xFF);
|
||||
delay(50);
|
||||
gpio_write(red_led_record, 1);
|
||||
api_hal_light_set(LightRed, 0x00);
|
||||
}
|
||||
|
||||
// light up red led
|
||||
void SdTest::set_red() {
|
||||
gpio_write(red_led_record, 0);
|
||||
api_hal_light_set(LightRed, 0x00);
|
||||
}
|
||||
|
||||
// blink green led
|
||||
void SdTest::blink_green() {
|
||||
gpio_write(green_led_record, 0);
|
||||
api_hal_light_set(LightGreen, 0xFF);
|
||||
delay(50);
|
||||
gpio_write(green_led_record, 1);
|
||||
api_hal_light_set(LightGreen, 0x00);
|
||||
}
|
||||
|
||||
// set text, but with infinite loop
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <furi.h>
|
||||
#include <api-hal.h>
|
||||
#include <gui/gui.h>
|
||||
#include <input/input.h>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user