-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Made the demo thingy properly center text. #7
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../components/ugfx/PermanentMarker36.c | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,25 +36,19 @@ | |
|
||
#ifndef UNIX | ||
#include "board_framebuffer.h" | ||
#include "ginput_lld_toggle_config.h" | ||
#endif | ||
|
||
#include "gfx.h" | ||
#include "gfxconf.h" | ||
#include "ginput_lld_toggle_config.h" | ||
|
||
#include "py/mperrno.h" | ||
#include "py/mphal.h" | ||
#include "py/runtime.h" | ||
|
||
const char *font_list[] = {"Roboto-Black22", "Roboto-BlackItalic24", | ||
"Roboto-Regular12", "Roboto-Regular18", | ||
"Roboto-Regular22", "PermanentMarker22"}; | ||
|
||
typedef struct _ugfx_obj_t { mp_obj_base_t base; } ugfx_obj_t; | ||
|
||
STATIC mp_obj_t ugfx_init(void) { | ||
// gwinSetDefaultFont(gdispOpenFont(font_list[0])); | ||
// gwinSetDefaultStyle(&WhiteWidgetStyle, FALSE); | ||
gfxInit(); | ||
return mp_const_none; | ||
} | ||
|
@@ -66,14 +60,6 @@ STATIC mp_obj_t ugfx_deinit(void) { | |
} | ||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(ugfx_deinit_obj, ugfx_deinit); | ||
|
||
/// \method print_fonts() | ||
/// | ||
/// Prints the list of installed fonts | ||
/// | ||
STATIC mp_obj_t ugfx_print_fonts(void) { | ||
return mp_obj_new_list(6, (void **)font_list); | ||
} | ||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(ugfx_print_fonts_obj, ugfx_print_fonts); | ||
|
||
// PRIMITIVES | ||
|
||
|
@@ -559,34 +545,28 @@ STATIC mp_obj_t ugfx_demo(mp_obj_t hacking) { | |
font_t permanentMarker; | ||
|
||
robotoBlackItalic = gdispOpenFont("Roboto_BlackItalic24"); | ||
permanentMarker = gdispOpenFont("PermanentMarker22"); | ||
permanentMarker = gdispOpenFont("PermanentMarker36"); | ||
|
||
uint16_t hackingWidth = gdispGetStringWidth(mp_obj_str_get_str(hacking), permanentMarker); | ||
|
||
gdispClear(White); | ||
gdispDrawString(150, 25, "STILL", robotoBlackItalic, Black); | ||
gdispDrawString(130, 50, mp_obj_str_get_str(hacking), permanentMarker, Black); | ||
gdispDrawStringBox(0, 6, 296, 40, "STILL", robotoBlackItalic, Black, justifyCenter); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. much nicer thx :) |
||
gdispDrawStringBox(0, 42, 276, 40, mp_obj_str_get_str(hacking), permanentMarker, Black, justifyCenter); | ||
// underline: | ||
gdispDrawLine( | ||
127 + 3, 50 + 22, | ||
127 + 3 + | ||
gdispGetStringWidth(mp_obj_str_get_str(hacking), permanentMarker) + | ||
14, | ||
50 + 22, Black); | ||
296/2 - hackingWidth/2 - 14, | ||
42 + 36 + 2, | ||
296/2 + hackingWidth/2 + 14, | ||
42 + 36 + 2, | ||
Black); | ||
// cursor: | ||
gdispDrawLine( | ||
127 + 3 + | ||
gdispGetStringWidth(mp_obj_str_get_str(hacking), permanentMarker) + | ||
10, | ||
50 + 2, | ||
127 + 3 + | ||
gdispGetStringWidth(mp_obj_str_get_str(hacking), permanentMarker) + | ||
10, | ||
50 + 22 - 2, Black); | ||
gdispDrawString(140, 75, "Anyway", robotoBlackItalic, Black); | ||
gdispFillCircle(60, 60, 50, Black); | ||
gdispFillCircle(60, 60, 40, White); | ||
gdispFillCircle(60, 60, 30, Black); | ||
gdispFillCircle(60, 60, 20, White); | ||
gdispFillCircle(60, 60, 10, Black); | ||
276/2 + hackingWidth/2 + 2 + 3, | ||
42 + 4, | ||
276/2 + hackingWidth/2 + 2, | ||
42 + 36, | ||
Black); | ||
gdispDrawStringBox(0, 82, 296, 40, "Anyway", robotoBlackItalic, Black, justifyCenter); | ||
gdispFlush(); | ||
|
||
return mp_const_none; | ||
|
@@ -609,22 +589,25 @@ STATIC const mp_rom_map_elem_t ugfx_module_globals_table[] = { | |
MP_OBJ_NEW_SMALL_INT(justifyCenter)}, | ||
{MP_OBJ_NEW_QSTR(MP_QSTR_justifyRight), MP_OBJ_NEW_SMALL_INT(justifyRight)}, | ||
|
||
{MP_OBJ_NEW_QSTR(MP_QSTR_JOY_UP), MP_OBJ_NEW_SMALL_INT(BADGE_BUTTON_UP)}, | ||
{MP_OBJ_NEW_QSTR(MP_QSTR_JOY_DOWN), | ||
MP_OBJ_NEW_SMALL_INT(BADGE_BUTTON_DOWN)}, | ||
{MP_OBJ_NEW_QSTR(MP_QSTR_JOY_LEFT), | ||
MP_OBJ_NEW_SMALL_INT(BADGE_BUTTON_LEFT)}, | ||
{MP_OBJ_NEW_QSTR(MP_QSTR_JOY_RIGHT), | ||
MP_OBJ_NEW_SMALL_INT(BADGE_BUTTON_RIGHT)}, | ||
{MP_OBJ_NEW_QSTR(MP_QSTR_BTN_MID), MP_OBJ_NEW_SMALL_INT(BADGE_BUTTON_MID)}, | ||
{MP_OBJ_NEW_QSTR(MP_QSTR_BTN_A), MP_OBJ_NEW_SMALL_INT(BADGE_BUTTON_A)}, | ||
{MP_OBJ_NEW_QSTR(MP_QSTR_BTN_B), MP_OBJ_NEW_SMALL_INT(BADGE_BUTTON_B)}, | ||
{MP_OBJ_NEW_QSTR(MP_QSTR_BTN_SELECT), | ||
MP_OBJ_NEW_SMALL_INT(BADGE_BUTTON_SELECT)}, | ||
{MP_OBJ_NEW_QSTR(MP_QSTR_BTN_START), | ||
MP_OBJ_NEW_SMALL_INT(BADGE_BUTTON_START)}, | ||
{MP_OBJ_NEW_QSTR(MP_QSTR_BTN_FLASH), | ||
MP_OBJ_NEW_SMALL_INT(BADGE_BUTTON_FLASH)}, | ||
#ifndef UNIX | ||
{MP_OBJ_NEW_QSTR(MP_QSTR_JOY_UP), MP_OBJ_NEW_SMALL_INT(BADGE_BUTTON_UP)}, | ||
{MP_OBJ_NEW_QSTR(MP_QSTR_JOY_DOWN), | ||
MP_OBJ_NEW_SMALL_INT(BADGE_BUTTON_DOWN)}, | ||
{MP_OBJ_NEW_QSTR(MP_QSTR_JOY_LEFT), | ||
MP_OBJ_NEW_SMALL_INT(BADGE_BUTTON_LEFT)}, | ||
{MP_OBJ_NEW_QSTR(MP_QSTR_JOY_RIGHT), | ||
MP_OBJ_NEW_SMALL_INT(BADGE_BUTTON_RIGHT)}, | ||
{MP_OBJ_NEW_QSTR(MP_QSTR_BTN_MID), MP_OBJ_NEW_SMALL_INT(BADGE_BUTTON_MID)}, | ||
{MP_OBJ_NEW_QSTR(MP_QSTR_BTN_A), MP_OBJ_NEW_SMALL_INT(BADGE_BUTTON_A)}, | ||
{MP_OBJ_NEW_QSTR(MP_QSTR_BTN_B), MP_OBJ_NEW_SMALL_INT(BADGE_BUTTON_B)}, | ||
{MP_OBJ_NEW_QSTR(MP_QSTR_BTN_SELECT), | ||
MP_OBJ_NEW_SMALL_INT(BADGE_BUTTON_SELECT)}, | ||
{MP_OBJ_NEW_QSTR(MP_QSTR_BTN_START), | ||
MP_OBJ_NEW_SMALL_INT(BADGE_BUTTON_START)}, | ||
{MP_OBJ_NEW_QSTR(MP_QSTR_BTN_FLASH), | ||
MP_OBJ_NEW_SMALL_INT(BADGE_BUTTON_FLASH)}, | ||
#endif | ||
|
||
|
||
{MP_OBJ_NEW_QSTR(MP_QSTR_clear), (mp_obj_t)&ugfx_clear_obj}, | ||
{MP_OBJ_NEW_QSTR(MP_QSTR_flush), (mp_obj_t)&ugfx_flush_obj}, | ||
|
@@ -655,8 +638,6 @@ STATIC const mp_rom_map_elem_t ugfx_module_globals_table[] = { | |
{MP_OBJ_NEW_QSTR(MP_QSTR_polygon), (mp_obj_t)&ugfx_polygon_obj}, | ||
{MP_OBJ_NEW_QSTR(MP_QSTR_fill_polygon), (mp_obj_t)&ugfx_fill_polygon_obj}, | ||
|
||
{MP_OBJ_NEW_QSTR(MP_QSTR_print_fonts), (mp_obj_t)&ugfx_print_fonts_obj}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are we implementing some API here or do we decide for ourselves what needs to be exposed? in any case the current implementation is ugly so removing the function altogether seems like an improvement to me, would appreciate a second set of eyes :) |
||
|
||
{MP_OBJ_NEW_QSTR(MP_QSTR_demo), (mp_obj_t)&ugfx_demo_obj}, | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm it'd be nice to avoid this but it's consistent with how we handle other fonts ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did this only because that's how the others were setup. It seems to just work when I remove the symlinks and just move the fonts from components/ugfx/ to micropython/esp32/. I could commit that to both PR's if desired.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No please don't move them, then it won't work with pure ugfx (without python) anymore :).
it'd be nice if upy could use the ugfx fonts without these symlinks, but that might be hard for some reason. Anyway this is OK for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK then :)