mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-24 11:43:09 +00:00
274c12fc56
* 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>
80 lines
2.5 KiB
C
Executable file
80 lines
2.5 KiB
C
Executable file
#include "bank_card.h"
|
|
#include "../helpers/nfc_emv_parser.h"
|
|
#include <m-string.h>
|
|
|
|
struct BankCard {
|
|
Widget* widget;
|
|
};
|
|
|
|
BankCard* bank_card_alloc() {
|
|
BankCard* bank_card = malloc(sizeof(BankCard));
|
|
bank_card->widget = widget_alloc();
|
|
return bank_card;
|
|
}
|
|
|
|
void bank_card_free(BankCard* bank_card) {
|
|
furi_assert(bank_card);
|
|
widget_free(bank_card->widget);
|
|
free(bank_card);
|
|
}
|
|
|
|
View* bank_card_get_view(BankCard* bank_card) {
|
|
furi_assert(bank_card);
|
|
return widget_get_view(bank_card->widget);
|
|
}
|
|
|
|
void bank_card_clear(BankCard* bank_card) {
|
|
furi_assert(bank_card);
|
|
widget_reset(bank_card->widget);
|
|
}
|
|
|
|
void bank_card_set_name(BankCard* bank_card, char* name) {
|
|
furi_assert(bank_card);
|
|
furi_assert(name);
|
|
widget_add_string_element(
|
|
bank_card->widget, 64, 6, AlignCenter, AlignTop, FontSecondary, name);
|
|
}
|
|
|
|
void bank_card_set_number(BankCard* bank_card, uint8_t* number, uint8_t len) {
|
|
furi_assert(bank_card);
|
|
furi_assert(number);
|
|
string_t num_str;
|
|
string_init(num_str);
|
|
for(uint8_t i = 0; i < len; i += 2) {
|
|
string_cat_printf(num_str, "%02X%02X ", number[i], number[i + 1]);
|
|
}
|
|
// Add number
|
|
widget_add_string_element(
|
|
bank_card->widget, 64, 32, AlignCenter, AlignTop, FontSecondary, string_get_cstr(num_str));
|
|
string_clear(num_str);
|
|
// Add icon
|
|
widget_add_icon_element(bank_card->widget, 8, 15, &I_Detailed_chip_17x13);
|
|
// Add frame
|
|
widget_add_frame_element(bank_card->widget, 0, 0, 128, 64, 6);
|
|
}
|
|
|
|
void bank_card_set_back_callback(BankCard* bank_card, ButtonCallback callback, void* context) {
|
|
furi_assert(bank_card);
|
|
furi_assert(callback);
|
|
widget_add_button_element(bank_card->widget, GuiButtonTypeLeft, "Back", callback, context);
|
|
}
|
|
|
|
void bank_card_set_exp_date(BankCard* bank_card, uint8_t mon, uint8_t year) {
|
|
furi_assert(bank_card);
|
|
char exp_date_str[16];
|
|
snprintf(exp_date_str, sizeof(exp_date_str), "Exp: %02X/%02X", mon, year);
|
|
widget_add_string_element(
|
|
bank_card->widget, 122, 54, AlignRight, AlignBottom, FontSecondary, exp_date_str);
|
|
}
|
|
|
|
void bank_card_set_country_name(BankCard* bank_card, const char* country_name) {
|
|
furi_assert(bank_card);
|
|
widget_add_string_element(
|
|
bank_card->widget, 120, 18, AlignRight, AlignTop, FontSecondary, country_name);
|
|
}
|
|
|
|
void bank_card_set_currency_name(BankCard* bank_card, const char* currency_name) {
|
|
furi_assert(bank_card);
|
|
widget_add_string_element(
|
|
bank_card->widget, 31, 18, AlignLeft, AlignTop, FontSecondary, currency_name);
|
|
}
|