Console changes for review - page 2 - General Discussion and Assistance - CHDK Forum

Console changes for review

  • 27 Replies
  • 13187 Views
*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Console changes for review
« Reply #10 on: 22 / July / 2013, 09:54:10 »
Advertisements
I've noticed that set_console_layout(..) doesn't work in my time lapse script since these changes, as demonstrated by this test script:
Code: [Select]
--[[
@title console test
--]]
set_console_layout(0,11,45,13) -- this has no effect now, worked before
print("testing 1")
print("testing 2")
print("testing 3")
set_console_autoredraw(-1) -- screen disappears in 3 seconds
print("Hello") -- doesn't show on screen
sleep(5000)
--set_console_autoredraw(1) -- screen reappears
print("Good Bye")
Here's the description in the Wiki:
Quote
set_console_layout x1 y1 x2 y2 --> set console position and size, range is x=0 to 45 and y=0 to 14

Note : coordinates are in units of characters and are  numbered from the lower left hand corner of the screen. So x1,y1 is the lower left corner and x2,y2 is the upper right corner.

set_console_autoredraw(-1) does work, as Phil described. That is, the screen console disappears after 3 seconds. However, the screen console doesn't reappear when a new script starts. That is, it's not re-initialized.

Since Phil did the changes, it would probably be easier for him to fix it.

Max console width was reduced to 44 to allow for scrolling when displaying the console history.

If you call set_console_layout with values out of range or too large it is ignored.

Your script is also not re-enabling console output with set_console_autoredraw(1) - I will update the console_close function to do this in case the script forgets to.

Phil.

CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

Re: Console changes for review
« Reply #11 on: 22 / July / 2013, 11:59:22 »
Max console width was reduced to 44 to allow for scrolling when displaying the console history.
If you call set_console_layout with values out of range or too large it is ignored.
Would it make more sense to clamp the console dimension at the max value rather than just ignoring the call?
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Console changes for review
« Reply #12 on: 22 / July / 2013, 15:45:37 »
Max console width was reduced to 44 to allow for scrolling when displaying the console history.
If you call set_console_layout with values out of range or too large it is ignored.
Would it make more sense to clamp the console dimension at the max value rather than just ignoring the call?

Probably.
A warning message displayed in the console might also be useful.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline srsa_4c

  • ******
  • 4451
Re: Console changes for review
« Reply #13 on: 21 / December / 2014, 08:29:26 »
Did not want to open a new thread for this.
There's a text editor script included in the CHDK distribution. The console's disappearance (3..30 seconds after last update) is quite annoying when somebody tries to use that script. Could we somehow allow a permanent console display (either with a script command or with console settings)?

Re: Console changes for review
« Reply #14 on: 21 / December / 2014, 10:14:19 »
There's a text editor script included in the CHDK distribution. The console's disappearance (3..30 seconds after last update) is quite annoying when somebody tries to use that script. Could we somehow allow a permanent console display (either with a script command or with console settings)?
I've used
Code: [Select]
    set_config_value( 297, 30000)   -- console timeoutto push the timeout to over 8 hours.  That's been enough for anything I've needed it for.   Obviously, the script probably should to do a get_config_value() and restore the timeout on exit.

The downside to this is a permanently on console if the script exits without resetting it.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline srsa_4c

  • ******
  • 4451
Re: Console changes for review
« Reply #15 on: 21 / December / 2014, 11:36:15 »
I've used
Code: [Select]
    set_config_value( 297, 30000)   -- console timeoutto push the timeout to over 8 hours.  That's been enough for anything I've needed it for.   Obviously, the script probably should to do a get_config_value() and restore the timeout on exit.
That seems to do the job, thanks. I have currently used the config ID directly. Perhaps it would be more future-proof to use the generated cnf_osd Lua library (but that would increase memory use and may not be available in case of an incomplete install)...?

Code: [Select]
Index: CHDK/SCRIPTS/EDITOR/EDI.lua
===================================================================
--- CHDK/SCRIPTS/EDITOR/EDI.lua (revision 3835)
+++ CHDK/SCRIPTS/EDITOR/EDI.lua (working copy)
@@ -45,6 +45,11 @@
     additionally: the biggest file I successfully opened on SX130IS had 916 kB. Opening 962 kB file failed. Other cameras has different size of free memory, nevertheless opening average scripts as 5-10 kb shouldn't cause any problems.
 --]]
 
+-- store original console timeout value
+-- TODO: use the cnf_osd library instead of config ID?
+ConTO = get_config_value(297)
+set_config_value( 297, 30000)
+
 -- CHECK GIVEN PARAMETERS --
 if y<5 then y=5 end
 if x<10 then x=10 end
@@ -498,6 +503,7 @@
     cls()
     print("EDI has been terminated.")
     set_console_autoredraw(1)
+    set_config_value( 297, ConTO) -- restore console timeout value
     set_console_layout(0,0,25,5) -- Thx, msl!
     EXIT=true
     end

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Console changes for review
« Reply #16 on: 21 / December / 2014, 14:06:04 »
I've used
Code: [Select]
    set_config_value( 297, 30000)   -- console timeoutto push the timeout to over 8 hours.  That's been enough for anything I've needed it for.   Obviously, the script probably should to do a get_config_value() and restore the timeout on exit.
That seems to do the job, thanks. I have currently used the config ID directly. Perhaps it would be more future-proof to use the generated cnf_osd Lua library (but that would increase memory use and may not be available in case of an incomplete install)...?

Code: [Select]
Index: CHDK/SCRIPTS/EDITOR/EDI.lua
===================================================================
--- CHDK/SCRIPTS/EDITOR/EDI.lua (revision 3835)
+++ CHDK/SCRIPTS/EDITOR/EDI.lua (working copy)
@@ -45,6 +45,11 @@
     additionally: the biggest file I successfully opened on SX130IS had 916 kB. Opening 962 kB file failed. Other cameras has different size of free memory, nevertheless opening average scripts as 5-10 kb shouldn't cause any problems.
 --]]
 
+-- store original console timeout value
+-- TODO: use the cnf_osd library instead of config ID?
+ConTO = get_config_value(297)
+set_config_value( 297, 30000)
+
 -- CHECK GIVEN PARAMETERS --
 if y<5 then y=5 end
 if x<10 then x=10 end
@@ -498,6 +503,7 @@
     cls()
     print("EDI has been terminated.")
     set_console_autoredraw(1)
+    set_config_value( 297, ConTO) -- restore console timeout value
     set_console_layout(0,0,25,5) -- Thx, msl!
     EXIT=true
     end

A new function to set the timeout would be clearer (and avoid the magic number and overhead of using cnf_osd.lua).

I'd also suggest saving and restoring the timeout value in the C code in case the script forgets or is cancelled by the user.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

Re: Console changes for review
« Reply #17 on: 21 / December / 2014, 14:55:07 »
I'd also suggest saving and restoring the timeout value in the C code in case the script forgets or is cancelled by the user.
I think you only need the restore part of that - just reset to whatever is in the conf.console_timeout value on script exit.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Console changes for review
« Reply #18 on: 21 / December / 2014, 16:14:33 »
I'd also suggest saving and restoring the timeout value in the C code in case the script forgets or is cancelled by the user.
I think you only need the restore part of that - just reset to whatever is in the conf.console_timeout value on script exit.

But isn't this the value the new function is going to change to give the script control over the console?

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

Re: Console changes for review
« Reply #19 on: 21 / December / 2014, 16:19:31 »
I'd also suggest saving and restoring the timeout value in the C code in case the script forgets or is cancelled by the user.
I think you only need the restore part of that - just reset to whatever is in the conf.console_timeout value on script exit.
But isn't this the value the new function is going to change to give the script control over the console?
AFAIK,  only needed while the script is running?

edit :  srsa_4c's complaint was the console timing out while a script was using it for output IIRC. You can tweak the value stored in the conf.console_timeout but that doesn't get reset when the script exits.
« Last Edit: 21 / December / 2014, 16:28:29 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

 

Related Topics


SimplePortal © 2008-2014, SimplePortal