mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-27 06:50:21 +00:00
working version, change bits on the fly
This commit is contained in:
parent
649887fe0f
commit
1e63f57bf7
1 changed files with 20 additions and 19 deletions
|
@ -1,51 +1,52 @@
|
|||
#include "flipfrid_scene_select_field.h"
|
||||
|
||||
void flipfrid_center_displayed_key(FlipFridState* context, uint8_t index) {
|
||||
//const char* key_cstr = string_get_cstr(context->data_str);
|
||||
char key_cstr[18];
|
||||
uint8_t str_index = (index * 3);
|
||||
int data_len = sizeof(context->data) / sizeof(context->data[0]);
|
||||
|
||||
char str[20];
|
||||
int index_temp = 0;
|
||||
int key_index = 0;
|
||||
|
||||
for(uint8_t i = 0; i < data_len; i++) {
|
||||
index_temp += snprintf(&str[index_temp], 20-index_temp, "%x", context->data[i]);
|
||||
if(context->data[i] > 9 ) {
|
||||
key_index += snprintf(&key_cstr[key_index], 18-key_index, "%X ", context->data[i]);
|
||||
} else {
|
||||
key_index += snprintf(&key_cstr[key_index], 18-key_index, "0%X ", context->data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char display_menu[17] = {
|
||||
'X', 'X', ' ', 'X', 'X', ' ', '<', 'X', 'X', '>', ' ', 'X', 'X', ' ', 'X', 'X', '\0'};
|
||||
|
||||
if(index > 1) {
|
||||
display_menu[0] = str[str_index - 6];
|
||||
display_menu[1] = str[str_index - 5];
|
||||
display_menu[0] = key_cstr[str_index - 6];
|
||||
display_menu[1] = key_cstr[str_index - 5];
|
||||
} else {
|
||||
display_menu[0] = ' ';
|
||||
display_menu[1] = ' ';
|
||||
}
|
||||
|
||||
if(index > 0) {
|
||||
display_menu[3] = str[str_index - 3];
|
||||
display_menu[4] = str[str_index - 2];
|
||||
display_menu[3] = key_cstr[str_index - 3];
|
||||
display_menu[4] = key_cstr[str_index - 2];
|
||||
} else {
|
||||
display_menu[3] = ' ';
|
||||
display_menu[4] = ' ';
|
||||
}
|
||||
|
||||
display_menu[7] = str[str_index];
|
||||
display_menu[8] = str[str_index + 1];
|
||||
display_menu[7] = key_cstr[str_index];
|
||||
display_menu[8] = key_cstr[str_index + 1];
|
||||
|
||||
if((str_index + 4) <= (uint8_t)strlen(str)) {
|
||||
display_menu[11] = str[str_index + 3];
|
||||
display_menu[12] = str[str_index + 4];
|
||||
if((str_index + 4) <= (uint8_t)strlen(key_cstr)) {
|
||||
display_menu[11] = key_cstr[str_index + 3];
|
||||
display_menu[12] = key_cstr[str_index + 4];
|
||||
} else {
|
||||
display_menu[11] = ' ';
|
||||
display_menu[12] = ' ';
|
||||
}
|
||||
|
||||
if((str_index + 8) <= (uint8_t)strlen(str)) {
|
||||
display_menu[14] = str[str_index + 6];
|
||||
display_menu[15] = str[str_index + 7];
|
||||
if((str_index + 8) <= (uint8_t)strlen(key_cstr)) {
|
||||
display_menu[14] = key_cstr[str_index + 6];
|
||||
display_menu[15] = key_cstr[str_index + 7];
|
||||
} else {
|
||||
display_menu[14] = ' ';
|
||||
display_menu[15] = ' ';
|
||||
|
@ -143,5 +144,5 @@ void flipfrid_scene_select_field_on_draw(Canvas* canvas, FlipFridState* context)
|
|||
flipfrid_center_displayed_key(context, context->key_index);
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
canvas_draw_str_aligned(
|
||||
canvas, 64, 40, AlignCenter, AlignTop, string_get_cstr(context->notification_msg));
|
||||
canvas, 64, 45, AlignCenter, AlignTop, string_get_cstr(context->notification_msg));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue