Detect All I2C Devices
This example is a handy utility which will identify all connected I2C devices and print information on them to the console.
When the program runs it will print the address and sensor type of all the Trill sensors you currently have connected to the I2C bus.
This is particularly useful if you are unsure of the address of the sensor after changing it via the solder bridges on the back. This example will also give you a total count of the amount of Trill sensors connected to Bela.
NOTE: as this example scans several addresses on the i2c bus it could cause non-Trill peripherals connected to it to malfunction.
 
#include <libraries/Trill/Trill.h>
 
{
        unsigned int i2cBus = 1;
        printf("Trill devices detected on bus %d\n", i2cBus);
        printf("Address    | Type\n");
        unsigned int total = 0;
        for(uint8_t n = 0x20; n <= 0x50; ++n) {
                        ++total;
                }
        }
        printf("Total: %d devices\n", total);
        return true;
}
 
{
        
        rt_printf("Done\n");
}
 
{
}
Device
Definition Trill.h:31
@ NONE
No device.
Definition Trill.h:32
static const std::string & getNameFromDevice(Device device)
Definition Trill.cpp:267
static Device probe(unsigned int i2c_bus, uint8_t i2c_address)
Definition Trill.cpp:236
void Bela_requestStop()
Tell the Bela program to stop.
void render(BelaContext *context, void *userData)
User-defined callback function to process audio and sensor data.
Definition render.cpp:68
bool setup(BelaContext *context, void *userData)
User-defined initialisation function which runs before audio rendering begins.
Definition render.cpp:51
void cleanup(BelaContext *context, void *userData)
User-defined cleanup function which runs when the program finishes.
Definition render.cpp:96
Structure holding audio and sensor settings and pointers to I/O data buffers.
Definition Bela.h:231