Skip to content

Commit 324daf7

Browse files
committed
add: Q reloads sketch in Run Mode
1 parent 813381d commit 324daf7

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

docs/commands.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
| --- | -------------------------------------------- |
2121
| h | Shows this information. |
2222
| q | Quits Run Mode. Switches back to Admin Mode. |
23+
| Q | Reloads sketch. |
2324
| w | Toggles window layout mode. |
2425

2526
### Step/Go-to

simuino.c

+29-6
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,24 @@ void cmdLoop()
384384
stop = atoi(command[1]);
385385
stop = checkRange(HEAL, "step", stop);
386386

387-
runMode(stop);
388-
if (stop == 0)
389-
putMsg(2, "Back in Admin Mode!");
387+
while (1)
388+
{
389+
int status = runMode(stop);
390+
391+
if (status == 1)
392+
{
393+
// reload sketch (Q)
394+
g_scenSource = 0;
395+
loadCurrentSketch();
396+
}
397+
else
398+
{
399+
// quit runMode (q)
400+
break;
401+
}
402+
}
403+
404+
if (stop == 0) putMsg(2, "Back in Admin Mode!");
390405
}
391406
else if (strstr(sstr, "res")) // reset simulation
392407
{
@@ -647,7 +662,7 @@ void cmdLoop()
647662
}
648663
}
649664

650-
void runMode(int stop)
665+
int runMode(int stop)
651666
{
652667
int step, res = 0, ok = 0;
653668
char ch, tempName[80], syscom[120], temp[80];
@@ -662,7 +677,8 @@ void runMode(int stop)
662677
stop = g_steps;
663678
//if(stop > currentStep)
664679
runAll(stop);
665-
return;
680+
// quit runMode
681+
return 0;
666682
}
667683

668684
putMsg(3, "Run Mode. Press h for help.");
@@ -683,8 +699,13 @@ void runMode(int stop)
683699
switch (ch)
684700
{
685701
case 'q':
686-
return;
702+
// quit runMode
703+
return 0;
704+
case 'Q':
705+
// reload sketch
706+
return 1;
687707
case 'h':
708+
// help
688709
readMsg(fileInfoRun);
689710
break;
690711
case 'i':
@@ -866,6 +887,8 @@ putMsg(2,syscom);
866887
putMsg(msg_h - 2, temp);
867888
}
868889
}
890+
891+
return 0;
869892
}
870893

871894
int main(/* int argc, char *argv[] */)

simuino.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ void mLog1(const char *p, int value1);
99
void wLog1(const char *p, int value1);
1010
void wLog2(const char *p, int value1, int value2);
1111
void debug(char *msg);
12-
void runMode(int stop);
12+
int runMode(int stop);
1313
int runStep(int dir);
1414
void cmdLoop();
1515
void iDelay(int ms);

0 commit comments

Comments
 (0)