barcode_app.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #pragma once
  2. #include <furi.h>
  3. #include <furi_hal.h>
  4. #include <gui/gui.h>
  5. #include <input/input.h>
  6. #include <dialogs/dialogs.h>
  7. #include <gui/view_dispatcher.h>
  8. #include <gui/modules/submenu.h>
  9. #include <gui/modules/text_input.h>
  10. #include <gui/modules/text_input.h>
  11. #include <flipper_format/flipper_format.h>
  12. #include "barcode_utils.h"
  13. #define TAG "BARCODE"
  14. #define VERSION "1.1"
  15. #define FILE_VERSION "1"
  16. #define TEXT_BUFFER_SIZE 128
  17. #define BARCODE_HEIGHT 50
  18. #define BARCODE_Y_START 3
  19. //the folder where the encodings are located
  20. #define BARCODE_DATA_FILE_DIR_PATH EXT_PATH("apps_data/barcode_data")
  21. //the folder where the codabar encoding table is located
  22. #define CODABAR_DICT_FILE_PATH BARCODE_DATA_FILE_DIR_PATH "/codabar_encodings.txt"
  23. //the folder where the code 39 encoding table is located
  24. #define CODE39_DICT_FILE_PATH BARCODE_DATA_FILE_DIR_PATH "/code39_encodings.txt"
  25. //the folder where the code 128 encoding table is located
  26. #define CODE128_DICT_FILE_PATH BARCODE_DATA_FILE_DIR_PATH "/code128_encodings.txt"
  27. //the folder where the code 128 C encoding table is located
  28. #define CODE128C_DICT_FILE_PATH BARCODE_DATA_FILE_DIR_PATH "/code128c_encodings.txt"
  29. //the folder where the user stores their barcodes
  30. #define DEFAULT_USER_BARCODES EXT_PATH("apps_data/barcodes")
  31. //The extension barcode files use
  32. #define BARCODE_EXTENSION ".txt"
  33. #define BARCODE_EXTENSION_LENGTH 4
  34. #include "views/barcode_view.h"
  35. #include "views/create_view.h"
  36. #include "views/message_view.h"
  37. #include "barcode_validator.h"
  38. typedef struct BarcodeApp BarcodeApp;
  39. struct BarcodeApp {
  40. Submenu* main_menu;
  41. ViewDispatcher* view_dispatcher;
  42. Gui* gui;
  43. FuriMessageQueue* event_queue;
  44. CreateView* create_view;
  45. Barcode* barcode_view;
  46. MessageView* message_view;
  47. TextInput* text_input;
  48. };
  49. enum SubmenuItems {
  50. SelectBarcodeItem,
  51. EditBarcodeItem,
  52. CreateBarcodeItem
  53. };
  54. enum Views {
  55. TextInputView,
  56. MessageErrorView,
  57. MainMenuView,
  58. CreateBarcodeView,
  59. BarcodeView
  60. };
  61. void submenu_callback(void* context, uint32_t index);
  62. uint32_t main_menu_callback(void* context);
  63. uint32_t exit_callback(void* context);
  64. int32_t barcode_main(void* p);