1- // Copyright (c) 2025 HIGH CODE LLC
2- //
3- // Licensed under the Apache License, Version 2.0 (the "License");
4- // you may not use this file except in compliance with the License.
5- // You may obtain a copy of the License at
6- //
7- // http://www.apache.org/licenses/LICENSE-2.0
8- //
9- // Unless required by applicable law or agreed to in writing, software
10- // distributed under the License is distributed on an "AS IS" BASIS,
11- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12- // See the License for the specific language governing permissions and
13- // limitations under the License.
14-
15-
161#include "menu_ui.h"
172#include "home_ui.h"
183#include "header_ui.h"
249#include <stdio.h>
2510#include <sys/stat.h>
2611#include "settings_ui.h"
12+ #include "buzzer.h"
2713
2814extern lv_group_t * main_group ;
2915static const char * TAG = "UI_MENU" ;
@@ -104,23 +90,16 @@ static void start_float_animation(lv_obj_t * obj) {
10490
10591static int get_visual_position (int item_idx ) {
10692 int diff = (item_idx - menu_index + MENU_ITEM_COUNT ) % MENU_ITEM_COUNT ;
107-
108- if (diff > MENU_ITEM_COUNT / 2 ) {
109- diff -= MENU_ITEM_COUNT ;
110- }
111-
93+ if (diff > MENU_ITEM_COUNT / 2 ) diff -= MENU_ITEM_COUNT ;
11294 int visual_pos = 3 + diff ;
113-
11495 if (visual_pos < 0 ) visual_pos = 0 ;
11596 if (visual_pos > 6 ) visual_pos = 6 ;
116-
11797 return visual_pos ;
11898}
11999
120100static void animate_item_to_position (int item_idx ) {
121101 lv_obj_t * obj = item_imgs [item_idx ];
122102 int pos_idx = get_visual_position (item_idx );
123-
124103 int frame_type = (pos_idx < 3 ) ? 1 : (pos_idx > 3 ) ? 2 : 0 ;
125104
126105 if (!menu_data [item_idx ].dscs [frame_type ]) {
@@ -148,15 +127,12 @@ static void animate_item_to_position(int item_idx) {
148127 lv_anim_set_var (& a , obj );
149128 lv_anim_set_duration (& a , 450 );
150129 lv_anim_set_path_cb (& a , lv_anim_path_ease_out );
151-
152130 lv_anim_set_values (& a , lv_obj_get_x_aligned (obj ), pos_x [pos_idx ]);
153131 lv_anim_set_exec_cb (& a , (lv_anim_exec_xcb_t )lv_obj_set_x );
154132 lv_anim_start (& a );
155-
156133 lv_anim_set_values (& a , lv_image_get_scale (obj ), scales [pos_idx ]);
157134 lv_anim_set_exec_cb (& a , (lv_anim_exec_xcb_t )lv_image_set_scale );
158135 lv_anim_start (& a );
159-
160136 lv_anim_set_values (& a , lv_obj_get_style_opa (obj , 0 ), opas [pos_idx ]);
161137 lv_anim_set_exec_cb (& a , (lv_anim_exec_xcb_t )lv_obj_set_style_opa );
162138 lv_anim_start (& a );
@@ -184,42 +160,30 @@ static void menu_update_ui(void) {
184160
185161static void menu_event_cb (lv_event_t * e ) {
186162 if (lv_event_get_code (e ) != LV_EVENT_KEY ) return ;
187-
188163 uint32_t key = lv_event_get_key (e );
189164
190165 if (key == LV_KEY_RIGHT ) {
166+ buzzer_scroll_tick ();
191167 menu_index = (menu_index + 1 ) % MENU_ITEM_COUNT ;
192168 menu_update_ui ();
193169 } else if (key == LV_KEY_LEFT ) {
170+ buzzer_scroll_tick ();
194171 menu_index = (menu_index == 0 ) ? MENU_ITEM_COUNT - 1 : menu_index - 1 ;
195172 menu_update_ui ();
196173 } else if (key == LV_KEY_ESC ) {
174+ buzzer_click ();
197175 ui_switch_screen (SCREEN_HOME );
198176 } else if (key == LV_KEY_ENTER ) {
177+ buzzer_hacker_confirm ();
199178 ESP_LOGI (TAG , "ENTRANDO NO SISTEMA: %s" , menu_data [menu_index ].name );
200-
201179 switch (menu_index ) {
202- case 0 : // BLUETOOTH
203- ui_switch_screen (SCREEN_BLE_MENU );
204- break ;
205- case 1 : // BAD USB
206- ui_switch_screen (SCREEN_BADUSB_MENU );
207- break ;
208- case 2 : // WIFI
209- ui_switch_screen (SCREEN_WIFI_MENU );
210- break ;
211- case 3 : // INFRARED
212- break ;
213- case 4 : //CONFIGS
214- ui_switch_screen (SCREEN_SETTINGS );
215- break ;
216- case 6 : // RADIO FREQUENCY
217- ui_switch_screen (SCREEN_SUBGHZ_SPECTRUM );
218- break ;
219- // ADD OUTROS //** TODO
220- default :
221- ESP_LOGW (TAG , "!!!Nenhuma tela definida!!!" );
222- break ;
180+ case 0 : ui_switch_screen (SCREEN_BLE_MENU ); break ;
181+ case 1 : ui_switch_screen (SCREEN_BADUSB_MENU ); break ;
182+ case 2 : ui_switch_screen (SCREEN_WIFI_MENU ); break ;
183+ case 3 : break ;
184+ case 4 : ui_switch_screen (SCREEN_SETTINGS ); break ;
185+ case 6 : ui_switch_screen (SCREEN_SUBGHZ_SPECTRUM ); break ;
186+ default : ESP_LOGW (TAG , "!!!Nenhuma tela definida!!!" ); break ;
223187 }
224188 }
225189}
@@ -271,4 +235,4 @@ void ui_menu_open(void) {
271235 lv_group_focus_obj (menu_screen );
272236 }
273237 lv_screen_load (menu_screen );
274- }
238+ }
0 commit comments