Skip to content

Commit

Permalink
fix for lock and sleep toggles
Browse files Browse the repository at this point in the history
  • Loading branch information
Unreal-Dan committed Jul 24, 2023
1 parent 62df5c8 commit 1a6a801
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 17 deletions.
7 changes: 7 additions & 0 deletions VortexTestingFramework/TestFramework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,13 @@ bool TestFramework::init(HINSTANCE hInstance)

// TODO: storage enabled tickbox?
//Vortex::enableStorage(true);
//Vortex::setStorageFilename(m_storageFile);
//if (access(m_storageFile.c_str(), F_OK) == 0) {
// // load storage if the file exists
// Vortex::loadStorage();
//}
Vortex::setSleepEnabled(true);
Vortex::setLockEnabled(true);

// hardcoded switch optimizes to a single call based on engine led count
switch (LED_COUNT) {
Expand Down
10 changes: 9 additions & 1 deletion VortexTestingFramework/TestFrameworkLinux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ TestFramework::TestFramework() :
m_record(false),
m_storage(false),
m_sleepEnabled(true),
m_lockEnabled(true),
m_storageFile("FlashStorage.flash"),
m_patternIDStr(),
m_colorsetStr(),
Expand All @@ -171,6 +172,7 @@ static struct option long_options[] = {
{"in-place", no_argument, nullptr, 'i'},
{"record", no_argument, nullptr, 'r'},
{"autowake", no_argument, nullptr, 'a'},
{"nolock", no_argument, nullptr, 'n'},
{"storage", optional_argument, nullptr, 's'},
{"pattern", required_argument, nullptr, 'P'},
{"colorset", required_argument, nullptr, 'C'},
Expand Down Expand Up @@ -216,6 +218,7 @@ static void print_usage(const char* program_name)
fprintf(stderr, " -i, --in-place Print the output in-place (interactive mode)\n");
fprintf(stderr, " -r, --record Record the inputs and dump to a file after (" RECORD_FILE ")\n");
fprintf(stderr, " -a, --autowake Automatically and instantly wake on sleep (disable sleep)\n");
fprintf(stderr, " -n, --nolock Automatically unlock upon locking the chip (disable lock)\n");
fprintf(stderr, " -s, --storage [file] Persistent storage to file (default file: FlashStorage.flash)\n");
fprintf(stderr, "\n");
fprintf(stderr, "Initial Pattern Options (optional):\n");
Expand Down Expand Up @@ -294,7 +297,7 @@ bool TestFramework::init(int argc, char *argv[])

int opt = -1;
int option_index = 0;
while ((opt = getopt_long(argc, argv, "xctlirasP:C:A:h", long_options, &option_index)) != -1) {
while ((opt = getopt_long(argc, argv, "xctliransP:C:A:h", long_options, &option_index)) != -1) {
switch (opt) {
case 'x':
// if the user wants pretty colors or hex codes
Expand Down Expand Up @@ -324,6 +327,10 @@ bool TestFramework::init(int argc, char *argv[])
// autuowake prevents sleep
m_sleepEnabled = false;
break;
case 'n':
// disable the lock
m_lockEnabled = false;
break;
case 's':
// enable persistent storage to file
m_storage = true;
Expand Down Expand Up @@ -382,6 +389,7 @@ bool TestFramework::init(int argc, char *argv[])
}
}
Vortex::setSleepEnabled(m_sleepEnabled);
Vortex::setLockEnabled(m_lockEnabled);

if (m_patternIDStr.length() > 0) {
PatternID id = (PatternID)strtoul(m_patternIDStr.c_str(), nullptr, 10);
Expand Down
1 change: 1 addition & 0 deletions VortexTestingFramework/TestFrameworkLinux.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class TestFramework
bool m_record;
bool m_storage;
bool m_sleepEnabled;
bool m_lockEnabled;
std::string m_storageFile;
std::string m_patternIDStr;
std::string m_colorsetStr;
Expand Down
2 changes: 1 addition & 1 deletion VortexTestingFramework/VortexEngine
29 changes: 15 additions & 14 deletions VortexTestingFramework/tests/create_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ YELLOW="$(tput setaf 3)"
WHITE="$(tput setaf 7)"
NC="$(tput sgr0)" # No Color

INTERACTIVE=1
# manual mode for losers
if [ "$1" == "-m" ]; then
INTERACTIVE=0
fi

NOMAKE=0
if [ "$1" == "-n" ]; then
NOMAKE=1
fi
for arg in "$@"
do
if [ "$arg" == "-m" ]; then
INTERACTIVE=0
fi
if [ "$arg" == "-n" ]; then
NOMAKE=1
fi
done

REPOS=(
"core"
Expand Down Expand Up @@ -188,10 +187,12 @@ while true; do
#git add $TEST_FILE

# run again?
echo -n "${YELLOW}Create another test? (y/N): ${WHITE}"
read -e CONFIRM
if [[ $CONFIRM != [yY] && $CONFIRM != [yY][eE][sS] ]]; then
exit
if [ $INTERACTIVE -ne 1 ]; then
echo -n "${YELLOW}Create another test? (y/N): ${WHITE}"
read -e CONFIRM
if [[ $CONFIRM != [yY] && $CONFIRM != [yY][eE][sS] ]]; then
exit
fi
fi

# end while true
Expand Down
2 changes: 1 addition & 1 deletion VortexTestingFramework/tests/make_pattern_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ patterns=(0)
colorsets=("red" "red,green" "red,green,blue")
max_args=5
max_value=3
create_test_script_path="./create_test.sh -n" # Update the path to your create_test.sh script if needed
create_test_script_path="./create_test.sh -n -m" # Update the path to your create_test.sh script if needed

# 1 core
# 2 gloves
Expand Down

0 comments on commit 1a6a801

Please sign in to comment.