]> Zhao Yanbai Git Server - acecode.git/commitdiff
...
authoracevest <zhaoyanbai@126.com>
Thu, 28 May 2015 01:39:49 +0000 (09:39 +0800)
committeracevest <zhaoyanbai@126.com>
Thu, 28 May 2015 01:39:49 +0000 (09:39 +0800)
arduino/Sensors/Sensors.ino
arduino/bluetoothinit/bluetoothinit.ino [new file with mode: 0644]
learn/doc/mac [new file with mode: 0644]
learn/test/socket.performance/.c.txt.swp [new file with mode: 0644]
learn/test/socket.performance/shell.c [new file with mode: 0644]
tools/AceBox/.DS_Store
tools/AceBox/AceBox.xcodeproj/project.xcworkspace/xcshareddata/AceBox.xccheckout
tools/AceBox/AceBox.xcodeproj/project.xcworkspace/xcuserdata/Ace.xcuserdatad/UserInterfaceState.xcuserstate
tools/AceBox/AceBox/Base.lproj/Main.storyboard

index 10df6a8eff5580f7fe5907f9e6c766410c380742..7db9b3fa6fcf3f6c9ec63c98460c23d85e98e8b5 100644 (file)
@@ -1,12 +1,25 @@
+#include <SoftwareSerial.h>
+SoftwareSerial BTSerial(10, 11); // RX | TX
+
+
 int cnt = 0;
 const int ledPin = 12;
 
 void setup() {
-  Serial.begin(9600);
+  //Serial.begin(9600);
+  BTSerial.begin(9600);  // HC-06 current bound rate (default 9600)
   pinMode(ledPin, OUTPUT);
   pinMode(0, INPUT);
   pinMode(1, INPUT);
   pinMode(2, INPUT);
+  pinMode(3, INPUT);
+}
+
+char* itos(int n)
+{
+    static char buf[16];
+    sprintf(buf, "%d", n);
+    return buf;
 }
 
 void loop() {
@@ -18,21 +31,25 @@ void loop() {
   
   int hb = analogRead(2);  // Human Body 
   
+  int hv = analogRead(3);  // humidity
+  
   if(hb < 100)
   {
     hb = 0;
   }
   
   digitalWrite(ledPin, hb > 0 ? HIGH : LOW);
-
-  delay(100);
   
-  if(cnt % 10 == 0)
+  
+  delay(10);
+  
+  if(cnt % 100 == 0)
   {
     float temperature;
-    float resistance = (float)(1023-tv)*10000/tv;
+    float resistance = (float)(1023.0-tv)*10000.0/tv;
     temperature = 1.00000/(log(resistance/10000)/3975+1/298.15) - 273.15;
 
+    /*
     Serial.print("Light Sensor Value: ");
     Serial.println(lv);
   
@@ -41,14 +58,28 @@ void loop() {
     
     Serial.print("Body: ");
     Serial.println(hb);
-    
+    */
+    /*
     Serial.print(">");
     Serial.print(lv);
     Serial.print(":");
     Serial.print(temperature);
     Serial.print(":");
     Serial.print(hb);
-    Serial.println(" ");
+    Serial.print(":");
+    Serial.print(hv);
+    Serial.println(" ");*/
+    
+    BTSerial.write(">");
+    BTSerial.write(itos(lv));
+    BTSerial.write(":");
+    BTSerial.write(itos(temperature));
+    BTSerial.write(":");
+    BTSerial.write(itos(hb));
+    BTSerial.write(":");
+    BTSerial.write(itos(hv));
+    BTSerial.write("\n");
+
   }
 }
 
diff --git a/arduino/bluetoothinit/bluetoothinit.ino b/arduino/bluetoothinit/bluetoothinit.ino
new file mode 100644 (file)
index 0000000..31d492d
--- /dev/null
@@ -0,0 +1,17 @@
+#include <SoftwareSerial.h>
+SoftwareSerial BTSerial(10, 11); // RX | TX
+void setup()
+{
+  Serial.begin(9600);
+  Serial.println("Enter AT commands:");
+  BTSerial.begin(9600);  // HC-06 current bound rate (default 9600)
+}
+void loop()
+{
+  // Keep reading from HC-06 and send to Arduino Serial Monitor
+  if (BTSerial.available())
+    Serial.write(BTSerial.read());
+  // Keep reading from Arduino Serial Monitor and send to HC-06
+  if (Serial.available())
+    BTSerial.write(Serial.read());
+}
diff --git a/learn/doc/mac b/learn/doc/mac
new file mode 100644 (file)
index 0000000..78854b3
--- /dev/null
@@ -0,0 +1,13 @@
+iterm2
+
+curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh
+
+git clone git://github.com/supermarin/powerline-fonts.git
+安装 Monaco fo Powerline.otf
+
+iterm2 设置字体为以上
+
+
+
+git clone git://github.com/jeremyFreeAgent/oh-my-zsh-powerline-theme
+cp oh-my-zsh-powerline-theme/powerline.zsh-them ~/.oh-my-zsh/theme/
diff --git a/learn/test/socket.performance/.c.txt.swp b/learn/test/socket.performance/.c.txt.swp
new file mode 100644 (file)
index 0000000..fb154d8
Binary files /dev/null and b/learn/test/socket.performance/.c.txt.swp differ
diff --git a/learn/test/socket.performance/shell.c b/learn/test/socket.performance/shell.c
new file mode 100644 (file)
index 0000000..2b41fcd
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * ------------------------------------------------------------------------
+ *   File Name: shell.c
+ *      Author: Zhao Yanbai
+ *              Fri Apr 10 11:14:22 2015
+ * Description: none
+ * ------------------------------------------------------------------------
+ */
+#include<unistd.h>
+#include<stdio.h>
+#include<stdlib.h>
+#include<sys/types.h>
+#include<sys/socket.h>
+#include<arpa/inet.h>
+#include<netinet/in.h>
+
+
+#define PORT 6666
+
+void do_child(int fd)
+{
+    printf("new connection: %d\n", fd);
+
+    close(STDIN_FILENO);
+    dup(fd);
+
+    close(STDOUT_FILENO);
+    dup(fd);
+
+    close(STDERR_FILENO);
+    dup(fd);
+
+
+    execvp("/bin/bash", 0);
+}
+
+int main()
+{
+       int sock;
+       struct sockaddr_in serv;
+
+       sock = socket(AF_INET, SOCK_STREAM, 0);
+       if(sock == -1)
+       {
+               perror("socket failed");
+               exit(1);
+       }
+
+
+       int flags;
+       setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &flags, sizeof(flags));
+
+
+       serv.sin_family             = AF_INET;
+       serv.sin_addr.s_addr    = htonl(INADDR_ANY);
+       serv.sin_port               = htons(PORT);
+       if(bind(sock, (struct sockaddr*)&serv, sizeof(serv)) == -1)
+       {
+               perror("bind failed");
+               exit(1);
+       }
+
+
+       if(listen(sock, SOMAXCONN) == -1)
+       {
+               perror("listen failed");
+               exit(1);
+       }
+
+
+       while(1)
+       {
+        int nfd;
+        struct sockaddr_in client;
+        socklen_t len = sizeof(client);
+               nfd = accept(sock, (struct sockaddr *)&client, &len);
+
+        pid_t pid = fork();
+
+               if(pid ==0)
+               {
+            do_child(nfd);
+            exit(0);
+               }
+       }
+
+       close(sock);
+
+       return 0;
+}
index e25c09b5ad691ba00ec39f5c7ff641b0fb364da6..6ff7f1596d4448a3a1d49e1c25fafb8ee1c4e855 100644 (file)
Binary files a/tools/AceBox/.DS_Store and b/tools/AceBox/.DS_Store differ
index 97be529d451f8b9f4b1d8bbf4ad19a19fa7effc2..7a2852c511ac6af53e7e668e4470779fd7ddfd43 100644 (file)
@@ -7,21 +7,21 @@
        <key>IDESourceControlProjectIdentifier</key>
        <string>A1372EDB-125D-4A73-9AE8-955FA3D42EAE</string>
        <key>IDESourceControlProjectName</key>
-       <string>project</string>
+       <string>AceBox</string>
        <key>IDESourceControlProjectOriginsDictionary</key>
        <dict>
                <key>BA634633803B1A00DDD2BCDEF5C645E5844F56E6</key>
-               <string>https://github.com/acevest/acecode.git</string>
+               <string>https://github.com/acevest/acecode</string>
        </dict>
        <key>IDESourceControlProjectPath</key>
-       <string>tools/AceBox/AceBox.xcodeproj/project.xcworkspace</string>
+       <string>tools/AceBox/AceBox.xcodeproj</string>
        <key>IDESourceControlProjectRelativeInstallPathDictionary</key>
        <dict>
                <key>BA634633803B1A00DDD2BCDEF5C645E5844F56E6</key>
                <string>../../../..</string>
        </dict>
        <key>IDESourceControlProjectURL</key>
-       <string>https://github.com/acevest/acecode.git</string>
+       <string>https://github.com/acevest/acecode</string>
        <key>IDESourceControlProjectVersion</key>
        <integer>111</integer>
        <key>IDESourceControlProjectWCCIdentifier</key>
index fe879128f2a9d8600de614d95e47d100b789efda..286c512b084157538a616842133886ef4f729910 100644 (file)
Binary files a/tools/AceBox/AceBox.xcodeproj/project.xcworkspace/xcuserdata/Ace.xcuserdatad/UserInterfaceState.xcuserstate and b/tools/AceBox/AceBox.xcodeproj/project.xcworkspace/xcuserdata/Ace.xcuserdatad/UserInterfaceState.xcuserstate differ
index 64f32e18efc16c0ef68c275f92d0dd0ebb55b228..8f5b4fa3b3cda05c9a3da539b796a47a13826689 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7702" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="49e-Tb-3d3">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7531" systemVersion="14D131" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="49e-Tb-3d3">
     <dependencies>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7701"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7520"/>
     </dependencies>
     <scenes>
         <!--First-->
                                 <rect key="frame" x="221" y="255" width="158" height="42"/>
                                 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
                                 <fontDescription key="fontDescription" name="Helvetica" family="Helvetica" pointSize="36"/>
-                                <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
+                                <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
                                 <nil key="highlightedColor"/>
                             </label>
                             <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Loaded by FirstViewController" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="A5M-7J-77L">
                                 <rect key="frame" x="203" y="305" width="195" height="17"/>
                                 <fontDescription key="fontDescription" type="system" pointSize="14"/>
-                                <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
+                                <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
                                 <nil key="highlightedColor"/>
                             </label>
-                            <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="kPh-8P-NAv">
-                                <rect key="frame" x="276" y="124" width="51" height="31"/>
-                            </switch>
                         </subviews>
                         <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
                         <constraints>
                                 <rect key="frame" x="195" y="255" width="210" height="42"/>
                                 <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                                 <fontDescription key="fontDescription" name="Helvetica" family="Helvetica" pointSize="36"/>
-                                <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
+                                <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
                                 <nil key="highlightedColor"/>
                             </label>
                             <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Loaded by SecondViewController" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="NDk-cv-Gan">
                                 <rect key="frame" x="192" y="305" width="216" height="17"/>
                                 <fontDescription key="fontDescription" type="system" pointSize="14"/>
-                                <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
+                                <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
                                 <nil key="highlightedColor"/>
                             </label>
                         </subviews>
@@ -91,7 +88,7 @@
         <scene sceneID="yl2-sM-qoP">
             <objects>
                 <tabBarController id="49e-Tb-3d3" sceneMemberID="viewController">
-                    <simulatedTabBarMetrics key="simulatedBottomBarMetrics" barStyle="black" translucent="NO"/>
+                    <nil key="simulatedBottomBarMetrics"/>
                     <tabBar key="tabBar" contentMode="scaleToFill" barStyle="black" translucent="NO" id="W28-zg-YXA">
                         <rect key="frame" x="0.0" y="975" width="768" height="49"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
                     <connections>
                         <segue destination="9pv-A4-QxB" kind="relationship" relationship="viewControllers" id="u7Y-xg-7CH"/>
                         <segue destination="8rJ-Kc-sve" kind="relationship" relationship="viewControllers" id="lzU-1b-eKA"/>
-                        <segue destination="p9b-Qi-Lhq" kind="relationship" relationship="viewControllers" id="eXb-lL-tDf"/>
                     </connections>
                 </tabBarController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="HuB-VB-40B" sceneMemberID="firstResponder"/>
             </objects>
             <point key="canvasLocation" x="0.0" y="0.0"/>
         </scene>
-        <!--Ace-->
-        <scene sceneID="0IU-Ji-ziU">
-            <objects>
-                <viewController title="Ace" id="p9b-Qi-Lhq" sceneMemberID="viewController">
-                    <layoutGuides>
-                        <viewControllerLayoutGuide type="top" id="tly-kp-32T"/>
-                        <viewControllerLayoutGuide type="bottom" id="jJj-ux-K3J"/>
-                    </layoutGuides>
-                    <view key="view" contentMode="scaleToFill" id="Hyy-kK-vzY">
-                        <rect key="frame" x="0.0" y="0.0" width="600" height="551"/>
-                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                        <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
-                    </view>
-                    <tabBarItem key="tabBarItem" title="Item" id="efr-HS-JSW"/>
-                </viewController>
-                <placeholder placeholderIdentifier="IBFirstResponder" id="7b0-pZ-bj7" userLabel="First Responder" sceneMemberID="firstResponder"/>
-            </objects>
-            <point key="canvasLocation" x="209" y="706"/>
-        </scene>
     </scenes>
     <resources>
         <image name="first" width="30" height="30"/>