1 /* Copyright (C) 2011-2013 by Joseph Makuch
2 * Additions by Jacob Alexander (2013-2014)
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 3.0 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
18 // ----- Includes -----
21 #include <Lib/ScanLib.h>
29 #include "scan_loop.h"
33 // ----- Defines -----
35 // TODO dfj defines...needs commenting and maybe some cleaning...
36 #define MAX_PRESS_DELTA_MV 450 // As measured from the Teensy ADC pin
37 #define THRESHOLD_MV (MAX_PRESS_DELTA_MV >> 1)
38 //(2560 / (0x3ff/2)) ~= 5
40 #define THRESHOLD (THRESHOLD_MV / MV_PER_ADC)
42 #define STROBE_SETTLE 1
46 #define RIGHT_JUSTIFY 0
47 #define LEFT_JUSTIFY (0xff)
49 // set left or right justification here:
50 #define JUSTIFY_ADC RIGHT_JUSTIFY
51 #define ADLAR_MASK (1 << ADLAR)
54 #define ADLAR_BITS ((ADLAR_MASK) & (JUSTIFY_ADC))
55 #else // defaults to right justification.
60 #define FULL_MUX_MASK ((1 << MUX0) | (1 << MUX1) | (1 << MUX2) | (1 << MUX3) | (1 << MUX4))
62 // F0-f7 pins only muxmask.
63 #define MUX_MASK ((1 << MUX0) | (1 << MUX1) | (1 << MUX2))
70 // set ADC clock prescale
71 #define PRESCALE_MASK ((1 << ADPS0) | (1 << ADPS1) | (1 << ADPS2))
72 #define PRESCALE_SHIFT (ADPS0)
75 // Max number of strobes supported by the hardware
76 // Strobe lines are detected at startup, extra strobes cause anomalies like phantom keypresses
77 #define MAX_STROBES 18
79 // Number of consecutive samples required to pass debounce
80 #define DEBOUNCE_THRESHOLD 5
83 #define MUXES_COUNT_XSHIFT 3
85 #define WARMUP_LOOPS ( 2048 )
86 #define WARMUP_STOP (WARMUP_LOOPS - 1)
88 #define SAMPLE_CONTROL 3
90 #define KEY_COUNT ((MAX_STROBES) * (MUXES_COUNT))
92 #define RECOVERY_CONTROL 1
93 #define RECOVERY_SOURCE 0
94 #define RECOVERY_SINK 2
99 // mix in 1/4 of the current average to the running average. -> (@mux_mix = 2)
102 #define IDLE_COUNT_MASK 0xff
103 #define IDLE_COUNT_SHIFT 8
105 // av = (av << shift) - av + sample; av >>= shift
106 // e.g. 1 -> (av + sample) / 2 simple average of new and old
107 // 2 -> (3 * av + sample) / 4 i.e. 3:1 mix of old to new.
108 // 3 -> (7 * av + sample) / 8 i.e. 7:1 mix of old to new.
109 #define KEYS_AVERAGES_MIX_SHIFT 3
113 // ----- Macros -----
116 #define SET_FULL_MUX(X) ((ADMUX) = (((ADMUX) & ~(FULL_MUX_MASK)) | ((X) & (FULL_MUX_MASK))))
120 // ----- Function Declarations -----
123 void cliFunc_avgDebug ( char* args );
124 void cliFunc_echo ( char* args );
125 void cliFunc_keyDebug ( char* args );
126 void cliFunc_pressDebug ( char* args );
127 void cliFunc_problemKeys( char* args );
128 void cliFunc_senseDebug ( char* args );
131 void dumpSenseTable();
133 // High-level Capsense Functions
135 void capsense_scan();
137 // Capsense Sense Functions
138 void testColumn ( uint8_t strobe );
139 void sampleColumn( uint8_t column );
141 // Low-level Capsense Functions
142 void strobe_w( uint8_t strobe_num );
143 void recovery( uint8_t on );
147 // ----- Variables -----
149 // Buffer used to inform the macro processing module which keys have been detected as pressed
150 volatile uint8_t KeyIndex_Buffer[KEYBOARD_BUFFER];
151 volatile uint8_t KeyIndex_BufferUsed;
154 // Scan Module command dictionary
155 char* scanCLIDictName = "DPH Module Commands";
156 CLIDictItem scanCLIDict[] = {
157 { "echo", "Example command, echos the arguments.", cliFunc_echo },
158 { "avgDebug", "Enables/Disables averaging results." NL "\t\tDisplays each average, starting from Key 0x00, ignoring 0 valued averages.", cliFunc_avgDebug },
159 { "keyDebug", "Enables/Disables long debug for each keypress." NL "\t\tkeycode - [strobe:mux] : sense val : threshold+delta=total : margin", cliFunc_keyDebug },
160 { "pressDebug", "Enables/Disables short debug for each keypress.", cliFunc_pressDebug },
161 { "problemKeys", "Display current list of problem keys,", cliFunc_problemKeys },
162 { "senseDebug", "Prints out the current sense table N times." NL "\t\tsense:max sense:delta", cliFunc_senseDebug },
163 { 0, 0, 0 } // Null entry for dictionary end
166 // CLI Control Variables
167 uint8_t enableAvgDebug = 0;
168 uint8_t enableKeyDebug = 0;
169 uint8_t enablePressDebug = 1;
170 uint8_t senseDebugCount = 3; // In order to get boot-time oddities
173 // Variables used to calculate the starting sense value (averaging)
174 uint32_t full_avg = 0;
175 uint32_t high_avg = 0;
176 uint32_t low_avg = 0;
178 uint8_t high_count = 0;
179 uint8_t low_count = 0;
182 uint16_t samples[MAX_STROBES][MUXES_COUNT]; // Overall table of cap sense ADC values
183 uint16_t sampleMax[MAX_STROBES][MUXES_COUNT]; // Records the max seen ADC value
185 uint8_t key_activity = 0; // Increments for each detected key per each full scan of the keyboard, it is reset before each full scan
186 uint8_t key_release = 0; // Indicates if going from key press state to release state (some keys pressed to no keys pressed)
188 uint16_t threshold = THRESHOLD;
190 uint16_t keys_averages_acc[KEY_COUNT];
191 uint16_t keys_averages [KEY_COUNT];
192 uint8_t keys_debounce [KEY_COUNT]; // Contains debounce statistics
193 uint8_t keys_problem [KEY_COUNT]; // Marks keys that should be ignored (determined by averaging at startup)
195 // TODO: change this to 'booting', then count down.
196 uint16_t boot_count = 0;
198 uint8_t total_strobes = MAX_STROBES;
199 uint8_t strobe_map[MAX_STROBES];
203 // ----- Functions -----
205 // Initial setup for cap sense controller
206 inline void Scan_setup()
208 // Register Scan CLI dictionary
209 CLI_registerDictionary( scanCLIDict, scanCLIDictName );
211 // Scan for active strobes
212 // NOTE1: On IBM PCBs, each strobe line that is *NOT* used is connected to GND.
213 // This means, the strobe GPIO can be set to Tri-State pull-up to detect which strobe lines are not used.
214 // NOTE2: This will *NOT* detect floating strobes.
215 // NOTE3: Rev 0.4, the strobe numbers are reversed, so D0 is actually strobe 0 and C7 is strobe 17
216 info_msg("Detecting Strobes...");
225 // Initially there are 0 strobes
228 // Iterate over each the strobes
229 for ( uint8_t strobe = 0; strobe < MAX_STROBES; strobe++ )
231 uint8_t detected = 0;
233 // If PIN is high, then strobe is *NOT* connected to GND and may be a strobe
240 #ifndef REV0_4_DEBUG // XXX These pins should be reworked, and connect to GND on Rev 0.4
250 detected = PIND & (1 << strobe);
255 detected = PINE & (1 << (strobe - 8));
264 #ifndef REV0_2_DEBUG // XXX If not using the 18 pin connector on Rev 0.2, rework these pins to GND
268 detected = PINC & (1 << (strobe - 10));
275 // Potential strobe line detected
278 strobe_map[total_strobes] = strobe;
283 printInt8( total_strobes );
284 print( " strobes found." NL );
286 // Setup Pins for Strobing
297 // Reset debounce table
298 for ( int i = 0; i < KEY_COUNT; ++i )
300 keys_debounce[i] = 0;
303 // Warm things up a bit before we start collecting data, taking real samples.
304 for ( uint8_t i = 0; i < total_strobes; ++i )
306 sampleColumn( strobe_map[i] );
311 // Main Detection Loop
312 // This is where the important stuff happens
313 inline uint8_t Scan_loop()
317 // Return non-zero if macro and USB processing should be delayed
318 // Macro processing will always run if returning 0
319 // USB processing only happens once the USB send timer expires, if it has not, Scan_loop will be called
320 // after the macro processing has been completed
325 // Signal KeyIndex_Buffer that it has been properly read
326 // NOTE: Only really required for implementing "tricks" in converters for odd protocols
327 void Scan_finishedWithBuffer( uint8_t sentKeys )
329 // Convenient place to clear the KeyIndex_Buffer
330 KeyIndex_BufferUsed = 0;
335 // Signal KeyIndex_Buffer that it has been properly read and sent out by the USB module
336 // NOTE: Only really required for implementing "tricks" in converters for odd protocols
337 void Scan_finishedWithUSBBuffer( uint8_t sentKeys )
343 inline void capsense_scan()
345 // Accumulated average used for the next scan
346 uint32_t cur_full_avg = 0;
347 uint32_t cur_high_avg = 0;
349 // Reset average counters
355 // Reset key activity, if there is no key activity, averages will accumulate for sense deltas, otherwise they will be reset
358 // Scan each of the mapped strobes in the matrix
359 for ( uint8_t strober = 0; strober < total_strobes; ++strober )
361 uint8_t map_strobe = strobe_map[strober];
363 // Sample the ADCs for the given column/strobe
364 sampleColumn( map_strobe );
366 // Only process sense data if warmup is finished
367 if ( boot_count >= WARMUP_LOOPS )
369 testColumn( map_strobe );
372 uint8_t strobe_line = map_strobe << MUXES_COUNT_XSHIFT;
373 for ( int mux = 0; mux < MUXES_COUNT; ++mux )
375 // discard sketchy low bit, and meaningless high bits.
376 uint8_t sample = samples[map_strobe][mux] >> 1;
377 keys_averages_acc[strobe_line + mux] += sample;
380 // Accumulate 3 total averages (used for determining starting average during warmup)
381 // full_avg - Average of all sampled lines on the previous scan set
382 // cur_full_avg - Average of all sampled lines for this scan set
383 // high_avg - Average of all sampled lines above full_avg on the previous scan set
384 // cur_high_avg - Average of all sampled lines above full_avg
385 // low_avg - Average of all sampled lines below or equal to full_avg
386 if ( boot_count < WARMUP_LOOPS )
388 for ( uint8_t mux = 0; mux < MUXES_COUNT; ++mux )
390 uint8_t sample = samples[map_strobe][mux] >> 1;
392 // Sample is high, add it to high avg
393 if ( sample > full_avg )
396 cur_high_avg += sample;
398 // Sample is low, add it to low avg
405 // If sample is higher than previous high_avg, then mark as "problem key"
406 // XXX Giving a bit more margin to pass (high_avg vs. high_avg + high_avg - full_avg) -HaaTa
407 keys_problem[strobe_line + mux] = sample > high_avg + (high_avg - full_avg) ? sample : 0;
409 // Prepare for next average
410 cur_full_avg += sample;
415 // Update total sense average (only during warm-up)
416 if ( boot_count < WARMUP_LOOPS )
418 full_avg = cur_full_avg / (total_strobes * MUXES_COUNT);
419 high_avg = cur_high_avg / high_count;
420 low_avg /= low_count;
422 // Update the base average value using the low_avg (best chance of not ignoring a keypress)
423 for ( int i = 0; i < KEY_COUNT; ++i )
425 keys_averages[i] = low_avg;
426 keys_averages_acc[i] = low_avg;
430 // Warm up voltage references
431 if ( boot_count < WARMUP_LOOPS )
435 switch ( boot_count )
439 // Show msg at first iteration only
440 info_msg("Warming up the voltage references");
452 info_msg("Warmup finished using ");
453 printInt16( WARMUP_LOOPS );
454 print(" iterations" NL );
456 // Display the final calculated averages of all the sensed strobes
457 info_msg("Full average (");
458 printInt8( total_strobes * MUXES_COUNT );
460 printHex( full_avg );
462 print(" High average (");
463 printInt8( high_count );
465 printHex( high_avg );
467 print(" Low average (");
468 printInt8( low_count );
472 print(" Rejection threshold: ");
473 printHex( high_avg + (high_avg - full_avg) );
476 // Display problem keys, and the sense value at the time
477 for ( uint8_t key = 0; key < KEY_COUNT; key++ )
479 if ( keys_problem[key] )
481 warn_msg("Problem key detected: ");
484 printHex( keys_problem[key] );
489 info_print("If problem keys were detected, and were being held down, they will be reset as soon as let go");
495 // No keypress, accumulate averages
499 if ( enableAvgDebug )
501 print("\033[1mAvg\033[0m: ");
505 for ( uint8_t i = 0; i < KEY_COUNT; ++i )
507 uint16_t acc = keys_averages_acc[i];
508 //uint16_t acc = keys_averages_acc[i] >> IDLE_COUNT_SHIFT; // XXX This fixes things... -HaaTa
509 uint32_t av = keys_averages[i];
511 av = (av << KEYS_AVERAGES_MIX_SHIFT) - av + acc;
512 av >>= KEYS_AVERAGES_MIX_SHIFT;
514 keys_averages[i] = av;
515 keys_averages_acc[i] = 0;
518 if ( enableAvgDebug && av > 0 )
526 if ( enableAvgDebug )
531 // No key presses detected, set key_release indicator
534 // Keypresses, reset accumulators
535 else if ( key_release )
537 for ( uint8_t c = 0; c < KEY_COUNT; ++c ) { keys_averages_acc[c] = 0; }
542 // If the debugging sense table is non-zero, display
543 if ( senseDebugCount > 0 )
555 // disable adc digital pins.
556 DIDR1 |= (1 << AIN0D) | (1<<AIN1D); // set disable on pins 1,0.
559 uint8_t mux = 0 & 0x1f; // 0 == first. // 0x1e = 1.1V ref.
561 // 0 = external aref 1,1 = 2.56V internal ref
562 uint8_t aref = ((1 << REFS1) | (1 << REFS0)) & ((1 << REFS1) | (1 << REFS0));
563 uint8_t adate = (1 << ADATE) & (1 << ADATE); // trigger enable
564 uint8_t trig = 0 & ((1 << ADTS0) | (1 << ADTS1) | (1 << ADTS2)); // 0 = free running
565 // ps2, ps1 := /64 ( 2^6 ) ps2 := /16 (2^4), ps1 := 4, ps0 :=2, PS1,PS0 := 8 (2^8)
566 uint8_t prescale = ( ((PRESCALE) << PRESCALE_SHIFT) & PRESCALE_MASK ); // 001 == 2^1 == 2
567 uint8_t hispeed = (1 << ADHSM);
568 uint8_t en_mux = (1 << ACME);
570 ADCSRA = (1 << ADEN) | prescale; // ADC enable
573 //ADMUX |= ((1 << REFS1) | (1 << REFS0)); // 2.56 V internal.
574 //ADMUX |= ((1 << REFS0) ); // Vcc with external cap.
575 //ADMUX &= ~((1 << REFS1) | (1 << REFS0)); // 0,0 : aref.
576 ADMUX = aref | mux | ADLAR_BITS;
579 ADCSRA |= adate; // trigger enable
580 ADCSRB = en_mux | hispeed | trig | (ADCSRB & ~((1 << ADTS0) | (1 << ADTS1) | (1 << ADTS2))); // trigger select free running
582 ADCSRA |= (1 << ADEN); // ADC enable
583 ADCSRA |= (1 << ADSC); // start conversions q
587 void recovery( uint8_t on )
589 DDRB |= (1 << RECOVERY_CONTROL);
590 PORTB &= ~(1 << RECOVERY_SINK); // SINK always zero
591 DDRB &= ~(1 << RECOVERY_SOURCE); // SOURCE high imp
595 // set strobes to sink to gnd.
604 DDRB |= (1 << RECOVERY_SINK); // SINK pull
605 PORTB |= (1 << RECOVERY_CONTROL);
606 PORTB |= (1 << RECOVERY_SOURCE); // SOURCE high
607 DDRB |= (1 << RECOVERY_SOURCE);
611 PORTB &= ~(1 << RECOVERY_CONTROL);
612 DDRB &= ~(1 << RECOVERY_SOURCE);
613 PORTB &= ~(1 << RECOVERY_SOURCE); // SOURCE low
614 DDRB &= ~(1 << RECOVERY_SINK); // SINK high-imp
619 void hold_sample( uint8_t on )
623 PORTB |= (1 << SAMPLE_CONTROL);
624 DDRB |= (1 << SAMPLE_CONTROL);
628 DDRB |= (1 << SAMPLE_CONTROL);
629 PORTB &= ~(1 << SAMPLE_CONTROL);
634 void strobe_w( uint8_t strobe_num )
641 // Not all strobes are used depending on which are detected
642 switch ( strobe_num )
645 case 0: PORTD |= (1 << 0); break;
646 case 1: PORTD |= (1 << 1); break;
647 case 2: PORTD |= (1 << 2); break;
648 case 3: PORTD |= (1 << 3); break;
649 case 4: PORTD |= (1 << 4); break;
650 case 5: PORTD |= (1 << 5); break;
651 case 6: PORTD |= (1 << 6); break;
652 case 7: PORTD |= (1 << 7); break;
654 case 8: PORTE |= (1 << 0); break;
655 case 9: PORTE |= (1 << 1); break;
657 case 10: PORTC |= (1 << 0); break;
658 case 11: PORTC |= (1 << 1); break;
659 case 12: PORTC |= (1 << 2); break;
660 case 13: PORTC |= (1 << 3); break;
661 case 14: PORTC |= (1 << 4); break;
662 case 15: PORTC |= (1 << 5); break;
663 case 16: PORTC |= (1 << 6); break;
664 case 17: PORTC |= (1 << 7); break;
672 inline uint16_t getADC(void)
674 ADCSRA |= (1 << ADIF); // clear int flag by writing 1.
676 //wait for last read to complete.
677 while ( !( ADCSRA & (1 << ADIF) ) );
679 return ADC; // return sample
683 void sampleColumn( uint8_t column )
685 // ensure all probe lines are driven low, and chill for recovery delay.
686 ADCSRA |= (1 << ADEN) | (1 << ADSC); // enable and start conversions
701 // Allow strobes to settle
702 for ( uint8_t i = 0; i < STROBE_SETTLE; ++i ) { getADC(); }
708 getADC(); // throw away; unknown mux.
710 SET_FULL_MUX( mux + 1 ); // our *next* sample will use this
712 // retrieve current read.
713 uint16_t readVal = getADC();
714 samples[column][mux] = readVal;
716 // Update max sense sample table
717 if ( readVal > sampleMax[column][mux] )
719 sampleMax[column][mux] = readVal;
730 ADCSRA &= ~(1 << ADEN);
732 // pull all columns' strobe-lines low.
743 void testColumn( uint8_t strobe )
745 uint16_t db_delta = 0;
746 uint8_t db_sample = 0;
747 uint16_t db_threshold = 0;
752 for ( uint8_t mux = 0; mux < MUXES_COUNT; ++mux )
754 uint16_t delta = keys_averages[(strobe << MUXES_COUNT_XSHIFT) + mux];
756 uint8_t key = (strobe << MUXES_COUNT_XSHIFT) + mux;
758 // Check if this is a bad key (e.g. test point, or non-existent key)
759 if ( keys_problem[key] )
761 // If the sample value of the problem key goes below full_avg (overall initial average)
763 if ( (db_sample = samples[strobe][mux] >> 1) < full_avg )
765 info_msg("Re-enabling problem key: ");
769 keys_problem[key] = 0;
772 // Do not waste any more cycles processing, regardless, a keypress cannot be detected
777 // db_sample (uint8_t), discard meaningless high bit, and garbage low bit
778 if ( (db_sample = samples[strobe][mux] >> 1) > (db_threshold = threshold) + (db_delta = delta) )
781 key_activity++; // No longer idle, stop averaging ADC data
783 // Only register keypresses once the warmup is complete, or not enough debounce info
784 if ( keys_debounce[key] <= DEBOUNCE_THRESHOLD )
786 // Add to the Macro processing buffer if debounce criteria met
787 // Automatically handles converting to a USB code and sending off to the PC
788 if ( keys_debounce[key] == DEBOUNCE_THRESHOLD )
790 // Debug message, pressDebug CLI
791 if ( enablePressDebug )
794 printHex_op( key, 2 );
798 // Only add the key to the buffer once
799 // NOTE: Buffer can easily handle multiple adds, just more efficient
800 // and nicer debug messages :P
801 //Macro_bufferAdd( key );
804 keys_debounce[key]++;
808 // Long form key debugging
809 if ( enableKeyDebug )
812 // <key> [<strobe>:<mux>] : <sense val> : <delta + threshold> : <margin>
814 printHex_op( key, 2 );
820 printHex( db_sample ); // Sense
822 printHex( db_threshold );
824 printHex( db_delta );
826 printHex( db_threshold + db_delta ); // Sense compare
828 printHex( db_sample - ( db_threshold + db_delta ) ); // Margin
832 // Clear debounce entry if no keypress detected
835 // If the key was previously pressed, remove from the buffer
836 for ( uint8_t c = 0; c < KeyIndex_BufferUsed; c++ )
838 // Key to release found
839 if ( KeyIndex_Buffer[c] == key )
841 // Shift keys from c position
842 for ( uint8_t k = c; k < KeyIndex_BufferUsed - 1; k++ )
843 KeyIndex_Buffer[k] = KeyIndex_Buffer[k + 1];
846 KeyIndex_BufferUsed--;
853 // Clear debounce entry
854 keys_debounce[key] = 0;
862 void dumpSenseTable()
864 // Initial table alignment, with base threshold used for every key
866 printHex( threshold );
869 // Print out headers first
870 for ( uint8_t mux = 0; mux < MUXES_COUNT; ++mux )
872 print(" Mux \033[1m");
879 // Display the full strobe/sense table
880 for ( uint8_t strober = 0; strober < total_strobes; ++strober )
882 uint8_t strobe = strobe_map[strober];
884 // Display the strobe
885 print("Strobe \033[1m");
889 // For each mux, display sense:threshold:delta
890 for ( uint8_t mux = 0; mux < MUXES_COUNT; ++mux )
892 uint8_t delta = keys_averages[(strobe << MUXES_COUNT_XSHIFT) + mux];
893 uint8_t sample = samples[strobe][mux] >> 1;
894 uint8_t max = sampleMax[strobe][mux] >> 1;
896 // Indicate if the key is being pressed by displaying green
897 if ( sample > delta + threshold )
902 printHex_op( sample, 2 );
904 printHex_op( max, 2 );
906 printHex_op( delta, 2 );
910 // New line for each strobe
916 // ----- CLI Command Functions -----
918 // XXX Just an example command showing how to parse arguments (more complex than generally needed)
919 void cliFunc_echo( char* args )
923 char* arg2Ptr = args;
925 // Parse args until a \0 is found
928 print( NL ); // No \r\n by default after the command is entered
930 curArgs = arg2Ptr; // Use the previous 2nd arg pointer to separate the next arg from the list
931 CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );
933 // Stop processing args if no more are found
934 if ( *arg1Ptr == '\0' )
942 void cliFunc_avgDebug( char* args )
946 // Args ignored, just toggling
947 if ( enableAvgDebug )
949 info_print("Cap Sense averaging debug disabled.");
954 info_print("Cap Sense averaging debug enabled.");
959 void cliFunc_keyDebug( char* args )
963 // Args ignored, just toggling
964 if ( enableKeyDebug )
966 info_print("Cap Sense key long debug disabled - pre debounce.");
971 info_print("Cap Sense key long debug enabled - pre debounce.");
976 void cliFunc_pressDebug( char* args )
980 // Args ignored, just toggling
981 if ( enablePressDebug )
983 info_print("Cap Sense key debug disabled - post debounce.");
984 enablePressDebug = 0;
988 info_print("Cap Sense key debug enabled - post debounce.");
989 enablePressDebug = 1;
993 void cliFunc_problemKeys( char* args )
999 // Args ignored, just displaying
1000 // Display problem keys, and the sense value at the time
1001 for ( uint8_t key = 0; key < KEY_COUNT; key++ )
1003 if ( keys_problem[key] )
1007 warn_msg("Problem keys: ");
1011 printHex( keys_problem[key] );
1017 void cliFunc_senseDebug( char* args )
1019 // Parse code from argument
1020 // NOTE: Only first argument is used
1023 CLI_argumentIsolation( args, &arg1Ptr, &arg2Ptr );
1025 // Default to a single print
1026 senseDebugCount = 1;
1028 // If there was an argument, use that instead
1029 if ( *arg1Ptr != '\0' )
1031 senseDebugCount = decToInt( arg1Ptr );