Hi Giulio, the render script you created to bring the raw values of the pressure sensor module into Pure Data is working very well.
I tried to modify the script to read 6 modules for my project, but I don't know how to code in C++.
Would it be possible for you to modify the script to get the raw values for 6 modules instead of one?
My Bela digital I/O's are all available. I would set up the sensors on a protoboard to test it out. Thanks!
Update
I asked chatgpt to modify the script to read the 6 sensors and it worked. I will now be able to complete my project on the Pd side.
Thanks again for all the help!!
For reference, here is what it came with:
#include <Bela.h>
#include <libraries/BelaLibpd/BelaLibpd.h>
#include "Hx710.h"
Hx710 hx710[6];
const unsigned int kClockPins[6] = {0, 2, 4, 6, 8, 10};
const unsigned int kDataPins[6] = {1, 3, 5, 7, 9, 11};
void Bela_userSettings(BelaInitSettings *settings)
{
settings->uniformSampleRate = 1;
settings->interleave = 0;
settings->analogOutputsPersist = 0;
}
bool setup(BelaContext* context, void* userData)
{
for(int i = 0; i < 6; i++) {
hx710[i].setup(context, kDataPins[i], kClockPins[i]);
}
return BelaLibpd_setup(context, userData, {});
}
void render(BelaContext* context, void* userData)
{
for(int i = 0; i < 6; i++) {
bool dataReady = hx710[i].process(context);
if(dataReady)
{
std::string receiverName = "hx710_" + std::to_string(i);
libpd_float(receiverName.c_str(), hx710[i].getData());
}
}
BelaLibpd_render(context, userData);
}
void cleanup(BelaContext* context, void* userData)
{
BelaLibpd_cleanup(context, userData);
}