Skip to content

Commit 98599e8

Browse files
committed
Allow disabling sensors at compile-time
Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent 61536fb commit 98599e8

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

SensorsComboDriver/Device.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,24 @@
1919

2020
#define EC_LPC_ADDR_MEMMAP 0xE00
2121
#define EC_MEMMAP_SIZE 255 /* ACPI IO buffer max is 255 bytes */
22+
#define ENABLE_ALS_SENSOR 1
23+
#define ENABLE_ORIENTATION_SENSOR 0
24+
#define ENABLE_ACCEL_SENSOR 0
2225

2326
//---------------------------------------
2427
// Declare and map devices below
2528
//---------------------------------------
2629
enum Device
2730
{
28-
Device_Als = 0,
31+
#if ENABLE_ALS_SENSOR
32+
Device_Als,
33+
#endif
34+
#if ENABLE_ORIENTATION_SENSOR
2935
Device_SimpleDeviceOrientation,
36+
#endif
37+
#if ENABLE_ACCEL_SENSOR
3038
Device_LinearAccelerometer,
39+
#endif
3140
// Keep this last
3241
Device_Count
3342
};
@@ -41,9 +50,15 @@ inline size_t GetDeviceSizeAtIndex(
4150
size_t result = 0;
4251
switch (static_cast<Device>(Index))
4352
{
53+
#if ENABLE_ALS_SENSOR
4454
case Device_Als: result = sizeof(AlsDevice); break;
55+
#endif
56+
#if ENABLE_ORIENTATION_SENSOR
4557
case Device_SimpleDeviceOrientation:result = sizeof(SimpleDeviceOrientationDevice); break;
58+
#endif
59+
#if ENABLE_ACCEL_SENSOR
4660
case Device_LinearAccelerometer: result = sizeof(LinearAccelerometerDevice); break;
61+
#endif
4762
default: break; // invalid
4863
}
4964
return result;
@@ -56,9 +71,15 @@ void AllocateDeviceAtIndex(
5671
{
5772
switch (static_cast<Device>(Index))
5873
{
74+
#if ENABLE_ALS_SENSOR
5975
case Device_Als: *ppDevice = new(*ppDevice) AlsDevice; break;
76+
#endif
77+
#if ENABLE_ORIENTATIONACCEL_SENSOR
6078
case Device_SimpleDeviceOrientation:*ppDevice = new(*ppDevice) SimpleDeviceOrientationDevice; break;
79+
#endif
80+
#if ENABLE_ACCEL_SENSOR
6181
case Device_LinearAccelerometer: *ppDevice = new(*ppDevice) LinearAccelerometerDevice; break;
82+
#endif
6283

6384
default: break; // invalid (let driver fail)
6485
}

0 commit comments

Comments
 (0)