diff --git a/python/port/genhdr/qstrdefs.in.h b/python/port/genhdr/qstrdefs.in.h index 5c13634eb..0f6d4e4c3 100644 --- a/python/port/genhdr/qstrdefs.in.h +++ b/python/port/genhdr/qstrdefs.in.h @@ -74,6 +74,7 @@ Q(get_pixel) Q(set_pixel) // Matplotlib QSTRs +Q(arrow) Q(axis) Q(bar) Q(grid) diff --git a/python/port/mod/matplotlib/modpyplot.cpp b/python/port/mod/matplotlib/modpyplot.cpp index 5cd0a92e9..eb26002f2 100644 --- a/python/port/mod/matplotlib/modpyplot.cpp +++ b/python/port/mod/matplotlib/modpyplot.cpp @@ -46,6 +46,16 @@ void modpyplot_gc_collect() { ); } +mp_obj_t modpyplot_arrow(size_t n_args, const mp_obj_t *args) { + assert(n_args == 4); + assert(sPlotStore != nullptr); + + KDColor color = Palette::DataColor[paletteIndex++]; // FIXME: Share overflow routine + sPlotStore->addSegment(args[0], args[1], mp_obj_new_float(mp_obj_get_float(args[0])+mp_obj_get_float(args[2])), mp_obj_new_float(mp_obj_get_float(args[1])+mp_obj_get_float(args[3])), color); + + return mp_const_none; +} + /* axis(arg) * - arg = [xmin, xmax, ymin, ymax] * - arg = True, False diff --git a/python/port/mod/matplotlib/modpyplot.h b/python/port/mod/matplotlib/modpyplot.h index 598402700..0cf40d3fc 100644 --- a/python/port/mod/matplotlib/modpyplot.h +++ b/python/port/mod/matplotlib/modpyplot.h @@ -3,6 +3,7 @@ mp_obj_t modpyplot___init__(); void modpyplot_gc_collect(); +mp_obj_t modpyplot_arrow(size_t n_args, const mp_obj_t *args); mp_obj_t modpyplot_axis(mp_obj_t arg); mp_obj_t modpyplot_bar(mp_obj_t x, mp_obj_t height); mp_obj_t modpyplot_grid(mp_obj_t b); @@ -10,5 +11,4 @@ mp_obj_t modpyplot_hist(mp_obj_t x); mp_obj_t modpyplot_plot(mp_obj_t x, mp_obj_t y); mp_obj_t modpyplot_scatter(mp_obj_t x, mp_obj_t y); mp_obj_t modpyplot_text(mp_obj_t x, mp_obj_t y, mp_obj_t s); -//mp_obj_t arrow(); mp_obj_t modpyplot_show(); diff --git a/python/port/mod/matplotlib/modpyplot_table.c b/python/port/mod/matplotlib/modpyplot_table.c index e3e311c0f..402b33e65 100644 --- a/python/port/mod/matplotlib/modpyplot_table.c +++ b/python/port/mod/matplotlib/modpyplot_table.c @@ -1,6 +1,7 @@ #include "modpyplot.h" STATIC MP_DEFINE_CONST_FUN_OBJ_0(modpyplot___init___obj, modpyplot___init__); +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modpyplot_arrow_obj, 4, 4, modpyplot_arrow); STATIC MP_DEFINE_CONST_FUN_OBJ_1(modpyplot_axis_obj, modpyplot_axis); STATIC MP_DEFINE_CONST_FUN_OBJ_2(modpyplot_bar_obj, modpyplot_bar); STATIC MP_DEFINE_CONST_FUN_OBJ_1(modpyplot_grid_obj, modpyplot_grid); @@ -13,6 +14,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(modpyplot_text_obj, modpyplot_text); STATIC const mp_rom_map_elem_t modpyplot_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_pyplot) }, { MP_ROM_QSTR(MP_QSTR___init__), MP_ROM_PTR(&modpyplot___init___obj) }, + { MP_ROM_QSTR(MP_QSTR_arrow), MP_ROM_PTR(&modpyplot_arrow_obj) }, { MP_ROM_QSTR(MP_QSTR_axis), MP_ROM_PTR(&modpyplot_axis_obj) }, { MP_ROM_QSTR(MP_QSTR_bar), MP_ROM_PTR(&modpyplot_bar_obj) }, { MP_ROM_QSTR(MP_QSTR_grid), MP_ROM_PTR(&modpyplot_grid_obj) },