Raspberry Pi Weighting Control System
This project serves as a simple weighting control system, that was realized as a Bachelor Thesis
Namespaces | Macros | Functions | Variables
keyboard.cpp File Reference
#include "keyboard.h"
#include <memory>
#include <SDL2/SDL.h>
#include <unistd.h>
#include <sys/time.h>
#include <vector>
#include <stdexcept>
#include <map>
#include <chrono>
#include <spdlog/spdlog.h>
#include "app_workspace.h"

Go to the source code of this file.

Namespaces

 keyboard
 

Macros

#define READ_INTERVAL   20000
 
#define RESPONSES_AVG_CNT   200
 

Functions

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) More...
 
void keyboard::push_event (uint16_t scancode, uint8_t flags)
 Creates and pushes event into event_queue. More...
 
kb_eventkeyboard::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 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. More...
 
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. More...
 
int keyboard::init_from_conf ()
 Initializes my_spi with config loaded from config file into app_workspace. Starts SPI. More...
 
void keyboard::start_capturing_events ()
 Infinite loop that reads SPI keyboard. Runs in it's own thread! More...
 
void keyboard::clean ()
 Stops event capturing and closes SPI. More...
 
bool keyboard::get_kb_testing_inner ()
 
void keyboard::set_kb_testing_inner (bool val)
 

Variables

std::queue< kb_eventkeyboard::event_queue
 
std::mutex keyboard::eq_mutex
 
bool keyboard::kb_testing = false
 
std::mutex keyboard::test_mtx
 
unsigned long keyboard::responses_sum = 0
 
int keyboard::responses_passed = 0
 
std::unique_ptr< spi_config_t > keyboard::spi_config
 
std::unique_ptr< SPI > keyboard::my_spi = nullptr
 
bool keyboard::capturing_events = true
 

Macro Definition Documentation

◆ READ_INTERVAL

#define READ_INTERVAL   20000

Definition at line 15 of file keyboard.cpp.

◆ RESPONSES_AVG_CNT

#define RESPONSES_AVG_CNT   200

Definition at line 16 of file keyboard.cpp.