Jump to content
View in the app

A better way to browse. Learn more.

Tinkerunity

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Geschrieben

Hi,

 

ich hätte da mal ein Problem mit meinem DualButtonBricklet. In einer recht einfachen Schleife wollte ich mal ein Wechselndes Blinken realisieren (nein, ich will das nicht auf mein Auto bauen ;))

 

Alles in Allem soll nichts weiter passieren, als dass die beiden LEDs abwechselnd an / aus gemacht werden und so der Eindruck des Blinkens entsteht:

for( Integer x = 1; x < mAmount; x++ ) {
    	try {
    		if( x % 2 == 0 ) {
    			dualbutton.setLEDState( dualbutton.LED_RIGHT, BrickletDualButton.LED_STATE_OFF );
    			dualbutton.setLEDState( dualbutton.LED_LEFT, BrickletDualButton.LED_STATE_ON );
    		}
    		else {
    			dualbutton.setLEDState( dualbutton.LED_RIGHT, BrickletDualButton.LED_STATE_ON );
    			dualbutton.setLEDState( dualbutton.LED_LEFT, BrickletDualButton.LED_STATE_OFF );
    		}
    	}
	    catch ( TimeoutException e ) {
	    	
	    	System.out.println( "Timeout occurred! Could not connect on <" + host + "> at port <" + port + "> - check if brick is connected!" );
	    	System.out.println( e.getMessage() );
	    	
	    }
    	try {
    	    TimeUnit.MILLISECONDS.sleep(100);
    	} catch (InterruptedException e) {
    	    //Handle exception
    	}
    	}

 

An und für sich passiert nun folgendes:

* die linke LED leuchtet durchgängig

* die rechte LED blinkt, wie sie soll

 

Vertausche ich im Code das Setzen der linken und rechten LED kommt es wie folgt:

* die linke LED flackert (sieht fast so aus als wäre sie aus oder als wäre der Sleep nur bei 1ms)

* die rechte LED blinkt, wie sie soll

 

in beiden Fällen wechselt die rechte LED anschließend aber nicht mehr bei einem Druck, bei der linken geht das noch. Im Brickviewer ist es noch seltsamer: da wird mit Button L der rechte Button geändert, mit Button R der linke. In meinem Fall sind für meinen nicht funktionierenden Button sowohl "ON" als auch "OFF" anklickbar.

 

Ich bin verwirrt und bitte um eine Idee was das sein könnte...

 

Danke und Gruß

J

Geschrieben
  • Autor

zumindest das mit dem "nicht mehr reagieren" habe ich gelöst. da war ich etwas vorschnell und bitte um Entschulidung. Ich hätte danach noch

BrickletDualButton.LED_STATE_AUTO_TOGGLE_ON

mit rein nehmen sollen.

 

Dafür flackern jetzt beide LEDs ^^

Geschrieben

Die Parameter für setLEDState() sind nicht LED-Index und LED-Zustand, sondern Linke-LED-Zustand und Rechte-LED-Zustand.

 

if( x % 2 == 0 ) {
dualbutton.setLEDState(BrickletDualButton.LED_STATE_ON, BrickletDualButton.LED_STATE_OFF);
}
else {
dualbutton.setLEDState(BrickletDualButton.LED_STATE_OFF, BrickletDualButton.LED_STATE_ON);
}

  • 2 weeks later...
Geschrieben
  • Autor

erm ... wer lesen kann ist klar im Vorteil. Danke für den Hinweis: funktioniert ;)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gast
Reply to this topic...

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.