forked from mirrors/qmk_firmware
switch debug on/off by pressing 4 keys on booting time
This commit is contained in:
parent
bf92bdd7fa
commit
4acc38751e
6 changed files with 61 additions and 14 deletions
17
README
17
README
|
@ -45,6 +45,12 @@ $ cd <target> (hhkb or macway)
|
||||||
$ make
|
$ make
|
||||||
|
|
||||||
|
|
||||||
|
Debuging
|
||||||
|
--------
|
||||||
|
Debug print is on if 4 keys are pressed during booting.
|
||||||
|
Use PJRC's hid_listen.exe to see debug messages.
|
||||||
|
|
||||||
|
|
||||||
AVR Target board
|
AVR Target board
|
||||||
----------------
|
----------------
|
||||||
Teensy/Teensy++
|
Teensy/Teensy++
|
||||||
|
@ -84,9 +90,14 @@ debouncing logic
|
||||||
will be coded when bouncing occurs.
|
will be coded when bouncing occurs.
|
||||||
bouncing doesnt occur on my ALPS switch so far.
|
bouncing doesnt occur on my ALPS switch so far.
|
||||||
scan rate is too slow?(to be measure)
|
scan rate is too slow?(to be measure)
|
||||||
layer switch
|
layer switching
|
||||||
time before switching
|
time before switching
|
||||||
timeout when not used during specific time
|
timeout when not used during specific time
|
||||||
|
debug on/off
|
||||||
|
Fn key conbination during normal operation
|
||||||
|
matrix print on/off
|
||||||
|
key print on/off
|
||||||
|
mouse print on/off
|
||||||
|
|
||||||
Trackpoint(PS/2)
|
Trackpoint(PS/2)
|
||||||
receive PS/2 signal from TrackPoint
|
receive PS/2 signal from TrackPoint
|
||||||
|
@ -116,6 +127,10 @@ keymap
|
||||||
2010/10/23
|
2010/10/23
|
||||||
souce code cleaning
|
souce code cleaning
|
||||||
2010/10/23
|
2010/10/23
|
||||||
|
debug on/off
|
||||||
|
debug off by default
|
||||||
|
pressing keys during booting
|
||||||
|
2010/10/23
|
||||||
|
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
|
@ -32,6 +32,7 @@ static uint8_t _matrix1[MATRIX_ROWS];
|
||||||
|
|
||||||
|
|
||||||
static bool matrix_has_ghost_in_row(int row);
|
static bool matrix_has_ghost_in_row(int row);
|
||||||
|
static int bit_pop(uint8_t bits);
|
||||||
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
|
@ -88,7 +89,7 @@ int matrix_scan(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool matrix_is_modified(void) {
|
bool matrix_is_modified(void) {
|
||||||
for (int i=0; i <MATRIX_ROWS; i++) {
|
for (int i = 0; i < MATRIX_ROWS; i++) {
|
||||||
if (matrix[i] != matrix_prev[i])
|
if (matrix[i] != matrix_prev[i])
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -117,7 +118,22 @@ void matrix_print(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int matrix_key_count(void) {
|
||||||
|
int count = 0;
|
||||||
|
for (int i = 0; i < MATRIX_ROWS; i++) {
|
||||||
|
count += bit_pop(~matrix[i]);
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
static bool matrix_has_ghost_in_row(int row) {
|
static bool matrix_has_ghost_in_row(int row) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int bit_pop(uint8_t bits) {
|
||||||
|
int c;
|
||||||
|
for (c = 0; bits; c++)
|
||||||
|
bits &= bits -1;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#define MOUSE_DELAY_ACC 5
|
#define MOUSE_DELAY_ACC 5
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: refactoring
|
||||||
void proc_matrix(void) {
|
void proc_matrix(void) {
|
||||||
static int mouse_repeat = 0;
|
static int mouse_repeat = 0;
|
||||||
|
|
||||||
|
|
9
print.c
9
print.c
|
@ -27,8 +27,12 @@
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
#include "print.h"
|
#include "print.h"
|
||||||
|
|
||||||
|
|
||||||
|
bool print_enable = false;
|
||||||
|
|
||||||
void print_P(const char *s)
|
void print_P(const char *s)
|
||||||
{
|
{
|
||||||
|
if (!print_enable) return;
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -41,17 +45,20 @@ void print_P(const char *s)
|
||||||
|
|
||||||
void phex1(unsigned char c)
|
void phex1(unsigned char c)
|
||||||
{
|
{
|
||||||
|
if (!print_enable) return;
|
||||||
usb_debug_putchar(c + ((c < 10) ? '0' : 'A' - 10));
|
usb_debug_putchar(c + ((c < 10) ? '0' : 'A' - 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
void phex(unsigned char c)
|
void phex(unsigned char c)
|
||||||
{
|
{
|
||||||
|
if (!print_enable) return;
|
||||||
phex1(c >> 4);
|
phex1(c >> 4);
|
||||||
phex1(c & 15);
|
phex1(c & 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
void phex16(unsigned int i)
|
void phex16(unsigned int i)
|
||||||
{
|
{
|
||||||
|
if (!print_enable) return;
|
||||||
phex(i >> 8);
|
phex(i >> 8);
|
||||||
phex(i);
|
phex(i);
|
||||||
}
|
}
|
||||||
|
@ -59,6 +66,7 @@ void phex16(unsigned int i)
|
||||||
|
|
||||||
void pbin(unsigned char c)
|
void pbin(unsigned char c)
|
||||||
{
|
{
|
||||||
|
if (!print_enable) return;
|
||||||
for (int i = 7; i >= 0; i--) {
|
for (int i = 7; i >= 0; i--) {
|
||||||
usb_debug_putchar((c & (1<<i)) ? '1' : '0');
|
usb_debug_putchar((c & (1<<i)) ? '1' : '0');
|
||||||
}
|
}
|
||||||
|
@ -66,6 +74,7 @@ void pbin(unsigned char c)
|
||||||
|
|
||||||
void pbin_reverse(unsigned char c)
|
void pbin_reverse(unsigned char c)
|
||||||
{
|
{
|
||||||
|
if (!print_enable) return;
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
usb_debug_putchar((c & (1<<i)) ? '1' : '0');
|
usb_debug_putchar((c & (1<<i)) ? '1' : '0');
|
||||||
}
|
}
|
||||||
|
|
4
print.h
4
print.h
|
@ -1,9 +1,13 @@
|
||||||
#ifndef PRINT_H__
|
#ifndef PRINT_H__
|
||||||
#define PRINT_H__ 1
|
#define PRINT_H__ 1
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
#include "usb_debug.h"
|
#include "usb_debug.h"
|
||||||
|
|
||||||
|
|
||||||
|
bool print_enable;
|
||||||
|
|
||||||
// this macro allows you to write print("some text") and
|
// this macro allows you to write print("some text") and
|
||||||
// the string is automatically placed into flash memory :)
|
// the string is automatically placed into flash memory :)
|
||||||
#define print(s) print_P(PSTR(s))
|
#define print(s) print_P(PSTR(s))
|
||||||
|
|
26
tmk.c
26
tmk.c
|
@ -63,18 +63,6 @@ int main(void)
|
||||||
usb_init();
|
usb_init();
|
||||||
while (!usb_configured()) /* wait */ ;
|
while (!usb_configured()) /* wait */ ;
|
||||||
|
|
||||||
// Wait an extra second for the PC's operating system to load drivers
|
|
||||||
// and do whatever it does to actually be ready for input
|
|
||||||
// needs such long time in my PC.
|
|
||||||
/* wait for debug print. no need for normal use */
|
|
||||||
for (int i =0; i < 6; i++) {
|
|
||||||
LED_CONFIG;
|
|
||||||
LED_ON;
|
|
||||||
_delay_ms(500);
|
|
||||||
LED_OFF;
|
|
||||||
_delay_ms(500);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure timer 0 to generate a timer overflow interrupt every
|
// Configure timer 0 to generate a timer overflow interrupt every
|
||||||
// 256*1024 clock cycles, or approx 61 Hz when using 16 MHz clock
|
// 256*1024 clock cycles, or approx 61 Hz when using 16 MHz clock
|
||||||
// This demonstrates how to use interrupts to implement a simple
|
// This demonstrates how to use interrupts to implement a simple
|
||||||
|
@ -85,6 +73,20 @@ int main(void)
|
||||||
|
|
||||||
|
|
||||||
matrix_init();
|
matrix_init();
|
||||||
|
matrix_scan();
|
||||||
|
// debug on when 4 keys are pressed
|
||||||
|
if (matrix_key_count() == 4) print_enable = true;
|
||||||
|
|
||||||
|
/* wait for debug pipe to print greetings. */
|
||||||
|
if (print_enable) {
|
||||||
|
for (int i =0; i < 6; i++) {
|
||||||
|
LED_CONFIG;
|
||||||
|
LED_ON;
|
||||||
|
_delay_ms(500);
|
||||||
|
LED_OFF;
|
||||||
|
_delay_ms(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
print("\nt.m.k. keyboard 1.2\n");
|
print("\nt.m.k. keyboard 1.2\n");
|
||||||
while (1) {
|
while (1) {
|
||||||
proc_matrix();
|
proc_matrix();
|
||||||
|
|
Loading…
Reference in a new issue