Move plex to use std::array instead of std::vector
This commit is contained in:
parent
e2347adb16
commit
e1cf39ed70
@ -77,13 +77,13 @@ void plex::update(){
|
|||||||
|
|
||||||
//parse the result
|
//parse the result
|
||||||
json_doc.Parse(json_string.c_str());
|
json_doc.Parse(json_string.c_str());
|
||||||
entries.clear();
|
//entries.clear();
|
||||||
|
|
||||||
//update internal state
|
//update internal state
|
||||||
rapidjson::Value& curr_entry = json_doc["response"]["data"]["data"];
|
rapidjson::Value& curr_entry = json_doc["response"]["data"]["data"];
|
||||||
|
|
||||||
for(short i = 0; i < 4; ++i){
|
for(short i = 0; i < 4; ++i){
|
||||||
entries.push_back({
|
entries.at(i) = {
|
||||||
truncate(curr_entry[i]["friendly_name"].GetString(),
|
truncate(curr_entry[i]["friendly_name"].GetString(),
|
||||||
PLEX_MAX_STRING_LENGTH),
|
PLEX_MAX_STRING_LENGTH),
|
||||||
truncate(curr_entry[i]["ip_address"].GetString(),
|
truncate(curr_entry[i]["ip_address"].GetString(),
|
||||||
@ -92,7 +92,7 @@ void plex::update(){
|
|||||||
PLEX_MAX_STRING_LENGTH),
|
PLEX_MAX_STRING_LENGTH),
|
||||||
truncate(curr_entry[i]["state"].IsNull() ? "Historical" : "Playing",
|
truncate(curr_entry[i]["state"].IsNull() ? "Historical" : "Playing",
|
||||||
PLEX_MAX_STRING_LENGTH),
|
PLEX_MAX_STRING_LENGTH),
|
||||||
});
|
};
|
||||||
|
|
||||||
std::cerr << entries[i].friendly_name << "\n";
|
std::cerr << entries[i].friendly_name << "\n";
|
||||||
std::cerr << entries[i].ip_address << "\n";
|
std::cerr << entries[i].ip_address << "\n";
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <vector>
|
#include <array>
|
||||||
|
|
||||||
namespace dashboard::panel {
|
namespace dashboard::panel {
|
||||||
class plex : public panel {
|
class plex : public panel {
|
||||||
@ -47,7 +47,7 @@ namespace dashboard::panel {
|
|||||||
std::string state;
|
std::string state;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<plex_entry> entries;
|
std::array<plex_entry, 4> entries;
|
||||||
|
|
||||||
|
|
||||||
std::chrono::time_point<std::chrono::high_resolution_clock> _last_update;
|
std::chrono::time_point<std::chrono::high_resolution_clock> _last_update;
|
||||||
|
@ -33,5 +33,4 @@ namespace dashboard::panel {
|
|||||||
constexpr uint8_t PLEX_BGBOX_BLUE = 0x66;
|
constexpr uint8_t PLEX_BGBOX_BLUE = 0x66;
|
||||||
constexpr uint8_t PLEX_BGBOX_ALPHA = 0x99;
|
constexpr uint8_t PLEX_BGBOX_ALPHA = 0x99;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user