byte_input.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. #include "byte_input.h"
  2. #include <gui/elements.h>
  3. #include <furi.h>
  4. struct ByteInput {
  5. View* view;
  6. };
  7. typedef struct {
  8. const uint8_t value;
  9. const uint8_t x;
  10. const uint8_t y;
  11. } ByteInputKey;
  12. typedef struct {
  13. const char* header;
  14. uint8_t* bytes;
  15. uint8_t bytes_count;
  16. ByteInputCallback input_callback;
  17. ByteChangedCallback changed_callback;
  18. void* callback_context;
  19. bool selected_high_nibble;
  20. uint8_t selected_byte;
  21. int8_t selected_row; // row -1 - input, row 0 & 1 - keyboard
  22. uint8_t selected_column;
  23. uint8_t first_visible_byte;
  24. } ByteInputModel;
  25. static const uint8_t keyboard_origin_x = 7;
  26. static const uint8_t keyboard_origin_y = 31;
  27. static const uint8_t keyboard_row_count = 2;
  28. static const uint8_t enter_symbol = '\r';
  29. static const uint8_t backspace_symbol = '\b';
  30. static const uint8_t max_drawable_bytes = 8;
  31. static const ByteInputKey keyboard_keys_row_1[] = {
  32. {'0', 0, 12},
  33. {'1', 11, 12},
  34. {'2', 22, 12},
  35. {'3', 33, 12},
  36. {'4', 44, 12},
  37. {'5', 55, 12},
  38. {'6', 66, 12},
  39. {'7', 77, 12},
  40. {backspace_symbol, 103, 4},
  41. };
  42. static const ByteInputKey keyboard_keys_row_2[] = {
  43. {'8', 0, 26},
  44. {'9', 11, 26},
  45. {'A', 22, 26},
  46. {'B', 33, 26},
  47. {'C', 44, 26},
  48. {'D', 55, 26},
  49. {'E', 66, 26},
  50. {'F', 77, 26},
  51. {enter_symbol, 95, 17},
  52. };
  53. /**
  54. * @brief Get row size
  55. *
  56. * @param row_index Index of row
  57. * @return uint8_t Row size
  58. */
  59. static uint8_t byte_input_get_row_size(uint8_t row_index) {
  60. uint8_t row_size = 0;
  61. switch(row_index + 1) {
  62. case 1:
  63. row_size = sizeof(keyboard_keys_row_1) / sizeof(ByteInputKey);
  64. break;
  65. case 2:
  66. row_size = sizeof(keyboard_keys_row_2) / sizeof(ByteInputKey);
  67. break;
  68. }
  69. return row_size;
  70. }
  71. /**
  72. * @brief Get row pointer
  73. *
  74. * @param row_index Index of row
  75. * @return const ByteInputKey* Row pointer
  76. */
  77. static const ByteInputKey* byte_input_get_row(uint8_t row_index) {
  78. const ByteInputKey* row = NULL;
  79. switch(row_index + 1) {
  80. case 1:
  81. row = keyboard_keys_row_1;
  82. break;
  83. case 2:
  84. row = keyboard_keys_row_2;
  85. break;
  86. }
  87. return row;
  88. }
  89. /**
  90. * @brief Get text from nibble
  91. *
  92. * @param byte byte value
  93. * @param high_nibble Get from high nibble, otherwise low nibble
  94. * @return char nibble text
  95. */
  96. static char byte_input_get_nibble_text(uint8_t byte, bool high_nibble) {
  97. if(high_nibble) {
  98. byte = byte >> 4;
  99. }
  100. byte = byte & 0x0F;
  101. switch(byte & 0x0F) {
  102. case 0x0:
  103. case 0x1:
  104. case 0x2:
  105. case 0x3:
  106. case 0x4:
  107. case 0x5:
  108. case 0x6:
  109. case 0x7:
  110. case 0x8:
  111. case 0x9:
  112. byte = byte + '0';
  113. break;
  114. case 0xA:
  115. case 0xB:
  116. case 0xC:
  117. case 0xD:
  118. case 0xE:
  119. case 0xF:
  120. byte = byte - 0xA + 'A';
  121. break;
  122. default:
  123. byte = '!';
  124. break;
  125. }
  126. return byte;
  127. }
  128. /**
  129. * @brief Draw input box (common view)
  130. *
  131. * @param canvas
  132. * @param model
  133. */
  134. static void byte_input_draw_input(Canvas* canvas, ByteInputModel* model) {
  135. const uint8_t text_x = 3;
  136. const uint8_t text_y = 25;
  137. elements_slightly_rounded_frame(canvas, 1, 14, 126, 15);
  138. for(uint8_t i = model->first_visible_byte;
  139. i < model->first_visible_byte + MIN(model->bytes_count, max_drawable_bytes);
  140. i++) {
  141. uint8_t byte_position = i - model->first_visible_byte;
  142. if(i == model->selected_byte) {
  143. canvas_draw_frame(canvas, text_x + byte_position * 14, text_y - 9, 15, 11);
  144. if(model->selected_high_nibble) {
  145. canvas_draw_glyph(
  146. canvas,
  147. text_x + 8 + byte_position * 14,
  148. text_y,
  149. byte_input_get_nibble_text(model->bytes[i], false));
  150. canvas_draw_box(canvas, text_x + 1 + byte_position * 14, text_y - 8, 7, 9);
  151. canvas_invert_color(canvas);
  152. canvas_draw_line(
  153. canvas,
  154. text_x + 14 + byte_position * 14,
  155. text_y - 6,
  156. text_x + 14 + byte_position * 14,
  157. text_y - 2);
  158. canvas_draw_glyph(
  159. canvas,
  160. text_x + 2 + byte_position * 14,
  161. text_y,
  162. byte_input_get_nibble_text(model->bytes[i], true));
  163. canvas_invert_color(canvas);
  164. } else {
  165. canvas_draw_box(canvas, text_x + 7 + byte_position * 14, text_y - 8, 7, 9);
  166. canvas_draw_glyph(
  167. canvas,
  168. text_x + 2 + byte_position * 14,
  169. text_y,
  170. byte_input_get_nibble_text(model->bytes[i], true));
  171. canvas_invert_color(canvas);
  172. canvas_draw_line(
  173. canvas,
  174. text_x + byte_position * 14,
  175. text_y - 6,
  176. text_x + byte_position * 14,
  177. text_y - 2);
  178. canvas_draw_glyph(
  179. canvas,
  180. text_x + 8 + byte_position * 14,
  181. text_y,
  182. byte_input_get_nibble_text(model->bytes[i], false));
  183. canvas_invert_color(canvas);
  184. }
  185. } else {
  186. canvas_draw_glyph(
  187. canvas,
  188. text_x + 2 + byte_position * 14,
  189. text_y,
  190. byte_input_get_nibble_text(model->bytes[i], true));
  191. canvas_draw_glyph(
  192. canvas,
  193. text_x + 8 + byte_position * 14,
  194. text_y,
  195. byte_input_get_nibble_text(model->bytes[i], false));
  196. }
  197. }
  198. if(model->bytes_count - model->first_visible_byte > max_drawable_bytes) {
  199. canvas_draw_icon_name(canvas, 123, 21, I_ButtonRightSmall_3x5);
  200. }
  201. if(model->first_visible_byte > 0) {
  202. canvas_draw_icon_name(canvas, 1, 21, I_ButtonLeftSmall_3x5);
  203. }
  204. }
  205. /**
  206. * @brief Draw input box (selected view)
  207. *
  208. * @param canvas
  209. * @param model
  210. */
  211. static void byte_input_draw_input_selected(Canvas* canvas, ByteInputModel* model) {
  212. const uint8_t text_x = 3;
  213. const uint8_t text_y = 25;
  214. canvas_draw_box(canvas, 0, 12, 128, 19);
  215. canvas_invert_color(canvas);
  216. elements_slightly_rounded_frame(canvas, 1, 14, 126, 15);
  217. for(uint8_t i = model->first_visible_byte;
  218. i < model->first_visible_byte + MIN(model->bytes_count, max_drawable_bytes);
  219. i++) {
  220. uint8_t byte_position = i - model->first_visible_byte;
  221. if(i == model->selected_byte) {
  222. canvas_draw_box(canvas, text_x + byte_position * 14, text_y - 9, 15, 11);
  223. canvas_invert_color(canvas);
  224. canvas_draw_glyph(
  225. canvas,
  226. text_x + 2 + byte_position * 14,
  227. text_y,
  228. byte_input_get_nibble_text(model->bytes[i], true));
  229. canvas_draw_glyph(
  230. canvas,
  231. text_x + 8 + byte_position * 14,
  232. text_y,
  233. byte_input_get_nibble_text(model->bytes[i], false));
  234. canvas_invert_color(canvas);
  235. } else {
  236. canvas_draw_glyph(
  237. canvas,
  238. text_x + 2 + byte_position * 14,
  239. text_y,
  240. byte_input_get_nibble_text(model->bytes[i], true));
  241. canvas_draw_glyph(
  242. canvas,
  243. text_x + 8 + byte_position * 14,
  244. text_y,
  245. byte_input_get_nibble_text(model->bytes[i], false));
  246. }
  247. }
  248. if(model->bytes_count - model->first_visible_byte > max_drawable_bytes) {
  249. canvas_draw_icon_name(canvas, 123, 21, I_ButtonRightSmall_3x5);
  250. }
  251. if(model->first_visible_byte > 0) {
  252. canvas_draw_icon_name(canvas, 1, 21, I_ButtonLeftSmall_3x5);
  253. }
  254. canvas_invert_color(canvas);
  255. }
  256. /**
  257. * @brief Set nibble at position
  258. *
  259. * @param data where to set nibble
  260. * @param position byte position
  261. * @param value char value
  262. * @param high_nibble set high nibble
  263. */
  264. static void byte_input_set_nibble(uint8_t* data, uint8_t position, char value, bool high_nibble) {
  265. switch(value) {
  266. case '0':
  267. case '1':
  268. case '2':
  269. case '3':
  270. case '4':
  271. case '5':
  272. case '6':
  273. case '7':
  274. case '8':
  275. case '9':
  276. value = value - '0';
  277. break;
  278. case 'A':
  279. case 'B':
  280. case 'C':
  281. case 'D':
  282. case 'E':
  283. case 'F':
  284. value = value - 'A' + 10;
  285. break;
  286. default:
  287. value = 0;
  288. break;
  289. }
  290. if(high_nibble) {
  291. data[position] &= 0x0F;
  292. data[position] |= value << 4;
  293. } else {
  294. data[position] &= 0xF0;
  295. data[position] |= value;
  296. }
  297. }
  298. /**
  299. * @brief What currently selected
  300. *
  301. * @return true - keyboard selected, false - input selected
  302. */
  303. static bool byte_input_keyboard_selected(ByteInputModel* model) {
  304. return model->selected_row >= 0;
  305. }
  306. /**
  307. * @brief Do transition from keyboard
  308. *
  309. * @param model
  310. */
  311. static void byte_input_transition_from_keyboard(ByteInputModel* model) {
  312. model->selected_row += 1;
  313. model->selected_high_nibble = true;
  314. }
  315. /**
  316. * @brief Increase selected byte position
  317. *
  318. * @param model
  319. */
  320. static void byte_input_inc_selected_byte(ByteInputModel* model) {
  321. if(model->selected_byte < model->bytes_count - 1) {
  322. model->selected_byte += 1;
  323. if(model->bytes_count > max_drawable_bytes) {
  324. if(model->selected_byte - model->first_visible_byte > (max_drawable_bytes - 2)) {
  325. if(model->first_visible_byte < model->bytes_count - max_drawable_bytes) {
  326. model->first_visible_byte++;
  327. }
  328. }
  329. }
  330. }
  331. }
  332. /**
  333. * @brief Decrease selected byte position
  334. *
  335. * @param model
  336. */
  337. static void byte_input_dec_selected_byte(ByteInputModel* model) {
  338. if(model->selected_byte > 0) {
  339. model->selected_byte -= 1;
  340. if(model->selected_byte - model->first_visible_byte < 1) {
  341. if(model->first_visible_byte > 0) {
  342. model->first_visible_byte--;
  343. }
  344. }
  345. }
  346. }
  347. /**
  348. * @brief Call input callback
  349. *
  350. * @param model
  351. */
  352. static void byte_input_call_input_callback(ByteInputModel* model) {
  353. if(model->input_callback != NULL) {
  354. model->input_callback(model->callback_context, model->bytes, model->bytes_count);
  355. }
  356. }
  357. /**
  358. * @brief Call changed callback
  359. *
  360. * @param model
  361. */
  362. static void byte_input_call_changed_callback(ByteInputModel* model) {
  363. if(model->changed_callback != NULL) {
  364. model->changed_callback(model->callback_context, model->bytes, model->bytes_count);
  365. }
  366. }
  367. /**
  368. * @brief Handle up button
  369. *
  370. * @param model
  371. */
  372. static void byte_input_handle_up(ByteInputModel* model) {
  373. if(model->selected_row > -1) {
  374. model->selected_row -= 1;
  375. }
  376. }
  377. /**
  378. * @brief Handle down button
  379. *
  380. * @param model
  381. */
  382. static void byte_input_handle_down(ByteInputModel* model) {
  383. if(byte_input_keyboard_selected(model)) {
  384. if(model->selected_row < keyboard_row_count - 1) {
  385. model->selected_row += 1;
  386. }
  387. } else {
  388. byte_input_transition_from_keyboard(model);
  389. }
  390. }
  391. /**
  392. * @brief Handle left button
  393. *
  394. * @param model
  395. */
  396. static void byte_input_handle_left(ByteInputModel* model) {
  397. if(byte_input_keyboard_selected(model)) {
  398. if(model->selected_column > 0) {
  399. model->selected_column -= 1;
  400. } else {
  401. model->selected_column = byte_input_get_row_size(model->selected_row) - 1;
  402. }
  403. } else {
  404. byte_input_dec_selected_byte(model);
  405. }
  406. }
  407. /**
  408. * @brief Handle right button
  409. *
  410. * @param model
  411. */
  412. static void byte_input_handle_right(ByteInputModel* model) {
  413. if(byte_input_keyboard_selected(model)) {
  414. if(model->selected_column < byte_input_get_row_size(model->selected_row) - 1) {
  415. model->selected_column += 1;
  416. } else {
  417. model->selected_column = 0;
  418. }
  419. } else {
  420. byte_input_inc_selected_byte(model);
  421. }
  422. }
  423. /**
  424. * @brief Handle OK button
  425. *
  426. * @param model
  427. */
  428. static void byte_input_handle_ok(ByteInputModel* model) {
  429. if(byte_input_keyboard_selected(model)) {
  430. uint8_t value = byte_input_get_row(model->selected_row)[model->selected_column].value;
  431. if(value == enter_symbol) {
  432. byte_input_call_input_callback(model);
  433. } else if(value == backspace_symbol) {
  434. model->bytes[model->selected_byte] = 0;
  435. model->selected_high_nibble = true;
  436. byte_input_dec_selected_byte(model);
  437. byte_input_call_changed_callback(model);
  438. } else {
  439. byte_input_set_nibble(
  440. model->bytes, model->selected_byte, value, model->selected_high_nibble);
  441. if(model->selected_high_nibble == true) {
  442. model->selected_high_nibble = false;
  443. } else {
  444. byte_input_inc_selected_byte(model);
  445. model->selected_high_nibble = true;
  446. }
  447. byte_input_call_changed_callback(model);
  448. }
  449. } else {
  450. byte_input_transition_from_keyboard(model);
  451. }
  452. }
  453. /**
  454. * @brief Draw callback
  455. *
  456. * @param canvas
  457. * @param _model
  458. */
  459. static void byte_input_view_draw_callback(Canvas* canvas, void* _model) {
  460. ByteInputModel* model = _model;
  461. canvas_clear(canvas);
  462. canvas_set_color(canvas, ColorBlack);
  463. canvas_draw_str(canvas, 2, 9, model->header);
  464. canvas_set_font(canvas, FontKeyboard);
  465. if(model->selected_row == -1) {
  466. byte_input_draw_input_selected(canvas, model);
  467. } else {
  468. byte_input_draw_input(canvas, model);
  469. }
  470. for(uint8_t row = 0; row < keyboard_row_count; row++) {
  471. const uint8_t column_count = byte_input_get_row_size(row);
  472. const ByteInputKey* keys = byte_input_get_row(row);
  473. for(size_t column = 0; column < column_count; column++) {
  474. if(keys[column].value == enter_symbol) {
  475. canvas_set_color(canvas, ColorBlack);
  476. if(model->selected_row == row && model->selected_column == column) {
  477. canvas_draw_icon_name(
  478. canvas,
  479. keyboard_origin_x + keys[column].x,
  480. keyboard_origin_y + keys[column].y,
  481. I_KeySaveSelected_24x11);
  482. } else {
  483. canvas_draw_icon_name(
  484. canvas,
  485. keyboard_origin_x + keys[column].x,
  486. keyboard_origin_y + keys[column].y,
  487. I_KeySave_24x11);
  488. }
  489. } else if(keys[column].value == backspace_symbol) {
  490. canvas_set_color(canvas, ColorBlack);
  491. if(model->selected_row == row && model->selected_column == column) {
  492. canvas_draw_icon_name(
  493. canvas,
  494. keyboard_origin_x + keys[column].x,
  495. keyboard_origin_y + keys[column].y,
  496. I_KeyBackspaceSelected_16x9);
  497. } else {
  498. canvas_draw_icon_name(
  499. canvas,
  500. keyboard_origin_x + keys[column].x,
  501. keyboard_origin_y + keys[column].y,
  502. I_KeyBackspace_16x9);
  503. }
  504. } else {
  505. if(model->selected_row == row && model->selected_column == column) {
  506. canvas_set_color(canvas, ColorBlack);
  507. canvas_draw_box(
  508. canvas,
  509. keyboard_origin_x + keys[column].x - 3,
  510. keyboard_origin_y + keys[column].y - 10,
  511. 11,
  512. 13);
  513. canvas_set_color(canvas, ColorWhite);
  514. } else if(model->selected_row == -1 && row == 0 && model->selected_column == column) {
  515. canvas_set_color(canvas, ColorBlack);
  516. canvas_draw_frame(
  517. canvas,
  518. keyboard_origin_x + keys[column].x - 3,
  519. keyboard_origin_y + keys[column].y - 10,
  520. 11,
  521. 13);
  522. } else {
  523. canvas_set_color(canvas, ColorBlack);
  524. }
  525. canvas_draw_glyph(
  526. canvas,
  527. keyboard_origin_x + keys[column].x,
  528. keyboard_origin_y + keys[column].y,
  529. keys[column].value);
  530. }
  531. }
  532. }
  533. }
  534. /**
  535. * @brief Input callback
  536. *
  537. * @param event
  538. * @param context
  539. * @return true
  540. * @return false
  541. */
  542. static bool byte_input_view_input_callback(InputEvent* event, void* context) {
  543. ByteInput* byte_input = context;
  544. furi_assert(byte_input);
  545. bool consumed = false;
  546. if(event->type == InputTypeShort || event->type == InputTypeRepeat) {
  547. switch(event->key) {
  548. case InputKeyLeft:
  549. with_view_model(
  550. byte_input->view, (ByteInputModel * model) {
  551. byte_input_handle_left(model);
  552. return true;
  553. });
  554. consumed = true;
  555. break;
  556. case InputKeyRight:
  557. with_view_model(
  558. byte_input->view, (ByteInputModel * model) {
  559. byte_input_handle_right(model);
  560. return true;
  561. });
  562. consumed = true;
  563. break;
  564. case InputKeyUp:
  565. with_view_model(
  566. byte_input->view, (ByteInputModel * model) {
  567. byte_input_handle_up(model);
  568. return true;
  569. });
  570. consumed = true;
  571. break;
  572. case InputKeyDown:
  573. with_view_model(
  574. byte_input->view, (ByteInputModel * model) {
  575. byte_input_handle_down(model);
  576. return true;
  577. });
  578. consumed = true;
  579. break;
  580. case InputKeyOk:
  581. with_view_model(
  582. byte_input->view, (ByteInputModel * model) {
  583. byte_input_handle_ok(model);
  584. return true;
  585. });
  586. consumed = true;
  587. break;
  588. default:
  589. break;
  590. }
  591. }
  592. return consumed;
  593. }
  594. /**
  595. * @brief Reset all input-related data in model
  596. *
  597. * @param model ByteInputModel
  598. */
  599. static void byte_input_reset_model_input_data(ByteInputModel* model) {
  600. model->bytes = NULL;
  601. model->bytes_count = 0;
  602. model->selected_high_nibble = true;
  603. model->selected_byte = 0;
  604. model->selected_row = 0;
  605. model->selected_column = 0;
  606. model->first_visible_byte = 0;
  607. }
  608. /**
  609. * @brief Allocate and initialize byte input. This byte input is used to enter bytes.
  610. *
  611. * @return ByteInput instance pointer
  612. */
  613. ByteInput* byte_input_alloc() {
  614. ByteInput* byte_input = furi_alloc(sizeof(ByteInput));
  615. byte_input->view = view_alloc();
  616. view_set_context(byte_input->view, byte_input);
  617. view_allocate_model(byte_input->view, ViewModelTypeLocking, sizeof(ByteInputModel));
  618. view_set_draw_callback(byte_input->view, byte_input_view_draw_callback);
  619. view_set_input_callback(byte_input->view, byte_input_view_input_callback);
  620. with_view_model(
  621. byte_input->view, (ByteInputModel * model) {
  622. model->header = "";
  623. model->input_callback = NULL;
  624. model->changed_callback = NULL;
  625. model->callback_context = NULL;
  626. byte_input_reset_model_input_data(model);
  627. return true;
  628. });
  629. return byte_input;
  630. }
  631. /**
  632. * @brief Deinitialize and free byte input
  633. *
  634. * @param byte_input Byte input instance
  635. */
  636. void byte_input_free(ByteInput* byte_input) {
  637. furi_assert(byte_input);
  638. view_free(byte_input->view);
  639. free(byte_input);
  640. }
  641. /**
  642. * @brief Get byte input view
  643. *
  644. * @param byte_input byte input instance
  645. * @return View instance that can be used for embedding
  646. */
  647. View* byte_input_get_view(ByteInput* byte_input) {
  648. furi_assert(byte_input);
  649. return byte_input->view;
  650. }
  651. /**
  652. * @brief Deinitialize and free byte input
  653. *
  654. * @param byte_input byte input instance
  655. * @param input_callback input callback fn
  656. * @param changed_callback changed callback fn
  657. * @param callback_context callback context
  658. * @param bytes buffer to use
  659. * @param bytes_count buffer length
  660. */
  661. void byte_input_set_result_callback(
  662. ByteInput* byte_input,
  663. ByteInputCallback input_callback,
  664. ByteChangedCallback changed_callback,
  665. void* callback_context,
  666. uint8_t* bytes,
  667. uint8_t bytes_count) {
  668. with_view_model(
  669. byte_input->view, (ByteInputModel * model) {
  670. byte_input_reset_model_input_data(model);
  671. model->input_callback = input_callback;
  672. model->changed_callback = changed_callback;
  673. model->callback_context = callback_context;
  674. model->bytes = bytes;
  675. model->bytes_count = bytes_count;
  676. return true;
  677. });
  678. }
  679. /**
  680. * @brief Set byte input header text
  681. *
  682. * @param byte_input byte input instance
  683. * @param text text to be shown
  684. */
  685. void byte_input_set_header_text(ByteInput* byte_input, const char* text) {
  686. with_view_model(
  687. byte_input->view, (ByteInputModel * model) {
  688. model->header = text;
  689. return true;
  690. });
  691. }