polemixing_RP2350_12nov2026 — Xiao Rp2350 simulation

An interactive Xiao Rp2350 circuit simulation you can run free in your browser on Velxio, by bwei.

Components

Sketch code

//#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Fonts/FreeMonoBold12pt7b.h>
//#include <Encoder.h>
#include <stdio.h>
#include "pico/stdlib.h"
#include "hardware/gpio.h"
#include "hardware/timer.h"

// Safe alternative to #define Serial Serial1:
HardwareSerial& DebugSerial = Serial1;

#define SCREEN_WIDTH  128
#define SCREEN_HEIGHT 64
#define OLED_RESET    -1
#define OLED_ADDRESS  0x3C

// Hardware Pin Definitions for RP2350
#define PIN_CUTOFF     26 // ADC0 (Potentiometer 1)
#define PIN_RESONANCE  27 // ADC1 (Potentiometer 2)
#define PIN_CLK  2  // Quadrature Encoder A CLK   D8(2)
#define PIN_DT  3  // Quadrature Encoder B DT    D10(3)
#define PIN_SW 4 // Encoder Click Switch  D9(4)


Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire1, OLED_RESET);//RP2350 wire1; RP2040 Wire (default=0)

// Menu Selection Classification
uint8_t current_Menu_Selected = 0; // 0=PoleMix1 ; 1=PoleMix2
const uint8_t nbTOTAL_Menu = 3;

// Filter Shape Classification
enum FilterShape {
    SHAPE_LOWPASS,
    SHAPE_HIGHPASS,
    SHAPE_BANDPASS,
    SHAPE_NOTCH,
    SHAPE_ALLPASS,
    SHAPE_HP_LP,
    SHAPE_ResNOTCH,
    SHAPE_NOTCHRes,
    SHAPE_LP_NOTCH
};

struct FilterMode {
    const char* name;
    FilterShape shape;
    uint8_t pole_beforeCutoff;
    uint8_t pole_afterCutoff;
};

// Oberheim Matrix-12 / Xpander Inspired Response Types
const FilterMode FILTER_MODES[] = {
    {"LP1",   SHAPE_LOWPASS,  1,1},
    {"LP2",   SHAPE_LOWPASS,  2,2},
    {"LP3",   SHAPE_LOWPASS,  3,3},
    {"LP4",   SHAPE_LOWPASS,  4,4},
    {"HP1",   SHAPE_HIGHPASS, 1,1},
    {"HP1+LP2",   SHAPE_HP_LP, 1,2},
    {"HP1+LP3",   SHAPE_HP_LP, 1,3},
    {"HP2+LP1",   SHAPE_HP_LP, 2,1},
    {"HP3+LP1",   SHAPE_HP_LP, 3,1},
    {"HP2",   SHAPE_HIGHPASS, 2,2},
    {"HP3",   SHAPE_HIGHPASS, 3,3},
    {"HP4",   SHAPE_HIGHPASS, 4,4},
    {"BP2",   SHAPE_BANDPASS, 2,2},
    {"BP4",   SHAPE_BANDPASS, 4,4},
    {"NO2",     SHAPE_NOTCH,    2,2},
    {"NO4",     SHAPE_NOTCH,    4,4},
    {"Res+N",     SHAPE_ResNOTCH,    4,4},
    {"N+Res",     SHAPE_NOTCHRes,    4,4},
    {"LP1+NOA",     SHAPE_LP_NOTCH,    1,4},
    {"AP3",     SHAPE_ALLPASS,  3,3},
    {"AP4",   SHAPE_ALLPASS,  4,4}
};

const uint8_t TOTAL_MODES = sizeof(FILTER_MODES) / sizeof(FILTER_MODES[0]);
volatile uint8_t currentModeIndex = 0;
volatile uint8_t currentModeIndex2 = 0;

// Encoder Button Management
typedef enum {
    PRESS_NONE = 0,
    PRESS_SHORT,
    PRESS_LONG,
    PRESS_HOLD
} PressType;


// Volatile variables modified by ISRs/Timers for the main program
volatile int encoder_direction = 0;       // 1 for CW, -1 for CCW, 0 for idle/no change
volatile PressType current_press_type = PRESS_NONE;

    int lastStateCLK;
    int currentStateCLK;

// Button state tracking
static volatile uint32_t press_start_time = 0;
static volatile bool is_button_down = false;
static alarm_id_t hold_alarm_id = 0;

// Forward declaration of alarm callback
int64_t button_hold_callback(

More projects by bwei