mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-10 15:04:19 +00:00
[FL-1819][FL-1848] About: hw, fw, boot version screens. Misc corrections of the About screens. (#719)
* About: hw, fw, boot version screens * About: fix comment * FuriHal: proper ARR in OS tick timer * GpioTester: all pins on/off option * Irda: fix release build * Format sources Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
parent
0ff677b174
commit
1448b9cf66
12 changed files with 300 additions and 36 deletions
|
@ -1,45 +1,225 @@
|
|||
#include <furi.h>
|
||||
#include <dialogs/dialogs.h>
|
||||
#include <gui/gui.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
#include <gui/modules/empty_screen.h>
|
||||
#include <m-string.h>
|
||||
#include <furi-hal-version.h>
|
||||
|
||||
typedef DialogMessageButton (*AboutDialogScreen)(DialogsApp* dialogs, DialogMessage* message);
|
||||
|
||||
static DialogMessageButton product_screen(DialogsApp* dialogs, DialogMessage* message) {
|
||||
DialogMessageButton result;
|
||||
|
||||
const char* screen_header = "Product: Flipper Zero\n"
|
||||
"Model: FZ.1\n";
|
||||
const char* screen_text = "FCC ID: 2A2V6-FZ\n"
|
||||
"IC ID: 27624-FZ";
|
||||
|
||||
dialog_message_set_header(message, screen_header, 0, 0, AlignLeft, AlignTop);
|
||||
dialog_message_set_text(message, screen_text, 0, 26, AlignLeft, AlignTop);
|
||||
result = dialog_message_show(dialogs, message);
|
||||
dialog_message_set_header(message, NULL, 0, 0, AlignLeft, AlignTop);
|
||||
dialog_message_set_text(message, NULL, 0, 0, AlignLeft, AlignTop);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static DialogMessageButton address_screen(DialogsApp* dialogs, DialogMessage* message) {
|
||||
DialogMessageButton result;
|
||||
|
||||
const char* screen_text = "Flipper Devices Inc\n"
|
||||
"Suite B #551, 2803\n"
|
||||
"Philadelphia Pike, Claymont\n"
|
||||
"DE, USA 19703\n";
|
||||
|
||||
dialog_message_set_text(message, screen_text, 0, 0, AlignLeft, AlignTop);
|
||||
result = dialog_message_show(dialogs, message);
|
||||
dialog_message_set_text(message, NULL, 0, 0, AlignLeft, AlignTop);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static DialogMessageButton compliance_screen(DialogsApp* dialogs, DialogMessage* message) {
|
||||
DialogMessageButton result;
|
||||
|
||||
const char* screen_text = "For all compliance\n"
|
||||
"certificates please visit\n"
|
||||
"www.flipp.dev/compliance";
|
||||
|
||||
dialog_message_set_text(message, screen_text, 0, 0, AlignLeft, AlignTop);
|
||||
result = dialog_message_show(dialogs, message);
|
||||
dialog_message_set_text(message, NULL, 0, 0, AlignLeft, AlignTop);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static DialogMessageButton icon1_screen(DialogsApp* dialogs, DialogMessage* message) {
|
||||
DialogMessageButton result;
|
||||
|
||||
dialog_message_set_icon(message, &I_Certification1_103x23, 12, 12);
|
||||
result = dialog_message_show(dialogs, message);
|
||||
dialog_message_set_icon(message, NULL, 0, 0);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static DialogMessageButton icon2_screen(DialogsApp* dialogs, DialogMessage* message) {
|
||||
DialogMessageButton result;
|
||||
|
||||
dialog_message_set_icon(message, &I_Certification2_119x30, 4, 9);
|
||||
result = dialog_message_show(dialogs, message);
|
||||
dialog_message_set_icon(message, NULL, 0, 0);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static DialogMessageButton hw_version_screen(DialogsApp* dialogs, DialogMessage* message) {
|
||||
DialogMessageButton result;
|
||||
string_t buffer;
|
||||
string_init(buffer);
|
||||
const char* my_name = furi_hal_version_get_name_ptr();
|
||||
|
||||
string_cat_printf(
|
||||
buffer,
|
||||
"%d.F%dB%dC%d %s\n",
|
||||
furi_hal_version_get_hw_version(),
|
||||
furi_hal_version_get_hw_target(),
|
||||
furi_hal_version_get_hw_body(),
|
||||
furi_hal_version_get_hw_connect(),
|
||||
my_name ? my_name : "Unknown");
|
||||
|
||||
dialog_message_set_header(message, "HW Version info:", 0, 0, AlignLeft, AlignTop);
|
||||
dialog_message_set_text(message, string_get_cstr(buffer), 0, 13, AlignLeft, AlignTop);
|
||||
result = dialog_message_show(dialogs, message);
|
||||
dialog_message_set_text(message, NULL, 0, 0, AlignLeft, AlignTop);
|
||||
dialog_message_set_header(message, NULL, 0, 0, AlignLeft, AlignTop);
|
||||
string_clear(buffer);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static DialogMessageButton fw_version_screen(DialogsApp* dialogs, DialogMessage* message) {
|
||||
DialogMessageButton result;
|
||||
string_t buffer;
|
||||
string_init(buffer);
|
||||
const Version* ver = furi_hal_version_get_firmware_version();
|
||||
|
||||
if(!ver) {
|
||||
string_cat_printf(buffer, "No info\n");
|
||||
} else {
|
||||
string_cat_printf(
|
||||
buffer,
|
||||
"%s [%s]\n%s [%s]\n[%s] %s",
|
||||
version_get_version(ver),
|
||||
version_get_builddate(ver),
|
||||
version_get_githash(ver),
|
||||
version_get_gitbranchnum(ver),
|
||||
version_get_target(ver),
|
||||
version_get_gitbranch(ver));
|
||||
}
|
||||
|
||||
dialog_message_set_header(message, "FW Version info:", 0, 0, AlignLeft, AlignTop);
|
||||
dialog_message_set_text(message, string_get_cstr(buffer), 0, 13, AlignLeft, AlignTop);
|
||||
result = dialog_message_show(dialogs, message);
|
||||
dialog_message_set_text(message, NULL, 0, 0, AlignLeft, AlignTop);
|
||||
dialog_message_set_header(message, NULL, 0, 0, AlignLeft, AlignTop);
|
||||
string_clear(buffer);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static DialogMessageButton boot_version_screen(DialogsApp* dialogs, DialogMessage* message) {
|
||||
DialogMessageButton result;
|
||||
string_t buffer;
|
||||
string_init(buffer);
|
||||
const Version* ver = furi_hal_version_get_boot_version();
|
||||
|
||||
if(!ver) {
|
||||
string_cat_printf(buffer, "No info\n");
|
||||
} else {
|
||||
string_cat_printf(
|
||||
buffer,
|
||||
"%s [%s]\n%s [%s]\n[%s] %s",
|
||||
version_get_version(ver),
|
||||
version_get_builddate(ver),
|
||||
version_get_githash(ver),
|
||||
version_get_gitbranchnum(ver),
|
||||
version_get_target(ver),
|
||||
version_get_gitbranch(ver));
|
||||
}
|
||||
|
||||
dialog_message_set_header(message, "Boot Version info:", 0, 0, AlignLeft, AlignTop);
|
||||
dialog_message_set_text(message, string_get_cstr(buffer), 0, 13, AlignLeft, AlignTop);
|
||||
result = dialog_message_show(dialogs, message);
|
||||
dialog_message_set_text(message, NULL, 0, 0, AlignLeft, AlignTop);
|
||||
dialog_message_set_header(message, NULL, 0, 0, AlignLeft, AlignTop);
|
||||
string_clear(buffer);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const AboutDialogScreen about_screens[] = {
|
||||
product_screen,
|
||||
compliance_screen,
|
||||
address_screen,
|
||||
icon1_screen,
|
||||
icon2_screen,
|
||||
hw_version_screen,
|
||||
fw_version_screen,
|
||||
boot_version_screen};
|
||||
|
||||
const size_t about_screens_count = sizeof(about_screens) / sizeof(AboutDialogScreen);
|
||||
|
||||
int32_t about_settings_app(void* p) {
|
||||
const char* first_screen_text = "Product: Flipper Zero\n"
|
||||
"Model: FZ.1\n"
|
||||
"FCC ID: 2A2V6-FZIC\n"
|
||||
"ID: 27624-FZ";
|
||||
|
||||
const char* second_screen_text = "Flipper Devices Inc\n"
|
||||
"Suite B #551, 2803\n"
|
||||
"Philadelphia Pike, Claymont\n"
|
||||
"DE, USA 19703\n";
|
||||
|
||||
const char* third_screen_text = "For all compliance\n"
|
||||
"certificates please visit\n"
|
||||
"www.flipp.dev/compliance";
|
||||
|
||||
DialogsApp* dialogs = furi_record_open("dialogs");
|
||||
DialogMessage* message = dialog_message_alloc();
|
||||
|
||||
do {
|
||||
dialog_message_set_buttons(message, NULL, NULL, "Next");
|
||||
Gui* gui = furi_record_open("gui");
|
||||
ViewDispatcher* view_dispatcher = view_dispatcher_alloc();
|
||||
EmptyScreen* empty_screen = empty_screen_alloc();
|
||||
const uint32_t empty_screen_index = 0;
|
||||
|
||||
dialog_message_set_text(message, first_screen_text, 0, 0, AlignLeft, AlignTop);
|
||||
if(dialog_message_show(dialogs, message) != DialogMessageButtonRight) break;
|
||||
size_t screen_index = 0;
|
||||
DialogMessageButton screen_result;
|
||||
|
||||
dialog_message_set_text(message, second_screen_text, 0, 0, AlignLeft, AlignTop);
|
||||
if(dialog_message_show(dialogs, message) != DialogMessageButtonRight) break;
|
||||
// draw empty screen to prevent menu flickering
|
||||
view_dispatcher_add_view(
|
||||
view_dispatcher, empty_screen_index, empty_screen_get_view(empty_screen));
|
||||
view_dispatcher_attach_to_gui(view_dispatcher, gui, ViewDispatcherTypeFullscreen);
|
||||
view_dispatcher_switch_to_view(view_dispatcher, empty_screen_index);
|
||||
|
||||
dialog_message_set_text(message, third_screen_text, 0, 0, AlignLeft, AlignTop);
|
||||
if(dialog_message_show(dialogs, message) != DialogMessageButtonRight) break;
|
||||
while(1) {
|
||||
if(screen_index >= about_screens_count - 1) {
|
||||
dialog_message_set_buttons(message, "Back", NULL, NULL);
|
||||
} else {
|
||||
dialog_message_set_buttons(message, "Back", NULL, "Next");
|
||||
}
|
||||
|
||||
dialog_message_set_text(message, NULL, 0, 0, AlignLeft, AlignTop);
|
||||
screen_result = about_screens[screen_index](dialogs, message);
|
||||
|
||||
dialog_message_set_icon(message, &I_Certification_128x64, 0, 0);
|
||||
dialog_message_set_buttons(message, NULL, NULL, NULL);
|
||||
dialog_message_show(dialogs, message);
|
||||
} while(false);
|
||||
if(screen_result == DialogMessageButtonLeft) {
|
||||
if(screen_index <= 0) {
|
||||
break;
|
||||
} else {
|
||||
screen_index--;
|
||||
}
|
||||
} else if(screen_result == DialogMessageButtonRight) {
|
||||
if(screen_index < about_screens_count) {
|
||||
screen_index++;
|
||||
}
|
||||
} else if(screen_result == DialogMessageButtonBack) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
dialog_message_free(message);
|
||||
furi_record_close("dialogs");
|
||||
|
||||
view_dispatcher_remove_view(view_dispatcher, empty_screen_index);
|
||||
view_dispatcher_free(view_dispatcher);
|
||||
empty_screen_free(empty_screen);
|
||||
furi_record_close("gui");
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -18,6 +18,7 @@ static const GpioItem GPIO_PINS[] = {
|
|||
{"1.7: PC3", &gpio_ext_pc3},
|
||||
{"2.7: PC1", &gpio_ext_pc1},
|
||||
{"2.8: PC0", &gpio_ext_pc0},
|
||||
{"*.*: ALL", NULL},
|
||||
};
|
||||
|
||||
static const size_t GPIO_PINS_COUNT = sizeof(GPIO_PINS) / sizeof(GPIO_PINS[0]);
|
||||
|
@ -49,8 +50,20 @@ static void gpio_test_input_callback(InputEvent* input_event, void* ctx) {
|
|||
|
||||
static void gpio_test_configure_pins(GpioMode mode) {
|
||||
for(size_t i = 0; i < GPIO_PINS_COUNT; i++) {
|
||||
if(!GPIO_PINS[i].pin) continue;
|
||||
hal_gpio_write(GPIO_PINS[i].pin, false);
|
||||
hal_gpio_init(GPIO_PINS[i].pin, mode, GpioPullNo, GpioSpeedLow);
|
||||
hal_gpio_init(GPIO_PINS[i].pin, mode, GpioPullNo, GpioSpeedVeryHigh);
|
||||
}
|
||||
}
|
||||
|
||||
static void gpio_test_set_pin(uint8_t index, bool level) {
|
||||
if(GPIO_PINS[index].pin) {
|
||||
hal_gpio_write(GPIO_PINS[index].pin, level);
|
||||
} else {
|
||||
for(size_t i = 0; i < GPIO_PINS_COUNT; i++) {
|
||||
if(!GPIO_PINS[i].pin) continue;
|
||||
hal_gpio_write(GPIO_PINS[i].pin, level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,10 +130,10 @@ int32_t gpio_test_app(void* p) {
|
|||
} else {
|
||||
if(event.key == InputKeyOk) {
|
||||
if(event.type == InputTypePress) {
|
||||
hal_gpio_write(GPIO_PINS[gpio_test->gpio_index].pin, true);
|
||||
gpio_test_set_pin(gpio_test->gpio_index, true);
|
||||
notification_message(gpio_test->notification, &sequence_set_green_255);
|
||||
} else if(event.type == InputTypeRelease) {
|
||||
hal_gpio_write(GPIO_PINS[gpio_test->gpio_index].pin, false);
|
||||
gpio_test_set_pin(gpio_test->gpio_index, false);
|
||||
notification_message(gpio_test->notification, &sequence_reset_green);
|
||||
}
|
||||
}
|
||||
|
|
34
applications/gui/modules/empty_screen.c
Normal file
34
applications/gui/modules/empty_screen.c
Normal file
|
@ -0,0 +1,34 @@
|
|||
#include "empty_screen.h"
|
||||
#include <furi.h>
|
||||
|
||||
struct EmptyScreen {
|
||||
View* view;
|
||||
};
|
||||
|
||||
static void empty_screen_view_draw_callback(Canvas* canvas, void* _model) {
|
||||
canvas_clear(canvas);
|
||||
}
|
||||
|
||||
static bool empty_screen_view_input_callback(InputEvent* event, void* context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
EmptyScreen* empty_screen_alloc() {
|
||||
EmptyScreen* empty_screen = furi_alloc(sizeof(EmptyScreen));
|
||||
empty_screen->view = view_alloc();
|
||||
view_set_context(empty_screen->view, empty_screen);
|
||||
view_set_draw_callback(empty_screen->view, empty_screen_view_draw_callback);
|
||||
view_set_input_callback(empty_screen->view, empty_screen_view_input_callback);
|
||||
return empty_screen;
|
||||
}
|
||||
|
||||
void empty_screen_free(EmptyScreen* empty_screen) {
|
||||
furi_assert(empty_screen);
|
||||
view_free(empty_screen->view);
|
||||
free(empty_screen);
|
||||
}
|
||||
|
||||
View* empty_screen_get_view(EmptyScreen* empty_screen) {
|
||||
furi_assert(empty_screen);
|
||||
return empty_screen->view;
|
||||
}
|
29
applications/gui/modules/empty_screen.h
Normal file
29
applications/gui/modules/empty_screen.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
#pragma once
|
||||
#include <gui/view.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Empty screen anonymous structure */
|
||||
typedef struct EmptyScreen EmptyScreen;
|
||||
|
||||
/* Allocate and initialize empty screen
|
||||
* This empty screen used to ask simple questions like Yes/
|
||||
*/
|
||||
EmptyScreen* empty_screen_alloc();
|
||||
|
||||
/* Deinitialize and free empty screen
|
||||
* @param empty_screen - Empty screen instance
|
||||
*/
|
||||
void empty_screen_free(EmptyScreen* empty_screen);
|
||||
|
||||
/* Get empty screen view
|
||||
* @param empty_screen - Empty screen instance
|
||||
* @return View instance that can be used for embedding
|
||||
*/
|
||||
View* empty_screen_get_view(EmptyScreen* empty_screen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
File diff suppressed because one or more lines are too long
|
@ -1,7 +1,8 @@
|
|||
#pragma once
|
||||
#include <gui/icon.h>
|
||||
|
||||
extern const Icon I_Certification_128x64;
|
||||
extern const Icon I_Certification1_103x23;
|
||||
extern const Icon I_Certification2_119x30;
|
||||
extern const Icon A_WatchingTV_128x64;
|
||||
extern const Icon A_Wink_128x64;
|
||||
extern const Icon I_125_10px;
|
||||
|
|
BIN
assets/icons/About/Certification1_103x23.png
Normal file
BIN
assets/icons/About/Certification1_103x23.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
BIN
assets/icons/About/Certification2_119x30.png
Normal file
BIN
assets/icons/About/Certification2_119x30.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.9 KiB |
|
@ -20,6 +20,7 @@ static inline void furi_hal_os_timer_init() {
|
|||
}
|
||||
|
||||
static inline void furi_hal_os_timer_continuous(uint32_t count) {
|
||||
count--;
|
||||
// Enable timer
|
||||
LL_LPTIM_Enable(FURI_HAL_OS_TIMER);
|
||||
while(!LL_LPTIM_IsEnabled(FURI_HAL_OS_TIMER));
|
||||
|
@ -33,6 +34,7 @@ static inline void furi_hal_os_timer_continuous(uint32_t count) {
|
|||
}
|
||||
|
||||
static inline void furi_hal_os_timer_single(uint32_t count) {
|
||||
count--;
|
||||
// Enable timer
|
||||
LL_LPTIM_Enable(FURI_HAL_OS_TIMER);
|
||||
while(!LL_LPTIM_IsEnabled(FURI_HAL_OS_TIMER));
|
||||
|
|
|
@ -20,6 +20,7 @@ static inline void furi_hal_os_timer_init() {
|
|||
}
|
||||
|
||||
static inline void furi_hal_os_timer_continuous(uint32_t count) {
|
||||
count--;
|
||||
// Enable timer
|
||||
LL_LPTIM_Enable(FURI_HAL_OS_TIMER);
|
||||
while(!LL_LPTIM_IsEnabled(FURI_HAL_OS_TIMER));
|
||||
|
@ -33,6 +34,7 @@ static inline void furi_hal_os_timer_continuous(uint32_t count) {
|
|||
}
|
||||
|
||||
static inline void furi_hal_os_timer_single(uint32_t count) {
|
||||
count--;
|
||||
// Enable timer
|
||||
LL_LPTIM_Enable(FURI_HAL_OS_TIMER);
|
||||
while(!LL_LPTIM_IsEnabled(FURI_HAL_OS_TIMER));
|
||||
|
|
|
@ -36,8 +36,7 @@ void irda_encoder_sirc_reset(void* encoder_ptr, const IrdaMessage* message) {
|
|||
IrdaStatus irda_encoder_sirc_encode_repeat(IrdaCommonEncoder* encoder, uint32_t* duration, bool* level) {
|
||||
furi_assert(encoder);
|
||||
|
||||
uint32_t timings_in_message = 1 + 2 + encoder->bits_to_encode * 2 - 1;
|
||||
furi_assert(encoder->timings_encoded == timings_in_message);
|
||||
furi_assert(encoder->timings_encoded == (1 + 2 + encoder->bits_to_encode * 2 - 1));
|
||||
|
||||
furi_assert(encoder->timings_sum < IRDA_SIRC_REPEAT_PERIOD);
|
||||
*duration = IRDA_SIRC_REPEAT_PERIOD - encoder->timings_sum;
|
||||
|
|
Loading…
Reference in a new issue