sf

Files at this revision

API Documentation at this revision

Comitter:
floatlei
Date:
Tue Sep 27 09:41:52 2016 +0000
Commit message:
sf

Changed in this revision

batter.cpp Show annotated file Show diff for this revision Revisions of this file
batter.h Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r e1658d625afc batter.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/batter.cpp	Tue Sep 27 09:41:52 2016 +0000
@@ -0,0 +1,29 @@
+#include "batter.h"
+
+//batter
+AnalogIn batter_volt(PA_3);
+DigitalOut batter_free(PB_5);
+
+BatterVol::BatterVol()
+{
+    
+    batter_free=1;
+}
+
+unsigned short BatterVol::detect(void)
+{
+    float batval;
+    unsigned short bata;
+    
+    batter_free=0;  
+    wait(5); 
+    batter_free=1;  
+    wait(3);
+    
+    batval=batter_volt.read();
+    batval*=4.17;       //3*7.1/5.1
+    
+    bata=(unsigned short)(batval*100);
+         
+    return bata;
+}
diff -r 000000000000 -r e1658d625afc batter.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/batter.h	Tue Sep 27 09:41:52 2016 +0000
@@ -0,0 +1,41 @@
+/* mbed Microcontroller Library
+ * Copyright (c) 2006-2013 ARM Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+#include "mbed.h"
+
+#ifndef SANFAN_BATTER_H
+#define SANFAN_BATTER_H
+
+#include "platform.h"
+
+class BatterVol {
+
+public:
+    BatterVol();
+
+    unsigned short detect(void);
+
+private:
+
+
+protected:
+  
+};
+
+#endif
+
+
+