Fixed formatting

This commit is contained in:
Mattias Lasersköld 2020-03-14 10:56:54 +01:00
parent e053a7b4b0
commit 0f26e38b84
11 changed files with 122 additions and 111 deletions

View File

@ -1,2 +1,17 @@
BasedOnStyle: LLVM
IndentWidth: 4
SortIncludes: true
AccessModifierOffset: -4
AlwaysBreakTemplateDeclarations: true
AllowShortFunctionsOnASingleLine: None
AllowAllArgumentsOnNextLine: true
BinPackArguments: false
BinPackParameters: false
BreakBeforeBraces: Custom
BraceWrapping:
BeforeCatch: true
BeforeElse: true
AlwaysBreakAfterReturnType: None
PenaltyReturnTypeOnItsOwnLine: 1000000

View File

@ -23,8 +23,6 @@ keyboard_state_t state;
KeyboardMap keyboardMap(width, height, keyConfig1);
void setup() {
for (auto pin : xPins) {
pinMode(pin, OUTPUT);
@ -61,5 +59,3 @@ void loop() {
readRowPins(state, x);
}
}

View File

@ -4,7 +4,6 @@
#include "keyboardwritefunctions.h"
#include "keys.h"
//! A class for translating key coordinates to scancodes
class KeyboardMap {
size_t _width;
@ -15,7 +14,8 @@ class KeyboardMap {
public:
KeyboardMap(size_t width, size_t height, const char *values)
: _width(width), _height(height), _size(width * height),
_translation(values) {}
_translation(values) {
}
void publishEvent(size_t x, size_t y, bool keyValue) {
size_t index = x + y * _width;
@ -23,7 +23,8 @@ public:
auto out = _translation[index];
if (keyValue) {
writeKeyPress(out);
} else {
}
else {
writeKeyRelease(out);
}
}

View File

@ -8,6 +8,10 @@ public:
typedef char state_t;
// Todo: Bounds check
state_t state(size_t x, size_t y) const { return _state[y * width + x]; }
state_t &state(size_t x, size_t y) { return _state[y * width + x]; }
state_t state(size_t x, size_t y) const {
return _state[y * width + x];
}
state_t &state(size_t x, size_t y) {
return _state[y * width + x];
}
};

View File

@ -12,6 +12,3 @@ constexpr size_t height = 5;
const char xPins[width] = {1, 2, 3, 4, 5, 6};
const char yPins[height] = {8, 9, 10, 11, 12};

View File

@ -8,12 +8,14 @@
#include <iostream>
using namespace std;
std::string scanCodeLookup(int code); // Defined in main
void writeKeyRelease(char key) {
cout << "Key released " << key << endl;
}
void writeKeyPress(char key) {
cout << "keyboard.cpp: key pressed " << key << ", " << static_cast<unsigned>(key) << endl;
cout << "keyboard.cpp: key pressed " << key << ", "
<< static_cast<unsigned>(key) << endl;
cout << "that is: " << scanCodeLookup(key) << endl;
}

View File

@ -8,12 +8,12 @@
#include "keys.h"
#include "matgui/application.h"
#include "matgui/window.h"
#include "matgui/button.h"
#include "matgui/window.h"
// Simulator
#include "simio.h"
#include "keyboardwritefunctions.h"
#include "simio.h"
// The code
#include "io.h"
@ -23,6 +23,10 @@
using namespace std;
using namespace MatGui;
std::string scanCodeLookup(int code) {
return Application::GetKeyNameFromScancode(code);
}
int main(int argc, char **argv) {
Application app(argc, argv);
@ -48,12 +52,7 @@ int main(int argc, char **argv) {
window.addChild(std::move(layout));
}
window.frameUpdate.connect([]() {
loop();
});
window.frameUpdate.connect([]() { loop(); });
app.mainLoop();
}

View File

@ -25,7 +25,6 @@
static class SerialPort {
public:
template <class T>
void print(const T &value);
@ -36,8 +35,7 @@ int digitalRead(uint8_t pin);
void pinMode(uint8_t pin, uint8_t mode);
template <class T>
inline void SerialPort::print(const T& value)
{
inline void SerialPort::print(const T &value) {
std::cout << value << std::endl;
}
@ -46,4 +44,3 @@ namespace simio {
void setSimKey(size_t x, size_t y, uint8_t state);
}