// Structure for specifying a 3-axis acceleration. 0.0 means "zero gravities", // 1.0 means "one gravity". typedefstruct sms_acceleration { float x; // Right-left acceleration (positive is rightwards) float y; // Front-rear acceleration (positive is rearwards) float z; // Up-down acceleration (positive is upwards)
} sms_acceleration;
// Structure for specifying a calibration. typedefstruct sms_calibration { float zeros[3]; // Zero points for three axes (X, Y, Z) float onegs[3]; // One gravity values for three axes
} sms_calibration;
#pragma mark Return value definitions
// These are the return values for accelStartup(), giving the // various stages where the most successful attempt at accessing // the accelerometer failed. The higher the value, the further along the // software progressed before failing. The options are: // - Didn't match model name #define SMS_FAIL_MODEL (-7) // - Failure getting dictionary matching desired services #define SMS_FAIL_DICTIONARY (-6) // - Failure getting list of services #define SMS_FAIL_LIST_SERVICES (-5) // - Failure if list of services is empty. The process generally fails // here if run on a machine without a Sudden Motion Sensor. #define SMS_FAIL_NO_SERVICES (-4) // - Failure if error opening device. #define SMS_FAIL_OPENING (-3) // - Failure if opened, but didn't get a connection #define SMS_FAIL_CONNECTION (-2) // - Failure if couldn't access connction using given function and size. // This is where the process would probably fail with a change // in Apple's API. Driver problems often also cause failures here. #define SMS_FAIL_ACCESS (-1) // - Success! #define SMS_SUCCESS (0)
#pragma mark Function declarations
// This starts up the accelerometer code, trying each possible sensor // specification. Note that for logging purposes it // takes an object and a selector; the object's selector is then invoked // with a single NSString as argument giving progress messages. Example // logging method: // - (void)logMessage: (NSString *)theString // which would be used in accelStartup's invocation thusly: // result = accelStartup(self, @selector(logMessage:)); // If the object is nil, then no logging is done. Sets calibation from built-in // value table. Returns ACCEL_SUCCESS for success, and other (negative) // values for various failures (returns value indicating result of // most successful trial). int smsStartup(id logObject, SEL logSelector);
// This starts up the library in debug mode, ignoring the actual hardware. // Returned data is in the form of 1Hz sine waves, with the X, Y and Z // axes 120 degrees out of phase; "calibrated" data has range +/- (1.0/5); // "uncalibrated" data has range +/- (256/5). X and Y axes centered on 0.0, // Z axes centered on 1 (calibrated) or 256 (uncalibrated). // Don't use smsGetBufferLength or smsGetBufferData. Always returns SMS_SUCCESS. int smsDebugStartup(id logObject, SEL logSelector);
// Returns the current calibration values. void smsGetCalibration(sms_calibration* calibrationRecord);
// Sets the calibration, but does NOT store it as a preference. If the argument // is nil then the current calibration is set from the built-in value table. void smsSetCalibration(sms_calibration* calibrationRecord);
// Stores the current calibration values as a stored preference. void smsStoreCalibration(void);
// Loads the stored preference values into the current calibration. // Returns YES if successful. BOOL smsLoadCalibration(void);
// Deletes any stored calibration, and then takes the current calibration values // from the built-in value table. void smsDeleteCalibration(void);
// Fills in the accel record with calibrated acceleration data. Takes // 1-2ms to return a value. Returns 0 if success, error number if failure. int smsGetData(sms_acceleration* accel);
// Fills in the accel record with uncalibrated acceleration data. // Returns 0 if success, error number if failure. int smsGetUncalibratedData(sms_acceleration* accel);
// Returns the length of a raw block of data for the current type of sensor. int smsGetBufferLength(void);
// Takes a pointer to accelGetRawLength() bytes; sets those bytes // to return value from sensor. Make darn sure the buffer length is right! void smsGetBufferData(char* buffer);
// This returns an NSString describing the current calibration in // human-readable form. Also include a description of the machine.
NSString* smsGetCalibrationDescription(void);
// Shuts down the accelerometer. void smsShutdown(void);
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.15 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.