format, str, contrast, saturation, brihtness, speed

This commit is contained in:
2021-10-15 18:51:03 +02:00
parent 790dcd2259
commit 4ea8ce944f

View File

@@ -30,6 +30,7 @@
#include <boost/algorithm/string/split.hpp> #include <boost/algorithm/string/split.hpp>
#include <boost/program_options.hpp> #include <boost/program_options.hpp>
#include <boost/format.hpp>
#include "TimeoutSerial.h" #include "TimeoutSerial.h"
#include "YmodemFileReceive.h" #include "YmodemFileReceive.h"
@@ -38,6 +39,7 @@
using namespace std; using namespace std;
using namespace boost; using namespace boost;
using boost::format;
namespace po = boost::program_options; namespace po = boost::program_options;
typedef vector< string > split_vector_type; typedef vector< string > split_vector_type;
@@ -112,7 +114,7 @@ int main(int argc, char* argv[])
float pressure = NAN; float pressure = NAN;
po::variables_map vm; po::variables_map vm;
std::string port,path,filename; std::string port,path,filename;
int speed; int speed,brightness,saturation,contrast;
po::options_description desc("Allowed options"); po::options_description desc("Allowed options");
desc.add_options() desc.add_options()
@@ -124,7 +126,10 @@ int main(int argc, char* argv[])
("path", po::value<string>(&path)->default_value("/tmp"),"directory for file of capture") ("path", po::value<string>(&path)->default_value("/tmp"),"directory for file of capture")
("capture", "capture photo of camera") ("capture", "capture photo of camera")
("port", po::value<string>(&port)->default_value("/dev/ttyUSB0"), "port to read from") ("port", po::value<string>(&port)->default_value("/dev/ttyUSB0"), "port to read from")
("speed", po::value<int>(&speed)->default_value(115200), "speed read from port") ("speed", po::value<int>(&speed)->default_value(460800), "speed read from port")
("brightness", po::value<int>(&brightness)->default_value(0), "set brightness")
("saturation", po::value<int>(&saturation)->default_value(0), "set saturation")
("contrast", po::value<int>(&contrast)->default_value(0), "set contrast")
("temperature", "get and print temprature") ("temperature", "get and print temprature")
("humidity", "get and print humidity") ("humidity", "get and print humidity")
("pressure", "get and print pressure") ("pressure", "get and print pressure")
@@ -229,7 +234,22 @@ int main(int argc, char* argv[])
return 0; return 0;
} }
if (vm.count("brightness")) {
serial.writeString(str(format("bright %d\r\n") % brightness));
}
if (vm.count("saturation")) {
serial.writeString(str(format("satur %d\r\n") % saturation));
}
if (vm.count("contrast")) {
serial.writeString(str(format("contr %d\r\n") % contrast));
}
if (vm.count("capture")) { if (vm.count("capture")) {
serial.writeString("capture\r\n"); serial.writeString("capture\r\n");
boost::this_thread::sleep(posix_time::milliseconds(100)); boost::this_thread::sleep(posix_time::milliseconds(100));