umer0586 / SensorServer

Android app which let you stream various phone's sensors to websocket clients
GNU General Public License v3.0
279 stars 31 forks source link

Clear method while live plotting. #38

Closed imvickykumar999 closed 1 year ago

imvickykumar999 commented 1 year ago

I was using IP WebCam to fetch sensor data over https, and my code was able to clear previous graphs from left side while new graphs are plotting from right side of screen as shown in below video.

https://private-user-images.githubusercontent.com/50515418/285238923-8a9b9e2a-e765-4109-abbe-e0cbf6e278e5.mp4?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTEiLCJleHAiOjE3MDA5MjEzMzIsIm5iZiI6MTcwMDkyMTAzMiwicGF0aCI6Ii81MDUxNTQxOC8yODUyMzg5MjMtOGE5YjllMmEtZTc2NS00MTA5LWFiYmUtZTBjYmY2ZTI3OGU1Lm1wND9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFJV05KWUFYNENTVkVINTNBJTJGMjAyMzExMjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjMxMTI1VDE0MDM1MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZlMDBiMmY5ZDAwNDE2NGEyNDBhYTA3OTkyZDU1ZjU4MTY3MzIwMWExY2FkMWQ0MWY2NGE4M2Y2YjcxYzc0YmQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.bgArcP2lwfHOrREB1zlBAoVqrHJKWV4Ohl7YmLbH0SM

But when I am running your code, it is not clearing instead it's squeezing as shown below.

python live_plot.py
C:\Users\Vicky\anaconda3\lib\site-packages\pyqtgraph\colors\palette.py:1: RuntimeWarning: PyQtGraph supports Qt version >= 5.15, but 5.9.7 detected.
  from ..Qt import QtGui
connected to : 192.168.0.102:8080

image

umer0586 commented 1 year ago

From the code

    def update_plot_data(self):

        # limit lists data to 1000 items 
        limit = -1000 

        # Update the data.
        self.x_data_line.setData(time_data[limit:], x_data[limit:])  
        self.y_data_line.setData(time_data[limit:], y_data[limit:])
        self.z_data_line.setData(time_data[limit:], z_data[limit:])

When sensor events exceed 1000, graph will automatically appear shifting from left to right. So you have to wait until your device delivers 1000 events or change this value to 500 ( limit = -500)