Skip to content

Commit

Permalink
save calibrated values
Browse files Browse the repository at this point in the history
  • Loading branch information
R-Abbasi committed Sep 2, 2024
1 parent bf3380f commit b60c437
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/saves_popup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,21 @@ static void save(const Omniscope::Id &device,
device.sampleRate);
std::string fileContent;
fileContent.resize_and_overwrite(
// four bytes for each y_value, three for the number
// and one new line as a separator between the numbers
values.size() * 4, [&values, &y_indx](char *begin, std::size_t) {
auto end = begin;
for (; y_indx < values.size(); y_indx++) {
end = std::to_chars(end, end + 3, values[y_indx].second).ptr;
*end++ = '\n';
}
return end - begin;
});
// ten bytes for each y_value, nine for the number
// and one new line as a separator between the numbers
values.size() * 10, // take const ref to values
[&values = std::as_const(values), &y_indx](char *begin, std::size_t) {
auto end = begin;
constexpr unsigned factor{100'000};
for (; y_indx < values.size(); y_indx++) {
double value = values[y_indx].second * factor;
value = std::floor(value);
value /= factor;
end = std::to_chars(end, end + 9, value).ptr;
*end++ = '\n';
}
return end - begin;
});
// create a .csv file to write to it
std::ofstream file(outFile, std::ios::app);
if (!file.is_open()) {
Expand Down

0 comments on commit b60c437

Please sign in to comment.