Using encoders with Daisy Patch Submodule

Hi all,

I’ve just received my Daisy Patch SM and am looking to dig into my first project. As a first step I’m going to hook up an encoder and work on getting it to operate as smoothly as possible, but I’m struggling to find a simple solution for implementing the software side of things. It looks like there is an easy to use encoder implementation for the Daisy Patch but this is not implemented on the SM. Is this correct and if so, what is the ‘usual’ way to get started using an encoder with the Daisy Patch SM?

There’s nothing special about encoder usage on Patch SM. In fact, you will find very few unique things on that platform compared to regular Daisy Seed (some pins remapped, different codec, etc)

So the encoder docs would apply. I think with custom code you could get some extra precision that would allow you to detect intermediate position between encoder clicks, but it likely is not very valuable.

Thanks for your reply. That makes sense, I must be overthinking this.

So does this mean that in my code I just need to declare and initialise an Encoder to be able to use the class as it is used with the Daisy Patch?

e.g.

#include "libDaisy/src/daisy_patch_sm.h"
#include "DaisySP/Source/daisysp.h"
#include "libDaisy/src/hid/encoder.h"

using namespace daisy;
using namespace patch_sm;
using namespace daisysp;

using daisy::Encoder;

DaisyPatchSM hardware;
Encoder encoder;

int main(void) {

hardware.Init();
encoder.Init(pinA, pinB, pinClick); // These pins need to be defined

while (1)
	{
		int increment = encoder.Increment();
		if (increment == 1)
		{
			hardware.SetLed(true);
			System::Delay(100);
		}
		if (increment == -1)
		{
			hardware.SetLed(false);
			System::Delay(100);
		}
	}
}

Thanks for your time