sensor

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package sensor provides Go bindings for Android Sensor NDK.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ALooper

type ALooper = capi.ALooper

type ALooper_callbackFunc

type ALooper_callbackFunc = capi.ALooper_callbackFunc

type ASensorList

type ASensorList = capi.ASensorList

type ASensorRef

type ASensorRef = capi.ASensorRef

type AdditionalInfoEvent

type AdditionalInfoEvent struct {
	// contains filtered or unexported fields
}

AdditionalInfoEvent wraps the NDK AAdditionalInfoEvent handle.

func NewAdditionalInfoEventFromPointer

func NewAdditionalInfoEventFromPointer(ptr unsafe.Pointer) *AdditionalInfoEvent

NewAdditionalInfoEventFromPointer wraps a raw AAdditionalInfoEvent pointer.

func (*AdditionalInfoEvent) Pointer

func (h *AdditionalInfoEvent) Pointer() unsafe.Pointer

Pointer returns the underlying pointer as unsafe.Pointer.

type DynamicSensorEvent

type DynamicSensorEvent struct {
	// contains filtered or unexported fields
}

DynamicSensorEvent wraps the NDK ADynamicSensorEvent handle.

func NewDynamicSensorEventFromPointer

func NewDynamicSensorEventFromPointer(ptr unsafe.Pointer) *DynamicSensorEvent

NewDynamicSensorEventFromPointer wraps a raw ADynamicSensorEvent pointer.

func (*DynamicSensorEvent) Pointer

func (h *DynamicSensorEvent) Pointer() unsafe.Pointer

Pointer returns the underlying pointer as unsafe.Pointer.

type Error

type Error int32

Error represents an NDK error code.

func (Error) Error

func (e Error) Error() string

type EventQueue

type EventQueue struct {
	// contains filtered or unexported fields
}

EventQueue wraps the NDK ASensorEventQueue handle.

func NewEventQueueFromPointer

func NewEventQueueFromPointer(ptr unsafe.Pointer) *EventQueue

NewEventQueueFromPointer wraps a raw ASensorEventQueue pointer.

func (*EventQueue) DisableSensor

func (h *EventQueue) DisableSensor(sensor *Sensor) error

DisableSensor calls the underlying NDK function.

func (*EventQueue) EnableSensor

func (h *EventQueue) EnableSensor(sensor *Sensor) error

EnableSensor calls the underlying NDK function.

func (*EventQueue) GetEvents

func (h *EventQueue) GetEvents(events *SensorEvent, count uint64) int64

GetEvents returns the value directly.

func (*EventQueue) HasEvents

func (h *EventQueue) HasEvents() int32

HasEvents returns the value directly.

func (*EventQueue) Pointer

func (h *EventQueue) Pointer() unsafe.Pointer

Pointer returns the underlying pointer as unsafe.Pointer.

func (*EventQueue) RegisterSensor

func (h *EventQueue) RegisterSensor(sensor *Sensor, samplingPeriodUs int32, maxBatchReportLatencyUs int64) error

RegisterSensor calls the underlying NDK function.

func (*EventQueue) RequestAdditionalInfoEvents

func (h *EventQueue) RequestAdditionalInfoEvents(enable bool) error

RequestAdditionalInfoEvents calls the underlying NDK function.

func (*EventQueue) SetEventRate

func (h *EventQueue) SetEventRate(sensor *Sensor, usec int32) error

SetEventRate calls the underlying NDK function.

type HardwareBuffer

type HardwareBuffer struct {
	// contains filtered or unexported fields
}

HardwareBuffer wraps the NDK AHardwareBuffer handle.

func NewHardwareBufferFromPointer

func NewHardwareBufferFromPointer(ptr unsafe.Pointer) *HardwareBuffer

NewHardwareBufferFromPointer wraps a raw AHardwareBuffer pointer.

func (*HardwareBuffer) Pointer

func (h *HardwareBuffer) Pointer() unsafe.Pointer

Pointer returns the underlying pointer as unsafe.Pointer.

type HeadTrackerEvent

type HeadTrackerEvent struct {
	// contains filtered or unexported fields
}

HeadTrackerEvent wraps the NDK AHeadTrackerEvent handle.

func NewHeadTrackerEventFromPointer

func NewHeadTrackerEventFromPointer(ptr unsafe.Pointer) *HeadTrackerEvent

NewHeadTrackerEventFromPointer wraps a raw AHeadTrackerEvent pointer.

func (*HeadTrackerEvent) Pointer

func (h *HeadTrackerEvent) Pointer() unsafe.Pointer

Pointer returns the underlying pointer as unsafe.Pointer.

type HeadingEvent

type HeadingEvent struct {
	// contains filtered or unexported fields
}

HeadingEvent wraps the NDK AHeadingEvent handle.

func NewHeadingEventFromPointer

func NewHeadingEventFromPointer(ptr unsafe.Pointer) *HeadingEvent

NewHeadingEventFromPointer wraps a raw AHeadingEvent pointer.

func (*HeadingEvent) Pointer

func (h *HeadingEvent) Pointer() unsafe.Pointer

Pointer returns the underlying pointer as unsafe.Pointer.

type HeartRateEvent

type HeartRateEvent struct {
	// contains filtered or unexported fields
}

HeartRateEvent wraps the NDK AHeartRateEvent handle.

func NewHeartRateEventFromPointer

func NewHeartRateEventFromPointer(ptr unsafe.Pointer) *HeartRateEvent

NewHeartRateEventFromPointer wraps a raw AHeartRateEvent pointer.

func (*HeartRateEvent) Pointer

func (h *HeartRateEvent) Pointer() unsafe.Pointer

Pointer returns the underlying pointer as unsafe.Pointer.

type LimitedAxesImuEvent

type LimitedAxesImuEvent struct {
	// contains filtered or unexported fields
}

LimitedAxesImuEvent wraps the NDK ALimitedAxesImuEvent handle.

func NewLimitedAxesImuEventFromPointer

func NewLimitedAxesImuEventFromPointer(ptr unsafe.Pointer) *LimitedAxesImuEvent

NewLimitedAxesImuEventFromPointer wraps a raw ALimitedAxesImuEvent pointer.

func (*LimitedAxesImuEvent) Pointer

func (h *LimitedAxesImuEvent) Pointer() unsafe.Pointer

Pointer returns the underlying pointer as unsafe.Pointer.

type LimitedAxesImuUncalibratedEvent

type LimitedAxesImuUncalibratedEvent struct {
	// contains filtered or unexported fields
}

LimitedAxesImuUncalibratedEvent wraps the NDK ALimitedAxesImuUncalibratedEvent handle.

func NewLimitedAxesImuUncalibratedEventFromPointer

func NewLimitedAxesImuUncalibratedEventFromPointer(ptr unsafe.Pointer) *LimitedAxesImuUncalibratedEvent

NewLimitedAxesImuUncalibratedEventFromPointer wraps a raw ALimitedAxesImuUncalibratedEvent pointer.

func (*LimitedAxesImuUncalibratedEvent) Pointer

Pointer returns the underlying pointer as unsafe.Pointer.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager wraps the NDK ASensorManager handle.

func ASensorManager_getInstanceForPackage

func ASensorManager_getInstanceForPackage(packageName string) *Manager

ASensorManager_getInstanceForPackage calls the underlying C function.

func GetInstance

func GetInstance() *Manager

GetInstance calls the underlying C function.

func NewManagerFromPointer

func NewManagerFromPointer(ptr unsafe.Pointer) *Manager

NewManagerFromPointer wraps a raw ASensorManager pointer.

func (*Manager) ConfigureDirectReport

func (h *Manager) ConfigureDirectReport(sensor *Sensor, channelID int32, rate int32) error

ConfigureDirectReport calls the underlying NDK function.

func (*Manager) CreateEventQueue

func (h *Manager) CreateEventQueue(looper *ALooper, ident int32, callback ALooper_callbackFunc, data unsafe.Pointer) *EventQueue

CreateEventQueue creates a new EventQueue from this Manager.

func (*Manager) CreateHardwareBufferDirectChannel

func (h *Manager) CreateHardwareBufferDirectChannel(buffer *HardwareBuffer, size uint64) error

CreateHardwareBufferDirectChannel calls the underlying NDK function.

func (*Manager) CreateSharedMemoryDirectChannel

func (h *Manager) CreateSharedMemoryDirectChannel(fd int32, size uint64) error

CreateSharedMemoryDirectChannel calls the underlying NDK function.

func (*Manager) DefaultSensor

func (h *Manager) DefaultSensor(_type Type) *Sensor

DefaultSensor creates a new Sensor from this Manager.

func (*Manager) DestroyDirectChannel

func (h *Manager) DestroyDirectChannel(channelID int32)

DestroyDirectChannel calls the underlying NDK function.

func (*Manager) DestroyEventQueue

func (h *Manager) DestroyEventQueue(queue *EventQueue) error

DestroyEventQueue calls the underlying NDK function.

func (*Manager) GetDefaultSensorEx

func (h *Manager) GetDefaultSensorEx(_type Type, wakeUp bool) *Sensor

GetDefaultSensorEx creates a new Sensor from this Manager.

func (*Manager) GetDynamicSensorList

func (h *Manager) GetDynamicSensorList(list *ASensorList) int64

GetDynamicSensorList returns the value directly.

func (*Manager) Pointer

func (h *Manager) Pointer() unsafe.Pointer

Pointer returns the underlying pointer as unsafe.Pointer.

type MetaDataEvent

type MetaDataEvent struct {
	// contains filtered or unexported fields
}

MetaDataEvent wraps the NDK AMetaDataEvent handle.

func NewMetaDataEventFromPointer

func NewMetaDataEventFromPointer(ptr unsafe.Pointer) *MetaDataEvent

NewMetaDataEventFromPointer wraps a raw AMetaDataEvent pointer.

func (*MetaDataEvent) Pointer

func (h *MetaDataEvent) Pointer() unsafe.Pointer

Pointer returns the underlying pointer as unsafe.Pointer.

type REPORTING_MODE

type REPORTING_MODE int32
const (
	AREPORTING_MODE_INVALID         REPORTING_MODE = -1
	AREPORTING_MODE_CONTINUOUS      REPORTING_MODE = 0
	AREPORTING_MODE_ON_CHANGE       REPORTING_MODE = 1
	AREPORTING_MODE_ONE_SHOT        REPORTING_MODE = 2
	AREPORTING_MODE_SPECIAL_TRIGGER REPORTING_MODE = 3
)

type SENSOR_ADDITIONAL_INFO

type SENSOR_ADDITIONAL_INFO int32
const (
	ASENSOR_ADDITIONAL_INFO_BEGIN                SENSOR_ADDITIONAL_INFO = 0
	ASENSOR_ADDITIONAL_INFO_END                  SENSOR_ADDITIONAL_INFO = 1
	ASENSOR_ADDITIONAL_INFO_UNTRACKED_DELAY      SENSOR_ADDITIONAL_INFO = 65536
	ASENSOR_ADDITIONAL_INFO_INTERNAL_TEMPERATURE SENSOR_ADDITIONAL_INFO = 65537
	ASENSOR_ADDITIONAL_INFO_VEC3_CALIBRATION     SENSOR_ADDITIONAL_INFO = 65538
	ASENSOR_ADDITIONAL_INFO_SENSOR_PLACEMENT     SENSOR_ADDITIONAL_INFO = 65539
	ASENSOR_ADDITIONAL_INFO_SAMPLING             SENSOR_ADDITIONAL_INFO = 65540
)

type SENSOR_DIRECT_CHANNEL_TYPE

type SENSOR_DIRECT_CHANNEL_TYPE int32
const (
	ASENSOR_DIRECT_CHANNEL_TYPE_SHARED_MEMORY   SENSOR_DIRECT_CHANNEL_TYPE = 1
	ASENSOR_DIRECT_CHANNEL_TYPE_HARDWARE_BUFFER SENSOR_DIRECT_CHANNEL_TYPE = 2
)

type SENSOR_DIRECT_RATE

type SENSOR_DIRECT_RATE int32
const (
	ASENSOR_DIRECT_RATE_STOP      SENSOR_DIRECT_RATE = 0
	ASENSOR_DIRECT_RATE_NORMAL    SENSOR_DIRECT_RATE = 1
	ASENSOR_DIRECT_RATE_FAST      SENSOR_DIRECT_RATE = 2
	ASENSOR_DIRECT_RATE_VERY_FAST SENSOR_DIRECT_RATE = 3
)

type Sensor

type Sensor struct {
	// contains filtered or unexported fields
}

Sensor wraps the NDK ASensor handle.

func NewSensorFromPointer

func NewSensorFromPointer(ptr unsafe.Pointer) *Sensor

NewSensorFromPointer wraps a raw ASensor pointer.

func (*Sensor) GetFifoMaxEventCount

func (h *Sensor) GetFifoMaxEventCount() error

GetFifoMaxEventCount calls the underlying NDK function.

func (*Sensor) GetFifoReservedEventCount

func (h *Sensor) GetFifoReservedEventCount() error

GetFifoReservedEventCount calls the underlying NDK function.

func (*Sensor) GetHandle

func (h *Sensor) GetHandle() error

GetHandle calls the underlying NDK function.

func (*Sensor) GetHighestDirectReportRateLevel

func (h *Sensor) GetHighestDirectReportRateLevel() error

GetHighestDirectReportRateLevel calls the underlying NDK function.

func (*Sensor) GetReportingMode

func (h *Sensor) GetReportingMode() error

GetReportingMode calls the underlying NDK function.

func (*Sensor) GetStringType

func (h *Sensor) GetStringType() string

GetStringType returns the value directly.

func (*Sensor) IsDirectChannelTypeSupported

func (h *Sensor) IsDirectChannelTypeSupported(channelType int32) bool

IsDirectChannelTypeSupported returns the value directly.

func (*Sensor) IsWakeUpSensor

func (h *Sensor) IsWakeUpSensor() bool

IsWakeUpSensor returns the value directly.

func (*Sensor) MinDelay

func (h *Sensor) MinDelay() int32

MinDelay returns the value directly.

func (*Sensor) Name

func (h *Sensor) Name() string

Name returns the value directly.

func (*Sensor) Pointer

func (h *Sensor) Pointer() unsafe.Pointer

Pointer returns the underlying pointer as unsafe.Pointer.

func (*Sensor) Resolution

func (h *Sensor) Resolution() float32

Resolution returns the value directly.

func (*Sensor) Type

func (h *Sensor) Type() int32

Type returns the value directly.

func (*Sensor) Vendor

func (h *Sensor) Vendor() string

Vendor returns the value directly.

type SensorEvent

type SensorEvent struct {
	// contains filtered or unexported fields
}

SensorEvent wraps the NDK ASensorEvent handle.

func NewSensorEventFromPointer

func NewSensorEventFromPointer(ptr unsafe.Pointer) *SensorEvent

NewSensorEventFromPointer wraps a raw ASensorEvent pointer.

func (*SensorEvent) Pointer

func (h *SensorEvent) Pointer() unsafe.Pointer

Pointer returns the underlying pointer as unsafe.Pointer.

type SensorVector

type SensorVector struct {
	// contains filtered or unexported fields
}

SensorVector wraps the NDK ASensorVector handle.

func NewSensorVectorFromPointer

func NewSensorVectorFromPointer(ptr unsafe.Pointer) *SensorVector

NewSensorVectorFromPointer wraps a raw ASensorVector pointer.

func (*SensorVector) Pointer

func (h *SensorVector) Pointer() unsafe.Pointer

Pointer returns the underlying pointer as unsafe.Pointer.

type Status

type Status int32
const (
	NoContact      Status = -1
	Unreliable     Status = 0
	AccuracyLow    Status = 1
	AccuracyMedium Status = 2
	AccuracyHigh   Status = 3
)

func (Status) String

func (v Status) String() string

type Type

type Type int32
const (
	Invalid                              Type = -1
	Accelerometer                        Type = 1
	MagneticField                        Type = 2
	Gyroscope                            Type = 4
	Light                                Type = 5
	Pressure                             Type = 6
	Proximity                            Type = 8
	Gravity                              Type = 9
	LinearAcceleration                   Type = 10
	RotationVector                       Type = 11
	RelativeHumidity                     Type = 12
	AmbientTemperature                   Type = 13
	MagneticFieldUncalibrated            Type = 14
	GameRotationVector                   Type = 15
	GyroscopeUncalibrated                Type = 16
	SignificantMotion                    Type = 17
	StepDetector                         Type = 18
	StepCounter                          Type = 19
	GeomagneticRotationVector            Type = 20
	HeartRate                            Type = 21
	Pose6dof                             Type = 28
	StationaryDetect                     Type = 29
	MotionDetect                         Type = 30
	HeartBeat                            Type = 31
	DynamicSensorMeta                    Type = 32
	AdditionalInfo                       Type = 33
	LowLatencyOffbodyDetect              Type = 34
	AccelerometerUncalibrated            Type = 35
	HingeAngle                           Type = 36
	HeadTracker                          Type = 37
	AccelerometerLimitedAxes             Type = 38
	GyroscopeLimitedAxes                 Type = 39
	AccelerometerLimitedAxesUncalibrated Type = 40
	GyroscopeLimitedAxesUncalibrated     Type = 41
	Heading                              Type = 42
)

func (Type) String

func (v Type) String() string

type UncalibratedEvent

type UncalibratedEvent struct {
	// contains filtered or unexported fields
}

UncalibratedEvent wraps the NDK AUncalibratedEvent handle.

func NewUncalibratedEventFromPointer

func NewUncalibratedEventFromPointer(ptr unsafe.Pointer) *UncalibratedEvent

NewUncalibratedEventFromPointer wraps a raw AUncalibratedEvent pointer.

func (*UncalibratedEvent) Pointer

func (h *UncalibratedEvent) Pointer() unsafe.Pointer

Pointer returns the underlying pointer as unsafe.Pointer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL