Hello,
I am continuing my work to bring up my new piece of hardware based partially off the DaisyFeild where at this point I have pulled all the code out expect for the code that supports the LED drivers. In order to check functionality I am running on the DaisyField first and then running it on my hardware as I bring it up. When doing this initial bit of work I ended up commenting out the line:
hw.Configure();
Why did I comment it out?
After looking at the code in the DaisyField setup, it did not look like there was a function created in the DaisyField.cpp for the function.
Here is the error when I leave the line in:
Blink.cpp:20:8: error: 'class daisy::Gr8Seq16' has no member named 'Configure'
20 | hw.Configure();
| ^~~~~~~~~
make: *** [../../libdaisy/core/Makefile:232: build/Blink.o] Error 1
In looking back at the daisy_field.h and daisy_field.cpp it does not have any specific ::Configuration code. I do not get the compilation error with th daisy_field, but I do with my code below.
Any thoughts or help here would be appreicated.
Here is my BSP header
#pragma once
#ifndef GR8_SEQ16_BSP_H
#define GR8_SEQ16_BSP_H /**< & */
#include "daisy_seed.h"
/**
@brief Hardware defines and helpers for daisy field platform.
*/
namespace daisy
{
/** @addtogroup boards
@{
*/
class Gr8Seq16
{
public:
/** enums for controls, etc.
*/
enum
{
LED_KEY_B1, /**< & */
LED_KEY_B2, /**< & */
LED_KEY_B3, /**< & */
LED_KEY_B4, /**< & */
LED_KEY_B5, /**< & */
LED_KEY_B6, /**< & */
LED_KEY_B7, /**< & */
LED_KEY_B8, /**< & */
LED_KEY_A8, /**< & */
LED_KEY_A7, /**< & */
LED_KEY_A6, /**< & */
LED_KEY_A5, /**< & */
LED_KEY_A4, /**< & */
LED_KEY_A3, /**< & */
LED_KEY_A2, /**< & */
LED_KEY_A1, /**< & */
LED_KNOB_1, /**< & */
LED_KNOB_2, /**< & */
LED_KNOB_3, /**< & */
LED_KNOB_4, /**< & */
LED_KNOB_5, /**< & */
LED_KNOB_6, /**< & */
LED_KNOB_7, /**< & */
LED_KNOB_8, /**< & */
LED_SW_1, /**< & */
LED_SW_2, /**< & */
LED_LAST /**< & */
};
Gr8Seq16() {}
~Gr8Seq16() {}
/**Initializes the Daisy Field, and all of its hardware.*/
void Init(bool boost = false);
/**
Wait some ms before going on.
\param del Delay time in ms.
*/
void DelayMs(size_t del);
/** Starts the callback
\cb Interleaved callback function
*/
void StartAudio(AudioHandle::InterleavingAudioCallback cb);
/** Starts the callback
\cb multichannel callback function
*/
void StartAudio(AudioHandle::AudioCallback cb);
/** Stops the audio if it is running. */
void StopAudio();
/**
Switch callback functions
\param cb New interleaved callback function.
*/
void ChangeAudioCallback(AudioHandle::InterleavingAudioCallback cb);
/**
Switch callback functions
\param cb New multichannel callback function.
*/
void ChangeAudioCallback(AudioHandle::AudioCallback cb);
/** Updates the Audio Sample Rate, and reinitializes.
** Audio must be stopped for this to work.
*/
void SetAudioSampleRate(SaiHandle::Config::SampleRate samplerate);
/** Returns the audio sample rate in Hz as a floating point number.
*/
float AudioSampleRate();
/** Sets the number of samples processed per channel by the audio callback.
*/
void SetAudioBlockSize(size_t blocksize);
/** Returns the number of samples per channel in a block of audio. */
size_t AudioBlockSize();
/** Returns the rate in Hz that the Audio callback is called */
float AudioCallbackRate();
/**Light show, cycling through all LEDs, and OLED
**/
void VegasMode();
DaisySeed seed;
dsy_gpio gate_out;
LedDriverPca9685<2, true> led_driver;
private:
uint32_t last_led_update_; // for vegas mode
};
/** @} */
} // namespace daisy
#endif
Here is my BSP CPP file:
#include "gr8_seq16.h"
#ifndef SAMPLE_RATE
#define SAMPLE_RATE DSY_AUDIO_SAMPLE_RATE /**< & */
#endif
using namespace daisy;
static constexpr I2CHandle::Config field_led_i2c_config
= {I2CHandle::Config::Peripheral::I2C_1,
{{DSY_GPIOB, 8}, {DSY_GPIOB, 9}},
I2CHandle::Config::Speed::I2C_1MHZ};
static LedDriverPca9685<2, true>::DmaBuffer DMA_BUFFER_MEM_SECTION
field_led_dma_buffer_a,
field_led_dma_buffer_b;
void Gr8Seq16::Init(bool boost)
{
seed.Configure();
seed.Init(boost);
seed.SetAudioBlockSize(48);
// LEDs
// 2x PCA9685 addresses 0x00, and 0x02
uint8_t addr[2] = {0x00, 0x02};
I2CHandle i2c;
i2c.Init(field_led_i2c_config);
led_driver.Init(i2c, addr, field_led_dma_buffer_a, field_led_dma_buffer_b);
}
void Gr8Seq16::DelayMs(size_t del)
{
seed.DelayMs(del);
}
void Gr8Seq16::StartAudio(AudioHandle::InterleavingAudioCallback cb)
{
seed.StartAudio(cb);
}
void Gr8Seq16::StartAudio(AudioHandle::AudioCallback cb)
{
seed.StartAudio(cb);
}
void Gr8Seq16::StopAudio()
{
seed.StopAudio();
}
void Gr8Seq16::ChangeAudioCallback(AudioHandle::InterleavingAudioCallback cb)
{
seed.ChangeAudioCallback(cb);
}
void Gr8Seq16::ChangeAudioCallback(AudioHandle::AudioCallback cb)
{
seed.ChangeAudioCallback(cb);
}
void Gr8Seq16::SetAudioSampleRate(SaiHandle::Config::SampleRate samplerate)
{
seed.SetAudioSampleRate(samplerate);
}
float Gr8Seq16::AudioSampleRate()
{
return seed.AudioSampleRate();
}
void Gr8Seq16::SetAudioBlockSize(size_t size)
{
seed.SetAudioBlockSize(size);
}
size_t Gr8Seq16::AudioBlockSize()
{
return seed.AudioBlockSize();
}
float Gr8Seq16::AudioCallbackRate()
{
return seed.AudioCallbackRate();
}
void Gr8Seq16::VegasMode()
{
uint32_t now;
now = seed.system.GetNow();
size_t idx;
float key_bright;
// Cycle all 16 LEDs on keyboard SM in opposite pattern or something
uint8_t led_grp_a[] = {LED_KEY_A8,
LED_KEY_A7,
LED_KEY_A6,
LED_KEY_A5,
LED_KEY_A4,
LED_KEY_A3,
LED_KEY_A2,
LED_KEY_A1};
uint8_t led_grp_b[] = {LED_KEY_B8,
LED_KEY_B7,
LED_KEY_B6,
LED_KEY_B5,
LED_KEY_B4,
LED_KEY_B3,
LED_KEY_B2,
LED_KEY_B1};
uint8_t led_grp_c[] = {LED_KNOB_1,
LED_KNOB_2,
LED_KNOB_3,
LED_KNOB_4,
LED_KNOB_5,
LED_KNOB_6,
LED_KNOB_7,
LED_KNOB_8};
if(now - last_led_update_ > 10)
{
idx = (now >> 10) % 8;
key_bright = (float)(now & 1023) / 1023.0f;
// Clear
for(size_t i = 0; i < LED_LAST; i++)
{
led_driver.SetLed(i, 0.0f);
}
// Knob LEDs dance in order
led_driver.SetLed(led_grp_a[idx], key_bright);
led_driver.SetLed(led_grp_b[idx], 1.0f - key_bright);
led_driver.SetLed(led_grp_c[idx], key_bright);
led_driver.SwapBuffersAndTransmit();
}
}
Here is my “Blink.cpp”
#include "gr8_seq16.h"
// Use the daisy namespace to prevent having to type
// daisy:: before all libdaisy functions
using namespace daisy;
// Declare a DaisySeed object called hardware
Gr8Seq16 hw;
int main(void)
{
// Declare a variable to store the state we want to set for the LED.
// bool led_state;
// led_state = true;
// Configure and Initialize the Daisy Seed
// These are separate to allow reconfiguration of any of the internal
// components before initialization.
hw.Configure();
hw.Init();
// Loop forever
for(;;)
{
// Set the onboard LED
// hw.SetLed(led_state);
hw.VegasMode();
// Toggle the LED state for the next time around.
// led_state = !led_state;
// Wait 500ms
System::Delay(500);
}
}
If you have any suggestions/comments on:
- is the function needed
- if so, what am I missing to make sure it works
Thank you for your time and help,
Brett