add basic timetable structure
This commit is contained in:
parent
87c9b1e125
commit
af5252f732
@ -1,32 +1,43 @@
|
|||||||
#include "timetable.h"
|
#include "timetable.h"
|
||||||
#include <cstdint>
|
|
||||||
#include <nlohmann/json.hpp>
|
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
#include <cstdint>
|
||||||
|
#include <format>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <ncurses.h>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using nlohmann::json;
|
||||||
|
|
||||||
#define NLINES 10
|
|
||||||
#define NCOLS 40
|
|
||||||
|
|
||||||
#define DEFAULT_X_OFFSET 10
|
|
||||||
#define DEFAULT_Y_OFFSET 2
|
|
||||||
|
|
||||||
#define DEFAULT_PADDING 4
|
|
||||||
|
|
||||||
void timetable_page() {
|
void timetable_page() {
|
||||||
// DONT FORGET TO UNCOMMENT
|
// DONT FORGET TO UNCOMMENT
|
||||||
// json resp_from_api = bakaapi::get_data_from_endpoint("api/3/timetable/actual");
|
// json resp_from_api =
|
||||||
std::ifstream f("test-data/timetable.json");
|
// bakaapi::get_data_from_endpoint("api/3/timetable/actual");
|
||||||
json resp_from_api = json::parse(f);
|
std::ifstream f("test-data/timetable.json");
|
||||||
|
json resp_from_api = json::parse(f);
|
||||||
|
|
||||||
// calculate table size
|
// calculate table size
|
||||||
|
// some lambda dark magic
|
||||||
uint8_t column_number = 0;
|
const uint8_t num_of_columns = [&]() -> uint8_t {
|
||||||
for(uint8_t i = 0; i < resp_from_api["Days"].size(); i++) {
|
uint8_t result = 0;
|
||||||
(resp_from_api["Days"][i]["Atoms"].size() > column_number) ? (column_number = resp_from_api["Days"][i]["Atoms"].size());
|
for (uint8_t i = 0; i < resp_from_api["Days"].size(); i++) {
|
||||||
|
uint8_t currentSize = resp_from_api["Days"][i]["Atoms"].size();
|
||||||
|
if (currentSize > result) {
|
||||||
|
result = currentSize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
|
}();
|
||||||
|
|
||||||
|
const uint8_t num_of_rows = resp_from_api["Days"].size();
|
||||||
|
|
||||||
|
setlocale(LC_ALL, "");
|
||||||
|
/* Initialize curses */
|
||||||
|
initscr();
|
||||||
|
start_color();
|
||||||
|
cbreak();
|
||||||
|
noecho();
|
||||||
|
keypad(stdscr, TRUE);
|
||||||
|
|
||||||
|
printw("LINES: %d COLS: %d", LINES, COLS);
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user