main.py 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. #!/usr/bin/env python
  2. #version : 2024.08.16
  3. #language : en
  4. #hardware : pi
  5. import time
  6. from maix import *
  7. import gc
  8. import os,sys
  9. import sys
  10. sys.path.append('/root/')
  11. from CocoPi import BUTTON
  12. from CocoPi import stm8s
  13. from CocoPi import multiFuncGpio
  14. from CocoPi import singleRgb
  15. from CocoPi import LED
  16. gc.enable()
  17. gc.collect()
  18. iic_slaver=stm8s()
  19. iic_slaver.clear()
  20. PIXEL_LED1= multiFuncGpio(0,7)
  21. PIXEL_LED2= multiFuncGpio(1,7)
  22. PIXEL_LED1.pixelInit_()
  23. time.sleep(0.1)
  24. PIXEL_LED2.pixelInit_()
  25. time.sleep(0.1)
  26. L1=singleRgb()
  27. L1.setColor(0,0,0)
  28. L1.show()
  29. time.sleep(0.1)
  30. L2=LED()
  31. L2.out(0)
  32. del iic_slaver
  33. del PIXEL_LED1
  34. del PIXEL_LED2
  35. del L1
  36. del L2
  37. count = 0
  38. def gc_log():
  39. global count
  40. gc.collect()
  41. count = count + 1
  42. splash_theme_color = (15,21,46)
  43. btn_selected = (255,255,255)
  44. btn_unselected = (76,86,127)
  45. txt_selected = (255,255,255)
  46. txt_unselected = (76,86,127)
  47. color_splash_theme = (15,21,46)
  48. color_blue = (31,61,185)
  49. color_blue_lighter = (60,131,211)
  50. color_white = (255,255,255)
  51. color_gray = (60,73,126)
  52. color_orange = (255,165,0)
  53. color_red = (255,0,0)
  54. btn_width = 134
  55. btn_height = 52
  56. btn_y_base = 5
  57. btn_col = (btn_y_base, btn_y_base+btn_width, btn_y_base+152)
  58. btn_row = 180
  59. main_title = (
  60. "Run",
  61. "Latest code",
  62. "Open",
  63. "Demo list",
  64. "B",
  65. "A"
  66. )
  67. splash_text = (
  68. "Version: 2024-08-16 ",
  69. "System version: N/A",
  70. "2. After loading the code,press ",
  71. " KEY-A for 2s to back to start ",
  72. " interface.",
  73. "Running Latest Code...",
  74. "Error: code not found.",
  75. "Error: invalid syntax",
  76. "Opening Demo Menu...",
  77. "Demo menu not found.",
  78. "Run",
  79. "Loading...",
  80. "Back",
  81. "Press KEY-C To Back",
  82. "Press KEY-D To Reboot",
  83. "Press KEY-B To Poweroff",
  84. "1. Press KEY-A for 5s to shut down",
  85. " the CocoPi or reboot the CocoPi.",
  86. " ",
  87. "CocoPi V6",
  88. "/ Linux / AIot /Python /",
  89. "/Graphical programming /",
  90. "------- BASIC -------",
  91. "-------- AI ---------",
  92. "-------- IoT --------",
  93. )
  94. title_logo_text = image.open("/root/preset/img/cocorobo_text.jpg")
  95. iconUpNp = image.open("/root/preset/img/arrow_up_filled.jpg")
  96. iconUpP = image.open("/root/preset/img/arrow_up_pressed.jpg")
  97. iconDownNp = image.open("/root/preset/img/arrow_down_filled.jpg")
  98. iconDownP = image.open("/root/preset/img/arrow_down_pressed.jpg")
  99. frostedGlass = image.open("/root/preset/img/frostedglass_.jpg")
  100. #backUp = image.open("/root/preset/img/backup_48x48.png")
  101. #powerOff = image.open("/root/preset/img/poweroff_48x48.png")
  102. #reBoot = image.open("/root/preset/img/reboot_48x48.png")
  103. run_user_code_path='/root/user_latest_code.py'
  104. key_A = BUTTON(14)
  105. key_B = BUTTON(8)
  106. key_C = BUTTON(13)
  107. key_D = BUTTON(7)
  108. splash = image.new(size=(320, 240),mode = "RGB")
  109. img_drop=image.new(size=(320,240),mode="RGB")
  110. demo_i=0
  111. demo_j=0
  112. demo_m=0
  113. demo_n=0
  114. pressTime=0
  115. systemRunNum=0
  116. image.load_freetype("/root/preset/fonts/CascadiaCodePL-Italic.ttf")
  117. def screenFirstPage():
  118. from maix import display,image,camera
  119. global splash,title_logo_text,btn_col,btn_row,splash_text,txt_unselected,txt_selected,btn_selected,btn_unselected,\
  120. splash_theme_color,btn_height,btn_width,main_title,menuSelect,gc_log,demo_i,demo_j,demo_m,demo_n,screenShow,img_drop,\
  121. frostedGlass
  122. gc_log()
  123. splash.clear()
  124. splash.draw_rectangle(0,0,320,320,color=splash_theme_color,thickness=-1)
  125. splash.draw_image(title_logo_text, btn_col[0]+16, 10)
  126. x, y = image.get_string_size(splash_text[0], 1)
  127. splash.draw_string(btn_col[0]+16, 40, splash_text[19]+" "+splash_text[0], color=(0,255,255), thickness = 1)
  128. # splash.draw_string(btn_col[0], 60, splash_text[20], color=(0,255,255), thickness = 1)
  129. # splash.draw_string(btn_col[0], 80, splash_text[21], color=(0,255,255), thickness = 1)
  130. # splash.draw_string(btn_col[0], 60, splash_text[0], color=(0,255,255), thickness = 1)
  131. splash.draw_string(btn_col[0]+16, btn_row-105, splash_text[16], color=txt_unselected, thickness = 1)
  132. splash.draw_string(btn_col[0]+16, btn_row-85, splash_text[17], color=txt_unselected, thickness = 1)
  133. #splash.draw_string(btn_col[0], btn_row-105, splash_text[18], color=txt_unselected, thickness = 1)
  134. splash.draw_string(btn_col[0]+16, btn_row-65, splash_text[2], color=txt_unselected, thickness = 1)
  135. splash.draw_string(btn_col[0]+16, btn_row-45, splash_text[3], color=txt_unselected, thickness = 1)
  136. splash.draw_string(btn_col[0]+16, btn_row-25, splash_text[4], color=txt_unselected, thickness = 1)
  137. if menuSelect==0:
  138. splash.draw_rectangle(btn_col[1]+40, btn_row, btn_col[1]+btn_width+42, btn_row+btn_height, color=btn_selected, thickness=1)
  139. splash.draw_string(btn_col[1]+52, btn_row+7, main_title[2], color=txt_selected, thickness = 1)
  140. splash.draw_string(btn_col[1]+52, btn_row+27, main_title[3], color=txt_selected, thickness = 1)
  141. splash.draw_string(btn_col[1]+157, btn_row+27, main_title[5], color=txt_unselected, thickness = 1)
  142. splash.draw_rectangle(btn_col[0], btn_row, btn_col[0]+btn_width, btn_row+btn_height, color=btn_selected, thickness=1)
  143. splash.draw_string(btn_col[0]+96, btn_row+7, main_title[0], color=txt_selected, thickness = 1)
  144. splash.draw_string(btn_col[0]+26, btn_row+27, main_title[1], color=txt_selected, thickness = 1)
  145. splash.draw_string(btn_col[0]+7, btn_row+27, main_title[4], color=txt_unselected, thickness = 1)
  146. if menuSelect==1:
  147. splash.draw_rectangle(btn_col[0], btn_row, btn_col[0]+btn_width, btn_row+btn_height, color=btn_unselected, thickness=1)
  148. splash.draw_string(btn_col[0]+7, btn_row+7, main_title[0], color=txt_unselected, thickness = 1)
  149. splash.draw_string(btn_col[0]+7, btn_row+27, main_title[1], color=txt_unselected, thickness = 1)
  150. splash.draw_rectangle(btn_col[1], btn_row, btn_col[1]+btn_width, btn_row+btn_height, color=btn_selected, thickness=1)
  151. splash.draw_string(btn_col[1]+7, btn_row+7, main_title[2], color=txt_selected, thickness = 1)
  152. splash.draw_string(btn_col[1]+7, btn_row+27, main_title[3], color=txt_selected, thickness = 1)
  153. splash.draw_image(frostedGlass, 0, 0,alpha=0.2)
  154. #screenShow()
  155. display.show(splash)
  156. def screenSecondPage():
  157. from maix import display, image,camera
  158. global splash,title_logo_text,btn_col,btn_row,splash_text,txt_unselected,txt_selected,btn_selected,btn_unselected,\
  159. splash_theme_color,btn_height,btn_width,main_title,demoSelect,gc_log,color_splash_theme,color_blue,color_blue_lighter,\
  160. color_white,color_gray,color_orange,color_red,iconUpNp,iconUpP,iconDownNp,iconDownP,demoListText,screenShow,img_drop,\
  161. frostedGlass
  162. gc_log()
  163. splash.clear()
  164. splash.draw_rectangle(0,0,320,240,color=splash_theme_color,thickness=-1)
  165. splash.draw_rectangle(0,0,320,32,color=color_blue,thickness=-1)
  166. splash.draw_image(iconUpNp, 3, 3)
  167. splash.draw_image(iconDownNp, 287, 3)
  168. splash.draw_rectangle(0,214,50,240,color=color_blue,thickness=-1)
  169. splash.draw_rectangle(270,214,320,240,color=color_blue,thickness=-1)
  170. splash.draw_string(12, 218, splash_text[10], color=(255,255,255), thickness = 1)
  171. splash.draw_string(282, 218, splash_text[12], color=(255,255,255), thickness = 1)
  172. demo_i=int(demoSelect/6)
  173. demo_j=demoSelect%6
  174. demo_m=int(demoNum/6)
  175. demo_n=demoNum%6
  176. for j in range(6):
  177. if demo_i==demo_m:
  178. if j>=demo_n:
  179. pass
  180. else:
  181. if j==demo_j:
  182. pass
  183. else:
  184. splash.draw_rectangle(0,33+30*j,319,33+30*(j+1),color=color_gray,thickness=1)
  185. splash.draw_string(8, 39+30*j,demoListText[j+demo_i*6] , color=color_gray, thickness = 1)
  186. else:
  187. if j==demo_j:
  188. pass
  189. else:
  190. splash.draw_rectangle(0,33+30*j,319,33+30*(j+1),color=color_gray,thickness=1)
  191. splash.draw_string(8, 39+30*j,demoListText[j+demo_i*6] , color=color_gray, thickness = 1)
  192. if demoSelect<13:
  193. splash.draw_string(72, 10, splash_text[22], color=(255,255,255), thickness = 1)
  194. elif demoSelect<31:
  195. splash.draw_string(72, 10, splash_text[23], color=(255,255,255), thickness = 1)
  196. else:
  197. splash.draw_string(72, 10, splash_text[24], color=(255,255,255), thickness = 1)
  198. splash.draw_rectangle(0,33+30*demo_j,319,33+30*(demo_j+1),color=color_white,thickness=1)
  199. splash.draw_string(8, 39+30*demo_j,demoListText[demoSelect] , color=color_white, thickness = 1)
  200. splash.draw_string(146, 218, str(demoSelect+1), color=(255,255,255), thickness = 1)
  201. splash.draw_string(160, 218, "/"+str(demoNum), color=(255,255,255), thickness = 1)
  202. splash.draw_image(frostedGlass, 0, 0,alpha=0.2)
  203. #screenShow()
  204. display.show(splash)
  205. def systemPage():
  206. from maix import display, image,camera
  207. import time
  208. global splash,title_logo_text,btn_col,btn_row,splash_text,txt_unselected,txt_selected,btn_selected,btn_unselected,\
  209. splash_theme_color,btn_height,btn_width,main_title,demoSelect,gc_log,color_splash_theme,color_blue,color_blue_lighter,\
  210. color_white,color_gray,color_orange,color_red,iconUpNp,iconUpP,iconDownNp,iconDownP,demoListText,screenShow,img_drop,\
  211. frostedGlass
  212. for i in range(10):
  213. splash.draw_image(frostedGlass, 0, 0,alpha=0.2)
  214. #screenShow()
  215. display.show(splash)
  216. splash.draw_string(80, 68, splash_text[13], 1,color=(0,255,0), thickness = 1)
  217. splash.draw_string(80, 118, splash_text[14], 1,color=(255,255,0), thickness = 1)
  218. splash.draw_string(80, 168, splash_text[15], 1,color=(255,0,0), thickness = 1)
  219. #splash.draw_image(backUp, 20, 140)
  220. #screenShow()
  221. splash.draw_image((image.open("/root/preset/img/backup_00ff00_32x32.png")).rotate(0, adjust=0),40,60,alpha=1)
  222. splash.draw_image((image.open("/root/preset/img/reboot_ffff00_32x32.png")).rotate(0, adjust=0),40,110,alpha=1)
  223. splash.draw_image((image.open("/root/preset/img/poweroff_ff0000_32x32.png")).rotate(0, adjust=0),40,160,alpha=1)
  224. display.show(splash)
  225. pageVal=0
  226. menuSelect=0
  227. demoSelect=0
  228. execVal=0
  229. demoListText=(
  230. "Camera",
  231. "Photo Viewer",
  232. "Color Detection",
  233. "Audio Recorder",
  234. "Audio Player",
  235. "Play Music",
  236. "Play Video",
  237. "Time Counter",
  238. "Local Time Clock",
  239. "Servo Control",
  240. "Motor Control",
  241. "Picture Loop Play",
  242. "QR Code Scanner",
  243. "Human Detection",
  244. "Face Recognition",
  245. "Face Comparison",
  246. "Object Recognition",
  247. "Edge Detection",
  248. "Handwritten Digit Recognition",
  249. "Car License Plate Recognition",
  250. "Mask Detection",
  251. "Gesture Recognition",
  252. "Finger Guessing",
  253. "Wi-Fi QR Code Scanner",
  254. "About CocoPi",
  255. "Internet Camera",
  256. "Internet Weather Prediction",
  257. "Internet Time Clock",
  258. "Environment Detection",
  259. "Model Training:Data Collect",
  260. "Model Training:Deploy Model",
  261. "Mnist Model Training",
  262. "Mnist Camera Test",
  263. "CocoGPT",
  264. "CocoTerminal",
  265. "Picture Analysis",
  266. "Speech To Image",
  267. "Jumpbot",
  268. "Gluttonous Snake",
  269. "Sound Loudness Analysis",
  270. "Sound Spectrum Analysis",
  271. "checkout",
  272. "pull",
  273. "reset",
  274. )
  275. demoNameList=(
  276. "01_camera",
  277. "02_photoViewer",
  278. "03_colorDetection",
  279. "04_recorder",
  280. "05_audioPlayer",
  281. "06_musicPlayer",
  282. "07_videoPlayer",
  283. "08_timeCounter",
  284. "09_localTimeClock",
  285. "10_servoControl",
  286. "11_motorControl",
  287. "12_pictureLoopPlay",
  288. "13_qrCodeScanner",
  289. "14_humanDetection",
  290. "15_faceDetection",
  291. "16_faceComparison",
  292. "17_objectRecognition",
  293. "18_edgeDetection",
  294. "19_handWrittenDigiRecognition",
  295. "20_carLicensePlateRecognition",
  296. "21_maskDetection",
  297. "22_gestureRecognition",
  298. "23_fingerGuessing",
  299. "24_connectWiFi",
  300. "25_aboutCocoPi",
  301. "26_internetCamera",
  302. "27_internetWeatherPrediction",
  303. "28_internetTimeClock",
  304. "29_environmentDetection",
  305. "30_training_data_collect",
  306. "31_training_deploy_model",
  307. "32_mnistModelTraining",
  308. "33_mnistCameraTest",
  309. "34_CocoGPT",
  310. "35_CocoTerminal",
  311. "36_pictureAnalysis",
  312. "37_speechToImageSynthesis",
  313. "38_jumpbot",
  314. "39_gluttonousSnake",
  315. "40_soundLoudnessAnalysis",
  316. "41_soundSpectrumAnalysis",
  317. "checkout",
  318. "pull",
  319. "reset",
  320. )
  321. demoNum=len(demoListText)
  322. pageSig=1
  323. selectSig=1
  324. ###需要查询的文件夹目录及文件格式后缀###
  325. def getAimFileList(filePath="/root/",selectFile=".REC"):
  326. import os
  327. FileList=[]
  328. aimFilePath=filePath
  329. aimFile=selectFile
  330. aimFileLenth=len(selectFile)*(-1)
  331. for root,dirs,files in os.walk(aimFilePath):
  332. for name in files:
  333. if str(name)[aimFileLenth:]==aimFile:
  334. FileList.append(name)
  335. return FileList
  336. def buttonDectect():
  337. from maix import display, image,camera
  338. import time
  339. import os
  340. global key_A,key_B,key_C,key_D,pageVal,menuSelect,execVal,demoNum,demoSelect,splash,iconUpP,iconDownP,screenShow,img_drop,systemRunNum,pageSig,selectSig
  341. if(pageVal==0):
  342. if(key_A.is_pressed()):
  343. pressTime=time.perf_counter()
  344. while key_A.is_pressed()==1:
  345. if(time.perf_counter()-pressTime)<5:
  346. time.sleep(0.001)
  347. pageVal=1
  348. else:
  349. pageVal=2
  350. break
  351. execVal=0
  352. elif(key_B.is_pressed()):
  353. while key_B.is_pressed()==1:
  354. time.sleep(0.001)
  355. execVal=1
  356. # elif (key_B.is_pressed()):
  357. # while key_B.is_pressed()==1:
  358. # time.sleep(0.001)
  359. # pageVal=1
  360. else:
  361. pass
  362. elif(pageVal==1):
  363. if execVal==0:
  364. if(key_D.is_pressed()):
  365. splash.draw_image(iconUpP, 3, 3)
  366. #screenShow()
  367. display.show(splash)
  368. while key_D.is_pressed()==1:
  369. time.sleep(0.001)
  370. demoSelect=demoSelect-1
  371. if(demoSelect==-1):
  372. demoSelect=demoNum-1
  373. elif (key_C.is_pressed()):
  374. splash.draw_image(iconDownP, 287, 3)
  375. #screenShow()
  376. display.show(splash)
  377. while key_C.is_pressed()==1:
  378. time.sleep(0.001)
  379. demoSelect=demoSelect+1
  380. if(demoSelect==demoNum):
  381. demoSelect=0
  382. elif (key_B.is_pressed()):
  383. while key_B.is_pressed()==1:
  384. time.sleep(0.001)
  385. execVal=2+demoSelect
  386. elif (key_A.is_pressed()):
  387. while key_A.is_pressed()==1:
  388. time.sleep(0.001)
  389. menuSelect=0
  390. pageVal=0
  391. demoSelect=0
  392. execVal=0
  393. try:
  394. with open( '/tmp/page.txt', 'w' ) as f:
  395. f.write(str(pageVal))
  396. except:
  397. pass
  398. try:
  399. with open( '/tmp/menu.txt', 'w' ) as f:
  400. f.write(str(demoSelect))
  401. except:
  402. pass
  403. pageSig=1
  404. selectSig=1
  405. else:
  406. pass
  407. else:
  408. if (key_A.is_pressed()):
  409. while key_A.is_pressed()==1:
  410. time.sleep(0.001)
  411. menuSelect=0
  412. pageVal=0
  413. demoSelect=0
  414. execVal=0
  415. systemRunNum=0
  416. elif pageVal==2:
  417. if(key_C.is_pressed()):
  418. pageVal=0
  419. menuSelect=0
  420. pageVal=0
  421. demoSelect=0
  422. execVal=0
  423. systemRunNum=0
  424. elif key_B.is_pressed():
  425. os.system("poweroff")
  426. elif key_D.is_pressed():
  427. os.system("reboot")
  428. else:
  429. pass
  430. def running():
  431. from maix import display, image,camera
  432. global splash,title_logo_text,btn_col,btn_row,splash_text,txt_unselected,txt_selected,btn_selected,btn_unselected,\
  433. splash_theme_color,btn_height,btn_width,main_title,menuSelect,pageVal,execVal,screenFirstPage,screenSecondPage,\
  434. color_splash_theme,color_blue,color_blue_lighter,color_white,color_gray,color_orange,color_red,demo_i,demo_j,\
  435. demo_m,demo_n,screenShow,img_drop,systemRunNum,systemPage,demoNameList,pageSig,selectSig,demoSelect
  436. if pageSig==1:
  437. try:
  438. with open( '/tmp/page.txt', 'r' ) as f:
  439. pageVal=int(f.read())
  440. print(pageVal)
  441. pageSig=0
  442. except:
  443. pass
  444. if selectSig==1:
  445. try:
  446. with open( '/tmp/menu.txt', 'r' ) as f:
  447. demoSelect=int(f.read())
  448. print(demoSelect)
  449. selectSig=0
  450. except:
  451. pass
  452. if(pageVal==0):
  453. screenFirstPage()
  454. if(execVal==0):
  455. pass
  456. #splash.draw_rectangle(btn_col[0], btn_row-26,btn_col[0]+220,26, color=splash_theme_color, thickness=1)
  457. #screenShow()
  458. #display.show(splash)
  459. else:
  460. try:
  461. splash.draw_string(btn_col[0], btn_row-25, splash_text[5], color=(0,255,255),thickness = 1)
  462. #screenShow()
  463. display.show(splash)
  464. time.sleep(0.5)
  465. os.system("ln -sf %s /tmp/event && touch /tmp/start" % "/root/user_latest_code.py")
  466. except BaseException as e:
  467. execVal=0
  468. print(str(e))
  469. splash.draw_rectangle(btn_col[0], btn_row-26,btn_col[0]+220,26, color=splash_theme_color, thickness=1)
  470. splash.draw_string(btn_col[0], btn_row-85, splash_text[9], color=(255,0,0), thickness = 1)
  471. #screenShow()
  472. display.show(splash)
  473. elif(pageVal==1):
  474. if(execVal==0):
  475. screenSecondPage()
  476. #print("show(demoSelect)")
  477. else:
  478. demo_i=int(demoSelect/6)
  479. demo_j=demoSelect%6
  480. demo_m=int(demoNum/6)
  481. demo_n=demoNum%6
  482. splash.draw_rectangle(0,33+30*demo_j,319,33+30*(demo_j+1),color=color_orange,thickness=-1)
  483. splash.draw_rectangle(0,33+30*demo_j,319,33+30*(demo_j+1),color=color_white,thickness=1)
  484. splash.draw_string(8, 39+30*demo_j,splash_text[11] , color=color_white, thickness = 1)
  485. #screenShow()
  486. display.show(splash)
  487. time.sleep(0.5)
  488. app_path_1='ln -sf /root/preset/app/'
  489. app_path_2='.py /tmp/event && touch /tmp/start'
  490. app_path=app_path_1+demoNameList[execVal-2]+app_path_2
  491. #print(app_path)
  492. try:
  493. with open( '/tmp/page.txt', 'w' ) as f:
  494. f.write(str(pageVal))
  495. except:
  496. pass
  497. try:
  498. with open( '/tmp/menu.txt', 'w' ) as f:
  499. f.write(str(demoSelect))
  500. except:
  501. pass
  502. pageSig=1
  503. selectSig=1
  504. os.system(app_path)
  505. else:
  506. if systemRunNum==0:
  507. systemPage()
  508. systemRunNum=systemRunNum+1
  509. else:
  510. pass
  511. def screenShow():
  512. from maix import image,display,camera
  513. global img_drop
  514. screenCapture=splash.crop(0,0,240,320)
  515. img_drop.draw_image((screenCapture.rotate(0,adjust=1)),0,0)
  516. #img_drop.draw_image((screenCapture.rotate(-90,adjust=1)),0,0)
  517. display.show(img_drop)
  518. try:
  519. aimFileShow=getAimFileList()
  520. aimFileNum=len(aimFileShow)
  521. if aimFileNum>0:
  522. #os.system("rm /root/"+aimFileShow[0])
  523. os.system("rm /root/*.REC")
  524. #print("del rec action!")
  525. #aimFileShow=getAimFileList()
  526. #aimFileNum=len(aimFileShow)
  527. #print(aimFileShow)
  528. except:
  529. pass
  530. try:
  531. os.system("touch /etc/wifi/test")
  532. except:
  533. os.system("{ wpa_supplicant -i wlan0 -D nl80211 -c /etc/wifi/wpa_supplicant.conf -O /etc/wifi/sockets -B ; } ; \
  534. { [ -f /etc/wifi/wpa_supplicant.conf.tmp ] && rm /etc/wifi/wpa_supplicant.conf.tmp && rm /etc/wifi/wpa_supplicant.conf && echo "" \
  535. > /etc/wifi/wpa_supplicant.conf; sync; } ; { echo "" > /etc/wifi/fileCfgTest && echo "" > /root/fileCfgTest && echo "" > \
  536. /home/fileCfgTest && echo "" > /tmp/fileCfgTest; } || { sync; fsck.ext4 -y /dev/root; fsck.ext4 -y /dev/mmcblk0p4; \
  537. (mount -o remount,rw -n /dev/root / ; mount -o remount,rw -n /dev/mmcblk0p4 / ; mount -o remount,rw -n /dev/mmcblk0p4 /mnt/UDISK ;\
  538. mount -o remount,rw -n / / ; mount -o remount,rw -n /root / ; ) ; fsck.ext4 -y /dev/root; fsck.ext4 -y /dev/mmcblk0p4; sync ; }")
  539. finally:
  540. os.system("rm /etc/wifi/test")
  541. try:
  542. os.popen("cd /root/preset/server/ && python wirelessServer.py &")
  543. except:
  544. pass
  545. while True:
  546. buttonDectect()
  547. running()
  548. del key_A
  549. del key_B
  550. del key_C
  551. del key_D