add CGEXT_Set_Margin_Color() function in Kandinsky module

This commit is contained in:
Sylvain PILLOT 2024-02-07 21:30:59 +01:00
parent d4dcc59d71
commit 2cb2bc6e67
3 changed files with 28 additions and 8 deletions

View File

@ -44,6 +44,8 @@ The following functions are additions to take advantage of the wide screen of th
- `CGEXT_Is_Wide_Screen_Enabled()`: Returns `True` if the extended screen is active and `False` otherwise.
- `CGEXT_Set_Margin_Color( color )` : Paints the margin of the `Numworks` screen on fxCG with the specified color.
Note 1: after having made a plot in the extended area, it must be active to allow its deletion (typically via a call to the `fill_rect()` function with the appropriate parameters).
Note 2: In non-extended mode (by default when initializing the `Kandinsky` module) the screen coordinates go from (0,0) to (319,221) centered on the fxCG screen. In extended mode, the screen coordinates range from (-38,-1) to (358,223).

View File

@ -44,6 +44,8 @@ Les fonctions suivantes sont des ajouts pour tirer partie de l'écran large de l
- `CGEXT_Is_Wide_Screen_Enabled()` : Retourne `True` si l'écran étendu est actif et `False` dans le cas contraire.
- `CGEXT_Set_Margin_Color( color )` : Trace les marge de la fxCG50 (pourtours de l'écran `Numworks`) de la couleur passée en argument.
Note 1 : après avoir réalisé un tracé dans la zone étendue, il faut que celle-ci soit active pour permettre son effacement (typiquement via un appel à la fonction `fill_rect()` avec les paramètres adéquats).
Note 2 : En mode non étendu (par défaut à l'initialisation du module `Kandinsky`) les coordonnées de l'écran vont de (0,0) à (319,221) centré sur l'écran de la fxCG. En mode étendu, les coordonnées de l'écran vont de (-38,-1) à (358,223).

View File

@ -22,10 +22,14 @@ extern bool is_dwindowed;
extern bool is_timered;
extern unsigned int timer_altered[9];
/* Parameters used in windowed mode to center the screen of the NW in the fxCG screen*/
#define DELTAXNW \
((DWIDTH - 320) / 2) // we center the NW screen on Casio's screen
#define DELTAYNW 1 // NW screen will be cut in the bottom
/* refresh rate of the screen */
#define TARGET_FPS 30
/* Definition of color on Numworks */
// Data can be found here
@ -85,7 +89,7 @@ static mp_obj_t Kandinsky_init(void) {
dwindow_set(nw);
is_dwindowed = true; // we mark as windowed
int t = timer_configure(TIMER_TMU, 33333, GINT_CALL(callback));
int t = timer_configure(TIMER_TMU, (1000000/TARGET_FPS), GINT_CALL(callback));
if (t >= 0) {
timer_start(t);
is_timered = true; // there is a timer altered from this module
@ -266,18 +270,29 @@ static mp_obj_t Kandinsky_CGEXT_Is_Wide_Screen_Enabled( void ) {
return mp_obj_new_bool( is_dwindowed );
}
static mp_obj_t Kandinsky_CGEXT_Set_Margin_Color( mp_obj_t color ) {
color_t colorside = NW_BLACK;
colorside = Internal_Treat_Color(color);
Kandinsky_CGEXT_Enable_Wide_Screen();
dclear(colorside);
Kandinsky_CGEXT_Disable_Wide_Screen();
return mp_obj_new_bool( is_dwindowed );
}
/* Extension of Kandinsky for fxCG - all names starting with "CGEXT_" */
MP_DEFINE_CONST_FUN_OBJ_0(Kandinsky_CGEXT_Enable_Wide_Screen_obj, Kandinsky_CGEXT_Enable_Wide_Screen);
MP_DEFINE_CONST_FUN_OBJ_0(Kandinsky_CGEXT_Disable_Wide_Screen_obj, Kandinsky_CGEXT_Disable_Wide_Screen);
MP_DEFINE_CONST_FUN_OBJ_0(Kandinsky_CGEXT_Is_Wide_Screen_Enabled_obj, Kandinsky_CGEXT_Is_Wide_Screen_Enabled);
MP_DEFINE_CONST_FUN_OBJ_1(Kandinsky_CGEXT_Set_Margin_Color_obj, Kandinsky_CGEXT_Set_Margin_Color);
/* Standard Kandinsky function as per Numworks specification */
MP_DEFINE_CONST_FUN_OBJ_0(Kandinsky_init_obj, Kandinsky_init);
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(Kandinsky_set_pixel_obj, 3, 3,
Kandinsky_set_pixel);
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(Kandinsky_set_pixel_obj, 3, 3, Kandinsky_set_pixel);
MP_DEFINE_CONST_FUN_OBJ_2(Kandinsky_get_pixel_obj, Kandinsky_get_pixel);
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(Kandinsky_draw_string_obj, 3, 5,
Kandinsky_draw_string);
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(Kandinsky_fill_rect_obj, 5, 5,
Kandinsky_fill_rect);
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(Kandinsky_draw_string_obj, 3, 5, Kandinsky_draw_string);
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(Kandinsky_fill_rect_obj, 5, 5, Kandinsky_fill_rect);
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(Kandinsky_color_obj, 3, 3, Kandinsky_color);
STATIC const mp_rom_map_elem_t kandinsky_module_globals_table[] = {
@ -291,6 +306,7 @@ STATIC const mp_rom_map_elem_t kandinsky_module_globals_table[] = {
{MP_ROM_QSTR(MP_QSTR_CGEXT_Enable_Wide_Screen), MP_ROM_PTR(&Kandinsky_CGEXT_Enable_Wide_Screen_obj)},
{MP_ROM_QSTR(MP_QSTR_CGEXT_Disable_Wide_Screen), MP_ROM_PTR(&Kandinsky_CGEXT_Disable_Wide_Screen_obj)},
{MP_ROM_QSTR(MP_QSTR_CGEXT_Is_Wide_Screen_Enabled), MP_ROM_PTR(&Kandinsky_CGEXT_Is_Wide_Screen_Enabled_obj)},
{MP_ROM_QSTR(MP_QSTR_CGEXT_Set_Margin_Color), MP_ROM_PTR(&Kandinsky_CGEXT_Set_Margin_Color_obj)},
};
STATIC MP_DEFINE_CONST_DICT(kandinsky_module_globals,
kandinsky_module_globals_table);