buttplug-csharp
buttplug-csharp copied to clipboard
Arduino serial device
Added a simple serial device that can interface with an Arduino for DIY sex toys. The device accepts SingleMotorVibrate commands. Not sure if this is worthy of a merge, or how much more effort it would take to make it worthy, so consider this a proposal for discussion. The corresponding Arduino code (in my case) looks something like this:
// pin for enabling the DC motor controller
const int enablePin = 12;
// pin for providing a PWM signal to the motor controller
const int motorPin = 14;
const int min_speed = 100;
const int max_speed = 1000;
const int cmd_ack = 0x01;
const int cmd_enable = 0x02;
const int cmd_disable = 0x03;
const int cmd_speed = 0x04;
void setup() {
Serial.begin(115200);
pinMode(motorPin, OUTPUT);
pinMode(enablePin, OUTPUT);
digitalWrite(enablePin, LOW);
}
void loop() {
if (Serial.available() > 0) {
int incomingByte = Serial.read();
switch(incomingByte){
case cmd_ack:
Serial.write(cmd_ack);
Serial.flush();
break;
case cmd_enable:
digitalWrite(enablePin, HIGH);
break;
case cmd_disable:
digitalWrite(enablePin, LOW);
break;
case cmd_speed:
while(Serial.available() == 0) {
delay(1);
}
int speed = Serial.read();
if (speed == 0) {
analogWrite(motorPin, 0);
}
else {
int val = (speed / 255.0) * (max_speed - min_speed) + min_speed;
analogWrite(motorPin, val);
}
break;
}
}
}
Codecov Report
Merging #353 into master will increase coverage by
0.03%. The diff coverage is0%.
@@ Coverage Diff @@
## master #353 +/- ##
==========================================
+ Coverage 70.85% 70.89% +0.03%
==========================================
Files 94 94
Lines 6228 6229 +1
Branches 443 443
==========================================
+ Hits 4413 4416 +3
+ Misses 1657 1655 -2
Partials 158 158
| Impacted Files | Coverage Δ | |
|---|---|---|
| ...lug.Components.Controls/ButtplugTabControl.xaml.cs | 29.87% <0%> (+1.65%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 7b3bec6...8de5ab3. Read the comment docs.
It's taken almost a year, but we're close to having this be possible. I'm working on abstracted protocols now in #453 and #559, after which I'll be working with people building hardware to discuss a simple format for a generic-message-only (vibrate/rotate/linear) hardware protocol.
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.
And 3 years later, this is actually doable via our websocket device system that I just finished documenting in our dev docs (see the Inflating buttplug portion of the dev guide at https://docs.buttplug.io) . Closing this.