MCPcopy Create free account
hub / github.com/golang/mobile / readEvents

Function readEvents

exp/sensor/android.go:156–180  ·  view source on GitHub ↗
(e []Event)

Source from the content-addressed store, hash-verified

154}
155
156func readEvents(e []Event) int {
157 num := len(e)
158 types := make([]C.int32_t, num)
159 timestamps := make([]C.int64_t, num)
160 vectors := make([]C.float, 3*num)
161
162 n := int(C.GoAndroid_readQueue(
163 C.int(num),
164 (*C.int32_t)(unsafe.Pointer(&types[0])),
165 (*C.int64_t)(unsafe.Pointer(&timestamps[0])),
166 (*C.float)(unsafe.Pointer(&vectors[0]))),
167 )
168 for i := 0; i < n; i++ {
169 e[i] = Event{
170 Sensor: intToType[int(types[i])],
171 Timestamp: int64(timestamps[i]),
172 Data: []float64{
173 float64(vectors[i*3]),
174 float64(vectors[i*3+1]),
175 float64(vectors[i*3+2]),
176 },
177 }
178 }
179 return n
180}
181
182// TODO(jbd): Remove destroy?
183func destroy() error {

Callers 1

initFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected