-- PSysPInfo
--created by Glynnder - PSPro
-- This version runs on luaplayer 0.16 - thanks to Pedro for the revised time left code -i already had the volt one sorted!
cont = false
purple =  Color.new(167, 29, 226)

dblue = Color.new(0, 0, 255)

red = Color.new(230, 0, 0)

pink = Color.new(255, 0 , 153)

blue = Color.new(0 , 153, 255)

orange = Color.new(255, 102, 0)

gray = Color.new(153, 153, 153)

black = Color.new(0 , 0 , 0)

white = Color.new(255, 255, 255)
green = Color.new(0 , 255, 0)
pagestatus=0
infostatus=1

--Loading bg items
bg = Image.load("mainbg2.png")
bg2 = Image.load("mainbg.png")
bg3 = Image.load("mainbg3.jpg")
bg1 = Image.load("mainbg1.png")
bg4 = Image.load("mainbg4.png")
bg5 = Image.load("mainbg5.png")
bg6 = Image.load("mainbg6.png")
bg7 = Image.load("mainbg8.png")
bg8 = Image.load("mainbg9.png")
bg9 = Image.load("mainbg10.png")


--loading other image-s-
controls = Image.load("controls.png")


screen.waitVblankStart(10)

screen.flip()

--app loading complete, begin program script
while true do
--blit images
--skins
if pagestatus==0
then
          screen:blit(0, 0, bg, false)
          elseif pagestatus==1 then
          screen:blit(0, 0, bg2, false)
          elseif pagestatus==2 then
          screen:blit(0, 0, bg3, false)
          elseif pagestatus==4 then
          screen:blit(0, 0, bg1, false)
          elseif pagestatus==3 then
          screen:blit(0, 0, bg4, false)          
          elseif pagestatus==5 then
          screen:blit(0, 0, bg5, false)
          elseif pagestatus==6 then
          screen:blit(0, 0, bg6, false)
          elseif pagestatus==7 then
          screen:blit(0, 0, bg7, false)
      elseif pagestatus==8 then
          screen:blit(0, 0, bg8, false)
      elseif pagestatus==9 then
          screen:blit(0, 0, bg9, false)
          end
      
if pagestatus==10
then pagestatus=pagestatus-10
end
         if pagestatus==-1
then pagestatus=pagestatus+10
end

      -- time display
        time = os.time()

          dateString = os.date("%c")

      screen:print(1, 1, os.date(), red)

      dateFields = os.date("*t")

      hour = dateFields.hour

      if hour < 10 then

        hour = "0" .. hour

      end
      min = dateFields.min

      if min < 10 then

      min = "0" .. min

      end
  sec = dateFields.sec

  if sec < 10 then

    sec = "0" .. sec

  end
-- main functions

if infostatus==1 then


-- remaining time module

tempo = System.powerGetBatteryLifeTime()
horas = tempo/60
seg = math.mod(tempo,60)
resto = seg/60
horas = horas-resto
if horas < 10 then
horas = "0" .. horas
end
if seg < 10 then
seg = "0" .. seg
end
-- end of remaing time module
    screen:print(50, 105, tostring("Battery Info:"))
    screen:print(50, 155, tostring("Temp:".. System.powerGetBatteryTemp() .. " degrees Celcius"))
   if (System.powerGetBatteryLifeTime()/60) == 0 then
    screen:print(50, 165, tostring("Life time left: CHARGING"))
   else
 screen:print(50, 165, tostring("Remaining time:".. horas .. ":" .. seg ..""))

end
    screen:print(50, 135, tostring("Batt:".. System.powerGetBatteryLifePercent() .. "%"))

-- prints battery voltage

    screen:print(50, 175, tostring("Voltage:".. System.powerGetBatteryVolt()/1000 .. "V"))

    if (System.powerIsBatteryCharging()) == true then
    screen:print(50, 145, tostring("Batt. Charging?: YES"))
else
    screen:print(50, 145, tostring("Batt. Charging?: NO"))
end
else if infostatus==2 then
-- if the luaplayer version isn't 0.17DK2 or above, please comment the following lines
--umd = "No"
--if System.isUmdInserted() then
--umd = "Yes"
--end
--screen:print(50, 175, tostring("UMD present:" .. umd .. ""), black)

-- stop comment here

screen:print(50, 155, tostring("Free Memory:".. System.getFreeMemory()/1024 .. "kb"))
    screen:print(50, 145, tostring("Dir:".. System.currentDirectory()))
   screen:print(50, 105, "System info:", black)
      screen:print(50, 135, tostring("Skin:".. pagestatus+1))
    screen:print(50, 125, tostring("Date:"), black)
          dateString = os.date("%c")

      screen:print(90, 125, os.date(), black)

      dateFields = os.date("*t")

      hour = dateFields.hour

      if hour < 10 then

        hour = "0" .. hour

      end
      min = dateFields.min

      if min < 10 then

      min = "0" .. min

      end
  sec = dateFields.sec

  if sec < 10 then

    sec = "0" .. sec

  end
end
end
--screen:print(100, 215, tostring("Press 'Square' to exit LuaPlayer"))
-- battery indicator
if cont == true then
         screen:blit(0, 0, controls, false)
         end
      screen:print(30, 242, "Press 'Start' to quit", blue)

      if  (System.powerIsLowBattery()) == true then

    screen:print(410, 1, tostring("Batt:".. System.powerGetBatteryLifePercent()) .. "%", red)

    else screen:print(410, 1, tostring("Batt:".. System.powerGetBatteryLifePercent()) .. "%", red)

    end

    if (System.powerIsBatteryCharging()) == true then

    screen:print(472, 1, "+", red) end 

                screen:print(300, 242, "'Select' = Screenshot", blue)
        screen.flip()


          pad = Controls.read() 
                if pad:start() then

                    break

          end          
          if pad:circle() then
          cont = true
else     
cont = false     
end
          if pad:select() then

          screen:save("screenshot.jpg") 
        end
  if pad ~= oldPad then
  
    if pad:l() then
    pagestatus = pagestatus - 1
    oldPad = pad
        else
    oldPad = pd
    end
else if pad:r() then
    pagestatus = pagestatus
    end
    end
    
    if pad:triangle() then
    dofile("calc.lua")
    end

--if pad:square() then
--
  --        System.Quit()
    --    end

  if pad ~= oldPad then
    if pad:r() then
    pagestatus = pagestatus + 1
    oldPad = pad
        else
    oldPad = pd
    end
else if pad:l() then
    pagestatus = pagestatus
    end
    end
    
adPad=Controls.read()
pid=Controls.read()

  if pad ~= adPad then
    if pad:left() then
    infostatus = infostatus - 1
    adPad = pad
        else
    adPad = pid
    end
else if pad:l() then
    infostatus = infostatus
    end
    end
    

  if pad ~= adPad then
    if pad:right() then
    infostatus = infostatus + 1
    adPad = pad
        else
    adPad = pid
    end
else if pad:right() then
    infostatus = infostatus
    end
    end    
    
  if pad ~= adPad then
    if pad:down() then
    infostatus = infostatus - 1
    adPad = pad
        else
    adPad = pid
    end
else if pad:down() then
    infostatus = infostatus
    end
    end
    

  if pad ~= adPad then
    if pad:up() then
    infostatus = infostatus + 1
    adPad = pad
        else
    adPad = pid
    end
else if pad:up() then
    infostatus = infostatus
    end
    end    
    
if infostatus == 3 then
infostatus = infostatus-2
end
if infostatus == 0 then
infostatus = infostatus+2
end
end