-
Notifications
You must be signed in to change notification settings - Fork 0
Options.md
Ready to tweak Bang to fit your Arduino’s command-line domination? This page covers the configuration options for Bang, letting you fine-tune Serial-USB communication, arduino_exec.py, and the Bang class for your ! (shell), & (sketch uploads), and @ (macro) commands. From baud rates to macro setups, these settings keep your Arduino lean and mean while maximizing flexibility. Let’s crank up the power and make Bang your own!
- Purpose: Configure Bang’s behavior on Arduino and host.
-
Components:
-
Arduino Side:
Bangclass stream setup (single/dual streams). -
Host Side:
arduino_exec.pyoptions (baud rate, serial port, macro dictionary).
-
Arduino Side:
-
Key Options:
- Serial baud rate (default: 38400).
- Serial port selection.
- Single vs. dual stream setup.
- Predefined macros in
arduino_exec.py.
-
Description: Sets the Serial-USB communication speed between Arduino and host.
-
Default: 38400 baud.
-
Arduino Side:
-
Set in sketch:
void setup() { Serial.begin(38400); // Change to 9600, 115200, etc. while (!Serial) ; }
-
-
Host Side:
- Match in
arduino_exec.py:-
macOS/Linux:
sudo python3 arduino_exec.py -p /dev/cu.usbserial-00100 -b 38400
-
Windows:
sudo python3 arduino_exec.py -p COM3 -b 38400
Run PowerShell as administrator.
-
- Use
-bto change (e.g.,-b 9600).
- Match in
-
Tip: Ensure Arduino and
arduino_exec.pyuse the same baud rate.
-
Description: Specifies the Serial-USB port for Arduino-host communication.
-
Default: Depends on system (e.g.,
/dev/cu.usbserial-00100on macOS/Linux,COM3on Windows). -
Arduino Side:
-
Set in Arduino IDE (Tools > Port) or sketch for dual streams:
SoftwareSerial cmd_serial(10, 11); // RX, TX for FTDI module Bang bang(cmd_serial, Serial); cmd_serial.begin(38400);
-
-
Host Side:
- Set in
arduino_exec.py:-
macOS/Linux:
sudo python3 arduino_exec.py -p /dev/cu.usbserial-00100 -b 38400
-
Windows:
sudo python3 arduino_exec.py -p COM3 -b 38400
Run PowerShell as administrator.
-
- Find port:
- macOS/Linux:
ls /dev/cu.*orls /dev/tty.*. - Windows: Check Device Manager for COM ports.
- macOS/Linux:
- Set in
-
Description: Configures whether Bang uses one stream (Serial) or two (e.g., SoftwareSerial + Serial).
-
Default: Single stream (
Bang bang(Serial);). -
Single Stream:
#include <Bang.h> Bang bang(Serial); // Commands and output via Serial
-
Dual Streams (e.g., with FTDI module):
#include <SoftwareSerial.h> SoftwareSerial cmd_serial(10, 11); // RX, TX Bang bang(cmd_serial, Serial); // Commands via cmd_serial, output via Serial
-
Tip: Use dual streams for separate command/output channels, but single stream is simpler.
-
Description: Sets initial macros in
arduino_exec.py’s in-memorymacrosdictionary. -
Default: Empty dictionary (
macros = {}). -
Configuration:
-
Add to
arduino_exec.py:macros = { 'play': 'osascript -e "tell application \"Music\" to play"', 'pause': 'osascript -e "tell application \"Music\" to pause"', 'weather': 'curl wttr.in?format=3' }
-
-
Dynamic Management:
- Add:
BANG("@add_macro:reboot:reboot"). - Delete:
BANG("@delete_macro:reboot"). - List:
BANG("@list_macros").
- Add:
-
Note: Macros reset on
arduino_exec.pyrestart (no file-based storage). -
Tip: Predefine common macros to save Arduino commands.
-
Arduino:
- Update sketch with new baud rate or stream setup.
- Upload via Arduino IDE (Tools > Upload).
-
Host:
- Stop
arduino_exec.py(Ctrl+C). - Edit for macros or options.
- Restart:
-
macOS/Linux:
sudo python3 arduino_exec.py -p /dev/cu.usbserial-00100 -b 38400
-
Windows:
sudo python3 arduino_exec.py -p COM3 -b 38400
Run PowerShell as administrator.
-
- Stop
-
Baud Mismatch: Ensure Arduino and
arduino_exec.pyuse the same baud rate. -
Wrong Port: Verify port in Arduino IDE and
arduino_exec.py. -
Macro Reset: Redefine macros after restarting
arduino_exec.py. - See Troubleshooting for more fixes.
- Check Performance for optimizing Bang.
- Explore Examples for configured sketches.
- See FAQ for option questions.