From c793a6ad3d5930c134a174f9a444f0bcc13026e0 Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Thu, 15 Jun 2023 01:25:47 +0800 Subject: [PATCH] Opt: Faster camera module --- .../cn/daily/{ => camera}/PICTURE_TAKEN.png | Bin .../share/daily/{ => camera}/TAKE_PICTURE.png | Bin tasks/daily/assets/assets_daily.py | 20 -------------- tasks/daily/assets/assets_daily_camera.py | 25 ++++++++++++++++++ tasks/daily/camera.py | 18 ++++++++----- 5 files changed, 37 insertions(+), 26 deletions(-) rename assets/cn/daily/{ => camera}/PICTURE_TAKEN.png (100%) rename assets/share/daily/{ => camera}/TAKE_PICTURE.png (100%) create mode 100644 tasks/daily/assets/assets_daily_camera.py diff --git a/assets/cn/daily/PICTURE_TAKEN.png b/assets/cn/daily/camera/PICTURE_TAKEN.png similarity index 100% rename from assets/cn/daily/PICTURE_TAKEN.png rename to assets/cn/daily/camera/PICTURE_TAKEN.png diff --git a/assets/share/daily/TAKE_PICTURE.png b/assets/share/daily/camera/TAKE_PICTURE.png similarity index 100% rename from assets/share/daily/TAKE_PICTURE.png rename to assets/share/daily/camera/TAKE_PICTURE.png diff --git a/tasks/daily/assets/assets_daily.py b/tasks/daily/assets/assets_daily.py index 684e39c95..579e7ba4b 100644 --- a/tasks/daily/assets/assets_daily.py +++ b/tasks/daily/assets/assets_daily.py @@ -63,16 +63,6 @@ CONSUMABLES_TRICK_SNACK_CHECK = ButtonWrapper( button=(593, 188, 678, 267), ), ) -PICTURE_TAKEN = ButtonWrapper( - name='PICTURE_TAKEN', - cn=Button( - file='./assets/cn/daily/PICTURE_TAKEN.png', - area=(1030, 620, 1069, 639), - search=(1010, 600, 1089, 659), - color=(153, 153, 155), - button=(1030, 620, 1069, 639), - ), -) RECIPE_UNLOCK = ButtonWrapper( name='RECIPE_UNLOCK', cn=Button( @@ -123,13 +113,3 @@ SYNTHESIZE_GOTO_CONSUMABLES = ButtonWrapper( button=(38, 120, 78, 141), ), ) -TAKE_PICTURE = ButtonWrapper( - name='TAKE_PICTURE', - share=Button( - file='./assets/share/daily/TAKE_PICTURE.png', - area=(1120, 344, 1160, 375), - search=(1100, 324, 1180, 395), - color=(172, 173, 172), - button=(1120, 344, 1160, 375), - ), -) diff --git a/tasks/daily/assets/assets_daily_camera.py b/tasks/daily/assets/assets_daily_camera.py new file mode 100644 index 000000000..3f73a68d4 --- /dev/null +++ b/tasks/daily/assets/assets_daily_camera.py @@ -0,0 +1,25 @@ +from module.base.button import Button, ButtonWrapper + +# This file was auto-generated, do not modify it manually. To generate: +# ``` python -m dev_tools.button_extract ``` + +PICTURE_TAKEN = ButtonWrapper( + name='PICTURE_TAKEN', + cn=Button( + file='./assets/cn/daily/camera/PICTURE_TAKEN.png', + area=(1030, 620, 1069, 639), + search=(1010, 600, 1089, 659), + color=(153, 153, 155), + button=(1030, 620, 1069, 639), + ), +) +TAKE_PICTURE = ButtonWrapper( + name='TAKE_PICTURE', + share=Button( + file='./assets/share/daily/camera/TAKE_PICTURE.png', + area=(1120, 344, 1160, 375), + search=(1100, 324, 1180, 395), + color=(172, 173, 172), + button=(1120, 344, 1160, 375), + ), +) diff --git a/tasks/daily/camera.py b/tasks/daily/camera.py index 9dd63ac59..2e038155a 100644 --- a/tasks/daily/camera.py +++ b/tasks/daily/camera.py @@ -1,8 +1,8 @@ from module.logger import logger from tasks.base.assets.assets_base_page import CLOSE -from tasks.base.page import page_camera +from tasks.base.page import page_camera, page_main from tasks.base.ui import UI -from tasks.daily.assets.assets_daily import * +from tasks.daily.assets.assets_daily_camera import PICTURE_TAKEN, TAKE_PICTURE class CameraUI(UI): @@ -25,7 +25,7 @@ class CameraUI(UI): skip_first_screenshot = False else: self.device.screenshot() - if self.appear_then_click(TAKE_PICTURE): + if self.appear_then_click(TAKE_PICTURE, interval=1): logger.info('Taking picture') continue if self.appear(PICTURE_TAKEN): @@ -38,9 +38,15 @@ class CameraUI(UI): skip_first_screenshot = False else: self.device.screenshot() - if self.appear(TAKE_PICTURE): + if self.appear(page_main.check_button): logger.info('Back to camera main page') break - if self.appear_then_click(CLOSE): - logger.info('Photo page was exited') + if self.appear(PICTURE_TAKEN, interval=1): + self.device.click(CLOSE) + logger.info(f'{PICTURE_TAKEN} -> {CLOSE}') + self.interval_reset(TAKE_PICTURE) + continue + if self.appear(TAKE_PICTURE, interval=1): + self.device.click(CLOSE) + logger.info(f'{TAKE_PICTURE} -> {CLOSE}') continue