From 131f82839404f176a82330ac7fda20445a97cd88 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 29 Nov 2021 20:41:55 +0100 Subject: add POSIX argv → ssd1306 app MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/posix-argv-to-ssd1306/Kconfig | 6 +++++ src/app/posix-argv-to-ssd1306/Makefile.inc | 14 ++++++++++ src/app/posix-argv-to-ssd1306/main.cc | 37 +++++++++++++++++++++++++ src/app/posix-stdin-to-ssd1306/Kconfig | 6 +++++ src/app/posix-stdin-to-ssd1306/Makefile.inc | 14 ++++++++++ src/app/posix-stdin-to-ssd1306/main.cc | 42 +++++++++++++++++++++++++++++ src/app/posix-text-to-ss1306/Kconfig | 6 ----- src/app/posix-text-to-ss1306/Makefile.inc | 14 ---------- src/app/posix-text-to-ss1306/main.cc | 42 ----------------------------- 9 files changed, 119 insertions(+), 62 deletions(-) create mode 100644 src/app/posix-argv-to-ssd1306/Kconfig create mode 100644 src/app/posix-argv-to-ssd1306/Makefile.inc create mode 100644 src/app/posix-argv-to-ssd1306/main.cc create mode 100644 src/app/posix-stdin-to-ssd1306/Kconfig create mode 100644 src/app/posix-stdin-to-ssd1306/Makefile.inc create mode 100644 src/app/posix-stdin-to-ssd1306/main.cc delete mode 100644 src/app/posix-text-to-ss1306/Kconfig delete mode 100644 src/app/posix-text-to-ss1306/Makefile.inc delete mode 100644 src/app/posix-text-to-ss1306/main.cc (limited to 'src/app') diff --git a/src/app/posix-argv-to-ssd1306/Kconfig b/src/app/posix-argv-to-ssd1306/Kconfig new file mode 100644 index 0000000..a877b2c --- /dev/null +++ b/src/app/posix-argv-to-ssd1306/Kconfig @@ -0,0 +1,6 @@ +# Copyright 2021 Daniel Friesel +# +# SPDX-License-Identifier: CC0-1.0 + +prompt "POSIX Dust Monitor" +depends on arch_posix && driver_ssd1306 && !loop && !wakeup diff --git a/src/app/posix-argv-to-ssd1306/Makefile.inc b/src/app/posix-argv-to-ssd1306/Makefile.inc new file mode 100644 index 0000000..8c4936b --- /dev/null +++ b/src/app/posix-argv-to-ssd1306/Makefile.inc @@ -0,0 +1,14 @@ +# vim:ft=make +# +# Copyright 2021 Daniel Friesel +# +# SPDX-License-Identifier: CC0-1.0 + +ifdef app + loop = 1 + override arch_drivers += ,i2c + CONFIG_driver_ssd1306 = y + COMMON_FLAGS += -DCONFIG_driver_ssd1306 + CONFIG_driver_ssd1306_width = 128 + CONFIG_driver_ssd1306_height = 64 +endif diff --git a/src/app/posix-argv-to-ssd1306/main.cc b/src/app/posix-argv-to-ssd1306/main.cc new file mode 100644 index 0000000..408cd3f --- /dev/null +++ b/src/app/posix-argv-to-ssd1306/main.cc @@ -0,0 +1,37 @@ +/* + * Copyright 2021 Daniel Friesel + * + * SPDX-License-Identifier: BSD-2-Clause + */ +#include "arch.h" +#include "driver/stdout.h" +#if defined(MULTIPASS_ARCH_HAS_I2C) && !defined(CONFIG_driver_softi2c) +#include "driver/i2c.h" +#else +#include "driver/soft_i2c.h" +#endif +#include "driver/ssd1306.h" +#include "object/framebuffer.h" +#include "lib/pixelfont/pixeloperator_mirrored.h" +#include + +int main(int argc, char **argv) +{ + arch.setup(); + kout.setup(); + i2c.setup(); + + fb.clear(); + fb.setFont(pixeloperator_mirrored); + if (argc > 2) { + fb.drawBattery(114, 0, atoi(argv[1]), atoi(argv[2])); + for (unsigned char i = 3; i < argc; i++) { + fb << argv[i] << endl; + } + } else { + ssd1306.init(); + } + ssd1306.showImage(fb.data, fb.width * fb.height / 8); + + return 0; +} diff --git a/src/app/posix-stdin-to-ssd1306/Kconfig b/src/app/posix-stdin-to-ssd1306/Kconfig new file mode 100644 index 0000000..c103631 --- /dev/null +++ b/src/app/posix-stdin-to-ssd1306/Kconfig @@ -0,0 +1,6 @@ +# Copyright 2021 Daniel Friesel +# +# SPDX-License-Identifier: CC0-1.0 + +prompt "POSIX stdin to SSD1306" +depends on arch_posix && driver_ssd1306 diff --git a/src/app/posix-stdin-to-ssd1306/Makefile.inc b/src/app/posix-stdin-to-ssd1306/Makefile.inc new file mode 100644 index 0000000..8c4936b --- /dev/null +++ b/src/app/posix-stdin-to-ssd1306/Makefile.inc @@ -0,0 +1,14 @@ +# vim:ft=make +# +# Copyright 2021 Daniel Friesel +# +# SPDX-License-Identifier: CC0-1.0 + +ifdef app + loop = 1 + override arch_drivers += ,i2c + CONFIG_driver_ssd1306 = y + COMMON_FLAGS += -DCONFIG_driver_ssd1306 + CONFIG_driver_ssd1306_width = 128 + CONFIG_driver_ssd1306_height = 64 +endif diff --git a/src/app/posix-stdin-to-ssd1306/main.cc b/src/app/posix-stdin-to-ssd1306/main.cc new file mode 100644 index 0000000..a3fd085 --- /dev/null +++ b/src/app/posix-stdin-to-ssd1306/main.cc @@ -0,0 +1,42 @@ +/* + * Copyright 2021 Daniel Friesel + * + * SPDX-License-Identifier: BSD-2-Clause + */ +#include "arch.h" +#include "driver/stdout.h" +#if defined(MULTIPASS_ARCH_HAS_I2C) && !defined(CONFIG_driver_softi2c) +#include "driver/i2c.h" +#else +#include "driver/soft_i2c.h" +#endif +#include "driver/ssd1306.h" +#include "object/framebuffer.h" +#include "lib/pixelfont/pixeloperator_mirrored.h" + +#include + +char buf[32]; + +void loop() +{ +} + +int main(void) +{ + arch.setup(); + kout.setup(); + i2c.setup(); + ssd1306.init(); + + fb.clear(); + ssd1306.showImage(fb.data, fb.width * fb.height / 8); + fb.setFont(pixeloperator_mirrored); + + while (fgets(buf, 32, stdin)) { + fb << buf; + ssd1306.showImage(fb.data, fb.width * fb.height / 8); + } + + return 0; +} diff --git a/src/app/posix-text-to-ss1306/Kconfig b/src/app/posix-text-to-ss1306/Kconfig deleted file mode 100644 index c103631..0000000 --- a/src/app/posix-text-to-ss1306/Kconfig +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright 2021 Daniel Friesel -# -# SPDX-License-Identifier: CC0-1.0 - -prompt "POSIX stdin to SSD1306" -depends on arch_posix && driver_ssd1306 diff --git a/src/app/posix-text-to-ss1306/Makefile.inc b/src/app/posix-text-to-ss1306/Makefile.inc deleted file mode 100644 index 8c4936b..0000000 --- a/src/app/posix-text-to-ss1306/Makefile.inc +++ /dev/null @@ -1,14 +0,0 @@ -# vim:ft=make -# -# Copyright 2021 Daniel Friesel -# -# SPDX-License-Identifier: CC0-1.0 - -ifdef app - loop = 1 - override arch_drivers += ,i2c - CONFIG_driver_ssd1306 = y - COMMON_FLAGS += -DCONFIG_driver_ssd1306 - CONFIG_driver_ssd1306_width = 128 - CONFIG_driver_ssd1306_height = 64 -endif diff --git a/src/app/posix-text-to-ss1306/main.cc b/src/app/posix-text-to-ss1306/main.cc deleted file mode 100644 index a3fd085..0000000 --- a/src/app/posix-text-to-ss1306/main.cc +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2021 Daniel Friesel - * - * SPDX-License-Identifier: BSD-2-Clause - */ -#include "arch.h" -#include "driver/stdout.h" -#if defined(MULTIPASS_ARCH_HAS_I2C) && !defined(CONFIG_driver_softi2c) -#include "driver/i2c.h" -#else -#include "driver/soft_i2c.h" -#endif -#include "driver/ssd1306.h" -#include "object/framebuffer.h" -#include "lib/pixelfont/pixeloperator_mirrored.h" - -#include - -char buf[32]; - -void loop() -{ -} - -int main(void) -{ - arch.setup(); - kout.setup(); - i2c.setup(); - ssd1306.init(); - - fb.clear(); - ssd1306.showImage(fb.data, fb.width * fb.height / 8); - fb.setFont(pixeloperator_mirrored); - - while (fgets(buf, 32, stdin)) { - fb << buf; - ssd1306.showImage(fb.data, fb.width * fb.height / 8); - } - - return 0; -} -- cgit v1.2.3