Skip to content

Commit

Permalink
apps: calibrate: Generate device specific configs
Browse files Browse the repository at this point in the history
  • Loading branch information
StollD committed Feb 21, 2024
1 parent bb6a0df commit a33b6f1
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/apps/calibrate/calibrate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,29 +112,35 @@ class Calibrate : public core::Application {
const clock::duration now = clock::now().time_since_epoch();
usize unix = chrono::duration_cast<seconds<usize>>(now).count();

const std::string no_slack = fmt::format("iptsd_calib_{}_0mm.conf", unix);
const std::string some_slack = fmt::format("iptsd_calib_{}_2mm.conf", unix);
const std::string much_slack = fmt::format("iptsd_calib_{}_10mm.conf", unix);
const std::string devtime =
fmt::format("{:04X}_{:04X}_{}", m_info.vendor, m_info.product, unix);

const std::string no_slack = fmt::format("iptsd_calib_{}_0mm.conf", devtime);
const std::string some_slack = fmt::format("iptsd_calib_{}_2mm.conf", devtime);
const std::string much_slack = fmt::format("iptsd_calib_{}_10mm.conf", devtime);

this->write_file(no_slack, 0.0);
this->write_file(some_slack, 0.1);
this->write_file(much_slack, 0.5);

// clang-format off

const std::string filename =
fmt::format("{}/90-calibration-{:04X}-{:04X}.conf", common::buildopts::ConfigDir, m_info.vendor, m_info.product);

spdlog::info("");
spdlog::info("To finish the calibration process, apply the determined values to iptsd.");
spdlog::info("Three config snippets have been generated for you in the current directory.");
spdlog::info("Run the displayed to command to install them, and restart iptsd.");
spdlog::info("");
spdlog::info("Recommended:");
spdlog::info(" sudo cp {} {}/90-calibration.conf", some_slack, common::buildopts::ConfigDir);
spdlog::info(" sudo cp {} {}", some_slack, filename);
spdlog::info("");
spdlog::info("If iptsd misses inputs:");
spdlog::info(" sudo cp {} {}/90-calibration.conf", much_slack, common::buildopts::ConfigDir);
spdlog::info(" sudo cp {} {}", much_slack, filename);
spdlog::info("");
spdlog::info("For manual finetuning:");
spdlog::info(" sudo cp {} {}/90-calibration.conf", no_slack, common::buildopts::ConfigDir);
spdlog::info(" sudo cp {} {}", no_slack, filename);
spdlog::info("");
spdlog::warn("Running these commands can permanently overwrite a previous calibration!");

Expand Down Expand Up @@ -190,6 +196,10 @@ class Calibrate : public core::Application {
writer << "# Slack: " << fmt::format("{:.3f}", slack) << "\n";
writer << "#\n";
writer << "\n";
writer << "[Device]\n";
writer << "Vendor = " << fmt::format("0x{:04X}", m_info.vendor) << "\n";
writer << "Product = " << fmt::format("0x{:04X}", m_info.product) << "\n";
writer << "\n";
writer << "[Contacts]\n";
writer << "SizeMin = " << fmt::format("{:.3f}", size_min) << "\n";
writer << "SizeMax = " << fmt::format("{:.3f}", size_max) << "\n";
Expand Down

0 comments on commit a33b6f1

Please sign in to comment.