Opt: Faster camera module

This commit is contained in:
LmeSzinc 2023-06-15 01:25:47 +08:00
parent 71b02ae767
commit c793a6ad3d
5 changed files with 37 additions and 26 deletions

View File

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@ -63,16 +63,6 @@ CONSUMABLES_TRICK_SNACK_CHECK = ButtonWrapper(
button=(593, 188, 678, 267), 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( RECIPE_UNLOCK = ButtonWrapper(
name='RECIPE_UNLOCK', name='RECIPE_UNLOCK',
cn=Button( cn=Button(
@ -123,13 +113,3 @@ SYNTHESIZE_GOTO_CONSUMABLES = ButtonWrapper(
button=(38, 120, 78, 141), 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),
),
)

View File

@ -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),
),
)

View File

@ -1,8 +1,8 @@
from module.logger import logger from module.logger import logger
from tasks.base.assets.assets_base_page import CLOSE 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.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): class CameraUI(UI):
@ -25,7 +25,7 @@ class CameraUI(UI):
skip_first_screenshot = False skip_first_screenshot = False
else: else:
self.device.screenshot() self.device.screenshot()
if self.appear_then_click(TAKE_PICTURE): if self.appear_then_click(TAKE_PICTURE, interval=1):
logger.info('Taking picture') logger.info('Taking picture')
continue continue
if self.appear(PICTURE_TAKEN): if self.appear(PICTURE_TAKEN):
@ -38,9 +38,15 @@ class CameraUI(UI):
skip_first_screenshot = False skip_first_screenshot = False
else: else:
self.device.screenshot() self.device.screenshot()
if self.appear(TAKE_PICTURE): if self.appear(page_main.check_button):
logger.info('Back to camera main page') logger.info('Back to camera main page')
break break
if self.appear_then_click(CLOSE): if self.appear(PICTURE_TAKEN, interval=1):
logger.info('Photo page was exited') 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 continue