コード例 #1
0
ファイル: staticversion.c プロジェクト: remyaraj/coroutines
int ascending (void) {
    static int i;
     scrBegin;
     for (i=0; i<10; i++) {
        scrReturn(i);
     }
     scrFinish(-1);
}
コード例 #2
0
ファイル: talkingbox.c プロジェクト: Shpek/TalkingBox.X
static State StatePlayTrack(StateAction action) {
    scrDeclare;
    static u8 trackNumber;

    if (action == Enter) {
        if (TrackNumber == 0) {
            // Random track
            trackNumber = GetRandomTrackNumber(NumTracks);
            // trackNumber = 0;
        } else {
            // Predefined track
            trackNumber = TrackNumber - 1;
        }
        
        scrReset;
        return Continue;
    }
    
    if (action == Update) {
        if (BtnSelect->stateChanged && BtnSelect->state == Pressed) {
            RotateTrack();
            Set7SegmentDisplay(TrackNumber);
        }

        if (Time < StateWaitUntil) {
            return Continue;
        }
        
        scrBegin;
        mp3_play_num(trackNumber);
        
        // Wait for player to start
        static u32 enterStandbyTime;
        enterStandbyTime = Time + 1000;
        
        while (1) {
            if (PlayerPlaying()) {
                break;
            }
            
            if (Time > enterStandbyTime) {
                scrReturn(StandBy);
            }
            
            scrReturn(Continue);
        }

        // Wait for the player to stop
        while (1) {
            if (BtnPlay->stateChanged && BtnPlay->state == Pressed) {
                scrReturn(Restart);
            }
            
            if (!PlayerPlaying()) {
                scrReturn(StandBy);
            }
            
            scrReturn(Continue);
        }
        
        // Shouldn't come here
        scrFinish(None);
    }
    
    return Continue;
}
コード例 #3
0
ファイル: talkingbox.c プロジェクト: Shpek/TalkingBox.X
static State StateInitPlayer(StateAction action) {
    scrDeclare;

    if (action == Enter) {
        PowerToPeripherals(1);
        NumTracks = 0;
        scrReset;
        return Continue;
    }
    
    if (action == Update) {
        if (BtnPlay->stateChanged && BtnPlay->state == Pressed) {
            GoToPlayTrack = 1;
        }

        if (BtnSelect->stateChanged && BtnSelect->state == Pressed) {
            RotateTrack();
            Set7SegmentDisplay(TrackNumber);
        }
        
        if (Time < StateWaitUntil) {
            return Continue;
        }
        
        scrBegin;
        scrSleep(1300);
        static u32 numFilesTimeout;
        numFilesTimeout = Time + 1000;
        mp3_set_volume(15);
        scrSleep(20);
        mp3_get_num_files_async();
               
        while (1) {
            scrReturn(Continue);
            
            if (Time > numFilesTimeout) {
                scrReturn(Sleep);
            }
            
            if (!mp3_check_for_result()) {
                continue;
            }

            NumTracks = mp3_get_result();
            
            if (TrackNumber > NumTracks) {
                TrackNumber = NumTracks;
                Set7SegmentDisplay(TrackNumber);
            }           
            
            if (NumTracks == 0) {
                scrReturn(Sleep);
            }

            if (GoToPlayTrack) {
                scrReturn(PlayTrack);
            }

            scrReturn(StandBy);
        }
        
        // Shouldn't come here
        scrFinish(None);
    }
    
    return Continue;
}