Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:atduskgreg/rad
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Borenstein committed Jul 22, 2008
2 parents e5b4043 + d80769a commit 8c2632c
Show file tree
Hide file tree
Showing 8 changed files with 212 additions and 18 deletions.
2 changes: 2 additions & 0 deletions Manifest.txt
Expand Up @@ -6,12 +6,14 @@ Rakefile
bin/rad
lib/examples/add_hysteresis.rb
lib/examples/blink_m_hello.rb
lib/examples/configure_pa_lcd_boot.rb
lib/examples/debounce_methods.rb
lib/examples/external_variables.rb
lib/examples/external_variable_fu.rb
lib/examples/first_sound.rb
lib/examples/frequency_generator.rb
lib/examples/hello_eeprom.rb
lib/examples/hello_pa_lcd.rb
lib/examples/hello_servos.rb
lib/examples/hello_world.rb
lib/examples/i2c_with_clock_chip.rb
Expand Down
91 changes: 91 additions & 0 deletions lib/examples/configure_pa_lcd_boot.rb
@@ -0,0 +1,91 @@
class ConfigurePaLcdBoot < ArduinoSketch

## important!
## most pa_lcd rates are set to 9200, but there are some newer at 19200
## if you have a 19200, uncomment the end of line 38

## purpose:
## change cursor to none
## and add custom boot screen
##
## jd's preferred setup for pa_lcd
##
## assumes 4 x 20 pa_lcd
##
## no blinking cursor press button 1
## configure custom start up screen - press button 2
## configure lcd to use custom startup screen - press button 3
##
## press buttons one, two and three
## or season to taste
##
## refernce
## K107 LCD Controller Board Manual
## page 11 for cursors
## page 13 for custom boot
## http://wulfden.org/downloads/manuals/K107manual.pdf
##
##

## set pins to your setup


input_pin 8, :as => :button_one, :device => :button
input_pin 9, :as => :button_two, :device => :button
input_pin 10, :as => :button_three, :device => :button

## note, most of these controllers are set to 9200
output_pin 14, :as => :my_lcd, :device => :pa_lcd #, :rate => 19200


def loop
set_cursor if button_one.read_input
set_custom_screen if button_two.read_input
change_boot_to_custom if button_three.read_input
end

## assumes 4 x 20 screen
## maintain 20 characters after ?Cn
## wny delays? the controller needs them to give it
## enough time to write 20 bytes to internl EEPROM
def set_custom_screen
my_lcd.clearscr
my_lcd.print "?C0 RAD & Arduino "
delay 400
my_lcd.print "?C1 Development "
delay 400
my_lcd.print "?C2 "
delay 400
my_lcd.print "?C3 v0.3.0 "
end


## ?c0 for no cursor
## ?c2 for non blinking cursor
## ?c3 for blinking cursor
def set_cursor
my_lcd.clearscr
my_lcd.print "Changing to "
my_lcd.setxy 0,1
my_lcd.print "no cursor. "
my_lcd.setxy 0,3
my_lcd.print "Reboot to view... "

my_lcd.print("?c0")
end

## "?S0 for blank screen
## ?S1 for configuration settings
## ?S2 for custom text screen
def change_boot_to_custom
my_lcd.clearscr
my_lcd.print "Changing to "
my_lcd.setxy 0,1
my_lcd.print "custom boot screen. "
my_lcd.setxy 0,3
my_lcd.print "Reboot to view... "
my_lcd.print("?S2")
end


end
63 changes: 63 additions & 0 deletions lib/examples/hello_pa_lcd.rb
@@ -0,0 +1,63 @@
class HelloPaLcd < ArduinoSketch


# demonstrate 4 x 20 pa_lcd toggle between normal and Bignum mode
# with @toggle external variable thrown in for fun

# change your pins to suit your setup

@toggle = false

input_pin 6, :as => :button_one, :device => :button
input_pin 7, :as => :button_two, :device => :button
input_pin 8, :as => :button_three, :device => :button

output_pin 5, :as => :my_lcd, :device => :pa_lcd, :rate => 19200, :clear_screen => :true

def setup
delay 3000
my_lcd.home
my_lcd.print "Press button"
my_lcd.setxy 0,1
my_lcd.print "One, two or three...."
end

def loop
say_hello if button_one.read_input
say_more if button_two.read_input
say_it_large if button_three.read_input
end

def say_hello
@toggle = true
my_lcd.clearscr
my_lcd.home # line 0, col 0
my_lcd.print "Any sufficiently advanced technology"
my_lcd.setxy 0,2
my_lcd.setxy 0,3
my_lcd.print "toggle state: "
my_lcd.print @toggle
end

def say_more # passing print strings to home and setxy (also works on clearscr)
@toggle = false
my_lcd.clearscr
my_lcd.home "is indistinguishablefrom magic"
my_lcd.setxy 0,3, "toggle state: "
my_lcd.print @toggle
end


def say_it_large
my_lcd.clearscr
my_lcd.intoBignum
my_lcd.home # line 0, col 0
1.upto(32) do |i|
my_lcd.setxy 0,1
my_lcd.print i * i
delay 200
end
my_lcd.outofBignum
end

end
48 changes: 37 additions & 11 deletions lib/libraries/SWSerLCDpa/SWSerLCDpa.cpp
Expand Up @@ -154,12 +154,49 @@ void SWSerLCDpa::clearscr(void)
delay(100);
}

void SWSerLCDpa::clearscr(const char *s)
{
print("?f");
delay(100);
print(s);
}

void SWSerLCDpa::home(void)
{
print("?a");
delay(10);
}

void SWSerLCDpa::home(const char *s)
{
print("?a");
delay(10);
print(s);
}

void SWSerLCDpa::setxy(int x, int y)
{
print("?y");
print(y);
print("?x");
if (x < 10)
print('0');
print(x);
delay(10);
}

void SWSerLCDpa::setxy(int x, int y, const char *s)
{
print("?y");
print(y);
print("?x");
if (x < 10)
print('0');
print(x);
delay(10);
print(s);
}


void SWSerLCDpa::setgeo(int geometry)
{
Expand Down Expand Up @@ -188,17 +225,6 @@ void SWSerLCDpa::outofBignum(void)
}


void SWSerLCDpa::setxy(int x, int y)
{
print("?y");
print(y);
print("?x");
if (x < 10)
print('0');
print(x);
delay(10);
}


void SWSerLCDpa::println(char c)
{
Expand Down
5 changes: 4 additions & 1 deletion lib/libraries/SWSerLCDpa/SWSerLCDpa.h
Expand Up @@ -46,11 +46,14 @@ class SWSerLCDpa
void println(void);
void clearscr(void);
void home(void);
void setxy(int, int);
void clearscr(const char[]);
void home(const char[]);
void setxy(int, int, const char[]);
void setgeo(int);
void setintensity(int);
void intoBignum(void);
void outofBignum(void);
void setxy(int, int);
void println(char);
void println(const char[]);
void println(uint8_t);
Expand Down
15 changes: 12 additions & 3 deletions lib/rad/arduino_sketch.rb
Expand Up @@ -667,6 +667,18 @@ def swser_LCDpa(tx, opts={})
accessor << "void home(SWSerLCDpa& s) {"
accessor << "\treturn s.home();"
accessor << "}"
accessor << "void setxy( SWSerLCDpa& s, int x, int y) {"
accessor << "\treturn s.setxy( x, y );"
accessor << "}"
accessor << "void clearscr(SWSerLCDpa& s, const char *str) {"
accessor << "\treturn s.clearscr(str);"
accessor << "}"
accessor << "void home(SWSerLCDpa& s, const char *str) {"
accessor << "\treturn s.home(str);"
accessor << "}"
accessor << "void setxy( SWSerLCDpa& s, int x, int y, const char *str) {"
accessor << "\treturn s.setxy( x, y, str );"
accessor << "}"
accessor << "void setgeo( SWSerLCDpa& s, int i ) {"
accessor << "\treturn s.setgeo( i );"
accessor << "}"
Expand All @@ -678,9 +690,6 @@ def swser_LCDpa(tx, opts={})
accessor << "}"
accessor << "void outofBignum(SWSerLCDpa& s) {"
accessor << "\treturn s.outofBignum();"
accessor << "}"
accessor << "void setxy( SWSerLCDpa& s, int x, int y) {"
accessor << "\treturn s.setxy( x, y );"
accessor << "}"
accessor << "void println( SWSerLCDpa& s, char c ) {"
accessor << "\treturn s.println( c );"
Expand Down
4 changes: 2 additions & 2 deletions lib/rad/tasks/build_and_make.rake
Expand Up @@ -55,14 +55,14 @@ namespace :make do
end

desc "generate a makefile and use it to compile the .cpp using the current .cpp file"
task :compile_cpp => ["build:sketch_dir", :clean_sketch_dir] do # should also depend on "build:sketch"
task :compile_cpp => ["build:sketch_dir", "build:gather_required_plugins", "build:plugin_setup", "build:setup", :clean_sketch_dir] do # should also depend on "build:sketch"
Makefile.compose_for_sketch( @test_dir + @sketch_name )
# not allowed? sh %{export PATH=#{Makefile.software_params[:arduino_root]}/tools/avr/bin:$PATH}
sh %{cd #{RAD_ROOT}/#{@test_dir + @sketch_name}; make depend; make}
end

desc "generate a makefile and use it to compile the .cpp and upload it using current .cpp file"
task :upload_cpp => ["build:sketch_dir", :clean_sketch_dir] do # should also depend on "build:sketch"
task :upload_cpp => ["build:sketch_dir", "build:gather_required_plugins", "build:plugin_setup", "build:setup", :clean_sketch_dir] do # should also depend on "build:sketch"
Makefile.compose_for_sketch( @test_dir + @sketch_name )
# not allowed? sh %{export PATH=#{Makefile.software_params[:arduino_root]}/tools/avr/bin:$PATH}
sh %{cd #{RAD_ROOT}/#{@test_dir + @sketch_name}; make depend; make upload}
Expand Down
2 changes: 1 addition & 1 deletion rad.gemspec
Expand Up @@ -12,7 +12,7 @@ Gem::Specification.new do |s|
s.has_rdoc = true
s.authors = ["Greg Borenstein", "plugins+: JD Barnhart"]
s.files = ["History.txt", "License.txt", "Manifest.txt",
"README.rdoc", "Rakefile", "bin/rad", "lib/examples/add_hysteresis.rb", "lib/examples/blink_m_hello.rb", "lib/examples/external_variable_fu.rb", "lib/examples/debounce_methods.rb", "lib/examples/external_variables.rb", "lib/examples/first_sound.rb", "lib/examples/frequency_generator.rb", "lib/examples/hello_eeprom.rb", "lib/examples/hello_servos.rb", "lib/examples/hello_world.rb", "lib/examples/i2c_with_clock_chip.rb", "lib/examples/orig_servo_throttle.rb", "lib/examples/servo_buttons.rb", "lib/examples/servo_throttle.rb", "lib/examples/sparkfun_lcd.rb", "lib/examples/times_method.rb", "lib/examples/toggle.rb", "lib/examples/two_wire.rb", "lib/libraries/DS1307/DS1307.cpp", "lib/libraries/DS1307/DS1307.h", "lib/libraries/DS1307/keywords.txt", "lib/libraries/FrequencyTimer2/keywords.txt", "lib/libraries/FrequencyTimer2/FrequencyTimer2.cpp", "lib/libraries/FrequencyTimer2/FrequencyTimer2.h", "lib/libraries/OneWire/keywords.txt", "lib/libraries/OneWire/OneWire.cpp", "lib/libraries/OneWire/OneWire.h", "lib/libraries/OneWire/readme.txt", "lib/libraries/Servo/keywords.txt", "lib/libraries/Servo/Servo.cpp", "lib/libraries/Servo/Servo.h", "lib/libraries/SWSerLCDpa/SWSerLCDpa.cpp", "lib/libraries/SWSerLCDpa/SWSerLCDpa.h", "lib/libraries/SWSerLCDsf/SWSerLCDsf.cpp", "lib/libraries/SWSerLCDsf/SWSerLCDsf.h", "lib/libraries/Wire/Wire.cpp", "lib/libraries/Wire/keywords.txt", "lib/libraries/Wire/Wire.h", "lib/libraries/Wire/twi.h", "lib/libraries/Wire/utilities/twi.c", "lib/libraries/Wire/utilities/twi.h", "lib/plugins/bitwise_ops.rb", "lib/plugins/blink_m.rb", "lib/plugins/debounce.rb", "lib/plugins/debug_output_to_lcd.rb", "lib/plugins/i2c_eeprom.rb", "lib/plugins/input_output_state.rb", "lib/plugins/mem_test.rb", "lib/plugins/servo_pulse.rb", "lib/plugins/servo_setup.rb", "lib/plugins/smoother.rb", "lib/plugins/spark_fun_serial_lcd.rb", "lib/rad.rb", "lib/rad/arduino_sketch.rb", "lib/rad/arduino_plugin.rb", "lib/rad/rad_processor.rb", "lib/rad/rad_rewriter.rb", "lib/rad/variable_processing.rb", "lib/rad/init.rb", "lib/rad/todo.txt", "lib/rad/tasks/build_and_make.rake", "lib/rad/tasks/rad.rb", "lib/rad/version.rb", "lib/rad/generators/makefile/makefile.erb", "lib/rad/generators/makefile/makefile.rb", "lib/test/test_array_processing.rb", "lib/test/test_variable_processing.rb", "scripts/txt2html", "setup.rb", "spec/models/spec_helper.rb", "spec/models/arduino_sketch_spec.rb", "spec/spec.opts", "website/index.html", "website/index.txt", "website/javascripts/rounded_corners_lite.inc.js", "website/stylesheets/screen.css", "website/template.rhtml", "website/examples/assembler_test.rb.html", "website/examples/gps_reader.rb.html", "website/examples/hello_world.rb.html", "website/examples/serial_motor.rb.html"]
"README.rdoc", "Rakefile", "bin/rad", "lib/examples/add_hysteresis.rb", "lib/examples/blink_m_hello.rb", "lib/examples/configure_pa_lcd_boot.rb", "lib/examples/external_variable_fu.rb", "lib/examples/debounce_methods.rb", "lib/examples/external_variables.rb", "lib/examples/first_sound.rb", "lib/examples/frequency_generator.rb", "lib/examples/hello_eeprom.rb", "lib/examples/hello_pa_lcd.rb", "lib/examples/hello_servos.rb", "lib/examples/hello_world.rb", "lib/examples/i2c_with_clock_chip.rb", "lib/examples/orig_servo_throttle.rb", "lib/examples/servo_buttons.rb", "lib/examples/servo_throttle.rb", "lib/examples/sparkfun_lcd.rb", "lib/examples/times_method.rb", "lib/examples/toggle.rb", "lib/examples/two_wire.rb", "lib/libraries/DS1307/DS1307.cpp", "lib/libraries/DS1307/DS1307.h", "lib/libraries/DS1307/keywords.txt", "lib/libraries/FrequencyTimer2/keywords.txt", "lib/libraries/FrequencyTimer2/FrequencyTimer2.cpp", "lib/libraries/FrequencyTimer2/FrequencyTimer2.h", "lib/libraries/OneWire/keywords.txt", "lib/libraries/OneWire/OneWire.cpp", "lib/libraries/OneWire/OneWire.h", "lib/libraries/OneWire/readme.txt", "lib/libraries/Servo/keywords.txt", "lib/libraries/Servo/Servo.cpp", "lib/libraries/Servo/Servo.h", "lib/libraries/SWSerLCDpa/SWSerLCDpa.cpp", "lib/libraries/SWSerLCDpa/SWSerLCDpa.h", "lib/libraries/SWSerLCDsf/SWSerLCDsf.cpp", "lib/libraries/SWSerLCDsf/SWSerLCDsf.h", "lib/libraries/Wire/Wire.cpp", "lib/libraries/Wire/keywords.txt", "lib/libraries/Wire/Wire.h", "lib/libraries/Wire/twi.h", "lib/libraries/Wire/utilities/twi.c", "lib/libraries/Wire/utilities/twi.h", "lib/plugins/bitwise_ops.rb", "lib/plugins/blink_m.rb", "lib/plugins/debounce.rb", "lib/plugins/debug_output_to_lcd.rb", "lib/plugins/i2c_eeprom.rb", "lib/plugins/input_output_state.rb", "lib/plugins/mem_test.rb", "lib/plugins/servo_pulse.rb", "lib/plugins/servo_setup.rb", "lib/plugins/smoother.rb", "lib/plugins/spark_fun_serial_lcd.rb", "lib/rad.rb", "lib/rad/arduino_sketch.rb", "lib/rad/arduino_plugin.rb", "lib/rad/rad_processor.rb", "lib/rad/rad_rewriter.rb", "lib/rad/variable_processing.rb", "lib/rad/init.rb", "lib/rad/todo.txt", "lib/rad/tasks/build_and_make.rake", "lib/rad/tasks/rad.rb", "lib/rad/version.rb", "lib/rad/generators/makefile/makefile.erb", "lib/rad/generators/makefile/makefile.rb", "lib/test/test_array_processing.rb", "lib/test/test_variable_processing.rb", "scripts/txt2html", "setup.rb", "spec/models/spec_helper.rb", "spec/models/arduino_sketch_spec.rb", "spec/spec.opts", "website/index.html", "website/index.txt", "website/javascripts/rounded_corners_lite.inc.js", "website/stylesheets/screen.css", "website/template.rhtml", "website/examples/assembler_test.rb.html", "website/examples/gps_reader.rb.html", "website/examples/hello_world.rb.html", "website/examples/serial_motor.rb.html"]
s.test_files = []
s.rdoc_options = ["--main", "README.rdoc"]
s.require_paths = ["lib"]
Expand Down

0 comments on commit 8c2632c

Please sign in to comment.