Raspberry Pi Weighting Control System
This project serves as a simple weighting control system, that was realized as a Bachelor Thesis
keyboard.h
Go to the documentation of this file.
1 #ifndef KEYBOARD_H
2 #define KEYBOARD_H
3 
4 // this is included in SPI lib, maybe include the lib here
5 //#include <stdint.h> // WHY DOESNT IT NEED THIS????????
6 #include <queue>
7 #include <sys/time.h>
8 #include <stdint.h>
9 
11 enum KB_FLAGS_ {
12  KB_FLAGS_NONE = 0x00,
13  KB_FLAGS_KEY_DOWN = 0x01 << 0,
14  KB_FLAGS_REPEATING = 0x01 << 1,
15  KB_FLAGS_TEST = 0x01 << 2,
16 
17 };
18 
23 typedef struct {
24  uint16_t scancode;
25  uint8_t flags;
26  struct timeval timestamp;
27 } kb_event;
28 
29 namespace keyboard {
30  // some of the functions are documented in the source file
31 
38  void clear_event_queue();
39 
40 
41  int init(const char*, uint8_t = 0, uint32_t = 500000, uint16_t = 0, uint8_t = 8);
42  int init_from_conf();
43  bool get_kb_testing_inner();
44  void set_kb_testing_inner(bool val);
46  void clean();
47 }
48 
49 #endif
KB_FLAGS_
Definition: keyboard.h:11
@ KB_FLAGS_REPEATING
Definition: keyboard.h:14
@ KB_FLAGS_TEST
Definition: keyboard.h:15
@ KB_FLAGS_NONE
Definition: keyboard.h:12
@ KB_FLAGS_KEY_DOWN
Definition: keyboard.h:13
void clear_event_queue()
With this the event queue can be cleared but all events are discarded. This can be used if limiting t...
Definition: keyboard.cpp:70
void start_capturing_events()
Infinite loop that reads SPI keyboard. Runs in it's own thread!
Definition: keyboard.cpp:140
void set_kb_testing_inner(bool val)
Definition: keyboard.cpp:222
bool get_kb_testing_inner()
Definition: keyboard.cpp:216
int init(const char *device, uint8_t mode, uint32_t speed, uint16_t delay, uint8_t bits_per_word)
Initializes spi_config and my_spi global variables and starts SPI.
Definition: keyboard.cpp:86
void clean()
Stops event capturing and closes SPI.
Definition: keyboard.cpp:209
int init_from_conf()
Initializes my_spi with config loaded from config file into app_workspace. Starts SPI.
Definition: keyboard.cpp:116
kb_event * poll_event()
Polls event from queue into param event Returns 1 on success because it is inteded to return "true" o...
Definition: keyboard.cpp:58
Structure of SPI keyboard event, Contains pressed scancode, flags and timestamp of event creation.
Definition: keyboard.h:23
uint8_t flags
Definition: keyboard.h:25
uint16_t scancode
Definition: keyboard.h:24