From 220e0b9e2ea9b9d141c24e5052912c59d2af9b3d Mon Sep 17 00:00:00 2001 From: Razvalyaev Date: Wed, 21 May 2025 03:14:26 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=81=D0=B5=20=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=B0=D0=B5=D1=82,=20=D0=BF=D1=80=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D0=BE=20usb=20=D0=BF=D0=BB=D0=BE=D1=85=D0=BE=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B8=D0=BF=D0=B0=D1=8F=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Переделал дефолтные значения цветов: теперь они выставляются если настройка не найдена --- mouse/LedControl.cpp | 8 ++++---- mouse/LedControl.h | 5 +++++ mouse/mouse.ino | 4 ---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/mouse/LedControl.cpp b/mouse/LedControl.cpp index 544a823..43937a1 100644 --- a/mouse/LedControl.cpp +++ b/mouse/LedControl.cpp @@ -86,10 +86,10 @@ void LedControl::setupBLEService(BLEServer *server) { void LedControl::loadSettings() { preferences.begin(LED_NAMESPACE, true); - currentR = preferences.getUChar("r", 0); - currentG = preferences.getUChar("g", 0); - currentB = preferences.getUChar("b", 0); - currentBrightness = preferences.getUChar("br", 0); + currentR = preferences.getUChar("r", RED_DEFAULT); + currentG = preferences.getUChar("g", GREEN_DEFAULT); + currentB = preferences.getUChar("b", BLUE_DEFAULT); + currentBrightness = preferences.getUChar("br", BRIGHT_DEFAULT); preferences.end(); } diff --git a/mouse/LedControl.h b/mouse/LedControl.h index daa5383..509b863 100644 --- a/mouse/LedControl.h +++ b/mouse/LedControl.h @@ -15,6 +15,11 @@ #define COLOR_CHAR_B_UUID "12345678-1234-5678-1234-56789abcdef3" #define COLOR_CHAR_BRIGHTNESS_UUID "12345678-1234-5678-1234-56789abcdef4" +#define RED_DEFAULT 255 +#define GREEN_DEFAULT 0 +#define BLUE_DEFAULT 255 +#define BRIGHT_DEFAULT 50 + class LedControl { public: LedControl(Adafruit_NeoPixel &led) diff --git a/mouse/mouse.ino b/mouse/mouse.ino index 537aee1..6bd3833 100644 --- a/mouse/mouse.ino +++ b/mouse/mouse.ino @@ -5,10 +5,6 @@ #define LED_PIN 21 // GPIO пин светодиода (скорее всего 48) #define NUM_LEDS 1 // Один RGB светодиод -#define RED_DEFAULT 255 -#define GREEN_DEFAULT 0 -#define BLUE_DEFAULT 255 -#define BRIGHT_DEFAULT 50 // #define DISABLE_RGB_UUID // #define DISABLE_USB