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.
Dependencies: mbed SerialInputReactionHandler AMPulseTrain SwArr16MOSFET StrCommandHandler KajiLabES
main.cpp@0:19a67422961f, 2018-10-23 (annotated)
- Committer:
- aktk
- Date:
- Tue Oct 23 15:11:18 2018 +0000
- Revision:
- 0:19a67422961f
- Child:
- 1:b97639dad576
used in UIST2018 DEMO
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| aktk | 0:19a67422961f | 1 | #include "mbed.h" |
| aktk | 0:19a67422961f | 2 | #include "KajiLabES.h" |
| aktk | 0:19a67422961f | 3 | #include "PMRC16ch.h" |
| aktk | 0:19a67422961f | 4 | #include "sigbind.h" |
| aktk | 0:19a67422961f | 5 | #include <iostream> |
| aktk | 0:19a67422961f | 6 | #include <bitset> |
| aktk | 0:19a67422961f | 7 | ProcessState pstate; |
| aktk | 0:19a67422961f | 8 | Serial pc(USBTX, USBRX); // tx, rx |
| aktk | 0:19a67422961f | 9 | |
| aktk | 0:19a67422961f | 10 | DigitalOut myled1(LED1); |
| aktk | 0:19a67422961f | 11 | DigitalOut myled2(LED2); |
| aktk | 0:19a67422961f | 12 | DigitalOut myled3(LED3); |
| aktk | 0:19a67422961f | 13 | DigitalOut myled4(LED4); |
| aktk | 0:19a67422961f | 14 | KajiLabES stimulator; |
| aktk | 0:19a67422961f | 15 | PMRC16ch pmrc(16); |
| aktk | 0:19a67422961f | 16 | uint32_t pw;//pulse width |
| aktk | 0:19a67422961f | 17 | uint32_t pp;//pulse period |
| aktk | 0:19a67422961f | 18 | uint32_t ph;//pulse hight |
| aktk | 0:19a67422961f | 19 | |
| aktk | 0:19a67422961f | 20 | int main() |
| aktk | 0:19a67422961f | 21 | { |
| aktk | 0:19a67422961f | 22 | stimulator.DAADinit(); |
| aktk | 0:19a67422961f | 23 | myled1 = 1; |
| aktk | 0:19a67422961f | 24 | pmrc.allHiZ(); |
| aktk | 0:19a67422961f | 25 | myled2 = 1; |
| aktk | 0:19a67422961f | 26 | { |
| aktk | 0:19a67422961f | 27 | using namespace aktk_sigbind; |
| aktk | 0:19a67422961f | 28 | pc.baud(921600); |
| aktk | 0:19a67422961f | 29 | pc.attach(&keyBind); |
| aktk | 0:19a67422961f | 30 | pw = 100; |
| aktk | 0:19a67422961f | 31 | pp = 5000; |
| aktk | 0:19a67422961f | 32 | ph = 0; |
| aktk | 0:19a67422961f | 33 | printKBManual(); |
| aktk | 0:19a67422961f | 34 | wait(.5); |
| aktk | 0:19a67422961f | 35 | } |
| aktk | 0:19a67422961f | 36 | while(1) { |
| aktk | 0:19a67422961f | 37 | while (pstate == WAIT_A_CERTAIN_KEY) { |
| aktk | 0:19a67422961f | 38 | myled3 = (!myled3); |
| aktk | 0:19a67422961f | 39 | wait(0.5); |
| aktk | 0:19a67422961f | 40 | } |
| aktk | 0:19a67422961f | 41 | myled3 = 1; |
| aktk | 0:19a67422961f | 42 | pmrc.setPol(PMRC16ch::Cathodic); |
| aktk | 0:19a67422961f | 43 | while (pstate == MAIN_ROUTINE) { |
| aktk | 0:19a67422961f | 44 | for(int i = 0; i < 2; i++) { |
| aktk | 0:19a67422961f | 45 | //pmrc.setTwin(i+1, (i+4)%8+1); |
| aktk | 0:19a67422961f | 46 | pmrc.setTwin(i+1, (i+1)%8+1); |
| aktk | 0:19a67422961f | 47 | //pmrc.setOvsO(i+1); |
| aktk | 0:19a67422961f | 48 | wait_us(pp-pw); |
| aktk | 0:19a67422961f | 49 | stimulator.DAAD(ph); |
| aktk | 0:19a67422961f | 50 | wait_us(pw); |
| aktk | 0:19a67422961f | 51 | stimulator.DAAD(0); |
| aktk | 0:19a67422961f | 52 | //pmrc.allHiZ(); |
| aktk | 0:19a67422961f | 53 | //wait_us(pw); |
| aktk | 0:19a67422961f | 54 | } |
| aktk | 0:19a67422961f | 55 | if (pstate == TERMINATED) break; |
| aktk | 0:19a67422961f | 56 | } |
| aktk | 0:19a67422961f | 57 | } |
| aktk | 0:19a67422961f | 58 | } |