-
Notifications
You must be signed in to change notification settings - Fork 0
/
cfg.cc
63 lines (42 loc) · 1.69 KB
/
cfg.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
// Created by Christian Kellner on 06/11/15.
//
#include "cfg.h"
#include <yaml-cpp/yaml.h>
namespace lpm {
lpm::cfg lpm::cfg::default_cfg() {
return lpm::cfg(iris::data::store::default_store());
}
std::map<uint8_t, uint16_t> cfg::lpm_leds() const {
std::map<uint8_t, uint16_t> lpm_led_map;
const fs::file base = store.location();
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> cfg::lpm_pwm() const {
std::map<uint16_t, uint16_t>lpm_led_map;
const fs::file base = store.location();
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;
}
} // lpm::