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 Zusammen,

 

hoffe Ihr könnt mir nochmals Behilflich sein. Mein Problem ist folgendes: Ich möchte mit dem RotaryPoti die Lautstärke von iTunes regeln. Mein Code ist in Python geschrieben und schaut momentan so aus:

 

# -*- coding: utf-8 -*-  

HOST = "localhost"
PORT = 4223

from tinkerforge.ip_connection import IPConnection
from tinkerforge.bricklet_rotary_poti import RotaryPoti
import win32com.client

iTunes = win32com.client.gencache.EnsureDispatch("iTunes.Application")

def volume(position):
    iTunes.SoundVolume = (position+150)/3 # Bereich von 0 bis 100

if __name__ == "__main__":
    ipcon = IPConnection(HOST, PORT)

    poti = RotaryPoti("91N")
    ipcon.add_device(poti)
    
    poti.set_position_callback_period(10)
    poti.register_callback(poti.CALLBACK_POSITION, volume)

    raw_input()
    
    ipcon.destroy()

 

Leider geht das ganze nicht so wie ich möchte.

 

Die lange Liste der Fehler sieht so aus:

 

Exception in thread Thread-2:

Traceback (most recent call last):

  File "C:\Python27\lib\threading.py", line 530, in __bootstrap_inner

    self.run()

  File "C:\Python27\lib\threading.py", line 483, in run

    self.__target(*self.__args, **self.__kwargs)

  File "build/bdist.linux-x86_64/egg/tinkerforge/ip_connection.py", line 225, in callback_loop

    device.registered_callbacks[function_id](self.data_to_return(data[4:], form))

  File "C:\Users\Kevin\Desktop\Eclipse Projekte\iTunes Tinkertrol\iTunes.py", line 14, in volume

    iTunes.SoundVolume = (position+150)/3 # Bereich von 0 bis 100

  File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 474, in __setattr__

    self._oleobj_.Invoke(*(args + (value,) + defArgs))

com_error: (-2147221008, 'CoInitialize wurde nicht aufgerufen.', None, None)

 

Programmiert wird mit Python 2.7 in Eclipse mit dem PyDev Plugin

 

Geschrieben

Du nutzt ja win32com. Steht da etwas in der Doku zum Thema initialisierung?

Es sieht so aus als wurde die COM-Bibliothek nicht initialisiert, das sollte dir vermutlich die Bibliothek win32com abnehmen, ich vermute dir wird ein methodenaufruf fehlen.

 

Ein kurzes google führt mich zu diesem Tipp:

iTunes.initialize()

(ich kenne die bibliothek win32com nciht)

Geschrieben

Also ich habs zwar nicht mit itunes gemacht aber mit der windows systemlautstärke --> funktioniert recht einfach über commandline und nircmd http://www.nirsoft.net/utils/nircmd.html, damit kann man auch Bildschirmhelligkeit etc. relativ einfach regeln.

 

Bsp:

import os

position = poti.get_position()

os.system("nircmd setsysvolume "+str((435)*position))

 

 

 

 

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.