-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
307 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
var pitft = require("../pitft"); | ||
|
||
var fb = new pitft.FrameBuffer("/dev/fb1"); | ||
fb.clear(); | ||
|
||
var xMax = fb.size().width; | ||
var yMax = fb.size().height; | ||
|
||
fb.image(x, y, "raspberry-pi.png"); | ||
|
||
for (var n=0; n<1000; n++) { | ||
var x = Math.random() * (xMax + 32) - 16; | ||
var y = Math.random() * (yMax + 32) - 16; | ||
|
||
fb.image(x, y, "raspberry-pi-icon.png"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,70 @@ | ||
var pitft = require("../pitft"); | ||
|
||
var fb = new pitft.FrameBuffer("/dev/fb1"); | ||
|
||
var fb = new pitft.FrameBuffer("/dev/fb1", true); | ||
fb.clear(); | ||
|
||
var rad = 180 / Math.PI; | ||
|
||
var xMax = fb.size().width; | ||
var yMax = fb.size().height; | ||
var rad = 180/Math.PI; | ||
|
||
fb.color(1, 1, 1); | ||
fb.circle(xMax / 2, yMax / 2, 100); | ||
|
||
fb.color(0, 0, 0); | ||
for (var a=0; a<360; a+=30) { | ||
var x0 = xMax / 2 + Math.sin(a / rad) * 85; | ||
var y0 = yMax / 2 + Math.cos(a / rad) * 85; | ||
var hand = function(_fb, x, y, angle, length, width) { | ||
var x0 = xMax/2 + Math.sin(angle/rad); | ||
var y0 = yMax/2 - Math.cos(angle/rad); | ||
|
||
var x1 = xMax / 2 + Math.sin(a / rad) * 95; | ||
var y1 = yMax / 2 + Math.cos(a / rad) * 95; | ||
var x1 = xMax/2 + Math.sin(angle/rad) * length; | ||
var y1 = yMax/2 - Math.cos(angle/rad) * length; | ||
|
||
fb.line(x0, y0, x1, y1, 5); | ||
fb.line(x0, y0, x1, y1, width); | ||
} | ||
|
||
fb.color(1, 0, 0); | ||
|
||
var a, x0, y0, x1, y1; | ||
|
||
a = 10 / 12 * 360; | ||
|
||
x0 = xMax / 2 - Math.sin(a / rad); | ||
y0 = yMax / 2 - Math.cos(a / rad); | ||
|
||
x1 = xMax / 2 - Math.sin(a / rad) * 50; | ||
y1 = yMax / 2 - Math.cos(a / rad) * 50; | ||
|
||
fb.line(x0, y0, x1, y1, 5); | ||
|
||
a = 2 / 12 * 360; | ||
|
||
x0 = xMax / 2 - Math.sin(a / rad); | ||
y0 = yMax / 2 - Math.cos(a / rad); | ||
|
||
x1 = xMax / 2 - Math.sin(a / rad) * 80; | ||
y1 = yMax / 2 - Math.cos(a / rad) * 80; | ||
var drawDial = function() { | ||
fb.color(1, 1, 1); | ||
fb.circle(xMax/2, yMax/2, 100); | ||
|
||
fb.color(0, 0, 0); | ||
for (var a = 0; a < 360; a += 6) { | ||
var x0, y0; | ||
|
||
var x0 = xMax/2 + Math.sin(a/rad) * 95; | ||
var y0 = yMax/2 + Math.cos(a/rad) * 95; | ||
|
||
if (a % 30 == 0) { | ||
x1 = xMax/2 + Math.sin(a/rad) * 85; | ||
y1 = yMax/2 + Math.cos(a/rad) * 85; | ||
fb.line(x0, y0, x1, y1, 5); | ||
} else { | ||
x1 = xMax/2 + Math.sin(a/rad) * 90; | ||
y1 = yMax/2 + Math.cos(a/rad) * 90; | ||
fb.line(x0, y0, x1, y1, 1); | ||
} | ||
} | ||
} | ||
|
||
fb.line(x0, y0, x1, y1, 5); | ||
var updateHands = function() { | ||
fb.color(1, 1, 1); | ||
fb.circle(xMax/2, yMax/2, 85); | ||
|
||
var now = new Date(), | ||
midnight = new Date( | ||
now.getFullYear(), | ||
now.getMonth(), | ||
now.getDate(), | ||
0,0,0), | ||
hours = (now.getTime() - midnight.getTime())/1000/60/60, | ||
minutes = (hours * 60) % 60; | ||
seconds = parseInt((minutes * 60) % 60); | ||
|
||
fb.color(1, 0, 0); | ||
hand(fb, 0, 0, hours/12 * 360, 60, 5); | ||
hand(fb, 0, 0, minutes/60 * 360, 80, 5); | ||
fb.color(0, 0, 0); | ||
hand(fb, 0, 0, seconds/60 * 360, 80, 1.5); | ||
fb.color(1, 0, 0); | ||
fb.circle(xMax/2, yMax/2, 7.5); | ||
fb.blit(); | ||
}; | ||
|
||
drawDial(); | ||
setInterval(function() { | ||
updateHands(); | ||
}, 100); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "pitft", | ||
"description": "A C++ extension for node.js that gives javascript access to the PiTFT framebuffer", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"main": "pitft.js", | ||
"author": "Werner Vesteraas <[email protected]>", | ||
"license": { | ||
|
Oops, something went wrong.