@@ -551,11 +551,6 @@ namespace microdata {
551551
552552 private targetIDCache : number [ ]
553553
554- private targetMicrobitsBtn : Button
555- private startLoggingBtn : Button
556- private startStreamingBtn : Button
557- private showDataBtn : Button
558-
559554 constructor ( app : AppInterface , sensors ?: Sensor [ ] , configs ?: RecordingConfig [ ] ) {
560555 super ( app )
561556 this . uiState = UI_STATE . SHOWING_OPTIONS
@@ -603,83 +598,82 @@ namespace microdata {
603598
604599 const y = Screen . HEIGHT * 0.234 // y = 30 on an Arcade Shield of height 128 pixels
605600
606- this . targetMicrobitsBtn = new Button ( {
607- parent : null ,
608- style : ButtonStyles . Transparent ,
609- icon : "largeSettingsGear" ,
610- ariaId : "See connected Microbits" ,
611- x : - 60 ,
612- y,
613- onClick : ( ) => {
614- if ( DistributedLoggingScreen . streamingDone ) {
615- this . uiState = UI_STATE . SHOWING_CONNECTED_MICROBITS
616- this . cursor . visible = false
617- this . targetIDCache = [ ]
618-
619- // Start timeout:
620- // Continually request the target ids; so that new incoming targets appear on the list as it is displayed, and outgoing targets leave it, in real-time:
621- control . inBackground ( ( ) => {
622- while ( this . uiState == UI_STATE . SHOWING_CONNECTED_MICROBITS ) {
623- this . targetIDCache = this . distributedLogger . commanderRequestTargetIDs ( )
624- basic . pause ( MESSAGE_LATENCY_MS * 2 )
625- }
626- } )
627- }
628- } ,
629- } )
630-
631- this . startLoggingBtn = new Button ( {
632- parent : null ,
633- style : ButtonStyles . Transparent ,
634- icon : "radio_set_group" ,
635- ariaId : "Start logging" ,
636- x : - 20 ,
637- y,
638- onClick : ( ) => {
639- if ( DistributedLoggingScreen . streamingDone ) {
640- DistributedLoggingScreen . streamDataBack = false
641-
642- this . app . popScene ( )
643- this . app . pushScene ( new SensorSelect ( this . app , CursorSceneEnum . DistributedLogging ) )
644- }
645- }
646- } )
647-
648- this . startStreamingBtn = new Button ( {
649- parent : null ,
650- style : ButtonStyles . Transparent ,
651- icon : "radio_set_group" ,
652- ariaId : "Start streaming" ,
653- x : 20 ,
654- y,
655- onClick : ( ) => {
656- if ( DistributedLoggingScreen . streamingDone ) {
657- DistributedLoggingScreen . streamDataBack = true
658-
659- this . app . popScene ( )
660- this . app . pushScene ( new SensorSelect ( this . app , CursorSceneEnum . DistributedLogging ) )
661- }
662- } ,
663- flipIcon : true
664- } )
665-
666- this . showDataBtn = new Button ( {
667- parent : null ,
668- style : ButtonStyles . Transparent ,
669- icon : "largeDisk" ,
670- ariaId : "View real-time data" ,
671- x : 60 ,
672- y,
673- onClick : ( ) => {
674- if ( DistributedLoggingScreen . showTabularData ) {
675- this . app . popScene ( ) ;
676- this . app . pushScene ( new TabularDataViewer ( this . app , function ( ) { this . app . popScene ( ) ; this . app . pushScene ( new DistributedLoggingScreen ( this . app ) ) } ) ) ;
601+ this . navigator . setBtns ( [ [
602+ new Button ( {
603+ parent : null ,
604+ style : ButtonStyles . Transparent ,
605+ icon : "largeSettingsGear" ,
606+ ariaId : "See connected Microbits" ,
607+ x : - 60 ,
608+ y,
609+ onClick : ( ) => {
610+ if ( DistributedLoggingScreen . streamingDone ) {
611+ this . uiState = UI_STATE . SHOWING_CONNECTED_MICROBITS
612+ this . cursor . visible = false
613+ this . targetIDCache = [ ]
614+
615+ // Start timeout:
616+ // Continually request the target ids; so that new incoming targets appear on the list as it is displayed, and outgoing targets leave it, in real-time:
617+ control . inBackground ( ( ) => {
618+ while ( this . uiState == UI_STATE . SHOWING_CONNECTED_MICROBITS ) {
619+ this . targetIDCache = this . distributedLogger . commanderRequestTargetIDs ( )
620+ basic . pause ( MESSAGE_LATENCY_MS * 2 )
621+ }
622+ } )
623+ }
624+ } ,
625+ } ) ,
626+
627+ new Button ( {
628+ parent : null ,
629+ style : ButtonStyles . Transparent ,
630+ icon : "radio_set_group" ,
631+ ariaId : "Start logging" ,
632+ x : - 20 ,
633+ y,
634+ onClick : ( ) => {
635+ if ( DistributedLoggingScreen . streamingDone ) {
636+ DistributedLoggingScreen . streamDataBack = false
637+
638+ this . app . popScene ( )
639+ this . app . pushScene ( new SensorSelect ( this . app , CursorSceneEnum . DistributedLogging ) )
640+ }
677641 }
678- } ,
679- } )
680-
681- const btns : Button [ ] = [ this . targetMicrobitsBtn , this . startLoggingBtn , this . startStreamingBtn , this . showDataBtn ]
682- this . navigator . setBtns ( [ btns ] )
642+ } ) ,
643+
644+ new Button ( {
645+ parent : null ,
646+ style : ButtonStyles . Transparent ,
647+ icon : "radio_set_group" ,
648+ ariaId : "Start streaming" ,
649+ x : 20 ,
650+ y,
651+ onClick : ( ) => {
652+ if ( DistributedLoggingScreen . streamingDone ) {
653+ DistributedLoggingScreen . streamDataBack = true
654+
655+ this . app . popScene ( )
656+ this . app . pushScene ( new SensorSelect ( this . app , CursorSceneEnum . DistributedLogging ) )
657+ }
658+ } ,
659+ flipIcon : true
660+ } ) ,
661+
662+ new Button ( {
663+ parent : null ,
664+ style : ButtonStyles . Transparent ,
665+ icon : "largeDisk" ,
666+ ariaId : "View real-time data" ,
667+ x : 60 ,
668+ y,
669+ onClick : ( ) => {
670+ if ( DistributedLoggingScreen . showTabularData ) {
671+ this . app . popScene ( ) ;
672+ this . app . pushScene ( new TabularDataViewer ( this . app , function ( ) { this . app . popScene ( ) ; this . app . pushScene ( new DistributedLoggingScreen ( this . app ) ) } ) ) ;
673+ }
674+ } ,
675+ } )
676+ ] ] )
683677 }
684678
685679 draw ( ) {
@@ -708,11 +702,7 @@ namespace microdata {
708702 2
709703 )
710704
711- this . targetMicrobitsBtn . draw ( )
712- this . startLoggingBtn . draw ( )
713- this . startStreamingBtn . draw ( )
714- this . showDataBtn . draw ( )
715-
705+ this . navigator . drawComponents ( ) ;
716706 break ;
717707 }
718708
0 commit comments