Raspberry Pi Weighting Control System
This project serves as a simple weighting control system, that was realized as a Bachelor Thesis
|
Functions | |
uint16_t | buffer_to_keycode (const uint8_t *rx_buffer) |
Concats keycode from rx_buffer into one (uint16_t) variable. rx_buffer is 4 bytes (this is assumed to always be true -> no error checking). Only middle bytes (index 1 and 2) are the actual keycode (byte_0 = cs, byte_3 = 00) More... | |
void | push_event (uint16_t scancode, uint8_t flags) |
Creates and pushes event into event_queue. More... | |
kb_event * | poll_event () |
Polls event from queue into param event Returns 1 on success because it is inteded to return "true" on successfull event pop. More... | |
void | clear_event_queue () |
With this the event queue can be cleared but all events are discarded. This can be used if limiting the maximum number of handled events. More... | |
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. More... | |
int | init_from_conf () |
Initializes my_spi with config loaded from config file into app_workspace. Starts SPI. More... | |
void | start_capturing_events () |
Infinite loop that reads SPI keyboard. Runs in it's own thread! More... | |
void | clean () |
Stops event capturing and closes SPI. More... | |
bool | get_kb_testing_inner () |
void | set_kb_testing_inner (bool val) |
Variables | |
std::queue< kb_event > | event_queue |
std::mutex | eq_mutex |
bool | kb_testing = false |
std::mutex | test_mtx |
unsigned long | responses_sum = 0 |
int | responses_passed = 0 |
std::unique_ptr< spi_config_t > | spi_config |
std::unique_ptr< SPI > | my_spi = nullptr |
bool | capturing_events = true |
uint16_t keyboard::buffer_to_keycode | ( | const uint8_t * | rx_buffer | ) |
Concats keycode from rx_buffer into one (uint16_t) variable. rx_buffer is 4 bytes (this is assumed to always be true -> no error checking). Only middle bytes (index 1 and 2) are the actual keycode (byte_0 = cs, byte_3 = 00)
rx_buffer | read byte buffer |
Definition at line 239 of file keyboard.cpp.
void keyboard::clean | ( | ) |
void keyboard::clear_event_queue | ( | ) |
With this the event queue can be cleared but all events are discarded. This can be used if limiting the maximum number of handled events.
Definition at line 70 of file keyboard.cpp.
bool keyboard::get_kb_testing_inner | ( | ) |
int keyboard::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.
device | |
mode | |
speed | |
delay | |
bits_per_word |
Definition at line 86 of file keyboard.cpp.
int keyboard::init_from_conf | ( | ) |
Initializes my_spi with config loaded from config file into app_workspace. Starts SPI.
Definition at line 116 of file keyboard.cpp.
kb_event * keyboard::poll_event | ( | ) |
Polls event from queue into param event Returns 1 on success because it is inteded to return "true" on successfull event pop.
event |
Definition at line 58 of file keyboard.cpp.
void keyboard::push_event | ( | uint16_t | scancode, |
uint8_t | flags | ||
) |
Creates and pushes event into event_queue.
scancode | one value keycode |
down | boolean - true if key is being held down, false (= up) on release of the key |
Definition at line 252 of file keyboard.cpp.
void keyboard::set_kb_testing_inner | ( | bool | val | ) |
Sets the kb_testing flag value
Definition at line 222 of file keyboard.cpp.
void keyboard::start_capturing_events | ( | ) |
Infinite loop that reads SPI keyboard. Runs in it's own thread!
Definition at line 140 of file keyboard.cpp.
bool keyboard::capturing_events = true |
Definition at line 36 of file keyboard.cpp.
std::mutex keyboard::eq_mutex |
Definition at line 25 of file keyboard.cpp.
std::queue<kb_event> keyboard::event_queue |
Definition at line 24 of file keyboard.cpp.
bool keyboard::kb_testing = false |
Definition at line 29 of file keyboard.cpp.
std::unique_ptr<SPI> keyboard::my_spi = nullptr |
Definition at line 35 of file keyboard.cpp.
int keyboard::responses_passed = 0 |
Definition at line 32 of file keyboard.cpp.
unsigned long keyboard::responses_sum = 0 |
Definition at line 31 of file keyboard.cpp.
std::unique_ptr<spi_config_t> keyboard::spi_config |
Definition at line 34 of file keyboard.cpp.
std::mutex keyboard::test_mtx |
Definition at line 30 of file keyboard.cpp.