summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Jones <admin@danieljon.es>2019-01-08 01:30:46 +1030
committerDaniel Jones <admin@danieljon.es>2019-01-08 01:30:46 +1030
commitabf4b28a99461ca9c8cb8ca82ce71ab36d93d8a0 (patch)
tree44e34afb7cd92963bc3e91a04814718e89320d31
parentb56754d9334d5e128e968779f3231fa46e01eefb (diff)
downloadledmatrix-master.tar.gz
ledmatrix-master.zip
added version that uses 8 bytes for the matrix, bit masking for each ledHEADmaster
-rw-r--r--matrix8bytes.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/matrix8bytes.c b/matrix8bytes.c
new file mode 100644
index 0000000..5d3ed63
--- /dev/null
+++ b/matrix8bytes.c
@@ -0,0 +1,69 @@
+/*
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ *(at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdint.h>
+#include <time.h>
+
+#define CIRCLE "◯"
+#define BLACKCIRCLE "⬤"
+#define BALLS 2
+
+uint64_t matrix;
+
+void
+printleds(void)
+{
+ printf("\0337");
+ printf("%s", "\033[8;0F");
+ printf("%s", "\033[0J");
+ /* loop through each byte of matrix */
+ int c = 56;
+ uint8_t byte;
+ while (c >= 0)
+ {
+ byte = (matrix >> c) & 0xff;
+ printf("%s %s %s %s %s %s %s %s\n",
+ (byte & 0x01) ? BLACKCIRCLE : CIRCLE,
+ ((byte >> 1) & 0x01) ? BLACKCIRCLE : CIRCLE,
+ ((byte >> 2) & 0x01) ? BLACKCIRCLE : CIRCLE,
+ ((byte >> 3) & 0x01) ? BLACKCIRCLE : CIRCLE,
+ ((byte >> 4) & 0x01) ? BLACKCIRCLE : CIRCLE,
+ ((byte >> 5) & 0x01) ? BLACKCIRCLE : CIRCLE,
+ ((byte >> 6) & 0x01) ? BLACKCIRCLE : CIRCLE,
+ ((byte >> 7) & 0x01) ? BLACKCIRCLE : CIRCLE);
+ c -= 8;
+ }
+ printf("\0338");
+}
+
+int
+main(void)
+{
+ printf("\n\n\n\n\n\n\n\n\n");
+ srand(time(NULL));
+ matrix = 0xff00000000000000;
+ while (1)
+ {
+ matrix>>=8;
+ if (matrix == 0)
+ matrix = 0xff00000000000000;
+ printleds();
+ usleep(200000);
+ }
+ return 0;
+}