Browse Source

Merge pc_monitor from https://github.com/TheSainEyereg/flipper-pc-monitor

# Conflicts:
#	pc_monitor/.github/workflows/build.yml
#	pc_monitor/helpers/ble_serial.c
#	pc_monitor/helpers/ble_serial.h
#	pc_monitor/pc_monitor.h
Willy-JL 9 tháng trước cách đây
mục cha
commit
3dc3cd0919

+ 16 - 1
pc_monitor/CHANGELOG.md

@@ -1,3 +1,18 @@
-## v1.0
+## 1.1.2
+
+- Blue LED blinks on data reception
+- Backlight is now enabled during communication
+
+## 1.1.1
+
+- Bump for README acknowledgement fixes
+
+## 1.1.0
+
+- Fixed app for latest firmware
+- Desktop app QR code
+- Minor code refactoring
+
+## 1.0.0
 
 - Stable release.

+ 3 - 1
pc_monitor/README.md

@@ -1,4 +1,6 @@
 # PC Monitor
 Flipper Application for monitoring PC resources
 
-**[A backend running on your PC is required](https://github.com/TheSainEyereg/flipper-pc-monitor-backend/releases)**
+**[A backend running on your PC is required](https://github.com/TheSainEyereg/flipper-pc-monitor-backend/releases)**
+
+Many thanks to [Willy-JL](https://github.com/Willy-JL) for implementing BLE Serial for the new firmware and bringing the app back to life

+ 3 - 2
pc_monitor/application.fam

@@ -7,7 +7,8 @@ App(
     stack_size=1 * 1024,
     fap_description="Application for monitoring PC resources",
     fap_category="Bluetooth",
-    fap_icon="icons/icon_10px.png",
-    fap_version="1.0",
+    fap_icon_assets="assets",
+    fap_icon="assets/icon_10px.png",
+    fap_version="1.1.2",
     fap_author="Olejka",
 )

BIN
pc_monitor/assets/icon_10px.png


BIN
pc_monitor/assets/qr_33px.png


+ 7 - 0
pc_monitor/helpers/ble_serial.c

@@ -1,3 +1,10 @@
+/*
+ * This code is based on the Willy-JL's (https://github.com/Willy-JL) BLE fix.
+ * 
+ * Thank you to Willy-JL for providing this code and making it available under the https://github.com/Flipper-XFW/Xtreme-Apps repository.
+ * Your contribution has been invaluable for this project.
+ */
+
 #include "ble_serial.h"
 
 #include <gap.h>

+ 7 - 0
pc_monitor/helpers/ble_serial.h

@@ -1,3 +1,10 @@
+/*
+ * This code is based on the Willy-JL's (https://github.com/Willy-JL) BLE fix.
+ * 
+ * Thank you to Willy-JL for providing this code and making it available under the https://github.com/Flipper-XFW/Xtreme-Apps repository.
+ * Your contribution has been invaluable for this project.
+ */
+
 #pragma once
 
 #include <furi_ble/profile_interface.h>

BIN
pc_monitor/icons/icon_10px.pdn


BIN
pc_monitor/icons/icon_10px.png


+ 17 - 100
pc_monitor/pc_monitor.c

@@ -4,106 +4,18 @@ static void render_callback(Canvas* canvas, void* ctx) {
     furi_assert(ctx);
     PcMonitorApp* app = ctx;
 
-    if(app->bt_state == BtStateRecieving) {
-        canvas_clear(canvas);
-        canvas_set_color(canvas, ColorBlack);
-        canvas_set_font(canvas, FontKeyboard);
-
-        uint8_t line = 0;
-        uint8_t spacing = app->lines_count ? SCREEN_HEIGHT / app->lines_count : 0;
-        uint8_t margin_top = spacing ? (spacing - LINE_HEIGHT) / 2 : 0;
-        char str[32];
-
-        if(app->data.cpu_usage <= 100) {
-            if(app->lines_count) {
-                canvas_draw_str(canvas, 1, margin_top + line * spacing + 9, "CPU");
-                snprintf(str, 32, "%d%%", app->data.cpu_usage);
-                elements_progress_bar_with_text(
-                    canvas,
-                    BAR_X,
-                    margin_top + line * spacing,
-                    BAR_WIDTH,
-                    app->data.cpu_usage / 100.0f,
-                    str);
-            }
-
-            line++;
-        }
-
-        if(app->data.ram_usage <= 100) {
-            if(app->lines_count) {
-                canvas_draw_str(canvas, 1, margin_top + line * spacing + 9, "RAM");
-                snprintf(
-                    str,
-                    32,
-                    "%.1f/%.1f %s",
-                    (double)(app->data.ram_max * 0.1f * app->data.ram_usage * 0.01f),
-                    (double)(app->data.ram_max * 0.1f),
-                    app->data.ram_unit);
-                elements_progress_bar_with_text(
-                    canvas,
-                    BAR_X,
-                    margin_top + line * spacing,
-                    BAR_WIDTH,
-                    app->data.ram_usage * 0.01f,
-                    str);
-            }
-
-            line++;
-        }
-
-        if(app->data.gpu_usage <= 100) {
-            if(app->lines_count) {
-                canvas_draw_str(canvas, 1, margin_top + line * spacing + 9, "GPU");
-                snprintf(str, 32, "%d%%", app->data.gpu_usage);
-                elements_progress_bar_with_text(
-                    canvas,
-                    BAR_X,
-                    margin_top + line * spacing,
-                    BAR_WIDTH,
-                    app->data.gpu_usage / 100.0f,
-                    str);
-            }
-
-            line++;
-        }
-
-        if(app->data.vram_usage <= 100) {
-            if(app->lines_count) {
-                canvas_draw_str(canvas, 1, margin_top + line * spacing + 9, "VRAM");
-                snprintf(
-                    str,
-                    32,
-                    "%.1f/%.1f %s",
-                    (double)(app->data.vram_max * 0.1f * app->data.vram_usage * 0.01f),
-                    (double)(app->data.vram_max * 0.1f),
-                    app->data.vram_unit);
-                elements_progress_bar_with_text(
-                    canvas,
-                    BAR_X,
-                    margin_top + line * spacing,
-                    BAR_WIDTH,
-                    app->data.vram_usage * 0.01f,
-                    str);
-            }
-
-            line++;
-        }
-
-        if(line == 0) app->bt_state = BtStateNoData;
-        app->lines_count = line;
-    } else {
-        canvas_draw_str_aligned(
-            canvas,
-            64,
-            32,
-            AlignCenter,
-            AlignCenter,
-            app->bt_state == BtStateChecking ? "Checking BLE..." :
-            app->bt_state == BtStateInactive ? "BLE inactive!" :
-            app->bt_state == BtStateWaiting  ? "Waiting for data..." :
-            app->bt_state == BtStateLost     ? "Connection lost!" :
-                                               "No data!");
+    switch(app->bt_state) {
+    case BtStateWaiting:
+        draw_connect_view(canvas);
+        break;
+
+    case BtStateRecieving:
+        draw_bars_view(canvas, app);
+        break;
+
+    default:
+        draw_status_view(canvas, app);
+        break;
     }
 }
 
@@ -129,6 +41,11 @@ static uint16_t bt_serial_callback(SerialServiceEvent event, void* ctx) {
             memcpy(&app->data, event.data.buffer, sizeof(DataStruct));
             app->bt_state = BtStateRecieving;
             app->last_packet = furi_hal_rtc_get_timestamp();
+
+            // Elegant solution, the backlight is only on when there is continuous communication
+            notification_message(app->notification, &sequence_display_backlight_on);
+
+            notification_message(app->notification, &sequence_blink_blue_10);
         }
     }
 

+ 4 - 1
pc_monitor/pc_monitor.h

@@ -11,8 +11,11 @@
 #include <input/input.h>
 #include <storage/storage.h>
 
-#define TAG "PCMonitor"
+#include "views/bars_view.h"
+#include "views/connect_view.h"
+#include "views/status_view.h"
 
+#define TAG                   "PCMonitor"
 #define BT_SERIAL_BUFFER_SIZE 128
 
 #define SCREEN_HEIGHT 64

BIN
pc_monitor/screenshots/0.png


BIN
pc_monitor/screenshots/1.png


BIN
pc_monitor/screenshots/2.png


BIN
pc_monitor/screenshots/qFlipper.png


+ 93 - 0
pc_monitor/views/bars_view.c

@@ -0,0 +1,93 @@
+#include "bars_view.h"
+
+void draw_bars_view(Canvas* canvas, void* ctx) {
+    PcMonitorApp* app = ctx;
+
+    canvas_clear(canvas);
+    canvas_set_color(canvas, ColorBlack);
+    canvas_set_font(canvas, FontKeyboard);
+
+    uint8_t line = 0;
+    uint8_t spacing = app->lines_count ? SCREEN_HEIGHT / app->lines_count : 0;
+    uint8_t margin_top = spacing ? (spacing - LINE_HEIGHT) / 2 : 0;
+    char str[32];
+
+    if(app->data.cpu_usage <= 100) {
+        if(app->lines_count) {
+            canvas_draw_str(canvas, 1, margin_top + line * spacing + 9, "CPU");
+            snprintf(str, 32, "%d%%", app->data.cpu_usage);
+            elements_progress_bar_with_text(
+                canvas,
+                BAR_X,
+                margin_top + line * spacing,
+                BAR_WIDTH,
+                app->data.cpu_usage / 100.0f,
+                str);
+        }
+
+        line++;
+    }
+
+    if(app->data.ram_usage <= 100) {
+        if(app->lines_count) {
+            canvas_draw_str(canvas, 1, margin_top + line * spacing + 9, "RAM");
+            snprintf(
+                str,
+                32,
+                "%.1f/%.1f %s",
+                (double)(app->data.ram_max * 0.1f * app->data.ram_usage * 0.01f),
+                (double)(app->data.ram_max * 0.1f),
+                app->data.ram_unit);
+            elements_progress_bar_with_text(
+                canvas,
+                BAR_X,
+                margin_top + line * spacing,
+                BAR_WIDTH,
+                app->data.ram_usage * 0.01f,
+                str);
+        }
+
+        line++;
+    }
+
+    if(app->data.gpu_usage <= 100) {
+        if(app->lines_count) {
+            canvas_draw_str(canvas, 1, margin_top + line * spacing + 9, "GPU");
+            snprintf(str, 32, "%d%%", app->data.gpu_usage);
+            elements_progress_bar_with_text(
+                canvas,
+                BAR_X,
+                margin_top + line * spacing,
+                BAR_WIDTH,
+                app->data.gpu_usage / 100.0f,
+                str);
+        }
+
+        line++;
+    }
+
+    if(app->data.vram_usage <= 100) {
+        if(app->lines_count) {
+            canvas_draw_str(canvas, 1, margin_top + line * spacing + 9, "VRAM");
+            snprintf(
+                str,
+                32,
+                "%.1f/%.1f %s",
+                (double)(app->data.vram_max * 0.1f * app->data.vram_usage * 0.01f),
+                (double)(app->data.vram_max * 0.1f),
+                app->data.vram_unit);
+            elements_progress_bar_with_text(
+                canvas,
+                BAR_X,
+                margin_top + line * spacing,
+                BAR_WIDTH,
+                app->data.vram_usage * 0.01f,
+                str);
+        }
+
+        line++;
+    }
+
+    if(line == 0) app->bt_state = BtStateNoData;
+    app->lines_count = line;
+}

+ 6 - 0
pc_monitor/views/bars_view.h

@@ -0,0 +1,6 @@
+#pragma once
+
+#include <gui/gui.h>
+#include "../pc_monitor.h"
+
+void draw_bars_view(Canvas* canvas, void* ctx);

+ 13 - 0
pc_monitor/views/connect_view.c

@@ -0,0 +1,13 @@
+#include "connect_view.h"
+
+void draw_connect_view(Canvas* canvas) {
+    canvas_draw_str(
+        canvas, 1, 10, "Waiting for connection...");
+
+    canvas_draw_str(
+        canvas, 1, 40, "Download back-end");
+    canvas_draw_str(
+        canvas, 1, 50, "app for your PC from:");
+
+    canvas_draw_icon(canvas, 128-34, 64-34, &I_qr_33px);
+}

+ 7 - 0
pc_monitor/views/connect_view.h

@@ -0,0 +1,7 @@
+#pragma once
+
+#include <gui/gui.h>
+#include <pc_monitor_icons.h>
+#include "../pc_monitor.h"
+
+void draw_connect_view(Canvas* canvas);

+ 16 - 0
pc_monitor/views/status_view.c

@@ -0,0 +1,16 @@
+#include "status_view.h"
+
+void draw_status_view(Canvas* canvas, void* ctx) {
+    PcMonitorApp* app = ctx;
+
+    canvas_draw_str_aligned(
+        canvas,
+        64,
+        32,
+        AlignCenter,
+        AlignCenter,
+        app->bt_state == BtStateChecking ? "Checking BLE..." :
+        app->bt_state == BtStateInactive ? "BLE inactive!" :
+        app->bt_state == BtStateLost     ? "Connection lost!" :
+                                           "No data!");
+}

+ 6 - 0
pc_monitor/views/status_view.h

@@ -0,0 +1,6 @@
+#pragma once
+
+#include <gui/gui.h>
+#include "../pc_monitor.h"
+
+void draw_status_view(Canvas* canvas, void* ctx);