Defined the clear byte function
This commit is contained in:
parent
cfdf40bd9c
commit
dad3f8f82a
|
@ -50,6 +50,10 @@ void LedController_ShowByte(LedByte *led_byte, uint8_t byte)
|
||||||
|
|
||||||
void LedControler_ClearByte(LedByte *led_byte)
|
void LedControler_ClearByte(LedByte *led_byte)
|
||||||
{
|
{
|
||||||
|
for (int i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
LedController_SetLow(&led_byte->leds[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LedController_SetHigh(Led *led)
|
void LedController_SetHigh(Led *led)
|
||||||
|
|
|
@ -35,11 +35,14 @@ LedByte LedController_New(uint8_t *port);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the byte of data via led pins.
|
* Displays the byte of data via led pins.
|
||||||
|
* @param led_byte A pointer to a LedByte structure.
|
||||||
|
* @param byte A uint8_t representing the byte to be displayed.
|
||||||
*/
|
*/
|
||||||
void LedController_ShowByte(LedByte *led_byte, uint8_t byte);
|
void LedController_ShowByte(LedByte *led_byte, uint8_t byte);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears out the byte led representation
|
* Clears out the byte led representation
|
||||||
|
* @param led_byte A pointer to the LedByte structure.
|
||||||
*/
|
*/
|
||||||
void LedControler_ClearByte(LedByte *led_byte);
|
void LedControler_ClearByte(LedByte *led_byte);
|
||||||
|
|
||||||
|
|
|
@ -140,3 +140,22 @@ TEST(test_LedController, LedByteDisplayPattern)
|
||||||
|
|
||||||
CHECK_EQUAL(0xAA, fake_port);
|
CHECK_EQUAL(0xAA, fake_port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(test_LedController, ClearingLedByteWorks)
|
||||||
|
{
|
||||||
|
uint8_t fake_port = 0xFF;
|
||||||
|
LedByte led_byte = LedController_New(&fake_port);
|
||||||
|
|
||||||
|
for(int i = 0; i < 8; i++){
|
||||||
|
led_byte.leds[i].state = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
LedControler_ClearByte(&led_byte);
|
||||||
|
|
||||||
|
for(int i = 0; i < 8; i++){
|
||||||
|
CHECK_TRUE(!led_byte.leds[i].state);
|
||||||
|
/*loop body*/
|
||||||
|
}
|
||||||
|
|
||||||
|
CHECK_EQUAL(0x00, fake_port);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue