Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(501)

Side by Side Diff: chromeos/accelerometer/accelerometer_reader.h

Issue 200643005: Read and expose accelerometer values from cros-ec-accel trigger. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Virtual dtor in observer, ASH_EXPORT for tests in dependent CLs. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROMEOS_ACCELEROMETER_ACCELEROMETER_READER_H_
6 #define CHROMEOS_ACCELEROMETER_ACCELEROMETER_READER_H_
7
8 #include <vector>
9
10 #include "base/memory/weak_ptr.h"
11 #include "base/observer_list.h"
12 #include "chromeos/chromeos_export.h"
13
14 namespace gfx {
15 class Vector3dF;
16 }
17
18 namespace chromeos {
19
20 // Reads an accelerometer device and reports data back to an
21 // AccelerometerDelegate.
22 class CHROMEOS_EXPORT AccelerometerReader {
23 public:
24 // An interface to receive data from the AccelerometerReader.
25 class Delegate {
26 public:
27 virtual void HandleAccelerometerReading(const gfx::Vector3dF& base,
28 const gfx::Vector3dF& lid) = 0;
29 };
30
31 AccelerometerReader(Delegate* delegate);
32 ~AccelerometerReader();
33
34 private:
35 // Detects and reads configuration of the accelerometer device.
36 bool Initialize();
37
38 // Triggers a read from the accelerometer, and posts a task to trigger another
39 // read after the sampling interval.
40 void TriggerRead();
41
42 // Triggers the accelerometer and reads the sampled values. On success,
43 // notifies the |delegate_| with the read values.
44 void ReadAccelerometer();
45
46 // A weak pointer to the delegate to send accelerometer readings to.
47 Delegate* delegate_;
48
49 // True after Initialize has run if an accelerometer sensor exists.
50 bool has_accelerometer_;
51
52 // The index of each axis of each accelerometer.
53 std::vector<unsigned int> accelerometer_index_;
54
55 // The scale of the base and lid accelerometers.
56 unsigned int accelerometer_base_scale_;
57 unsigned int accelerometer_lid_scale_;
58
59 base::WeakPtrFactory<AccelerometerReader> weak_factory_;
60
61 DISALLOW_COPY_AND_ASSIGN(AccelerometerReader);
62 };
63
64 } // namespace chromeos
65
66 #endif // CHROMEOS_ACCELEROMETER_ACCELEROMETER_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698