Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Battery

in Questions Posts: 2,428

All,

Does anyone know if you can read and display the battery level in your project ? I know you can display time but battery level could be handy to allow users to save before a shutdown due to low charge.

Tagged:

Comments

  • dave1707dave1707 Mod
    Posts: 9,584

    @Bri_G The battery level sounded familiar, so I did a forum search and found this.

    Simeon Admin Mod
    September 2019 Posts: 5,714122.199.18.254
    
    @dave1707 Oh I see the popover initially starts out very large, I'll look into that.
    
    On device information, I've updated the deviceMetrics API for the next build to include batteryLevel and batteryState (as well as a few other fields)
    
  • dave1707dave1707 Mod
    Posts: 9,584

    @Bri_G Try this.

    function setup()
        s=deviceMetrics()
        for a,b in pairs(s) do
            print(a,b)
        end
    end
    
  • Posts: 180

    deviceMetrics() returns nil for me

  • dave1707dave1707 Mod
    Posts: 9,584

    @skar What were you running my above code on. I tried it on different iPads and an iPhone 8 and they all worked.

  • Posts: 180

    oh it’s because i ran it without the setup function, looks like it needs codea to be bootstrapped to work

Sign In or Register to comment.