Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updating documentation

git-svn-id: svn+ssh://rubyforge.org/var/svn/betabrite/trunk@28 32089d7b-f314-0410-b504-a527b3b390a0
  • Loading branch information...
commit 577b3b32d33bc22217cf6ab0f7357156b3cc070d 1 parent 37a5a01
aaronp authored
View
101 EXAMPLES
@@ -2,85 +2,40 @@
== Allocate Memory
- require 'betabrite'
- require 'serialport'
-
- sp = SerialPort.new(0, 9600, 8, 1, SerialPort::NONE)
-
- sign = BetaBrite.new
-
- string = BetaBrite::Memory::String.new('0', 32)
- dots = BetaBrite::Memory::Dots.new('1', 7, 7)
- text = BetaBrite::Memory::Text.new('A', 256)
-
- sign.add text
- sign.add dots
- sign.add string
-
- sign.allocate { |text|
- sp.write text
- }
+ bb = BetaBrite::Serial.new('/dev/ttyUSB0') do |sign|
+ sign.allocate do |memory|
+ memory.text('A', 4096)
+ memory.string('0', 64)
+ memory.dots('1', 7, 7)
+ end
+ end
+ bb.write_memory!
== Reset the sign
- require 'betabrite'
- require 'serialport'
-
- sp = SerialPort.new(0, 9600, 8, 1, SerialPort::NONE)
+ BetaBrite::Serial.new('/dev/ttyUSB0').clear_memory!
- sign = BetaBrite.new
- sign.add BetaBrite::Memory::Clear.new
-
- sign.allocate { |text|
- sp.write text
- }
-
== Write a text file
- require 'serialport'
- require 'betabrite'
-
- sp = SerialPort.new(0, 9600, 8, 1, SerialPort::NONE)
-
- sign = BetaBrite.new
- tf = BetaBrite::TextFile.new
- tf.message = ARGV[0]
-
- sign.add tf
-
- sign.write { |text|
- sp.write text
- }
+ bb = BetaBrite::Serial.new('/dev/ttyUSB0') do |sign|
+ sign.textfile do
+ print left_arrow + string("Hello ").green
+ print string(" world.").green + sail_boat
+ end
+ end
+ bb.write!
== Write a text file that references a string file
- require 'betabrite'
- require 'serialport'
-
- sp = SerialPort.new(0, 9600, 8, 1, SerialPort::NONE)
-
- sign = BetaBrite.new
-
- # Create a new TextFile with the COMPRESSED_ROTATE mode.
- tf = BetaBrite::TextFile.new { |a|
- a.mode = BetaBrite::TextFile::Mode::COMPRESSED_ROTATE
- }
-
- # Set up a BetaBrite::String
- name = BetaBrite::String.new('James',
- :color => BetaBrite::String::Color::AMBER
- )
- # Create a StringFile which can be modified without making the sign blink.
- sf = BetaBrite::StringFile.new('0', name)
-
- # Set the TextFile message and reference the StringFile
- tf.message = BetaBrite::String.new("Aaron #{sf.id} Patterson")
-
-
- sign.add tf
- sign.add sf
-
- sign.write { |text|
- sp.write text
- }
-
+ bb = BetaBrite::Serial.new('/dev/ttyUSB0') do |sign|
+ sign.stringfile('0') do
+ print string("cruel").red
+ end
+
+ sign.textfile do
+ print left_arrow + string("Hello ").green
+ print stringfile("0")
+ print string(" world.").green + sail_boat
+ end
+ end
+ bb.write!
View
29 NOTES
@@ -1,29 +0,0 @@
-= BetaBrite Release Notes
-
-== 0.0.2
-
-This release comes with new syntax for setting attributes of
-BetaBrite::String and BetaBrite::TextFile. Setting attributes like color
-and character set is now less cumbersome. For example, here is the old
-way to set the color using constants:
- s = BetaBrite::String.new("hello")
- s.color = BetaBrite::String::Color::GREEN
-Instead you can do this:
- s = BetaBrite::String.new("hello") { |a|
- a.set_color "green"
- }
-You can treat TextFile similarly:
- s = BetaBrite::TextFile.new { |a|
- a.set_mode "compressed_rotate"
- a.set_position "middle"
- }
-These special set functions figure out what constant you want and set it
-to the attribute you want. "set_mode" looks up the name passed in in the
-constants stored in the Mode class, and sets it to the mode attribute.
-
-
-== 0.0.1
-
-This is the first release of the BetaBrite sign library. Please see the RDoc,
-the 'script' directory, and the EXAMPLES file for how to use this library.
-
View
78 README.txt
@@ -19,42 +19,27 @@ file displayed on the sign is labeled 'A'.
Here is an example of modifying the default sign text:
- sp = SerialPort.new(0, 9600, 8, 1, SerialPort::NONE)
-
- sign = BetaBrite.new
- tf = BetaBrite::TextFile.new
- tf.message = ARGV[0]
-
- sign.add tf
-
- sign.write { |text|
- sp.write text
- }
+ bb = BetaBrite::Serial.new('/dev/ttyUSB0') do |sign|
+ sign.textfile do
+ print ARGV[0]
+ end
+ end
+ bb.write!
== Allocating Memory
The memory in the BetaBrite sign should be configured before anything is
-written to it. This means writing a seperate script to allocate the memory
-from the one that actually writes data. This may change in the future, I
-just haven't figured out if it is possible to allocate memory and write data
-at the same time.
+written to it. You only have to configure the memory once before writing to
+it. So subsequent executions of your script do not require allocating memory.
Here is an example of allocating memory on the sign:
- sp = SerialPort.new(0, 9600, 8, 1, SerialPort::NONE)
-
- sign = BetaBrite.new
-
- string = BetaBrite::Memory::String.new('0', 32)
- dots = BetaBrite::Memory::Dots.new('1', 7, 7)
- text = BetaBrite::Memory::Text.new('A', 256)
-
- sign.add text
- sign.add dots
- sign.add string
-
- sign.allocate { |text|
- sp.write text
- }
+ bb = BetaBrite::Serial.new('/dev/ttyUSB0') do |sign|
+ sign.memory do
+ memory.text('A', 4096)
+ memory.string('0', 64)
+ end
+ end
+ bb.write_memory!
For more examples, see the EXAMPLES file.
@@ -73,27 +58,18 @@ be displayed unless referenced from a Text File.
Here is an example of referencing a String File from a Text File:
- sp = SerialPort.new(0, 9600, 8, 1, SerialPort::NONE)
- sign = BetaBrite.new
- tf = BetaBrite::TextFile.new
-
- # Set up a BetaBrite::String
- middle_name = BetaBrite::String.new('James',
- :color => BetaBrite::String::Color::AMBER
- )
- # Create a StringFile which can be modified without making the sign blink.
- sf = BetaBrite::StringFile.new('0', middle_name)
-
- # Set the TextFile message and reference the StringFile
- tf.message = BetaBrite::String.new("Aaron #{sf.id} Patterson")
-
-
- sign.add tf
- sign.add sf
-
- sign.write { |text|
- sp.write text
- }
+ bb = BetaBrite::Serial.new('/dev/ttyUSB0') do |sign|
+ sign.stringfile('0') do
+ print string("cruel").red
+ end
+
+ sign.textfile do
+ print string("Goodbye ").green
+ print stringfile("0")
+ print string(" world.").green + sail_boat
+ end
+ end
+ bb.write!
Once the String file is allocated and displayed, it can be changed at any
time and the string will be updated without the screen going blank.
View
7 lib/betabrite/base.rb
@@ -52,9 +52,10 @@ def allocate(&block)
@memory.push(*(BetaBrite::Memory::Factory.find(&block)))
end
- #def clear_memory!
- # @memory << BetaBrite::Memory::Clear.new
- #end
+ def clear_memory!
+ @memory = []
+ self.write_memory!
+ end
# Get the message to be sent to the sign
def message
View
7 lib/betabrite/serial.rb
@@ -1,14 +1,7 @@
-begin
- require 'serialport'
- HAVE_SERIALPORT = true
-rescue LoadError => ex
- HAVE_SERIALPORT = false
-end
module BetaBrite
class Serial < Base
def initialize(serialport)
@serialport = serialport
- raise("Please install ruby-serialport") unless HAVE_SERIALPORT
super()
end
Please sign in to comment.
Something went wrong with that request. Please try again.