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:
- 6:812c1b9f2183
- Parent:
- 5:1eb90dace1c7
--- a/I2CSlaveComm.cpp Thu Nov 01 20:50:28 2018 +0000
+++ b/I2CSlaveComm.cpp Fri Nov 23 14:30:52 2018 +0000
@@ -13,12 +13,10 @@
int saveswitch = 0;
float counter = 0;
-int I2Cswitch = 1;
-
float risetime = 600;
float falltime = 30;
float plateautime = 5;
-float steptime = 0.5;
+float steptime = 5;
float highvalue = 6;
float lowvalue = -1;
@@ -222,12 +220,11 @@
{
char command = PcUart.getc();
switch(command)
- {
+ {
+
case 'w':
{
- I2Cswitch = 0;
- flow_ticker.detach();
-
+ flow_ticker.detach();
printf("Setting parameters\n");
printf("Enter tension high value in kPa\n");
@@ -261,14 +258,13 @@
modeswitch = 1;
flow_ticker.attach(&flow, steptime);
- I2Cswitch = 1;
break;
}
case 'i':
{
printf("List of parameter values\n");
- printf("High tension: %df kPa\n", (int)highvalue);
+ printf("High tension: %d kPa\n", (int)highvalue);
printf("Low tension: %d kPa\n", (int)lowvalue);
printf("Cycle rise time: %d seconds\n", (int)risetime);
printf("Cycle fall time: %d seconds\n", (int)falltime);
@@ -301,7 +297,7 @@
setTension(tension);
if(modeswitch == 1)
- printf("Rising, tension = %f\n", tension);
+ printf("Rising, tension = %f\n", tension);
if(modeswitch == 2)
printf("Falling, tension = %f\n", tension);
@@ -320,15 +316,42 @@
int main()
{
- printf("Initiating\n");
+ printf("Setting parameters\n");
+
+ printf("Enter tension high value in kPa\n");
+ scanf("%s", buffer);
+ highvalue = atoi(buffer);
+
+ printf("Enter tension low value in kPa\n");
+ scanf("%s", buffer);
+ lowvalue = atoi(buffer);
+
+ printf("Enter tension rise time in seconds\n");
+ scanf("%s", buffer);
+ risetime = atoi(buffer);
+
+ printf("Enter tension fall time in seconds\n");
+ scanf("%s", buffer);
+ falltime = atoi(buffer);
+
+ printf("Enter plateau time in seconds\n");
+ scanf("%s", buffer);
+ plateautime = atoi(buffer);
+
+ printf("Enter step time *in milliseconds*\n");
+ scanf("%s", buffer);
+ steptime = (float)atoi(buffer)/1000;
+
+ tension = lowvalue;
+ stepvalue = steptime * (highvalue - lowvalue) / risetime;
+
+ printf("Beginning simulation\n");
+
InitI2CSlaveComm();
flow_ticker.attach(&flow, steptime);
command_ticker.attach(&commandselect, 1);
while(1)
{
- if(I2Cswitch == 1)
- {
I2CSlaveProcess();
- }
}
}
\ No newline at end of file