summaryrefslogtreecommitdiff
path: root/rail.h
diff options
context:
space:
mode:
Diffstat (limited to 'rail.h')
-rw-r--r--rail.h31
1 files changed, 26 insertions, 5 deletions
diff --git a/rail.h b/rail.h
index 62a633aae..b3ce18798 100644
--- a/rail.h
+++ b/rail.h
@@ -34,6 +34,17 @@ typedef enum Track {
} Track;
+/** Convert an Axis to the corresponding Track
+ * AXIS_X -> TRACK_X
+ * AXIS_Y -> TRACK_Y
+ * Uses the fact that they share the same internal encoding
+ */
+static inline Track AxisToTrack(Axis a)
+{
+ return (Track)a;
+}
+
+
/** Bitfield corresponding to Track */
typedef enum TrackBits {
TRACK_BIT_NONE = 0U,
@@ -55,6 +66,21 @@ typedef enum TrackBits {
} TrackBits;
+/**
+ * Maps a Track to the corresponding TrackBits value
+ */
+static inline TrackBits TrackToTrackBits(Track track)
+{
+ return (TrackBits)(1 << track);
+}
+
+
+static inline TrackBits AxisToTrackBits(Axis a)
+{
+ return TrackToTrackBits(AxisToTrack(a));
+}
+
+
/** These are a combination of tracks and directions. Values are 0-5 in one
direction (corresponding to the Track enum) and 8-13 in the other direction. */
typedef enum Trackdirs {
@@ -242,11 +268,6 @@ static inline Trackdir ReverseTrackdir(Trackdir trackdir) {
}
/**
- * Maps a Track to the corresponding TrackBits value
- */
-static inline TrackBits TrackToTrackBits(Track track) { return (TrackBits)(1 << track); }
-
-/**
* Returns the Track that a given Trackdir represents
*/
static inline Track TrackdirToTrack(Trackdir trackdir) { return (Track)(trackdir & 0x7); }