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

Hallo alle,

 

für die C#-Entwickler habe ich vor einiger Zeit ein Pull Request an Tinkerforge gestellt, dass die Callback-behandlung auf Events umstellt, so wie es in .NET üblich ist.

 

Bisher wurden die Änderungen nicht von TF übernommen, was ich verstehen kann, da ich die Delegates alle umbenannt habe und es dadurch etwas inkompatibel zu den aktuellen Bindings ist.

 

Um meine Motivation zu erhöhen (ich muss im Moment bei allen Änderungen am Original ja auch meine Bindings aktualisieren) dachte ich mir ich poste meine Bindings hier einfach mal. Falls jemand Interesse daran hat oder Feedback geben möchte höre ich es gerne ^^

 

Die Binding gibt es hier: https://github.com/downloads/NobodysNightmare/generators/TF-with-Events_1.1.9.zip

Das ganze github-project: https://github.com/NobodysNightmare/generators

 

Warum eigentlich

Ich hatte zweieinhalb Motivationsgründe ^^

1. Mehr als ein Listener pro Callback (siehe Code unten)

2. Typ-Prüfung zur Compilezeit (falls man einen falschen Delegate angibt knallt es nicht erst beim Ausführen)

2,5. In .NET wird es halt einfach so gemacht, ich finde es "sauberer"

 

Noch schnell Beispielcode und dann bin ich auch schon fertig:

servoBrick.PositionReached += firstHandler;
servoBrick.PositionReached += secondHandler;

...

public void firstHandler(byte servoNum, short position)
{
if(servoNum != 0)
  return;

//Do something with servo 0
}

public void secondHandler(byte servoNum, short position)
{
if(servoNum != 1)
  return;

//Do something with servo 1
}

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.