数字时钟字体测试。

This commit is contained in:
unlockable
2023-08-24 17:53:14 +08:00
parent 1cdc07778e
commit 0aa14d2a39

View File

@@ -1,6 +1,6 @@
#include "TimerOne.h"
#define TIME_PER_LAYER_IN_US 700
#define TIME_PER_LAYER_IN_US 800
#define BUS_START_PIN 22
#define CLOCK_START_PIN 30
#define SW_START_PIN 38
@@ -28,7 +28,9 @@ public:
// In LED_status:
// 0 = off
// 4 = brightest
digitalWrite(BUS_START_PIN + j, ((LED_status[layer_count][i] >> (j * 2)) & 3) >= (3 - brightness_count));
digitalWrite(BUS_START_PIN + j,
((LED_status[layer_count][i] >> (j * 2)) & 3) >=
(3 - brightness_count));
}
digitalWrite(CLOCK_START_PIN + i, HIGH);
digitalWrite(CLOCK_START_PIN + i, LOW);
@@ -42,7 +44,20 @@ public:
y %= 8;
z %= 8;
brightness %= 4;
LED_status[z][x] = (LED_status[z][x] & (~(3 << (y * 2)))) | (brightness << (y * 2));
LED_status[z][x] =
(LED_status[z][x] & (~(3 << (y * 2)))) | (brightness << (y * 2));
}
static int get_status(int x, int y, int z) {
return LED_status[z][x] >> (y * 2) & 3;
}
static void clear() {
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
LED_status[i][j] = 0;
}
}
}
};
@@ -62,17 +77,83 @@ void setup() {
Serial.begin(115200);
randomSeed(analogRead(0));
}
void loop() {
// Ref: https://raw.githubusercontent.com/wiki/olikraus/u8glib/fontpic/u8g_font_u8glib_4.png
for (int i = 7; i >= 0; i--) {
for (int j = 0; j < 8; j++) {
for (int k = 0; k < 8; k++) {
Cube::set_status(i, j, k, bright);
delay(5);
}
}
}
bright = (bright + 1) % 4;
// for (int i = 7; i >= 0; i--) {
// for (int j = 0; j < 8; j++) {
// for (int k = 0; k < 8; k++) {
// Cube::set_status(i, j, k, bright);
// delay(5);
// }
// }
// }
// bright = (bright + 1) % 4;
// // 0
// Cube::clear();
// Cube::set_status(7, 0, 7, 3);
// Cube::set_status(7, 1, 7, 3);
// Cube::set_status(7, 2, 7, 3);
// Cube::set_status(7, 0, 6, 3);
// Cube::set_status(7, 2, 6, 3);
// Cube::set_status(7, 0, 5, 3);
// Cube::set_status(7, 2, 5, 3);
// Cube::set_status(7, 0, 4, 3);
// Cube::set_status(7, 1, 4, 3);
// Cube::set_status(7, 2, 4, 3);
// delay(5000);
// // 1
// Cube::clear();
// Cube::set_status(7, 1, 7, 3);
// Cube::set_status(7, 0, 6, 3);
// Cube::set_status(7, 1, 6, 3);
// Cube::set_status(7, 1, 5, 3);
// // Cube::set_status(7, 0, 4, 3);
// Cube::set_status(7, 1, 4, 3);
// // Cube::set_status(7, 2, 4, 3);
// delay(5000);
// 2
Cube::clear();
Cube::set_status(6, 0, 7, 3);
Cube::set_status(6, 1, 7, 3);
Cube::set_status(6, 2, 7, 3);
Cube::set_status(6, 2, 6, 3);
Cube::set_status(6, 1, 5, 3);
Cube::set_status(6, 0, 4, 3);
Cube::set_status(6, 1, 4, 3);
Cube::set_status(6, 2, 4, 3);
// delay(5000);
// 3
// Cube::clear();
Cube::set_status(7, 0, 3, 3);
Cube::set_status(7, 1, 3, 3);
Cube::set_status(7, 2, 3, 3);
Cube::set_status(7, 1, 2, 3);
Cube::set_status(7, 2, 1, 3);
Cube::set_status(7, 0, 0, 3);
Cube::set_status(7, 1, 0, 3);
Cube::set_status(7, 2, 0, 3);
delay(5000);
}