x = 100
y = 20
screen.waitVblankStart(10)
while true do
battime = System.powerGetBatteryLifeTime()
battime = tonumber(battime)
batpercent = System.powerGetBatteryLifePercent()
batpercent = tonumber(batpercent)
if batpercent < 0 then
	batpercent = "Power Adapter"
end
if battime <= 0 then
	battime = "Power Adapter"
else
battime = battime / 60
end
pad = Controls.read()
screen:clear()
screen:print(400,5,"CPU "..speed,white)
screen:print(1,5,"Time "..battime,white)
screen:print(250,5,"% "..batpercent,white)
screen:print(250,5,"% "..batpercent,white)
screen:print(120,20,"Set Cpu Speed ",white)
screen:print(120,30,"Enable USB ",white)
screen:print(120,40,"Disable USB ",white)
screen:print(120,50,"Show LuaPlayer Version ",white)
screen:print(120,60,"Quit HMplayer ",white)
screen:print(x, y, "=>", red)
screen.waitVblankStart()
screen.flip()

if pad:down() then
	y = y + 10
		if y > 60 then
			y = 60
		end
	screen:print(x, y, "=>", red)
	screen.waitVblankStart(10)
end
if pad:up() then
	y = y - 10
		if y < 20 then
			y = 20
		end
	screen:print(x, y, "=>", red)
	screen.waitVblankStart(10)
end
if pad:cross() then
	if y == 20 then
			dofile("./System/setcpuspeed.lua")
	end
	if y == 30 then
			System.usbDiskModeActivate()
			screen.waitVblankStart(10)
	end
	if y == 40 then
		System.usbDiskModeDeactivate()
		screen.waitVblankStart(10)
	end
	if y == 50 then
		System.madeby(1)
	end
	if y == 60 then
		System.Quit()
	end
end
if pad:circle() and not oldpad:circle() then
if playing == true then
Mp3me.stop()
System.memclean()
time = "0"
playing = false
nowplaying = " "
end
end
if Mp3me.eos() == true then
	nextsong = true
	while nextsong == true do
	
	fbrowser.s = fbrowser.s + 1
	if fbrowser.s < 1 then
			fbrowser.s = 1
			nextsong = false
	end
	if string.lower(string.sub(fbrowser.fl[fbrowser.s].name, -4)) == ".mp3" then
		System.memclean()
		Mp3me.stop()
		Mp3me.load(fbrowser.fl[fbrowser.s].name)
		Mp3me.play()
		nextsong = false
		playing = true
		nowplaying = fbrowser.fl[fbrowser.s].name
	end
	end
end
if pad:square() and not oldpad:square() then
if playing == true then
Mp3me.pause()
end
end
if pad:r() then
nextsong = true
	while nextsong == true do
	
	fbrowser.s = fbrowser.s + 1
	if fbrowser.s < 1 then
			fbrowser.s = 1
			nextsong = false
	end
	if string.lower(string.sub(fbrowser.fl[fbrowser.s].name, -4)) == ".mp3" then
		System.memclean()
		Mp3me.stop()
		Mp3me.load(fbrowser.fl[fbrowser.s].name)
		Mp3me.play()
		nextsong = false
		playing = true
		nowplaying = fbrowser.fl[fbrowser.s].name
	end
	end
end
if pad:l() then
nextsong = true
	while nextsong == true do
	
	fbrowser.s = fbrowser.s - 1
	if fbrowser.s == 0 then
			fbrowser.s = 1
			nextsong = false
	end
	if string.lower(string.sub(fbrowser.fl[fbrowser.s].name, -4)) == ".mp3" then
		System.memclean()
		Mp3me.stop()
		Mp3me.load(fbrowser.fl[fbrowser.s].name)
		Mp3me.play()
		nextsong = false
		playing = true
		nowplaying = fbrowser.fl[fbrowser.s].name
	end
	end
end
oldpad = pad
if pad:start() then
dofile("./System/system.lua")
end
end
