Skip to content

Commit

Permalink
Merge branch 'kernel-update-ckt10'
Browse files Browse the repository at this point in the history
  • Loading branch information
ddemidov committed Jun 21, 2016
2 parents 7e84d91 + 6449498 commit bb1f70c
Show file tree
Hide file tree
Showing 6 changed files with 203 additions and 220 deletions.
65 changes: 26 additions & 39 deletions demos/ev3dev-lang-demo.cpp
Expand Up @@ -178,13 +178,8 @@ void motor_action(motor &dev)
<< endl
<< "(i)nfo" << endl
<< "(c)ommand" << endl
<< "st(o)p command [" << dev.stop_command() << "]" << endl
<< "speed r(e)gulation [" << dev.speed_regulation_enabled() << "]" << endl;

if (dev.speed_regulation_enabled()==dev.speed_regulation_on)
cout << "speed (s)etpoint (" << dev.speed_sp() << ")" << endl;
else
cout << "duty cycle (s)etpoint (" << dev.duty_cycle_sp() << ")" << endl;
<< "st(o)p command [" << dev.stop_action() << "]" << endl
<< "speed (s)etpoint (" << dev.speed_sp() << ")" << endl;

cout << "(p)osition setpoint (" << dev.position_sp() << ")" << endl
<< "ramp (u)p setpoint (" << dev.ramp_up_sp() << ")" << endl
Expand All @@ -204,12 +199,18 @@ void motor_action(motor &dev)
cout << endl;
//~autogen generic_report_status classes.motor>currentClass

cout << " Address: ";
try { cout << dev.address() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Commands: ";
try { cout << dev.commands() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Count Per Rot: ";
try { cout << dev.count_per_rot() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Count Per M: ";
try { cout << dev.count_per_m() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Driver Name: ";
try { cout << dev.driver_name() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
Expand All @@ -219,15 +220,12 @@ void motor_action(motor &dev)
cout << " Duty Cycle SP: ";
try { cout << dev.duty_cycle_sp() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Encoder Polarity: ";
try { cout << dev.encoder_polarity() << endl; }
cout << " Full Travel Count: ";
try { cout << dev.full_travel_count() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Polarity: ";
try { cout << dev.polarity() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Address: ";
try { cout << dev.address() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Position: ";
try { cout << dev.position() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
Expand All @@ -243,6 +241,9 @@ void motor_action(motor &dev)
cout << " Position SP: ";
try { cout << dev.position_sp() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Max Speed: ";
try { cout << dev.max_speed() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Speed: ";
try { cout << dev.speed() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
Expand All @@ -255,26 +256,23 @@ void motor_action(motor &dev)
cout << " Ramp Down SP: ";
try { cout << dev.ramp_down_sp() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Speed Regulation Enabled: ";
try { cout << dev.speed_regulation_enabled() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Speed Regulation P: ";
try { cout << dev.speed_regulation_p() << endl; }
cout << " Speed P: ";
try { cout << dev.speed_p() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Speed Regulation I: ";
try { cout << dev.speed_regulation_i() << endl; }
cout << " Speed I: ";
try { cout << dev.speed_i() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Speed Regulation D: ";
try { cout << dev.speed_regulation_d() << endl; }
cout << " Speed D: ";
try { cout << dev.speed_d() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " State: ";
try { cout << dev.state() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Stop Command: ";
try { cout << dev.stop_command() << endl; }
cout << " Stop Action: ";
try { cout << dev.stop_action() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Stop Commands: ";
try { cout << dev.stop_commands() << endl; }
cout << " Stop Actions: ";
try { cout << dev.stop_actions() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Time SP: ";
try { cout << dev.time_sp() << endl; }
Expand All @@ -289,22 +287,11 @@ void motor_action(motor &dev)
cin >> answer; dev.set_command(answer); cout << endl;
break;
case 'o':
cout << "stop command " << dev.stop_commands() << ": ";
cin >> answer; dev.set_stop_command(answer); cout << endl;
break;
case 'e':
cout << "speed regulation (off, on): ";
cin >> answer; dev.set_speed_regulation_enabled(answer); cout << endl;
cout << "stop command " << dev.stop_actions() << ": ";
cin >> answer; dev.set_stop_action(answer); cout << endl;
break;
case 's':
if (dev.speed_regulation_enabled()==dev.speed_regulation_on)
{
cout << "speed: "; cin >> new_value; dev.set_speed_sp(new_value); cout << endl;
}
else
{
cout << "duty cycle: "; cin >> new_value; dev.set_duty_cycle_sp(new_value); cout << endl;
}
cout << "speed: "; cin >> new_value; dev.set_speed_sp(new_value); cout << endl;
break;
case 'p':
cout << "position: "; cin >> new_value; dev.set_position_sp(new_value); cout << endl;
Expand Down
63 changes: 33 additions & 30 deletions demos/ev3dev-lang-test.cpp
Expand Up @@ -22,7 +22,7 @@
//-----------------------------------------------------------------------------
//~autogen autogen-header

// Sections of the following code were auto-generated based on spec v0.9.3-pre, rev 2.
// Sections of the following code were auto-generated based on spec v1.2.0.

//~autogen
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -55,6 +55,9 @@ void test_sensor(const char *name)
<< " Current properties are:" << endl;
//~autogen generic_report_status classes.sensor>currentClass

cout << " Address: ";
try { cout << dev.address() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Commands: ";
try { cout << dev.commands() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
Expand All @@ -73,9 +76,6 @@ void test_sensor(const char *name)
cout << " Num Values: ";
try { cout << dev.num_values() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Address: ";
try { cout << dev.address() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Units: ";
try { cout << dev.units() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
Expand All @@ -99,12 +99,18 @@ void test_motor(const char *name)
<< " Current properties are:" << endl;
//~autogen generic_report_status classes.motor>currentClass

cout << " Address: ";
try { cout << dev.address() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Commands: ";
try { cout << dev.commands() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Count Per Rot: ";
try { cout << dev.count_per_rot() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Count Per M: ";
try { cout << dev.count_per_m() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Driver Name: ";
try { cout << dev.driver_name() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
Expand All @@ -114,15 +120,12 @@ void test_motor(const char *name)
cout << " Duty Cycle SP: ";
try { cout << dev.duty_cycle_sp() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Encoder Polarity: ";
try { cout << dev.encoder_polarity() << endl; }
cout << " Full Travel Count: ";
try { cout << dev.full_travel_count() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Polarity: ";
try { cout << dev.polarity() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Address: ";
try { cout << dev.address() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Position: ";
try { cout << dev.position() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
Expand All @@ -138,6 +141,9 @@ void test_motor(const char *name)
cout << " Position SP: ";
try { cout << dev.position_sp() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Max Speed: ";
try { cout << dev.max_speed() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Speed: ";
try { cout << dev.speed() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
Expand All @@ -150,26 +156,23 @@ void test_motor(const char *name)
cout << " Ramp Down SP: ";
try { cout << dev.ramp_down_sp() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Speed Regulation Enabled: ";
try { cout << dev.speed_regulation_enabled() << endl; }
cout << " Speed P: ";
try { cout << dev.speed_p() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Speed Regulation P: ";
try { cout << dev.speed_regulation_p() << endl; }
cout << " Speed I: ";
try { cout << dev.speed_i() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Speed Regulation I: ";
try { cout << dev.speed_regulation_i() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Speed Regulation D: ";
try { cout << dev.speed_regulation_d() << endl; }
cout << " Speed D: ";
try { cout << dev.speed_d() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " State: ";
try { cout << dev.state() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Stop Command: ";
try { cout << dev.stop_command() << endl; }
cout << " Stop Action: ";
try { cout << dev.stop_action() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Stop Commands: ";
try { cout << dev.stop_commands() << endl; }
cout << " Stop Actions: ";
try { cout << dev.stop_actions() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Time SP: ";
try { cout << dev.time_sp() << endl; }
Expand All @@ -193,6 +196,9 @@ void test_dc_motor()
<< " Current properties are:" << endl;
//~autogen generic_report_status classes.dcMotor>currentClass

cout << " Address: ";
try { cout << dev.address() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Commands: ";
try { cout << dev.commands() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
Expand All @@ -208,9 +214,6 @@ void test_dc_motor()
cout << " Polarity: ";
try { cout << dev.polarity() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Address: ";
try { cout << dev.address() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Ramp Down SP: ";
try { cout << dev.ramp_down_sp() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
Expand All @@ -220,8 +223,8 @@ void test_dc_motor()
cout << " State: ";
try { cout << dev.state() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Stop Commands: ";
try { cout << dev.stop_commands() << endl; }
cout << " Stop Actions: ";
try { cout << dev.stop_actions() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Time SP: ";
try { cout << dev.time_sp() << endl; }
Expand All @@ -245,6 +248,9 @@ void test_servo_motor()
<< " Current properties are:" << endl;
//~autogen generic_report_status classes.servoMotor>currentClass

cout << " Address: ";
try { cout << dev.address() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Driver Name: ";
try { cout << dev.driver_name() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
Expand All @@ -260,9 +266,6 @@ void test_servo_motor()
cout << " Polarity: ";
try { cout << dev.polarity() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Address: ";
try { cout << dev.address() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
cout << " Position SP: ";
try { cout << dev.position_sp() << endl; }
catch(...) { cout << "[" << strerror(errno) << "]" << endl; }
Expand Down
6 changes: 3 additions & 3 deletions demos/remote-control.cpp
Expand Up @@ -50,7 +50,7 @@ std::function<void(bool)> roll(Motor &motor, Leds &leds, int dir) {
motor.set_duty_cycle_sp(90 * dir).run_forever();
ev3::led::set_color(leds, dir > 0 ? ev3::led::green : ev3::led::red);
} else {
motor.set_stop_command("brake").stop();
motor.set_stop_action("brake").stop();
for(auto led : leds) led->off();
}
};
Expand Down Expand Up @@ -81,8 +81,8 @@ int main() {
if (ts.is_pressed()) {
ev3::sound::speak("Oops, excuse me!");

lmotor.set_stop_command("brake").stop();
rmotor.set_stop_command("brake").stop();
lmotor.set_stop_action("brake").stop();
rmotor.set_stop_action("brake").stop();

// Turn red lights on
ev3::led::set_color(ev3::led::left, ev3::led::red);
Expand Down
22 changes: 11 additions & 11 deletions ev3dev.cpp
Expand Up @@ -26,7 +26,7 @@
//-----------------------------------------------------------------------------
//~autogen autogen-header

// Sections of the following code were auto-generated based on spec v0.9.3-pre, rev 2.
// Sections of the following code were auto-generated based on spec v1.2.0.

//~autogen
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -751,11 +751,9 @@ const std::string motor::encoder_polarity_normal{ "normal" };
const std::string motor::encoder_polarity_inversed{ "inversed" };
const std::string motor::polarity_normal{ "normal" };
const std::string motor::polarity_inversed{ "inversed" };
const std::string motor::speed_regulation_on{ "on" };
const std::string motor::speed_regulation_off{ "off" };
const std::string motor::stop_command_coast{ "coast" };
const std::string motor::stop_command_brake{ "brake" };
const std::string motor::stop_command_hold{ "hold" };
const std::string motor::stop_action_coast{ "coast" };
const std::string motor::stop_action_brake{ "brake" };
const std::string motor::stop_action_hold{ "hold" };

//~autogen

Expand Down Expand Up @@ -821,8 +819,8 @@ const std::string dc_motor::command_run_direct{ "run-direct" };
const std::string dc_motor::command_stop{ "stop" };
const std::string dc_motor::polarity_normal{ "normal" };
const std::string dc_motor::polarity_inversed{ "inversed" };
const std::string dc_motor::stop_command_coast{ "coast" };
const std::string dc_motor::stop_command_brake{ "brake" };
const std::string dc_motor::stop_action_coast{ "coast" };
const std::string dc_motor::stop_action_brake{ "brake" };

//~autogen

Expand Down Expand Up @@ -882,12 +880,13 @@ void led::flash(unsigned on_ms, unsigned off_ms)
#ifdef EV3DEV_PLATFORM_BRICKPI
//~autogen leds-define platforms.brickpi.led>currentClass

led led::blue_led1{"brickpi1:blue:ev3dev"};
led led::blue_led2{"brickpi2:blue:ev3dev"};
led led::blue_led1{"brickpi:led1:blue:ev3dev"};
led led::blue_led2{"brickpi:led2:blue:ev3dev"};

std::vector<led*> led::led1{ &led::blue_led1 };
std::vector<led*> led::led2{ &led::blue_led2 };

std::vector<float> led::black{ static_cast<float>(0) };
std::vector<float> led::blue{ static_cast<float>(1) };

//-----------------------------------------------------------------------------
Expand All @@ -910,11 +909,12 @@ led led::green_right{"ev3:right:green:ev3dev"};
std::vector<led*> led::left{ &led::red_left, &led::green_left };
std::vector<led*> led::right{ &led::red_right, &led::green_right };

std::vector<float> led::black{ static_cast<float>(0), static_cast<float>(0) };
std::vector<float> led::red{ static_cast<float>(1), static_cast<float>(0) };
std::vector<float> led::green{ static_cast<float>(0), static_cast<float>(1) };
std::vector<float> led::amber{ static_cast<float>(1), static_cast<float>(1) };
std::vector<float> led::orange{ static_cast<float>(1), static_cast<float>(0.5) };
std::vector<float> led::yellow{ static_cast<float>(0.5), static_cast<float>(1) };
std::vector<float> led::yellow{ static_cast<float>(0.1), static_cast<float>(1) };

//-----------------------------------------------------------------------------
void led::all_off() {
Expand Down

0 comments on commit bb1f70c

Please sign in to comment.