Possible to find out LCD size? - LUA Scripting - CHDK Forum supplierdeeply

Possible to find out LCD size?

  • 7 Replies
  • 4481 Views
Possible to find out LCD size?
« on: 27 / December / 2013, 17:41:01 »
Advertisements
Is there a way to find out the camera's LCD size (in pixels)? I've read the pages detailing propcases, but finding out the LCD size doesn't seem to be included.

Re: Possible to find out LCD size?
« Reply #1 on: 27 / December / 2013, 17:56:12 »
Is there a way to find out the camera's LCD size (in pixels)? I've read the pages detailing propcases, but finding out the LCD size doesn't seem to be included.
msl uses a Lua function that does it in a "brute force" kind of way :

Code: [Select]
function screen_w()     -- lookup table for 480 px screen
    local cams = "ixus110_sd960|ixus200_sd980|ixus240_elph320hs|ixus300_sd4000|ixus310_elph500hs|ixus1000_sd4500|sx1|sx210is|sx220hs|sx230hs"
    return string.find(cams, get_buildinfo().platform) and 480 or 360
end

Not too sure I'd want to try and code that in uBASIC though .... ::)
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 14080
Re: Possible to find out LCD size?
« Reply #2 on: 27 / December / 2013, 19:09:59 »
Ugh, good reminder we need to add functions for this.

Assuming the size of interest is the bitmap it should be fairly straightforward. There are different "real" and adjusted sizes, but I guess the most useful would be the same ones the drawing functions use.

I'm not sure this is needed in ubasic since it doesn't have drawing functions.
Don't forget what the H stands for.

Re: Possible to find out LCD size?
« Reply #3 on: 28 / December / 2013, 08:15:24 »
Ugh, good reminder we need to add functions for this.
Candidate patch file attached.

Sample script :
Code: [Select]
--[[
@title Screen Resolution
--]]
set_console_layout(1 ,4, 45, 16 )
info = get_screenInfo()
print("screen width:"..info.screen_width,"screen height:"..info.screen_height)
print("buffer width:"..info.buffer_width,"buffer height:",info.buffer_height)
print("aspect correction:",info.aspect_correction)
Ported :   A1200    SD940   G10    Powershot N    G16


*

Offline reyalp

  • ******
  • 14080
Re: Possible to find out LCD size?
« Reply #4 on: 28 / December / 2013, 17:42:50 »
Candidate patch file attached.
Thanks.

For drawing, do we really need anything more than the bitmap width / height in CHDK adjusted coordinates?

I'm not sure how you would use the buffer sizes or aspect correction, but I haven't used the drawing stuff much.

Also aspect_correction and has_variable_aspect are two different things.

CAM_USES_ASPECT_CORRECTION means the camera has 2x1 bitmap pixels instead of (roughly) square bitmap pixels.

CAM_HAS_VARIABLE_ASPECT is something else related to zebra on cameras with a 16:9 screen, which appears to be mis-defined in some ports...
Don't forget what the H stands for.

Re: Possible to find out LCD size?
« Reply #5 on: 28 / December / 2013, 17:57:04 »
For drawing, do we really need anything more than the bitmap width / height in CHDK adjusted coordinates?
I just threw in everything I found there - its basically free once you go to the trouble of adding the function.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 14080
Re: Possible to find out LCD size?
« Reply #6 on: 28 / December / 2013, 19:25:48 »
I just threw in everything I found there - its basically free once you go to the trouble of adding the function.
In this case I think less is more :)

Trunk changeset 3282 adds
get_gui_screen_width() and get_gui_screen_height()

Code: [Select]
draw_rect(0,0,get_gui_screen_width()-1,get_gui_screen_height()-1,259)

should draw a red rectangle around the screen on most cameras. Some old cameras like a540 are only visible pixels wide, even though they report 360.

I put _gui in the name because "screen" will be ambiguous if we ever add viewport or unadjusted bitmap dimensions. Since there's only two, having individual functions seems more convenient than having a table.

Since these are trivial, I'm OK backporting these to 1.2, but I'd like to know if they meet peoples needs first.
Don't forget what the H stands for.

Re: Possible to find out LCD size?
« Reply #7 on: 28 / December / 2013, 19:42:04 »
Since these are trivial, I'm OK backporting these to 1.2, but I'd like to know if they meet peoples needs first.
All I needed was the ability to center the display widgit in a couple of my scripts and for that it's fine.  Can't speak for anyone else though.
« Last Edit: 28 / December / 2013, 19:47:30 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16


 

Related Topics