I am not sure much about Node.js. But like to try something with node.js in Raspberry pi. Here is installation steps for Node.js.
Node.js is a cross-platform runtime environment and a library for running applications written in JavaScript outside the browser (for example, on the server).
Node.js applications are designed to maximize throughput and efficiency, using non-blocking I/O and asynchronous events. Node.js applications run single-threaded, although Node.js uses multiple threads for file and network events.Internally, it uses the Google V8 JavaScript engine to execute code, and a large percentage of the basic modules are written in JavaScript.
Node.js was created by Ryan Dahl starting in 2009. Its development and maintenance is sponsored by Joyent.
Installation Steps for Node.js in Raspberry Pi
1. sudo apt-get upgrade
2. sudo apt-get update
Install Node and NPM
wget http://nodejs.org/dist/v0.10.2/node-v0.10.2-linux-arm-pi.tar.gz
tar -xvzf node-v0.10.2-linux-arm-pi.tar.gz
set the path variable as the bin directory
PATH=$PATH:/home/pi/node-v0.10.2-linux-arm-pi/bin
after the setting the path variable , try the command in command line
npm - -version
in order to work on native modules , we need to install node-gyp
check whether gcc is installed or not ?
gcc --version
install Native
npm install -g node-gyp
Monday, August 4, 2014
Sunday, August 3, 2014
X,Y coordinates in Joystick in Pygame
Co-ordinates can be controlled easily with pygame joystick get_axis function.
joystick.get_axis(0) returns the 'x' axis position, at the same time
joystick.get_axis(1) returns the y axis position of the joystick. You can add to you rectangle image coordinates with the above values to make movement to the image in X,Y axis.
# get the rectangle the image occupies
# rec(x, y, w, h)
start_rect = image.get_rect()
image_rect = start_rect
.....
.....
.....
hor_x = joystick.get_axis(0)
hor_y = joystick.get_axis(1)
image_rect.left = image_rect.left+ hor_x * 2
image_rect.top = image_rect.top+ hor_y * 2
joystick.get_axis(0) returns the 'x' axis position, at the same time
joystick.get_axis(1) returns the y axis position of the joystick. You can add to you rectangle image coordinates with the above values to make movement to the image in X,Y axis.
# get the rectangle the image occupies
# rec(x, y, w, h)
start_rect = image.get_rect()
image_rect = start_rect
.....
.....
.....
hor_x = joystick.get_axis(0)
hor_y = joystick.get_axis(1)
image_rect.left = image_rect.left+ hor_x * 2
image_rect.top = image_rect.top+ hor_y * 2
Joystick Axis control with Pygame
Raspberry Pi joystick Pygames
As blogged before the screen image position controlling with joystick button are done. The good thing about electronic devices are that there will be many more things to explore further .Joy stick works as coordinates of the axis when we move it. Looks like its values moves from 1.0 to -1.0 . I am interested to control the screen image with this axis rather than buttons in the joystick.
Looking further on the documentation in Pygame - http://www.pygame.org/docs/ref/joystick.html
The axis number must be an integer from zero to get_numaxes()-1.
As blogged before the screen image position controlling with joystick button are done. The good thing about electronic devices are that there will be many more things to explore further .Joy stick works as coordinates of the axis when we move it. Looks like its values moves from 1.0 to -1.0 . I am interested to control the screen image with this axis rather than buttons in the joystick.
Looking further on the documentation in Pygame - http://www.pygame.org/docs/ref/joystick.html
- get_axis()
- get the current position of an axis
- get_axis(axis_number) -> float
The axis number must be an integer from zero to get_numaxes()-1.