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>
30 #include "scan_loop.h"
34 // ----- Defines -----
36 // TODO dfj defines...needs commenting and maybe some cleaning...
37 #define MAX_PRESS_DELTA_MV 450 // As measured from the Teensy ADC pin
38 #define THRESHOLD_MV (MAX_PRESS_DELTA_MV >> 1)
39 //(2560 / (0x3ff/2)) ~= 5
41 #define THRESHOLD (THRESHOLD_MV / MV_PER_ADC)
43 #define STROBE_SETTLE 1
47 // Right justification of ADLAR
51 #define FULL_MUX_MASK ((1 << MUX0) | (1 << MUX1) | (1 << MUX2) | (1 << MUX3) | (1 << MUX4))
53 // F0-f7 pins only muxmask.
54 #define MUX_MASK ((1 << MUX0) | (1 << MUX1) | (1 << MUX2))
61 // set ADC clock prescale
62 #define PRESCALE_MASK ((1 << ADPS0) | (1 << ADPS1) | (1 << ADPS2))
63 #define PRESCALE_SHIFT (ADPS0)
66 // Max number of strobes supported by the hardware
67 // Strobe lines are detected at startup, extra strobes cause anomalies like phantom keypresses
68 #define MAX_STROBES 18
70 // Number of consecutive samples required to pass debounce
71 #define DEBOUNCE_THRESHOLD 5
73 // Scans to remain idle after all keys were release before starting averaging
74 // XXX So this makes the initial keypresses fast,
75 // but it's still possible to lose a keypress if you press at the wrong time -HaaTa
76 #define KEY_IDLE_SCANS 30000
78 // Total number of muxes/sense lines available
80 #define MUXES_COUNT_XSHIFT 3
82 // Number of warm-up loops before starting to scan keys
83 #define WARMUP_LOOPS ( 1024 )
84 #define WARMUP_STOP (WARMUP_LOOPS - 1)
86 #define SAMPLE_CONTROL 3
88 #define KEY_COUNT ((MAX_STROBES) * (MUXES_COUNT))
90 #define RECOVERY_CONTROL 1
91 #define RECOVERY_SOURCE 0
92 #define RECOVERY_SINK 2
97 // mix in 1/4 of the current average to the running average. -> (@mux_mix = 2)
100 #define IDLE_COUNT_SHIFT 8
102 // av = (av << shift) - av + sample; av >>= shift
103 // e.g. 1 -> (av + sample) / 2 simple average of new and old
104 // 2 -> (3 * av + sample) / 4 i.e. 3:1 mix of old to new.
105 // 3 -> (7 * av + sample) / 8 i.e. 7:1 mix of old to new.
106 #define KEYS_AVERAGES_MIX_SHIFT 3
110 // ----- Macros -----
113 #define SET_FULL_MUX(X) ((ADMUX) = (((ADMUX) & ~(FULL_MUX_MASK)) | ((X) & (FULL_MUX_MASK))))
117 // ----- Function Declarations -----
120 void cliFunc_avgDebug ( char* args );
121 void cliFunc_echo ( char* args );
122 void cliFunc_keyDebug ( char* args );
123 void cliFunc_pressDebug ( char* args );
124 void cliFunc_problemKeys( char* args );
125 void cliFunc_senseDebug ( char* args );
128 void dumpSenseTable();
130 // High-level Capsense Functions
132 void capsense_scan();
134 // Capsense Sense Functions
135 void testColumn ( uint8_t strobe );
136 void sampleColumn( uint8_t column );
138 // Low-level Capsense Functions
139 void strobe_w( uint8_t strobe_num );
140 void recovery( uint8_t on );
144 // ----- Variables -----
146 // Buffer used to inform the macro processing module which keys have been detected as pressed
147 volatile uint8_t KeyIndex_Buffer[KEYBOARD_BUFFER];
148 volatile uint8_t KeyIndex_BufferUsed;
151 // Scan Module command dictionary
152 char* scanCLIDictName = "DPH Module Commands";
153 CLIDictItem scanCLIDict[] = {
154 { "echo", "Example command, echos the arguments.", cliFunc_echo },
155 { "avgDebug", "Enables/Disables averaging results." NL "\t\tDisplays each average, starting from Key 0x00, ignoring 0 valued averages.", cliFunc_avgDebug },
156 { "keyDebug", "Enables/Disables long debug for each keypress." NL "\t\tkeycode - [strobe:mux] : sense val : threshold+delta=total : margin", cliFunc_keyDebug },
157 { "pressDebug", "Enables/Disables short debug for each keypress.", cliFunc_pressDebug },
158 { "problemKeys", "Display current list of problem keys,", cliFunc_problemKeys },
159 { "senseDebug", "Prints out the current sense table N times." NL "\t\tsense:max sense:delta", cliFunc_senseDebug },
160 { 0, 0, 0 } // Null entry for dictionary end
163 // CLI Control Variables
164 uint8_t enableAvgDebug = 0;
165 uint8_t enableKeyDebug = 0;
166 uint8_t enablePressDebug = 1;
167 uint8_t senseDebugCount = 3; // In order to get boot-time oddities
170 // Variables used to calculate the starting sense value (averaging)
171 uint32_t full_avg = 0;
172 uint32_t high_avg = 0;
173 uint32_t low_avg = 0;
175 uint8_t high_count = 0;
176 uint8_t low_count = 0;
179 uint16_t samples[MAX_STROBES][MUXES_COUNT]; // Overall table of cap sense ADC values
180 uint16_t sampleMax[MAX_STROBES][MUXES_COUNT]; // Records the max seen ADC value
182 uint8_t key_activity = 0; // Increments for each detected key per each full scan of the keyboard, it is reset before each full scan
183 uint16_t key_idle = 0; // Defines how scans after all keys were released before starting averaging again
184 uint8_t key_release = 0; // Indicates if going from key press state to release state (some keys pressed to no keys pressed)
186 uint16_t threshold = THRESHOLD;
188 uint16_t keys_averages_acc[KEY_COUNT];
189 uint16_t keys_averages [KEY_COUNT];
190 uint8_t keys_debounce [KEY_COUNT]; // Contains debounce statistics
191 uint8_t keys_problem [KEY_COUNT]; // Marks keys that should be ignored (determined by averaging at startup)
193 // TODO: change this to 'booting', then count down.
194 uint16_t boot_count = 0;
196 uint8_t total_strobes = MAX_STROBES;
197 uint8_t strobe_map[MAX_STROBES];
201 // ----- Functions -----
203 // Initial setup for cap sense controller
204 inline void Scan_setup()
206 // Register Scan CLI dictionary
207 CLI_registerDictionary( scanCLIDict, scanCLIDictName );
209 // Scan for active strobes
210 // NOTE1: On IBM PCBs, each strobe line that is *NOT* used is connected to GND.
211 // This means, the strobe GPIO can be set to Tri-State pull-up to detect which strobe lines are not used.
212 // NOTE2: This will *NOT* detect floating strobes.
213 // NOTE3: Rev 0.4, the strobe numbers are reversed, so D0 is actually strobe 0 and C7 is strobe 17
214 info_msg("Detecting Strobes...");
223 // Initially there are 0 strobes
226 // Iterate over each the strobes
227 for ( uint8_t strobe = 0; strobe < MAX_STROBES; strobe++ )
229 uint8_t detected = 0;
231 // If PIN is high, then strobe is *NOT* connected to GND and may be a strobe
238 #ifndef REV0_4_DEBUG // XXX These pins should be reworked, and connect to GND on Rev 0.4
248 detected = PIND & (1 << strobe);
253 detected = PINE & (1 << (strobe - 8));
262 #ifndef REV0_2_DEBUG // XXX If not using the 18 pin connector on Rev 0.2, rework these pins to GND
266 detected = PINC & (1 << (strobe - 10));
273 // Potential strobe line detected
276 strobe_map[total_strobes] = strobe;
281 printInt8( total_strobes );
282 print( " strobes found." NL );
284 // Setup Pins for Strobing
295 // Reset debounce table
296 for ( int i = 0; i < KEY_COUNT; ++i )
298 keys_debounce[i] = 0;
301 // Warm things up a bit before we start collecting data, taking real samples.
302 for ( uint8_t i = 0; i < total_strobes; ++i )
304 sampleColumn( strobe_map[i] );
309 // Main Detection Loop
310 // This is where the important stuff happens
311 inline uint8_t Scan_loop()
315 // Return non-zero if macro and USB processing should be delayed
316 // Macro processing will always run if returning 0
317 // USB processing only happens once the USB send timer expires, if it has not, Scan_loop will be called
318 // after the macro processing has been completed
323 // Signal KeyIndex_Buffer that it has been properly read
324 // NOTE: Only really required for implementing "tricks" in converters for odd protocols
325 void Scan_finishedWithBuffer( uint8_t sentKeys )
327 // Convenient place to clear the KeyIndex_Buffer
328 KeyIndex_BufferUsed = 0;
333 // Signal KeyIndex_Buffer that it has been properly read and sent out by the USB module
334 // NOTE: Only really required for implementing "tricks" in converters for odd protocols
335 void Scan_finishedWithUSBBuffer( uint8_t sentKeys )
341 inline void capsense_scan()
343 // Accumulated average used for the next scan
344 uint32_t cur_full_avg = 0;
345 uint32_t cur_high_avg = 0;
347 // Reset average counters
353 // Reset key activity, if there is no key activity, averages will accumulate for sense deltas, otherwise they will be reset
356 // Scan each of the mapped strobes in the matrix
357 for ( uint8_t strober = 0; strober < total_strobes; ++strober )
359 uint8_t map_strobe = strobe_map[strober];
361 // Sample the ADCs for the given column/strobe
362 sampleColumn( map_strobe );
364 // Only process sense data if warmup is finished
365 if ( boot_count >= WARMUP_LOOPS )
367 testColumn( map_strobe );
370 uint8_t strobe_line = map_strobe << MUXES_COUNT_XSHIFT;
371 for ( int mux = 0; mux < MUXES_COUNT; ++mux )
373 // discard sketchy low bit, and meaningless high bits.
374 uint8_t sample = samples[map_strobe][mux] >> 1;
375 keys_averages_acc[strobe_line + mux] += sample;
378 // Accumulate 3 total averages (used for determining starting average during warmup)
379 // full_avg - Average of all sampled lines on the previous scan set
380 // cur_full_avg - Average of all sampled lines for this scan set
381 // high_avg - Average of all sampled lines above full_avg on the previous scan set
382 // cur_high_avg - Average of all sampled lines above full_avg
383 // low_avg - Average of all sampled lines below or equal to full_avg
384 if ( boot_count < WARMUP_LOOPS )
386 for ( uint8_t mux = 0; mux < MUXES_COUNT; ++mux )
388 uint8_t sample = samples[map_strobe][mux] >> 1;
390 // Sample is high, add it to high avg
391 if ( sample > full_avg )
394 cur_high_avg += sample;
396 // Sample is low, add it to low avg
403 // If sample is higher than previous high_avg, then mark as "problem key"
404 // XXX Giving a bit more margin to pass (high_avg vs. high_avg + high_avg - full_avg) -HaaTa
405 keys_problem[strobe_line + mux] = sample > high_avg + (high_avg - full_avg) ? sample : 0;
407 // Prepare for next average
408 cur_full_avg += sample;
413 // Update total sense average (only during warm-up)
414 if ( boot_count < WARMUP_LOOPS )
416 full_avg = cur_full_avg / (total_strobes * MUXES_COUNT);
417 high_avg = cur_high_avg / high_count;
418 low_avg /= low_count;
420 // Update the base average value using the low_avg (best chance of not ignoring a keypress)
421 for ( int i = 0; i < KEY_COUNT; ++i )
423 keys_averages[i] = low_avg;
424 keys_averages_acc[i] = low_avg;
428 // Warm up voltage references
429 if ( boot_count < WARMUP_LOOPS )
433 switch ( boot_count )
437 // Show msg at first iteration only
438 info_msg("Warming up the voltage references");
450 info_msg("Warmup finished using ");
451 printInt16( WARMUP_LOOPS );
452 print(" iterations" NL );
454 // Display the final calculated averages of all the sensed strobes
455 info_msg("Full average (");
456 printInt8( total_strobes * MUXES_COUNT );
458 printHex( full_avg );
460 print(" High average (");
461 printInt8( high_count );
463 printHex( high_avg );
465 print(" Low average (");
466 printInt8( low_count );
470 print(" Rejection threshold: ");
471 printHex( high_avg + (high_avg - full_avg) );
474 // Display problem keys, and the sense value at the time
475 for ( uint8_t key = 0; key < KEY_COUNT; key++ )
477 if ( keys_problem[key] )
479 warn_msg("Problem key detected: ");
482 printHex( keys_problem[key] );
487 info_print("If problem keys were detected, and were being held down, they will be reset as soon as let go");
493 // No keypress, accumulate averages
496 // Only start averaging once the idle counter has counted down to 0
500 if ( enableAvgDebug )
502 print("\033[1mAvg\033[0m: ");
506 for ( uint8_t i = 0; i < KEY_COUNT; ++i )
508 uint16_t acc = keys_averages_acc[i];
509 //uint16_t acc = keys_averages_acc[i] >> IDLE_COUNT_SHIFT; // XXX This fixes things... -HaaTa
510 uint32_t av = keys_averages[i];
512 av = (av << KEYS_AVERAGES_MIX_SHIFT) - av + acc;
513 av >>= KEYS_AVERAGES_MIX_SHIFT;
515 keys_averages[i] = av;
516 keys_averages_acc[i] = 0;
519 if ( enableAvgDebug && av > 0 )
527 if ( enableAvgDebug )
532 // No key presses detected, set key_release indicator
535 // Otherwise decrement the idle counter
541 // Keypresses, reset accumulators
542 else if ( key_release )
544 for ( uint8_t c = 0; c < KEY_COUNT; ++c ) { keys_averages_acc[c] = 0; }
549 // If the debugging sense table is non-zero, display
550 if ( senseDebugCount > 0 )
562 // disable adc digital pins.
563 DIDR1 |= (1 << AIN0D) | (1<<AIN1D); // set disable on pins 1,0.
566 uint8_t mux = 0 & 0x1f; // 0 == first. // 0x1e = 1.1V ref.
568 // 0 = external aref 1,1 = 2.56V internal ref
569 uint8_t aref = ((1 << REFS1) | (1 << REFS0)) & ((1 << REFS1) | (1 << REFS0));
570 uint8_t adate = (1 << ADATE) & (1 << ADATE); // trigger enable
571 uint8_t trig = 0 & ((1 << ADTS0) | (1 << ADTS1) | (1 << ADTS2)); // 0 = free running
572 // ps2, ps1 := /64 ( 2^6 ) ps2 := /16 (2^4), ps1 := 4, ps0 :=2, PS1,PS0 := 8 (2^8)
573 uint8_t prescale = ( ((PRESCALE) << PRESCALE_SHIFT) & PRESCALE_MASK ); // 001 == 2^1 == 2
574 uint8_t hispeed = (1 << ADHSM);
575 uint8_t en_mux = (1 << ACME);
577 ADCSRA = (1 << ADEN) | prescale; // ADC enable
580 //ADMUX |= ((1 << REFS1) | (1 << REFS0)); // 2.56 V internal.
581 //ADMUX |= ((1 << REFS0) ); // Vcc with external cap.
582 //ADMUX &= ~((1 << REFS1) | (1 << REFS0)); // 0,0 : aref.
583 ADMUX = aref | mux | ADLAR_BITS;
586 ADCSRA |= adate; // trigger enable
587 ADCSRB = en_mux | hispeed | trig | (ADCSRB & ~((1 << ADTS0) | (1 << ADTS1) | (1 << ADTS2))); // trigger select free running
589 ADCSRA |= (1 << ADEN); // ADC enable
590 ADCSRA |= (1 << ADSC); // start conversions q
594 void recovery( uint8_t on )
596 DDRB |= (1 << RECOVERY_CONTROL);
597 PORTB &= ~(1 << RECOVERY_SINK); // SINK always zero
598 DDRB &= ~(1 << RECOVERY_SOURCE); // SOURCE high imp
602 // set strobes to sink to gnd.
611 DDRB |= (1 << RECOVERY_SINK); // SINK pull
612 PORTB |= (1 << RECOVERY_CONTROL);
613 PORTB |= (1 << RECOVERY_SOURCE); // SOURCE high
614 DDRB |= (1 << RECOVERY_SOURCE);
618 PORTB &= ~(1 << RECOVERY_CONTROL);
619 DDRB &= ~(1 << RECOVERY_SOURCE);
620 PORTB &= ~(1 << RECOVERY_SOURCE); // SOURCE low
621 DDRB &= ~(1 << RECOVERY_SINK); // SINK high-imp
626 void hold_sample( uint8_t on )
630 PORTB |= (1 << SAMPLE_CONTROL);
631 DDRB |= (1 << SAMPLE_CONTROL);
635 DDRB |= (1 << SAMPLE_CONTROL);
636 PORTB &= ~(1 << SAMPLE_CONTROL);
641 void strobe_w( uint8_t strobe_num )
648 // Not all strobes are used depending on which are detected
649 switch ( strobe_num )
652 case 0: PORTD |= (1 << 0); break;
653 case 1: PORTD |= (1 << 1); break;
654 case 2: PORTD |= (1 << 2); break;
655 case 3: PORTD |= (1 << 3); break;
656 case 4: PORTD |= (1 << 4); break;
657 case 5: PORTD |= (1 << 5); break;
658 case 6: PORTD |= (1 << 6); break;
659 case 7: PORTD |= (1 << 7); break;
661 case 8: PORTE |= (1 << 0); break;
662 case 9: PORTE |= (1 << 1); break;
664 case 10: PORTC |= (1 << 0); break;
665 case 11: PORTC |= (1 << 1); break;
666 case 12: PORTC |= (1 << 2); break;
667 case 13: PORTC |= (1 << 3); break;
668 case 14: PORTC |= (1 << 4); break;
669 case 15: PORTC |= (1 << 5); break;
670 case 16: PORTC |= (1 << 6); break;
671 case 17: PORTC |= (1 << 7); break;
679 inline uint16_t getADC(void)
681 ADCSRA |= (1 << ADIF); // clear int flag by writing 1.
683 //wait for last read to complete.
684 while ( !( ADCSRA & (1 << ADIF) ) );
686 return ADC; // return sample
690 void sampleColumn( uint8_t column )
692 // ensure all probe lines are driven low, and chill for recovery delay.
693 ADCSRA |= (1 << ADEN) | (1 << ADSC); // enable and start conversions
708 // Allow strobes to settle
709 for ( uint8_t i = 0; i < STROBE_SETTLE; ++i ) { getADC(); }
715 getADC(); // throw away; unknown mux.
717 SET_FULL_MUX( mux + 1 ); // our *next* sample will use this
719 // retrieve current read.
720 uint16_t readVal = getADC();
721 samples[column][mux] = readVal;
723 // Update max sense sample table
724 if ( readVal > sampleMax[column][mux] )
726 sampleMax[column][mux] = readVal;
737 ADCSRA &= ~(1 << ADEN);
739 // pull all columns' strobe-lines low.
750 void testColumn( uint8_t strobe )
752 uint16_t db_delta = 0;
753 uint8_t db_sample = 0;
754 uint16_t db_threshold = 0;
759 for ( uint8_t mux = 0; mux < MUXES_COUNT; ++mux )
761 uint16_t delta = keys_averages[(strobe << MUXES_COUNT_XSHIFT) + mux];
763 uint8_t key = (strobe << MUXES_COUNT_XSHIFT) + mux;
765 // Check if this is a bad key (e.g. test point, or non-existent key)
766 if ( keys_problem[key] )
768 // If the sample value of the problem key goes below full_avg (overall initial average)
770 if ( (db_sample = samples[strobe][mux] >> 1) < full_avg )
772 info_msg("Re-enabling problem key: ");
776 keys_problem[key] = 0;
779 // Do not waste any more cycles processing, regardless, a keypress cannot be detected
784 // db_sample (uint8_t), discard meaningless high bit, and garbage low bit
785 if ( (db_sample = samples[strobe][mux] >> 1) > (db_threshold = threshold) + (db_delta = delta) )
788 key_activity++; // No longer idle, stop averaging ADC data
789 key_idle = KEY_IDLE_SCANS; // Reset idle count-down
791 // Only register keypresses once the warmup is complete, or not enough debounce info
792 if ( keys_debounce[key] <= DEBOUNCE_THRESHOLD )
794 // Add to the Macro processing buffer if debounce criteria met
795 // Automatically handles converting to a USB code and sending off to the PC
796 if ( keys_debounce[key] == DEBOUNCE_THRESHOLD )
798 // Debug message, pressDebug CLI
799 if ( enablePressDebug )
802 printHex_op( key, 2 );
806 // Only add the key to the buffer once
807 // NOTE: Buffer can easily handle multiple adds, just more efficient
808 // and nicer debug messages :P
809 Macro_bufferAdd( key );
812 keys_debounce[key]++;
816 // Long form key debugging
817 if ( enableKeyDebug )
820 // <key> [<strobe>:<mux>] : <sense val> : <delta + threshold> : <margin>
822 printHex_op( key, 2 );
828 printHex( db_sample ); // Sense
830 printHex( db_threshold );
832 printHex( db_delta );
834 printHex( db_threshold + db_delta ); // Sense compare
836 printHex( db_sample - ( db_threshold + db_delta ) ); // Margin
840 // Clear debounce entry if no keypress detected
843 // If the key was previously pressed, remove from the buffer
844 for ( uint8_t c = 0; c < KeyIndex_BufferUsed; c++ )
846 // Key to release found
847 if ( KeyIndex_Buffer[c] == key )
849 // Shift keys from c position
850 for ( uint8_t k = c; k < KeyIndex_BufferUsed - 1; k++ )
851 KeyIndex_Buffer[k] = KeyIndex_Buffer[k + 1];
854 KeyIndex_BufferUsed--;
861 // Clear debounce entry
862 keys_debounce[key] = 0;
870 void dumpSenseTable()
872 // Initial table alignment, with base threshold used for every key
874 printHex( threshold );
877 // Print out headers first
878 for ( uint8_t mux = 0; mux < MUXES_COUNT; ++mux )
880 print(" Mux \033[1m");
887 // Display the full strobe/sense table
888 for ( uint8_t strober = 0; strober < total_strobes; ++strober )
890 uint8_t strobe = strobe_map[strober];
892 // Display the strobe
893 print("Strobe \033[1m");
897 // For each mux, display sense:threshold:delta
898 for ( uint8_t mux = 0; mux < MUXES_COUNT; ++mux )
900 uint8_t delta = keys_averages[(strobe << MUXES_COUNT_XSHIFT) + mux];
901 uint8_t sample = samples[strobe][mux] >> 1;
902 uint8_t max = sampleMax[strobe][mux] >> 1;
904 // Indicate if the key is being pressed by displaying green
905 if ( sample > delta + threshold )
910 printHex_op( sample, 2 );
912 printHex_op( max, 2 );
914 printHex_op( delta, 2 );
918 // New line for each strobe
924 // ----- CLI Command Functions -----
926 // XXX Just an example command showing how to parse arguments (more complex than generally needed)
927 void cliFunc_echo( char* args )
931 char* arg2Ptr = args;
933 // Parse args until a \0 is found
936 print( NL ); // No \r\n by default after the command is entered
938 curArgs = arg2Ptr; // Use the previous 2nd arg pointer to separate the next arg from the list
939 CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );
941 // Stop processing args if no more are found
942 if ( *arg1Ptr == '\0' )
950 void cliFunc_avgDebug( char* args )
954 // Args ignored, just toggling
955 if ( enableAvgDebug )
957 info_print("Cap Sense averaging debug disabled.");
962 info_print("Cap Sense averaging debug enabled.");
967 void cliFunc_keyDebug( char* args )
971 // Args ignored, just toggling
972 if ( enableKeyDebug )
974 info_print("Cap Sense key long debug disabled - pre debounce.");
979 info_print("Cap Sense key long debug enabled - pre debounce.");
984 void cliFunc_pressDebug( char* args )
988 // Args ignored, just toggling
989 if ( enablePressDebug )
991 info_print("Cap Sense key debug disabled - post debounce.");
992 enablePressDebug = 0;
996 info_print("Cap Sense key debug enabled - post debounce.");
997 enablePressDebug = 1;
1001 void cliFunc_problemKeys( char* args )
1007 // Args ignored, just displaying
1008 // Display problem keys, and the sense value at the time
1009 for ( uint8_t key = 0; key < KEY_COUNT; key++ )
1011 if ( keys_problem[key] )
1015 warn_msg("Problem keys: ");
1019 printHex( keys_problem[key] );
1025 void cliFunc_senseDebug( char* args )
1027 // Parse code from argument
1028 // NOTE: Only first argument is used
1031 CLI_argumentIsolation( args, &arg1Ptr, &arg2Ptr );
1033 // Default to a single print
1034 senseDebugCount = 1;
1036 // If there was an argument, use that instead
1037 if ( *arg1Ptr != '\0' )
1039 senseDebugCount = decToInt( arg1Ptr );