Created
February 2, 2020 22:06
-
-
Save RChehowski/f1046a29496ced6cdc8478586a186394 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define BLINK(x) __blink(x) | |
#define SLEEP_MS() Sleep(1) | |
bool get_indicator_status(const int8_t i) | |
{ | |
static const bool matrix[] = { | |
/* 1 */ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, | |
/* 2 */ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, | |
/* 3 */ 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, | |
/* 4 */ 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, | |
/* 5 */ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, | |
/* 6 */ 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, | |
/* 7 */ 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, | |
/* 8 */ 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, | |
/* 9 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, | |
/* 10*/ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 | |
}; | |
return matrix[i]; | |
} | |
void blink_loop() | |
{ | |
int8_t arr[] = { 0, 0, 0, 0, 0, 0, 0, 1 }; | |
while (true) | |
{ | |
uint8_t reg = 0; | |
for (size_t i = 0; i < sizeof(arr); ++i) | |
reg |= (get_indicator_status(arr[i]) << i); | |
BLINK(reg); | |
for (size_t i = 0; i < sizeof(arr); ++i) | |
{ | |
if (arr[i] != 0) | |
{ | |
if (++arr[i] == 99) | |
{ | |
arr[i] = -arr[i]; | |
arr[(i - 1) % sizeof(arr)] = 1; | |
} | |
} | |
} | |
SLEEP_MS(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment