Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

after calling an plyer audio function from an accelerometer function, App crashes. #361

Closed
Akash3194 opened this issue Jul 25, 2017 · 8 comments

Comments

@Akash3194
Copy link

Akash3194 commented Jul 25, 2017

[from kivy.app import App
from kivy.lang import Builder
from kivy.clock import Clock
from plyer import accelerometer
from kivy.uix .relativelayout import RelativeLayout
from kivy.properties import ObjectProperty, NumericProperty

Builder.load_string("""
:
BoxLayout:
orientation:'vertical'
Label:
id: x_val
text: 'X:'
Label:
id: y_val
text: 'y:'
Label:
id: z_val
text: 'z:'

    Label:
        id: x_tst
        text: 'value:'
        
BoxLayout:
    size_hint_y: None
    height: '48dp'
    padding: '4dp'

    ToggleButton:
        id: start_btn
        text: 'Start accelerometer'
        on_press: root.accelerometer()

""")

class Accel(RelativeLayout):

audio = ObjectProperty()
time = NumericProperty()

has_record = False

def __init__(self):
    super(Accel, self).__init__()
    self.sensorEnabled=False
    self.counter=0
    self.x_axis=[0,0,0,0,0]
    self.pan=0

def record(self):

    state = self.audio.state
    if state == 'ready':
        self.audio.start()
        self.ids.x_tst.text = "recording started"

def accelerometer(self):


    if not self.sensorEnabled:
        accelerometer.enable()
        Clock.schedule_interval(self.accelerate, 1/5)
        self.sensorEnabled =True
        self.ids.start_btn.text="Stop"
    else:
        accelerometer.disable()
        Clock.unschedule(self.accelerate)
        self.sensorEnabled =False
        self.ids.start_btn.text = "Start"

def accelerate(self,dt):
    val=accelerometer.acceleration[:3]


    if not val==(None,None,None):
        self.ids.x_val.text="X:" +str(val[0])
        self.ids.y_val.text="y:" +str(val[1])
        self.ids.z_val.text="z:" +str(val[2])



        if self.counter<5:
            self.x_axis[self.counter] = val[0]
            self.k=self.x_axis[self.counter]-self.x_axis[self.counter-1]
            if self.k>8:
                self.record()
            self.counter += 1
        else:
            self.counter=0

class MeterApp(App):
def build(self):
return Accel()

if name=="main":
MeterApp().run()

]

well this programming is for detecting shake and acting on the command given.
When i call self.record() in accelerate() function, app crashes but when i do something else like giving comand to change labels text it dont crash.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@sumitmadhwani
Copy link
Contributor

@Akash3194 please share the logs you see on the terminal. It would help us to see where exactly you are facing error.

@Akash3194
Copy link
Author

Akash3194 commented Jul 26, 2017

@Malverick i am converting this program into apk and running that apk file on my android phone and when i start accelerometer it it runs smoothely but when i shake my phone, instead of recording, the app crashes. How can i share logs here?

@sumitmadhwani
Copy link
Contributor

@Akash3194 see it here.

@Akash3194
Copy link
Author

Akash3194 commented Jul 30, 2017

@Malverick , I followed these instructions but every time when i run the 6th step then in between a error pops up that says adb not found --waiting for device--. This app which i am trying to make is really important from me. please help, i am trying to find its solution from many days but failing , can u please help, will you please run the above code in your PC and find the error?? Please help me

@sumitmadhwani
Copy link
Contributor

@Akash3194 pm me on IRC (#malverick). We can have a proper discussion there.

@Akash3194
Copy link
Author

@Malverick i texted you on IRC

@sumitmadhwani
Copy link
Contributor

@Akash3194 I didn't receive it. You can contact me on my email - [email protected]

@KeyWeeUsr
Copy link
Contributor

Try to use the latest release (1.3.1) and open a new issue if the problem is still present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants