unleashed-firmware/applications/irda/view/irda_app_brut_view.c
SG 274c12fc56
[FL-2274] Inventing streams and moving FFF to them (#981)
* Streams: string stream
* String stream: updated insert/delete api
* Streams: generic stream interface and string stream implementation
* Streams: helpers for insert and delete_and_insert
* FFF: now compatible with streams
* MinUnit: introduced tests with arguments
* FFF: stream access violation
* Streams: copy data between streams
* Streams: file stream
* FFF: documentation
* FFStream: documentation
* FFF: alloc as file
* MinUnit: support for nested tests
* Streams: changed delete_and_insert, now it returns success flag. Added ability dump stream inner parameters and data to cout.
* FFF: simplified file open function
* Streams: unit tests
* FFF: tests
* Streams: declare cache_size constant as define, to allow variable modified arrays
* FFF: lib moved to a separate folder
* iButton: new FFF
* RFID: new FFF
* Animations: new FFF
* IR: new FFF
* NFC: new FFF
* Flipper file format: delete lib
* U2F: new FFF
* Subghz: new FFF and streams
* Streams: read line
* Streams: split
* FuriCore: implement memset with extra asserts
* FuriCore: implement extra heap asserts without inventing memset
* Scene manager: protected access to the scene id stack with a size check
* NFC worker: dirty fix for issue where hal_nfc was busy on app start
* Furi: update allocator to erase memory on allocation. Replace furi_alloc with malloc.
* FuriCore: cleanup memmgr code.
* Furi HAL: furi_hal_init is split into critical and non-critical parts. The critical part is currently clock and console.
* Memmgr: added ability to track allocations and deallocations through console.
* FFStream: some speedup
* Streams, FF: minor fixes
* Tests: restore
* File stream: a slightly more thread-safe version of file_stream_delete_and_insert

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2022-02-18 22:53:46 +03:00

84 lines
2.8 KiB
C

#include "furi_hal_resources.h"
#include "assets_icons.h"
#include "gui/canvas.h"
#include "gui/view.h"
#include "input/input.h"
#include <gui/elements.h>
#include <furi.h>
#include "irda_app_brut_view.h"
#include "gui/modules/button_panel.h"
#include <stdint.h>
struct IrdaAppPopupBrut {
uint16_t progress;
uint16_t progress_max;
char percents_string_storage[8];
};
bool popup_brut_increase_progress(IrdaAppPopupBrut* popup_brut) {
furi_assert(popup_brut);
if(popup_brut->progress < popup_brut->progress_max)
++popup_brut->progress;
else
furi_assert(0);
return popup_brut->progress < popup_brut->progress_max;
}
void popup_brut_draw_callback(Canvas* canvas, void* context) {
furi_assert(canvas);
furi_assert(context);
IrdaAppPopupBrut* popup_brut = (IrdaAppPopupBrut*)context;
uint8_t x = 0;
uint8_t width = 64;
uint8_t x_max = x + width - 1;
uint8_t y = 36;
uint8_t height = 59;
uint8_t y_max = y + height - 1;
canvas_invert_color(canvas);
canvas_draw_rbox(canvas, x + 1, y + 1, width - 2, height - 2, 3);
canvas_invert_color(canvas);
canvas_draw_rframe(canvas, x, y, width, height, 3);
canvas_draw_rframe(canvas, x + 1, y + 1, width - 2, height - 2, 3);
canvas_draw_line(canvas, x + 2, y + 1, x + 2, y + 3);
canvas_draw_line(canvas, x + 1, y + 2, x + 3, y + 2);
canvas_draw_line(canvas, x_max - 2, y + 1, x_max - 2, y + 3);
canvas_draw_line(canvas, x_max - 1, y + 2, x_max - 3, y + 2);
canvas_draw_line(canvas, x + 2, y_max - 1, x + 2, y_max - 3);
canvas_draw_line(canvas, x + 1, y_max - 2, x + 3, y_max - 2);
canvas_draw_line(canvas, x_max - 2, y_max - 1, x_max - 2, y_max - 3);
canvas_draw_line(canvas, x_max - 1, y_max - 2, x_max - 3, y_max - 2);
elements_progress_bar(
canvas, x + 4, y + 19, x_max - 7, popup_brut->progress, popup_brut->progress_max);
canvas_set_font(canvas, FontSecondary);
canvas_draw_str(canvas, x + 15, y + 12, "Sending ...");
canvas_draw_icon(canvas, x + 11, y_max - 14, &I_Back_15x10);
uint8_t percent_value = 100 * popup_brut->progress / popup_brut->progress_max;
snprintf(
popup_brut->percents_string_storage,
sizeof(popup_brut->percents_string_storage),
"%d%%",
percent_value);
elements_multiline_text_aligned(
canvas, x + 32, y + 40, AlignCenter, AlignBottom, popup_brut->percents_string_storage);
canvas_draw_str(canvas, x + 30, y_max - 5, "= stop");
}
void popup_brut_set_progress_max(IrdaAppPopupBrut* popup_brut, uint16_t progress_max) {
furi_assert(popup_brut);
popup_brut->progress = 0;
popup_brut->progress_max = progress_max;
}
IrdaAppPopupBrut* popup_brut_alloc(void) {
return (IrdaAppPopupBrut*)malloc(sizeof(IrdaAppPopupBrut));
}
void popup_brut_free(IrdaAppPopupBrut* popup_brut) {
free(popup_brut);
}