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, bin neu hier.

Ich habe am Industrieal Counter Bricklet einen Drehfeldgeber angeschlossen.

Das ganze funktioniert auch sehr gut.

Ist es möglich das Callback so zu konfigurieren, dass nur bei Änderung eines Wertes zB. "Counter" die Callback-Funktion ausgeführt wird?

Habe viel probiert, es gelingt mir nicht. Vieleicht habe ich ein Verständnisproblem bzw. mache ich was falsch.

mfg

Sahip

Geschrieben

Eigentlich sollte das per

set_all_counter_callback_configuration(100, True)

funktionieren.

Damit bekommst du den Callback alle 100ms, aber nur dann wenn sich der Wert auch geändert hat.

Geschrieben
  • Autor

Hallo borg,

hier mein Testprogramm

import time

from tinkerforge.ip_connection import IPConnection
from tinkerforge.bricklet_industrial_counter import BrickletIndustrialCounter

def my_callback(param):
    print (param)

if __name__ == "__main__":
    ipcon = IPConnection()
    ic = BrickletIndustrialCounter("CoUNT", ipcon)
    ipcon.connect("192.168.250.80", 4223)
    ic.register_callback(ic.CALLBACK_ALL_COUNTER, my_callback)
    ic.set_all_counter_callback_configuration(2000,True)
    
    time.sleep(100)
    ipcon.disconnect()

Es wird alle 2s diese Zeile (Beispiel) ausgegeben obwohl sich der Wert nicht geändert hat

(717, 0, 9765, 1253)

Auch wenn sich der wert ändert, wird dieser erst nach Ablauf der Periode (2s) ausgeben.

Kann es sein, dass hier evt. ein Bug vorliegt?

 

Geschrieben

In der Tat. Ich schaue mir gerade den Code an:

if((!counter.cb_counter_value_has_to_change) ||
   (last_counter[0] != new_counter[0])       ||
   (last_counter[1] != new_counter[1])       ||
   (last_counter[2] != new_counter[2])       ||
   (last_counter[3] != new_counter[3])) {
    last_time = system_timer_get_ms();
    tfp_make_default_header(&cb.header, bootloader_get_uid(), sizeof(AllCounter_Callback), FID_CALLBACK_ALL_COUNTER);
    for(uint8_t channel = 0; channel < COUNTER_NUM; channel++) {
        cb.counter[channel] = new_counter[channel];
  }
}

Der Check ist zwar richtig, aber last_counter wird nie gesetzt... Ich fixe das kurzfristig.

Geschrieben
  • Autor

Hallo borg,

das ging aber schnell. Habe das Update gemacht, jetzt funktioniert es.

Vielen Dank

 

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.