Freenove / Freenove_Big_Hexapod_Robot_Kit_for_Raspberry_Pi

Apply to FNK0052
Other
114 stars 86 forks source link

CPU / Battery usage #2

Open haakoni opened 3 years ago

haakoni commented 3 years ago

The server runs in a tight loop even when in "relaxed" mode (10 second idle timeout)

I would suggest to add this simple change to keep the raspberry much cooler and not using so much power when idle/relaxed;

diff --git a/Code/Server/Control.py b/Code/Server/Control.py
index 7e73f6e..d26060b 100644
--- a/Code/Server/Control.py
+++ b/Code/Server/Control.py
@@ -152,6 +152,8 @@ class Control:
         return flag
     def condition(self):
         while True:
+            if self.flag==0x00:
+                time.sleep(0.01)
             if (time.time()-self.timeout)>10 and  self.timeout!=0 and self.order[0]=='':
                 self.timeout=time.time()
                 self.relax(True)
DenzelChen commented 3 years ago

Thank you for your suggestion. We will optimize the code. Have a nice day. :)