mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-20 09:17:23 +01:00
[python] modpyplot: show() does nothing when the store is empty
This commit is contained in:
@@ -342,6 +342,9 @@ mp_obj_t modpyplot_text(mp_obj_t x, mp_obj_t y, mp_obj_t s) {
|
||||
}
|
||||
|
||||
mp_obj_t modpyplot_show() {
|
||||
if (sPlotStore->isEmpty()) {
|
||||
return mp_const_none;
|
||||
}
|
||||
MicroPython::ExecutionEnvironment * env = MicroPython::ExecutionEnvironment::currentExecutionEnvironment();
|
||||
env->displayViewController(sPlotController);
|
||||
return mp_const_none;
|
||||
|
||||
@@ -20,6 +20,10 @@ void PlotStore::flush() {
|
||||
m_gridRequested = false;
|
||||
}
|
||||
|
||||
bool PlotStore::isEmpty() {
|
||||
return MP_OBJ_SMALL_INT_VALUE(mp_obj_len(m_dots)) == 0 && MP_OBJ_SMALL_INT_VALUE(mp_obj_len(m_segments)) == 0 && MP_OBJ_SMALL_INT_VALUE(mp_obj_len(m_rects)) == 0 && MP_OBJ_SMALL_INT_VALUE(mp_obj_len(m_labels)) == 0;
|
||||
}
|
||||
|
||||
// Iterators
|
||||
|
||||
template <class T>
|
||||
|
||||
@@ -13,6 +13,7 @@ class PlotStore : public Shared::InteractiveCurveViewRange {
|
||||
public:
|
||||
PlotStore();
|
||||
void flush();
|
||||
bool isEmpty();
|
||||
|
||||
// Iterators
|
||||
|
||||
|
||||
Reference in New Issue
Block a user