1
0
Fork 0
forked from Miroirs/x49gp

Compare commits

...

2 commits

Author SHA1 Message Date
Gwenhael Le Moine
2e9954e57c
Merge branch 'main' of ssh://src.le-moine.org:38172/gwh/x50ng 2024-12-15 15:52:50 +01:00
Gwenhael Le Moine
967055c88e
-z --zoom and --reset 2024-12-15 15:52:17 +01:00
4 changed files with 36 additions and 30 deletions

View file

@ -55,19 +55,19 @@ Please consult HP's manual (for their official firmware) or the documentation of
*-d* *--datadir*[=_absolute path_] alternate datadir (default: $XDG_CONFIG_HOME/x50ng/) *-d* *--datadir*[=_absolute path_] alternate datadir (default: $XDG_CONFIG_HOME/x50ng/)
*-n* *--name*[=_name_] set alternate UI name *-n* *--name*[=_name_] set alternate UI name
*-s* *--style*[=_filename_] css filename in <datadir> (default: style-50g.css) *-s* *--style*[=_filename_] css filename in <datadir> (default: style-50g.css)
*-S* *--display-scale*[=_X_] scale LCD by X (default: 2) *-z* *--zoom*[=_X_] scale LCD by X (default: 2)
*-r* *--reboot* reboot on startup instead of continuing from the saved state in the state file *-r* *--reset* reboot on startup instead of continuing from the saved state in the state file
*--overwrite-config* force writing <datadir>/config.lua even if it exists *--overwrite-config* force writing <datadir>/config.lua even if it exists
*--newrpl-keyboard* label keyboard for newRPL *--newrpl-keyboard* label keyboard for newRPL
*--enable-debug*[=_port_] enable the debugger interface (default port: 1234) *--enable-debug*[=_port_] enable the debugger interface (default port: 1234)
*--debug* use along -D to also start the debugger immediately *--debug* use along -D to also start the debugger immediately
*--reflash*[=_firmware_] rebuild the flash using the supplied firmware (default: select one interactively) (implies -r for safety reasons) *--reflash*[=_firmware_] rebuild the flash using the supplied firmware (default: select one interactively) (implies -r for safety reasons)
*--reflash-full*[=_firmware_] rebuild the flash using the supplied firmware and drop the flash contents in the area beyond the firmware (default: select one interactively) (implies -r for safety reasons) *--reflash-full*[=_firmware_] rebuild the flash using the supplied firmware and drop the flash contents in the area beyond the firmware (default: select one interactively) (implies -r for safety reasons)
*--50g* use an HP 50g bootloader when (re-)flashing (default) *--50g* use an HP 50g bootloader when (re-)flashing (default)
*--49gp* use an HP 49g+ bootloader when (re-)flashing *--49gp* use an HP 49g+ bootloader when (re-)flashing
# FILES # FILES

View file

@ -2,6 +2,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>
#include <assert.h>
#include <getopt.h> #include <getopt.h>
#include <glib.h> #include <glib.h>
@ -26,7 +27,7 @@ struct options opt = {
.name = NULL, .name = NULL,
.verbose = false, .verbose = false,
.style_filename = NULL, .style_filename = NULL,
.display_scale = 2, .zoom = 2,
}; };
lua_State* config_lua_values; lua_State* config_lua_values;
@ -98,10 +99,10 @@ static char* config_to_string( void )
"model = \"%s\" -- possible values: \"49gp\", \"50g\". Changes the bootloader looked for when (re-)flashing\n" "model = \"%s\" -- possible values: \"49gp\", \"50g\". Changes the bootloader looked for when (re-)flashing\n"
"newrpl_keyboard = %s -- when true this makes the keyboard labels more suited to newRPL use\n" "newrpl_keyboard = %s -- when true this makes the keyboard labels more suited to newRPL use\n"
"style = \"%s\" -- CSS file (relative to this file)\n" "style = \"%s\" -- CSS file (relative to this file)\n"
"display_scale = %i -- integer only\n" "zoom = %i -- integer only\n"
"verbose = %s\n" "verbose = %s\n"
"--- End of x50ng configuration -----------------------------------------------\n", "--- End of x50ng configuration -----------------------------------------------\n",
opt.name, opt.model == MODEL_50G ? "50g" : "49gp", opt.newrpl ? "true" : "false", opt.style_filename, opt.display_scale, opt.name, opt.model == MODEL_50G ? "50g" : "49gp", opt.newrpl ? "true" : "false", opt.style_filename, opt.zoom,
opt.verbose ? "true" : "false" ); opt.verbose ? "true" : "false" );
return config; return config;
@ -153,12 +154,12 @@ void config_init( char* progname, int argc, char* argv[] )
char* clopt_style_filename = NULL; char* clopt_style_filename = NULL;
int clopt_model = -1; int clopt_model = -1;
int clopt_newrpl = -1; int clopt_newrpl = -1;
int clopt_display_scale = -1; int clopt_zoom = -1;
int print_config_and_exit = false; int print_config_and_exit = false;
int overwrite_config = false; int overwrite_config = false;
const char* optstring = "dhrf:n:s:S:vV"; const char* optstring = "dhrf:n:s:S:vVz:";
struct option long_options[] = { struct option long_options[] = {
{"help", no_argument, NULL, 'h' }, {"help", no_argument, NULL, 'h' },
{"version", no_argument, NULL, 'v' }, {"version", no_argument, NULL, 'v' },
@ -173,13 +174,15 @@ void config_init( char* progname, int argc, char* argv[] )
{"newrpl-keyboard", no_argument, &clopt_newrpl, true}, {"newrpl-keyboard", no_argument, &clopt_newrpl, true},
{"name", required_argument, NULL, 'n' }, {"name", required_argument, NULL, 'n' },
{"style", required_argument, NULL, 's' }, {"style", required_argument, NULL, 's' },
{"display-scale", required_argument, NULL, 'S' }, {"display-scale", required_argument, NULL, 'S' }, /* deprecated */
{"zoom", required_argument, NULL, 'z' },
{"enable-debug", required_argument, NULL, 10 }, {"enable-debug", required_argument, NULL, 10 },
{"debug", no_argument, NULL, 11 }, {"debug", no_argument, NULL, 11 },
{"reflash", required_argument, NULL, 90 }, {"reflash", required_argument, NULL, 90 },
{"reflash-full", required_argument, NULL, 91 }, {"reflash-full", required_argument, NULL, 91 },
{"reboot", no_argument, NULL, 'r' }, {"reboot", no_argument, NULL, 'r' }, /* deprecated */
{"reset", no_argument, NULL, 'r' },
{0, 0, 0, 0 } {0, 0, 0, 0 }
}; };
@ -200,8 +203,8 @@ void config_init( char* progname, int argc, char* argv[] )
"-d --datadir[=absolute path] alternate datadir (default: $XDGCONFIGHOME/%s/)\n" "-d --datadir[=absolute path] alternate datadir (default: $XDGCONFIGHOME/%s/)\n"
"-n --name[=name] set alternate UI name\n" "-n --name[=name] set alternate UI name\n"
"-s --style[=filename] css filename in <datadir> (default: style-50g.css)\n" "-s --style[=filename] css filename in <datadir> (default: style-50g.css)\n"
"-S --display-scale[=X] scale LCD by X (default: 2)\n" "-S --zoom[=X] scale LCD by X (default: 2)\n"
"-r --reboot reboot on startup instead of continuing from the saved state in the state file\n" "-r --reset reboot on startup instead of continuing from the saved state in the state file\n"
"--overwrite-config force writing <datadir>/config.lua even if it exists\n" "--overwrite-config force writing <datadir>/config.lua even if it exists\n"
"\n" "\n"
"--newrpl-keyboard label keyboard for newRPL\n" "--newrpl-keyboard label keyboard for newRPL\n"
@ -262,7 +265,7 @@ void config_init( char* progname, int argc, char* argv[] )
clopt_style_filename = strdup( optarg ); clopt_style_filename = strdup( optarg );
break; break;
case 'S': case 'S':
clopt_display_scale = atoi( optarg ); clopt_zoom = atoi( optarg );
break; break;
case 'v': case 'v':
fprintf( stderr, "%i.%i.%i\n", VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL ); fprintf( stderr, "%i.%i.%i\n", VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL );
@ -317,8 +320,11 @@ void config_init( char* progname, int argc, char* argv[] )
lua_getglobal( config_lua_values, "style" ); lua_getglobal( config_lua_values, "style" );
opt.style_filename = strdup( luaL_optstring( config_lua_values, -1, opt.style_filename ) ); opt.style_filename = strdup( luaL_optstring( config_lua_values, -1, opt.style_filename ) );
lua_getglobal( config_lua_values, "display_scale" ); lua_getglobal( config_lua_values, "zoom" );
opt.display_scale = luaL_optinteger( config_lua_values, -1, opt.display_scale ); opt.zoom = luaL_optinteger( config_lua_values, -1, opt.zoom );
lua_getglobal( config_lua_values, "zoom" );
opt.zoom = luaL_optinteger( config_lua_values, -1, opt.zoom );
} }
if ( opt.haz_config_file && overwrite_config ) if ( opt.haz_config_file && overwrite_config )
opt.haz_config_file = false; opt.haz_config_file = false;
@ -336,8 +342,8 @@ void config_init( char* progname, int argc, char* argv[] )
opt.model = clopt_model; opt.model = clopt_model;
if ( clopt_newrpl != -1 ) if ( clopt_newrpl != -1 )
opt.newrpl = clopt_newrpl; opt.newrpl = clopt_newrpl;
if ( clopt_display_scale > 0 ) if ( clopt_zoom > 0 )
opt.display_scale = clopt_display_scale; opt.zoom = clopt_zoom;
if ( print_config_and_exit ) { if ( print_config_and_exit ) {
fprintf( stdout, config_to_string() ); fprintf( stdout, config_to_string() );

View file

@ -33,7 +33,7 @@ struct options {
bool newrpl; bool newrpl;
char* name; char* name;
int display_scale; int zoom;
char* style_filename; char* style_filename;
bool verbose; bool verbose;
bool haz_config_file; bool haz_config_file;

View file

@ -22,8 +22,8 @@
#define KB_NB_ROWS 10 #define KB_NB_ROWS 10
#define LCD_WIDTH ( 131 * opt.display_scale ) #define LCD_WIDTH ( 131 * opt.zoom )
#define LCD_HEIGHT ( 80 * opt.display_scale ) #define LCD_HEIGHT ( 80 * opt.zoom )
static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
{.css_class = "menu", {.css_class = "menu",
@ -1747,9 +1747,9 @@ void gui_update_lcd( x49gp_t* x49gp )
gtk_widget_set_opacity( ui->ui_ann_busy, x49gp_get_pixel_color( lcd, 131, 5 ) ); gtk_widget_set_opacity( ui->ui_ann_busy, x49gp_get_pixel_color( lcd, 131, 5 ) );
gtk_widget_set_opacity( ui->ui_ann_io, x49gp_get_pixel_color( lcd, 131, 0 ) ); gtk_widget_set_opacity( ui->ui_ann_io, x49gp_get_pixel_color( lcd, 131, 0 ) );
for ( int y = 0; y < ( LCD_HEIGHT / opt.display_scale ); y++ ) for ( int y = 0; y < ( LCD_HEIGHT / opt.zoom ); y++ )
for ( int x = 0; x < ( LCD_WIDTH / opt.display_scale ); x++ ) for ( int x = 0; x < ( LCD_WIDTH / opt.zoom ); x++ )
_draw_pixel( ui->lcd_surface, opt.display_scale * x, opt.display_scale * y, opt.display_scale, opt.display_scale, _draw_pixel( ui->lcd_surface, opt.zoom * x, opt.zoom * y, opt.zoom, opt.zoom,
&( ui->colors[ UI_COLOR_GRAYSCALE_0 + x49gp_get_pixel_color( lcd, x, y ) ] ) ); &( ui->colors[ UI_COLOR_GRAYSCALE_0 + x49gp_get_pixel_color( lcd, x, y ) ] ) );
} }