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.
Revision 6:065aa0a2c4f8, committed 2015-03-26
- Comitter:
- rkk
- Date:
- Thu Mar 26 13:44:31 2015 +0000
- Parent:
- 5:6e2176d77900
- Commit message:
- repeatably send commands
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 6e2176d77900 -r 065aa0a2c4f8 main.cpp --- a/main.cpp Thu Mar 26 13:15:23 2015 +0000 +++ b/main.cpp Thu Mar 26 13:44:31 2015 +0000 @@ -61,17 +61,24 @@ pc.attach(&rxCallback, MODSERIAL::RxIrq); bt.attach(&txCallback, MODSERIAL::TxIrq); - led1 = 1.0f; - led2 = 1.0f; - led3 = 1.0f; - led4 = 1.0f; + led1 = 0.0f; + led2 = 0.0f; + led3 = 0.0f; + led4 = 0.0f; int input = 0; int index = 0; pc.printf("Master Alive!\n"); int which = 0; int newIntensity =0; int newOnTime =0; - int newPeriodTime=0; + int newPeriodTime = 0; + int motorNumber = '0'; + + //init some values + intensity[which] = 1; + onTime[which] = 50; + periodTime[which] = 50; + pc.printf("Type: WhichMotor[0-7] Intensity[0-9] OnTime[0-9] PeriodTime[0-9], e.g. 0826 \n"); while(1) { // Wait here until we detect the \n going into the buffer. @@ -81,11 +88,12 @@ input = pc.getc(); switch ( index ) { case 0: { - which = input-'0';//set into range from 0 - 9 + motorNumber = input; + which = motorNumber-('0');//set into range from 0 - 9 index = (which < 0)? 4 : index; index = (which > (NUM_SENSORS-1))? 4 : index; pc.printf("Sensor: %d ",which); - bt.putc(input); + bt.putc(motorNumber); break; } case 1: { @@ -132,12 +140,21 @@ bt.putc('\0'); index = 0; } - // send out new line command - - led1 = (float) which/3.0; - led2 = (float) intensity[which]/255.0; - led3 = (float) onTime[which]/255.0; - led4 = (float) periodTime[which]/255.0; + else + { + bt.putc(motorNumber); + bt.putc(intensity[which]); + bt.putc(onTime[which]); + bt.putc(periodTime[which]); + bt.putc('\0'); + } + + wait_ms(400); + //led1 = (float) which/3.0; + //led2 = (float) intensity[which]/255.0; + //led3 = (float) onTime[which]/255.0; + //led4 = (float) periodTime[which]/255.0; + }