def on_event(): #app.btn.event() app.btn.expand_event() if app.btn.home( ) == 2 or launcher.app_run: # click button release to 2 launcher.app_run = False # print('into', app.layer) if app.layer == 1: app.layer += 1 # launcher into application app.load_application(launcher.app_select) elif app.layer == 2: if app.btn.interval() > 1000: # long press app.layer -= 1 app.exit_application() # application return launcher else: app.layer += 1 # help into launcher #launcher.btn.enable = True #if launcher.app_run: #launcher.app_run = False #print('launcher.app_select', launcher.app_select) if app.btn.next() == 1: app.rgb = (app.rgb + 1) % 8 app.rgb_change(app.rgb) if launcher.app_select == 3: photos.image_next() if app.btn.back() == 1: app.rgb = (app.rgb - 1) % 8 app.rgb_change(app.rgb) if launcher.app_select == 3: photos.image_last()
def touch_draw(): app.toth.event() app.loop = (app.loop + 1) % 200 value = math.cos(math.pi * app.loop / 32) * 8 # temp code tmp_x, tmp_l, tmp_r = 0, 0, 0 if app.toth.state == 2: print(app.toth.state, app.toth.points) p = app.toth.points[1] if p[0] > 430 and p[1] > 260: app.layer -= 1 app.exit_application() elif p[0] < 60 and p[1] < 60: app.touch_select = -1 #print(app.touch_select) if launcher.app_select == 1: app.current.page -= 1 elif launcher.app_select == 3: photos.image_last() elif launcher.app_select == 0: ai_camera.back() elif p[0] > 420 and p[1] < 60: app.touch_select = +1 #print(app.touch_select) if launcher.app_select == 1: app.current.page -= 1 elif launcher.app_select == 3: photos.image_last() elif launcher.app_select == 0: ai_camera.next() if app.toth.state == 1: p = app.toth.points[1] if p[0] > 430 and p[1] > 270: tmp_x = int(value) + 30 elif p[0] < 50 and p[1] < 50: tmp_l = int(value) + 30 elif p[0] > 430 and p[1] < 50: tmp_r = int(value) + 30 ui.canvas.draw_circle(ui.height, 0, 40 + tmp_x, thickness=8, fill=False, color=(100, 100, 100)) ui.canvas.draw_circle(ui.height, 0, 38 + tmp_x, fill=True, color=(255, 255, 255)) #ui.canvas.draw_string(ui.height - 15, 5, "x", scale=2, color=(0, 0, 0)) ui.canvas.draw_font(ui.height - 22, 8, 16, 16, app.touch_close, scale=1, color=(155, 155, 0)) ui.canvas.draw_circle(0, ui.weight, 40 + tmp_l, thickness=8, fill=False, color=(100, 100, 100)) ui.canvas.draw_circle(0, ui.weight, 38 + tmp_l, fill=True, color=(255, 255, 100)) #ui.canvas.draw_string(10, ui.weight - 30, "<", scale=2, color=(0, 0, 0)) ui.canvas.draw_font(8, ui.weight - 25, 16, 16, app.touch_left, scale=1, color=(155, 155, 0)) ui.canvas.draw_circle(ui.height, ui.weight, 40 + tmp_r, thickness=8, fill=False, color=(100, 100, 100)) ui.canvas.draw_circle(ui.height, ui.weight, 38 + tmp_r, fill=True, color=(100, 255, 255)) #ui.canvas.draw_string(ui.height - 15, ui.weight - 30, ">", scale=2, color=(0, 0, 0)) ui.canvas.draw_font(ui.height - 20, ui.weight - 25, 16, 16, app.touch_right, scale=1, color=(0, 155, 155))