#include "libs/http_client/curl_thread_pool_p.h" #include "picodeparser.h" #include "pidigest.h" #include "pihttpclient.h" #include "pip.h" #include "pivaluetree_conversions.h" using namespace PICoutManipulators; using namespace PIHTTP; PIMathVectord data; void _sfplot(const PIMathVectord & sf, PIString * str, const int lines, const int length) { int offset = (data.size() - length) / 2 / 2; double max_sf = 0; for (int i = 0; i < length * 2; i++) { if (sf[offset + i] > max_sf) { max_sf = sf[offset + i]; } } static PIVector2D grid; grid.clear(); grid.resize(lines * 2, length * 2); // clang-format off static const PIChar dots[16] = { PIChar::fromUTF8(" "), PIChar::fromUTF8("▘"), PIChar::fromUTF8("▝"), PIChar::fromUTF8("▀"), PIChar::fromUTF8("▖"), PIChar::fromUTF8("▌"), PIChar::fromUTF8("▞"), PIChar::fromUTF8("▛"), PIChar::fromUTF8("▗"), PIChar::fromUTF8("▚"), PIChar::fromUTF8("▐"), PIChar::fromUTF8("▜"), PIChar::fromUTF8("▄"), PIChar::fromUTF8("▙"), PIChar::fromUTF8("▟"), PIChar::fromUTF8("█"), }; // clang-format on memset(grid.data(), 0, grid.size()); for (int c = 0; c < grid.cols(); c++) { double rind = piClampi(piRound(sf[offset + c] / max_sf * (grid.rows() - 1)), 0, grid.rows() - 1); grid.element(rind, c) = 1; } union helper { uint index = 0; struct { uint tl: 1; uint tr: 1; uint bl: 1; uint br: 1; }; }; for (int i = 0; i < lines; i++) { str[i].resize(length); } helper h; for (int l = 0; l < lines; l++) { for (int c = 0; c < length; c++) { int l2 = l + l; int c2 = c + c; h.bl = grid.element(l2, c2); h.br = grid.element(l2, c2 + 1); h.tl = grid.element(l2 + 1, c2); h.tr = grid.element(l2 + 1, c2 + 1); // piCout << h.index; str[lines - 1 - l][c] = dots[h.index]; } } } TileSimple * test_tile; PIScreen screen; PIMathVectord asf; int main(int argc, char * argv[]) { test_tile = new TileSimple(); screen.rootTile()->addTile(test_tile); screen.rootTile()->addTile(new TilePICout()); PITimer _t; PIString str[9]; asf.resize(80); _t.start(20_Hz, [&str] { static double t = 0; t += 0.1; for (uint i = 0; i < asf.size(); ++i) asf[i] = 1. + sin(t + 2. * i * M_2PI / asf.size()); _sfplot(asf, str, 9, 28); screen.lock(); test_tile->content.resize(9); for (int i = 0; i < 9; i++) { test_tile->content[i].first = str[i]; } screen.unlock(); piCout << "Время: "_u8 << t; }); screen.enableExitCapture(); WAIT_FOR_EXIT; screen.stopAndWait(); return 0; }