@@ -201,5 +201,81 @@ ROUTE(1771,"1771 Test IFLOCO with multiple loco ids")
201201 PRINT ("IFLOCO 1,2,4 test failed" )
202202 ELSE
203203 PRINT ("IFLOCO 1,2,4 test passed" )
204- DONE
205-
204+ ENDIF
205+
206+ HAL (Bitmap ,1700 ,10 )
207+ SET (1702 ) SET (1703 ) SET (1704 )
208+
209+ IF_ANY (1700 ,1701 ,1702 )
210+ PRINT ("IF_ANY 0,1,2 test OK" )
211+ ELSE
212+ PRINT ("IF_ANY 0,1,2 test failed" )
213+ ENDIF
214+
215+ IF_ANY (1700 ,1701 ,1706 )
216+ PRINT ("IF_ANY 0,1,6 test failed" )
217+ ELSE
218+ PRINT ("IF_ANY 0,1,6 test passed" )
219+ ENDIF
220+
221+ IF_ALL (1702 ,1703 ,1704 )
222+ PRINT ("IF_ALL 2,3,4 test OK" )
223+ ELSE
224+ PRINT ("IF_ALL 2,3,4 test failed" )
225+ ENDIF
226+
227+ IF_ALL (1702 ,1703 ,1706 )
228+ PRINT ("IF_ALL 2,3,6 test failed" )
229+ ELSE
230+ PRINT ("IF_ALL 2,3,6 test passed" )
231+ ENDIF
232+
233+ IF_ANY (1701 ,-1706 )
234+ PRINT ("IF_ANY 1,-1706 test passed" )
235+ ELSE
236+ PRINT ("IF_ANY 1,-1706 test failed" )
237+ ENDIF
238+
239+ IF_ALL (1701 ,-1706 )
240+ PRINT ("IF_ALL 1,-1706 test failed" )
241+ ELSE
242+ PRINT ("IF_ALL 1,-1706 test passed" )
243+ ENDIF
244+
245+ DONE
246+
247+
248+
249+ // Speedometer example
250+ // Track is =TS1===TS2===TS3= timing between S2 and S3.
251+
252+ ALIAS (TS1 ,181 ) ALIAS (TS2 ,182 ) ALIAS (TS3 ,183 )
253+ STEALTH_GLOBAL (
254+ byte testStartSpeed = 2 ;
255+ byte testEndSpeed = 100 ;
256+ byte testStep = 10 ;
257+ byte testSpeed ;
258+ unsigned long testStartTime ;
259+ )
260+
261+ AUTOMATION (9000 ,"Run Speed Test" ) // speed test setup
262+ STEALTH (testSpeed = testStartSpeed ;)
263+ PRINT ("Starting speed test" )
264+ REV (20 ) // reverse loco to start point
265+
266+ SEQUENCE (9001 )
267+ // make sure loco is at start point
268+ AT (TS1 ) ESTOP
269+ // drive loco fwd at testSpeed
270+ STEALTH (DCC ::setThrottle (loco ,testSpeed ,true );)
271+ // At timing-start sensor(s2) record time
272+ AT (TS2 ) STEALTH (testStartTime = millis ();)
273+ // at timing-end sensor(s3) stop and calculate and print speed
274+ AT (TS3 ) ESTOP STEALTH (
275+ StringFormatter ::send (& USB_SERIAL ,
276+ F ("Speed %d Time %l \n "), testSpeed , millis ()- testStartTime );
277+ testSpeed += testStep ;
278+ if (testSpeed > testEndSpeed ) kill (); // test complete =DONE
279+ )
280+ // Reverse back to start, and test again
281+ REV (127 ) FOLLOW (9001 )
0 commit comments