local a=require('data.min')local b=require('battery.min')local c=require('camera.min')local d=require('code.min')local e=require('plain_text.min')CAPTURE_SETTINGS_MSG=0x0d;AUTO_EXP_SETTINGS_MSG=0x0e;MANUAL_EXP_SETTINGS_MSG=0x0f;TEXT_MSG=0x0a;TAP_SUBS_MSG=0x10;a.parsers[CAPTURE_SETTINGS_MSG]=c.parse_capture_settings;a.parsers[AUTO_EXP_SETTINGS_MSG]=c.parse_auto_exp_settings;a.parsers[MANUAL_EXP_SETTINGS_MSG]=c.parse_manual_exp_settings;a.parsers[TEXT_MSG]=e.parse_plain_text;a.parsers[TAP_SUBS_MSG]=d.parse_code;TAP_MSG=0x09;AUTO_EXP_MSG=0x12;function handle_tap()rc,err=pcall(frame.bluetooth.send,string.char(TAP_MSG))if rc==false then print(err)end end;function print_text()local f=0;for g in a.app_data[TEXT_MSG].string:gmatch("([^\n]*)\n?")do if g~=""then frame.display.text(g,1,f*60+1)f=f+1 end end end;function clear_display()frame.display.text(" ",1,1)frame.display.show()frame.sleep(0.04)end;function show_flash()frame.display.bitmap(241,191,160,2,0,string.rep("\xFF",400))frame.display.bitmap(311,121,20,2,0,string.rep("\xFF",400))frame.display.show()frame.sleep(0.04)end;function app_loop()clear_display()local h=0;while true do rc,err=pcall(function()local i=a.process_raw_items()if i>0 then if a.app_data[CAPTURE_SETTINGS_MSG]~=nil then show_flash()rc,err=pcall(c.capture_and_send,a.app_data[CAPTURE_SETTINGS_MSG])clear_display()if rc==false then print(err)end;a.app_data[CAPTURE_SETTINGS_MSG]=nil end;if a.app_data[AUTO_EXP_SETTINGS_MSG]~=nil then rc,err=pcall(c.set_auto_exp_settings,a.app_data[AUTO_EXP_SETTINGS_MSG])if rc==false then print(err)end;a.app_data[AUTO_EXP_SETTINGS_MSG]=nil end;if a.app_data[MANUAL_EXP_SETTINGS_MSG]~=nil then rc,err=pcall(c.set_manual_exp_settings,a.app_data[MANUAL_EXP_SETTINGS_MSG])if rc==false then print(err)end;a.app_data[MANUAL_EXP_SETTINGS_MSG]=nil end;if a.app_data[TEXT_MSG]~=nil and a.app_data[TEXT_MSG].string~=nil then print_text()frame.display.show()a.app_data[TEXT_MSG]=nil end;if a.app_data[TAP_SUBS_MSG]~=nil then if a.app_data[TAP_SUBS_MSG].value==1 then print('subscribing for taps')frame.imu.tap_callback(handle_tap)else print('cancel subscription for taps')frame.imu.tap_callback(nil)end;a.app_data[TAP_SUBS_MSG]=nil end end;h=b.send_batt_if_elapsed(h,120)if c.is_auto_exp then autoexp_result=c.run_auto_exposure()c.send_autoexp_result(autoexp_result)end;frame.sleep(0.1)end)if rc==false then print(err)frame.display.text(" ",1,1)frame.display.show()frame.sleep(0.04)break end end end;app_loop()