-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph_window.hpp
More file actions
41 lines (31 loc) · 961 Bytes
/
graph_window.hpp
File metadata and controls
41 lines (31 loc) · 961 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#pragma once
#include <cstring>
#include <string>
#include <unordered_map>
#include "window.hpp"
class GraphWindow : public Window {
public:
GraphWindow() = default;
void init(lv_obj_t *parent, size_t width, size_t height) override;
void update() override;
void set_max_point_count(size_t max_point_count);
void clear_plots(void);
void add_data(const std::string &plot_name, int new_data);
void remove_plot(const std::string &plot_name);
lv_obj_t *get_lv_obj(void) { return wrapper_; }
void invalidate() {
if (wrapper_) {
lv_obj_invalidate(wrapper_);
}
}
protected:
lv_chart_series_t *create_plot(const std::string &plotName);
lv_chart_series_t *get_plot(const std::string &plotName);
void update_ticks(void);
private:
lv_obj_t *wrapper_{nullptr};
lv_obj_t *y_scale_{nullptr};
lv_obj_t *chart_{nullptr};
lv_obj_t *legend_{nullptr};
std::unordered_map<std::string, lv_chart_series_t *> plot_map_{};
};