-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
26,551 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//{{NO_DEPENDENCIES}} | ||
// Microsoft Visual C++ generated include file. | ||
// Used by WindowsApp_test.rc | ||
|
||
#define IDS_APP_TITLE 103 | ||
|
||
#define IDR_MAINFRAME 128 | ||
#define IDD_WINDOWSAPPTEST_DIALOG 102 | ||
#define IDD_ABOUTBOX 103 | ||
#define IDM_ABOUT 104 | ||
#define IDM_EXIT 105 | ||
#define IDI_WINDOWSAPPTEST 107 | ||
#define IDI_SMALL 108 | ||
#define IDC_WINDOWSAPPTEST 109 | ||
#define IDC_MYICON 2 | ||
#ifndef IDC_STATIC | ||
#define IDC_STATIC -1 | ||
#define IDB_BUTTON 1000 | ||
#define IDC_COMBOBOX1 1001 | ||
#define IDC_COMBOBOX2 1002 | ||
#define IDC_COMBOBOX3 1003 | ||
#define IDC_COMBOBOX4 1004 | ||
#define IDB_CONNECT_SERIAL_BTN 1068 | ||
#define IDB_SAVE_PRESET_BTN 1069 | ||
#define IDB_LOAD_PRESET_BTN 1070 | ||
#endif | ||
// Next default values for new objects | ||
// | ||
#ifdef APSTUDIO_INVOKED | ||
#ifndef APSTUDIO_READONLY_SYMBOLS | ||
|
||
#define _APS_NO_MFC 130 | ||
#define _APS_NEXT_RESOURCE_VALUE 129 | ||
#define _APS_NEXT_COMMAND_VALUE 32771 | ||
#define _APS_NEXT_CONTROL_VALUE 1000 | ||
#define _APS_NEXT_SYMED_VALUE 110 | ||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#include <iostream> | ||
#include <fstream> | ||
#include <string> | ||
#include <vector> | ||
#include "json.hpp" // Include nlohmann::json | ||
|
||
using json = nlohmann::json; | ||
|
||
// Function to write data to a JSON file | ||
bool writeToJson(const std::vector<std::string> sliders) { | ||
try { | ||
json data; | ||
for (int i = 0; i < sliders.size(); i++) { | ||
data["slider"]["slider" + std::to_string(i + 1)] = sliders[i]; | ||
} | ||
|
||
std::ofstream outfile("config.txt"); | ||
if (outfile.is_open()) { | ||
outfile << data.dump(4); // Use dump(4) for pretty printing | ||
outfile.close(); | ||
std::cout << "Data written to " << "config.txt" << std::endl; | ||
return true; | ||
} | ||
else { | ||
std::cerr << "Error opening file for writing: " << "config.txt" << std::endl; | ||
return false; | ||
} | ||
} | ||
catch (json::exception& e) { | ||
std::cerr << "JSON exception: " << e.what() << std::endl; | ||
return false; | ||
} | ||
} | ||
|
||
// Function to read data from a JSON file | ||
std::vector<std::string> readFromJson() { | ||
std::vector<std::string> sliders; | ||
try { | ||
std::ifstream infile("config.txt"); | ||
if (infile.is_open()) { | ||
json data; | ||
infile >> data; | ||
infile.close(); | ||
|
||
if (data.contains("slider") && | ||
data["slider"].contains("slider1") && | ||
data["slider"].contains("slider2") && | ||
data["slider"].contains("slider3") && | ||
data["slider"].contains("slider4")) | ||
{ | ||
sliders.push_back(data["slider"]["slider1"].get<std::string>()); | ||
sliders.push_back(data["slider"]["slider2"].get<std::string>()); | ||
sliders.push_back(data["slider"]["slider3"].get<std::string>()); | ||
sliders.push_back(data["slider"]["slider4"].get<std::string>()); | ||
return sliders; | ||
} | ||
else { | ||
std::cerr << "Invalid JSON structure in " << "config.txt" << std::endl; | ||
return sliders; | ||
} | ||
} | ||
else { | ||
std::cerr << "Error opening file for reading: " << "config.txt" << std::endl; | ||
return sliders; | ||
} | ||
} | ||
catch (json::exception& e) { | ||
std::cerr << "JSON exception: " << e.what() << std::endl; | ||
return sliders; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
// Forward declaration of json (if you don't want to include json.hpp in the header) | ||
namespace nlohmann { | ||
class json; | ||
} | ||
|
||
// Function prototypes | ||
bool writeToJson(const std::vector<std::string> sliders); | ||
std::vector<std::string> readFromJson(); |
Oops, something went wrong.