From 60be15b825d5a68a77632fcbbabc31879d4ae946 Mon Sep 17 00:00:00 2001
From: Federico Terraneo <fede.tft@miosix.org>
Date: Wed, 26 Oct 2022 00:03:59 +0200
Subject: [PATCH] Fix compile error when targeting 1bit per pixel displays

---
 drivers/display_st7735.cpp | 5 +++++
 drivers/display_st7735.h   | 7 ++++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/display_st7735.cpp b/drivers/display_st7735.cpp
index d4d814d..365f826 100644
--- a/drivers/display_st7735.cpp
+++ b/drivers/display_st7735.cpp
@@ -31,6 +31,9 @@
 #include "misc_inst.h"
 #include "line.h"
 
+//The ST7735 driver requires a color depth 16 per pixel
+#ifdef MXGUI_COLOR_DEPTH_16_BIT
+
 using namespace std;
 using namespace miosix;
 
@@ -349,3 +352,5 @@ void DisplayGenericST7735::sendCmds(const unsigned char *cmds) {
 }
 
 } //mxgui
+
+#endif //MXGUI_COLOR_DEPTH_16_BIT
diff --git a/drivers/display_st7735.h b/drivers/display_st7735.h
index 02a8f37..5b783ef 100644
--- a/drivers/display_st7735.h
+++ b/drivers/display_st7735.h
@@ -39,9 +39,8 @@
 
 namespace mxgui {
 
-#ifndef MXGUI_COLOR_DEPTH_16_BIT
-#error The ST7735 driver requires a color depth 16 per pixel
-#endif
+//The ST7735 driver requires a color depth 16 per pixel
+#ifdef MXGUI_COLOR_DEPTH_16_BIT
 
 //Used to transiently pull low either the csx or dcx pin
 class Transaction
@@ -438,4 +437,6 @@ private:
     Color *buffer;          ///< For scanLineBuffer
 };
 
+#endif //MXGUI_COLOR_DEPTH_16_BIT
+
 } //namespace mxgui
-- 
GitLab