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 // Scan Module command dictionary
147 CLIDict_Entry( echo, "Example command, echos the arguments." );
148 CLIDict_Entry( avgDebug, "Enables/Disables averaging results." NL "\t\tDisplays each average, starting from Key 0x00, ignoring 0 valued averages." );
149 CLIDict_Entry( keyDebug, "Enables/Disables long debug for each keypress." NL "\t\tkeycode - [strobe:mux] : sense val : threshold+delta=total : margin" );
150 CLIDict_Entry( pressDebug, "Enables/Disables short debug for each keypress." );
151 CLIDict_Entry( problemKeys, "Display current list of problem keys," );
152 CLIDict_Entry( senseDebug, "Prints out the current sense table N times." NL "\t\tsense:max sense:delta" );
154 CLIDict_Def( scanCLIDict, "DPH Module Commands" ) = {
155 CLIDict_Item( echo ),
156 CLIDict_Item( avgDebug ),
157 CLIDict_Item( keyDebug ),
158 CLIDict_Item( pressDebug ),
159 CLIDict_Item( problemKeys ),
160 CLIDict_Item( senseDebug ),
161 { 0, 0, 0 } // Null entry for dictionary end
165 // CLI Control Variables
166 uint8_t enableAvgDebug = 0;
167 uint8_t enableKeyDebug = 0;
168 uint8_t enablePressDebug = 0;
169 uint8_t senseDebugCount = 3; // In order to get boot-time oddities
172 // Variables used to calculate the starting sense value (averaging)
173 uint32_t full_avg = 0;
174 uint32_t high_avg = 0;
175 uint32_t low_avg = 0;
177 uint8_t high_count = 0;
178 uint8_t low_count = 0;
181 uint16_t samples[MAX_STROBES][MUXES_COUNT]; // Overall table of cap sense ADC values
182 uint16_t sampleMax[MAX_STROBES][MUXES_COUNT]; // Records the max seen ADC value
184 uint8_t key_activity = 0; // Increments for each detected key per each full scan of the keyboard, it is reset before each full scan
185 uint16_t key_idle = 0; // Defines how scans after all keys were released before starting averaging again
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 from macro module that keys have been processed
326 // NOTE: Only really required for implementing "tricks" in converters for odd protocols
327 void Scan_finishedWithMacro( uint8_t sentKeys )
333 // Signal from output module that keys have been processed/sent
334 // NOTE: Only really required for implementing "tricks" in converters for odd protocols
335 void Scan_finishedWithOutput( 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.");
488 info_print("Some keys have unusually high sense values, on the first press they should be re-enabled.");
494 // No keypress, accumulate averages
497 // Only start averaging once the idle counter has counted down to 0
501 if ( enableAvgDebug )
503 print("\033[1mAvg\033[0m: ");
507 for ( uint8_t i = 0; i < KEY_COUNT; ++i )
509 uint16_t acc = keys_averages_acc[i];
510 //uint16_t acc = keys_averages_acc[i] >> IDLE_COUNT_SHIFT; // XXX This fixes things... -HaaTa
511 uint32_t av = keys_averages[i];
513 av = (av << KEYS_AVERAGES_MIX_SHIFT) - av + acc;
514 av >>= KEYS_AVERAGES_MIX_SHIFT;
516 keys_averages[i] = av;
517 keys_averages_acc[i] = 0;
520 if ( enableAvgDebug && av > 0 )
528 if ( enableAvgDebug )
533 // No key presses detected, set key_release indicator
536 // Otherwise decrement the idle counter
542 // Keypresses, reset accumulators
543 else if ( key_release )
545 for ( uint8_t c = 0; c < KEY_COUNT; ++c ) { keys_averages_acc[c] = 0; }
550 // If the debugging sense table is non-zero, display
551 if ( senseDebugCount > 0 )
563 // disable adc digital pins.
564 DIDR1 |= (1 << AIN0D) | (1<<AIN1D); // set disable on pins 1,0.
567 uint8_t mux = 0 & 0x1f; // 0 == first. // 0x1e = 1.1V ref.
569 // 0 = external aref 1,1 = 2.56V internal ref
570 uint8_t aref = ((1 << REFS1) | (1 << REFS0)) & ((1 << REFS1) | (1 << REFS0));
571 uint8_t adate = (1 << ADATE) & (1 << ADATE); // trigger enable
572 uint8_t trig = 0 & ((1 << ADTS0) | (1 << ADTS1) | (1 << ADTS2)); // 0 = free running
573 // ps2, ps1 := /64 ( 2^6 ) ps2 := /16 (2^4), ps1 := 4, ps0 :=2, PS1,PS0 := 8 (2^8)
574 uint8_t prescale = ( ((PRESCALE) << PRESCALE_SHIFT) & PRESCALE_MASK ); // 001 == 2^1 == 2
575 uint8_t hispeed = (1 << ADHSM);
576 uint8_t en_mux = (1 << ACME);
578 ADCSRA = (1 << ADEN) | prescale; // ADC enable
581 //ADMUX |= ((1 << REFS1) | (1 << REFS0)); // 2.56 V internal.
582 //ADMUX |= ((1 << REFS0) ); // Vcc with external cap.
583 //ADMUX &= ~((1 << REFS1) | (1 << REFS0)); // 0,0 : aref.
584 ADMUX = aref | mux | ADLAR_BITS;
587 ADCSRA |= adate; // trigger enable
588 ADCSRB = en_mux | hispeed | trig | (ADCSRB & ~((1 << ADTS0) | (1 << ADTS1) | (1 << ADTS2))); // trigger select free running
590 ADCSRA |= (1 << ADEN); // ADC enable
591 ADCSRA |= (1 << ADSC); // start conversions q
595 void recovery( uint8_t on )
597 DDRB |= (1 << RECOVERY_CONTROL);
598 PORTB &= ~(1 << RECOVERY_SINK); // SINK always zero
599 DDRB &= ~(1 << RECOVERY_SOURCE); // SOURCE high imp
603 // set strobes to sink to gnd.
612 DDRB |= (1 << RECOVERY_SINK); // SINK pull
613 PORTB |= (1 << RECOVERY_CONTROL);
614 PORTB |= (1 << RECOVERY_SOURCE); // SOURCE high
615 DDRB |= (1 << RECOVERY_SOURCE);
619 PORTB &= ~(1 << RECOVERY_CONTROL);
620 DDRB &= ~(1 << RECOVERY_SOURCE);
621 PORTB &= ~(1 << RECOVERY_SOURCE); // SOURCE low
622 DDRB &= ~(1 << RECOVERY_SINK); // SINK high-imp
627 void hold_sample( uint8_t on )
631 PORTB |= (1 << SAMPLE_CONTROL);
632 DDRB |= (1 << SAMPLE_CONTROL);
636 DDRB |= (1 << SAMPLE_CONTROL);
637 PORTB &= ~(1 << SAMPLE_CONTROL);
642 void strobe_w( uint8_t strobe_num )
649 // Not all strobes are used depending on which are detected
650 switch ( strobe_num )
653 case 0: PORTD |= (1 << 0); break;
654 case 1: PORTD |= (1 << 1); break;
655 case 2: PORTD |= (1 << 2); break;
656 case 3: PORTD |= (1 << 3); break;
657 case 4: PORTD |= (1 << 4); break;
658 case 5: PORTD |= (1 << 5); break;
659 case 6: PORTD |= (1 << 6); break;
660 case 7: PORTD |= (1 << 7); break;
662 case 8: PORTE |= (1 << 0); break;
663 case 9: PORTE |= (1 << 1); break;
665 case 10: PORTC |= (1 << 0); break;
666 case 11: PORTC |= (1 << 1); break;
667 case 12: PORTC |= (1 << 2); break;
668 case 13: PORTC |= (1 << 3); break;
669 case 14: PORTC |= (1 << 4); break;
670 case 15: PORTC |= (1 << 5); break;
671 case 16: PORTC |= (1 << 6); break;
672 case 17: PORTC |= (1 << 7); break;
680 inline uint16_t getADC(void)
682 ADCSRA |= (1 << ADIF); // clear int flag by writing 1.
684 //wait for last read to complete.
685 while ( !( ADCSRA & (1 << ADIF) ) );
687 return ADC; // return sample
691 void sampleColumn( uint8_t column )
693 // ensure all probe lines are driven low, and chill for recovery delay.
694 ADCSRA |= (1 << ADEN) | (1 << ADSC); // enable and start conversions
709 // Allow strobes to settle
710 for ( uint8_t i = 0; i < STROBE_SETTLE; ++i ) { getADC(); }
716 getADC(); // throw away; unknown mux.
718 SET_FULL_MUX( mux + 1 ); // our *next* sample will use this
720 // retrieve current read.
721 uint16_t readVal = getADC();
722 samples[column][mux] = readVal;
724 // Update max sense sample table
725 if ( readVal > sampleMax[column][mux] )
727 sampleMax[column][mux] = readVal;
738 ADCSRA &= ~(1 << ADEN);
740 // pull all columns' strobe-lines low.
751 void testColumn( uint8_t strobe )
753 uint16_t db_delta = 0;
754 uint8_t db_sample = 0;
755 uint16_t db_threshold = 0;
760 for ( uint8_t mux = 0; mux < MUXES_COUNT; ++mux )
762 uint16_t delta = keys_averages[(strobe << MUXES_COUNT_XSHIFT) + mux];
764 uint8_t key = (strobe << MUXES_COUNT_XSHIFT) + mux;
766 // Check if this is a bad key (e.g. test point, or non-existent key)
767 if ( keys_problem[key] )
769 // If the sample value of the problem key goes above initally recorded result + threshold
771 if ( (db_sample = samples[strobe][mux] >> 1) > keys_problem[key] + threshold )
772 //if ( (db_sample = samples[strobe][mux] >> 1) < high_avg )
774 info_msg("Re-enabling problem key: ");
778 keys_problem[key] = 0;
781 // Do not waste any more cycles processing, regardless, a keypress cannot be detected
786 // db_sample (uint8_t), discard meaningless high bit, and garbage low bit
787 if ( (db_sample = samples[strobe][mux] >> 1) > (db_threshold = threshold) + (db_delta = delta) )
790 key_activity++; // No longer idle, stop averaging ADC data
791 key_idle = KEY_IDLE_SCANS; // Reset idle count-down
793 // Only register keypresses once the warmup is complete, or not enough debounce info
794 if ( keys_debounce[key] <= DEBOUNCE_THRESHOLD )
796 // Add to the Macro processing buffer if debounce criteria met
797 // Automatically handles converting to a USB code and sending off to the PC
798 if ( keys_debounce[key] == DEBOUNCE_THRESHOLD )
800 // Debug message, pressDebug CLI
801 if ( enablePressDebug )
804 printHex_op( key, 2 );
809 Macro_keyState( key, 0x01 );
812 keys_debounce[key]++;
815 else if ( keys_debounce[key] >= DEBOUNCE_THRESHOLD )
818 Macro_keyState( key, 0x02 );
821 // Long form key debugging
822 if ( enableKeyDebug )
825 // <key> [<strobe>:<mux>] : <sense val> : <delta + threshold> : <margin>
827 printHex_op( key, 1 );
833 printHex( db_sample ); // Sense
835 printHex( db_threshold );
837 printHex( db_delta );
839 printHex( db_threshold + db_delta ); // Sense compare
841 printHex( db_sample - ( db_threshold + db_delta ) ); // Margin
845 // Clear debounce entry if no keypress detected
849 if ( keys_debounce[key] >= DEBOUNCE_THRESHOLD )
851 Macro_keyState( key, 0x03 );
854 // Clear debounce entry
855 keys_debounce[key] = 0;
863 void dumpSenseTable()
865 // Initial table alignment, with base threshold used for every key
867 printHex( threshold );
870 // Print out headers first
871 for ( uint8_t mux = 0; mux < MUXES_COUNT; ++mux )
873 print(" Mux \033[1m");
880 // Display the full strobe/sense table
881 for ( uint8_t strober = 0; strober < total_strobes; ++strober )
883 uint8_t strobe = strobe_map[strober];
885 // Display the strobe
886 print("Strobe \033[1m");
890 // For each mux, display sense:threshold:delta
891 for ( uint8_t mux = 0; mux < MUXES_COUNT; ++mux )
893 uint8_t delta = keys_averages[(strobe << MUXES_COUNT_XSHIFT) + mux];
894 uint8_t sample = samples[strobe][mux] >> 1;
895 uint8_t max = sampleMax[strobe][mux] >> 1;
897 // Indicate if the key is being pressed by displaying green
898 if ( sample > delta + threshold )
903 printHex_op( sample, 2 );
905 printHex_op( max, 2 );
907 printHex_op( delta, 2 );
911 // New line for each strobe
917 // ----- CLI Command Functions -----
919 // XXX Just an example command showing how to parse arguments (more complex than generally needed)
920 void cliFunc_echo( char* args )
924 char* arg2Ptr = args;
926 // Parse args until a \0 is found
929 print( NL ); // No \r\n by default after the command is entered
931 curArgs = arg2Ptr; // Use the previous 2nd arg pointer to separate the next arg from the list
932 CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );
934 // Stop processing args if no more are found
935 if ( *arg1Ptr == '\0' )
943 void cliFunc_avgDebug( char* args )
947 // Args ignored, just toggling
948 if ( enableAvgDebug )
950 info_print("Cap Sense averaging debug disabled.");
955 info_print("Cap Sense averaging debug enabled.");
960 void cliFunc_keyDebug( char* args )
964 // Args ignored, just toggling
965 if ( enableKeyDebug )
967 info_print("Cap Sense key long debug disabled - pre debounce.");
972 info_print("Cap Sense key long debug enabled - pre debounce.");
977 void cliFunc_pressDebug( char* args )
981 // Args ignored, just toggling
982 if ( enablePressDebug )
984 info_print("Cap Sense key debug disabled - post debounce.");
985 enablePressDebug = 0;
989 info_print("Cap Sense key debug enabled - post debounce.");
990 enablePressDebug = 1;
994 void cliFunc_problemKeys( char* args )
1000 // Args ignored, just displaying
1001 // Display problem keys, and the sense value at the time
1002 for ( uint8_t key = 0; key < KEY_COUNT; key++ )
1004 if ( keys_problem[key] )
1008 warn_msg("Problem keys: ");
1012 printHex( keys_problem[key] );
1018 void cliFunc_senseDebug( char* args )
1020 // Parse code from argument
1021 // NOTE: Only first argument is used
1024 CLI_argumentIsolation( args, &arg1Ptr, &arg2Ptr );
1026 // Default to a single print
1027 senseDebugCount = 1;
1029 // If there was an argument, use that instead
1030 if ( *arg1Ptr != '\0' )
1032 senseDebugCount = numToInt( arg1Ptr );