NAME

Device::BCM2835::NES - Perl extension for interfacing with a NES controller from the Raspberry Pi's GPIO ports.

SYNOPSIS

  # Sample Program (NOTE: MUST RUN VIA SUDO)

  use Device::BCM2835::NES;
  use strict;

  # Instantiate object
  my $nes = Device::BCM2835::NES->new();

  # Add controller at pin 21
  $nes->addController(Device::BCM2835::NES::RPI_GPIO_P1_13);

  # Initialize libraries / GPIO pins
  $nes->init();

  # Read contrller data
  while(1) {
	# Get raw data for all controllers
	my @raw = $nes->read();

	# Translate raw data into text (e.g SELECT, START)
	foreach $c (@raw) {
		my @btns = $nes->translateButtons($c);
		print join(' ',@btns);
	}

	# Cycle - NES Reads controller data at 60Hz
	$nes->cycle();
  }

DESCRIPTION

METHODS

new(['latch' => $latch, 'clock' => $clock])

Instantiates new object and optionlly sets pins for CLOCK and LATCH pins.

Defaults:
	LATCH - Device::BCM2835::NES::RPI_GPIO_P1_11
	CLOCK - Device::BCM2835::NES::RPI_GPIO_P1_12

init()

Initialize BCM2835 libraries then clear latch and clock pins. 

addController($data_pin)

Adds a controller from which to read data.

read()

Gets raw data from each of the controllers and returns them in an array.    

translateButtons($btn_data)

Translate raw button data into text (e.g. 'A', 'SELECT')  

cycle([$time])

Delay between reads. NES polls at 60Hz by default.

SEE ALSO

http://search.cpan.org/~mikem/Device-BCM2835-1.3/lib/Device/BCM2835.pm http://www.mit.edu/~tarvizo/nes-controller.html

AUTHOR

Chris Kloberdanz, <klobyone at gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2012 by Chris Kloberdanz

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available.