• kami

    Hi,

    anyone here how can help me with the recieving problem? Thanks a lot.

    Cu kami

    posted in Pythonista read more
  • kami

    Hi,

    i am trying to write a chat client with a arduino controller. For now i am connecting to JDY-08 and sending the command on\n in hex. This works and the Arduino answer with "LED_on" but how can i recieve this string in Python???

    import cb
    import struct
    from pprint import pprint
    
    class MyCentralManagerDelegate (object):
        def __init__(self):
            self.peripheral = None
    
        def did_discover_peripheral(self, p):
            print('+++ Discovered peripheral: %s (%s)' % (p.name, p.uuid))
            if p.name and 'JDY-08' in p.name and not self.peripheral:
                # Keep a reference to the peripheral, so it doesn't get garbage-collected:
                self.peripheral = p
                cb.connect_peripheral(self.peripheral)
    
        def did_connect_peripheral(self, p):
            print('*** Connected: %s' % p.name)
            print('Discovering services...')
            p.discover_services()
    
        def did_fail_to_connect_peripheral(self, p, error):
            print('Failed to connect')
    
        def did_disconnect_peripheral(self, p, error):
            print('Disconnected, error: %s' % (error,))
            self.peripheral = None
    
        def did_discover_services(self, p, error):
            for s in p.services:
                print s.uuid
                if 'FE96' in s.uuid:
                    print('+++ Different Service found')
                    p.discover_characteristics(s)
                elif 'FFE0' in s.uuid:
                    print('+++ Arduino found')
                    p.discover_characteristics(s)
    
        def did_discover_characteristics(self, s, error):
            
            if 'FFE0' in s.uuid:
                pprint(s)
                for c in s.characteristics:
                    pprint(c)
                    if 'FFE1' in c.uuid:
                        print('Enabling Arduino Cmd1...')
                        self.peripheral.write_characteristic_value(c, chr(0x6F), False)
                        self.peripheral.write_characteristic_value(c, chr(0x6E), False)
                        self.peripheral.write_characteristic_value(c, chr(0x0a), True)
                        
                    elif 'AA01' in c.uuid:
                        
                        print('Enabling temperature sensor notifications...')
                        self.peripheral.set_notify_value(c, True)
            elif 'FFE3' in s.uuid:
                print('Enabling notifications for Simple Key Service...')
                
        def did_write_value(self, c, error):
            
            print('Did enable Arduino 1')
    
        def did_update_value(self, c, error):
            print('update:')
            pprint(c.value.encode('hex'))
            if 'FFE1' == c.uuid:
               
                print('Get value: %s' % c.value.encode('hex'))
                
            else:
                
                print('Nothing')
    
       
    delegate = MyCentralManagerDelegate()
    print('Scanning for peripherals...')
    cb.set_central_delegate(delegate)
    cb.scan_for_peripherals()
    
    # Keep the connection alive until the 'Stop' button is pressed:
    try:
        while True: pass
    except KeyboardInterrupt:
        # Disconnect everything:
        cb.reset()
    

    Thanks a lot.

    Cu kami

    posted in Pythonista read more
  • kami

    Hi,

    is there any UI-File Editor for PC to manage the pythonista UI Files without the Iphone or Ipad?

    Thanks a lot.

    Cu kami

    posted in Pythonista read more
  • kami

    Hi,

    it is working really fine with .whiteColor().

    Thanks a lot.

    Cu kami

    posted in Pythonista read more
  • kami

    Hi,

    i am trying this part with my xcode template:

    objc = ObjCInstance(v['datepicker1'])
    text_ui_color = ObjCClass('UIColor').color(red=1.0, green=1.0, blue=1.0, alpha=1.0)
    objc.setValue_forKeyPath_(text_ui_color,"textColor")
    v.present('sheet', hide_title_bar=True)

    After compiling i get this error:
    Traceback (most recent call last):
    File "/var/mobile/Containers/Data/Application/5F678712-8E2D-4524-9835-0212BB429000/Library/Application Support/PythonistaScript/main.py", line 122, in <module>
    text_ui_color = ObjCClass('UIColor').color(red=1.0, green=1.0, blue=1.0, alpha=1.0)
    File "/var/containers/Bundle/Application/ABFA86F0-AD8F-46F5-A0EF-86A6B5FF5A02/sendpulse.app/Frameworks/PythonistaKit.framework/pylib/site-packages/objc_util.py", line 347, in getattr
    cached_method = ObjCClassMethod(self, attr)
    File "/var/containers/Bundle/Application/ABFA86F0-AD8F-46F5-A0EF-86A6B5FF5A02/sendpulse.app/Frameworks/PythonistaKit.framework/pylib/site-packages/objc_util.py", line 600, in init
    raise AttributeError('No class method found for selector "%s"' % (self.sel_name))
    AttributeError: No class method found for selector "color"

    if i use it directly with Pythonista everything works fine.

    BR kami

    posted in Pythonista read more
  • kami

    Hi,

    thanks a lot. This works great.

    BR

    kami

    posted in Pythonista read more
  • kami

    Hi,

    how to change the textcolor of a Datapicker. Temporaly it is only Black?

    Thanks a lot.

    Cu kami

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!