From 7c03ce179c197f6e22147114c9f8007e9408ed17 Mon Sep 17 00:00:00 2001 From: aanper Date: Sun, 18 Oct 2020 05:43:09 +0300 Subject: [PATCH] add cc1101 to build/menu --- applications/app-loader/app-loader.c | 2 + applications/applications.mk | 1 + .../cc1101-workaround/cc1101-workaround.cpp | 37 ++++++++++--------- applications/startup.h | 8 ---- core/flipper_v2.h | 10 +++++ 5 files changed, 32 insertions(+), 26 deletions(-) diff --git a/applications/app-loader/app-loader.c b/applications/app-loader/app-loader.c index 81a9d84c..0ebfcb37 100644 --- a/applications/app-loader/app-loader.c +++ b/applications/app-loader/app-loader.c @@ -49,11 +49,13 @@ void handle_menu(void* _ctx) { void application_blink(void* p); void application_uart_write(void* p); void application_input_dump(void* p); +void cc1101_workaround(void* p); const FlipperStartupApp FLIPPER_APPS[] = { {.app = application_blink, .name = "blink", .libs = {0}}, {.app = application_uart_write, .name = "uart write", .libs = {0}}, {.app = application_input_dump, .name = "input dump", .libs = {1, FURI_LIB{"input_task"}}}, + {.app = cc1101_workaround, .name = "cc1101 workaround", .libs = {1, FURI_LIB{"gui_task"}}}, }; void app_loader(void* p) { diff --git a/applications/applications.mk b/applications/applications.mk index 34c8e36e..911cccc8 100644 --- a/applications/applications.mk +++ b/applications/applications.mk @@ -21,6 +21,7 @@ C_SOURCES += $(wildcard $(APP_DIR)/app-loader/*.c) APP_EXAMPLE_BLINK = 1 APP_EXAMPLE_UART_WRITE = 1 APP_EXAMPLE_INPUT_DUMP = 1 +APP_CC1101 = 1 endif APP_TEST ?= 0 diff --git a/applications/cc1101-workaround/cc1101-workaround.cpp b/applications/cc1101-workaround/cc1101-workaround.cpp index e9b7c4fb..1e8158cc 100644 --- a/applications/cc1101-workaround/cc1101-workaround.cpp +++ b/applications/cc1101-workaround/cc1101-workaround.cpp @@ -1,6 +1,4 @@ #include "flipper.h" -#include "u8g2.h" -#include #include "cc1101-workaround/cc1101.h" @@ -189,14 +187,25 @@ void jamming(CC1101* cc1101, uint8_t band, uint16_t channel, uint16_t miniSec) { cc1101->SpiStrobe(CC1101_SIDLE); } -extern "C" void cc1101_workaround(void* p) { - FuriRecordSubscriber* fb_record = - furi_open_deprecated("u8g2_fb", false, false, NULL, NULL, NULL); +void render_callback(CanvasApi* canvas, void* _ctx) { + canvas->clear(canvas); + canvas->set_color(canvas, ColorBlack); + canvas->set_font(canvas, FontPrimary); + canvas->draw_str(canvas, 2, 12, "cc1101 workaround"); +} - if(fb_record == NULL) { - printf("[cc1101] cannot create fb record\n"); +extern "C" void cc1101_workaround(void* p) { + Widget* widget = widget_alloc(); + + widget_draw_callback_set(widget, render_callback, NULL); + + // Open GUI and register widget + GuiApi* gui = furi_open("gui"); + if(gui == NULL) { + printf("gui is not available\n"); furiac_exit(NULL); } + gui->add_widget(gui, state.widget, WidgetLayerFullscreen); printf("[cc1101] creating device\n"); @@ -207,9 +216,10 @@ extern "C" void cc1101_workaround(void* p) { uint8_t address = cc1101.Init(); if(address > 0) { - printf("CC1101 init done: %d\n", address); + printf("[cc1101] init done: %d\n", address); } else { - printf("CC1101 init fail\n"); + printf("[cc1101] init fail\n"); + furiac_exit(NULL); } // RX filter bandwidth 58.035714(0xFD) 100k(0xCD) 200k(0x8D) @@ -222,15 +232,6 @@ extern "C" void cc1101_workaround(void* p) { cc1101.SpiWriteReg(CC1101_MDMCFG0, 0xF8); while(1) { - u8g2_t* fb = (u8g2_t*)furi_take(fb_record); - if(fb != NULL) { - u8g2_SetFont(fb, u8g2_font_6x10_mf); - u8g2_SetDrawColor(fb, 1); - u8g2_SetFontMode(fb, 1); - u8g2_DrawStr(fb, 2, 12, "cc1101 workaround"); - } - furi_commit(fb_record); - /* for(uint8_t i = 0; i <= NUM_OF_SUB_BANDS; i++) { highRSSI[i] = MIN_DBM; diff --git a/applications/startup.h b/applications/startup.h index d9c0e438..ff8000a0 100644 --- a/applications/startup.h +++ b/applications/startup.h @@ -20,7 +20,6 @@ void input_task(void* p); void menu_task(void* p); void coreglitch_demo_0(void* p); -void cc1101_workaround(void* p); void u8g2_qrcode(void* p); void fatfs_list(void* p); @@ -69,11 +68,4 @@ const FlipperStartupApp FLIPPER_STARTUP[] = { #ifdef APP_EXAMPLE_DISPLAY {.app = u8g2_example, .name = "u8g2_example", .libs = {1, FURI_LIB{"display_u8g2"}}}, #endif - -#ifdef APP_CC1101 - {.app = cc1101_workaround, - .name = "cc1101_workaround", - .libs = {2, FURI_LIB{"display_u8g2", "input_task"}}}, -#endif - }; diff --git a/core/flipper_v2.h b/core/flipper_v2.h index 6d3fa47f..ca362468 100644 --- a/core/flipper_v2.h +++ b/core/flipper_v2.h @@ -2,6 +2,10 @@ #include "flipper.h" +#ifdef __cplusplus +extern "C" { +#endif + #include "api-basic/furi.h" //#include "api-basic/flapp.h" #include "cmsis_os2.h" @@ -9,3 +13,9 @@ #include "api-basic/pubsub.h" #include "api-basic/memmgr.h" + +#include "gui/gui.h" + +#ifdef __cplusplus +} +#endif \ No newline at end of file