From a33b6f10ca84e1150b55c67e0780872d87273f08 Mon Sep 17 00:00:00 2001 From: Dorian Stoll Date: Wed, 21 Feb 2024 22:03:12 +0100 Subject: [PATCH] apps: calibrate: Generate device specific configs --- src/apps/calibrate/calibrate.hpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/apps/calibrate/calibrate.hpp b/src/apps/calibrate/calibrate.hpp index baa72827..c4eb5065 100644 --- a/src/apps/calibrate/calibrate.hpp +++ b/src/apps/calibrate/calibrate.hpp @@ -112,9 +112,12 @@ class Calibrate : public core::Application { const clock::duration now = clock::now().time_since_epoch(); usize unix = chrono::duration_cast>(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); @@ -122,19 +125,22 @@ class Calibrate : public core::Application { // 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!"); @@ -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";