Prettier, better terminal handling, more variation

This commit is contained in:
Toby Jaffey 2025-12-08 21:41:51 +00:00
parent 54f71f18c2
commit 7e7cabeb24
3 changed files with 18 additions and 10 deletions

View file

@ -6,7 +6,7 @@ PREFIX:=${DOCKER_CMD} riscv64-unknown-elf-
CFLAGS+=-I../../common
CFLAGS+=-fno-stack-protector
CFLAGS+=-static-libgcc -fdata-sections -ffunction-sections
CFLAGS+=-g -Os -march=rv32ima_zicsr -mabi=ilp32 -static
CFLAGS+=-g -O6 -march=rv32ima_zicsr -mabi=ilp32 -static
LDFLAGS:= -T ../linker.ld -nostdlib -Wl,--gc-sections
LIBS:= -lgcc # needed for softfp

View file

@ -86,13 +86,14 @@ double cos(double x) {
}
void main(void) {
int freq1 = 45;
int freq2 = 90;
float freq1 = 45;
float freq2 = 90;
for (int i = 0; i < 300; i++) {
putc('\n');
}
print("\033[H"); // Cursor at Corner of Screen
print("\033[?25l"); // hide cursor
float x = 0;
float y = 0;
@ -101,18 +102,25 @@ void main(void) {
while (1) {
uint32_t framestart = millis();
for (angle = 0; angle < 2 * PI; angle += 0.15) {
print("\033[?2026h"); // pause updates
print("\033[2J"); // cls
for (angle = 0; angle < 2 * PI; angle += 0.2) {
movecursor(x, y);
x = 40 * cos(freq1 * angle + beta) + 60;
y = 20 * sin(freq2 * angle) + 30;
x = 20 * cos(freq1 * angle + beta) + 30;
y = 10 * sin(freq2 * angle) + 15;
print("#");
}
print("\033[?2026l"); // resume updates
// wait for next frame
while (millis() < framestart + 20) {
while (millis() < framestart + (1000 / 30)) {
yield();
}
beta += 0.05;
print("\033[2J");
freq1 += 0.01;
freq2 += 0.005;
}
}

Binary file not shown.