Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Jason Kridner (Beagleboard.org Archive)
Published

easyBlack C++ Library

(Arduino Style) Beaglebone Black C++ Library for GPIO using high performance of mmap.

423
easyBlack C++ Library

Things used in this project

Story

Read more

Code

Code snippet #2

Plain text
#include "memGPIO.hpp"

const int REPEATS = 10;
const int DELAY = 250000;

int main () {
  // Make a instance.
  easyBlack::memGPIO myExample;

  // Get PINs data for better performance.
  easyBlack::memGPIO::gpioPin usr0 = myExample.getPin ("USR0");

  // Get PIN direction for better performance.
  const unsigned char output = myExample.OUTPUT;

  // Get PIN values for better performance.
  const unsigned char low = myExample.LOW;
  const unsigned char high = myExample.HIGH;

  // Set pin mode.
  myExample.pinMode (usr0, output);

  for (int x = 0; x < REPEATS; x++) {
    // Turn USR0 LED on.
    myExample.digitalWrite (usr0, high);

    usleep (DELAY);

    // Turn USR0 LED off.
    myExample.digitalWrite (usr0, low);

    usleep (DELAY);
  }

  // Reset USR0 LED trigger to default.
  myExample.resetLEDPin0ToDefault ();

  // Call the destructor.
  myExample.~memGPIO ();

  exit (EXIT_SUCCESS);
}

Github file

https://github.com/facine/easyBlack#example

Credits

manu

Comments