Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto

# Declare files that will always have CRLF line endings on checkout.
*.appxmanifest text eol=crlf
*.c text eol=crlf
*.cpp text eol=crlf
*.cs text eol=crlf
*.csproj text eol=crlf
*.css text eol=crlf
*.def text eol=crlf
*.filters text eol=crlf
*.h text eol=crlf
*.htm text eol=crlf
*.html text eol=crlf
*.idl text eol=crlf
*.js text eol=crlf
*.jsproj text eol=crlf
*.rc text eol=crlf
*.rgs text eol=crlf
*.sln text eol=crlf
*.vcxproj text eol=crlf
*.xaml text eol=crlf

# Declare files that are encoded in UTF-16
*.inf text diff working-tree-encoding=UTF-16LE-BOM eol=crlf
*.inx text diff working-tree-encoding=UTF-16LE-BOM eol=crlf

###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
*.cs diff=csharp
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
platform: [x64]
runs-on: windows-2022
# env:
# Solution_Path: SensorsComboDriver\SensorsComboDriver.sln
# Solution_Path: FrameworkSensors\FrameworkSensors.sln
steps:
- name: Check out repository code
uses: actions/checkout@v4
Expand All @@ -21,8 +21,7 @@ jobs:
# msbuild ${{ env.Solution_Path }} -p:Configuration:${{ env.Configuration }} -p:Platform:${{ env.Platform }}
- name: Build solution
run: |
msbuild SensorsComboDriver\SensorsComboDriver.sln /property:Configuration=${{ env.Configuration }} /property:Platform=${{ env.Platform }}
msbuild SimpleDeviceOrientationSensor\SimpleDeviceOrientationSensor.sln /property:Configuration=${{ env.Configuration }} /property:Platform=${{ env.Platform }}
msbuild FrameworkSensors\FrameworkSensors.sln /property:Configuration=${{ env.Configuration }} /property:Platform=${{ env.Platform }}
env:
Configuration: ${{ matrix.configuration }}
Platform: ${{ matrix.platform }}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// Windows User-Mode Driver Framework (WUDF)

#include "Clients.h"
#include "EcCommunication.h"

#include "AlsClient.tmh"

Expand Down Expand Up @@ -165,7 +166,7 @@ AlsDevice::Initialize(
&(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value));

m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer;
InitPropVariantFromString(L"Manufacturer name",
InitPropVariantFromString(L"Framework Computer Inc",
&(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value));

m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model;
Expand Down Expand Up @@ -462,7 +463,6 @@ AlsDevice::Initialize(
}



//------------------------------------------------------------------------------
// Function: GetData
//
Expand All @@ -478,6 +478,7 @@ AlsDevice::Initialize(
//------------------------------------------------------------------------------
NTSTATUS
AlsDevice::GetData(
_In_ HANDLE Handle
)
{
BOOLEAN DataReady = FALSE;
Expand All @@ -486,6 +487,15 @@ AlsDevice::GetData(

SENSOR_FunctionEnter();

UINT8 als[4] = {0};
CrosEcReadMemU8(Handle, EC_MEMMAP_ALS + 0, &als[0]);
CrosEcReadMemU8(Handle, EC_MEMMAP_ALS + 1, &als[1]);
CrosEcReadMemU8(Handle, EC_MEMMAP_ALS + 2, &als[2]);
CrosEcReadMemU8(Handle, EC_MEMMAP_ALS + 3, &als[3]);
m_CachedData.Lux = (float) (als[0] + (als[1] << 8) + (als[2] << 16) + (als[3] << 24));
TraceInformation("Read ALS value %02x %02x %02x %02x (%f)\n",
als[0], als[1], als[2], als[3], m_CachedData.Lux);

// new sample?
if (m_FirstSample != FALSE)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ OnTimerExpire(

// Get data and push to clx
Lock(pDevice->m_Lock);
Status = pDevice->GetData();
Status = pDevice->GetData(pDevice->m_CrosEcHandle);
if (!NT_SUCCESS(Status) && Status != STATUS_DATA_NOT_ACCEPTED)
{
TraceError("COMBO %!FUNC! GetData Failed %!STATUS!", Status);
Expand Down
161 changes: 15 additions & 146 deletions SensorsComboDriver/Clients.h → FrameworkSensors/Clients.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ typedef class _ComboDevice
ULONG m_StartTime;
ULONGLONG m_SampleCount;
BOOLEAN m_WakeEnabled;
HANDLE m_CrosEcHandle;

//
// Sensor Specific Properties
Expand All @@ -142,7 +143,7 @@ typedef class _ComboDevice
// Sensor specific functions
//
virtual NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj) = NULL;
virtual NTSTATUS GetData() = NULL;
virtual NTSTATUS GetData(_In_ HANDLE Handle) = NULL;
virtual NTSTATUS UpdateCachedThreshold() = NULL;
virtual NTSTATUS EnableWake() { return STATUS_NOT_SUPPORTED; }
virtual NTSTATUS DisableWake() { return STATUS_NOT_SUPPORTED; }
Expand Down Expand Up @@ -197,127 +198,13 @@ typedef class _AlsDevice : public _ComboDevice
public:

NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj);
NTSTATUS GetData();
NTSTATUS GetData(_In_ HANDLE Device);
NTSTATUS UpdateCachedThreshold();

} AlsDevice, *PAlsDevice;



//
// Barometer --------------------------------------------------------------
//
typedef class _BarDevice : public _ComboDevice
{
private:

FLOAT m_CachedThresholds;
FLOAT m_CachedData;
FLOAT m_LastSample;

public:

NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj);
NTSTATUS GetData();
NTSTATUS UpdateCachedThreshold();

} BarDevice, *PBarDevice;



//
// Gyroscope ------------------------------------------------------------------
//
typedef class _GyrDevice : public _ComboDevice
{
private:

VEC3D m_CachedThresholds;
VEC3D m_CachedData;
VEC3D m_LastSample;

public:

NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj);
NTSTATUS GetData();
NTSTATUS UpdateCachedThreshold();

} GyrDevice, *PGyrDevice;



//
// Magnetometer ---------------------------------------------------------------
//
typedef struct _MagData
{
VEC3D Axis;
ULONG Accuracy;
} MagData, *PMagData;

typedef class _MagDevice : public _ComboDevice
{
private:

VEC3D m_CachedThresholds;
MagData m_CachedData;
MagData m_LastSample;

public:

NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj);
NTSTATUS GetData();
NTSTATUS UpdateCachedThreshold();

} MagDevice, *PMagDevice;



//
// Proximity ------------------------------------------------------------------
//
typedef struct
{
BOOL Detected;
ULONG DistanceMillimeters;
} PrxData, *PPrxData;

typedef class _PrxDevice : public _ComboDevice
{
private:

PrxData m_CachedData;
PrxData m_LastSample;

public:

NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj);
NTSTATUS GetData();
NTSTATUS UpdateCachedThreshold();

} PrxDevice, *PPrxDevice;



//
// Relative Fusion ------------------------------------------------------------------
//
typedef class _RelativeFusionDevice : public _ComboDevice
{
private:

QUATERNION m_CachedThresholds;
QUATERNION m_CachedData;
QUATERNION m_LastSample;

public:

NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj);
NTSTATUS GetData();
NTSTATUS UpdateCachedThreshold();

} RelativeFusionDevice, *PRelativeFusionDevice;

//
// Linear Accelerometer --------------------------------------------------------------
//
Expand All @@ -338,52 +225,34 @@ typedef class _LinearAccelerometerDevice : public _ComboDevice
public:

NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj);
NTSTATUS GetData();
NTSTATUS GetData(_In_ HANDLE Device);
NTSTATUS UpdateCachedThreshold();

} LinearAccelerometerDevice, *PLinearAccelerometerDevice;

//
// Gravity Vector --------------------------------------------------------------
//
typedef class _GravityVectorDevice : public _ComboDevice
{
private:

VEC3D m_CachedThresholds;
VEC3D m_CachedData;
VEC3D m_LastSample;

public:

NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj);
NTSTATUS GetData();
NTSTATUS UpdateCachedThreshold();

} GravityVectorDevice, *PGravityVectorDevice;

//
// Geomagnetic Orientation ------------------------------------------------------------------
// Simple Device Orientation --------------------------------------------------
//
typedef class _GeomagneticOrientationDevice : public _ComboDevice
typedef class _SimpleDeviceOrientationDevice : public _ComboDevice
{
private:

typedef struct _GeomagneticOrientationSample
typedef struct _SimpleDeviceOrientationSample
{
QUATERNION Quaternion;
FLOAT RotationAngle_Degrees;
FLOAT DeclinationAngle_Degrees;
} GeomagneticOrientationSample, *PGeomagneticOrientationSample;
FLOAT X;
BOOL Shake;
} SimpleDeviceOrientationSample, *PSimpleDeviceOrientationSample;

GeomagneticOrientationSample m_CachedThresholds;
GeomagneticOrientationSample m_CachedData;
GeomagneticOrientationSample m_LastSample;
SimpleDeviceOrientationSample m_CachedThresholds;
SimpleDeviceOrientationSample m_CachedData;
SimpleDeviceOrientationSample m_LastSample;

public:

NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj);
NTSTATUS GetData();
NTSTATUS GetData(_In_ HANDLE Device);
NTSTATUS UpdateCachedThreshold();

} GeomagneticOrientationDevice, *PGeomagneticOrientationDevice;
} SimpleDeviceOrientationDevice, *PSimpleDeviceOrientationDevice;
Loading