@@ -32,7 +32,6 @@ def get_files(base):
3232 file_names .append ((filetext , False ))
3333 return filenames
3434
35- # Get a touch from the touchscreen (blocking function)
3635def get_touch (screen ):
3736 p = None
3837 while p is None :
@@ -206,84 +205,3 @@ def get_touch(screen):
206205 labels [i ].text = " "
207206# End while
208207
209-
210- filetype = BMP
211- elif filename .endswith (".wav" ):
212- filetype = WAV
213- elif filename .endswith (".py" ):
214- filetype = PY
215- else :
216- filetype = FILE
217- # Set icon location information and icon type
218- sprites [spot ].x = xpos
219- sprites [spot ].y = ypos
220- sprites [spot ][0 ] = filetype
221- #
222- # Set filename
223- labels [spot ].x = xpos
224- labels [spot ].y = ypos + ICONSIZE + TEXTSPACE
225- # The next line gets the filename without the extension, first 11 chars
226- labels [spot ].text = filename .rsplit ('.' , 1 )[0 ][0 :10 ]
227-
228- currentpage = PAGE
229-
230- # Pagination Handling
231- if spot >= PAGEMAXFILES - 1 :
232- if currentfile < (len (filenames ) + 1 ):
233- # Need to display the greater than touch sprite
234- moresprite [0 ] = RIGHT
235- else :
236- # Blank out more and extra icon spaces
237- moresprite [0 ] = BLANK
238- if PAGE > 1 : # Need to display the less than touch sprite
239- lesssprite [0 ] = LEFT
240- else :
241- lesssprite [0 ] = BLANK
242-
243- # Time to check for user touch of screen (BLOCKING)
244- touch_x = get_touch (ts )
245- print ("Touch Registered " )
246- # Check if touch_x is around the LEFT or RIGHT arrow
247- currentpage = PAGE
248- if touch_x >= int (WIDTH - ICONSIZE ): # > Touched
249- if moresprite [0 ] != BLANK : # Ensure there are more
250- if spot == (PAGEMAXFILES - 1 ): # Page full
251- if currentfile < (len (filenames )): # and more files
252- PAGE = PAGE + 1 # Increment page
253- if touch_x <= ICONSIZE : # < Touched
254- if PAGE > 1 :
255- PAGE = PAGE - 1 # Decrement page
256- else :
257- lesssprite [0 ] = BLANK # Not show < for first page
258- print ("Page " , PAGE )
259- # Icon Positioning
260-
261- if PAGE != currentpage : # We have a page change
262- # Reset icon locations to upper left
263- xpos = LEFTSPACE
264- ypos = TOPSPACE
265- spot = 0
266- if currentpage > PAGE :
267- # Decrement files by a page (current page & previous page)
268- currentfile = currentfile - (PAGEMAXFILES * 2 ) + 1
269- else :
270- # Forward go to the next file
271- currentfile = currentfile + 1
272- else :
273- currentfile += 1 # Increment file counter
274- spot += 1 # Increment icon space counter
275- if spot == PAGEMAXFILES : # Last page ended with
276- print ("hit" )
277- # calculate next icon location
278- if spot % ICONSACROSS : # not at end of icon row
279- xpos += SPACING + ICONSIZE
280- else : # start new icon row
281- ypos += ICONSIZE + SPACING + TEXTSPACE
282- xpos = LEFTSPACE
283- # End If Changed Page
284- # Blank out rest if needed
285- if currentfile == len (filenames ):
286- for i in range (spot , PAGEMAXFILES ):
287- sprites [i ][0 ] = BLANK
288- labels [i ].text = " "
289- # End while
0 commit comments