summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksa Vučković <56649122+aleksav013@users.noreply.github.com>2023-03-10 22:55:42 +0000
committerGitHub <noreply@github.com>2023-03-10 22:55:42 +0000
commit01905c85caf85f658e6efff8672d873e7a5fd8ad (patch)
tree2782af11a61f1f3f828d568019174d67a9fed26f
parent30a0aafd0feb6615b17bd226ba82010a6aaeb20b (diff)
parentf6ebc8903c51435cccfc95915f75d96f73f16fa7 (diff)
Merge pull request #2 from vmisovic/masterHEADmaster
vladin deo
-rw-r--r--.gitignore1
-rw-r--r--CMakeLists.txt5
-rw-r--r--config.h25
-rw-r--r--led_cube.c140
-rw-r--r--src/config.h22
-rw-r--r--src/draw.c52
-rw-r--r--src/draw.h15
-rw-r--r--src/font.h156
-rw-r--r--src/init.c32
-rw-r--r--src/init.h11
-rw-r--r--src/main.c74
-rw-r--r--src/tests.c59
-rw-r--r--src/tests.h12
13 files changed, 438 insertions, 166 deletions
diff --git a/.gitignore b/.gitignore
index d9d8bd8..40d916c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
build/*
compile_commands.json
+.ccls*
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c05c0c6..3deaef9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,7 +15,10 @@ pico_sdk_init()
if (TARGET tinyusb_device)
add_executable(led_cube
- led_cube.c
+ src/init.c
+ src/draw.c
+ src/tests.c
+ src/main.c
)
# pull in common dependencies
diff --git a/config.h b/config.h
deleted file mode 100644
index fe639e9..0000000
--- a/config.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef CONFIG_H
-#define CONFIG_H
-
-#include <stdint.h>
-
-// define the pins used controlling 74HC595
-#define DATA_PIN 2
-#define CLOCK_PIN 3
-#define LATCH_PIN 4
-#define LED_PIN 25
-
-// define the order of 74HC595 chain
-#define CHIP_0 0
-#define CHIP_1 1
-#define CHIP_2 3
-#define CHIP_3 5
-#define CHIP_4 7
-#define CHIP_5 8
-#define CHIP_6 6
-#define CHIP_7 4
-#define CHIP_8 2
-
-extern uint8_t map[9];
-
-#endif
diff --git a/led_cube.c b/led_cube.c
deleted file mode 100644
index 8573d53..0000000
--- a/led_cube.c
+++ /dev/null
@@ -1,140 +0,0 @@
-#include "pico/stdlib.h"
-#include "hardware/timer.h"
-#include "config.h"
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-#include <math.h>
-
-uint8_t map[9];
-
-void init_pins(void)
-{
- gpio_init(DATA_PIN);
- gpio_init(CLOCK_PIN);
- gpio_init(LATCH_PIN);
- gpio_set_dir(DATA_PIN, GPIO_OUT);
- gpio_set_dir(CLOCK_PIN, GPIO_OUT);
- gpio_set_dir(LATCH_PIN, GPIO_OUT);
-
- gpio_init(LED_PIN);
- gpio_set_dir(LED_PIN, GPIO_OUT);
- gpio_put(LED_PIN, 1);
-}
-
-void init_map(void)
-{
- map[0] = CHIP_0;
- map[1] = CHIP_1;
- map[2] = CHIP_2;
- map[3] = CHIP_3;
- map[4] = CHIP_4;
- map[5] = CHIP_5;
- map[6] = CHIP_6;
- map[7] = CHIP_7;
- map[8] = CHIP_8;
-}
-
-void send_raw_data(uint8_t data[9])
-{
- gpio_put(LATCH_PIN, 0);
- for (size_t i = 0; i < 9; i++) {
- for (size_t j = 0; j < 8; j++)
- {
- gpio_put(DATA_PIN, data[map[i]] & (1 << j));
- gpio_put(CLOCK_PIN, 0);
- gpio_put(CLOCK_PIN, 1);
- }
- }
- gpio_put(LATCH_PIN, 1);
-}
-
-void send_data(uint8_t floor, uint64_t on_floor)
-{
- uint8_t data[9];
- data[0] = floor;
- memcpy(&data[1], &on_floor, 8);
- send_raw_data(data);
-}
-
-int64_t zero_byte(alarm_id_t id, void* user_data)
-{
- memset(user_data, 0, 1);
- return 0;
-}
-
-void draw(uint64_t data[8], uint32_t time)
-{
- volatile uint8_t ind = 1;
- add_alarm_in_ms(time, (void*)zero_byte, (void*)&ind, false);
-
- while (ind) {
- for (size_t i = 0; i < 8; i++) {
- send_data((1 << i), data[i]);
- }
- tight_loop_contents();
- }
-}
-
-void test_every_floor(void)
-{
- for (size_t i = 0; i < 8; i++) {
- send_data((1 << i), 0xFFFFFFFFFFFFFFFF);
- sleep_ms(125);
- }
-}
-
-#define PIN(x, y) (1LL << ((y) * 8 + (x)))
-
-void test_every_pin(void)
-{
- uint64_t data[8];
- memset(data, 0, 64);
-
- for (size_t x = 0; x < 8; x++) {
- for (size_t y = 0; y < 8; y++) {
- for (size_t z = 0; z < 8; z++) {
- data[z] = PIN(x, y);
- }
- draw(data, 125);
- for (size_t z = 0; z < 8; z++) {
- data[z] = 0;
- }
- }
- }
-}
-
-void sphere(void)
-{
- uint64_t data[8];
-
- for (size_t i = 0; i < 7; i++) {
- memset(data, 0, 64);
- for (int8_t x = 0; x < 8; x++) {
- for (int8_t y = 0; y < 8; y++) {
- for (int8_t z = 0; z < 8; z++) {
- if ((3.5-x)*(3.5-x) + (3.5-y)*(3.5-y) + (3.5-z)*(3.5-z) < 1.0*i*i) {
- data[z] = PIN(x, y);
- }
- }
- }
- }
- draw(data, 200 - i * 20);
- }
-}
-
-int main()
-{
- stdio_init_all();
- init_pins();
- init_map();
- test_every_floor();
- test_every_pin();
-
- while(1) {
- sphere();
- }
-
- return 0;
-}
diff --git a/src/config.h b/src/config.h
new file mode 100644
index 0000000..7f8bc9a
--- /dev/null
+++ b/src/config.h
@@ -0,0 +1,22 @@
+#ifndef CONFIG_H
+#define CONFIG_H
+// configuration file
+
+// define pico gpio pins used for controlling 74HC595 chips
+#define DATA_PIN 2
+#define CLOCK_PIN 3
+#define LATCH_PIN 4
+#define LED_PIN 25
+
+// define the order of 74HC595 chain
+#define CHIP_0 0
+#define CHIP_1 8
+#define CHIP_2 6
+#define CHIP_3 4
+#define CHIP_4 2
+#define CHIP_5 1
+#define CHIP_6 3
+#define CHIP_7 5
+#define CHIP_8 7
+
+#endif
diff --git a/src/draw.c b/src/draw.c
new file mode 100644
index 0000000..a927e9c
--- /dev/null
+++ b/src/draw.c
@@ -0,0 +1,52 @@
+#include "draw.h"
+#include "config.h"
+#include <string.h>
+
+void send_raw_data(uint8_t data[9])
+{
+ gpio_put(LATCH_PIN, 0);
+ for (size_t i = 0; i < 9; i++) {
+ for (size_t j = 0; j < 8; j++)
+ {
+ gpio_put(DATA_PIN, data[map[i]] & (1 << j));
+ gpio_put(CLOCK_PIN, 0);
+ gpio_put(CLOCK_PIN, 1);
+ }
+ }
+ gpio_put(LATCH_PIN, 1);
+}
+
+void send_data(uint8_t floor, uint64_t on_floor)
+{
+ uint8_t data[9];
+ data[0] = floor;
+ memcpy(&data[1], &on_floor, 8);
+ send_raw_data(data);
+}
+
+void cube_set_led(uint64_t data[8], uint8_t x, uint8_t y, uint8_t z, bool value)
+{
+ uint64_t mask = 1LL << (y * 8 + x);
+ if (value != (bool)(data[z] & mask))
+ data[z] ^= mask;
+}
+
+int64_t zero_byte(alarm_id_t id, void* user_data)
+{
+ memset(user_data, 0, 1);
+ return 0;
+}
+
+void draw(uint64_t data[8], uint32_t time)
+{
+ volatile uint8_t ind = 1;
+ add_alarm_in_ms(time, (void*)zero_byte, (void*)&ind, false);
+
+ while (ind) {
+ for (size_t i = 0; i < 8; i++) {
+ send_data((1 << i), data[i]);
+ sleep_ms(1);
+ }
+ tight_loop_contents();
+ }
+}
diff --git a/src/draw.h b/src/draw.h
new file mode 100644
index 0000000..097da77
--- /dev/null
+++ b/src/draw.h
@@ -0,0 +1,15 @@
+#ifndef DRAW_H
+#define DRAW_H
+// library used for manipulating and displaying cube matrix
+
+#include "pico/stdlib.h"
+
+extern uint8_t map[9]; // map[] is defined in init.h
+
+void send_raw_data(uint8_t data[9]);
+void send_data(uint8_t floor, uint64_t on_floor);
+void cube_set_led(uint64_t data[8], uint8_t x, uint8_t y, uint8_t z, bool value);
+int64_t zero_byte(alarm_id_t id, void* user_data);
+void draw(uint64_t data[8], uint32_t time);
+
+#endif
diff --git a/src/font.h b/src/font.h
new file mode 100644
index 0000000..598ce07
--- /dev/null
+++ b/src/font.h
@@ -0,0 +1,156 @@
+#ifndef FONT_H
+#define FONT_H
+/**
+ * 8x8 monochrome bitmap fonts for rendering
+ * Author: Daniel Hepper <daniel@hepper.net>
+ *
+ * License: Public Domain
+ *
+ * Based on:
+ * // Summary: font8x8.h
+ * // 8x8 monochrome bitmap fonts for rendering
+ * //
+ * // Author:
+ * // Marcel Sondaar
+ * // International Business Machines (public domain VGA fonts)
+ * //
+ * // License:
+ * // Public Domain
+ *
+ * Fetched from: http://dimensionalrift.homelinux.net/combuster/mos3/?p=viewsource&file=/modules/gfx/font8_8.asm
+ **/
+
+// Constant: font8x8_basic
+// Contains an 8x8 font map for unicode points U+0000 - U+007F (basic latin)
+const char font8x8_basic[128][8] = {
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0000 (nul)
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0001
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0002
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0003
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0004
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0005
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0006
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0007
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0008
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0009
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000A
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000B
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000C
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000D
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000E
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000F
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0010
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0011
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0012
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0013
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0014
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0015
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0016
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0017
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0018
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0019
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001A
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001B
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001C
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001D
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001E
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001F
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0020 (space)
+ { 0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00}, // U+0021 (!)
+ { 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0022 (")
+ { 0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36, 0x00}, // U+0023 (#)
+ { 0x0C, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x0C, 0x00}, // U+0024 ($)
+ { 0x00, 0x63, 0x33, 0x18, 0x0C, 0x66, 0x63, 0x00}, // U+0025 (%)
+ { 0x1C, 0x36, 0x1C, 0x6E, 0x3B, 0x33, 0x6E, 0x00}, // U+0026 (&)
+ { 0x06, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0027 (')
+ { 0x18, 0x0C, 0x06, 0x06, 0x06, 0x0C, 0x18, 0x00}, // U+0028 (()
+ { 0x06, 0x0C, 0x18, 0x18, 0x18, 0x0C, 0x06, 0x00}, // U+0029 ())
+ { 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00}, // U+002A (*)
+ { 0x00, 0x0C, 0x0C, 0x3F, 0x0C, 0x0C, 0x00, 0x00}, // U+002B (+)
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+002C (,)
+ { 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00}, // U+002D (-)
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+002E (.)
+ { 0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00}, // U+002F (/)
+ { 0x3E, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x3E, 0x00}, // U+0030 (0)
+ { 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x3F, 0x00}, // U+0031 (1)
+ { 0x1E, 0x33, 0x30, 0x1C, 0x06, 0x33, 0x3F, 0x00}, // U+0032 (2)
+ { 0x1E, 0x33, 0x30, 0x1C, 0x30, 0x33, 0x1E, 0x00}, // U+0033 (3)
+ { 0x38, 0x3C, 0x36, 0x33, 0x7F, 0x30, 0x78, 0x00}, // U+0034 (4)
+ { 0x3F, 0x03, 0x1F, 0x30, 0x30, 0x33, 0x1E, 0x00}, // U+0035 (5)
+ { 0x1C, 0x06, 0x03, 0x1F, 0x33, 0x33, 0x1E, 0x00}, // U+0036 (6)
+ { 0x3F, 0x33, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x00}, // U+0037 (7)
+ { 0x1E, 0x33, 0x33, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+0038 (8)
+ { 0x1E, 0x33, 0x33, 0x3E, 0x30, 0x18, 0x0E, 0x00}, // U+0039 (9)
+ { 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+003A (:)
+ { 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+003B (;)
+ { 0x18, 0x0C, 0x06, 0x03, 0x06, 0x0C, 0x18, 0x00}, // U+003C (<)
+ { 0x00, 0x00, 0x3F, 0x00, 0x00, 0x3F, 0x00, 0x00}, // U+003D (=)
+ { 0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, 0x00}, // U+003E (>)
+ { 0x1E, 0x33, 0x30, 0x18, 0x0C, 0x00, 0x0C, 0x00}, // U+003F (?)
+ { 0x3E, 0x63, 0x7B, 0x7B, 0x7B, 0x03, 0x1E, 0x00}, // U+0040 (@)
+ { 0x0C, 0x1E, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x00}, // U+0041 (A)
+ { 0x3F, 0x66, 0x66, 0x3E, 0x66, 0x66, 0x3F, 0x00}, // U+0042 (B)
+ { 0x3C, 0x66, 0x03, 0x03, 0x03, 0x66, 0x3C, 0x00}, // U+0043 (C)
+ { 0x1F, 0x36, 0x66, 0x66, 0x66, 0x36, 0x1F, 0x00}, // U+0044 (D)
+ { 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x46, 0x7F, 0x00}, // U+0045 (E)
+ { 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x06, 0x0F, 0x00}, // U+0046 (F)
+ { 0x3C, 0x66, 0x03, 0x03, 0x73, 0x66, 0x7C, 0x00}, // U+0047 (G)
+ { 0x33, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x33, 0x00}, // U+0048 (H)
+ { 0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0049 (I)
+ { 0x78, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E, 0x00}, // U+004A (J)
+ { 0x67, 0x66, 0x36, 0x1E, 0x36, 0x66, 0x67, 0x00}, // U+004B (K)
+ { 0x0F, 0x06, 0x06, 0x06, 0x46, 0x66, 0x7F, 0x00}, // U+004C (L)
+ { 0x63, 0x77, 0x7F, 0x7F, 0x6B, 0x63, 0x63, 0x00}, // U+004D (M)
+ { 0x63, 0x67, 0x6F, 0x7B, 0x73, 0x63, 0x63, 0x00}, // U+004E (N)
+ { 0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00}, // U+004F (O)
+ { 0x3F, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x0F, 0x00}, // U+0050 (P)
+ { 0x1E, 0x33, 0x33, 0x33, 0x3B, 0x1E, 0x38, 0x00}, // U+0051 (Q)
+ { 0x3F, 0x66, 0x66, 0x3E, 0x36, 0x66, 0x67, 0x00}, // U+0052 (R)
+ { 0x1E, 0x33, 0x07, 0x0E, 0x38, 0x33, 0x1E, 0x00}, // U+0053 (S)
+ { 0x3F, 0x2D, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0054 (T)
+ { 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3F, 0x00}, // U+0055 (U)
+ { 0x33, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0056 (V)
+ { 0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63, 0x00}, // U+0057 (W)
+ { 0x63, 0x63, 0x36, 0x1C, 0x1C, 0x36, 0x63, 0x00}, // U+0058 (X)
+ { 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x0C, 0x1E, 0x00}, // U+0059 (Y)
+ { 0x7F, 0x63, 0x31, 0x18, 0x4C, 0x66, 0x7F, 0x00}, // U+005A (Z)
+ { 0x1E, 0x06, 0x06, 0x06, 0x06, 0x06, 0x1E, 0x00}, // U+005B ([)
+ { 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x40, 0x00}, // U+005C (\)
+ { 0x1E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x00}, // U+005D (])
+ { 0x08, 0x1C, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00}, // U+005E (^)
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF}, // U+005F (_)
+ { 0x0C, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0060 (`)
+ { 0x00, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x6E, 0x00}, // U+0061 (a)
+ { 0x07, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00}, // U+0062 (b)
+ { 0x00, 0x00, 0x1E, 0x33, 0x03, 0x33, 0x1E, 0x00}, // U+0063 (c)
+ { 0x38, 0x30, 0x30, 0x3e, 0x33, 0x33, 0x6E, 0x00}, // U+0064 (d)
+ { 0x00, 0x00, 0x1E, 0x33, 0x3f, 0x03, 0x1E, 0x00}, // U+0065 (e)
+ { 0x1C, 0x36, 0x06, 0x0f, 0x06, 0x06, 0x0F, 0x00}, // U+0066 (f)
+ { 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0067 (g)
+ { 0x07, 0x06, 0x36, 0x6E, 0x66, 0x66, 0x67, 0x00}, // U+0068 (h)
+ { 0x0C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0069 (i)
+ { 0x30, 0x00, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E}, // U+006A (j)
+ { 0x07, 0x06, 0x66, 0x36, 0x1E, 0x36, 0x67, 0x00}, // U+006B (k)
+ { 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+006C (l)
+ { 0x00, 0x00, 0x33, 0x7F, 0x7F, 0x6B, 0x63, 0x00}, // U+006D (m)
+ { 0x00, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x33, 0x00}, // U+006E (n)
+ { 0x00, 0x00, 0x1E, 0x33, 0x33, 0x33, 0x1E, 0x00}, // U+006F (o)
+ { 0x00, 0x00, 0x3B, 0x66, 0x66, 0x3E, 0x06, 0x0F}, // U+0070 (p)
+ { 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x78}, // U+0071 (q)
+ { 0x00, 0x00, 0x3B, 0x6E, 0x66, 0x06, 0x0F, 0x00}, // U+0072 (r)
+ { 0x00, 0x00, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x00}, // U+0073 (s)
+ { 0x08, 0x0C, 0x3E, 0x0C, 0x0C, 0x2C, 0x18, 0x00}, // U+0074 (t)
+ { 0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x6E, 0x00}, // U+0075 (u)
+ { 0x00, 0x00, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0076 (v)
+ { 0x00, 0x00, 0x63, 0x6B, 0x7F, 0x7F, 0x36, 0x00}, // U+0077 (w)
+ { 0x00, 0x00, 0x63, 0x36, 0x1C, 0x36, 0x63, 0x00}, // U+0078 (x)
+ { 0x00, 0x00, 0x33, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0079 (y)
+ { 0x00, 0x00, 0x3F, 0x19, 0x0C, 0x26, 0x3F, 0x00}, // U+007A (z)
+ { 0x38, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, 0x38, 0x00}, // U+007B ({)
+ { 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00}, // U+007C (|)
+ { 0x07, 0x0C, 0x0C, 0x38, 0x0C, 0x0C, 0x07, 0x00}, // U+007D (})
+ { 0x6E, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+007E (~)
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // U+007F
+};
+
+#endif
diff --git a/src/init.c b/src/init.c
new file mode 100644
index 0000000..a9f5d63
--- /dev/null
+++ b/src/init.c
@@ -0,0 +1,32 @@
+#include "pico/stdlib.h"
+#include "config.h"
+#include "init.h"
+
+uint8_t map[9];
+
+void init_pins(void)
+{
+ gpio_init(DATA_PIN);
+ gpio_init(CLOCK_PIN);
+ gpio_init(LATCH_PIN);
+ gpio_set_dir(DATA_PIN, GPIO_OUT);
+ gpio_set_dir(CLOCK_PIN, GPIO_OUT);
+ gpio_set_dir(LATCH_PIN, GPIO_OUT);
+
+ gpio_init(LED_PIN);
+ gpio_set_dir(LED_PIN, GPIO_OUT);
+ gpio_put(LED_PIN, 1);
+}
+
+void init_map(void)
+{
+ map[0] = CHIP_0;
+ map[1] = CHIP_1;
+ map[2] = CHIP_2;
+ map[3] = CHIP_3;
+ map[4] = CHIP_4;
+ map[5] = CHIP_5;
+ map[6] = CHIP_6;
+ map[7] = CHIP_7;
+ map[8] = CHIP_8;
+}
diff --git a/src/init.h b/src/init.h
new file mode 100644
index 0000000..8dabbdb
--- /dev/null
+++ b/src/init.h
@@ -0,0 +1,11 @@
+#ifndef INIT_H
+#define INIT_H
+
+#include <stdint.h>
+
+extern uint8_t map[9];
+
+void init_pins(void);
+void init_map(void);
+
+#endif
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..86c5a95
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,74 @@
+#include "pico/stdlib.h"
+#include "hardware/timer.h"
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include "config.h"
+#include "init.h"
+#include "draw.h"
+#include "tests.h"
+#include "font.h"
+
+void draw_letter(char c)
+{
+ uint8_t data[9];
+ data[0] = 1;
+ memcpy(&data[1], &font8x8_basic[c], 8);
+ send_raw_data(data);
+ sleep_ms(1000);
+}
+
+void draw_letter2(char c)
+{
+ uint64_t data[8];
+ for(int i = 0; i<8; i++) {
+ data[i] = 0LL;
+ for(int j = 0; j<8; j++) {
+ cube_set_led(data, 0, j, i, (font8x8_basic[c][i] >> j) & 1);
+ }
+ }
+ draw(data, 1000);
+}
+
+int main()
+{
+ stdio_init_all();
+ init_pins();
+ init_map();
+ //test_every_pin();
+
+ uint64_t data[8];
+ while(1) {
+ //test_every_floor();
+ //test_sphere();
+ /*for (int i = 0; i < 8; i++)
+ data[i] = 0LL;
+ draw_letter2('x');
+ for (int x = 0; x < 8; x++) {
+ cube_set_led(data, x, 0, 0, 1);
+ draw(data, 100);
+ }
+ draw_letter2('y');
+ for (int y = 0; y < 8; y++) {
+ cube_set_led(data, 0, y, 0, 1);
+ draw(data, 100);
+ }
+ draw_letter2('z');
+ for (int z = 0; z < 8; z++) {
+ cube_set_led(data, 0, 0, z, 1);
+ draw(data, 100);
+ }
+ for (int i = 32; i<128; i++) {
+ //draw_letter(i);
+ draw_letter2(i);
+ }*/
+ const char *tekst = "Aki kad ces kocku da zavrsavas?";
+ for (int i = 0; tekst[i]!='\0'; i++)
+ draw_letter2(tekst[i]);
+ }
+
+ return 0;
+}
diff --git a/src/tests.c b/src/tests.c
new file mode 100644
index 0000000..8f77acc
--- /dev/null
+++ b/src/tests.c
@@ -0,0 +1,59 @@
+#include "tests.h"
+#include <string.h>
+
+void test_every_floor(void)
+{
+ for (size_t i = 0; i < 8; i++) {
+ send_data((1 << i), 0xFFFFFFFFFFFFFFFF);
+ sleep_ms(125);
+ }
+}
+
+void test_every_pin(void)
+{
+ uint64_t data[8];
+ memset(data, 0, 64);
+
+ for (size_t x = 0; x < 8; x++) {
+ for (size_t y = 0; y < 8; y++) {
+ for (size_t z = 0; z < 8; z++) {
+ cube_set_led(data, x, y, z, 1);
+ }
+ draw(data, 125);
+ for (size_t z = 0; z < 8; z++) {
+ data[z] = 0;
+ }
+ }
+ }
+}
+
+void test_sphere(void)
+{
+ uint64_t data[8];
+
+ for (size_t r = 0; r < 7; r++) {
+ memset(data, 0, 64);
+ for (int8_t x = 0; x < 8; x++) {
+ for (int8_t y = 0; y < 8; y++) {
+ for (int8_t z = 0; z < 8; z++) {
+ if ((3.5-x)*(3.5-x) + (3.5-y)*(3.5-y) + (3.5-z)*(3.5-z) <= (float)r*r) {
+ cube_set_led(data, x, y, z, 1);
+ }
+ }
+ }
+ }
+ draw(data, 500);
+ }
+}
+
+void test_letter(uint64_t letter)
+{
+ uint64_t data[8];
+ for (size_t i = 0; i < 8; i++) {
+ if(i<2)
+ data[i] = letter;
+ else
+ data[i] = 0LL;
+ }
+ draw(data, 2000);
+}
diff --git a/src/tests.h b/src/tests.h
new file mode 100644
index 0000000..aa2726b
--- /dev/null
+++ b/src/tests.h
@@ -0,0 +1,12 @@
+#ifndef TESTS_H
+#define TESTS_H
+// all animations or tests are defined here
+
+#include "draw.h"
+
+void test_every_floor(void);
+void test_every_pin(void);
+void test_sphere(void);
+void test_letter(uint64_t letter);
+
+#endif