diff --git a/ion/Makefile b/ion/Makefile index c49f13277..0e9555cff 100644 --- a/ion/Makefile +++ b/ion/Makefile @@ -25,7 +25,6 @@ initializer_list = $(shell echo $(1) | sed "s/\(.\)/'\1',/g")0 $(call object_for,ion/src/shared/platform_info.cpp): SFLAGS += -DPATCH_LEVEL="$(call initializer_list,$(PATCH_LEVEL))" -DEPSILON_VERSION="$(call initializer_list,$(EPSILON_VERSION))" ion_src += $(addprefix ion/src/shared/, \ - console_display.cpp:+consoledisplay \ console_line.cpp \ crc32_eat_byte.cpp \ decompress.cpp \ diff --git a/ion/src/device/shared/drivers/Makefile b/ion/src/device/shared/drivers/Makefile index a73470f0e..d099cca35 100644 --- a/ion/src/device/shared/drivers/Makefile +++ b/ion/src/device/shared/drivers/Makefile @@ -5,6 +5,8 @@ ion_device_src += $(addprefix ion/src/device/shared/drivers/, \ board.cpp \ clipboard.cpp \ console_uart.cpp:+consoleuart \ + console_display.cpp:+consoledisplay \ + console_dummy.cpp:-consoledisplay \ console_dummy.cpp:-consoleuart \ crc32.cpp \ display.cpp \ diff --git a/ion/src/device/shared/drivers/console_display.cpp b/ion/src/device/shared/drivers/console_display.cpp new file mode 100644 index 000000000..b85227bc7 --- /dev/null +++ b/ion/src/device/shared/drivers/console_display.cpp @@ -0,0 +1,39 @@ +#include "console.h" +#include +#include + +namespace Ion { +namespace Console { + +char readChar() { + return 0; +} + +void writeChar(char c) { + KDIonContext::putchar(c); +} + +bool transmissionDone() { + return true; +} + +} +} + +namespace Ion { +namespace Device { +namespace Console { + +void init() { +} + +void shutdown() { +} + +bool peerConnected() { + return false; +} + +} +} +} diff --git a/ion/src/device/shared/drivers/console_dummy.cpp b/ion/src/device/shared/drivers/console_dummy.cpp index 9ed1718f5..bc7eccd22 100644 --- a/ion/src/device/shared/drivers/console_dummy.cpp +++ b/ion/src/device/shared/drivers/console_dummy.cpp @@ -1,4 +1,22 @@ #include "console.h" +#include + +namespace Ion { +namespace Console { + +char readChar() { + return 0; +} + +void writeChar(char c) { +} + +bool transmissionDone() { + return true; +} + +} +} namespace Ion { namespace Device { diff --git a/ion/src/shared/console_display.cpp b/ion/src/shared/console_display.cpp deleted file mode 100644 index 8be425eb9..000000000 --- a/ion/src/shared/console_display.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include -#include - -namespace Ion { -namespace Console { - -char readChar() { - return '\0'; -} - -static KDPoint cursor = KDPointZero; - -void writeChar(char c) { - char text[2] = {c, 0}; - KDContext * ctx = KDIonContext::sharedContext(); - cursor = ctx->drawString(text, cursor); - if (cursor.y() > Ion::Display::Height) { - cursor = KDPoint(cursor.x(), 0); - } -} - -bool transmissionDone() { - // Always true because we flush after each writeChar - return true; -} - -} -} diff --git a/ion/src/simulator/shared/console.cpp b/ion/src/simulator/shared/console.cpp new file mode 100644 index 000000000..36b4a8f98 --- /dev/null +++ b/ion/src/simulator/shared/console.cpp @@ -0,0 +1,31 @@ +#include +#include "window.h" +#include +#include + +namespace Ion { +namespace Console { + +char readChar() { + if (Simulator::Window::isHeadless()) { + return getchar(); + } else { + return 0; + } +} + +void writeChar(char c) { + if (Simulator::Window::isHeadless()) { + putchar(c); + fflush(stdout); + } else { + KDIonContext::putchar(c); + } +} + +bool transmissionDone() { + return true; +} + +} +} diff --git a/ion/src/simulator/shared/console_stdio.cpp b/ion/src/simulator/shared/console_stdio.cpp deleted file mode 100644 index e77659f71..000000000 --- a/ion/src/simulator/shared/console_stdio.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -namespace Ion { -namespace Console { - -char readChar() { - return getchar(); -} - -void writeChar(char c) { - putchar(c); - fflush(stdout); -} - -bool transmissionDone() { - // Always true because we flush after each writeChar - return true; -} - -} -} diff --git a/kandinsky/include/kandinsky/ion_context.h b/kandinsky/include/kandinsky/ion_context.h index 42eb738ad..b367a557a 100644 --- a/kandinsky/include/kandinsky/ion_context.h +++ b/kandinsky/include/kandinsky/ion_context.h @@ -6,6 +6,7 @@ class KDIonContext : public KDContext { public: static KDIonContext * sharedContext(); + static void putchar(char c); private: KDIonContext(); void pushRect(KDRect rect, const KDColor * pixels) override; diff --git a/kandinsky/src/ion_context.cpp b/kandinsky/src/ion_context.cpp index ee7fcb5af..e1eb73c14 100644 --- a/kandinsky/src/ion_context.cpp +++ b/kandinsky/src/ion_context.cpp @@ -1,5 +1,5 @@ #include -#include +#include KDIonContext * KDIonContext::sharedContext() { static KDIonContext context; @@ -23,3 +23,12 @@ void KDIonContext::pushRectUniform(KDRect rect, KDColor color) { void KDIonContext::pullRect(KDRect rect, KDColor * pixels) { Ion::Display::pullRect(rect, pixels); } + +void KDIonContext::putchar(char c) { + static KDPoint cursor = KDPointZero; + char text[2] = {c, 0}; + cursor = sharedContext()->drawString(text, cursor); + if (cursor.y() > Ion::Display::Height) { + cursor = KDPoint(cursor.x(), 0); + } +}