David Lee 2 лет назад
Родитель
Сommit
11a23cee6d

+ 3 - 0
docs/changelog.md

@@ -1,3 +1,6 @@
+## v1.1
+- New UI to Set Stations
+
 ## v1.0
 ## v1.0
 - Added support for TD174
 - Added support for TD174
 
 

+ 144 - 518
helpers/gui/int_input.c

@@ -10,25 +10,23 @@ struct IntInput {
 };
 };
 
 
 typedef struct {
 typedef struct {
-    const uint8_t value;
+    const char text;
     const uint8_t x;
     const uint8_t x;
     const uint8_t y;
     const uint8_t y;
 } IntInputKey;
 } IntInputKey;
 
 
 typedef struct {
 typedef struct {
     const char* header;
     const char* header;
-    uint8_t* bytes;
-    uint8_t bytes_count;
-
+    char* text_buffer;
+    size_t text_buffer_size;
+    bool clear_default_text;
+    
     IntInputCallback input_callback;
     IntInputCallback input_callback;
-    IntChangedCallback changed_callback;
+    //IntChangedCallback changed_callback;
     void* callback_context;
     void* callback_context;
 
 
-    bool selected_high_nibble;
-    uint8_t selected_byte;
-    int8_t selected_row; // row -2 - mini_editor, -1 - input, row 0 & 1 - keyboard
+    int8_t selected_row; 
     uint8_t selected_column;
     uint8_t selected_column;
-    uint8_t first_visible_byte;
 } IntInputModel;
 } IntInputModel;
 
 
 static const uint8_t keyboard_origin_x = 7;
 static const uint8_t keyboard_origin_x = 7;
@@ -36,7 +34,7 @@ static const uint8_t keyboard_origin_y = 31;
 static const uint8_t keyboard_row_count = 2;
 static const uint8_t keyboard_row_count = 2;
 static const uint8_t enter_symbol = '\r';
 static const uint8_t enter_symbol = '\r';
 static const uint8_t backspace_symbol = '\b';
 static const uint8_t backspace_symbol = '\b';
-static const uint8_t max_drawable_bytes = 8;
+//static const uint8_t max_drawable_digits = 4;
 
 
 static const IntInputKey keyboard_keys_row_1[] = {
 static const IntInputKey keyboard_keys_row_1[] = {
     {'0', 0, 12},
     {'0', 0, 12},
@@ -102,69 +100,23 @@ static const IntInputKey* int_input_get_row(uint8_t row_index) {
     return row;
     return row;
 }
 }
 
 
-/** Get text from nibble
- *
- * @param      byte         byte value
- * @param      high_nibble  Get from high nibble, otherwise low nibble
- *
- * @return     char nibble text
- */
-static char int_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;
-}
-
-const char num_to_char[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
-
 /** Draw input box (common view)
 /** Draw input box (common view)
  *
  *
  * @param      canvas  The canvas
  * @param      canvas  The canvas
  * @param      model   The model
  * @param      model   The model
  */
  */
 static void int_input_draw_input(Canvas* canvas, IntInputModel* model) {
 static void int_input_draw_input(Canvas* canvas, IntInputModel* model) {
-    const uint8_t text_x = 8;
-    const uint8_t text_y = 25;
-    const uint8_t text_y2 = 40;
-    const bool draw_index_line =
-        (model->selected_row == -2) &&
-        (model->first_visible_byte + MIN(model->bytes_count, max_drawable_bytes + 1) <= 100);
-
+    //const uint8_t text_x = 8;
+    //const uint8_t text_y = 25;
+    //const uint8_t text_y2 = 40;
+    UNUSED(model);
+    
     elements_slightly_rounded_frame(canvas, 6, 14, 116, 15);
     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);
+    //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;
+    /*for(uint8_t i = model->first_visible_byte;
         i < model->first_visible_byte + MIN(model->bytes_count, max_drawable_bytes);
         i < model->first_visible_byte + MIN(model->bytes_count, max_drawable_bytes);
         i++) {
         i++) {
         uint8_t byte_position = i - model->first_visible_byte;
         uint8_t byte_position = i - model->first_visible_byte;
@@ -248,249 +200,7 @@ static void int_input_draw_input(Canvas* canvas, IntInputModel* model) {
                     int_input_get_nibble_text(model->bytes[i], false));
                     int_input_get_nibble_text(model->bytes[i], false));
             }
             }
         }
         }
-
-        if(draw_index_line) {
-            canvas_draw_icon(canvas, 1, text_y + 8, &I_Hashmark_7x7);
-            canvas_draw_glyph(
-                canvas, text_x + 2 + byte_position * 14, text_y2, num_to_char[(i + 1) / 10]);
-
-            canvas_draw_glyph(
-                canvas, text_x + 8 + byte_position * 14, text_y2, num_to_char[(i + 1) % 10]);
-        }
-    }
-
-    if((model->selected_row == -2) &&
-       (model->first_visible_byte + MIN(model->bytes_count, max_drawable_bytes + 1) > 100)) {
-        char str[20];
-
-        canvas_set_font(canvas, FontSecondary);
-        snprintf(str, 20, "Selected index");
-        canvas_draw_str(canvas, text_x, text_y2, str);
-
-        canvas_set_font(canvas, FontPrimary);
-        snprintf(str, 20, "%u", (model->selected_byte + 1));
-        canvas_draw_str(canvas, text_x + 75, text_y2, str);
-    }
-}
-
-/** Draw input box (selected view)
- *
- * @param      canvas  The canvas
- * @param      model   The model
- */
-static void int_input_draw_input_selected(Canvas* canvas, IntInputModel* 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,
-                int_input_get_nibble_text(model->bytes[i], true));
-            canvas_draw_glyph(
-                canvas,
-                text_x + 8 + byte_position * 14,
-                text_y,
-                int_input_get_nibble_text(model->bytes[i], false));
-            canvas_invert_color(canvas);
-        } else {
-            if(model->first_visible_byte > 0 && i == model->first_visible_byte) {
-                canvas_draw_icon(
-                    canvas,
-                    text_x + 2 + byte_position * 14,
-                    text_y - 7,
-                    &I_More_data_placeholder_5x7);
-            } else {
-                canvas_draw_glyph(
-                    canvas,
-                    text_x + 2 + byte_position * 14,
-                    text_y,
-                    int_input_get_nibble_text(model->bytes[i], true));
-            }
-            if(model->bytes_count - model->first_visible_byte > max_drawable_bytes &&
-               i == model->first_visible_byte + MIN(model->bytes_count, max_drawable_bytes) - 1) {
-                canvas_draw_icon(
-                    canvas,
-                    text_x + 8 + byte_position * 14,
-                    text_y - 7,
-                    &I_More_data_placeholder_5x7);
-            } else {
-                canvas_draw_glyph(
-                    canvas,
-                    text_x + 8 + byte_position * 14,
-                    text_y,
-                    int_input_get_nibble_text(model->bytes[i], false));
-            }
-        }
-    }
-
-    canvas_invert_color(canvas);
-}
-
-/** 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 int_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;
-    }
-}*/
-
-/** What currently selected
- *
- * @param      model  The model
- *
- * @return     true - keyboard selected, false - input selected
- */
-static bool int_input_keyboard_selected(IntInputModel* model) {
-    return model->selected_row >= 0;
-}
-
-/** Do transition from keyboard
- *
- * @param      model  The model
- */
-static void int_input_transition_from_keyboard(IntInputModel* model) {
-    model->selected_row += 1;
-    model->selected_high_nibble = true;
-}
-
-/** Increase selected byte position
- *
- * @param      model  The model
- */
-static void int_input_inc_selected_byte(IntInputModel* 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++;
-                }
-            }
-        }
-    }
-}
-
-static void int_input_inc_selected_byte_mini(IntInputModel* model) {
-    if((model->selected_byte < model->bytes_count - 1) || model->selected_high_nibble) {
-        if(!model->selected_high_nibble) {
-            model->selected_high_nibble = !model->selected_high_nibble; //-V547
-            int_input_inc_selected_byte(model);
-        } else {
-            model->selected_high_nibble = !model->selected_high_nibble; //-V547
-        }
-    }
-}
-
-/** Decrease selected byte position
- *
- * @param      model  The model
- */
-static void int_input_dec_selected_byte(IntInputModel* model) {
-    if(model->selected_byte > 0) {
-        model->selected_byte -= 1;
-
-        furi_assert(model->selected_byte >= model->first_visible_byte);
-        if(model->selected_byte - model->first_visible_byte < 1) {
-            if(model->first_visible_byte > 0) {
-                model->first_visible_byte--;
-            }
-        }
-    }
-}
-
-static void int_input_dec_selected_byte_mini(IntInputModel* model) {
-    if(model->selected_byte > 0 || !model->selected_high_nibble) {
-        if(model->selected_high_nibble) {
-            model->selected_high_nibble = !model->selected_high_nibble; //-V547
-            int_input_dec_selected_byte(model);
-        } else {
-            model->selected_high_nibble = !model->selected_high_nibble; //-V547
-        }
-    }
-}
-
-/** Call input callback
- *
- * @param      model  The model
- */
-static void int_input_call_input_callback(IntInputModel* model) {
-    if(model->input_callback != NULL) {
-        model->input_callback(model->callback_context);
-    }
-}
-
-/** Call changed callback
- *
- * @param      model  The model
- */
-static void int_input_call_changed_callback(IntInputModel* model) {
-    if(model->changed_callback != NULL) {
-        model->changed_callback(model->callback_context);
-    }
-}
-
-/** Clear selected byte
- *
- * @param      model  The model
- */
-
-static void int_input_clear_selected_byte(IntInputModel* model) {
-    model->bytes[model->selected_byte] = 0;
-    model->selected_high_nibble = true;
-    int_input_dec_selected_byte(model);
-    int_input_call_changed_callback(model);
+    }*/
 }
 }
 
 
 /** Handle up button
 /** Handle up button
@@ -498,18 +208,8 @@ static void int_input_clear_selected_byte(IntInputModel* model) {
  * @param      model  The model
  * @param      model  The model
  */
  */
 static void int_input_handle_up(IntInputModel* model) {
 static void int_input_handle_up(IntInputModel* model) {
-    if(model->selected_row > -2) {
-        model->selected_row -= 1;
-    } else if(model->selected_row == -2) {
-        if(!model->selected_high_nibble) {
-            model->bytes[model->selected_byte] = (model->bytes[model->selected_byte] & 0xF0) |
-                                                 ((model->bytes[model->selected_byte] + 1) & 0x0F);
-        } else {
-            model->bytes[model->selected_byte] =
-                ((model->bytes[model->selected_byte] + 0x10) & 0xF0) |
-                (model->bytes[model->selected_byte] & 0x0F);
-        }
-        int_input_call_changed_callback(model);
+    if(model->selected_row > 0) {
+        model->selected_row--;
     }
     }
 }
 }
 
 
@@ -518,24 +218,8 @@ static void int_input_handle_up(IntInputModel* model) {
  * @param      model  The model
  * @param      model  The model
  */
  */
 static void int_input_handle_down(IntInputModel* model) {
 static void int_input_handle_down(IntInputModel* model) {
-    if(model->selected_row != -2) {
-        if(int_input_keyboard_selected(model)) {
-            if(model->selected_row < keyboard_row_count - 1) {
-                model->selected_row += 1;
-            }
-        } else {
-            int_input_transition_from_keyboard(model);
-        }
-    } else {
-        if(!model->selected_high_nibble) {
-            model->bytes[model->selected_byte] = (model->bytes[model->selected_byte] & 0xF0) |
-                                                 ((model->bytes[model->selected_byte] - 1) & 0x0F);
-        } else {
-            model->bytes[model->selected_byte] =
-                ((model->bytes[model->selected_byte] - 0x10) & 0xF0) |
-                (model->bytes[model->selected_byte] & 0x0F);
-        }
-        int_input_call_changed_callback(model);
+    if(model->selected_row < keyboard_row_count - 1) {
+        model->selected_row += 1;
     }
     }
 }
 }
 
 
@@ -544,18 +228,10 @@ static void int_input_handle_down(IntInputModel* model) {
  * @param      model  The model
  * @param      model  The model
  */
  */
 static void int_input_handle_left(IntInputModel* model) {
 static void int_input_handle_left(IntInputModel* model) {
-    if(int_input_keyboard_selected(model)) {
-        if(model->selected_column > 0) {
-            model->selected_column -= 1;
-        } else {
-            model->selected_column = int_input_get_row_size(model->selected_row) - 1;
-        }
+    if(model->selected_column > 0) {
+        model->selected_column--;
     } else {
     } else {
-        if(model->selected_row != -2) {
-            int_input_dec_selected_byte(model);
-        } else {
-            int_input_dec_selected_byte_mini(model);
-        }
+        model->selected_column = int_input_get_row_size(model->selected_row) - 1;
     }
     }
 }
 }
 
 
@@ -564,18 +240,10 @@ static void int_input_handle_left(IntInputModel* model) {
  * @param      model  The model
  * @param      model  The model
  */
  */
 static void int_input_handle_right(IntInputModel* model) {
 static void int_input_handle_right(IntInputModel* model) {
-    if(int_input_keyboard_selected(model)) {
-        if(model->selected_column < int_input_get_row_size(model->selected_row) - 1) {
-            model->selected_column += 1;
-        } else {
-            model->selected_column = 0;
-        }
+    if(model->selected_column < int_input_get_row_size(model->selected_row) - 1) {
+        model->selected_column++;
     } else {
     } else {
-        if(model->selected_row != -2) {
-            int_input_inc_selected_byte(model);
-        } else {
-            int_input_inc_selected_byte_mini(model);
-        }
+        model->selected_column = 0;
     }
     }
 }
 }
 
 
@@ -584,29 +252,26 @@ static void int_input_handle_right(IntInputModel* model) {
  * @param      model  The model
  * @param      model  The model
  */
  */
 static void int_input_handle_ok(IntInputModel* model) {
 static void int_input_handle_ok(IntInputModel* model) {
-    if(int_input_keyboard_selected(model)) {
-        uint8_t value = int_input_get_row(model->selected_row)[model->selected_column].value;
-
-        if(value == enter_symbol) {
-            int_input_call_input_callback(model);
-        } else if(value == backspace_symbol) {
-            int_input_clear_selected_byte(model);
-        } else {
-            /*int_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 {
-                int_input_inc_selected_byte(model);
-                model->selected_high_nibble = true;
-            }
-            int_input_call_changed_callback(model);*/
-        }
-    } else if(model->selected_row == -2) {
-        int_input_call_input_callback(model);
+    char selected = int_input_get_row(model->selected_row)[model->selected_column].text;
+    size_t text_length = strlen(model->text_buffer);
+UNUSED(text_length);
+    if(selected == enter_symbol) {
+    //    int_input_call_input_callback(model);
+    } else if(selected == backspace_symbol) {
+        //int_input_clear_selected_byte(model);
     } else {
     } else {
-        int_input_transition_from_keyboard(model);
+        if (model->clear_default_text) {
+            text_length = 0;
+        }
+        if(text_length < (model->text_buffer_size - 1)) {
+            //model->text_buffer[text_length] = selected;
+            //model->text_buffer[text_length + 1] = 0;
+            //FURI_LOG_D("INT_INPUT", model->text_buffer);
+            FURI_LOG_D("INT_INPUT", "%u", text_length);
+            FURI_LOG_D("INT_INPUT", "%u", model->text_buffer_size);
+        }
     }
     }
+    model->clear_default_text = false;
 }
 }
 
 
 /** Draw callback
 /** Draw callback
@@ -616,98 +281,86 @@ static void int_input_handle_ok(IntInputModel* model) {
  */
  */
 static void int_input_view_draw_callback(Canvas* canvas, void* _model) {
 static void int_input_view_draw_callback(Canvas* canvas, void* _model) {
     IntInputModel* model = _model;
     IntInputModel* model = _model;
+    uint8_t text_length = model->text_buffer ? strlen(model->text_buffer) : 0;
+    UNUSED(text_length);
+    //uint8_t needed_string_width = canvas_width(canvas) - 8;
+    //uint8_t start_pos = 4;
+
+    //const char* text = model->text_buffer;
 
 
     canvas_clear(canvas);
     canvas_clear(canvas);
     canvas_set_color(canvas, ColorBlack);
     canvas_set_color(canvas, ColorBlack);
+    
+    int_input_draw_input(canvas, model);
+    
+    canvas_set_font(canvas, FontSecondary);
+    canvas_draw_str(canvas, 2, 9, model->header);
     canvas_set_font(canvas, FontKeyboard);
     canvas_set_font(canvas, FontKeyboard);
-
-    if(model->selected_row == -1) {
-        int_input_draw_input_selected(canvas, model);
-    } else {
-        int_input_draw_input(canvas, model);
-    }
-
-    if(model->selected_row == -2) {
-        canvas_set_font(canvas, FontSecondary);
-        canvas_draw_icon(canvas, 3, 1, &I_Pin_back_arrow_10x8);
-        canvas_draw_str_aligned(canvas, 16, 9, AlignLeft, AlignBottom, "back to keyboard");
-        elements_button_center(canvas, "Save");
-    } else {
-        // Draw the header
-        canvas_set_font(canvas, FontSecondary);
-        if(model->selected_row == -1) {
-            canvas_draw_str(canvas, 10, 9, "Move up for alternate input");
-            canvas_draw_icon(canvas, 3, 4, &I_SmallArrowUp_3x5);
-        } else {
-            canvas_draw_str(canvas, 2, 9, model->header);
-        }
-        canvas_set_font(canvas, FontKeyboard);
-        // Draw keyboard
-        for(uint8_t row = 0; row < keyboard_row_count; row++) {
-            const uint8_t column_count = int_input_get_row_size(row);
-            const IntInputKey* keys = int_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);
-                    }
+    // Draw keyboard
+    for(uint8_t row = 0; row < keyboard_row_count; row++) {
+        const uint8_t column_count = int_input_get_row_size(row);
+        const IntInputKey* keys = int_input_get_row(row);
+
+        for(size_t column = 0; column < column_count; column++) {
+            if(keys[column].text == 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 {
                 } 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_draw_icon(
                         canvas,
                         canvas,
                         keyboard_origin_x + keys[column].x,
                         keyboard_origin_x + keys[column].x,
                         keyboard_origin_y + keys[column].y,
                         keyboard_origin_y + keys[column].y,
-                        keys[column].value);
+                        &I_KeySave_24x11);
                 }
                 }
+            } else if(keys[column].text == 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].text);
             }
             }
         }
         }
     }
     }
@@ -724,66 +377,37 @@ static void int_input_view_draw_callback(Canvas* canvas, void* _model) {
 static bool int_input_view_input_callback(InputEvent* event, void* context) {
 static bool int_input_view_input_callback(InputEvent* event, void* context) {
     IntInput* int_input = context;
     IntInput* int_input = context;
     furi_assert(int_input);
     furi_assert(int_input);
+
     bool consumed = false;
     bool consumed = false;
+    
+    // Fetch the model
+    IntInputModel* model = view_get_model(int_input->view);
 
 
-    if(event->type == InputTypeShort || event->type == InputTypeRepeat) {
+    if(event->type == InputTypeShort || event->type == InputTypeLong || event->type == InputTypeRepeat) {
+        consumed = true;
         switch(event->key) {
         switch(event->key) {
         case InputKeyLeft:
         case InputKeyLeft:
-            with_view_model(
-                int_input->view, IntInputModel * model, { int_input_handle_left(model); }, true);
-            consumed = true;
+            int_input_handle_left(model);
             break;
             break;
         case InputKeyRight:
         case InputKeyRight:
-            with_view_model(
-                int_input->view,
-                IntInputModel * model,
-                { int_input_handle_right(model); },
-                true);
-            consumed = true;
+            int_input_handle_right(model);
             break;
             break;
         case InputKeyUp:
         case InputKeyUp:
-            with_view_model(
-                int_input->view, IntInputModel * model, { int_input_handle_up(model); }, true);
-            consumed = true;
+            int_input_handle_up(model);
             break;
             break;
         case InputKeyDown:
         case InputKeyDown:
-            with_view_model(
-                int_input->view, IntInputModel * model, { int_input_handle_down(model); }, true);
-            consumed = true;
+            int_input_handle_down(model);
             break;
             break;
         case InputKeyOk:
         case InputKeyOk:
-            with_view_model(
-                int_input->view, IntInputModel * model, { int_input_handle_ok(model); }, true);
-            consumed = true;
+            int_input_handle_ok(model);
             break;
             break;
         default:
         default:
             break;
             break;
         }
         }
     }
     }
 
 
-    if(event->type == InputTypeShort && event->key == InputKeyBack) {
-        // Back to keyboard
-        with_view_model(
-            int_input->view,
-            IntInputModel * model,
-            {
-                if(model->selected_row == -2) {
-                    model->selected_row += 1;
-                    consumed = true;
-                };
-            },
-            true);
-    }
-
-    if((event->type == InputTypeLong || event->type == InputTypeRepeat) &&
-       event->key == InputKeyBack) {
-        with_view_model(
-            int_input->view,
-            IntInputModel * model,
-            { int_input_clear_selected_byte(model); },
-            true);
-        consumed = true;
-    }
+    // commit view
+    view_commit_model(int_input->view, consumed);
 
 
     return consumed;
     return consumed;
 }
 }
@@ -793,13 +417,8 @@ static bool int_input_view_input_callback(InputEvent* event, void* context) {
  * @param      model  The model
  * @param      model  The model
  */
  */
 static void int_input_reset_model_input_data(IntInputModel* model) {
 static void int_input_reset_model_input_data(IntInputModel* model) {
-    model->bytes = NULL;
-    model->bytes_count = 0;
-    model->selected_high_nibble = true;
-    model->selected_byte = 0;
     model->selected_row = 0;
     model->selected_row = 0;
     model->selected_column = 0;
     model->selected_column = 0;
-    model->first_visible_byte = 0;
 }
 }
 
 
 IntInput* int_input_alloc() {
 IntInput* int_input_alloc() {
@@ -816,7 +435,7 @@ IntInput* int_input_alloc() {
         {
         {
             model->header = "";
             model->header = "";
             model->input_callback = NULL;
             model->input_callback = NULL;
-            model->changed_callback = NULL;
+           // model->changed_callback = NULL;
             model->callback_context = NULL;
             model->callback_context = NULL;
             int_input_reset_model_input_data(model);
             int_input_reset_model_input_data(model);
         },
         },
@@ -839,25 +458,32 @@ View* int_input_get_view(IntInput* int_input) {
 void int_input_set_result_callback(
 void int_input_set_result_callback(
     IntInput* int_input,
     IntInput* int_input,
     IntInputCallback input_callback,
     IntInputCallback input_callback,
-    IntChangedCallback changed_callback,
+    //IntChangedCallback changed_callback,
     void* callback_context,
     void* callback_context,
-    uint8_t* bytes,
-    uint8_t bytes_count) {
+    char* text_buffer,
+    size_t text_buffer_size,
+    bool clear_default_text) {
+    //UNUSED(changed_callback);
     with_view_model(
     with_view_model(
         int_input->view,
         int_input->view,
         IntInputModel * model,
         IntInputModel * model,
         {
         {
             int_input_reset_model_input_data(model);
             int_input_reset_model_input_data(model);
             model->input_callback = input_callback;
             model->input_callback = input_callback;
-            model->changed_callback = changed_callback;
             model->callback_context = callback_context;
             model->callback_context = callback_context;
-            model->bytes = bytes;
-            model->bytes_count = bytes_count;
+            model->text_buffer = text_buffer;
+            model->text_buffer_size = text_buffer_size;
+            model->clear_default_text = clear_default_text;
         },
         },
         true);
         true);
 }
 }
 
 
 void int_input_set_header_text(IntInput* int_input, const char* text) {
 void int_input_set_header_text(IntInput* int_input, const char* text) {
     with_view_model(
     with_view_model(
-        int_input->view, IntInputModel * model, { model->header = text; }, true);
+        int_input->view, 
+        IntInputModel * model, 
+        { 
+            model->header = text; 
+        }, 
+        true);
 }
 }

+ 12 - 9
helpers/gui/int_input.h

@@ -42,20 +42,23 @@ View* int_input_get_view(IntInput* int_input);
 
 
 /** Set byte input result callback
 /** Set byte input result callback
  *
  *
- * @param      int_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
+ * @param      int_input          byte input instance
+ * @param      input_callback     input callback fn
+ * @param      changed_callback   changed callback fn
+ * @param      callback_context   callback context
+ * @param      text_buffer        buffer to use
+ * @param      text_buffer_size   buffer length
+ * @param      clear_default_text clear previous entry
  */
  */
+
 void int_input_set_result_callback(
 void int_input_set_result_callback(
     IntInput* int_input,
     IntInput* int_input,
     IntInputCallback input_callback,
     IntInputCallback input_callback,
-    IntChangedCallback changed_callback,
+    //IntChangedCallback changed_callback,
     void* callback_context,
     void* callback_context,
-    uint8_t* bytes,
-    uint8_t bytes_count);
+    char* text_buffer,
+    size_t text_buffer_size,
+    bool clear_default_text);
 
 
 /** Set byte input header text
 /** Set byte input header text
  *
  *

+ 21 - 0
helpers/meal_pager_storage.c

@@ -178,6 +178,7 @@ void meal_pager_read_settings(void* context) {
     }
     }
 
 
     flipper_format_read_uint32(fff_file, MEAL_PAGER_SETTINGS_KEY_PAGER_TYPE, &app->pager_type, 1);
     flipper_format_read_uint32(fff_file, MEAL_PAGER_SETTINGS_KEY_PAGER_TYPE, &app->pager_type, 1);
+    meal_pager_set_max_values(app);
     flipper_format_read_uint32(
     flipper_format_read_uint32(
         fff_file, MEAL_PAGER_SETTINGS_KEY_FIRST_STATION, &app->first_station, 1);
         fff_file, MEAL_PAGER_SETTINGS_KEY_FIRST_STATION, &app->first_station, 1);
     flipper_format_read_uint32(
     flipper_format_read_uint32(
@@ -196,4 +197,24 @@ void meal_pager_read_settings(void* context) {
 
 
     meal_pager_close_config_file(fff_file);
     meal_pager_close_config_file(fff_file);
     meal_pager_close_storage();
     meal_pager_close_storage();
+}
+
+void meal_pager_set_max_values(void* context)
+{
+    Meal_Pager* app = context;
+    switch (app->pager_type) {
+        case Meal_PagerPagerTypeT119:
+        case Meal_PagerPagerTypeTD165:
+            app->max_station = 8191;
+            app->max_pager = 999;
+            break;
+        case Meal_PagerPagerTypeTD174:
+            app->max_station = 8191;
+            app->max_pager = 10;
+            break;
+        case Meal_PagerPagerTypeTD157:
+            app->max_station = 1023;
+            app->max_pager = 999;
+            break;
+    }
 }
 }

+ 2 - 1
helpers/meal_pager_storage.h

@@ -34,4 +34,5 @@ bool meal_pager_save_subghz_buffer_file_start(void* context, FlipperFormat* ff,
 void meal_pager_save_subghz_buffer_stop(void* context, FlipperFormat* ff);
 void meal_pager_save_subghz_buffer_stop(void* context, FlipperFormat* ff);
 
 
 void meal_pager_save_settings(void* context);
 void meal_pager_save_settings(void* context);
-void meal_pager_read_settings(void* context);
+void meal_pager_read_settings(void* context);
+void meal_pager_set_max_values(void* context);

+ 13 - 8
scenes/meal_pager_scene_set_station.c

@@ -1,5 +1,6 @@
 #include "../meal_pager_i.h"
 #include "../meal_pager_i.h"
 #include "../helpers/meal_pager_custom_event.h"
 #include "../helpers/meal_pager_custom_event.h"
+#include "../helpers/meal_pager_storage.h"
 #include "../helpers/retekess/meal_pager_retekess_t119.h"
 #include "../helpers/retekess/meal_pager_retekess_t119.h"
 #include "../helpers/retekess/meal_pager_retekess_td157.h"
 #include "../helpers/retekess/meal_pager_retekess_td157.h"
 #include "../helpers/retekess/meal_pager_retekess_td165.h"
 #include "../helpers/retekess/meal_pager_retekess_td165.h"
@@ -18,27 +19,31 @@ void meal_pager_set_station_callback(Meal_PagerCustomEvent event, void* context)
     UNUSED(event);
     UNUSED(event);
 }
 }
 
 
-/*static void meal_pager_int_input_callback(void* context) {
+static void meal_pager_int_input_callback(void* context) {
     furi_assert(context);
     furi_assert(context);
     Meal_Pager* app = context;
     Meal_Pager* app = context;
     view_dispatcher_send_custom_event(app->view_dispatcher, Meal_PagerCustomerEventIntInput);
     view_dispatcher_send_custom_event(app->view_dispatcher, Meal_PagerCustomerEventIntInput);
-}*/
+}
 
 
 void meal_pager_scene_set_station_on_enter(void* context) {
 void meal_pager_scene_set_station_on_enter(void* context) {
     furi_assert(context);
     furi_assert(context);
     Meal_Pager* app = context;
     Meal_Pager* app = context;
     IntInput* int_input = app->int_input;
     IntInput* int_input = app->int_input;
     uint8_t enter_name_length = 4;
     uint8_t enter_name_length = 4;
-
-    int_input_set_header_text(int_input, "Set first Station (0 - 8191)");
-
-    /*int_input_set_result_callback(
+    meal_pager_set_max_values(app);
+    char *str = "Set first Station (0 - 9999)";
+    const char *constStr = str;
+    snprintf(str, 36, "Set first Station (0 - %lu)", app->max_station);
+    
+    int_input_set_header_text(int_input, constStr);
+    
+    int_input_set_result_callback(
         int_input,
         int_input,
         meal_pager_int_input_callback,
         meal_pager_int_input_callback,
         context,
         context,
         app->text_buffer,
         app->text_buffer,
-        &enter_name_length,
-        false);*/
+        enter_name_length,
+        false);
         
         
     UNUSED(app);
     UNUSED(app);
     UNUSED(enter_name_length);
     UNUSED(enter_name_length);