From 9fc9e43cd6c73fb630fe197ded0d1f17bf35f782 Mon Sep 17 00:00:00 2001 From: jake Date: Sun, 25 Aug 2024 06:38:10 -0700 Subject: [PATCH] Fixed issue with pin number Fixed an issue where a placeholder value was still being used in a function. --- src/LedController/LedController.c | 6 +++++- src/LedController/LedController.h | 3 +-- tests/LedController/test_LedController.cpp | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/LedController/LedController.c b/src/LedController/LedController.c index 5a83584..91f1f8d 100644 --- a/src/LedController/LedController.c +++ b/src/LedController/LedController.c @@ -26,7 +26,7 @@ LedByte LedController_New(uint8_t *port) LedByte led_byte; for (int i = 0; i < 8; i++) { - led_byte.leds[i].pin_num = 1; + led_byte.leds[i].pin_num = i; led_byte.leds[i].state = false; led_byte.leds[i].port = port; } @@ -35,6 +35,10 @@ LedByte LedController_New(uint8_t *port) void LedController_ShowByte(LedByte *led_byte, uint8_t byte) { + for (int i = 0; i < 8; i++) + { + LedController_SetHigh(&led_byte->leds[i]); + } } void LedControler_ClearByte(LedByte *led_byte) diff --git a/src/LedController/LedController.h b/src/LedController/LedController.h index b9757f9..9f7d60b 100644 --- a/src/LedController/LedController.h +++ b/src/LedController/LedController.h @@ -26,7 +26,7 @@ typedef struct Led typedef struct LedByte { Led leds[8]; -}LedByte; +} LedByte; /** * Returns a instance of the LedByte structure. @@ -38,7 +38,6 @@ LedByte LedController_New(uint8_t *port); */ void LedController_ShowByte(LedByte *led_byte, uint8_t byte); - /** * Clears out the byte led representation */ diff --git a/tests/LedController/test_LedController.cpp b/tests/LedController/test_LedController.cpp index d009dbb..599667b 100644 --- a/tests/LedController/test_LedController.cpp +++ b/tests/LedController/test_LedController.cpp @@ -103,3 +103,19 @@ TEST(test_LedController, NewLedByte) } } + +TEST(test_LedController, LedByteDisplay) +{ + uint8_t fake_port = 0x00; + uint8_t byte = 0xFF; + LedByte led_byte = LedController_New(&fake_port); + + LedController_ShowByte(&led_byte, byte); + + for(int i = 0; i < 8; i++){ + CHECK_TRUE(led_byte.leds[i].state); + } + + CHECK_EQUAL(0xFF, fake_port); + +}