Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- deton
- Date:
- 2017-03-18
- Revision:
- 1:00109a338de8
- Parent:
- 0:9ae9d1744fe4
File content as of revision 1:00109a338de8:
// KeyMatrixAnalyzer for TrackPoint Keyboard USB English 0B47190 #include "mbed.h" // R1 R7 R6 S9 R4 R5 S0 R2 R3 S5 S1 R0 S2 S4 S7 S8 S6 S3 S12 S13 S14 S11 S10 S15 M0 ML MM MR const int RPINLEN = 8; const int SPINLEN = 16; DigitalIn rpin[RPINLEN] = {p12, p20, p14, p22, p18, p15, p19, p17}; DigitalOut spin[SPINLEN] = {p21, p23, p24, p9, p11, p13, p26, p25, p10, p16, p29, p7, p27, p8, p28, p6}; Serial pc(USBTX, USBRX); int prevs = -1; int prevr = -1; void loop() { for (int s = 0; s < SPINLEN; s++) { spin[s] = 0; wait_ms(5); for (int r = 0; r < RPINLEN; r++) { if (rpin[r] == 0) { if (prevs == s && prevr == r) { continue; } prevs = s; prevr = r; pc.printf(" %d %d\r\n", s, r); } } spin[s] = 1; } } int main() { for (int r = 0; r < RPINLEN; r++) { rpin[r].mode(PullUp); } for (int s = 0; s < SPINLEN; s++) { spin[s] = 1; } while (true) { loop(); } }