Skip to content

Commit 7247b34

Browse files
committed
First Betta app
1 parent 905fcf1 commit 7247b34

File tree

4 files changed

+28
-10
lines changed

4 files changed

+28
-10
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.DS_Store
2+
.idea

application.fam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ App(
1515
fap_author="Igor Danilov",
1616
fap_version=(0, 5),
1717
order=70,
18-
fap_category="Misc",
18+
fap_category="Tools",
1919
fap_icon_assets="icons"
2020
)
2121

bc_scanner_script.c

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#define TAG "BarCodeScanner"
1414
#define WORKER_TAG TAG "Worker"
15-
#define FILE_BUFFER_LEN 16
15+
#define FILE_BUFFER_LEN 1
1616

1717
#define SCRIPT_STATE_ERROR (-1)
1818
#define SCRIPT_STATE_END (-2)
@@ -36,7 +36,7 @@ struct BarCodeScript {
3636
FuriString* file_path;
3737
uint32_t defdelay;
3838
FuriThread* thread;
39-
uint8_t file_buf[FILE_BUFFER_LEN + 1];
39+
uint8_t file_buf[FILE_BUFFER_LEN];
4040
uint8_t buf_start;
4141
uint8_t buf_len;
4242
bool file_end;
@@ -85,19 +85,18 @@ static int32_t bc_scanner_worker(void* context){
8585
BarCodeWorkerState worker_state = BarCodeStateInit;
8686
int32_t delay_val = 0;
8787
UNUSED(delay_val);
88-
UNUSED(is_bc_end);
8988
File* script_file = storage_file_alloc(furi_record_open(RECORD_STORAGE));
9089

9190
FURI_LOG_I(WORKER_TAG, "Init");
92-
uint8_t buff[5] = {'p', 'r', 'i', 'v', 'k'};
93-
uint8_t state = 99;
91+
//uint8_t buff[5] = {'p', 'r', 'i', 'v', 'k'};
92+
//uint8_t state = 99;
9493

9594
usb_uart_serial_init();
9695

9796
while (1)
9897
{
99-
state = furi_hal_cdc_get_ctrl_line_state(FuriHalUartIdUSART1);
100-
FURI_LOG_I(WORKER_TAG, "STATTE: %d", state);
98+
//state = furi_hal_cdc_get_ctrl_line_state(FuriHalUartIdUSART1);
99+
//FURI_LOG_I(WORKER_TAG, "STATTE: %d", state);
101100
if (worker_state == BarCodeStateInit)
102101
{
103102
if(storage_file_open(
@@ -131,9 +130,26 @@ static int32_t bc_scanner_worker(void* context){
131130
worker_state = BarCodeStateIdle; // Ready to run
132131
} else if(flags & WorkerEvtToggle) {
133132
FURI_LOG_I(WORKER_TAG, "SendUART_MSG");
134-
furi_hal_cdc_send(0, buff, sizeof (buff));
133+
uint16_t ret = 0;
134+
do {
135+
ret = storage_file_read(script_file, bc_script->file_buf, FILE_BUFFER_LEN);
136+
if (is_bc_end((char)bc_script->file_buf[0]))
137+
{
138+
bc_script->st.line_nb++;
139+
break;
140+
}
141+
142+
furi_hal_cdc_send(0, bc_script->file_buf, FILE_BUFFER_LEN);
143+
furi_delay_ms(10);
144+
if(storage_file_eof(script_file)) {
145+
bc_script->st.line_nb++;
146+
break;
147+
}
148+
}while (ret > 0);
149+
135150
worker_state = BarCodeStateIdle;
136151
bc_script->st.state = BarCodeStateDone;
152+
storage_file_seek(script_file, 0, true);
137153
continue;
138154
}
139155
bc_script->st.state = worker_state;
@@ -173,6 +189,7 @@ void bc_scanner_script_close(BarCodeScript* bc_script) {
173189
furi_thread_free(bc_script->thread);
174190
furi_string_free(bc_script->file_path);
175191
free(bc_script);
192+
FURI_LOG_D(WORKER_TAG, "bc_scanner_script_close");
176193
}
177194

178195
void bc_scanner_script_toggle(BarCodeScript* bc_script) {

views/bc_scanner_view.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ void bc_scanner_free(BarCodeView* bar_code) {
137137
furi_assert(bar_code);
138138
view_free(bar_code->view);
139139
free(bar_code);
140-
FURI_LOG_I(WORKER_TAG, "Free");
140+
FURI_LOG_D(WORKER_TAG, "bc_scanner_free");
141141
}
142142

143143
View* bc_scanner_get_view(BarCodeView* bar_code) {

0 commit comments

Comments
 (0)