Ensure cursor is not showing when running

This commit is contained in:
Bad Diode 2022-03-03 09:28:22 +00:00
parent 1d4759d8c0
commit fd20872250
2 changed files with 21 additions and 1 deletions

View File

@ -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:

View File

@ -2,6 +2,7 @@
#include<stdlib.h>
#include<stdint.h>
#include<stdbool.h>
#include<unistd.h>
#include<fcntl.h>
#include<linux/fb.h>
#include<sys/ioctl.h>
@ -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;
}