Skip to content

Commit d03ed9b

Browse files
[Thread tutorial] Screen start and checkpoint 6
1 parent 1b4cedb commit d03ed9b

File tree

5 files changed

+59
-0
lines changed

5 files changed

+59
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Makefile for user application
2+
3+
# Specify this directory relative to the current application.
4+
TOCK_USERLAND_BASE_DIR = ../../../../
5+
6+
# Which files to compile.
7+
C_SRCS := $(wildcard *.c)
8+
9+
PACKAGE_NAME = screen
10+
11+
# Include userland master makefile. Contains rules and flags for actually
12+
# building the application.
13+
include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <stdbool.h>
2+
#include <stdint.h>
3+
#include <stdio.h>
4+
#include <string.h>
5+
6+
int main(void) {
7+
8+
}
198 KB
Binary file not shown.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Makefile for user application
2+
3+
# Specify this directory relative to the current application.
4+
TOCK_USERLAND_BASE_DIR = ../../../../
5+
6+
# Which files to compile.
7+
C_SRCS := $(wildcard *.c)
8+
9+
PACKAGE_NAME = screen
10+
11+
# Include userland master makefile. Contains rules and flags for actually
12+
# building the application.
13+
include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <stdbool.h>
2+
#include <stdint.h>
3+
#include <stdio.h>
4+
#include <string.h>
5+
6+
#include <libtock/interface/button.h>
7+
8+
static void button_callback(returncode_t ret,
9+
int btn_num,
10+
bool pressed) {
11+
12+
if (pressed) {
13+
printf("Button %i pressed!\r\n", btn_num);
14+
}
15+
}
16+
17+
int main(void) {
18+
for (int i = 0; i < 4; i++){
19+
libtock_button_notify_on_press(i, button_callback);
20+
}
21+
22+
for(;;) {
23+
yield();
24+
}
25+
}

0 commit comments

Comments
 (0)