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
Diff: I2CSlaveComm.cpp
- Revision:
- 4:5f2b51fa096a
- Parent:
- 3:29925a0f88da
- Child:
- 5:1eb90dace1c7
diff -r 29925a0f88da -r 5f2b51fa096a I2CSlaveComm.cpp --- a/I2CSlaveComm.cpp Thu Nov 01 17:43:10 2018 +0000 +++ b/I2CSlaveComm.cpp Thu Nov 01 19:33:01 2018 +0000 @@ -10,19 +10,19 @@ Serial PcUart(USBTX, USBRX); int modeswitch = 1; -int saveswitch; -int counter = 0; +int saveswitch = 0; +float counter = 0; int I2Cswitch = 1; -float risetime = 40; -float falltime = 20; -float plateautime = 10; +float risetime = 60; +float falltime = 10; +float plateautime = 5; +float steptime = 0.2; -float steptime = 5; +float highvalue = 6; +float lowvalue = -1; -float highvalue = 100; -float lowvalue = 20; float stepvalue = steptime * (highvalue - lowvalue) / risetime; float tension = lowvalue; @@ -187,14 +187,15 @@ if(saveswitch == 2) { printf("Tension fall begins\n"); - modeswitch = saveswitch; } else if (saveswitch == 1) { printf("Tension rise begins\n"); - modeswitch = saveswitch; } + counter = 0; + modeswitch = saveswitch; + } else { @@ -304,12 +305,12 @@ if(modeswitch == 2) printf("Falling, tension = %f\n", tension); - if(modeswitch == 1 && tension >= highvalue - 0.0001f) + if(modeswitch == 1 && tension >= highvalue - 0.001f) { tension = highvalue; cycle(); } - else if(modeswitch == 2 && tension <= lowvalue + 0.0001f) + else if(modeswitch == 2 && tension <= lowvalue + 0.001f) { tension = lowvalue; cycle();