From d6ba290e863cfb89abc4b1e2466c41e1f4357e03 Mon Sep 17 00:00:00 2001 From: Rob Tillaart Date: Fri, 10 May 2024 16:06:32 +0200 Subject: [PATCH] fix code --- GY521.cpp | 9 +++++---- GY521.h | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/GY521.cpp b/GY521.cpp index 1c26b12..bf62c69 100644 --- a/GY521.cpp +++ b/GY521.cpp @@ -488,12 +488,13 @@ bool GY521::setDLPFMode(uint8_t mode) { if (mode > 6) { + _error = GY521_ERROR_PARAMETER; return false; } - uint8_t val = getRegister(GY521_CONFIG); - val &= 0xF8; - val |= mode; - return true; + uint8_t value = getRegister(GY521_CONFIG); + value &= 0xF8; + value |= mode; + return (setRegister(GY521_CONFIG, value) == GY521_OK); } diff --git a/GY521.h b/GY521.h index 659198a..f2ea315 100644 --- a/GY521.h +++ b/GY521.h @@ -28,6 +28,7 @@ const float GRAVITY = 9.80655; #define GY521_ERROR_READ -1 #define GY521_ERROR_WRITE -2 #define GY521_ERROR_NOT_CONNECTED -3 +#define GY521_ERROR_PARAMETER -4 // CONVERSION CONSTANTS