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.
Fork of httpServer-orgel by
Revision 5:3c24e937da61, committed 2016-05-04
- Comitter:
- justinkim
- Date:
- Wed May 04 00:43:24 2016 +0000
- Parent:
- 4:2903435e3811
- Child:
- 6:9aefb9ff74ce
- Commit message:
- pet feeder system ver 0.1
Changed in this revision
| Handler/FsHandler.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/Handler/FsHandler.cpp Fri Feb 12 07:39:47 2016 +0000
+++ b/Handler/FsHandler.cpp Wed May 04 00:43:24 2016 +0000
@@ -8,9 +8,7 @@
DigitalOut led_green(LED2);
DigitalOut led_blue(LED3);
-DigitalIn din(PC_14);
-AnalogIn ain0(A0);
-AnalogIn ain1(A1);
+PwmOut myservo(PC_10);
static int matchstrings(const char* one, const char* two)
{
@@ -83,7 +81,7 @@
{
char buf[256];
- sprintf(buf, "AinCallback({\"ain_v0\":\"%.3f\",\"ain_v1\":\"%.3f\"});",ain0.read()*100, ain1.read()*100);
+ //sprintf(buf, "AinCallback({\"ain_v0\":\"%.3f\",\"ain_v1\":\"%.3f\"});",ain0.read()*100, ain1.read()*100);
tcp.send(buf, strlen(buf));
}
@@ -149,7 +147,9 @@
int HTTPFsRequestHandler::handlePostRequest()
{
-
+ char ch;
+ double duty;
+ myservo.period_ms(20);
int pin = 0;
if( std::string::npos != msg.uri.find("set_dio.cgi") )
@@ -173,7 +173,32 @@
}
return 0;
- }
+ }
+ else if( std::string::npos != msg.uri.find("set_dio2.cgi") )
+ {
+ ch = get_http_param_value("pin");
+
+ if(ch == 0)
+ {
+ duty = 0.05;
+ myservo = duty;
+ printf("duty : %lf\r\n", duty);
+ }
+ else if(ch == 1)
+ {
+ duty = 1;
+ myservo = duty;
+ printf("duty : %lf\r\n", duty);
+ //myservo.pulsewidth_ms(1.0);
+ }
+ else if(ch == 2)
+ {
+ duty = 0.2;
+ myservo = duty;
+ printf("duty : %lf\r\n", duty);
+ //myservo.pulsewidth_ms(1.0);
+ }
+ }
else
{
return 404;
