aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2022-03-03 09:28:22 +0000
committerBad Diode <bd@badd10de.dev>2022-03-03 09:28:22 +0000
commitfd2087225089ccb37a63cbddf786a5efaf5a0377 (patch)
tree5ecd51fa57feaff12f8dff954c8189cf5643e6c2
parent1d4759d8c04f18dc2e4f3ce45c4656f85f7301a7 (diff)
downloaduxnfb-fd2087225089ccb37a63cbddf786a5efaf5a0377.tar.gz
uxnfb-fd2087225089ccb37a63cbddf786a5efaf5a0377.zip
Ensure cursor is not showing when running
-rw-r--r--Makefile2
-rw-r--r--src/main.c20
2 files changed, 21 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 53d756b..5face8f 100644
--- a/Makefile
+++ b/Makefile
@@ -30,6 +30,8 @@ $(BUILD_DIR):
30 mkdir -p $(BUILD_DIR) 30 mkdir -p $(BUILD_DIR)
31 31
32run: $(BIN) 32run: $(BIN)
33 # NOTE: This should probably be done on the C code.
34 echo 0 > /sys/class/graphics/fbcon/cursor_blink
33 ./$(BIN) 35 ./$(BIN)
34 36
35clean: 37clean:
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 @@
2#include<stdlib.h> 2#include<stdlib.h>
3#include<stdint.h> 3#include<stdint.h>
4#include<stdbool.h> 4#include<stdbool.h>
5#include<unistd.h>
5#include<fcntl.h> 6#include<fcntl.h>
6#include<linux/fb.h> 7#include<linux/fb.h>
7#include<sys/ioctl.h> 8#include<sys/ioctl.h>
@@ -30,14 +31,31 @@ main(void) {
30 fprintf(stderr, "couldn't mmap the framebuffer\n"); 31 fprintf(stderr, "couldn't mmap the framebuffer\n");
31 exit(EXIT_FAILURE); 32 exit(EXIT_FAILURE);
32 } 33 }
34
35 // Main loop.
33 uint8_t shade = 0; 36 uint8_t shade = 0;
37 size_t counter = 0;
38 size_t direction = 1;
34 while (true) { 39 while (true) {
35 for (size_t j = 0; j < height; j++) { 40 for (size_t j = 0; j < height; j++) {
36 for (size_t i = 0; i < width; i++) { 41 for (size_t i = 0; i < width; i++) {
37 buf[j * width + i] = shade; 42 buf[j * width + i] = shade;
38 } 43 }
39 } 44 }
40 shade++; 45 counter++;
46 if (counter > 10) {
47 shade += direction;
48 counter = 0;
49 }
50 if (shade == 0xFF) {
51 direction = -1;
52 } else if (shade == 0x00) {
53 direction = 1;
54 }
41 } 55 }
56
57 // Cleanup.
58 munmap(buf, len);
59 close(fb);
42 return 0; 60 return 0;
43} 61}