Browse Source

Implemented all features for now

feature/build_system
Maximilian Stiefel 3 years ago
parent
commit
42f290209e
  1. 12
      hal/stepper.cpp
  2. 3
      include/stepper.h
  3. 32
      main.cpp
  4. 2
      settings.json

12
hal/stepper.cpp

@ -17,13 +17,13 @@ namespace simon {
// TODO: Throw exception
}
extract_settings(j_set, axis);
m_thread = std::thread(std::bind(&a4988::c_allegro_4988::run, &(*m_ptr_a4988)));
for (int i=0; i<10; i++) {
rotate(90);
rotate(-90);
}
m_driver_thread = std::thread(std::bind(&a4988::c_allegro_4988::run, &(*m_ptr_a4988)));
}
c_stepper::~c_stepper()
{
m_ptr_a4988->kill();
m_thread.join();
m_driver_thread.join();
}
void c_stepper::extract_settings(const json& j_set, const std::string& axis)

3
include/stepper.h

@ -20,11 +20,12 @@ namespace simon {
{
public:
c_stepper(const std::string& axis, const std::string& fname);
~c_stepper();
float rotate(const float& degrees);
private:
settings_t m_stepper;
std::unique_ptr<a4988::c_allegro_4988> m_ptr_a4988;
std::thread m_thread;
std::thread m_driver_thread;
private:
std::string read_file(const std::string& fname) const;
void extract_settings(const json& j_set, const std::string& axis);

32
main.cpp

@ -1,28 +1,38 @@
#include <iostream>
#include <include/stepper.h>
#include <boost/program_options.hpp>
int main(int argc, char *argv[])
{
using namespace simon;
namespace po = boost::program_options;
po::options_description desc("Allowed options");
po::options_description desc("This small program allows to control SMcam. Allowed options");
desc.add_options()
("help", "produce help message")
("compression", po::value<int>(), "set compression level");
("help", "Produce help message")
("axis", po::value<std::string>(), "Name of the axis to rotate")
("settings", po::value<std::string>(), "Settings file name")
("rotate", po::value<int>(), "Rotation in degrees. Positive means clockwise.");
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
if (vm.count("help")) {
std::cout << desc << "\n";
return 1;
return EXIT_FAILURE;
}
if (vm.count("compression")) {
std::cout << "Compression level was set to "
<< vm["compression"].as<int>() << ".\n";
stepper::c_stepper* ptr_stepper = nullptr;
if (vm.count("axis") && vm.count("settings")) {
auto axis = vm["axis"].as<std::string>();
auto fname_settings = vm["settings"].as<std::string>();
ptr_stepper = new stepper::c_stepper(axis, fname_settings);
if (vm.count("rotate")) {
auto degrees = vm["rotate"].as<int>();
ptr_stepper->rotate(degrees);
}
} else {
std::cout << "Compression level was not set.\n";
std::cerr << "Please specify axis and settings file.\n";
return EXIT_FAILURE;
}
stepper::c_stepper("azimuth", "settings.json");
std::cout << "Hello camera :*" << std::endl;
return 0;
if (ptr_stepper != nullptr)
delete ptr_stepper;
return EXIT_SUCCESS;
}

2
settings.json

@ -12,7 +12,7 @@
"gpio_en": 17,
"gpio_step": 18
},
"id": "azimuth"
"id": "elevation"
}
]
}

Loading…
Cancel
Save