mirror of
https://github.com/meshtastic/firmware.git
synced 2026-02-03 15:42:02 +00:00
I thought git would be smart enough to understand all the whitespace changes but even with all the flags I know to make it ignore theses it still blows up if there are identical changes on both sides.
I have a solution but it require creating a new commit at the merge base for each conflicting PR and merging it into develop.
I don't think blowing up all PRs is worth for now, maybe if we can coordinate this for V3 let's say.
This reverts commit 0d11331d18.
This commit is contained in:
@@ -24,161 +24,164 @@ unsigned char KeyMap[3][4][10] = {{{'.', 'a', 'd', 'g', 'j', 'm', 'p', 't', 'w',
|
||||
|
||||
#endif
|
||||
|
||||
SerialKeyboard::SerialKeyboard(const char *name) : concurrency::OSThread(name) {
|
||||
this->_originName = name;
|
||||
SerialKeyboard::SerialKeyboard(const char *name) : concurrency::OSThread(name)
|
||||
{
|
||||
this->_originName = name;
|
||||
|
||||
globalSerialKeyboard = this;
|
||||
globalSerialKeyboard = this;
|
||||
}
|
||||
|
||||
void SerialKeyboard::erase() {
|
||||
InputEvent e = {};
|
||||
e.inputEvent = INPUT_BROKER_BACK;
|
||||
e.kbchar = 0x08;
|
||||
e.source = this->_originName;
|
||||
this->notifyObservers(&e);
|
||||
void SerialKeyboard::erase()
|
||||
{
|
||||
InputEvent e = {};
|
||||
e.inputEvent = INPUT_BROKER_BACK;
|
||||
e.kbchar = 0x08;
|
||||
e.source = this->_originName;
|
||||
this->notifyObservers(&e);
|
||||
}
|
||||
|
||||
int32_t SerialKeyboard::runOnce() {
|
||||
if (!INPUTBROKER_SERIAL_TYPE) {
|
||||
// Input device is not requested.
|
||||
return disable();
|
||||
}
|
||||
|
||||
if (firstTime) {
|
||||
// This is the first time the OSThread library has called this function, so do port setup
|
||||
firstTime = 0;
|
||||
pinMode(KB_LOAD, OUTPUT);
|
||||
pinMode(KB_CLK, OUTPUT);
|
||||
pinMode(KB_DATA, INPUT);
|
||||
digitalWrite(KB_LOAD, HIGH);
|
||||
digitalWrite(KB_CLK, LOW);
|
||||
prevKeys = 0b1111111111111111;
|
||||
LOG_DEBUG("Serial Keyboard setup");
|
||||
}
|
||||
|
||||
if (INPUTBROKER_SERIAL_TYPE == 1) { // Chatter V1.0 & V2.0 keypads
|
||||
// scan for keypresses
|
||||
// Write pulse to load pin
|
||||
digitalWrite(KB_LOAD, LOW);
|
||||
delayMicroseconds(5);
|
||||
digitalWrite(KB_LOAD, HIGH);
|
||||
delayMicroseconds(5);
|
||||
|
||||
// Get data from 74HC165
|
||||
byte shiftRegister1 = shiftIn(KB_DATA, KB_CLK, LSBFIRST);
|
||||
byte shiftRegister2 = shiftIn(KB_DATA, KB_CLK, LSBFIRST);
|
||||
|
||||
keys = (shiftRegister1 << 8) + shiftRegister2;
|
||||
|
||||
// Print to serial monitor
|
||||
// Serial.print (shiftRegister1, BIN);
|
||||
// Serial.print ("X");
|
||||
// Serial.println (shiftRegister2, BIN);
|
||||
|
||||
if (!Throttle::isWithinTimespanMs(lastPressTime, 500)) {
|
||||
quickPress = 0;
|
||||
int32_t SerialKeyboard::runOnce()
|
||||
{
|
||||
if (!INPUTBROKER_SERIAL_TYPE) {
|
||||
// Input device is not requested.
|
||||
return disable();
|
||||
}
|
||||
|
||||
if (keys < prevKeys) { // a new key has been pressed (and not released), doesn't works for multiple presses at once
|
||||
// but shouldn't be a limitation
|
||||
InputEvent e = {};
|
||||
e.inputEvent = INPUT_BROKER_NONE;
|
||||
e.source = this->_originName;
|
||||
// SELECT OR SEND OR CANCEL EVENT
|
||||
if (!(shiftRegister2 & (1 << 3))) {
|
||||
if (shift > 0) {
|
||||
e.inputEvent = INPUT_BROKER_ANYKEY; // REQUIRED
|
||||
e.kbchar = 0x09; // TAB
|
||||
shift = 0; // reset shift after TAB
|
||||
} else {
|
||||
e.inputEvent = INPUT_BROKER_LEFT;
|
||||
}
|
||||
} else if (!(shiftRegister2 & (1 << 2))) {
|
||||
if (shift > 0) {
|
||||
e.inputEvent = INPUT_BROKER_ANYKEY; // REQUIRED
|
||||
e.kbchar = 0x09; // TAB
|
||||
shift = 0; // reset shift after TAB
|
||||
} else {
|
||||
e.inputEvent = INPUT_BROKER_RIGHT;
|
||||
}
|
||||
e.kbchar = 0;
|
||||
} else if (!(shiftRegister2 & (1 << 1))) {
|
||||
e.inputEvent = INPUT_BROKER_SELECT;
|
||||
} else if (!(shiftRegister2 & (1 << 0))) {
|
||||
e.inputEvent = INPUT_BROKER_CANCEL;
|
||||
}
|
||||
if (firstTime) {
|
||||
// This is the first time the OSThread library has called this function, so do port setup
|
||||
firstTime = 0;
|
||||
pinMode(KB_LOAD, OUTPUT);
|
||||
pinMode(KB_CLK, OUTPUT);
|
||||
pinMode(KB_DATA, INPUT);
|
||||
digitalWrite(KB_LOAD, HIGH);
|
||||
digitalWrite(KB_CLK, LOW);
|
||||
prevKeys = 0b1111111111111111;
|
||||
LOG_DEBUG("Serial Keyboard setup");
|
||||
}
|
||||
|
||||
// TEXT INPUT EVENT
|
||||
else if (!(shiftRegister1 & (1 << 4))) {
|
||||
keyPressed = 0;
|
||||
} else if (!(shiftRegister1 & (1 << 3))) {
|
||||
keyPressed = 1;
|
||||
} else if (!(shiftRegister2 & (1 << 4))) {
|
||||
keyPressed = 2;
|
||||
} else if (!(shiftRegister1 & (1 << 5))) {
|
||||
keyPressed = 3;
|
||||
} else if (!(shiftRegister1 & (1 << 2))) {
|
||||
keyPressed = 4;
|
||||
} else if (!(shiftRegister2 & (1 << 5))) {
|
||||
keyPressed = 5;
|
||||
} else if (!(shiftRegister1 & (1 << 6))) {
|
||||
keyPressed = 6;
|
||||
} else if (!(shiftRegister1 & (1 << 1))) {
|
||||
keyPressed = 7;
|
||||
} else if (!(shiftRegister2 & (1 << 6))) {
|
||||
keyPressed = 8;
|
||||
} else if (!(shiftRegister1 & (1 << 0))) {
|
||||
keyPressed = 9;
|
||||
}
|
||||
// BACKSPACE or TAB
|
||||
else if (!(shiftRegister1 & (1 << 7))) {
|
||||
if (shift == 0 || shift == 2) { // BACKSPACE
|
||||
e.inputEvent = INPUT_BROKER_BACK;
|
||||
e.kbchar = 0x08;
|
||||
} else { // shift = 1 => TAB
|
||||
e.inputEvent = INPUT_BROKER_ANYKEY;
|
||||
e.kbchar = 0x09;
|
||||
}
|
||||
}
|
||||
// SHIFT
|
||||
else if (!(shiftRegister2 & (1 << 7))) {
|
||||
keyPressed = 10;
|
||||
}
|
||||
if (INPUTBROKER_SERIAL_TYPE == 1) { // Chatter V1.0 & V2.0 keypads
|
||||
// scan for keypresses
|
||||
// Write pulse to load pin
|
||||
digitalWrite(KB_LOAD, LOW);
|
||||
delayMicroseconds(5);
|
||||
digitalWrite(KB_LOAD, HIGH);
|
||||
delayMicroseconds(5);
|
||||
|
||||
if (keyPressed < 11) {
|
||||
if (keyPressed == lastKeyPressed && millis() - lastPressTime < 500) {
|
||||
quickPress += 1;
|
||||
if (quickPress > 3) {
|
||||
// Get data from 74HC165
|
||||
byte shiftRegister1 = shiftIn(KB_DATA, KB_CLK, LSBFIRST);
|
||||
byte shiftRegister2 = shiftIn(KB_DATA, KB_CLK, LSBFIRST);
|
||||
|
||||
keys = (shiftRegister1 << 8) + shiftRegister2;
|
||||
|
||||
// Print to serial monitor
|
||||
// Serial.print (shiftRegister1, BIN);
|
||||
// Serial.print ("X");
|
||||
// Serial.println (shiftRegister2, BIN);
|
||||
|
||||
if (!Throttle::isWithinTimespanMs(lastPressTime, 500)) {
|
||||
quickPress = 0;
|
||||
}
|
||||
}
|
||||
if (keyPressed != lastKeyPressed) {
|
||||
quickPress = 0;
|
||||
}
|
||||
if (keyPressed < 10) { // if it's a letter
|
||||
if (keyPressed == lastKeyPressed && millis() - lastPressTime < 500) {
|
||||
erase();
|
||||
}
|
||||
e.inputEvent = INPUT_BROKER_ANYKEY;
|
||||
e.kbchar = char(KeyMap[shift][quickPress][keyPressed]);
|
||||
} else { // then it's shift
|
||||
shift += 1;
|
||||
if (shift > 2) {
|
||||
shift = 0;
|
||||
}
|
||||
}
|
||||
lastPressTime = millis();
|
||||
lastKeyPressed = keyPressed;
|
||||
keyPressed = 13;
|
||||
}
|
||||
|
||||
if (e.inputEvent != INPUT_BROKER_NONE) {
|
||||
this->notifyObservers(&e);
|
||||
}
|
||||
if (keys < prevKeys) { // a new key has been pressed (and not released), doesn't works for multiple presses at once but
|
||||
// shouldn't be a limitation
|
||||
InputEvent e = {};
|
||||
e.inputEvent = INPUT_BROKER_NONE;
|
||||
e.source = this->_originName;
|
||||
// SELECT OR SEND OR CANCEL EVENT
|
||||
if (!(shiftRegister2 & (1 << 3))) {
|
||||
if (shift > 0) {
|
||||
e.inputEvent = INPUT_BROKER_ANYKEY; // REQUIRED
|
||||
e.kbchar = 0x09; // TAB
|
||||
shift = 0; // reset shift after TAB
|
||||
} else {
|
||||
e.inputEvent = INPUT_BROKER_LEFT;
|
||||
}
|
||||
} else if (!(shiftRegister2 & (1 << 2))) {
|
||||
if (shift > 0) {
|
||||
e.inputEvent = INPUT_BROKER_ANYKEY; // REQUIRED
|
||||
e.kbchar = 0x09; // TAB
|
||||
shift = 0; // reset shift after TAB
|
||||
} else {
|
||||
e.inputEvent = INPUT_BROKER_RIGHT;
|
||||
}
|
||||
e.kbchar = 0;
|
||||
} else if (!(shiftRegister2 & (1 << 1))) {
|
||||
e.inputEvent = INPUT_BROKER_SELECT;
|
||||
} else if (!(shiftRegister2 & (1 << 0))) {
|
||||
e.inputEvent = INPUT_BROKER_CANCEL;
|
||||
}
|
||||
|
||||
// TEXT INPUT EVENT
|
||||
else if (!(shiftRegister1 & (1 << 4))) {
|
||||
keyPressed = 0;
|
||||
} else if (!(shiftRegister1 & (1 << 3))) {
|
||||
keyPressed = 1;
|
||||
} else if (!(shiftRegister2 & (1 << 4))) {
|
||||
keyPressed = 2;
|
||||
} else if (!(shiftRegister1 & (1 << 5))) {
|
||||
keyPressed = 3;
|
||||
} else if (!(shiftRegister1 & (1 << 2))) {
|
||||
keyPressed = 4;
|
||||
} else if (!(shiftRegister2 & (1 << 5))) {
|
||||
keyPressed = 5;
|
||||
} else if (!(shiftRegister1 & (1 << 6))) {
|
||||
keyPressed = 6;
|
||||
} else if (!(shiftRegister1 & (1 << 1))) {
|
||||
keyPressed = 7;
|
||||
} else if (!(shiftRegister2 & (1 << 6))) {
|
||||
keyPressed = 8;
|
||||
} else if (!(shiftRegister1 & (1 << 0))) {
|
||||
keyPressed = 9;
|
||||
}
|
||||
// BACKSPACE or TAB
|
||||
else if (!(shiftRegister1 & (1 << 7))) {
|
||||
if (shift == 0 || shift == 2) { // BACKSPACE
|
||||
e.inputEvent = INPUT_BROKER_BACK;
|
||||
e.kbchar = 0x08;
|
||||
} else { // shift = 1 => TAB
|
||||
e.inputEvent = INPUT_BROKER_ANYKEY;
|
||||
e.kbchar = 0x09;
|
||||
}
|
||||
}
|
||||
// SHIFT
|
||||
else if (!(shiftRegister2 & (1 << 7))) {
|
||||
keyPressed = 10;
|
||||
}
|
||||
|
||||
if (keyPressed < 11) {
|
||||
if (keyPressed == lastKeyPressed && millis() - lastPressTime < 500) {
|
||||
quickPress += 1;
|
||||
if (quickPress > 3) {
|
||||
quickPress = 0;
|
||||
}
|
||||
}
|
||||
if (keyPressed != lastKeyPressed) {
|
||||
quickPress = 0;
|
||||
}
|
||||
if (keyPressed < 10) { // if it's a letter
|
||||
if (keyPressed == lastKeyPressed && millis() - lastPressTime < 500) {
|
||||
erase();
|
||||
}
|
||||
e.inputEvent = INPUT_BROKER_ANYKEY;
|
||||
e.kbchar = char(KeyMap[shift][quickPress][keyPressed]);
|
||||
} else { // then it's shift
|
||||
shift += 1;
|
||||
if (shift > 2) {
|
||||
shift = 0;
|
||||
}
|
||||
}
|
||||
lastPressTime = millis();
|
||||
lastKeyPressed = keyPressed;
|
||||
keyPressed = 13;
|
||||
}
|
||||
|
||||
if (e.inputEvent != INPUT_BROKER_NONE) {
|
||||
this->notifyObservers(&e);
|
||||
}
|
||||
}
|
||||
prevKeys = keys;
|
||||
}
|
||||
prevKeys = keys;
|
||||
}
|
||||
return 50;
|
||||
return 50;
|
||||
}
|
||||
|
||||
#endif // INPUTBROKER_SERIAL_TYPE
|
||||
Reference in New Issue
Block a user