From 98004bbcbed1ea89463d00dcf11a47ede5c43ef8 Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Sun, 9 Feb 2020 11:30:30 -0600 Subject: add some c o m m e n t s --- Lab_2B.X/lab2b_c.c | 88 +++++++++++++++++++++++++++++------------------------- 1 file changed, 47 insertions(+), 41 deletions(-) (limited to 'Lab_2B.X') diff --git a/Lab_2B.X/lab2b_c.c b/Lab_2B.X/lab2b_c.c index 21fdcba..bf917a3 100644 --- a/Lab_2B.X/lab2b_c.c +++ b/Lab_2B.X/lab2b_c.c @@ -36,73 +36,79 @@ int main(void) { } void writeColor(int r, int g, int b) { + int i = 0; LATA = 0x0000; wait_100us(); - - for (int i = 0; i < 8; i++){ + //RED + while (i < 8) { if (r & 1) { write_1(); } else { write_0(); } r >> 1; + ++i; } - for (int j = 0; j < 8; j++){ + //GREEN + while (i > 0) { if (g & 1) { write_1(); } else { write_0(); } - g >> 1; + g >> 1; + --i; } - for (int k = 0; k < 8; k++){ + //BLUE + while (i < 8){ if (b & 1) { write_1(); } else { write_0(); } b >> 1; + ++i; } } void loop(void) { while (1) { - LATA = 0x0000; - wait_100us(); +// LATA = 0x0000; +// wait_100us(); +// +// //RED +// write_1(); +// write_1(); +// write_1(); +// write_1(); +// +// write_1(); +// write_1(); +// write_1(); +// write_1(); +// +// //GREEN +// write_1(); +// write_0(); +// write_0(); +// write_1(); +// +// write_1(); +// write_0(); +// write_1(); +// write_1(); +// +// //BLUE +// write_0(); +// write_0(); +// write_0(); +// write_0(); +// +// write_0(); +// write_0(); +// write_0(); +// write_0(); - //RED - write_1(); - write_1(); - write_1(); - write_1(); - - write_1(); - write_1(); - write_1(); - write_1(); - - //GREEN - write_1(); - write_0(); - write_0(); - write_1(); - - write_1(); - write_0(); - write_1(); - write_1(); - - //BLUE - write_0(); - write_0(); - write_0(); - write_0(); - - write_0(); - write_0(); - write_0(); - write_0(); - - //writeColor(255, 155, 0); + writeColor(255, 155, 0); } } \ No newline at end of file -- cgit v1.2.3