Welcome to mirror list, hosted at ThFree Co, Russian Federation.

byte_input.c « modules « gui « applications - github.com/ClusterM/flipperzero-firmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b116030f8f3207da0c31d13d19c38322fe21b5d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
#include "byte_input.h"
#include <gui/elements.h>
#include <furi.h>

struct ByteInput {
    View* view;
};

typedef struct {
    const uint8_t value;
    const uint8_t x;
    const uint8_t y;
} ByteInputKey;

typedef struct {
    const char* header;
    uint8_t* bytes;
    uint8_t bytes_count;

    ByteInputCallback input_callback;
    ByteChangedCallback changed_callback;
    void* callback_context;

    bool selected_high_nibble;
    uint8_t selected_byte;
    int8_t selected_row; // row -1 - input, row 0 & 1 - keyboard
    uint8_t selected_column;
    uint8_t first_visible_byte;
} ByteInputModel;

static const uint8_t keyboard_origin_x = 7;
static const uint8_t keyboard_origin_y = 31;
static const uint8_t keyboard_row_count = 2;
static const uint8_t enter_symbol = '\r';
static const uint8_t backspace_symbol = '\b';
static const uint8_t max_drawable_bytes = 8;

static const ByteInputKey keyboard_keys_row_1[] = {
    {'0', 0, 12},
    {'1', 11, 12},
    {'2', 22, 12},
    {'3', 33, 12},
    {'4', 44, 12},
    {'5', 55, 12},
    {'6', 66, 12},
    {'7', 77, 12},
    {backspace_symbol, 103, 4},
};

static const ByteInputKey keyboard_keys_row_2[] = {
    {'8', 0, 26},
    {'9', 11, 26},
    {'A', 22, 26},
    {'B', 33, 26},
    {'C', 44, 26},
    {'D', 55, 26},
    {'E', 66, 26},
    {'F', 77, 26},
    {enter_symbol, 95, 17},
};

/**
 * @brief Get row size
 * 
 * @param row_index Index of row 
 * @return uint8_t Row size
 */
static uint8_t byte_input_get_row_size(uint8_t row_index) {
    uint8_t row_size = 0;

    switch(row_index + 1) {
    case 1:
        row_size = sizeof(keyboard_keys_row_1) / sizeof(ByteInputKey);
        break;
    case 2:
        row_size = sizeof(keyboard_keys_row_2) / sizeof(ByteInputKey);
        break;
    }

    return row_size;
}

/**
 * @brief Get row pointer
 * 
 * @param row_index Index of row 
 * @return const ByteInputKey* Row pointer
 */
static const ByteInputKey* byte_input_get_row(uint8_t row_index) {
    const ByteInputKey* row = NULL;

    switch(row_index + 1) {
    case 1:
        row = keyboard_keys_row_1;
        break;
    case 2:
        row = keyboard_keys_row_2;
        break;
    }

    return row;
}

/**
 * @brief Get text from nibble
 * 
 * @param byte byte value
 * @param high_nibble Get from high nibble, otherwise low nibble
 * @return char nibble text
 */
static char byte_input_get_nibble_text(uint8_t byte, bool high_nibble) {
    if(high_nibble) {
        byte = byte >> 4;
    }
    byte = byte & 0x0F;

    switch(byte & 0x0F) {
    case 0x0:
    case 0x1:
    case 0x2:
    case 0x3:
    case 0x4:
    case 0x5:
    case 0x6:
    case 0x7:
    case 0x8:
    case 0x9:
        byte = byte + '0';
        break;
    case 0xA:
    case 0xB:
    case 0xC:
    case 0xD:
    case 0xE:
    case 0xF:
        byte = byte - 0xA + 'A';
        break;
    default:
        byte = '!';
        break;
    }

    return byte;
}

/**
 * @brief Draw input box (common view)
 * 
 * @param canvas 
 * @param model 
 */
static void byte_input_draw_input(Canvas* canvas, ByteInputModel* model) {
    const uint8_t text_x = 8;
    const uint8_t text_y = 25;

    elements_slightly_rounded_frame(canvas, 6, 14, 116, 15);

    canvas_draw_icon(canvas, 2, 19, &I_ButtonLeftSmall_3x5);
    canvas_draw_icon(canvas, 123, 19, &I_ButtonRightSmall_3x5);

    for(uint8_t i = model->first_visible_byte;
        i < model->first_visible_byte + MIN(model->bytes_count, max_drawable_bytes);
        i++) {
        uint8_t byte_position = i - model->first_visible_byte;

        if(i == model->selected_byte) {
            canvas_draw_frame(canvas, text_x + byte_position * 14, text_y - 9, 15, 11);

            if(model->selected_high_nibble) {
                canvas_draw_glyph(
                    canvas,
                    text_x + 8 + byte_position * 14,
                    text_y,
                    byte_input_get_nibble_text(model->bytes[i], false));
                canvas_draw_box(canvas, text_x + 1 + byte_position * 14, text_y - 8, 7, 9);
                canvas_invert_color(canvas);
                canvas_draw_line(
                    canvas,
                    text_x + 14 + byte_position * 14,
                    text_y - 6,
                    text_x + 14 + byte_position * 14,
                    text_y - 2);
                canvas_draw_glyph(
                    canvas,
                    text_x + 2 + byte_position * 14,
                    text_y,
                    byte_input_get_nibble_text(model->bytes[i], true));
                canvas_invert_color(canvas);
            } else {
                canvas_draw_box(canvas, text_x + 7 + byte_position * 14, text_y - 8, 7, 9);
                canvas_draw_glyph(
                    canvas,
                    text_x + 2 + byte_position * 14,
                    text_y,
                    byte_input_get_nibble_text(model->bytes[i], true));
                canvas_invert_color(canvas);
                canvas_draw_line(
                    canvas,
                    text_x + byte_position * 14,
                    text_y - 6,
                    text_x + byte_position * 14,
                    text_y - 2);
                canvas_draw_glyph(
                    canvas,
                    text_x + 8 + byte_position * 14,
                    text_y,
                    byte_input_get_nibble_text(model->bytes[i], false));
                canvas_invert_color(canvas);
            }
        } else {
            canvas_draw_glyph(
                canvas,
                text_x + 2 + byte_position * 14,
                text_y,
                byte_input_get_nibble_text(model->bytes[i], true));
            canvas_draw_glyph(
                canvas,
                text_x + 8 + byte_position * 14,
                text_y,
                byte_input_get_nibble_text(model->bytes[i], false));
        }
    }

    if(model->bytes_count - model->first_visible_byte > max_drawable_bytes) {
        canvas_draw_icon(canvas, 123, 21, &I_ButtonRightSmall_3x5);
    }

    if(model->first_visible_byte > 0) {
        canvas_draw_icon(canvas, 1, 21, &I_ButtonLeftSmall_3x5);
    }
}

/**
 * @brief Draw input box (selected view)
 * 
 * @param canvas 
 * @param model 
 */
static void byte_input_draw_input_selected(Canvas* canvas, ByteInputModel* model) {
    const uint8_t text_x = 7;
    const uint8_t text_y = 25;

    canvas_draw_box(canvas, 0, 12, 127, 19);
    canvas_invert_color(canvas);

    elements_slightly_rounded_frame(canvas, 6, 14, 115, 15);
    canvas_draw_icon(canvas, 2, 19, &I_ButtonLeftSmall_3x5);
    canvas_draw_icon(canvas, 122, 19, &I_ButtonRightSmall_3x5);

    for(uint8_t i = model->first_visible_byte;
        i < model->first_visible_byte + MIN(model->bytes_count, max_drawable_bytes);
        i++) {
        uint8_t byte_position = i - model->first_visible_byte;

        if(i == model->selected_byte) {
            canvas_draw_box(canvas, text_x + 1 + byte_position * 14, text_y - 9, 13, 11);
            canvas_invert_color(canvas);
            canvas_draw_glyph(
                canvas,
                text_x + 2 + byte_position * 14,
                text_y,
                byte_input_get_nibble_text(model->bytes[i], true));
            canvas_draw_glyph(
                canvas,
                text_x + 8 + byte_position * 14,
                text_y,
                byte_input_get_nibble_text(model->bytes[i], false));
            canvas_invert_color(canvas);
        } else {
            canvas_draw_glyph(
                canvas,
                text_x + 2 + byte_position * 14,
                text_y,
                byte_input_get_nibble_text(model->bytes[i], true));
            canvas_draw_glyph(
                canvas,
                text_x + 8 + byte_position * 14,
                text_y,
                byte_input_get_nibble_text(model->bytes[i], false));
        }
    }

    if(model->bytes_count - model->first_visible_byte > max_drawable_bytes) {
        canvas_draw_icon(canvas, 123, 21, &I_ButtonRightSmall_3x5);
    }

    if(model->first_visible_byte > 0) {
        canvas_draw_icon(canvas, 1, 21, &I_ButtonLeftSmall_3x5);
    }

    canvas_invert_color(canvas);
}

/**
 * @brief Set nibble at position
 * 
 * @param data where to set nibble
 * @param position byte position
 * @param value char value
 * @param high_nibble set high nibble
 */
static void byte_input_set_nibble(uint8_t* data, uint8_t position, char value, bool high_nibble) {
    switch(value) {
    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':
        value = value - '0';
        break;
    case 'A':
    case 'B':
    case 'C':
    case 'D':
    case 'E':
    case 'F':
        value = value - 'A' + 10;
        break;
    default:
        value = 0;
        break;
    }

    if(high_nibble) {
        data[position] &= 0x0F;
        data[position] |= value << 4;
    } else {
        data[position] &= 0xF0;
        data[position] |= value;
    }
}

/**
 * @brief What currently selected
 * 
 * @return true - keyboard selected, false - input selected
 */
static bool byte_input_keyboard_selected(ByteInputModel* model) {
    return model->selected_row >= 0;
}

/**
 * @brief Do transition from keyboard
 * 
 * @param model 
 */
static void byte_input_transition_from_keyboard(ByteInputModel* model) {
    model->selected_row += 1;
    model->selected_high_nibble = true;
}

/**
 * @brief Increase selected byte position
 * 
 * @param model 
 */
static void byte_input_inc_selected_byte(ByteInputModel* model) {
    if(model->selected_byte < model->bytes_count - 1) {
        model->selected_byte += 1;

        if(model->bytes_count > max_drawable_bytes) {
            if(model->selected_byte - model->first_visible_byte > (max_drawable_bytes - 2)) {
                if(model->first_visible_byte < model->bytes_count - max_drawable_bytes) {
                    model->first_visible_byte++;
                }
            }
        }
    }
}

/**
 * @brief Decrease selected byte position
 * 
 * @param model 
 */
static void byte_input_dec_selected_byte(ByteInputModel* model) {
    if(model->selected_byte > 0) {
        model->selected_byte -= 1;

        if(model->selected_byte - model->first_visible_byte < 1) {
            if(model->first_visible_byte > 0) {
                model->first_visible_byte--;
            }
        }
    }
}

/**
 * @brief Call input callback
 * 
 * @param model 
 */
static void byte_input_call_input_callback(ByteInputModel* model) {
    if(model->input_callback != NULL) {
        model->input_callback(model->callback_context);
    }
}

/**
 * @brief Call changed callback
 * 
 * @param model 
 */
static void byte_input_call_changed_callback(ByteInputModel* model) {
    if(model->changed_callback != NULL) {
        model->changed_callback(model->callback_context);
    }
}

/**
 * @brief Clear selected byte 
 */

static void byte_input_clear_selected_byte(ByteInputModel* model) {
    model->bytes[model->selected_byte] = 0;
    model->selected_high_nibble = true;
    byte_input_dec_selected_byte(model);
    byte_input_call_changed_callback(model);
}

/**
 * @brief Handle up button
 * 
 * @param model 
 */
static void byte_input_handle_up(ByteInputModel* model) {
    if(model->selected_row > -1) {
        model->selected_row -= 1;
    }
}

/**
 * @brief Handle down button
 * 
 * @param model 
 */
static void byte_input_handle_down(ByteInputModel* model) {
    if(byte_input_keyboard_selected(model)) {
        if(model->selected_row < keyboard_row_count - 1) {
            model->selected_row += 1;
        }
    } else {
        byte_input_transition_from_keyboard(model);
    }
}

/**
 * @brief Handle left button
 * 
 * @param model 
 */
static void byte_input_handle_left(ByteInputModel* model) {
    if(byte_input_keyboard_selected(model)) {
        if(model->selected_column > 0) {
            model->selected_column -= 1;
        } else {
            model->selected_column = byte_input_get_row_size(model->selected_row) - 1;
        }
    } else {
        byte_input_dec_selected_byte(model);
    }
}

/**
 * @brief Handle right button
 * 
 * @param model 
 */
static void byte_input_handle_right(ByteInputModel* model) {
    if(byte_input_keyboard_selected(model)) {
        if(model->selected_column < byte_input_get_row_size(model->selected_row) - 1) {
            model->selected_column += 1;
        } else {
            model->selected_column = 0;
        }
    } else {
        byte_input_inc_selected_byte(model);
    }
}

/**
 * @brief Handle OK button
 * 
 * @param model 
 */
static void byte_input_handle_ok(ByteInputModel* model) {
    if(byte_input_keyboard_selected(model)) {
        uint8_t value = byte_input_get_row(model->selected_row)[model->selected_column].value;

        if(value == enter_symbol) {
            byte_input_call_input_callback(model);
        } else if(value == backspace_symbol) {
            byte_input_clear_selected_byte(model);
        } else {
            byte_input_set_nibble(
                model->bytes, model->selected_byte, value, model->selected_high_nibble);
            if(model->selected_high_nibble == true) {
                model->selected_high_nibble = false;
            } else {
                byte_input_inc_selected_byte(model);
                model->selected_high_nibble = true;
            }
            byte_input_call_changed_callback(model);
        }
    } else {
        byte_input_transition_from_keyboard(model);
    }
}

/**
 * @brief Draw callback
 * 
 * @param canvas 
 * @param _model 
 */
static void byte_input_view_draw_callback(Canvas* canvas, void* _model) {
    ByteInputModel* model = _model;

    canvas_clear(canvas);
    canvas_set_color(canvas, ColorBlack);

    canvas_draw_str(canvas, 2, 9, model->header);

    canvas_set_font(canvas, FontKeyboard);

    if(model->selected_row == -1) {
        byte_input_draw_input_selected(canvas, model);
    } else {
        byte_input_draw_input(canvas, model);
    }

    for(uint8_t row = 0; row < keyboard_row_count; row++) {
        const uint8_t column_count = byte_input_get_row_size(row);
        const ByteInputKey* keys = byte_input_get_row(row);

        for(size_t column = 0; column < column_count; column++) {
            if(keys[column].value == enter_symbol) {
                canvas_set_color(canvas, ColorBlack);
                if(model->selected_row == row && model->selected_column == column) {
                    canvas_draw_icon(
                        canvas,
                        keyboard_origin_x + keys[column].x,
                        keyboard_origin_y + keys[column].y,
                        &I_KeySaveSelected_24x11);
                } else {
                    canvas_draw_icon(
                        canvas,
                        keyboard_origin_x + keys[column].x,
                        keyboard_origin_y + keys[column].y,
                        &I_KeySave_24x11);
                }
            } else if(keys[column].value == backspace_symbol) {
                canvas_set_color(canvas, ColorBlack);
                if(model->selected_row == row && model->selected_column == column) {
                    canvas_draw_icon(
                        canvas,
                        keyboard_origin_x + keys[column].x,
                        keyboard_origin_y + keys[column].y,
                        &I_KeyBackspaceSelected_16x9);
                } else {
                    canvas_draw_icon(
                        canvas,
                        keyboard_origin_x + keys[column].x,
                        keyboard_origin_y + keys[column].y,
                        &I_KeyBackspace_16x9);
                }
            } else {
                if(model->selected_row == row && model->selected_column == column) {
                    canvas_set_color(canvas, ColorBlack);
                    canvas_draw_box(
                        canvas,
                        keyboard_origin_x + keys[column].x - 3,
                        keyboard_origin_y + keys[column].y - 10,
                        11,
                        13);
                    canvas_set_color(canvas, ColorWhite);
                } else if(model->selected_row == -1 && row == 0 && model->selected_column == column) {
                    canvas_set_color(canvas, ColorBlack);
                    canvas_draw_frame(
                        canvas,
                        keyboard_origin_x + keys[column].x - 3,
                        keyboard_origin_y + keys[column].y - 10,
                        11,
                        13);
                } else {
                    canvas_set_color(canvas, ColorBlack);
                }

                canvas_draw_glyph(
                    canvas,
                    keyboard_origin_x + keys[column].x,
                    keyboard_origin_y + keys[column].y,
                    keys[column].value);
            }
        }
    }
}

/**
 * @brief Input callback
 * 
 * @param event 
 * @param context 
 * @return true 
 * @return false 
 */
static bool byte_input_view_input_callback(InputEvent* event, void* context) {
    ByteInput* byte_input = context;
    furi_assert(byte_input);
    bool consumed = false;

    if(event->type == InputTypeShort || event->type == InputTypeRepeat) {
        switch(event->key) {
        case InputKeyLeft:
            with_view_model(
                byte_input->view, (ByteInputModel * model) {
                    byte_input_handle_left(model);
                    return true;
                });
            consumed = true;
            break;
        case InputKeyRight:
            with_view_model(
                byte_input->view, (ByteInputModel * model) {
                    byte_input_handle_right(model);
                    return true;
                });
            consumed = true;
            break;
        case InputKeyUp:
            with_view_model(
                byte_input->view, (ByteInputModel * model) {
                    byte_input_handle_up(model);
                    return true;
                });
            consumed = true;
            break;
        case InputKeyDown:
            with_view_model(
                byte_input->view, (ByteInputModel * model) {
                    byte_input_handle_down(model);
                    return true;
                });
            consumed = true;
            break;
        case InputKeyOk:
            with_view_model(
                byte_input->view, (ByteInputModel * model) {
                    byte_input_handle_ok(model);
                    return true;
                });
            consumed = true;
            break;
        default:
            break;
        }
    }

    if((event->type == InputTypeLong || event->type == InputTypeRepeat) &&
       event->key == InputKeyBack) {
        with_view_model(
            byte_input->view, (ByteInputModel * model) {
                byte_input_clear_selected_byte(model);
                return true;
            });
        consumed = true;
    }

    return consumed;
}

/**
 * @brief Reset all input-related data in model
 * 
 * @param model ByteInputModel
 */
static void byte_input_reset_model_input_data(ByteInputModel* model) {
    model->bytes = NULL;
    model->bytes_count = 0;
    model->selected_high_nibble = true;
    model->selected_byte = 0;
    model->selected_row = 0;
    model->selected_column = 0;
    model->first_visible_byte = 0;
}

/** 
 * @brief Allocate and initialize byte input. This byte input is used to enter bytes.
 * 
 * @return ByteInput instance pointer
 */
ByteInput* byte_input_alloc() {
    ByteInput* byte_input = furi_alloc(sizeof(ByteInput));
    byte_input->view = view_alloc();
    view_set_context(byte_input->view, byte_input);
    view_allocate_model(byte_input->view, ViewModelTypeLocking, sizeof(ByteInputModel));
    view_set_draw_callback(byte_input->view, byte_input_view_draw_callback);
    view_set_input_callback(byte_input->view, byte_input_view_input_callback);

    with_view_model(
        byte_input->view, (ByteInputModel * model) {
            model->header = "";
            model->input_callback = NULL;
            model->changed_callback = NULL;
            model->callback_context = NULL;
            byte_input_reset_model_input_data(model);
            return true;
        });

    return byte_input;
}

/** 
 * @brief Deinitialize and free byte input
 * 
 * @param byte_input Byte input instance
 */
void byte_input_free(ByteInput* byte_input) {
    furi_assert(byte_input);
    view_free(byte_input->view);
    free(byte_input);
}

/** 
 * @brief Get byte input view
 * 
 * @param byte_input byte input instance
 * @return View instance that can be used for embedding
 */
View* byte_input_get_view(ByteInput* byte_input) {
    furi_assert(byte_input);
    return byte_input->view;
}

/** 
 * @brief Deinitialize and free byte input
 * 
 * @param byte_input byte input instance
 * @param input_callback input callback fn
 * @param changed_callback changed callback fn
 * @param callback_context callback context
 * @param bytes buffer to use
 * @param bytes_count buffer length
 */
void byte_input_set_result_callback(
    ByteInput* byte_input,
    ByteInputCallback input_callback,
    ByteChangedCallback changed_callback,
    void* callback_context,
    uint8_t* bytes,
    uint8_t bytes_count) {
    with_view_model(
        byte_input->view, (ByteInputModel * model) {
            byte_input_reset_model_input_data(model);
            model->input_callback = input_callback;
            model->changed_callback = changed_callback;
            model->callback_context = callback_context;
            model->bytes = bytes;
            model->bytes_count = bytes_count;
            return true;
        });
}

/**
 * @brief Set byte input header text
 * 
 * @param byte_input byte input instance
 * @param text text to be shown
 */
void byte_input_set_header_text(ByteInput* byte_input, const char* text) {
    with_view_model(
        byte_input->view, (ByteInputModel * model) {
            model->header = text;
            return true;
        });
}