mirror of
https://github.com/eclipse/upm.git
synced 2025-07-01 09:21:12 +03:00
LED: Added C Src and Example
Changed from Grove LED to LED. Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
This commit is contained in:
@ -87,7 +87,7 @@ link_directories (${MRAA_LIBDIR})
|
||||
# mq? will use module gas
|
||||
# grove* will use module grove
|
||||
add_example (hmc5883l)
|
||||
add_example (groveled)
|
||||
add_example (led)
|
||||
add_example (relay)
|
||||
add_example (light)
|
||||
add_example (temperature)
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "grove.hpp"
|
||||
#include "led.hpp"
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
@ -33,7 +33,7 @@ main(int argc, char **argv)
|
||||
//! [Interesting]
|
||||
|
||||
// Create the Grove LED object using GPIO pin 2
|
||||
upm::GroveLed* led = new upm::GroveLed(2);
|
||||
upm::Led* led = new upm::Led(2);
|
||||
|
||||
// Print the name
|
||||
std::cout << led->name() << std::endl;
|
@ -115,6 +115,7 @@ add_example (loudness)
|
||||
add_example (tsl2561)
|
||||
add_example (collision)
|
||||
add_example (moisture)
|
||||
add_example (led)
|
||||
|
||||
# Custom examples
|
||||
add_custom_example (nmea_gps_i2c-example-c nmea_gps_i2c.c nmea_gps)
|
||||
|
24
examples/c/led.c
Normal file
24
examples/c/led.c
Normal file
@ -0,0 +1,24 @@
|
||||
//Modified: Abhishek Malik <abhishek.malik@intel.com>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "led.h"
|
||||
|
||||
void main(void)
|
||||
{
|
||||
led_context dev = led_init(2);
|
||||
while(1){
|
||||
if(led_on(dev) != UPM_SUCCESS){
|
||||
printf("problem turning the LED on\n");
|
||||
}
|
||||
upm_delay(1);
|
||||
if(led_off(dev) != UPM_SUCCESS){
|
||||
printf("problem turning the LED off\n");
|
||||
}
|
||||
upm_delay(1);
|
||||
}
|
||||
led_close(dev);
|
||||
}
|
@ -37,7 +37,7 @@ add_example(GroveEHRSample groveehr)
|
||||
add_example(Emg emg)
|
||||
add_example(Gsr gsr)
|
||||
add_example(GroveLed_multiSample grove)
|
||||
add_example(GroveLEDSample grove)
|
||||
add_example(LEDSample led)
|
||||
add_example(LightSample light)
|
||||
add_example(GroveLineFinderSample grovelinefinder)
|
||||
add_example(GroveMDSample grovemd)
|
||||
|
@ -22,10 +22,10 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class GroveLEDSample {
|
||||
public class LEDSample {
|
||||
public static void main (String args[]) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
upm_grove.GroveLed led = new upm_grove.GroveLed(2);
|
||||
upm_led.Led led = new upm_led.Led(2);
|
||||
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
led.on();
|
@ -23,10 +23,10 @@
|
||||
*/
|
||||
|
||||
// Load Grove module
|
||||
var groveSensor = require('jsupm_grove');
|
||||
var ledSensor = require('jsupm_led');
|
||||
|
||||
// Create the Grove LED object using GPIO pin 2
|
||||
var led = new groveSensor.GroveLed(2);
|
||||
var led = new ledSensor.Led(2);
|
||||
|
||||
// Print the name
|
||||
console.log(led.name());
|
@ -21,10 +21,10 @@
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time
|
||||
import pyupm_grove as grove
|
||||
import pyupm_led as led
|
||||
|
||||
# Create the Grove LED object using GPIO pin 2
|
||||
led = grove.GroveLed(2)
|
||||
led = led.Led(2)
|
||||
|
||||
# Print the name
|
||||
print led.name()
|
Reference in New Issue
Block a user