]> Zhao Yanbai Git Server - acecode.git/commitdiff
...
authorAceVest <zhaoyanbai@126.com>
Wed, 10 Jan 2018 16:19:26 +0000 (00:19 +0800)
committerAceVest <zhaoyanbai@126.com>
Wed, 10 Jan 2018 16:19:26 +0000 (00:19 +0800)
12 files changed:
arduino/clockintr/clockintr.ino [new file with mode: 0644]
arduino/ir/irrecv/irrecv.ino [new file with mode: 0644]
arduino/ir/irsend/irsend.ino [new file with mode: 0644]
documents/ArduinoClockInterrupt.md [new file with mode: 0644]
documents/遥控红外线编码.md [new file with mode: 0644]
tools/AceBox/AceBox.xcodeproj/project.pbxproj
tools/AceBox/AceBox.xcodeproj/project.xcworkspace/xcuserdata/Ace.xcuserdatad/UserInterfaceState.xcuserstate
tools/AceBox/AceBox/AppDelegate.swift
tools/AceBox/AceBox/Base.lproj/LaunchScreen.xib
tools/AceBox/AceBox/Base.lproj/Main.storyboard
tools/AceBox/AceBox/Info.plist
tools/AceBox/AceBox/SecondViewController.swift

diff --git a/arduino/clockintr/clockintr.ino b/arduino/clockintr/clockintr.ino
new file mode 100644 (file)
index 0000000..25f0363
--- /dev/null
@@ -0,0 +1,96 @@
+
+int led0 = 7;
+int led1 = 8;
+int led2 = 12;
+int cnt0 = 0;
+int cnt1 = 0;
+int cnt2 = 0;
+void setup(){
+  Serial.begin(9600);
+  pinMode(LED_BUILTIN, OUTPUT);
+  pinMode(led0, OUTPUT);
+  pinMode(led1, OUTPUT);
+  pinMode(led2, OUTPUT);
+
+  cli();//stop interrupts
+
+#if 0     // 设置timer0会影响到loop函数里调用的delay,会使其失效
+  //set timer0 interrupt at 2kHz
+  TCCR0A = 0;// set entire TCCR0A register to 0
+  TCCR0B = 0;// same for TCCR0B
+  TCNT0  = 0;//initialize counter value to 0
+  // set compare match register for 2khz increments
+  OCR0A = 124;// = (16*10^6) / (2000*64) - 1 (must be <256)
+  // turn on CTC mode
+  TCCR0A |= (1 << WGM01);
+  // Set CS01 and CS00 bits for 64 prescaler (参考上表)
+  TCCR0B |= (1 << CS01) | (1 << CS00);   
+  // enable timer compare interrupt
+  TIMSK0 |= (1 << OCIE0A);
+#endif
+
+#if 1
+  //set timer1 interrupt at 1Hz
+  TCCR1A = 0;// set entire TCCR1A register to 0
+  TCCR1B = 0;// same for TCCR1B
+  TCNT1  = 0;//initialize counter value to 0
+  // set compare match register for 1hz increments
+  OCR1A = 15624;// = (16*10^6) / (1*1024) - 1 (must be <65536)
+  // turn on CTC mode
+  TCCR1B |= (1 << WGM12);
+  // Set CS10 and CS12 bits for 1024 prescaler (参考上表)
+  TCCR1B |= (1 << CS12) | (1 << CS10);  
+  // enable timer compare interrupt
+  TIMSK1 |= (1 << OCIE1A);
+#endif
+
+#if 1
+  //set timer2 interrupt at 8kHz
+  TCCR2A = 0;// set entire TCCR2A register to 0
+  TCCR2B = 0;// same for TCCR2B
+  TCNT2  = 0;//initialize counter value to 0
+  // set compare match register for 8khz increments
+  OCR2A = 249;// = (16*10^6) / (8000*8) - 1 (must be <256)
+  // turn on CTC mode
+  TCCR2A |= (1 << WGM21);
+  // Set CS21 bit for 8 prescaler (参考上表)
+  TCCR2B |= (1 << CS21);   
+  // enable timer compare interrupt
+  TIMSK2 |= (1 << OCIE2A);
+#endif
+
+  sei();//allow interrupts
+
+}//end setup
+
+void loop() {
+  Serial.println("High");
+  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
+  delay(1000);                       // wait for a second
+  
+  Serial.println("Low");
+  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
+  delay(1000);                       // wait for a second
+}
+
+ISR(TIMER0_COMPA_vect){
+  cnt0++;
+  if(cnt0 % 1000 == 0) {
+    cnt0 == 0;
+    digitalWrite(led0, !digitalRead(led0));
+  }
+}
+
+ISR(TIMER1_COMPA_vect){
+  cnt1++;
+  digitalWrite(led1, !digitalRead(led1));
+}
+
+ISR(TIMER2_COMPA_vect) {
+  cnt2++;
+  if(cnt2 % 1000 == 0) {
+    cnt2 = 0;
+    digitalWrite(led2, !digitalRead(led2));
+  }
+}
+
diff --git a/arduino/ir/irrecv/irrecv.ino b/arduino/ir/irrecv/irrecv.ino
new file mode 100644 (file)
index 0000000..445838d
--- /dev/null
@@ -0,0 +1,179 @@
+//------------------------------------------------------------------------------
+// Include the IRremote library header
+//
+#include <IRremote.h>
+
+// HX1838(用金属包住头) 面对HX1838正面从左至右三个脚分别为 OUT、GND、VCC
+
+//------------------------------------------------------------------------------
+// Tell IRremote which Arduino pin is connected to the IR Receiver (TSOP4838)
+//
+int recvPin = 11;
+IRrecv irrecv(recvPin);
+
+//+=============================================================================
+// Configure the Arduino
+//
+void  setup ( )
+{
+  Serial.begin(9600);   // Status message will be sent to PC at 9600 baud
+  irrecv.enableIRIn();  // Start the receiver
+}
+
+//+=============================================================================
+// Display IR code
+//
+void  ircode (decode_results *results)
+{
+  // Panasonic has an Address
+  if (results->decode_type == PANASONIC) {
+    Serial.print(results->address, HEX);
+    Serial.print(":");
+  }
+
+  // Print Code
+  Serial.print(results->value, HEX);
+}
+
+//+=============================================================================
+// Display encoding type
+//
+void  encoding (decode_results *results)
+{
+  switch (results->decode_type) {
+    default:
+    case UNKNOWN:      Serial.print("UNKNOWN");       break ;
+    case NEC:          Serial.print("NEC");           break ;
+    case SONY:         Serial.print("SONY");          break ;
+    case RC5:          Serial.print("RC5");           break ;
+    case RC6:          Serial.print("RC6");           break ;
+    case DISH:         Serial.print("DISH");          break ;
+    case SHARP:        Serial.print("SHARP");         break ;
+    case JVC:          Serial.print("JVC");           break ;
+    case SANYO:        Serial.print("SANYO");         break ;
+    case MITSUBISHI:   Serial.print("MITSUBISHI");    break ;
+    case SAMSUNG:      Serial.print("SAMSUNG");       break ;
+    case LG:           Serial.print("LG");            break ;
+    case WHYNTER:      Serial.print("WHYNTER");       break ;
+    case AIWA_RC_T501: Serial.print("AIWA_RC_T501");  break ;
+    case PANASONIC:    Serial.print("PANASONIC");     break ;
+    case DENON:        Serial.print("Denon");         break ;
+  }
+}
+
+//+=============================================================================
+// Dump out the decode_results structure.
+//
+void  dumpInfo (decode_results *results)
+{
+  // Check if the buffer overflowed
+  if (results->overflow) {
+    Serial.println("IR code too long. Edit IRremoteInt.h and increase RAWBUF");
+    return;
+  }
+
+  // Show Encoding standard
+  Serial.print("Encoding  : ");
+  encoding(results);
+  Serial.println("");
+
+  // Show Code & length
+  Serial.print("Code      : ");
+  ircode(results);
+  Serial.print(" (");
+  Serial.print(results->bits, DEC);
+  Serial.println(" bits)");
+}
+
+//+=============================================================================
+// Dump out the decode_results structure.
+//
+void  dumpRaw (decode_results *results)
+{
+  // Print Raw data
+  Serial.print("Timing[");
+  Serial.print(results->rawlen-1, DEC);
+  Serial.println("]: ");
+
+  for (int i = 1;  i < results->rawlen;  i++) {
+    unsigned long  x = results->rawbuf[i] * USECPERTICK;
+    if (!(i & 1)) {  // even
+      Serial.print("-");
+      if (x < 1000)  Serial.print(" ") ;
+      if (x < 100)   Serial.print(" ") ;
+      Serial.print(x, DEC);
+    } else {  // odd
+      Serial.print("     ");
+      Serial.print("+");
+      if (x < 1000)  Serial.print(" ") ;
+      if (x < 100)   Serial.print(" ") ;
+      Serial.print(x, DEC);
+      if (i < results->rawlen-1) Serial.print(", "); //',' not needed for last one
+    }
+    if (!(i % 8))  Serial.println("");
+  }
+  Serial.println("");                    // Newline
+}
+
+//+=============================================================================
+// Dump out the decode_results structure.
+//
+void  dumpCode (decode_results *results)
+{
+  // Start declaration
+  Serial.print("unsigned int  ");          // variable type
+  Serial.print("rawData[");                // array name
+  Serial.print(results->rawlen - 1, DEC);  // array size
+  Serial.print("] = {");                   // Start declaration
+
+  // Dump data
+  for (int i = 1;  i < results->rawlen;  i++) {
+    Serial.print(results->rawbuf[i] * USECPERTICK, DEC);
+    if ( i < results->rawlen-1 ) Serial.print(","); // ',' not needed on last one
+    if (!(i & 1))  Serial.print(" ");
+  }
+
+  // End declaration
+  Serial.print("};");  // 
+
+  // Comment
+  Serial.print("  // ");
+  encoding(results);
+  Serial.print(" ");
+  ircode(results);
+
+  // Newline
+  Serial.println("");
+
+  // Now dump "known" codes
+  if (results->decode_type != UNKNOWN) {
+
+    // Some protocols have an address
+    if (results->decode_type == PANASONIC) {
+      Serial.print("unsigned int  addr = 0x");
+      Serial.print(results->address, HEX);
+      Serial.println(";");
+    }
+
+    // All protocols have data
+    Serial.print("unsigned int  data = 0x");
+    Serial.print(results->value, HEX);
+    Serial.println(";");
+  }
+}
+
+//+=============================================================================
+// The repeating section of the code
+//
+void  loop ( )
+{
+  decode_results  results;        // Somewhere to store the results
+
+  if (irrecv.decode(&results)) {  // Grab an IR code
+    dumpInfo(&results);           // Output the results
+    dumpRaw(&results);            // Output the results in RAW format
+    dumpCode(&results);           // Output the results as source code
+    Serial.println("");           // Blank line between entries
+    irrecv.resume();              // Prepare for the next value
+  }
+}
diff --git a/arduino/ir/irsend/irsend.ino b/arduino/ir/irsend/irsend.ino
new file mode 100644 (file)
index 0000000..c30aac6
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * IRremote: IRsendDemo - demonstrates sending IR codes with IRsend
+ * An IR LED must be connected to Arduino PWM pin 3.
+ * Version 0.1 July, 2009
+ * Copyright 2009 Ken Shirriff
+ * http://arcfn.com
+ */
+
+
+// arduino ~3号引脚接940纳米发送头的长引脚
+// 短引脚接100欧电阻,再接GND
+
+#include <IRremote.h>
+
+IRsend irsend;
+
+void setup()
+{
+  Serial.begin(9600);
+}
+
+void loop() {
+
+  // 电信机顶盒用NEC发送
+  
+       irsend.sendNEC(0xCD3201FE, 32); // 音量+
+  Serial.println("+");
+       delay(1000);
+       irsend.sendNEC(0xCD32817E, 32); // 音量-
+  Serial.println("-");
+  delay(1000);
+
+
+  // 小米电视遥控
+  int khz = 38; // 38kHz carrier frequency for the NEC protocol
+  // xiaomi increase volume signal
+  unsigned int ivs[] = {1000,600, 550,1150, 600,600, 550,900, 550,1150, 600,550, 600,600, 550,1450, 550,1200, 550,600, 550,600, 550};
+  // xiaomi decrease volume signal
+  unsigned int dvs[] = {1050,550, 650,1050, 650,500, 650,800, 650,1100, 650,500, 650,500, 650,1400, 650,1350, 650,500, 650,800, 650};
+  irsend.sendRaw(ivs, sizeof(ivs) / sizeof(ivs[0]), khz);
+  Serial.println("tv+");
+  delay(1000); 
+  irsend.sendRaw(dvs, sizeof(dvs) / sizeof(dvs[0]), khz); 
+  Serial.println("tv-");
+  delay(1000); 
+}
diff --git a/documents/ArduinoClockInterrupt.md b/documents/ArduinoClockInterrupt.md
new file mode 100644 (file)
index 0000000..b89fe99
--- /dev/null
@@ -0,0 +1,126 @@
+# arduino clock interrupt
+
+## Clock Select Bit Description
+
+
+|CS02|CS01|CS00|Description|
+|---|---|---|---|
+|0|0|0|no clock source (Timer/Counter stopped)|
+|0|0|1|clk/1 (no prescaler)|
+|0|1|0|clk/8 (from prescaler)|
+|0|1|1|clk/64 (from prescaler)|
+|1|0|0|clk/256 (from prescaler)|
+|1|0|1|clk/1024 (from prescaler)|
+|1|1|0|external clock source on T0 pin. clock falling edge|
+|1|1|1|external clock source on T0 pin. clock rising edge|
+
+
+
+|CS12|CS11|CS10|Description|
+|---|---|---|---|
+|0|0|0|no clock source (Timer/Counter stopped)|
+|0|0|1|clk/1 (no prescaler)|
+|0|1|0|clk/8 (from prescaler)|
+|0|1|1|clk/64 (from prescaler)|
+|1|0|0|clk/256 (from prescaler)|
+|1|0|1|clk/1024 (from prescaler)|
+|1|1|0|external clock source on T1 pin. clock falling edge|
+|1|1|1|external clock source on T1 pin. clock rising edge|
+
+
+|CS22|CS21|CS20|Description|
+|---|---|---|---|
+|0|0|0|no clock source (Timer/Counter stopped)|
+|0|0|1|clk<sub>T2S</sub>/1 (no prescaler)|
+|0|1|0|clk<sub>T2S</sub>/8 (from prescaler)|
+|0|1|1|clk<sub>T2S</sub>/64 (from prescaler)|
+
+## Compare Match Register计算方法
+
+arduino有三个时钟计数器:Timer0、Timer1、Timer2。
+
+arduino的时钟频率是16MHz,所以每个嘀嗒(tick)代表1/16000000秒(约为63ns)。而arduino的Timer0、Timer2的时钟计数器是8位、Timer1是16位。因此这就意味着就算把值设置成最大的,对于8位的将以256/1600000(约16us),对于16位将以65536/16000000(约4ms)的频率触发。因此如果想让它频率变得更低一点,比如一秒触发一次就有点不现实。
+
+除非可以利用预分频器(prescaler)来控制时钟计数器的增加方式:
+
+`(时钟计数频率(Hz)) = 16MHz / prescaler`
+
+所以当prescaler=1,时钟计数频率=16MHz;当prescaler=64,时钟计数频率=250KHz。
+
+如上表所述,prescaler只能在1, 8, 64, 256, 1024中取值。
+
+所以:
+
+`(计数器触发频率(Hz)) = 16MHz / ( prescaler*(CompareMatchRegister+1) )`
+
+变换一下上式:
+
+`CompareMatchRegister = 16MHz / ( prescaler*(计数器触发频率(Hz)) ) - 1`
+
+**注意:Timer0、Timer1的CompareMatchRegister必需小于256;Timer1的CompareMatchRegister必需小于65536**
+
+所以如果想要1Hz的触发频率,则`CompareMatchRegister = 16MHz / ( 1024*1) - 1 = 15624`,这里的prescaler=1024,因为prescaler取到最大值了CompareMatchRegister还等于15624,256<15624<65536,所以必需要用到Timer1。
+
+
+## 示例代码
+
+```
+void setup(){
+
+  cli();//stop interrupts
+
+  //设置timer0会影响到loop函数里调用的delay,会使其失效
+  //set timer0 interrupt at 2kHz
+  TCCR0A = 0;// set entire TCCR0A register to 0
+  TCCR0B = 0;// same for TCCR0B
+  TCNT0  = 0;//initialize counter value to 0
+  // set compare match register for 2khz increments
+  OCR0A = 124;// = (16*10^6) / (2000*64) - 1 (must be <256)
+  // turn on CTC mode
+  TCCR0A |= (1 << WGM01);
+  // Set CS01 and CS00 bits for 64 prescaler (参考上表)
+  TCCR0B |= (1 << CS01) | (1 << CS00);   
+  // enable timer compare interrupt
+  TIMSK0 |= (1 << OCIE0A);
+
+  //set timer1 interrupt at 1Hz
+  TCCR1A = 0;// set entire TCCR1A register to 0
+  TCCR1B = 0;// same for TCCR1B
+  TCNT1  = 0;//initialize counter value to 0
+  // set compare match register for 1hz increments
+  OCR1A = 15624;// = (16*10^6) / (1*1024) - 1 (must be <65536)
+  // turn on CTC mode
+  TCCR1B |= (1 << WGM12);
+  // Set CS10 and CS12 bits for 1024 prescaler (参考上表)
+  TCCR1B |= (1 << CS12) | (1 << CS10);  
+  // enable timer compare interrupt
+  TIMSK1 |= (1 << OCIE1A);
+
+  //set timer2 interrupt at 8kHz
+  TCCR2A = 0;// set entire TCCR2A register to 0
+  TCCR2B = 0;// same for TCCR2B
+  TCNT2  = 0;//initialize counter value to 0
+  // set compare match register for 8khz increments
+  OCR2A = 249;// = (16*10^6) / (8000*8) - 1 (must be <256)
+  // turn on CTC mode
+  TCCR2A |= (1 << WGM21);
+  // Set CS21 bit for 8 prescaler (参考上表)
+  TCCR2B |= (1 << CS21);   
+  // enable timer compare interrupt
+  TIMSK2 |= (1 << OCIE2A);
+
+  sei();//allow interrupts
+
+}//end setup
+
+void loop() { }
+
+ISR(TIMER0_COMPA_vect){ /* TODO */ }
+ISR(TIMER1_COMPA_vect){ /* TODO */ }
+ISR(TIMER2_COMPA_vect){ /* TODO */ }
+```
+
+
+
+## 注
+1. 1MHz = 1 * 1000KHz = 1 * 1000 * 1000Hz,这里是1000不是1024
\ No newline at end of file
diff --git a/documents/遥控红外线编码.md b/documents/遥控红外线编码.md
new file mode 100644 (file)
index 0000000..54d8db4
--- /dev/null
@@ -0,0 +1,45 @@
+
+## 1. 电信机顶盒遥控编码
+||格式|编码|
+|---|---|---|
+|电源|NEC|`CD328F70`|
+|待机|NEC|`CD323BC4`|
+|频道+|NEC|`CD32A15E`|
+|频道-|NEC|`CD32619E`|
+|音量+|NEC|`CD3201FE`|
+|音量-|NEC|`CD32817E`|
+|返回|NEC|`CD32A35C`|
+|确定|NEC|`CD32738C`|
+|上|NEC|`CD3253AC`|
+|下|NEC|`CD324BB4`|
+|左|NEC|`CD329966`|
+|右|NEC|`CD32837C`|
+|上页|NEC|`CD32BB44`|
+|下页|NEC|`CD3231CE`|
+|0|NEC|`CD32E11E`|
+|1|NEC|`CD3249B6`|
+|2|NEC|`CD32C936`|
+|3|NEC|`CD3233CC`|
+|4|NEC|`CD32718E`|
+|5|NEC|`CD32F10E`|
+|6|NEC|`CD3213EC`|
+|7|NEC|`CD3251AE`|
+|8|NEC|`CD32D12E`|
+|9|NEC|`CD3223DC`|
+
+
+## 2. 小米电视遥控编码
+
+||格式|编码|RawData|
+|---|---|---|---|
+|电源|UNKNOWN|`5E7DB3DC`|`{1100,500, 650,500, 650,1400, 650,1350, 650,500, 650,1400, 650,500, 650,1350, 650,550, 650,1350, 650,1350, 650}`|
+|上|UNKNOWN|`3F9089B2`|`{1100,500, 600,1150, 650,500, 600,850, 650,1050, 650,550, 650,500, 650,800, 650,800, 650,1050, 650,1400, 650}`|
+|下|UNKNOWN|`B23FB1E9`|`{1050,550, 600,1150, 600,550, 600,850, 650,1050, 650,550, 600,550, 600,850, 650,1050, 650,1100, 650,500, 650}`|
+|左|UNKNOWN|`8753BA5C`|`{1000,600, 600,1150, 550,600, 550,900, 550,1200, 550,600, 550,600, 550,1200, 550,1450, 550,900, 550,900, 550}`|
+|右|UNKNOWN|`69893291`|`{1000,600, 550,1200, 550,600, 550,900, 550,1150, 600,600, 550,600, 550,1450, 550,600, 600,600, 550,1150, 550}`|
+|确定|UNKNOWN|`76A77416`|`{1000,600, 550,1200, 550,600, 550,900, 550,1150, 600,600, 550,600, 550,1450, 550,900, 550,600, 550,1500, 550}`|
+|HOME|UNKNOWN|`F874E0F8`|`{1000,600, 550,1200, 550,600, 550,900, 550,1150, 600,600, 550,600, 550,1150, 600,600, 550,900, 550,1150, 550}`|
+|返回|UNKNOWN|`DE3AA631`|`{950,650, 500,1200, 550,650, 550,850, 550,1250, 500,650, 450,650, 550,900, 550,1500, 500,1250, 500,900, 550}`|
+|MENU|UNKNOWN|`F574DC41`|`{1000,600, 550,1200, 550,600, 550,900, 550,1200, 550,600, 550,600, 550,900, 550,600, 550,1200, 550,1150, 600}`|
+|音量+|UNKNOWN|`8753BA5C`|`{1000,600, 550,1150, 600,600, 550,900, 550,1150, 600,550, 600,600, 550,1450, 550,1200, 550,600, 550,600, 550}`|
+|音量-|UNKNOWN|`8453B5A5`|`{1050,550, 650,1050, 650,500, 650,800, 650,1100, 650,500, 650,500, 650,1400, 650,1350, 650,500, 650,800, 650}`|
index 617ae793b5370805194e6e546a9099315b1aab43..c4d9a97b9a2174e2b1c354703a4b1a8f750b8924 100644 (file)
                                        50A4F2741AF2154100DB7E36 = {
                                                CreatedOnToolsVersion = 6.3.1;
                                                DevelopmentTeam = VR7L9Q5L2E;
+                                               ProvisioningStyle = Automatic;
+                                               SystemCapabilities = {
+                                                       com.apple.BackgroundModes = {
+                                                               enabled = 1;
+                                                       };
+                                               };
                                        };
                                };
                        };
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+                               "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+                               CODE_SIGN_STYLE = Automatic;
                                DEVELOPMENT_TEAM = VR7L9Q5L2E;
                                INFOPLIST_FILE = AceBox/Info.plist;
                                IPHONEOS_DEPLOYMENT_TARGET = 8.2;
                                LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
                                PRODUCT_BUNDLE_IDENTIFIER = com.tencent.voip.ace;
                                PRODUCT_NAME = Ace;
+                               PROVISIONING_PROFILE_SPECIFIER = "";
                        };
                        name = Debug;
                };
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+                               "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+                               CODE_SIGN_STYLE = Automatic;
                                DEVELOPMENT_TEAM = VR7L9Q5L2E;
                                INFOPLIST_FILE = AceBox/Info.plist;
                                IPHONEOS_DEPLOYMENT_TARGET = 8.2;
                                LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
                                PRODUCT_BUNDLE_IDENTIFIER = com.tencent.voip.ace;
                                PRODUCT_NAME = Ace;
+                               PROVISIONING_PROFILE_SPECIFIER = "";
                        };
                        name = Release;
                };
index edc0110c060f8efbf370b3abd9159bf40d9d7d34..b20ba3ce735579d526b617186c3cd8eef8ea94ee 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 5cf83f748caa1f475df8bc1157699a0fe3d4e7be..469c173910ed0264949d1e83e3fa5537713d13c8 100644 (file)
@@ -14,30 +14,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
     var window: UIWindow?
 
 
-    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
+    private func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
         // Override point for customization after application launch.
         return true
     }
 
-    func applicationWillResignActive(application: UIApplication) {
+    func applicationWillResignActive(application: UIApplication) {
         // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
         // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
     }
 
-    func applicationDidEnterBackground(application: UIApplication) {
+    func applicationDidEnterBackground(application: UIApplication) {
         // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
         // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
     }
 
-    func applicationWillEnterForeground(application: UIApplication) {
+    func applicationWillEnterForeground(application: UIApplication) {
         // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
     }
 
-    func applicationDidBecomeActive(application: UIApplication) {
+    func applicationDidBecomeActive(application: UIApplication) {
         // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
     }
 
-    func applicationWillTerminate(application: UIApplication) {
+    func applicationWillTerminate(application: UIApplication) {
         // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
     }
 
index 816612e0b5bd2e923e5405c86e2cca238158772b..6e8050476d2d1a7f947701518f2b2713e7a60f9e 100644 (file)
@@ -1,10 +1,19 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES">
+    <device id="retina4_7" orientation="portrait">
+        <adaptation id="fullscreen"/>
+    </device>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/>
         <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
+    <customFonts key="customFonts">
+        <array key="HelveticaNeue.ttc">
+            <string>HelveticaNeue</string>
+        </array>
+    </customFonts>
     <objects>
         <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
         <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
                 <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="  Copyright (c) 2016 Ace. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
                     <rect key="frame" x="20" y="439" width="441" height="21"/>
                     <fontDescription key="fontDescription" type="system" pointSize="17"/>
-                    <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                    <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                     <nil key="highlightedColor"/>
                 </label>
                 <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="AceBox" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
                     <rect key="frame" x="20" y="140" width="441" height="43"/>
                     <fontDescription key="fontDescription" type="system" pointSize="36"/>
-                    <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                    <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                     <nil key="highlightedColor"/>
                 </label>
                 <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="👻" textAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="sT9-gH-fBt">
                     <rect key="frame" x="182" y="251" width="118" height="114"/>
-                    <color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="calibratedRGB"/>
-                    <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+                    <color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                    <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                     <fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="128"/>
                     <textInputTraits key="textInputTraits"/>
                 </textField>
             </subviews>
-            <color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+            <color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
             <constraints>
                 <constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC"/>
                 <constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk"/>
index cc3204583bd1e2e357d7c590534071d7e7bfe49d..d68453c374919fc4a669d5efdf459685246895f2 100644 (file)
@@ -5,7 +5,7 @@
     </device>
     <dependencies>
         <deployment version="2336" identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13174"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <customFonts key="customFonts">
index 222ac7470b262d568bd8ec2fb0fdfb35d2e86e78..6a070d066a8485700865b1a7578f474bf3c51fc7 100644 (file)
        <string>????</string>
        <key>CFBundleVersion</key>
        <string>1</string>
+       <key>LSApplicationCategoryType</key>
+       <array>
+               <string>en</string>
+       </array>
        <key>LSRequiresIPhoneOS</key>
        <true/>
+       <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
+       <string>需要始终访问你的地理位置</string>
+       <key>NSLocationWhenInUseUsageDescription</key>
+       <string>需要在使用应用时访问你的地理位置</string>
+       <key>UIBackgroundModes</key>
+       <array>
+               <string>location</string>
+       </array>
        <key>UILaunchStoryboardName</key>
        <string>LaunchScreen</string>
        <key>UIMainStoryboardFile</key>
index b403572648a9413f94b26d6abd1f51d9174a6a11..3e2c11bd78ecbf93527ea73e982e470b3af01470 100644 (file)
@@ -7,20 +7,94 @@
 //
 
 import UIKit
+import CoreLocation
 
-class SecondViewController: UIViewController {
+class SecondViewController: UIViewController, CLLocationManagerDelegate {
+    
+    var locationMgr:CLLocationManager!
+    var cnt:Int = 0
+    var labelGPS:UILabel!
 
     override func viewDidLoad() {
         super.viewDidLoad()
         // Do any additional setup after loading the view, typically from a nib.
         //view.backgroundColor = UIColor.blueColor()
         view.backgroundColor = UIColor(red: 0, green: 0.47843137250000001, blue: 1, alpha: 1)
+        
+        locationMgr = CLLocationManager()
+        locationMgr.desiredAccuracy = kCLLocationAccuracyBestForNavigation
+        if #available(iOS 9.0, *) {
+            locationMgr.allowsBackgroundLocationUpdates = true
+        }
+        locationMgr.pausesLocationUpdatesAutomatically = false
+        
+        //locationMgr.distanceFilter = 50
+        
+        locationMgr.requestAlwaysAuthorization()
+        
+        locationMgr.delegate = self
+        
+        if CLLocationManager.locationServicesEnabled() {
+            locationMgr.startUpdatingLocation()
+        } else {
+            print("no location service")
+        }
+        
+        labelGPS = UILabel(frame: CGRect(x: 10, y: 20, width: 300, height: 100))
+        labelGPS.text = "searching"
+        labelGPS.textColor = UIColor.white
+        labelGPS.numberOfLines = 3
+        self.view.addSubview(labelGPS)
     }
 
     override func didReceiveMemoryWarning() {
         super.didReceiveMemoryWarning()
         // Dispose of any resources that can be recreated.
     }
+    
+    
+    func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
+        print(error)
+    }
+    
+    func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
+        if locations.count > 0 {
+            let locationInfo  = locations.last!
+            
+            let msg = "次数:\(cnt)\n经度:\(locationInfo.coordinate.longitude)\n纬度:\(locationInfo.coordinate.latitude)"
+            
+            cnt += 1
+            
+            //let alert:UIAlertView = UIAlertView(title:"Get Location", message:msg, delegate:nil, cancelButtonTitle:"Yes")
+            //alert.show()
+            
+            print(msg)
+            
+            labelGPS.text = msg
+            /*
+            let fileManager = FileManager.default
+            let filePath:String = NSHomeDirectory() + "/Documents/gps.data"
+            let exist = fileManager.fileExists(atPath: filePath)
+            if exist {
+                print("exist \(filePath)")
+                let data = "\(cnt) \(locationInfo.coordinate.longitude) \(locationInfo.coordinate.latitude)\n"
+                //try! data.write(toFile: filePath, atomically: true, encoding: String.Encoding.utf8)
+            
+                let writeHandler = try? FileHandle(forWritingAtPath: filePath)
+                writeHandler!?.seekToEndOfFile()
+                writeHandler!?.write(data.data(using: String.Encoding.utf8, allowLossyConversion: true)!)
+                
+                let rd = fileManager.contents(atPath: filePath)
+                print("content: \(String(data:rd!, encoding: String.Encoding.utf8))")
+            } else {
+                print(NSHomeDirectory())
+                try! fileManager.createDirectory(atPath: NSHomeDirectory()+"/Documents/",
+                                                 withIntermediateDirectories: true, attributes: nil)
+                let createSuccess = fileManager.createFile(atPath: filePath, contents: nil, attributes: nil)
+                print("create file \(filePath) return \(createSuccess)")
+            }*/
+        }
+    }
 
 
 }