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) mkdir -p $(BUILD_DIR)
run: $(BIN) run: $(BIN)
# NOTE: This should probably be done on the C code.
echo 0 > /sys/class/graphics/fbcon/cursor_blink
./$(BIN) ./$(BIN)
clean: clean:

View File

@ -2,6 +2,7 @@
#include<stdlib.h> #include<stdlib.h>
#include<stdint.h> #include<stdint.h>
#include<stdbool.h> #include<stdbool.h>
#include<unistd.h>
#include<fcntl.h> #include<fcntl.h>
#include<linux/fb.h> #include<linux/fb.h>
#include<sys/ioctl.h> #include<sys/ioctl.h>
@ -30,14 +31,31 @@ main(void) {
fprintf(stderr, "couldn't mmap the framebuffer\n"); fprintf(stderr, "couldn't mmap the framebuffer\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
// Main loop.
uint8_t shade = 0; uint8_t shade = 0;
size_t counter = 0;
size_t direction = 1;
while (true) { while (true) {
for (size_t j = 0; j < height; j++) { for (size_t j = 0; j < height; j++) {
for (size_t i = 0; i < width; i++) { for (size_t i = 0; i < width; i++) {
buf[j * width + i] = shade; 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; return 0;
} }