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 b45385e
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/apps/calibrate/calibrate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,29 +112,37 @@ 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 u16 vendor = m_info.vendor;
const u16 product = m_info.product;

const std::string devtime = fmt::format("{:04X}_{:04X}_{}", vendor, 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, vendor, 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 +198,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 b45385e

Please sign in to comment.