Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoserial :) #235

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ BUILD_PATH = build
CONFIG_FILE = $(HOME)/.arduino15/arduino-cli.yaml

# Default target
all: install build
all: build

update-index:
$(ARDUINO_CLI) core update-index
Expand All @@ -28,6 +28,8 @@ install:
wget https://raw.githubusercontent.com/microsoft/uf2/master/utils/uf2conv.py
wget https://raw.githubusercontent.com/microsoft/uf2/master/utils/uf2families.json
chmod +x uf2conv.py uf2families.json
chmod +x rewrite_trinket_source.sh
./rewrite_trinket_source.sh

build:
$(ARDUINO_CLI) compile --fqbn $(BOARD) $(PROJECT_NAME) --config-file $(CONFIG_FILE) --build-path $(BUILD_PATH)
Expand Down
13 changes: 11 additions & 2 deletions VortexEngine/src/Serial/Serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "../Serial/ByteStream.h"
#include "../Time/TimeControl.h"
#include "../Time/Timings.h"
#include "../Menus/Menus.h"
#include "../Log/Log.h"

#include "../VortexEngine.h"
Expand All @@ -23,7 +24,7 @@ uint32_t SerialComs::m_lastCheck = 0;
bool SerialComs::init()
{
// Try connecting serial ?
//checkSerial();
checkSerial();
return true;
}

Expand All @@ -33,6 +34,12 @@ void SerialComs::cleanup()

bool SerialComs::isConnected()
{
#ifdef VORTEX_EMBEDDED
if (!Serial) {
m_serialConnected = false;
return false;
}
#endif
return m_serialConnected;
}

Expand Down Expand Up @@ -62,8 +69,10 @@ bool SerialComs::checkSerial()
// serial is not connected
return false;
}
// Begin serial communications
// Begin serial communications (turns out this is actually a NO-OP in trinket source)
Serial.begin(SERIAL_BAUD_RATE);
// directly open the editor connection menu because we are connected to USB serial
Menus::openMenu(MENU_EDITOR_CONNECTION);
#endif
#endif
// serial is now connected
Expand Down
3 changes: 3 additions & 0 deletions VortexEngine/src/VortexEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ void VortexEngine::runMainLogic()
// the current tick
uint32_t now = Time::getCurtime();

// check if the device has been plugged in
SerialComs::checkSerial();

// if the menus are open and running then just return
if (Menus::run()) {
return;
Expand Down
20 changes: 20 additions & 0 deletions rewrite_trinket_source.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

FILE_PATH="$HOME/.arduino15/packages/adafruit/hardware/samd/1.7.14/cores/arduino/USB/CDC.cpp"

# Check if the file exists
if [ ! -f "$FILE_PATH" ]; then
echo "Error: File does not exist."
fi
# Read the specific line and check its content
CURRENT_LINE=$(sed -n '258p' "$FILE_PATH")

if [ "$CURRENT_LINE" != " delay(10);" ]; then
echo "No changes made: line 258 does not match the expected content or has already been modified."
exit 0
fi

# Replace the content of line 258
sed -i '258s/.*/ \/\/delay(10);/' "$FILE_PATH"

echo "Line 258, a delay(10), has been commented out in: [$FILE_PATH]"