Config management mode, to send/receive config via usb midi sysex

This commit is contained in:
John Stäck 2019-07-29 15:44:43 +02:00
parent db4e4ac2f7
commit 2741ff5a27
8 changed files with 316 additions and 28 deletions

View file

@ -21,7 +21,7 @@
// Forward declarations
static void SimQuit(void);
static int SimInit(void);
static int SimRun(std::string eepromFile, bool eepromWrite, bool factoryReset);
static int SimRun(std::string eepromFile, bool eepromWrite, bool factoryReset, bool ConfigMode);
static void SimLoop(std::function<bool()>, std::function<void()>);
@ -39,6 +39,8 @@ static const int scale = 3;
static SDL_Window *window;
bool no_delay = false;
void _reboot_Teensyduino_()
{
// TODO: reboot
@ -81,6 +83,8 @@ uint8_t digitalRead(uint8_t pin) {
void delay(unsigned int ms)
{
if(no_delay) return;
uint32_t endTick = SDL_GetTicks() + ms;
auto checktime = [endTick]() -> bool { return endTick > SDL_GetTicks(); };
SimLoop(checktime,NULL);
@ -508,7 +512,7 @@ static void SimLoop(std::function<bool()> continue_predicate, std::function<void
}
}
static int SimRun(std::string eepromFile, bool eepromWrite, bool factoryReset)
static int SimRun(std::string eepromFile, bool eepromWrite, bool factoryReset, bool configMode)
{
if( 0 != SimInit() ) { return 1; }
@ -523,11 +527,19 @@ static int SimRun(std::string eepromFile, bool eepromWrite, bool factoryReset)
digitalInputs[ePin] = 0;
}
//Go into config management mode. This should not happen (in NuEVI) if factory reset is done
if(configMode) {
digitalInputs[uPin] = 0;
digitalInputs[dPin] = 0;
}
setup();
//Let it go, let it go, not resetting any more
digitalInputs[mPin] = 1;
digitalInputs[ePin] = 1;
digitalInputs[uPin] = 1;
digitalInputs[dPin] = 1;
SimLoop( []() -> bool { return true; }, loop );
SimQuit();
@ -583,7 +595,7 @@ static int SimInit()
analogInputs[vMeterPin] = 3025;
// Initialize touch sensors to not be poked
// Initialize touch sensors to not be poked
for(int i = 0; i < 12; ++i) {
touchSensor.mockFilteredData(i, 4095);
}
@ -616,6 +628,8 @@ int main(int argc, const char** argv)
args::ValueFlag<std::string> eepromFile(parser, "eeprom-write", "File to use for EEPROM data", {'e', "eeprom-file"});
args::Flag eepromWrite(parser, "eeprom-write", "Write EEPROM changes to file", {'w', "eeprom-write"});
args::Flag factoryReset(parser, "factory-reset", "Trigger factory reset", {'r', "factory-reset"});
args::Flag configMode(parser, "config-mode", "Trigger config-management mode", {'c', "config-mode"});
args::Flag nodelay(parser, "nodelay", "Skip all delays when running", {'n', "nodelay"});
parser.ParseCLI(argc, argv);
@ -628,5 +642,7 @@ int main(int argc, const char** argv)
eepromFileName += "eeprom.bin";
}
return SimRun(eepromFileName, args::get(eepromWrite), args::get(factoryReset));
no_delay = args::get(nodelay);
return SimRun(eepromFileName, args::get(eepromWrite), args::get(factoryReset), args::get(configMode));
}