Wrote code to pass tests for the showbyte function.
+ Added statment for checking bits for hi/low
This commit is contained in:
parent
9fc9e43cd6
commit
cfdf40bd9c
|
@ -36,9 +36,16 @@ LedByte LedController_New(uint8_t *port)
|
||||||
void LedController_ShowByte(LedByte *led_byte, uint8_t byte)
|
void LedController_ShowByte(LedByte *led_byte, uint8_t byte)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
if (byte & (1 << i))
|
||||||
{
|
{
|
||||||
LedController_SetHigh(&led_byte->leds[i]);
|
LedController_SetHigh(&led_byte->leds[i]);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LedController_SetLow(&led_byte->leds[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LedControler_ClearByte(LedByte *led_byte)
|
void LedControler_ClearByte(LedByte *led_byte)
|
||||||
|
|
|
@ -119,3 +119,24 @@ TEST(test_LedController, LedByteDisplay)
|
||||||
CHECK_EQUAL(0xFF, fake_port);
|
CHECK_EQUAL(0xFF, fake_port);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(test_LedController, LedByteDisplayPattern)
|
||||||
|
{
|
||||||
|
uint8_t fake_port = 0x00;
|
||||||
|
uint8_t byte = 0xAA;
|
||||||
|
LedByte led_byte = LedController_New(&fake_port);
|
||||||
|
|
||||||
|
|
||||||
|
LedController_ShowByte(&led_byte, byte);
|
||||||
|
|
||||||
|
for(int i = 0; i < 8; i++){
|
||||||
|
if(byte & (1<<i)) {
|
||||||
|
CHECK_TRUE(led_byte.leds[i].state);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
CHECK_TRUE(!led_byte.leds[i].state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CHECK_EQUAL(0xAA, fake_port);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue