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 // Right justification of ADLAR
50 #define FULL_MUX_MASK ((1 << MUX0) | (1 << MUX1) | (1 << MUX2) | (1 << MUX3) | (1 << MUX4))
52 // F0-f7 pins only muxmask.
53 #define MUX_MASK ((1 << MUX0) | (1 << MUX1) | (1 << MUX2))
60 // set ADC clock prescale
61 #define PRESCALE_MASK ((1 << ADPS0) | (1 << ADPS1) | (1 << ADPS2))
62 #define PRESCALE_SHIFT (ADPS0)
65 // Max number of strobes supported by the hardware
66 // Strobe lines are detected at startup, extra strobes cause anomalies like phantom keypresses
67 #define MAX_STROBES 18
69 // Number of consecutive samples required to pass debounce
70 #define DEBOUNCE_THRESHOLD 5
72 // Scans to remain idle after all keys were release before starting averaging
73 // XXX So this makes the initial keypresses fast,
74 // but it's still possible to lose a keypress if you press at the wrong time -HaaTa
75 #define KEY_IDLE_SCANS 30000
77 // Total number of muxes/sense lines available
79 #define MUXES_COUNT_XSHIFT 3
81 // Number of warm-up loops before starting to scan keys
82 #define WARMUP_LOOPS ( 1024 )
83 #define WARMUP_STOP (WARMUP_LOOPS - 1)
85 #define SAMPLE_CONTROL 3
87 #define KEY_COUNT ((MAX_STROBES) * (MUXES_COUNT))
89 #define RECOVERY_CONTROL 1
90 #define RECOVERY_SOURCE 0
91 #define RECOVERY_SINK 2
96 // mix in 1/4 of the current average to the running average. -> (@mux_mix = 2)
99 #define IDLE_COUNT_SHIFT 8
101 // av = (av << shift) - av + sample; av >>= shift
102 // e.g. 1 -> (av + sample) / 2 simple average of new and old
103 // 2 -> (3 * av + sample) / 4 i.e. 3:1 mix of old to new.
104 // 3 -> (7 * av + sample) / 8 i.e. 7:1 mix of old to new.
105 #define KEYS_AVERAGES_MIX_SHIFT 3
109 // ----- Macros -----
112 #define SET_FULL_MUX(X) ((ADMUX) = (((ADMUX) & ~(FULL_MUX_MASK)) | ((X) & (FULL_MUX_MASK))))
116 // ----- Function Declarations -----
119 void cliFunc_avgDebug ( char* args );
120 void cliFunc_echo ( char* args );
121 void cliFunc_keyDebug ( char* args );
122 void cliFunc_pressDebug ( char* args );
123 void cliFunc_problemKeys( char* args );
124 void cliFunc_senseDebug ( char* args );
127 void dumpSenseTable();
129 // High-level Capsense Functions
131 void capsense_scan();
133 // Capsense Sense Functions
134 void testColumn ( uint8_t strobe );
135 void sampleColumn( uint8_t column );
137 // Low-level Capsense Functions
138 void strobe_w( uint8_t strobe_num );
139 void recovery( uint8_t on );
143 // ----- Variables -----
145 // Buffer used to inform the macro processing module which keys have been detected as pressed
146 volatile uint8_t KeyIndex_Buffer[KEYBOARD_BUFFER];
147 volatile uint8_t KeyIndex_BufferUsed;
150 // Scan Module command dictionary
151 char* scanCLIDictName = "DPH Module Commands";
152 CLIDictItem scanCLIDict[] = {
153 { "echo", "Example command, echos the arguments.", cliFunc_echo },
154 { "avgDebug", "Enables/Disables averaging results." NL "\t\tDisplays each average, starting from Key 0x00, ignoring 0 valued averages.", cliFunc_avgDebug },
155 { "keyDebug", "Enables/Disables long debug for each keypress." NL "\t\tkeycode - [strobe:mux] : sense val : threshold+delta=total : margin", cliFunc_keyDebug },
156 { "pressDebug", "Enables/Disables short debug for each keypress.", cliFunc_pressDebug },
157 { "problemKeys", "Display current list of problem keys,", cliFunc_problemKeys },
158 { "senseDebug", "Prints out the current sense table N times." NL "\t\tsense:max sense:delta", cliFunc_senseDebug },
159 { 0, 0, 0 } // Null entry for dictionary end
162 // CLI Control Variables
163 uint8_t enableAvgDebug = 0;
164 uint8_t enableKeyDebug = 0;
165 uint8_t enablePressDebug = 1;
166 uint8_t senseDebugCount = 3; // In order to get boot-time oddities
169 // Variables used to calculate the starting sense value (averaging)
170 uint32_t full_avg = 0;
171 uint32_t high_avg = 0;
172 uint32_t low_avg = 0;
174 uint8_t high_count = 0;
175 uint8_t low_count = 0;
178 uint16_t samples[MAX_STROBES][MUXES_COUNT]; // Overall table of cap sense ADC values
179 uint16_t sampleMax[MAX_STROBES][MUXES_COUNT]; // Records the max seen ADC value
181 uint8_t key_activity = 0; // Increments for each detected key per each full scan of the keyboard, it is reset before each full scan
182 uint16_t key_idle = 0; // Defines how scans after all keys were released before starting averaging again
183 uint8_t key_release = 0; // Indicates if going from key press state to release state (some keys pressed to no keys pressed)
185 uint16_t threshold = THRESHOLD;
187 uint16_t keys_averages_acc[KEY_COUNT];
188 uint16_t keys_averages [KEY_COUNT];
189 uint8_t keys_debounce [KEY_COUNT]; // Contains debounce statistics
190 uint8_t keys_problem [KEY_COUNT]; // Marks keys that should be ignored (determined by averaging at startup)
192 // TODO: change this to 'booting', then count down.
193 uint16_t boot_count = 0;
195 uint8_t total_strobes = MAX_STROBES;
196 uint8_t strobe_map[MAX_STROBES];
200 // ----- Functions -----
202 // Initial setup for cap sense controller
203 inline void Scan_setup()
205 // Register Scan CLI dictionary
206 CLI_registerDictionary( scanCLIDict, scanCLIDictName );
208 // Scan for active strobes
209 // NOTE1: On IBM PCBs, each strobe line that is *NOT* used is connected to GND.
210 // This means, the strobe GPIO can be set to Tri-State pull-up to detect which strobe lines are not used.
211 // NOTE2: This will *NOT* detect floating strobes.
212 // NOTE3: Rev 0.4, the strobe numbers are reversed, so D0 is actually strobe 0 and C7 is strobe 17
213 info_msg("Detecting Strobes...");
222 // Initially there are 0 strobes
225 // Iterate over each the strobes
226 for ( uint8_t strobe = 0; strobe < MAX_STROBES; strobe++ )
228 uint8_t detected = 0;
230 // If PIN is high, then strobe is *NOT* connected to GND and may be a strobe
237 #ifndef REV0_4_DEBUG // XXX These pins should be reworked, and connect to GND on Rev 0.4
247 detected = PIND & (1 << strobe);
252 detected = PINE & (1 << (strobe - 8));
261 #ifndef REV0_2_DEBUG // XXX If not using the 18 pin connector on Rev 0.2, rework these pins to GND
265 detected = PINC & (1 << (strobe - 10));
272 // Potential strobe line detected
275 strobe_map[total_strobes] = strobe;
280 printInt8( total_strobes );
281 print( " strobes found." NL );
283 // Setup Pins for Strobing
294 // Reset debounce table
295 for ( int i = 0; i < KEY_COUNT; ++i )
297 keys_debounce[i] = 0;
300 // Warm things up a bit before we start collecting data, taking real samples.
301 for ( uint8_t i = 0; i < total_strobes; ++i )
303 sampleColumn( strobe_map[i] );
308 // Main Detection Loop
309 // This is where the important stuff happens
310 inline uint8_t Scan_loop()
314 // Return non-zero if macro and USB processing should be delayed
315 // Macro processing will always run if returning 0
316 // USB processing only happens once the USB send timer expires, if it has not, Scan_loop will be called
317 // after the macro processing has been completed
322 // Signal KeyIndex_Buffer that it has been properly read
323 // NOTE: Only really required for implementing "tricks" in converters for odd protocols
324 void Scan_finishedWithBuffer( uint8_t sentKeys )
326 // Convenient place to clear the KeyIndex_Buffer
327 KeyIndex_BufferUsed = 0;
332 // Signal KeyIndex_Buffer that it has been properly read and sent out by the USB module
333 // NOTE: Only really required for implementing "tricks" in converters for odd protocols
334 void Scan_finishedWithUSBBuffer( uint8_t sentKeys )
340 inline void capsense_scan()
342 // Accumulated average used for the next scan
343 uint32_t cur_full_avg = 0;
344 uint32_t cur_high_avg = 0;
346 // Reset average counters
352 // Reset key activity, if there is no key activity, averages will accumulate for sense deltas, otherwise they will be reset
355 // Scan each of the mapped strobes in the matrix
356 for ( uint8_t strober = 0; strober < total_strobes; ++strober )
358 uint8_t map_strobe = strobe_map[strober];
360 // Sample the ADCs for the given column/strobe
361 sampleColumn( map_strobe );
363 // Only process sense data if warmup is finished
364 if ( boot_count >= WARMUP_LOOPS )
366 testColumn( map_strobe );
369 uint8_t strobe_line = map_strobe << MUXES_COUNT_XSHIFT;
370 for ( int mux = 0; mux < MUXES_COUNT; ++mux )
372 // discard sketchy low bit, and meaningless high bits.
373 uint8_t sample = samples[map_strobe][mux] >> 1;
374 keys_averages_acc[strobe_line + mux] += sample;
377 // Accumulate 3 total averages (used for determining starting average during warmup)
378 // full_avg - Average of all sampled lines on the previous scan set
379 // cur_full_avg - Average of all sampled lines for this scan set
380 // high_avg - Average of all sampled lines above full_avg on the previous scan set
381 // cur_high_avg - Average of all sampled lines above full_avg
382 // low_avg - Average of all sampled lines below or equal to full_avg
383 if ( boot_count < WARMUP_LOOPS )
385 for ( uint8_t mux = 0; mux < MUXES_COUNT; ++mux )
387 uint8_t sample = samples[map_strobe][mux] >> 1;
389 // Sample is high, add it to high avg
390 if ( sample > full_avg )
393 cur_high_avg += sample;
395 // Sample is low, add it to low avg
402 // If sample is higher than previous high_avg, then mark as "problem key"
403 // XXX Giving a bit more margin to pass (high_avg vs. high_avg + high_avg - full_avg) -HaaTa
404 keys_problem[strobe_line + mux] = sample > high_avg + (high_avg - full_avg) ? sample : 0;
406 // Prepare for next average
407 cur_full_avg += sample;
412 // Update total sense average (only during warm-up)
413 if ( boot_count < WARMUP_LOOPS )
415 full_avg = cur_full_avg / (total_strobes * MUXES_COUNT);
416 high_avg = cur_high_avg / high_count;
417 low_avg /= low_count;
419 // Update the base average value using the low_avg (best chance of not ignoring a keypress)
420 for ( int i = 0; i < KEY_COUNT; ++i )
422 keys_averages[i] = low_avg;
423 keys_averages_acc[i] = low_avg;
427 // Warm up voltage references
428 if ( boot_count < WARMUP_LOOPS )
432 switch ( boot_count )
436 // Show msg at first iteration only
437 info_msg("Warming up the voltage references");
449 info_msg("Warmup finished using ");
450 printInt16( WARMUP_LOOPS );
451 print(" iterations" NL );
453 // Display the final calculated averages of all the sensed strobes
454 info_msg("Full average (");
455 printInt8( total_strobes * MUXES_COUNT );
457 printHex( full_avg );
459 print(" High average (");
460 printInt8( high_count );
462 printHex( high_avg );
464 print(" Low average (");
465 printInt8( low_count );
469 print(" Rejection threshold: ");
470 printHex( high_avg + (high_avg - full_avg) );
473 // Display problem keys, and the sense value at the time
474 for ( uint8_t key = 0; key < KEY_COUNT; key++ )
476 if ( keys_problem[key] )
478 warn_msg("Problem key detected: ");
481 printHex( keys_problem[key] );
486 info_print("If problem keys were detected, and were being held down, they will be reset as soon as let go");
492 // No keypress, accumulate averages
495 // Only start averaging once the idle counter has counted down to 0
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 // Otherwise decrement the idle counter
540 // Keypresses, reset accumulators
541 else if ( key_release )
543 for ( uint8_t c = 0; c < KEY_COUNT; ++c ) { keys_averages_acc[c] = 0; }
548 // If the debugging sense table is non-zero, display
549 if ( senseDebugCount > 0 )
561 // disable adc digital pins.
562 DIDR1 |= (1 << AIN0D) | (1<<AIN1D); // set disable on pins 1,0.
565 uint8_t mux = 0 & 0x1f; // 0 == first. // 0x1e = 1.1V ref.
567 // 0 = external aref 1,1 = 2.56V internal ref
568 uint8_t aref = ((1 << REFS1) | (1 << REFS0)) & ((1 << REFS1) | (1 << REFS0));
569 uint8_t adate = (1 << ADATE) & (1 << ADATE); // trigger enable
570 uint8_t trig = 0 & ((1 << ADTS0) | (1 << ADTS1) | (1 << ADTS2)); // 0 = free running
571 // ps2, ps1 := /64 ( 2^6 ) ps2 := /16 (2^4), ps1 := 4, ps0 :=2, PS1,PS0 := 8 (2^8)
572 uint8_t prescale = ( ((PRESCALE) << PRESCALE_SHIFT) & PRESCALE_MASK ); // 001 == 2^1 == 2
573 uint8_t hispeed = (1 << ADHSM);
574 uint8_t en_mux = (1 << ACME);
576 ADCSRA = (1 << ADEN) | prescale; // ADC enable
579 //ADMUX |= ((1 << REFS1) | (1 << REFS0)); // 2.56 V internal.
580 //ADMUX |= ((1 << REFS0) ); // Vcc with external cap.
581 //ADMUX &= ~((1 << REFS1) | (1 << REFS0)); // 0,0 : aref.
582 ADMUX = aref | mux | ADLAR_BITS;
585 ADCSRA |= adate; // trigger enable
586 ADCSRB = en_mux | hispeed | trig | (ADCSRB & ~((1 << ADTS0) | (1 << ADTS1) | (1 << ADTS2))); // trigger select free running
588 ADCSRA |= (1 << ADEN); // ADC enable
589 ADCSRA |= (1 << ADSC); // start conversions q
593 void recovery( uint8_t on )
595 DDRB |= (1 << RECOVERY_CONTROL);
596 PORTB &= ~(1 << RECOVERY_SINK); // SINK always zero
597 DDRB &= ~(1 << RECOVERY_SOURCE); // SOURCE high imp
601 // set strobes to sink to gnd.
610 DDRB |= (1 << RECOVERY_SINK); // SINK pull
611 PORTB |= (1 << RECOVERY_CONTROL);
612 PORTB |= (1 << RECOVERY_SOURCE); // SOURCE high
613 DDRB |= (1 << RECOVERY_SOURCE);
617 PORTB &= ~(1 << RECOVERY_CONTROL);
618 DDRB &= ~(1 << RECOVERY_SOURCE);
619 PORTB &= ~(1 << RECOVERY_SOURCE); // SOURCE low
620 DDRB &= ~(1 << RECOVERY_SINK); // SINK high-imp
625 void hold_sample( uint8_t on )
629 PORTB |= (1 << SAMPLE_CONTROL);
630 DDRB |= (1 << SAMPLE_CONTROL);
634 DDRB |= (1 << SAMPLE_CONTROL);
635 PORTB &= ~(1 << SAMPLE_CONTROL);
640 void strobe_w( uint8_t strobe_num )
647 // Not all strobes are used depending on which are detected
648 switch ( strobe_num )
651 case 0: PORTD |= (1 << 0); break;
652 case 1: PORTD |= (1 << 1); break;
653 case 2: PORTD |= (1 << 2); break;
654 case 3: PORTD |= (1 << 3); break;
655 case 4: PORTD |= (1 << 4); break;
656 case 5: PORTD |= (1 << 5); break;
657 case 6: PORTD |= (1 << 6); break;
658 case 7: PORTD |= (1 << 7); break;
660 case 8: PORTE |= (1 << 0); break;
661 case 9: PORTE |= (1 << 1); break;
663 case 10: PORTC |= (1 << 0); break;
664 case 11: PORTC |= (1 << 1); break;
665 case 12: PORTC |= (1 << 2); break;
666 case 13: PORTC |= (1 << 3); break;
667 case 14: PORTC |= (1 << 4); break;
668 case 15: PORTC |= (1 << 5); break;
669 case 16: PORTC |= (1 << 6); break;
670 case 17: PORTC |= (1 << 7); break;
678 inline uint16_t getADC(void)
680 ADCSRA |= (1 << ADIF); // clear int flag by writing 1.
682 //wait for last read to complete.
683 while ( !( ADCSRA & (1 << ADIF) ) );
685 return ADC; // return sample
689 void sampleColumn( uint8_t column )
691 // ensure all probe lines are driven low, and chill for recovery delay.
692 ADCSRA |= (1 << ADEN) | (1 << ADSC); // enable and start conversions
707 // Allow strobes to settle
708 for ( uint8_t i = 0; i < STROBE_SETTLE; ++i ) { getADC(); }
714 getADC(); // throw away; unknown mux.
716 SET_FULL_MUX( mux + 1 ); // our *next* sample will use this
718 // retrieve current read.
719 uint16_t readVal = getADC();
720 samples[column][mux] = readVal;
722 // Update max sense sample table
723 if ( readVal > sampleMax[column][mux] )
725 sampleMax[column][mux] = readVal;
736 ADCSRA &= ~(1 << ADEN);
738 // pull all columns' strobe-lines low.
749 void testColumn( uint8_t strobe )
751 uint16_t db_delta = 0;
752 uint8_t db_sample = 0;
753 uint16_t db_threshold = 0;
758 for ( uint8_t mux = 0; mux < MUXES_COUNT; ++mux )
760 uint16_t delta = keys_averages[(strobe << MUXES_COUNT_XSHIFT) + mux];
762 uint8_t key = (strobe << MUXES_COUNT_XSHIFT) + mux;
764 // Check if this is a bad key (e.g. test point, or non-existent key)
765 if ( keys_problem[key] )
767 // If the sample value of the problem key goes below full_avg (overall initial average)
769 if ( (db_sample = samples[strobe][mux] >> 1) < full_avg )
771 info_msg("Re-enabling problem key: ");
775 keys_problem[key] = 0;
778 // Do not waste any more cycles processing, regardless, a keypress cannot be detected
783 // db_sample (uint8_t), discard meaningless high bit, and garbage low bit
784 if ( (db_sample = samples[strobe][mux] >> 1) > (db_threshold = threshold) + (db_delta = delta) )
787 key_activity++; // No longer idle, stop averaging ADC data
788 key_idle = KEY_IDLE_SCANS; // Reset idle count-down
790 // Only register keypresses once the warmup is complete, or not enough debounce info
791 if ( keys_debounce[key] <= DEBOUNCE_THRESHOLD )
793 // Add to the Macro processing buffer if debounce criteria met
794 // Automatically handles converting to a USB code and sending off to the PC
795 if ( keys_debounce[key] == DEBOUNCE_THRESHOLD )
797 // Debug message, pressDebug CLI
798 if ( enablePressDebug )
801 printHex_op( key, 2 );
805 // Only add the key to the buffer once
806 // NOTE: Buffer can easily handle multiple adds, just more efficient
807 // and nicer debug messages :P
808 //Macro_bufferAdd( key );
811 keys_debounce[key]++;
815 // Long form key debugging
816 if ( enableKeyDebug )
819 // <key> [<strobe>:<mux>] : <sense val> : <delta + threshold> : <margin>
821 printHex_op( key, 2 );
827 printHex( db_sample ); // Sense
829 printHex( db_threshold );
831 printHex( db_delta );
833 printHex( db_threshold + db_delta ); // Sense compare
835 printHex( db_sample - ( db_threshold + db_delta ) ); // Margin
839 // Clear debounce entry if no keypress detected
842 // If the key was previously pressed, remove from the buffer
843 for ( uint8_t c = 0; c < KeyIndex_BufferUsed; c++ )
845 // Key to release found
846 if ( KeyIndex_Buffer[c] == key )
848 // Shift keys from c position
849 for ( uint8_t k = c; k < KeyIndex_BufferUsed - 1; k++ )
850 KeyIndex_Buffer[k] = KeyIndex_Buffer[k + 1];
853 KeyIndex_BufferUsed--;
860 // Clear debounce entry
861 keys_debounce[key] = 0;
869 void dumpSenseTable()
871 // Initial table alignment, with base threshold used for every key
873 printHex( threshold );
876 // Print out headers first
877 for ( uint8_t mux = 0; mux < MUXES_COUNT; ++mux )
879 print(" Mux \033[1m");
886 // Display the full strobe/sense table
887 for ( uint8_t strober = 0; strober < total_strobes; ++strober )
889 uint8_t strobe = strobe_map[strober];
891 // Display the strobe
892 print("Strobe \033[1m");
896 // For each mux, display sense:threshold:delta
897 for ( uint8_t mux = 0; mux < MUXES_COUNT; ++mux )
899 uint8_t delta = keys_averages[(strobe << MUXES_COUNT_XSHIFT) + mux];
900 uint8_t sample = samples[strobe][mux] >> 1;
901 uint8_t max = sampleMax[strobe][mux] >> 1;
903 // Indicate if the key is being pressed by displaying green
904 if ( sample > delta + threshold )
909 printHex_op( sample, 2 );
911 printHex_op( max, 2 );
913 printHex_op( delta, 2 );
917 // New line for each strobe
923 // ----- CLI Command Functions -----
925 // XXX Just an example command showing how to parse arguments (more complex than generally needed)
926 void cliFunc_echo( char* args )
930 char* arg2Ptr = args;
932 // Parse args until a \0 is found
935 print( NL ); // No \r\n by default after the command is entered
937 curArgs = arg2Ptr; // Use the previous 2nd arg pointer to separate the next arg from the list
938 CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );
940 // Stop processing args if no more are found
941 if ( *arg1Ptr == '\0' )
949 void cliFunc_avgDebug( char* args )
953 // Args ignored, just toggling
954 if ( enableAvgDebug )
956 info_print("Cap Sense averaging debug disabled.");
961 info_print("Cap Sense averaging debug enabled.");
966 void cliFunc_keyDebug( char* args )
970 // Args ignored, just toggling
971 if ( enableKeyDebug )
973 info_print("Cap Sense key long debug disabled - pre debounce.");
978 info_print("Cap Sense key long debug enabled - pre debounce.");
983 void cliFunc_pressDebug( char* args )
987 // Args ignored, just toggling
988 if ( enablePressDebug )
990 info_print("Cap Sense key debug disabled - post debounce.");
991 enablePressDebug = 0;
995 info_print("Cap Sense key debug enabled - post debounce.");
996 enablePressDebug = 1;
1000 void cliFunc_problemKeys( char* args )
1006 // Args ignored, just displaying
1007 // Display problem keys, and the sense value at the time
1008 for ( uint8_t key = 0; key < KEY_COUNT; key++ )
1010 if ( keys_problem[key] )
1014 warn_msg("Problem keys: ");
1018 printHex( keys_problem[key] );
1024 void cliFunc_senseDebug( char* args )
1026 // Parse code from argument
1027 // NOTE: Only first argument is used
1030 CLI_argumentIsolation( args, &arg1Ptr, &arg2Ptr );
1032 // Default to a single print
1033 senseDebugCount = 1;
1035 // If there was an argument, use that instead
1036 if ( *arg1Ptr != '\0' )
1038 senseDebugCount = decToInt( arg1Ptr );