Skip to content

Commit

Permalink
upd barcode gen
Browse files Browse the repository at this point in the history
  • Loading branch information
xMasterX committed Mar 15, 2024
1 parent ab2ba32 commit ead0694
Show file tree
Hide file tree
Showing 8 changed files with 316 additions and 248 deletions.
8 changes: 2 additions & 6 deletions base_pack/barcode_gen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,8 @@ Note: Barcode save locations have been moved from `/barcodes` to `/apps_data/bar
## Building
1) Clone the [flipperzero-firmware](https://github.com/flipperdevices/flipperzero-firmware) repository or a firmware of your choice
2) Clone this repository and put it in the `applications_user` folder
3) Build this app by using the command `./fbt fap_Barcode_App`
4) Copy the `.fap` from `build\f7-firmware-D\.extapps\Barcode_App.fap` to `apps\Misc` using the qFlipper app
5) While still in the qFlipper app, navigate to the root folder of the SD card and create the folder `apps_data`, if not already there
6) Navigate into `apps_data` and create another folder called `barcode_data`
7) Navigate into `barcode_data`
8) Drag & drop the encoding txts (`code39_encodings.txt`, `code128_encodings.txt` & `codabar_encodings.txt`) from the `encoding_tables` folder in this repository into the `barcode_data` folder
3) Build this app by using the command `./fbt fap_barcode_App`
4) Copy the `.fap` from `build\f7-firmware-D\.extapps\Barcode_App.fap` to `apps\Tools` using the qFlipper app

## Usage

Expand Down
2 changes: 1 addition & 1 deletion base_pack/barcode_gen/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ App(
fap_file_assets="barcode_encoding_files",
fap_author="@Kingal1337",
fap_weburl="https://github.com/Kingal1337/flipper-barcode-generator",
fap_version="1.1",
fap_version="1.2",
fap_description="App allows you to display various barcodes on flipper screen",
)
78 changes: 78 additions & 0 deletions base_pack/barcode_gen/barcode_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ void submenu_callback(void* context, uint32_t index) {
edit_barcode_item(app);
} else if(index == CreateBarcodeItem) {
create_barcode_item(app);
} else if(index == AboutWidgetItem) {
view_dispatcher_switch_to_view(app->view_dispatcher, AboutWidgetView);
} else if(index == ErrorCodesWidgetItem) {
view_dispatcher_switch_to_view(app->view_dispatcher, ErrorCodesWidgetView);
}
}

Expand Down Expand Up @@ -269,6 +273,12 @@ void free_app(BarcodeApp* app) {
view_dispatcher_remove_view(app->view_dispatcher, TextInputView);
text_input_free(app->text_input);

view_dispatcher_remove_view(app->view_dispatcher, AboutWidgetView);
widget_free(app->about_widget);

view_dispatcher_remove_view(app->view_dispatcher, ErrorCodesWidgetView);
widget_free(app->error_codes_widget);

view_dispatcher_remove_view(app->view_dispatcher, MessageErrorView);
message_view_free(app->message_view);

Expand Down Expand Up @@ -349,6 +359,74 @@ int32_t barcode_main(void* p) {
view_dispatcher_add_view(
app->view_dispatcher, CreateBarcodeView, create_get_view(app->create_view));

/*****************************
* Creating Error Codes View
******************************/
app->error_codes_widget = widget_alloc();
widget_add_text_scroll_element(
app->error_codes_widget,
0,
0,
128,
64,
"\e#Error Codes\n"
"\e#Wrong # Of Characters\n"
"The barcode data has too \nmany or too few characters\n"
"UPC-A: 11-12 characters\n"
"EAN-8: 7-8 characters\n"
"EAN-13: 12-13 characters\n"
"Code128C - even # of \ncharacters\n"
"\n"
"\e#Invalid Characters\n"
"The barcode data has invalid \ncharacters.\n"
"Ex: UPC-A, EAN-8, EAN-13 barcodes can only have \nnumbers while Code128 can \nhave almost any character\n"
"\n"
"\e#Unsupported Type\n"
"The barcode type is not \nsupported by this application\n"
"\n"
"\e#File Opening Error\n"
"The barcode file could not be opened. One reason could be \nthat the file no longer exists\n"
"\n"
"\e#Invalid File Data\n"
"The barcode file could not find the keys \"Type\" or \"Data\". \nThis usually occurs when you edit the file manually and \naccidently change the keys\n"
"\n"
"\e#Missing Encoding Table\n"
"The encoding table files are \nmissing. This only occurs \nwhen you need to handle the \nencoding files manually. If you \ndownload the files from the \napp store this should not \noccur\n"
"\n"
"\e#Encoding Table Error\n"
"This occurs when the \nprogram cannot find a \ncharacter in the encoding \ntable, meaning that either the\ncharacter isn't supported \nor the character is missing \nfrom the encoding table\n"
"");
view_set_previous_callback(widget_get_view(app->error_codes_widget), main_menu_callback);
view_dispatcher_add_view(
app->view_dispatcher, ErrorCodesWidgetView, widget_get_view(app->error_codes_widget));
submenu_add_item(
app->main_menu, "Error Codes Info", ErrorCodesWidgetItem, submenu_callback, app);

/*****************************
* Creating About View
******************************/
app->about_widget = widget_alloc();
widget_add_text_scroll_element(
app->about_widget,
0,
0,
128,
64,
"This is a barcode generator\n"
"capable of generating UPC-A,\n"
"EAN-8, EAN-13, Code-39,\n"
"Codabar, and Code-128\n"
"\n"
"author: @Kingal1337\n"
"\n"
"For more information or\n"
"issues, go to\n"
"https://github.com/Kingal1337/flipper-barcode-generator");
view_set_previous_callback(widget_get_view(app->about_widget), main_menu_callback);
view_dispatcher_add_view(
app->view_dispatcher, AboutWidgetView, widget_get_view(app->about_widget));
submenu_add_item(app->main_menu, "About", AboutWidgetItem, submenu_callback, app);

/*****************************
* Creating Barcode View
******************************/
Expand Down
12 changes: 9 additions & 3 deletions base_pack/barcode_gen/barcode_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
#include <furi_hal.h>

#include <gui/gui.h>
#include <gui/elements.h>
#include <input/input.h>
#include <dialogs/dialogs.h>
#include <gui/view_dispatcher.h>
#include <gui/modules/submenu.h>
#include <gui/modules/widget.h>
#include <gui/modules/text_input.h>
#include <gui/modules/text_input.h>

Expand Down Expand Up @@ -59,23 +61,27 @@ struct BarcodeApp {
CreateView* create_view;
Barcode* barcode_view;

Widget* about_widget;
Widget* error_codes_widget;
MessageView* message_view;
TextInput* text_input;
};

enum SubmenuItems {
SelectBarcodeItem,
EditBarcodeItem,

CreateBarcodeItem
CreateBarcodeItem,
ErrorCodesWidgetItem,
AboutWidgetItem
};

enum Views {
TextInputView,
AboutWidgetView,
ErrorCodesWidgetView,
MessageErrorView,
MainMenuView,
CreateBarcodeView,

BarcodeView
};

Expand Down
Loading

0 comments on commit ead0694

Please sign in to comment.