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

Support for Trill capacitive sensors #657

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ add_library(daisy STATIC
${MODULE_DIR}/dev/lcd_hd44780.cpp
${MODULE_DIR}/dev/sdram.cpp
${MODULE_DIR}/dev/sr_595.cpp
${MODULE_DIR}/dev/trill/Trill.cpp
${MODULE_DIR}/dev/trill/CentroidDetection.cpp
${MODULE_DIR}/hid/audio.cpp
${MODULE_DIR}/hid/ctrl.cpp
${MODULE_DIR}/hid/encoder.cpp
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ dev/codec_ak4556 \
dev/codec_pcm3060 \
dev/codec_wm8731 \
dev/lcd_hd44780 \
dev/trill/Trill \
dev/trill/CentroidDetection \
dev/sdram \
hid/ctrl \
hid/encoder \
Expand Down
12 changes: 12 additions & 0 deletions examples/Trill-Craft/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Project Name
TARGET = Trill

# Sources
CPP_SOURCES = Trill-Craft.cpp

# Library Locations
LIBDAISY_DIR = ../..

# Core location, and generic Makefile.
SYSTEM_FILES_DIR = $(LIBDAISY_DIR)/core
include $(SYSTEM_FILES_DIR)/Makefile
41 changes: 41 additions & 0 deletions examples/Trill-Craft/Trill-Craft.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Read Trill craft capacitive sensor
*/

#include "daisy_seed.h"
#include "dev/trill/Trill.h"

using namespace daisy;

DaisySeed hw;

int main(void)
{
// Initialize the Daisy Seed
hw.Init();

// Start the Serial Logger
hw.StartLog();

// Create a Trill object
Trill trill;

// Initialize the Trill object
int i2cBus = 1; // only 1 and 4 are properly mapped to pins on the Seed
int ret = trill.setup(i2cBus, Trill::CRAFT);
if(ret)
hw.PrintLine("trill.setup() returned %d", ret);

// loop forever
while(1)
{
hw.DelayMs(100);
trill.readI2C();
for(auto &x : trill.rawData)
{
hw.Print("%d ", int(x * 100000.f));
}
hw.PrintLine("");
}
return 0;
}
12 changes: 12 additions & 0 deletions examples/Trill/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Project Name
TARGET = Trill

# Sources
CPP_SOURCES = Trill.cpp

# Library Locations
LIBDAISY_DIR = ../..

# Core location, and generic Makefile.
SYSTEM_FILES_DIR = $(LIBDAISY_DIR)/core
include $(SYSTEM_FILES_DIR)/Makefile
52 changes: 52 additions & 0 deletions examples/Trill/Trill.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Read Trill capacitive sensor
*/

#include "daisy_seed.h"
#include "dev/trill/Trill.h"

using namespace daisy;
using namespace daisy::seed;

DaisySeed hw;

void AudioCallback(AudioHandle::InputBuffer in,
AudioHandle::OutputBuffer out,
size_t size)
{
//
}

int main(void)
{
// Initialize the Daisy Seed
hw.Init();

// Start the Serial Logger
hw.StartLog();

/** Start the Audio engine, and call the "AudioCallback" function to fill new data */
hw.StartAudio(AudioCallback);

// Create a Trill object
Trill trill;

// Initialize the Trill object
int i2cBus = 1; // only 1 and 4 are properly mapped to pins on the Seed
int ret = trill.setup(i2cBus, Trill::BAR);
if(ret)
hw.Print("trill.setup() returned %d\n", ret);

// loop forever
while(1)
{
trill.readI2C();
if(trill.getNumTouches())
{
for(size_t n = 0; n < trill.getNumTouches(); ++n)
hw.Print(
"%.3f (%.2f) ", trill.touchLocation(n), trill.touchSize(n));
hw.Print("\n");
}
}
}
Loading