for pet feeder system

Dependents:   PetfeederWebServer

Fork of httpServer_with_Ethernt by IOP

Files at this revision

API Documentation at this revision

Comitter:
justinkim
Date:
Wed May 04 00:43:24 2016 +0000
Parent:
4:2903435e3811
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
diff -r 2903435e3811 -r 3c24e937da61 Handler/FsHandler.cpp
--- 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;