This article reprinted to http://mobile.51cto.com/iphone-423219.htm
In the actual application development, will use the sensor, the following first introduce the iphone4 sensor, and then some of the sensor development API for a brief introduction.
AD:2014WOT Global Software Technology Summit Beijing Station course video release
In the actual application development, will use the sensor, the following first introduce the iphone4 sensor, and then a few sensor development API to make a brief introduction
First, the IPhone 4 sensor technology
To get to the point, what kind of sensors does the IPhone 4 use?
1) Image sensor
Simply said is the camera lens, because only the micro-photonics and microelectronics, no mechanical components in the inside, even if the motor, mechanical drive lens, this kind of mechanical parts too large, less than the "micro" point, so this belongs to the photoelectric semiconductor, belongs to optical, photoelectric sensor.
2) Brightness sensor
It's not clear how the iphone 4 senses ambient light, and the simplest way to do this is to use a photoresistors, or the iphone 4 to use an image sensor as a brightness detector. However, this is also not with the mechanical components, belonging to the photoelectric sensor, and may not even miniature, just general optical, photoelectric sensors.
3) magneto-resistive sensor
Simply speaking is the sense of geomagnetic, so or Imperial College name, induction geomagnetic is the compass principle, this geomagnetic induction electronic, digital, is called digital Compass. To be honest, the digital compass technology compared to the toy sex, because to sense the geomagnetic magnetoresistive sensor, very easy to be affected by the environment (such as high-voltage electric tower next to the motor), must always be corrected to use.
Magnetoresistive sensors are not currently considered a popular MEMS component, and some MEMS components will have additional integrated magnetoresistive sensing capabilities (such as Adi's products and target applications for torpedo use), but generally there are no signs of imminent miniaturization of magnetoresistive sensors.
4) Close-up sensor
Proximity sensors can be implemented in a variety of ways, such as infrared (automatic doors for convenience stores, automatic flushing of men's public toilets), ultrasound, lasers, and much more. Similarly, Apple does not say that we can only guess or search the web as much as possible, however, proximity sensors are not urgently needed for miniaturization, not in the list of popular MEMS components.
5) Sonic Sensor
Scientific name acoustic sensor, common name microphone. Yes, IPhone 4 to enhance sound quality, using 2 microphones and related operations to achieve noise reduction (noise reduction) effect, this technology is called array mic, in fact, long before Apple implementation, 2004 Wintel has been put on the PC, The difference is that Apple is used for mobile phones and Wintel for PCs.
Does the microphone need to be miniaturized? Yes, need, quite needed, and with more than one microphone, the volume of the microphone needs to be more urgent, the microphone is also involved in machinery (sound waves will make micro-mechanical vibration), and the mechanical vibration into electronic signals, so the micro-microphone is a no-compromise MEMS sensor.
6) Acceleration Sensor
Commonly known as acceleration regulation, g-sensor, can sense the acceleration of the object. In fact, the accelerometer is implemented in many ways, MEMS is only one of the methods, the use of MEMS accelerometer sensor is indeed the current trend.
Acceleration sensor generally has "x, y two axes" and "x, Y, z three axes" two, two axes more for vehicles, ships and other plane movement for more, three axes more for missiles, aircraft and other flying objects. Without much to say, the Wii Remote is also used three-axis, the iphone can sense the body flip and automatically corresponding to the flip screen, but also rely on this sensor.
7) Angular acceleration sensor
More simply the gyroscope, gyroscope technology has mechanical and optical (infrared, laser) type, the sixth acceleration sensor can sense the translation, but for the object has an axis, the angle of movement, then its induction effect is not as good as the gyroscope, so many applications are mostly mixed with the use of accelerometers and gyroscopes, Now the iphone 4 is also receptive. However, the IPhone 4 is really the first to use a gyroscope phone.
Second, commonly used methods
In our application, there are up to accelerometer, angular accelerometer, these two main applications in the application of gravity sensing, in the public API Uiaccelerometer class to achieve the corresponding function; magnetoresistive sensors are mainly used in applications that require direction, In the public API Cllocationmanager class implementation of the corresponding functions, the above methods are not introduced today, and the use of image sensors and brightness sensors, whether there is a public API, limited to my academic level, has not been found to use the method; today, we mainly introduce the usage of the proximity sensor. , the code is as follows:
- [[Uidevice Currentdevice] setproximitymonitoringenabled:yes];
- [[Nsnotificationcenter Defaultcenter] Addobserver:self
- Selector: @selector (sensorstatechange:)
- name:@"Uideviceproximitystatedidchangenotification"
- Object:nil];
- -(void) Sensorstatechange: (nsnotificationcenter *) notification;
- {
- if ([[Uidevice currentdevice] proximitystate] = = YES) {
- NSLog (@"Device is close to user");
- The Operation logic code to be done when writing close
- }else{
- NSLog (@"Device isn't close to user");
- }
- }
iOS Development – Sensor usage