Plasma 2350 W C/C++ projects

Picked up a Plasma 2350 W over the weekend with the hope of building a project with it using the C/C++ SDK. However, I’ve come to find the SDK and libraries a bit less functional than I’d expect!

Here’s my boilerplate code:

Rather than forking pico-sdk to add the new board file, I’ve set a PICO_BOARD_HEADER_DIRS in my CMakeLists.txt and added it to the project directory. I have had to fork pimoroni-pico to add the new board definitions.

Doing this:

$ mkdir build && cd build
$ cmake ..
$ make

Produces a valid UF2 and ELF. However, if I try loading it onto the Plasma 2350 W, it accepts the binary (it does a reset) but then reboots into bootloader mode again. I do have a debug probe, however I’m not quite at the point of knowing how to debug boot failures just yet (only started with the Pico a week ago).

Evidently it is possible to build C/C++ projects for the Plasma 2350 W since there’s a Micropython build available for it;) I have cribbed a few of the CMake tricks from that repository, in fact.

I guess that the pimoroni-pico libraries aren’t compatible with RP2350 … and the pimoroni-pico-rp2350 repository seems to just be Micropython builds (which do work) and not the rest of the library. So … we’re just missing a bunch of stuff needed to do C++ projects on the Pimoroni RP2350 boards?

Cribbing off what the official Pico VS Code plugin does, I added some things to my CMakeLists.txt and - magically - it now works?

I have no idea what I did to make this work! However I’m able to use the plasma library as such:

#include "pico/stdlib.h" 
#include <stdio.h>

#include "common/pimoroni_common.hpp"
#include "plasma2350.hpp"
#include "rgbled.hpp"

using namespace pimoroni;
using namespace plasma;

// Set how many LEDs you have
const uint NUM_LEDS = 66;

// The SPEED that the LEDs cycle at (1 - 255)
const uint SPEED = 5;

// How many times the LEDs will be updated per second
const uint UPDATES = 60;

RGBLED led(plasma2350::LED_R, plasma2350::LED_G, plasma2350::LED_B);
WS2812 led_strip(NUM_LEDS, pio0, 0, plasma2350::DAT, WS2812::DEFAULT_SERIAL_FREQ, false, WS2812::COLOR_ORDER::RGB);


int main() {
  // Start updating the LED strip
  led_strip.start(UPDATES);

  float offset = 0.0f;

  // Make rainbows
  while(true) {

    offset += float(SPEED) / 2000.0f;
    if (offset > 1.0) {
      offset -= 1.0;
    }

    for(auto i = 0u; i < NUM_LEDS; ++i) {
      float hue = float(i) / NUM_LEDS;
      hue += offset;
      hue -= floor(hue);
      led_strip.set_hsv(i, hue, 1.0f, 1.0f);
    }
    led.set_rgb(100, 0, 255);
    sleep_ms(1000 / UPDATES);
    led.set_rgb(0, 0, 255);
  }
}

And this does indeed make rainbows.

1 Like