Skip to content

Commit 3b813c0

Browse files
committed
update
1 parent 705e80b commit 3b813c0

File tree

13 files changed

+140
-134
lines changed

13 files changed

+140
-134
lines changed

sketchbooks/enr_message_board/include/message.h

Lines changed: 0 additions & 72 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <M5EPD.h>
2+
3+
void clear_canvas(M5EPD_Canvas &canvas) {
4+
canvas.clear();
5+
canvas.setCursor(0, 0);
6+
}
7+
8+
void init_epd(M5EPD_Canvas &canvas_title, M5EPD_Canvas &canvas_status, M5EPD_Canvas &canvas_message) {
9+
canvas_title.createCanvas(540, 100);
10+
canvas_status.createCanvas(540, 60);
11+
canvas_message.createCanvas(540, 800);
12+
canvas_title.setTextSize(3);
13+
canvas_status.setTextSize(2);
14+
canvas_message.setTextSize(2);
15+
clear_canvas(canvas_title);
16+
clear_canvas(canvas_status);
17+
clear_canvas(canvas_message);
18+
}
19+
20+
void update_epd(M5EPD_Canvas &canvas_title, M5EPD_Canvas &canvas_status, M5EPD_Canvas &canvas_message) {
21+
canvas_title.pushCanvas(0, 0, UPDATE_MODE_DU4);
22+
canvas_status.pushCanvas(0, 100, UPDATE_MODE_DU4);
23+
canvas_message.pushCanvas(0, 160, UPDATE_MODE_DU4);
24+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include <smart_device_protocol/Packet.h>
2+
3+
#include <variant>
4+
#include <vector>
5+
6+
#include "sdp/packet_creator.h"
7+
#include "sdp/packet_parser.h"
8+
9+
class Message {
10+
public:
11+
inline static std::string packet_description_write = "Message Board to write";
12+
inline static std::string serialization_format_write = "siS";
13+
inline static std::string packet_description_message = "Message Board message";
14+
15+
char message[64];
16+
char source_name[64];
17+
unsigned long deadline;
18+
19+
Message(char *source_name, char *message, int32_t timeout_duration) {
20+
strncpy(this->source_name, source_name, 16);
21+
strncpy(this->message, message, 64);
22+
this->deadline = (int32_t)millis() + timeout_duration;
23+
}
24+
25+
void to_v2_packet(uint8_t *data) {
26+
std::vector<std::variant<int32_t, float, std::string, bool>> data_vector;
27+
data_vector.push_back(std::variant<int32_t, float, std::string, bool>(std::string(source_name)));
28+
data_vector.push_back(std::variant<int32_t, float, std::string, bool>((int32_t)(this->deadline - millis())));
29+
data_vector.push_back(std::variant<int32_t, float, std::string, bool>(std::string(message)));
30+
generate_data_frame(data, packet_description_message.c_str(), data_vector);
31+
}
32+
33+
static SDPInterfaceDescription get_interface_description() {
34+
return std::make_tuple(packet_description_message, serialization_format_write);
35+
}
36+
};
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)