tPut chime into function, clean up - lego_film_processor - software for rotary photographic film processor with Lego Mindstorms RCX
 (HTM) git clone git://src.adamsgaard.dk/lego_film_processor
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit cc2bea7bc1c570d2f4a7581d37528091967bbc66
 (DIR) parent bc96f1816b4fec6ffbfa90d262c16cbb63a8a365
 (HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
       Date:   Sun,  7 Jul 2019 20:38:11 +0200
       
       Put chime into function, clean up
       
       Diffstat:
         M lego_jobo.nqc                       |      39 +++++++++++++++++++------------
       
       1 file changed, 24 insertions(+), 15 deletions(-)
       ---
 (DIR) diff --git a/lego_jobo.nqc b/lego_jobo.nqc
       t@@ -4,16 +4,36 @@
        #define DEVELOP_MINS 10         /* number of minutes to develop for */
        #define DEVELOP_SECS 30         /* number of seconds to develop for */
        
       +#define chime_speed 1
       +
       +void
       +end_chime(int repeats)
       +{
       +        int i;
       +        for (i=0; i<repeats; ++i) {
       +                PlayTone(147, 50*chime_speed);  /* d   */
       +                PlayTone(156, 50*chime_speed);  /* d#  */
       +                PlayTone(147, 50*chime_speed);  /* d   */
       +                PlayTone(294, 100*chime_speed); /* d+1 */
       +
       +                PlayTone(147, 50*chime_speed);  /* d   */
       +                PlayTone(156, 50*chime_speed);  /* d#  */
       +                PlayTone(147, 50*chime_speed);  /* d   */
       +                PlayTone(175, 100*chime_speed); /* f   */
       +        }
       +}
       +
        task main()
        {
       -        int i, t_current;
       -        int t_end = 60*DEVELOP_MINS + DEVELOP_SECS;
       -        SetSleepTime(60);
       +        int t_current, t_end;
        
       +        SetSleepTime(60);
                Off(OUTPUT);
                SetPower(OUTPUT, OUT_FULL);    /* second arg an int between 0 and 7 */
        
                t_current = 0;
       +        t_end = 60*DEVELOP_MINS + DEVELOP_SECS;
       +
                while (t_current < t_end) {
        
                        Wait(T_TURN);
       t@@ -22,17 +42,6 @@ task main()
                        t_current += T_TURN;
                }
                Off(OUTPUT);
       -
       -        for (i=0; i<4; ++i) {
       -                PlayTone(147, 50);  /* d   */
       -                PlayTone(156, 50);  /* d#  */
       -                PlayTone(147, 50);  /* d   */
       -                PlayTone(294, 100); /* d+1 */
       -
       -                PlayTone(147, 50);  /* d   */
       -                PlayTone(156, 50);  /* d#  */
       -                PlayTone(147, 50);  /* d   */
       -                PlayTone(175, 100); /* f   */
       -        }
       +        end_chime(4);
                SetSleepTime(5);
        }