diff --git a/Makefile b/Makefile index 53d756b..5face8f 100644 --- a/Makefile +++ b/Makefile @@ -30,6 +30,8 @@ $(BUILD_DIR): mkdir -p $(BUILD_DIR) run: $(BIN) + # NOTE: This should probably be done on the C code. + echo 0 > /sys/class/graphics/fbcon/cursor_blink ./$(BIN) clean: diff --git a/src/main.c b/src/main.c index e3e8b77..b5247af 100644 --- a/src/main.c +++ b/src/main.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -30,14 +31,31 @@ main(void) { fprintf(stderr, "couldn't mmap the framebuffer\n"); exit(EXIT_FAILURE); } + + // Main loop. uint8_t shade = 0; + size_t counter = 0; + size_t direction = 1; while (true) { for (size_t j = 0; j < height; j++) { for (size_t i = 0; i < width; i++) { buf[j * width + i] = shade; } } - shade++; + counter++; + if (counter > 10) { + shade += direction; + counter = 0; + } + if (shade == 0xFF) { + direction = -1; + } else if (shade == 0x00) { + direction = 1; + } } + + // Cleanup. + munmap(buf, len); + close(fb); return 0; }