Skip to content

Commit a71c457

Browse files
committed
Simplifiy explaining R.sleep
1 parent 7afd107 commit a71c457

File tree

2 files changed

+11
-68
lines changed

2 files changed

+11
-68
lines changed

simulator/programming/index.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,20 @@ The LEDs are attached to digital pins 3-4:
9696

9797
Using the `digital_write` method, you can set these to True (On) or False (Off).
9898

99-
### Time
99+
## Simulated Time
100100

101101
In the simulated environment, time advances only at the pace that the simulator
102102
is run. As a result, using `time.time` to know how long your robot has been
103103
running for or `time.sleep` to wait for some duration will be unreliable.
104104

105105
As a result the API present in the simulator supports a slightly different
106-
approach to handling time. See the documentation about [simulated time](./time)
107-
for more details.
106+
approach to handling time.
107+
The methods `R.time` and `R.sleep` are provided as a direct replacement of `time.time` and `time.sleep` respectively and can be used anywhere the previous methods were used.
108+
109+
<div class="warning">
110+
Since the simulator does not simulate the time taken to execute your code, any loop or decision which needs an event to occur must be accompanied by a <code>R.sleep</code> even if with a small value.
111+
112+
<b>If in doubt add an <code>R.sleep</code></b>.
113+
114+
If you find that the simulator freezes then this indicates that your code is reaching a loop which does not contain any <code>R.sleep</code> and is expecting time to advance.
115+
</div>

simulator/programming/time.md

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)