Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@ target_link_libraries(iris PUBLIC ${LINK_LIBS})
#######################################
# tools

set(lpm_SOURCES tools/lpm.cc)
add_executable(lpm ${lpm_SOURCES})
target_link_libraries(lpm iris)

set(LEDPhotoSpectrum_SOURCES tools/LEDPhotoSpectrum.cc)
add_executable(iris-LEDPhotoSpectrum ${LEDPhotoSpectrum_SOURCES})
target_link_libraries(iris-LEDPhotoSpectrum iris)

set(ledPWMthresholder_SOURCES tools/ledPWMthresholder.cc)
add_executable(iris-ledPWMthresholder ${ledPWMthresholder_SOURCES})
target_link_libraries(iris-ledPWMthresholder iris)

set(pr655_SOURCES tools/pr655.cc)
add_executable(pr655 ${pr655_SOURCES})
target_link_libraries(pr655 iris)
Expand Down
45 changes: 45 additions & 0 deletions lib/data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,51 @@ display store::make_display(const monitor &monitor,
return dsp;
}

std::map<uint8_t, uint16_t> store::lpm_leds() const {

std::map<uint8_t, uint16_t> lpm_led_map;

fs::file valuesFile = base.child("lpm/pwmLed");
std::string data = valuesFile.read_all();
YAML::Node root = YAML::Load(data);

YAML::Node led_node = root["leds"];

for(YAML::const_iterator it = led_node.begin(); it != led_node.end(); it++) {
std::string pin_no = it->first.as<std::string>();
std::string led_wavelength = it->second.as<std::string>();

uint8_t pin_int = std::stoi(pin_no);
uint16_t pwm_val_int = std::stoi(led_wavelength);

lpm_led_map.insert( std::pair<uint8_t ,uint16_t >(pin_int, pwm_val_int) );
}

return lpm_led_map;
}

std::map<uint16_t, uint16_t> store::lpm_pwm() const {

std::map<uint16_t, uint16_t>lpm_led_map;

fs::file valuesFile = base.child("lpm/pwm");
std::string data = valuesFile.read_all();
YAML::Node root = YAML::Load(data);

YAML::Node led_node = root["pwm"];

for(YAML::const_iterator it = led_node.begin(); it != led_node.end(); it++) {
std::string wavelength = it->first.as<std::string>();
std::string led_pwm = it->second.as<std::string>();

uint16_t wavelength_int = std::stoi(wavelength);
uint16_t led_pwm_int = std::stoi(led_pwm);

lpm_led_map.insert( std::pair<uint16_t ,uint16_t >(wavelength_int, led_pwm_int) );
}

return lpm_led_map;
}


// yaml stuff
Expand Down
9 changes: 7 additions & 2 deletions lib/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <dkl.h>
#include <fs.h>
#include <spectra.h>

#include <map>

namespace iris {
namespace data {
Expand Down Expand Up @@ -123,7 +123,6 @@ struct isoslant : entity {
std::string rgb2lms;
};


///

/* store dir layout:
Expand Down Expand Up @@ -165,6 +164,12 @@ class store {
// cone fundamentals for calibration
fs::file cone_fundamentals(size_t spacing = 4) const;

// the led mapping for the led pseudo monochromator
std::map<uint8_t, uint16_t> lpm_leds() const;

// the pwm mapping for the led pseudo monochromator
std::map<uint16_t, uint16_t> lpm_pwm() const;

// yaml config IO

static monitor yaml2monitor(const std::string &data);
Expand Down
71 changes: 71 additions & 0 deletions lib/lpm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#include <serial.h>


namespace device {


class lpm {

public:

device::serial io;

lpm(const device::serial &io) : io(io) { }

static lpm open(const std::string &path) {
lpm lpm(serial::open(path));
return lpm;
}

void setPWM(std::string cmd) {
io.send_data(cmd);
}

void getInfo() {
io.send_data("info");
}

void reset() {
io.send_data("reset");
}

void shoot() {
io.send_data("shoot");
}

int isCommandPWM(std::string cmd) {
std::string pwmCmd = "pwm";
return cmd.compare(0, pwmCmd.length(), pwmCmd);
}

int isCommandInfo(std::string cmd) {
std::string infoCmd = "info";
return cmd.compare(0, infoCmd.length(), infoCmd);
}

int isCommandReset(std::string cmd) {
std::string resetCmd = "reset";
return cmd.compare(0, resetCmd.length(), resetCmd);
}

int isCommandShoot(std::string cmd) {
std::string shootCmd = "shoot";
return cmd.compare(0, shootCmd.length(), shootCmd);
}

void receiveArduinoOutput() {

while(1) {
std::string data = io.recv_line(1000);
std::cout << data << std::endl;

if(data == std::string("*")) {
break;
}
}
}

};


}
2 changes: 1 addition & 1 deletion lib/serial.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ std::string serial::recv_line(sleeper::rep read_timeout) {
}

if (!timeout.maybe_sleep(nread == 0)) {
throw std::runtime_error("w failed: timeout");
throw std::runtime_error("r failed: timeout");
}

} while (ch != '\n');
Expand Down
4 changes: 4 additions & 0 deletions lib/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ class serial {
std::this_thread::sleep_for(dura);
}

int printfd() {
return fd;
}

private:
int fd;
};
Expand Down
Loading