Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose selected driver in python binding #8

Merged
merged 2 commits into from
Mar 22, 2024
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
1 change: 1 addition & 0 deletions .github/workflows/build_arduino.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- "examples/**/*.ino"
- "src/*.h"
- "src/*.cpp"
- "!src/py_bindings.cpp"
push:
branches: [master]
paths:
Expand Down
6 changes: 5 additions & 1 deletion examples/cpython/absolute_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
PinnacleTouchI2C,
PINNACLE_SW_DR,
PINNACLE_ABSOLUTE,
PINNACLE_DRIVER,
)

print("CirquePinnacle/examples/cpython/absolute_mode")
Expand All @@ -22,7 +23,10 @@
dr_pin = PINNACLE_SW_DR # uses internal DR flag
if not input("Use SW Data Ready? [y/N] ").lower().startswith("y"):
print("-- Using HW Data Ready pin.")
dr_pin = 25 # GPIO25 (pin 22 if using MRAA driver)
if PINNACLE_DRIVER == "mraa":
dr_pin = 22 # GPIO25
else:
dr_pin = 25 # GPIO25

trackpad: Union[PinnacleTouchSPI, PinnacleTouchI2C]
if not input("Is the trackpad configured for I2C? [y/N] ").lower().startswith("y"):
Expand Down
6 changes: 5 additions & 1 deletion examples/cpython/anymeas_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
PinnacleTouchSPI,
PinnacleTouchI2C, # noqa: imported but unused
PINNACLE_ANYMEAS,
PINNACLE_DRIVER,
)

print("CirquePinnacle/examples/cpython/anymeas_mode\n")

dr_pin = 25 # GPIO25 (pin 22 if using MRAA driver)
if PINNACLE_DRIVER == "mraa":
dr_pin = 22 # GPIO25
else:
dr_pin = 25 # GPIO25

trackpad: Union[PinnacleTouchSPI, PinnacleTouchI2C]
if not input("Is the trackpad configured for I2C? [y/N] ").lower().startswith("y"):
Expand Down
6 changes: 5 additions & 1 deletion examples/cpython/relative_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
PinnacleTouchSPI,
PinnacleTouchI2C,
PINNACLE_SW_DR,
PINNACLE_DRIVER,
)

print("CirquePinnacle/examples/cpython/relative_mode\n")
Expand All @@ -20,7 +21,10 @@
dr_pin = PINNACLE_SW_DR # uses internal DR flag
if not input("Use SW Data Ready? [y/N] ").lower().startswith("y"):
print("-- Using HW Data Ready pin.")
dr_pin = 25 # GPIO25 (pin 22 if using MRAA driver)
if PINNACLE_DRIVER == "mraa":
dr_pin = 22 # GPIO25
else:
dr_pin = 25 # GPIO25

trackpad: Union[PinnacleTouchSPI, PinnacleTouchI2C]
if not input("Is the trackpad configured for I2C? [y/N] ").lower().startswith("y"):
Expand Down
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ else() # if(${PINNACLE_PY_BINDING})
utility/includes.h
${PINNACLE_DRIVER_SOURCES}
)
# expose the selected driver in the python binding
target_compile_definitions(cirque_pinnacle PUBLIC
PINNACLE_DRIVER="${PINNACLE_DRIVER}"
)

if(DEFINED PINNACLE_SPI_SPEED)
message(STATUS "PINNACLE_SPI_SPEED set to ${PINNACLE_SPI_SPEED}")
Expand Down
1 change: 1 addition & 0 deletions src/cirque_pinnacle-stubs/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from typing import List, overload

PINNACLE_SW_DR: int = ...
PINNACLE_DRIVER: str = ...

class PinnacleDataMode:
@property
Expand Down
1 change: 1 addition & 0 deletions src/py_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ void setCalibrationMatrix_wrapper(PinnacleTouch* self, py::list& matrix)
PYBIND11_MODULE(cirque_pinnacle, m)
{
m.attr("PINNACLE_SW_DR") = PINNACLE_SW_DR;
m.attr("PINNACLE_DRIVER") = PINNACLE_DRIVER;

// ******************** expose PinnacleDataMode
py::enum_<PinnacleDataMode> dataMode(m, "PinnacleDataMode");
Expand Down