var signalName : MWNamedSignal MWDataTable .Framework
protocol MWLoggable : MWDataConvertible To start logging, use the .log() operators. These are available on a Publisher whose output is a Meta, including:
These operators accept MWLoggable instances construct by autocompletion, such as sensor, or by direct construction, such as MWSensor init(mode:).
metawear
.publishWhenConnected()
.first()
.mapToMWError() // Changes Failure from Never to MWError
.log(.sensorFusionQuaternion(mode: .ndof)
.log(.gyroscope(range: .dps2000, frequency: .hz400)
.sink { _ in }
.store(in: &subs)Direct construction may be useful when you persist user selected settings or organize arbitrarily large logging sessions. The SDK includes the operators .macro(execute and .optionally to help with this.
let pressure = MWBarometer.MWPressure(standby: .ms125, iir: .off, oversampling: .standard)
let gyro = MWGyroscope(range: .dps1000, frequency: .hz400)
let euler: MWSensorFusion.EulerAngles? = nil
metawear
.publishIfConnected()
.macro(executeOnBoot: true) { metawear in
metawear
.optionallyLog(euler)
.optionallyLog(gyro)
.optionallyLog(pressure)
}
.sink { _ in }
.store(in: &subs)Our open-source MetaBase 5 app provides a similar example in ActionVM.swift and MetaWear+WriteSensorMacro.swift by creating a macro of multiple MWLoggable and MWPollable signals from arbitrary user-selected sensors and sensor parameters.
Downloading logs in CSV format is simple with the .download operator, also demonstrated in the aforementioned MetaBase app.
Unless you construct your own sensor wrappers, this protocol’s details and default methods are unlikely to be important to you.
var signalName : MWNamedSignal MWDataTable .func loggerCleanup (board: MWBoard) func loggerConfigure (board: MWBoard) func loggerDataSignal (board: MWBoard) throws -> MWDataSignal ? func loggerStart (board: MWBoard) static var chargingStatus : MWChargingStatus Self is MWChargingStatus .static var mechanicalButton : MWMechanicalButton Self is MWMechanicalButton .static var orientation: MWOrientationSensor Self is MWOrientationSensor .static func absoluteAltitude (standby: MWBarometer.StandbyTime , iir: MWBarometer.IIRFilter, oversampling: MWBarometer.Oversampling) -> Self Self is MWBarometer.MWAltitude .static func accelerometer(rate: MWAccelerometer.SampleFrequency , gravity: MWAccelerometer.GravityRange ) -> Self Self is MWAccelerometer.static func ambientLight (rate: MWAmbientLight .MeasurementRate , gain: MWAmbientLight .Gain, integrationTime : MWAmbientLight .IntegrationTime ) -> Self Self is MWAmbientLight .static func gyroscope(rate: MWGyroscope.Frequency?, range: MWGyroscope.GraphRange ?) -> Self Self is MWGyroscope.static func magnetometer(rate: MWMagnetometer.SampleFrequency ?) -> Self Self is MWMagnetometer.static func relativePressure (standby: MWBarometer.StandbyTime , iir: MWBarometer.IIRFilter, oversampling: MWBarometer.Oversampling) -> Self Self is MWBarometer.MWPressure .static func sensorFusionEulerAngles (mode: MWSensorFusion .Mode) -> Self Self is MWSensorFusion.EulerAngles .static func sensorFusionGravity (mode: MWSensorFusion .Mode) -> Self Self is MWSensorFusion.Gravity .static func sensorFusionLinearAcceleration (mode: MWSensorFusion .Mode) -> Self Self is MWSensorFusion.LinearAcceleration .static func sensorFusionQuaternion (mode: MWSensorFusion .Mode) -> Self Self is MWSensorFusion.Quaternion .static func stepCounter (sensitivity: MWAccelerometer.StepCounterSensitivity ?) -> Self Self is MWStepCounter .static func stepDetector (sensitivity: MWAccelerometer.StepCounterSensitivity ?) -> Self Self is MWStepDetector .MWDataConvertible Swift.Equatable Swift.Hashable MWAccelerometer MWAmbientLight MWBarometer.MWAltitude MWBarometer.MWPressure MWChargingStatus MWGyroscope MWMagnetometer MWMechanicalButton MWMotion.Activity MWMotion.AnyMotion MWMotion.NoMotion MWMotion.Significant MWOrientationSensor MWSensorFusion.EulerAngles MWSensorFusion.Gravity MWSensorFusion.LinearAcceleration MWSensorFusion.Quaternion MWStepCounter MWStepDetector protocol MWCommand protocol MWCommandWithResponse protocol MWPollable protocol MWReadable protocol MWReadableMerged protocol MWStreamable struct MWFrequency