Console colour control - General Help and Assistance on using CHDK stable releases - CHDK Forum

Console colour control

  • 6 Replies
  • 1848 Views
Console colour control
« on: 18 / April / 2023, 01:31:13 »
Advertisements
@reyalp

As far as I can see, currently we have no control over the console colours, ie white on transparent.

Would it be possible for you to consider adding colour control, ie of text and background.

The use case is that sometimes the Canon stuff interferes with the readability of the console. Thus if we could just have a black background it would help, ie no other colour options.

Cheers

Garry

*

Online reyalp

  • ******
  • 14085
Re: Console colour control
« Reply #1 on: 18 / April / 2023, 02:13:01 »
The console should currently use conf.menu_color, which you should be able to control with set_config_value. However color values are not in LUALIB/GEN/conf_osd.lua, I'm not sure if this is an oversight or if there's some reason colors weren't included.

The color value should be an integer representing the 4 bytes defined in confColor in https://app.assembla.com/spaces/chdk/subversion/source/HEAD/trunk/include/color.h so you'll need some bit fiddling to pack/unpack them.

Of course, if you get that to work, it will also change the color scheme of the menu, so at the very least, you'd want to restore it on exit.

edit:
Alternately, for your own use, you could just adjust the menu color in OSD settings.

edit2:
I think the color conf IDs were probably lost inadvertently when the conf code changed in r3812, when a new macro was introduced. Since the generated files aren't checked in, differences in output are likely to go unnoticed. I'll look into this more later.
« Last Edit: 18 / April / 2023, 02:19:34 by reyalp »
Don't forget what the H stands for.

Re: Console colour control
« Reply #2 on: 18 / April / 2023, 13:00:42 »
@reyalp

Many thanks for the insight.

I’ll wait to hear from you before I do anything more ;-)

Cheers

Garry

*

Online reyalp

  • ******
  • 14085
Re: Console colour control
« Reply #3 on: 18 / April / 2023, 20:52:01 »
Looks like the color IDs being left out was a mistake. I fixed this in trunk r6237, stable r6239

In trunk 6238, I added two new functions to drawings.lua

draw.pack_cnf_colors(fg,bg) takes two colors in the system used by lua drawings (0-255 for native colors, 256-275  for chdk colors, or string names) and turns them into a number for use with set_config_value

draw.unpack_cnf_colors(v) takes a number returned by get_config_value and returns the foreground and background color as numbers in the script system.

Examples
Code: [Select]
require'drawings'
return draw.unpack_cnf_colors(get_config_value(require'gen/cnf_osd'.menu_color))
-- returns numbers like 258, 269

set_config_value(require'gen/cnf_osd'.menu_color,draw.pack_cnf_colors('green','magenta'))

set_config_value(require'gen/cnf_osd'.menu_color,draw.pack_cnf_colors(258,269))

I'm not really inclined to add new config values to set the color of the console separately from the menu color, but maybe I could be convinced  :haha
Don't forget what the H stands for.


Re: Console colour control
« Reply #4 on: 19 / April / 2023, 01:09:14 »
Looks like the color IDs being left out was a mistake. I fixed this in trunk r6237, stable r6239

In trunk 6238, I added two new functions to drawings.lua

draw.pack_cnf_colors(fg,bg) takes two colors in the system used by lua drawings (0-255 for native colors, 256-275  for chdk colors, or string names) and turns them into a number for use with set_config_value

draw.unpack_cnf_colors(v) takes a number returned by get_config_value and returns the foreground and background color as numbers in the script system.

Examples
Code: [Select]
require'drawings'
return draw.unpack_cnf_colors(get_config_value(require'gen/cnf_osd'.menu_color))
-- returns numbers like 258, 269

set_config_value(require'gen/cnf_osd'.menu_color,draw.pack_cnf_colors('green','magenta'))

set_config_value(require'gen/cnf_osd'.menu_color,draw.pack_cnf_colors(258,269))

I'm not really inclined to add new config values to set the color of the console separately from the menu color, but maybe I could be convinced  :haha

Many thanks for such a quick turn around.

As for being ‘convinced’ to include a way to separately control the console colours, I believe this would be a great enhancement in scripting.

Using colour to provide enhanced feedback is a powerful way to convey information. However, the current console is rather static in the that regard.

The optimum functionality would be away to control the colour of individual letters (fg,bg) in console text strings, however, I accept that may not be possible. For example creating a console text string to print, made up of substrings, each with their own colour states.

If the above is not possible, then a Lua command to control the colour of a line of console text would be a great additional feature to enhance the informational content, ie through colour.

The call could be print(“text”,[fg,[bg]])

IMHO ;-)


*

Online reyalp

  • ******
  • 14085
Re: Console colour control
« Reply #5 on: 19 / April / 2023, 16:26:12 »
The optimum functionality would be away to control the colour of individual letters (fg,bg) in console text strings, however, I accept that may not be possible. For example creating a console text string to print, made up of substrings, each with their own colour states.

If the above is not possible, then a Lua command to control the colour of a line of console text would be a great additional feature to enhance the informational content, ie through colour.
I'd suggest using the Lua drawing functions to create a separate "colored text area" control you can use instead of the the console for this. I'm not in favor of adding this kind of the complexity to the core C code.
Don't forget what the H stands for.

Re: Console colour control
« Reply #6 on: 19 / April / 2023, 16:56:05 »
Ok.

 

Related Topics