Skip to content

Commit

Permalink
Use FIX2INT() for converting C/C++ values to Ruby
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Scott committed Jun 12, 2017
1 parent c388519 commit d19a723
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 176 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/tubbo/

## License

The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
This Ruby gem is available as open source under the terms of the [MIT
License](http://opensource.org/licenses/MIT). The GrovePi C++ code is
Copyright (C) 2017 Dexter Industries.

## Code of Conduct

Expand Down
170 changes: 0 additions & 170 deletions ext/grovepi/README.md

This file was deleted.

10 changes: 5 additions & 5 deletions ext/grovepi/grovepi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,23 +420,23 @@ const char* GrovePi::I2CError::detail()
// TODO: how to convert VALUE -> uint8_t || VALUE -> bool?
namespace GrovePiRuby {
static void digitalWrite(VALUE pin, VALUE data) {
GrovePi::digitalWrite(pin, data);
GrovePi::digitalWrite(FIX2INT(pin), data);
}

static VALUE digitalRead(VALUE pin) {
return rb_str_new2(GrovePi::digitalRead(pin));
return rb_str_new2(GrovePi::digitalRead(FIX2INT(pin)));
}

static void analogWrite(VALUE pin, VALUE data) {
return GrovePi::analogWrite(pin, data);
return GrovePi::analogWrite(FIX2INT(pin), data);
}

static VALUE analogRead(VALUE pin) {
return rb_str_new2(GrovePi::analogRead(pin));
return rb_str_new2(GrovePi::analogRead(FIX2INT(pin)));
}

static VALUE ultrasonicRead(VALUE pin) {
return rb_str_new2(GrovePi::ultrasonicRead(pin));
return rb_str_new2(GrovePi::ultrasonicRead(FIX2INT(pin)));
}
}

Expand Down

0 comments on commit d19a723

Please sign in to comment.