def shitBtn(self): global st, data, beta, rrrrr, busy if(not rrrrr):data = "5>" if(beta):s.sendto(data.encode(), (addr, port)) #notification.notify(title="Kivy Notification",message="Plyer Up and Running!",app_name="dick",timeout=10) if(vib):vibrator.vibrate(time=0.4) #if(seff):gunfire.play() #data = "shot>" #if(beta):s3.send(data.encode()) if(debugOutput):print("SEND : Fire command sent.") st += 1 if(debugOutput):print("INFO : Shoot " + str(st) + " times.") #labelSt.configure(text="Shoot " + str(st) + " times") time.sleep(1) busy = True if(st == 12 and shotLim): if(rst):data = "stop" if(rst):postdt2(data) if(debugOutput):print("\nINFO limit shots reached.\n") #self.ui.source = ui_img_Gameover self.ui_govr = Image(source=ui_img_Gameover, size_hint=(1, 1), pos=(0, 0)) self.add_widget(self.ui_govr) rrrrr = True #self.remove_widget(self.ui_govr) st = 0
def send(self, _): print("[myDEBUG] Button pressed") if not check_permission('android.permission.SEND_SMS'): request_permissions([Permission.SEND_SMS]) sms.send(self.recipient.text, self.message) vibrator.vibrate(0.3)
def height_increment(self): vibrator.vibrate(0.017) self._height = MarkupLabel(self._height).markup self._height = int(self._height[2]) self._height += 1 self._height = f'[b][color=b39ddb]{self._height}[/color][/b]' if main_app.theme == "purple" else f"[b][color=CFD8DC]{self._height}[/b][/color]" self.ids.height.text = self._height
def verify(self, event): if is_android: vibrator.vibrate(0.1) options = verifier.parseAndVerify(self.txtInput.text) self.lblResult.text = '' for option in options: self.lblResult.text += option['texts'][0]['text'] + '\n'
def connect(self): self.m = sk.socket(sk.AF_INET, sk.SOCK_STREAM) self.m.bind(("localhost", 5000)) self.m.listen(10) self.c, addr = self.m.accept() print("{} connected".format(addr)) vibrator.vibrate(0.01)
def age_increment(self): vibrator.vibrate(0.017) self._age = MarkupLabel(self._age).markup self._age = int(self._age[2]) self._age += 1 self._age = f'[b][color=b39ddb]{self._age}[/color][/b]' if main_app.theme == "purple" else f"[b][color=CFD8DC]{self._age}[/b][/color]" self.ids.age.text = self._age
def setView(self,value): self.bindroot.grabbed['view']={"state":"grabbed"} if self.vibrate: vibrator.vibrate(0.05) self.current=value self.bindroot.setFG("/sim/current-view/view-number",value) self.bindroot.grabbed['view']={"state":"ungrabbed"}
def send_notification(self, text): for i in range(5): title = "Lecture "+str(i)+" is starting soon!" notification.notify(title=title, message=text, app_name='ConferencePi', timeout=1) time.sleep(2) vibrator.vibrate(time=2)
def join_button(self, instance): port = self.port.text ip = self.ip.text username = self.username.text with open("prev_details.txt", "w") as f: f.write(f"{ip},{port},{username}") #print(f"Joining {ip}:{port} as {username}") info = f"Joining {ip}:{port} as {username}" sensor_app.info_page.update_info(info) if port.isalnum(): sensor_app.screen_manager.current = 'Info' Clock.schedule_once(self.connect, 1) else: vibrator.vibrate(0.05) sensor_app.screen_manager.current = 'Connect' content = Button(text='Close') popup = Popup(title="Error No Input !", content=content, auto_dismiss=False, size_hint=(None, None), size=(400, 300)) content.bind(on_press=popup.dismiss) popup.open()
def Vibrate(): try: from jnius import autoclass, cast # PythonActivity is provided by the Kivy bootstrap app in python-for-android print("Vibrate Start") PythonActivity = autoclass('org.kivy.android.PythonActivity') print("1") # The PythonActivity stores a reference to the currently running activity # We need this to access the vibrator service activity = PythonActivity.mActivity print("2") # This is almost identical to the java code for the vibrator Context = autoclass('android.content.Context') print("3") vibrator_service = activity.getSystemService(Context.VIBRATOR_SERVICE) print("4") vibrator = cast("android.os.Vibrator", vibrator_service) print("5") vibration_effect = autoclass("android.os.VibrationEffect") print("6") #vibrator.vibrate(10000) vibrator.vibrate(vibration_effect.createOneShot(2000, 150)) print("end of Vibrate") except Exception as e: print("Not Vibrated") print(str(e))
def timer_alarm(self): # stop decrementing time Clock.unschedule(self.decrement_time) # set timer to 0:00 self.timer.minutes = 0 self.timer.seconds = 0 # update time string self.timer.update_time_string() # log work if not self.current_project_index == -1: self.log_work(self.current_project_index) # save log self.refresh_projects() self.save_projects() if platform == 'win' and self.config.get('system', 'hide_window') == '1': # show main window again self.root_window.show() # log date of completed session to file if self.config.get('ebs', 'log_activity') == '1': # date and count for this session date_today = datetime.datetime.today().strftime('%Y-%m-%d') count_today = 1 # read old file if isfile(self.activity_fn): with open(self.activity_fn, 'r') as f: # read lines lines = f.readlines() # get date and count date_file, count_file = lines[-1].split() if date_file == date_today: # add count from earlier sessions today count_today += int(count_file) # remove last line with current log for today lines = lines[:-1] else: lines = [] # append new last line lines.append("%s\t%s\n" % (date_today, str(count_today))) # write new file with open(self.activity_fn, 'w') as f: f.writelines(lines) # store flags that timer is not running down but up self.timer.running_down = False self.timer.running_up = True # start incrementing time Clock.schedule_interval(self.increment_time, 1) # show notification if self.timer.notification_activated: self.timer.notification_wrapper.notify( title="3PM", message="Session finished!", timeout=self.timer.notification_timeout) # play alarm sound if file found if self.timer.start_sound_activated and self.timer.alarm_sound: self.timer.alarm_sound.play() # vibrate on smartphone if self.timer.vibration_activated and platform in ['android', 'ios']: vibrator.vibrate(2)
def setView(self, value): self.bindroot.grabbed['view'] = {"state": "grabbed"} if self.vibrate: vibrator.vibrate(0.05) self.current = value self.bindroot.setFG("/sim/current-view/view-number", value) self.bindroot.grabbed['view'] = {"state": "ungrabbed"}
def setFG(self, item, key, value): self.data[item]['current'] = value self.ctrlupdate = False Clock.unschedule(self.enableUpdate) if self.vibrate: vibrator.vibrate(0.05) self.bindroot.setFG(key, value) Clock.schedule_once(self.enableUpdate, 2)
def mk_hardware_vibration_time(seconds_to_vibrate): """ Vibration via time """ try: vibrator.vibrate(seconds_to_vibrate) except NotImplementedError: pass
def vibra(self, tempo): animazione = Animation(x=self.width * 0.01, duration=tempo/8.0) animazione += Animation(x=0, duration=tempo*7/8.0, transition="out_elastic") animazione.start(self) try: vibrator.vibrate(tempo/3) except NotImplementedError: pass
def _run_vibrator(self, period): if platform=="android": if period==1: vibrator.vibrate(1) else: self._callback = lambda *x: self.stop_vibrator(0) Clock.schedule_once(self._callback, period) vibrator.pattern(pattern=[0, 1, 0], repeat=0)
def _run_vibrator(self, period): if platform == "android": if period == 1: vibrator.vibrate(1) else: self._callback = lambda *x: self.stop_vibrator(0) Clock.schedule_once(self._callback, period) vibrator.pattern(pattern=[0, 1, 0], repeat=0)
def bmi_calc(self): vibrator.vibrate(0.035) self._height = MarkupLabel(self.ids.height.text).markup self._height = int(self._height[2]) self.bmi = round(((self.ids.weight.value * 10000) / (self._height**2)), 1) self._height = f'[b][color=b39ddb]{self._height}[/color][/b]' if main_app.theme == "purple" else f"[b][color=CFD8DC]{self._height}[/b][/color]" self.ids.height.text = self._height
def android_vibration(self): try: from plyer import vibrator extra_packages = 1 except ImportError: print 'Not all Packages are installed on Pc' if extra_packages == 1: if platform == 'android': vibrator.vibrate(0.1)
def onControllerParkingBrakeChange(self,state): self.grabbed['parkingbrake']={"state":"grabbed"} if self.vibrate: vibrator.vibrate(0.05) if state=='down': self.setFG("/controls/gear/brake-parking",1) else: self.setFG("/controls/gear/brake-parking",0) self.grabbed['parkingbrake']={"state":"ungrabbed"}
def on_touch_move(self, touch): global dx, dy if(debugOutput):print("// MOVE X = " + str(touch.x) + " MOVE Y = " + str(touch.y)) dx = touch.x dy = touch.y if(dx <= 800 * zoom): if(vib):vibrator.vibrate(0.05) self.ui.source = ui_img self.ff()
def count_points_false(self): """ Called by count_points """ self.no_points += 1 self.time_penality += 3 self.sound_miss_play() # On Android try: vibrator.vibrate(0.4) except NotImplementedError: pass
def vibrate_cb(self, time=1): try: vibrator.vibrate(time) except (NotImplementedError, ImportError): Logger.warn( "DEVICE: No vibrate function defined for {} platform.".format( constants.PLATFORM)) else: Logger.info("DEVICE: BUZZ!!")
def set(self,direction): self.bindroot.grabbed['elevatortrim']={"state":"grabbed"} if self.bindroot.vibrate: vibrator.vibrate(0.05) if direction=="up" and self.bindroot.current['elevatortrim']<1: self.toController(self.bindroot.current['elevatortrim']+0.01) elif direction=="down" and self.bindroot.current['elevatortrim']>-1: self.toController(self.bindroot.current['elevatortrim']-0.01) self.bindroot.update() self.bindroot.grabbed['elevatortrim']={"state":"ungrabbed"}
def onLights(self,state): if self.vibrate: vibrator.vibrate(0.05) if state == "down": self.flaps.doEnable(False) self.viewbuttons.doEnable(False) self.lightsbuttons.doEnable(True) else: self.flaps.doEnable(True) self.lightsbuttons.doEnable(False)
def toggle(self, state, item): if self.vibrate: vibrator.vibrate(0.05) self.data[item]['current'] = self.data[item][state] self.bindroot.setFG(self.data[item]['key'], self.data[item][state]) if item == 'LANDING': self.bindroot.setFG(self.data[item]['key2'], self.data[item][state]) self.bindroot.setFG(self.data[item]['key1'], self.data[item][state])
def vibra(self, tempo): animazione = Animation(x=self.width * 0.01, duration=tempo / 8.0) animazione += Animation(x=0, duration=tempo * 7 / 8.0, transition="out_elastic") animazione.start(self) try: vibrator.vibrate(tempo / 3) except NotImplementedError: pass
def onSetAccelerometer(self,state): if self.vibrate: vibrator.vibrate(0.05) if state == "down": p = AcclPopup(bindroot=self) p.open() else: accelerometer.disable() Clock.unschedule(self.accl) self.padctrl.PadMode()
def on_touch_down(self, touch): if self.collide_point(*touch.pos): self.pressed = touch.pos number = self.secondary_text print(number) tel = number vibrator.vibrate(.3) call.makecall(tel=tel) return True return super(CallerButton, self).on_touch_down(touch)
def set(self, direction): self.bindroot.grabbed['elevatortrim'] = {"state": "grabbed"} if self.bindroot.vibrate: vibrator.vibrate(0.05) if direction == "up" and self.bindroot.current['elevatortrim'] < 1: self.toController(self.bindroot.current['elevatortrim'] + 0.01) elif direction == "down" and self.bindroot.current['elevatortrim'] > -1: self.toController(self.bindroot.current['elevatortrim'] - 0.01) self.bindroot.update() self.bindroot.grabbed['elevatortrim'] = {"state": "ungrabbed"}
def get_data(self): try: print ("ENTRO AL TRY") data=s.recv(1024) with open('data.txt', "w") as f: f.write(data) sleep(0.1) with open('data.txt', "r") as f: strin=str(data) global DATA DATA=f.read() Datas=data.decode() dato_rec=True except Exception: dato_rec=False if dato_rec== True: with open('alerta.txt', "w") as f: f.write(Datas) sleep(0.1) with open('alerta.txt', "r") as f: strin=str(Datas) I_ALERTA=f.read() #verificamos que este la clave i_alerta if "i_alerta" in json_arreglo: json_arreglo = json.loads(I_ALERTA) corrientem=eval(json_arreglo.get("i_alerta")) #NOTIFICACIONES #Generamos la notificacion con vibracion title = b"Alerta".decode('utf8') message = f" Alerta de corriente" ticker = "La corriente tiene un valor de:" + corrientem + "superando el valor maximo" app_name = "conexion" app_icon = "plyer-icon.png" toast = True notification.notify(title=title, message=message, app_name=app_name, app_icon=app_icon, timeout=10, ticker=ticker, toast=toast ) #ponemos a vibrar el telefono vibrator.vibrate(10) else: print("NO HAY ALERTA")
def sendMessage(self, text): try: self.c.sendall(text) text = text + "\n" self.chatLog += text self.label.text = self.chatLog vibrator.vibrate(0.01) except: self.popup.open() vibrator.vibrate(3)
def OS_Vibrate(fDuration=0.05): ''' Vibrates a device ''' if oORCA.bVibrate: try: vibrator.vibrate(fDuration) except NotImplementedError: pass except Exception as e: uMsg=u'Globals: can\'t Vibrate:'+ToUnicode(e) Logger.info (uMsg) return False
def Vibrate(fDuration=0.05): """ Vibrates a device """ if Globals.bVibrate: try: vibrator.vibrate(fDuration) except NotImplementedError: pass except Exception as e: uMsg=u'Globals: can\'t Vibrate:'+ToUnicode(e) Logger.info (uMsg) return False
def clap( self, instance ): '''Produce simultaneous visual and audio output. Args: instance: (ignored) The object which caused this function to be called ''' if self.sound: self.sound.play() Color( 1., 1., 1. ) Rectangle( pos=( 10, 10 ), size=( 500, 500 ) ) if vibrator.exists(): vibrator.vibrate(1) #Vibrate for one second
def on_touch_move(self,touch): if touch.grab_current is self: tx,ty = touch.pos if abs(self.cy-ty)>20: if self.cy-ty>0: inc=-1 else: inc=+1 if self.bindroot.vibrate: vibrator.vibrate(0.02) self.setController(self.bindroot.current['autobrake']+inc) self.cy = ty
def on_touch_move(self, touch): if touch.grab_current is self: tx, ty = touch.pos if abs(self.cy - ty) > 20: if self.cy - ty > 0: inc = -1 else: inc = +1 if self.bindroot.vibrate: vibrator.vibrate(0.02) self.setController(self.bindroot.current['autobrake'] + inc) self.cy = ty
def move(self,dt): for child in self.others: if child.collide_point(self.player.x,self.player.y): Player.yandin() vec=accelerometer.acceleration[:2] if not vec==(None,None): self.player.move(vec[0],vec[1]) if self.player.collide_point(self.evil.x,self.evil.y): if vibrator: vibrator.vibrate(10) else: Player.error(text="plyer vibrate")
def Vibrate(fDuration: float = 0.05) -> None: """ Vibrates a device """ if Globals.bVibrate: try: Vibrator.vibrate(fDuration) except Exception: try: vibrator.vibrate( VibrationEffect.createOneShot( 1000 * fDuration, VibrationEffect.DEFAULT_AMPLITUDE)) except Exception as e: Logger.error("Error in Vibrate:" + str(e))
def on_muc_receive(self, msg): """ Whenever a group message is received, it is processed according to whatever the user is currently doing. :param Message msg: The XMPP message object. """ sender = str(msg['from']).strip() text = str(msg['body']).strip() if self.chatting == "Operator Group": lab = Label(text=sender.split('/')[1] + ": " + text, size_hint_y=None, markup=True, halign='left') lab.bind(width=lambda s, w: s.setter('text_size')(s, (w, None))) lab.bind(texture_size=lab.setter('size')) lab.color = colorsys.hsv_to_rgb( self.name_to_txt(sender.split('/')[1]), 1, 1) with lab.canvas.before: Color(name_to_bg(sender.split('/')[1]), 1, 1, mode='hsv') lab.bg_rect = Rectangle(pos=self.pos, size=self.size) lab.bind(pos=self.redraw, size=self.redraw) self.sub_layout.add_widget(lab) if self.new: self.sub_layout.remove_widget(self.new_lab) self.new = False else: toast(sender.split('/')[1] + ": " + text, True) vibrator.vibrate(.1) if sender.split('/')[0] in self.messages: self.main_app.xmpp_log('info', 'receiving new message from ' + sender) else: self.main_app.xmpp_log('info', 'receiving first message from ' + sender) m = Message(sender.split('/')[1], text) self.messages[sender.split('/')[0]].append(m)
def on_touch_move(self, touch): if "vjtouch" not in touch.ud: return vec = Vector(touch.pos) - Vector(self.center) vlen = vec.length() if vlen > self.radius: vec = vec.normalize() * self.radius stripsize = 0.2 try: if vlen < self.radius * stripsize or \ self.radius * (1.0 + stripsize) > vlen > self.radius: vibrator.vibrate(0.005) except NotImplementedError: pass self.touch = Vector(self.center) + vec self.vec = vec / self.radius
def ping(*args): count = 0 try: for message in Announcementss.select(): count += 1 print count if count == store.get('announcements')['count']: print 'yeah' osc.sendMsg( '/message', [''.join('yeah'), ], port=3002) else: kwargs = {'title': 'hey', 'message': 'New Devotion in ', 'ticker': 'New Devotion','timeout':4} print 'nah' store.put('announcements',count=count) notification.notify(**kwargs) vibrator.vibrate(.5) except peewee.OperationalError: print('cant connect') else: pass
def fill(l): global oldn n = "" #notification.notify(title="hallo",message="end of parsing fill") for item in l: n+= item[2]+". "+item[5] + ", " if len(l) > 4: n = str(len(l))+ "Vertretungen" if n != oldn: vibrator.vibrate(1) time.sleep(1.2) oldn = n vibrator.vibrate(0.2) time.sleep(0.4) vibrator.vibrate(0.2) time.sleep(0.4) vibrator.vibrate(0.2) time.sleep(0.4) vibrator.vibrate(1) #notification.notify(title="hallo",message="end of parsing end") if n != "" : notification.notify(title="Neue Vertretung(en)",message=n)
def decoded(self, val): ''' if self.message.text != "Labels: ": self.message.text += ", " self.message.text += val ''' if val not in self.labels: self.labels.append(val) #obtener informacion del warehouse leido wh = Warehouses.Query.get(objectId=val) box = Bubble(size_hint_y=None, height=200) labelreceipt = LabelReceipt() labelreceipt.receipt.text = "Receipt#: " + str(wh.Receipt) labelreceipt.zone.text = "Zone: " + wh.Zone labelreceipt.volume.text = "Volume: " + wh.Volume labelreceipt.consignee.text = "[b]Consignee:[/b]\n" + wh.Consignee.Name labelreceipt.country.text = "Country: " + wh.Country labelreceipt.objectId.text = "ID: " + wh.objectId ''' labelreceipt.zone.text = wh.Zone ''' #box.add_widget(Label(text="ID:"+val)) box.add_widget(labelreceipt) if os.path.isfile("box.png"): print "BOX IMAGE FOUND" self.boxlabels.add_widget( box ) vibrator.vibrate(.2)
def __init__(self, **kwargs): print(sm.current_screen) super(HomeScreen, self).__init__(**kwargs) self.cols = 3 self.rows = 2 btn1 = Button(text="BElGen Live Graph") btn2 = Button(text="Lights") btn3 = Button(text="Unused") btn4 = Button(text="Unused") btn5 = Button(text="Unused") btn6 = Button(text="Unused") self.add_widget(btn1) btn1.bind(on_press = callbackgraph) self.add_widget(btn2) btn2.bind(on_press = callbacklights) self.add_widget(btn3) btn3.bind(on_press = callbackunused) self.add_widget(btn4) btn4.bind(on_press = callbackunused) self.add_widget(btn5) btn5.bind(on_press = callbackunused) self.add_widget(btn6) btn6.bind(on_press = callbackunused) vibrator.vibrate(0.1)
def setPreviousView(self): if self.vibrate: vibrator.vibrate(0.05) self.bindroot.setFG("/command/view/prev","true") self.setControllerView(self.current-1)
def vibrate(self, time): vibrator.vibrate(time)
def setNextView(self): if self.vibrate: vibrator.vibrate(0.05) self.bindroot.setFG("/command/view/next","true") self.setControllerView(self.current+1)
def fun(self): vibrator.vibrate(.50)
def callbackgraph(instance): sm.current = 'BElGenLiveGraph' vibrator.vibrate(0.1) print(sm.current_screen) ElectricGraph().run()
def android_vibration(self): if extra_packages == 1: if platform == 'android': vibrator.vibrate(0.1)