tmp
Former-commit-id: b7e0d7df2a42a28fd683029bdf79b88a27cb1130
This commit is contained in:
13
main.py
13
main.py
@ -49,10 +49,12 @@ class MAT:
|
||||
def process_left(self, now: float, value_only=False):
|
||||
if self.state.mode == State.Mode.CRAZY:
|
||||
value_only = True
|
||||
if self.state.mode == State.Mode.ABOUT:
|
||||
return self.total_volume
|
||||
st = self.ch340.start
|
||||
if not value_only:
|
||||
self.ch340.stop()
|
||||
assert abs(self.ch340._get_time()-1) < 1e3
|
||||
assert abs(self.ch340._get_time()-1) < 1e-3
|
||||
r = now - st
|
||||
ret = self.total_volume - (1-r) * self.speeds[self.state.mode.value]
|
||||
if value_only:
|
||||
@ -138,12 +140,12 @@ class MAT:
|
||||
self.control_logger.info(f"middle比例{trans_ratio:.2%}<60%,退出middle检查,返回fast模式")
|
||||
|
||||
if self.state.mode == State.Mode.ABOUT and self.state.about_check:
|
||||
h = self.history.get_recent_records(self.about_time,now)
|
||||
h = self.history.get_recent_records(self.about_time/3,now)
|
||||
ratio = self.history.get_state_ratio("about", h)
|
||||
self.history.about_history.append(ratio<0.3)
|
||||
while len(self.history.about_history) > 10:
|
||||
while len(self.history.about_history) > 5:
|
||||
self.history.about_history.pop(0)
|
||||
if len(self.history.about_history) == 10:
|
||||
if len(self.history.about_history) == 5:
|
||||
rate = sum(self.history.about_history) / len(self.history.about_history)
|
||||
if rate > 0.8:
|
||||
self.state.exit_about()
|
||||
@ -283,7 +285,6 @@ class MAT:
|
||||
self.about_time=about_time
|
||||
|
||||
self.crazy = 0
|
||||
self.state.mode = State.Mode.CRAZY
|
||||
|
||||
while self.running:
|
||||
if not self.ch340.running:
|
||||
@ -358,6 +359,8 @@ if __name__ == "__main__":
|
||||
end_bounce_time=0.01
|
||||
)
|
||||
|
||||
mat.state.mode = State.Mode.FAST
|
||||
|
||||
mat.run(
|
||||
slow_speed = 0.05,
|
||||
quick_speed = 0.15,
|
||||
|
Reference in New Issue
Block a user