You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
3.1 KiB
118 lines
3.1 KiB
8 years ago
|
#include "KeyboardioFirmware.h"
|
||
|
#include "TestMode.h"
|
||
8 years ago
|
#include "LED-RainbowEffect.h"
|
||
|
|
||
8 years ago
|
cRGB red;
|
||
|
cRGB blue;
|
||
|
|
||
|
#define LED_TEST_DELAY 2000
|
||
|
|
||
8 years ago
|
TestMode_::TestMode_(void) {
|
||
|
}
|
||
|
|
||
8 years ago
|
void TestMode_::TestLEDs(void) {
|
||
8 years ago
|
// make all LEDs dim red
|
||
|
LEDControl.set_all_leds_to(50,0,0);
|
||
8 years ago
|
LEDControl.led_sync();
|
||
8 years ago
|
delay(LED_TEST_DELAY);
|
||
8 years ago
|
// make all LEDs dim blue
|
||
|
LEDControl.set_all_leds_to(0,50,0);
|
||
8 years ago
|
LEDControl.led_sync();
|
||
8 years ago
|
delay(LED_TEST_DELAY);
|
||
8 years ago
|
// make all LEDs dim green
|
||
|
LEDControl.set_all_leds_to(0,0,50);
|
||
8 years ago
|
LEDControl.led_sync();
|
||
8 years ago
|
delay(LED_TEST_DELAY);
|
||
8 years ago
|
// make all LEDs dim white
|
||
|
LEDControl.set_all_leds_to(50,50,50);
|
||
8 years ago
|
LEDControl.led_sync();
|
||
8 years ago
|
delay(LED_TEST_DELAY);
|
||
8 years ago
|
// make all the LEDs bright red
|
||
|
LEDControl.set_all_leds_to(200,0,0);
|
||
8 years ago
|
LEDControl.led_sync();
|
||
8 years ago
|
delay(LED_TEST_DELAY);
|
||
8 years ago
|
// make all the LEDs bright green
|
||
|
LEDControl.set_all_leds_to(0,200,0);
|
||
8 years ago
|
LEDControl.led_sync();
|
||
8 years ago
|
delay(LED_TEST_DELAY);
|
||
8 years ago
|
// make all the LEDs bright blue
|
||
|
LEDControl.set_all_leds_to(0,0,200);
|
||
8 years ago
|
LEDControl.led_sync();
|
||
8 years ago
|
delay(LED_TEST_DELAY);
|
||
8 years ago
|
// make all the LEDs bright white (1.6A)
|
||
|
LEDControl.set_all_leds_to(160,160,160);
|
||
8 years ago
|
LEDControl.led_sync();
|
||
8 years ago
|
delay(LED_TEST_DELAY);
|
||
8 years ago
|
// rainbow for 10 seconds
|
||
8 years ago
|
for(auto i=0; i<1000; i++ ) {
|
||
8 years ago
|
LEDRainbowEffect.update();
|
||
8 years ago
|
LEDControl.led_sync();
|
||
8 years ago
|
}
|
||
|
// set all the keys to red
|
||
|
LEDControl.set_all_leds_to(50,0,0);
|
||
|
// make all LEDs dim blue
|
||
|
// as you hit each key, set it to blue
|
||
|
// as you hit each key a second time, set it to green
|
||
|
// as you hit each key a third time, set it to off
|
||
8 years ago
|
}
|
||
8 years ago
|
|
||
|
|
||
|
|
||
8 years ago
|
|
||
8 years ago
|
void TestMode_::TestMatrix () {
|
||
8 years ago
|
while(1) {
|
||
|
KeyboardHardware.read_matrix();
|
||
|
for (byte row = 0; row < 4; row++) {
|
||
|
for (byte col = 0; col < 8; col++) {
|
||
|
|
||
|
uint8_t keynum = (row*8)+(col);
|
||
|
|
||
|
uint8_t keyState = (bitRead(KeyboardHardware.previousLeftHandState.all, keynum) << 0) |
|
||
|
(bitRead(KeyboardHardware.leftHandState.all, keynum) << 1);
|
||
|
|
||
|
if(keyState ==3 ) {
|
||
|
Serial.print(" Key: ");
|
||
|
Serial.print(keynum);
|
||
|
Serial.print(" value ");
|
||
|
Serial.println(keyState);
|
||
|
KeyboardHardware.led_set_crgb_at(row, 7-col, red);
|
||
|
} else if (keyState ==1) {
|
||
|
KeyboardHardware.led_set_crgb_at(row,7-col, blue);
|
||
|
}
|
||
8 years ago
|
|
||
8 years ago
|
keyState = (bitRead(KeyboardHardware.previousRightHandState.all, keynum) << 0) |
|
||
|
(bitRead(KeyboardHardware.rightHandState.all, keynum) << 1);
|
||
|
|
||
|
if(keyState ==3 ) {
|
||
|
Serial.print(" Key: ");
|
||
|
Serial.print(keynum);
|
||
|
Serial.print(" value ");
|
||
|
Serial.println(keyState);
|
||
|
KeyboardHardware.led_set_crgb_at(row, 15-col, red);
|
||
|
} else if (keyState ==1) {
|
||
|
KeyboardHardware.led_set_crgb_at(row,15-col, blue);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
8 years ago
|
LEDControl.led_sync();
|
||
8 years ago
|
}
|
||
8 years ago
|
}
|
||
|
|
||
|
void TestMode_::setup() {
|
||
8 years ago
|
red.r=101;
|
||
|
blue.b=101;
|
||
|
// TestLEDs();
|
||
8 years ago
|
eventHandlers[0] = handle_key_event_test;
|
||
|
}
|
||
8 years ago
|
|
||
|
void TestMode_::loop() {
|
||
|
TestMatrix();
|
||
|
}
|
||
|
|
||
8 years ago
|
Key handle_key_event_test(Key mappedKey, byte row, byte col, uint8_t keyState) {
|
||
8 years ago
|
Serial.write(row);
|
||
8 years ago
|
return mappedKey;
|
||
8 years ago
|
}
|
||
|
|
||
|
TestMode_ TestMode;
|