浏览代码

use system() rather than popen() in FunKey menu

Signed-off-by: Michel-FK <michel.stempin@funkey-project.com>
Michel-FK 3 年之前
父节点
当前提交
77d912d3c6
共有 1 个文件被更改,包括 14 次插入57 次删除
  1. 14 57
      platform/common/menu_pico.c

+ 14 - 57
platform/common/menu_pico.c

@@ -691,7 +691,6 @@ void run_menu_loop()
     int start_scroll=0;
     uint8_t screen_refresh = 1;
     char shell_cmd[100];
-    FILE *fp;
     uint8_t menu_confirmation = 0;
     stop_menu_loop = 0;
     char fname[MAXPATHLEN];
@@ -712,10 +711,7 @@ void run_menu_loop()
             RES_HW_SCREEN_HORIZONTAL * RES_HW_SCREEN_VERTICAL * sizeof(uint16_t));
 
     /* Stop Ampli */
-    fp = popen(SHELL_CMD_TURN_AMPLI_OFF, "r");
-    if (fp != NULL) {
-        pclose(fp);
-    }
+    system(SHELL_CMD_TURN_AMPLI_OFF);
 
     /// ------ Wait for menu UP key event ------
     int actions[IN_BINDTYPE_COUNT] = { 0, };
@@ -805,12 +801,7 @@ void run_menu_loop()
 
                             /// ----- Shell cmd ----
                             sprintf(shell_cmd, "%s %d", SHELL_CMD_VOLUME_SET, volume_percentage);
-                            fp = popen(shell_cmd, "r");
-                            if (fp == NULL) {
-                                MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
-                            } else {
-            			        pclose(fp);
-            			    }
+                            system(shell_cmd);
 
                             /// ------ Refresh screen ------
                             screen_refresh = 1;
@@ -823,13 +814,9 @@ void run_menu_loop()
 
                             /// ----- Shell cmd ----
                             sprintf(shell_cmd, "%s %d", SHELL_CMD_BRIGHTNESS_SET, brightness_percentage);
-                            fp = popen(shell_cmd, "r");
-                            if (fp == NULL) {
-                                MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
-                            } else {
-			                     pclose(fp);
-                            }
-                        /// ------ Refresh screen ------
+                            system(shell_cmd);
+
+			    /// ------ Refresh screen ------
                             screen_refresh = 1;
                         }
                         else if(idx_menus[menuItem] == MENU_TYPE_SAVE){
@@ -881,12 +868,8 @@ void run_menu_loop()
 
                             /// ----- Shell cmd ----
                             sprintf(shell_cmd, "%s %d", SHELL_CMD_VOLUME_SET, volume_percentage);
-                            fp = popen(shell_cmd, "r");
-                            if (fp == NULL) {
-                                MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
-                            } else {
-			                     pclose(fp);
-                            }
+                            system(shell_cmd);
+
                             /// ------ Refresh screen ------
                             screen_refresh = 1;
                         }
@@ -898,12 +881,8 @@ void run_menu_loop()
 
                             /// ----- Shell cmd ----
                             sprintf(shell_cmd, "%s %d", SHELL_CMD_BRIGHTNESS_SET, brightness_percentage);
-                            fp = popen(shell_cmd, "r");
-                            if (fp == NULL) {
-                                MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
-                            } else {
-			                     pclose(fp);
-                            }
+                            system(shell_cmd);
+
                             /// ------ Refresh screen ------
                             screen_refresh = 1;
                         }
@@ -966,13 +945,7 @@ void run_menu_loop()
                                     sprintf(shell_cmd, "%s %d \"        SAVED IN SLOT %d\"",
                                         SHELL_CMD_NOTIF, NOTIF_SECONDS_DISP, state_slot+1);
                                 }
-                                fp = popen(shell_cmd, "r");
-                                if (fp == NULL) {
-                                    MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
-                				} else {
-                				    pclose(fp);
-                                }
-
+                                system(shell_cmd);
                                 stop_menu_loop = 1;
                             }
                             else{
@@ -1013,13 +986,7 @@ void run_menu_loop()
                                             SHELL_CMD_NOTIF, NOTIF_SECONDS_DISP, state_slot+1);
                                     }
                                 }
-                                fp = popen(shell_cmd, "r");
-                                if (fp == NULL) {
-                                    MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
-                				} else {
-                				    pclose(fp);
-                                }
-
+                                system(shell_cmd);
                                 /*snprintf(hud_msg, sizeof(hud_msg), ret == 0 ? "LOADED" : "FAIL!");
                                 hud_new_msg = 3;*/
                                 stop_menu_loop = 1;
@@ -1118,10 +1085,7 @@ void run_menu_loop()
     }
 
     /* Start Ampli */
-    fp = popen(SHELL_CMD_TURN_AMPLI_ON, "r");
-    if (fp != NULL) {
-        pclose(fp);
-    }
+    system(SHELL_CMD_TURN_AMPLI_ON);
 
     /// ------ Reset last screen ------
     SDL_BlitSurface(backup_hw_screen, NULL, hw_screen, NULL);
@@ -1151,13 +1115,9 @@ int launch_resume_menu_loop()
     uint8_t screen_refresh = 1;
     uint8_t menu_confirmation = 0;
     int option_idx=RESUME_YES;
-    FILE *fp;
 
     /* Stop Ampli */
-    fp = popen(SHELL_CMD_TURN_AMPLI_OFF, "r");
-    if (fp != NULL) {
-        pclose(fp);
-    }
+    system(SHELL_CMD_TURN_AMPLI_OFF);
 
     /* Save prev key repeat params and set new Key repeat */
     SDL_GetKeyRepeat(&backup_key_repeat_delay, &backup_key_repeat_interval);
@@ -1326,10 +1286,7 @@ int launch_resume_menu_loop()
     }
 
     /* Start Ampli */
-    fp = popen(SHELL_CMD_TURN_AMPLI_ON, "r");
-    if (fp != NULL) {
-        pclose(fp);
-    }
+    system(SHELL_CMD_TURN_AMPLI_ON);
 
     return option_idx;
 }