From 1898e37775ba5a1853ccbcd8f858ad08abd4e831 Mon Sep 17 00:00:00 2001 From: unlockable Date: Thu, 24 Aug 2023 18:19:58 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=B8=8D=E5=85=81=E8=AE=B8=E8=B6=85?= =?UTF-8?q?=E5=87=BA=E8=8C=83=E5=9B=B4=E7=9A=84=E5=9D=90=E6=A0=87=E5=80=BC?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 8By8/8By8.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/8By8/8By8.ino b/8By8/8By8.ino index 09df817..ed72e79 100644 --- a/8By8/8By8.ino +++ b/8By8/8By8.ino @@ -38,9 +38,9 @@ public: } static void set_status(int x, int y, int z, int brightness) { - x %= 8; - y %= 8; - z %= 8; + if (x >= 8 || x <= 0 || y >= 8 || y <= 0 || z >= 8 || z <= 0) { + return; + } brightness %= 4; LED_status[z][x] = (LED_status[z][x] & (~(3 << (y * 2)))) | (brightness << (y * 2)); } From 2879b9ccb0460dc7daa97b0a088e29082695cb12 Mon Sep 17 00:00:00 2001 From: unlockable Date: Thu, 24 Aug 2023 18:20:01 +0800 Subject: [PATCH 2/2] Amend --- 8By8/8By8.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/8By8/8By8.ino b/8By8/8By8.ino index ed72e79..800c7e7 100644 --- a/8By8/8By8.ino +++ b/8By8/8By8.ino @@ -38,7 +38,7 @@ public: } static void set_status(int x, int y, int z, int brightness) { - if (x >= 8 || x <= 0 || y >= 8 || y <= 0 || z >= 8 || z <= 0) { + if (x >= 8 || x < 0 || y >= 8 || y < 0 || z >= 8 || z < 0) { return; } brightness %= 4;