Rearrange the file layout in preparation of becoming a monorepo

Move the documentation to `doc/plugin/Model01-TestMode.md`, sources under
`src/kaleidoscope/plugin/` (appropriately namespaced). This is in preparation of
merging plugins into a single monorepo.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/365/head
Gergely Nagy 6 years ago
parent 88d3ed3780
commit 3130555de3
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -0,0 +1,8 @@
# Kaleidoscope-Model01-TestMode
[![Build Status][travis:image]][travis:status]
[travis:image]: https://travis-ci.org/keyboardio/Kaleidoscope-Model01-TestMode.svg?branch=master
[travis:status]: https://travis-ci.org/keyboardio/Kaleidoscope-Model01-TestMode
See [doc/plugin/Model01-TestMode.md](doc/plugin/Model01-TestMode.md) for documentation.

@ -16,34 +16,4 @@
#pragma once
#ifndef ARDUINO_AVR_MODEL01
#error The Kaleidoscope-Model01-TestMode plugin was designed for the Keyboardio Model01, and does not work with any other hardware.
#endif
#include <Arduino.h>
#include "Kaleidoscope.h"
typedef struct {
uint8_t cyclesSinceStateChange[32];
uint32_t badKeys;
} side_data_t;
class TestMode_ : public kaleidoscope::Plugin {
public:
TestMode_(void) {};
kaleidoscope::EventHandlerResult beforeReportingState();
private:
static void run_tests();
static void test_leds();
static void testMatrix();
static void toggle_programming_leds_on();
static void handleKeyEvent(side_data_t *side, keydata_t *oldState, keydata_t *newState, uint8_t row, uint8_t col, uint8_t col_offset);
static void waitForKeypress();
static void set_leds(cRGB color);
};
extern TestMode_ TestMode;
Key handleKeyswitchEvent_test(Key mappedKey, byte row, byte col, uint8_t keyState);
#include "kaleidoscope/plugin/Model01-TestMode.h"

@ -18,6 +18,8 @@
#include "Kaleidoscope-Model01-TestMode.h"
#include "Kaleidoscope-LEDEffect-Rainbow.h"
namespace kaleidoscope {
namespace plugin {
constexpr uint8_t CHATTER_CYCLE_LIMIT = 30;
constexpr uint8_t TOGGLED_OFF = 2;
@ -25,18 +27,17 @@ constexpr uint8_t TOGGLED_ON = 1;
constexpr uint8_t HELD = 3;
constexpr uint8_t RELEASED = 0;
kaleidoscope::EventHandlerResult TestMode_::beforeReportingState() {
EventHandlerResult TestMode::beforeReportingState() {
if (KeyboardHardware.isKeyswitchPressed(R0C0) &&
KeyboardHardware.isKeyswitchPressed(R0C6) &&
KeyboardHardware.isKeyswitchPressed(R3C6) &&
KeyboardHardware.pressedKeyswitchCount() == 3) {
run_tests();
}
return kaleidoscope::EventHandlerResult::OK;
return EventHandlerResult::OK;
}
void TestMode_::waitForKeypress() {
void TestMode::waitForKeypress() {
for (uint8_t temp = 0; temp < 8; temp++) {
KeyboardHardware.readMatrix();
}
@ -50,13 +51,13 @@ void TestMode_::waitForKeypress() {
}
}
void TestMode_::set_leds(cRGB color) {
LEDControl.set_all_leds_to(color);
LEDControl.syncLeds();
void TestMode::set_leds(cRGB color) {
::LEDControl.set_all_leds_to(color);
::LEDControl.syncLeds();
waitForKeypress();
}
void TestMode_::test_leds(void) {
void TestMode::test_leds(void) {
constexpr cRGB red = CRGB(201, 0, 0);
constexpr cRGB blue = CRGB(0, 0, 201);
constexpr cRGB green = CRGB(0, 201, 0);
@ -72,15 +73,15 @@ void TestMode_::test_leds(void) {
set_leds(brightWhite);
// rainbow for 10 seconds
for (auto i = 0; i < 1000; i++) {
LEDRainbowEffect.update();
LEDControl.syncLeds();
::LEDRainbowEffect.update();
::LEDControl.syncLeds();
}
waitForKeypress();
}
void TestMode_::handleKeyEvent(side_data_t *side, keydata_t *oldState, keydata_t *newState, uint8_t row, uint8_t col, uint8_t col_offset) {
void TestMode::handleKeyEvent(side_data_t *side, keydata_t *oldState, keydata_t *newState, uint8_t row, uint8_t col, uint8_t col_offset) {
constexpr cRGB red = CRGB(201, 0, 0);
constexpr cRGB blue = CRGB(0, 0, 201);
@ -117,13 +118,13 @@ void TestMode_::handleKeyEvent(side_data_t *side, keydata_t *oldState, keydata_t
}
void TestMode_::testMatrix() {
void TestMode::testMatrix() {
// Reset bad keys from previous tests.
side_data_t left = {{0}, 0};
side_data_t right = {{0}, 0};
LEDControl.set_all_leds_to(200, 0, 0);
::LEDControl.set_all_leds_to(200, 0, 0);
// Clear out the key event buffer so we don't get messed up information from
// taps during LED test mode.
while (1) {
@ -140,16 +141,16 @@ void TestMode_::testMatrix() {
handleKeyEvent(&right, &(KeyboardHardware.previousRightHandState), &(KeyboardHardware.rightHandState), row, col, 15);
}
}
LEDControl.syncLeds();
::LEDControl.syncLeds();
}
}
void TestMode_::toggle_programming_leds_on() {
void TestMode::toggle_programming_leds_on() {
PORTD |= (1 << 5);
PORTB |= (1 << 0);
}
void TestMode_::run_tests() {
void TestMode::run_tests() {
// Serial.println("Running tests");
toggle_programming_leds_on();
// Disable debouncing
@ -159,4 +160,7 @@ void TestMode_::run_tests() {
// Serial.println("Done running tests");
}
TestMode_ TestMode;
}
}
kaleidoscope::plugin::TestMode TestMode;

@ -0,0 +1,53 @@
/* Kaleidoscope-Model01-TestMode - A factory test mode for the Model 01.
* Copyright (C) 2017-2018 Keyboard.io, Inc.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#ifndef ARDUINO_AVR_MODEL01
#error The Kaleidoscope-Model01-TestMode plugin was designed for the Keyboardio Model01, and does not work with any other hardware.
#endif
#include <Arduino.h>
#include "Kaleidoscope.h"
namespace kaleidoscope {
namespace plugin {
class TestMode : public kaleidoscope::Plugin {
public:
typedef struct {
uint8_t cyclesSinceStateChange[32];
uint32_t badKeys;
} side_data_t;
TestMode(void) {};
EventHandlerResult beforeReportingState();
private:
static void run_tests();
static void test_leds();
static void testMatrix();
static void toggle_programming_leds_on();
static void handleKeyEvent(side_data_t *side, keydata_t *oldState, keydata_t *newState, uint8_t row, uint8_t col, uint8_t col_offset);
static void waitForKeypress();
static void set_leds(cRGB color);
};
}
}
extern kaleidoscope::plugin::TestMode TestMode;
Loading…
Cancel
Save