digistump / DigistumpArduino

Files to add Digistump support (Digispark, Pro, DigiX) to Arduino 1.6.X (1.6.5+)
932 stars 377 forks source link

add RTS and DTR to SerialUSB #147

Open cyber-murmel opened 2 years ago

cyber-murmel commented 2 years ago

I find the control lines to be useful for out-of-band signalling e.g. for resetting a program while sending raw data as bytes over serial.

For example in this USB to OLED sketch.

#include <DigiCDC.h>
#include <DigisparkOLED.h>

void setup()
{
    SerialUSB.begin();
    oled.begin();
}

void loop()
{
    static bool rts_old = false;
    bool rts = false;

    if (SerialUSB.available()) {
        char c = SerialUSB.read();
        oled.ssd1306_send_data_byte(c);
    }

    rts = SerialUSB.getRTS();
    if (rts_old != rts) {
        rts_old = rts;
        oled.clear();
    }
}

Is this a feature you would like to merge?