From 23464ab763278e38af60bb257307f2c31934e94b Mon Sep 17 00:00:00 2001
From: bovlb <31326650+bovlb@users.noreply.github.com>
Date: Wed, 25 Sep 2024 10:37:56 -0700
Subject: [PATCH] Add NT property updating; clarify addPeriodic
---
_includes/note.html | 4 ++++
commands/commandscheduler.md | 15 +++++++++++----
styles.css | 7 +++++++
3 files changed, 22 insertions(+), 4 deletions(-)
create mode 100644 _includes/note.html
diff --git a/_includes/note.html b/_includes/note.html
new file mode 100644
index 0000000..87f549a
--- /dev/null
+++ b/_includes/note.html
@@ -0,0 +1,4 @@
+
+
📝 Note: {{include.content}}
+
+{% comment %} Copyright 2021 Google LLC {% endcomment %}
\ No newline at end of file
diff --git a/commands/commandscheduler.md b/commands/commandscheduler.md
index ad3a1c0..d41a51b 100644
--- a/commands/commandscheduler.md
+++ b/commands/commandscheduler.md
@@ -46,19 +46,21 @@ This is a rough outline of how everything gets run.
`TimedRobot.startCompetition` has an endless loop which polls its time-based priority queue for callbacks that are ready to run.
`Runnable`s are added to that priority queue using `TimedRobot.addPeriodic`.
By default, the only thing on that queue is `IterativeRobotBase.loopFunc`.
-You could use `addPeriodic` yourself to add other tasks with a different period, but you could also use `Notifier`s if you're happy dealing with thread-safety.
+
+
`IterativeRobotBase.loopFunc` does:
1. Calls `Exit` and `Init` if the mode is changing
2. Calls `Periodic` (e.g. `autoPeriodic` and `telopPeriodic`)
3. Calls `robotPeriodic`
-4. Does loop overrun reporting
+4. Updates `SmartDashbaord` and `LiveWindow` properties
+5. Does loop overrun reporting
By default, the only thing `robotPeriodic` does is to call `CommandScheduler.run`.
`CommandScheduler.run` does the following:
-1. Runs subsystem periodic methods
-2. Polls its EventLoop
+1. Calls subsystem `periodic` methods
+2. Polls its `EventLoop`
3. For all scheduled commands, call `execute`, `isFinished` and/or possibly `end`.
4. Enact pending calls to `schedule` and `cancel`
5. Schedule default commands
@@ -68,6 +70,11 @@ When `EventLoop.poll` is called, it runs every registered Runnable.
Runnables are registered using `EventLoop.bind`.
By default, the only way `Runnable`s are added to the `CommandScheduler`'s `EventLoop` is by calling one of the binding methods on a `Trigger`.
+{% include note.html content="You can call `Robot.addPeriodic` to add your own periodic tasks, possibly with a different period. Don't rely on being able to use periods shorter than the main loop period of 20ms, because it's all running in the same thread. Periodic methods registered with `addPeriodic` are not subject to overrun reporting, so you may not notice if they're causing performance problems.
+
+If you are confident about thread-safe programming,
+you could also use [`Notifier`s](https://github.wpilib.org/allwpilib/docs/release/java/edu/wpi/first/wpilibj/Notifier.html)." %}
+
## See also
* [The Command Scheduler](https://docs.wpilib.org/en/stable/docs/software/commandbased/command-scheduler.html)
diff --git a/styles.css b/styles.css
index 9b59cd2..03f5702 100644
--- a/styles.css
+++ b/styles.css
@@ -137,6 +137,13 @@ body {
padding: 15px;
}
+.note {
+ background-color: #000040;
+ border: thin solid #404088;
+ /* color: #3c763d; */
+ padding: 15px;
+}
+
/* General & 'Reset' Stuff */
.container {
width: 90%;