shabadge display

This commit is contained in:
folkert van heusden 2023-04-01 20:40:45 +02:00
parent 393ec9098b
commit f12c0f5b53
Signed by untrusted user who does not match committer: folkert
GPG key ID: 6B6455EDFEED3BD1
10 changed files with 135 additions and 20 deletions

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "ESP32/SHAdisplay"]
path = ESP32/SHAdisplay
url = https://github.com/krzychb/esp-epaper-29-dke

1
ESP32/SHAdisplay Submodule

@ -0,0 +1 @@
Subproject commit 18b42491ceecbfdb70e0dac69a379f5787a84a5d

View file

@ -14,8 +14,8 @@
#define NEOPIXELS_PIN 25 #define NEOPIXELS_PIN 25
console_esp32::console_esp32(std::atomic_uint32_t *const stop_event, bus *const b, std::vector<Stream *> & io_ports) : console_esp32::console_esp32(std::atomic_uint32_t *const stop_event, bus *const b, std::vector<Stream *> & io_ports, const int t_width, const int t_height) :
console(stop_event, b), console(stop_event, b, t_width, t_height),
io_ports(io_ports) io_ports(io_ports)
{ {
} }

View file

@ -18,7 +18,7 @@ protected:
void put_char_ll(const char c) override; void put_char_ll(const char c) override;
public: public:
console_esp32(std::atomic_uint32_t *const stop_event, bus *const b, std::vector<Stream *> & io_ports); console_esp32(std::atomic_uint32_t *const stop_event, bus *const b, std::vector<Stream *> & io_ports, const int t_width, const int t_height);
virtual ~console_esp32(); virtual ~console_esp32();
void put_string_lf(const std::string & what) override; void put_string_lf(const std::string & what) override;

View file

@ -0,0 +1,72 @@
// (C) 2023 by Folkert van Heusden
// Released under MIT license
#include <SPI.h>
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#include "console_shabadge.h"
#include "cpu.h"
#include "error.h"
#include "utils.h"
#define COLORED 0
#define UNCOLORED 1
console_shabadge::console_shabadge(std::atomic_uint32_t *const stop_event, bus *const b, std::vector<Stream *> & io_ports) :
console_esp32(stop_event, b, io_ports, 296 / 8, 128 / 8)
{
if (epd.Init() != 0)
Serial.println("Init of DEPG0290B01 failed");
else {
Serial.println("DEPG0290B01 initialized");
paint = new Paint(image, 0, 0);
paint->SetRotate(ROTATE_270);
paint->SetWidth(128);
paint->SetHeight(296);
paint->Clear(UNCOLORED);
epd.ClearFrameMemory(UNCOLORED);
}
}
console_shabadge::~console_shabadge()
{
stop_thread();
delete paint;
}
void console_shabadge::put_char_ll(const char c)
{
screen_updated = true;
}
void console_shabadge::panel_update_thread()
{
for(;;) {
vTaskDelay(1000 / portTICK_RATE_MS);
if (screen_updated.exchange(false)) {
paint->Clear(UNCOLORED);
for(int y=0; y<t_height; y++) {
for(int x=0; x<t_width; x++) {
char c = screen_buffer[y * t_width + x];
if (c <= 0)
c = ' ';
paint->DrawCharAt(x * 8, y * 8, c, &Font8, COLORED);
}
}
epd.SetFrameMemory(paint->GetImage(), 0, 0, paint->GetWidth(), paint->GetHeight());
epd.DisplayFrame();
}
}
}

28
ESP32/console_shabadge.h Normal file
View file

@ -0,0 +1,28 @@
// (C) 2023 by Folkert van Heusden
// Released under MIT license
#include <Arduino.h>
#include <epd2in9-badge.h>
#include <epdpaint.h>
#include <vector>
#include "console_esp32.h"
class console_shabadge : public console_esp32
{
private:
unsigned char image[4736];
Paint *paint { nullptr };
Epd epd;
std::atomic_bool screen_updated { false };
void put_char_ll(const char c) override;
public:
console_shabadge(std::atomic_uint32_t *const stop_event, bus *const b, std::vector<Stream *> & io_ports);
virtual ~console_shabadge();
void panel_update_thread() override;
};

View file

@ -14,7 +14,11 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/types.h> #include <sys/types.h>
#if defined(SHA2017)
#include "console_shabadge.h"
#else
#include "console_esp32.h" #include "console_esp32.h"
#endif
#include "cpu.h" #include "cpu.h"
#include "debugger.h" #include "debugger.h"
#include "disk_backend.h" #include "disk_backend.h"
@ -513,7 +517,11 @@ void setup()
Serial_RS232.println(F("\014Console enabled on TTY")); Serial_RS232.println(F("\014Console enabled on TTY"));
std::vector<Stream *> serial_ports { &Serial_RS232, &Serial }; std::vector<Stream *> serial_ports { &Serial_RS232, &Serial };
cnsl = new console_esp32(&stop_event, b, serial_ports); #if defined(SHA2017)
cnsl = new console_shabadge(&stop_event, b, serial_ports);
#else
cnsl = new console_esp32(&stop_event, b, serial_ports, 80, 25);
#endif
Serial.println(F("Start line-frequency interrupt")); Serial.println(F("Start line-frequency interrupt"));
kw11_l *lf = new kw11_l(b, cnsl); kw11_l *lf = new kw11_l(b, cnsl);

View file

@ -4,10 +4,10 @@
[platformio] [platformio]
default_envs = ESP32-wemos default_envs = ESP32-wemos
src_dir = . src_dir = .
lib_ignore = SHAdisplay
[env:ESP32-wemos] [env:ESP32-wemos]
lib_ldf_mode = deep+ build_src_filter = +<*> -<.git/> -<.svn/> -<example/> -<examples/> -<test/> -<tests/> -<build> -<player.cpp> -<SHAdisplay/> -<console_shabadge.cpp>
build_src_filter = +<*> -<.git/> -<.svn/> -<example/> -<examples/> -<test/> -<tests/> -<build> -<player.cpp>
platform = espressif32 platform = espressif32
board = wemos_d1_mini32 board = wemos_d1_mini32
framework = arduino framework = arduino
@ -21,8 +21,7 @@ build_flags = -std=gnu++17 -Ofast -DESP32=1 -ggdb3 -D_GLIBCXX_USE_C99
build_unflags = -std=gnu++11 -Os build_unflags = -std=gnu++11 -Os
[env:SHA2017-badge] [env:SHA2017-badge]
lib_ldf_mode = deep+ build_src_filter = +<*> -<.git/> -<.svn/> -<example/> -<examples/> -<test/> -<tests/> -<build> -<player.cpp> -<SHAdisplay/main/> -<SHAdisplay/components> -<SHAdisplay/Arduino/epd2in9-badge>
build_src_filter = +<*> -<.git/> -<.svn/> -<example/> -<examples/> -<test/> -<tests/> -<build> -<player.cpp>
platform = espressif32 platform = espressif32
board = esp32doit-devkit-v1 board = esp32doit-devkit-v1
framework = arduino framework = arduino
@ -32,6 +31,6 @@ board_build.filesystem = littlefs
lib_deps = greiman/SdFat@^2.1.2 lib_deps = greiman/SdFat@^2.1.2
adafruit/Adafruit NeoPixel adafruit/Adafruit NeoPixel
bblanchon/ArduinoJson@^6.19.4 bblanchon/ArduinoJson@^6.19.4
build_flags = -std=gnu++17 -Ofast -DESP32=1 -DSHA2017 -ggdb3 -D_GLIBCXX_USE_C99 build_flags = -std=gnu++17 -Ofast -DESP32=1 -DSHA2017 -ggdb3 -D_GLIBCXX_USE_C99 -ISHAdisplay/Arduino/libraries/epd2in9-badge -ISHAdisplay/Arduino/libraries/epdpaint -ISHAdisplay/components/epaper-29-dke
build_unflags = -std=gnu++11 -Os build_unflags = -std=gnu++11 -Os
upload_protocol = esptool upload_protocol = esptool

View file

@ -15,11 +15,14 @@
#include "utils.h" #include "utils.h"
console::console(std::atomic_uint32_t *const stop_event, bus *const b) : console::console(std::atomic_uint32_t *const stop_event, bus *const b, const int t_width, const int t_height) :
stop_event(stop_event), stop_event(stop_event),
b(b) b(b),
t_width(t_width),
t_height(t_height)
{ {
memset(screen_buffer, ' ', sizeof screen_buffer);
screen_buffer = new char[t_width * t_height]();
} }
console::~console() console::~console()
@ -27,6 +30,8 @@ console::~console()
// done as well in subclasses but also here to // done as well in subclasses but also here to
// stop lgtm.com complaining about it // stop lgtm.com complaining about it
stop_thread(); stop_thread();
delete [] screen_buffer;
} }
void console::start_thread() void console::start_thread()
@ -187,7 +192,7 @@ void console::put_char(const char c)
tx--; tx--;
} }
else { else {
screen_buffer[ty][tx++] = c; screen_buffer[ty * t_width + tx++] = c;
if (tx == t_width) { if (tx == t_width) {
tx = 0; tx = 0;
@ -200,11 +205,11 @@ void console::put_char(const char c)
} }
if (ty == t_height) { if (ty == t_height) {
memmove(&screen_buffer[0], &screen_buffer[1], sizeof(char) * t_width * (t_height - 1)); memmove(&screen_buffer[0 * t_width], &screen_buffer[1 * t_width], sizeof(char) * t_width * (t_height - 1));
ty--; ty--;
memset(screen_buffer[t_height - 1], ' ', t_width); memset(&screen_buffer[(t_height - 1) * t_width], ' ', t_width);
} }
} }

View file

@ -16,9 +16,6 @@
#endif #endif
constexpr const int t_width { 80 };
constexpr const int t_height { 25 };
class console class console
{ {
private: private:
@ -37,7 +34,9 @@ protected:
bool stop_thread_flag { false }; bool stop_thread_flag { false };
char screen_buffer[t_height][t_width]; const int t_width { 0 };
const int t_height { 0 };
char *screen_buffer { nullptr };
uint8_t tx { 0 }; uint8_t tx { 0 };
uint8_t ty { 0 }; uint8_t ty { 0 };
@ -48,7 +47,7 @@ protected:
virtual void put_char_ll(const char c) = 0; virtual void put_char_ll(const char c) = 0;
public: public:
console(std::atomic_uint32_t *const stop_event, bus *const b); console(std::atomic_uint32_t *const stop_event, bus *const b, const int t_width = 80, const int t_height = 25);
virtual ~console(); virtual ~console();
void start_thread(); void start_thread();