Sha256: 679b869f8782a8b843051d32f5468cf352de84300a99e3ff15fe33ec5f7e6961

Contents?: true

Size: 1.65 KB

Versions: 21

Compression:

Stored size: 1.65 KB

Contents

class HelloArrayEeprom < ArduinoSketch

   # ----------------------------------------------------------------------
   #    Checking out various array operations  with I2C serial EEPROM
   #      doing block writes and bloack readbacks with byte arrays
   #
   #      JD Barnhart - Seattle, WA July 2008
   #      Brian Riley - Underhill Center, VT, USA  July 2008
   #                     <brianbr@wulfden.org>
   #
   # ----------------------------------------------------------------------

 # still working this out...
 # for example, new instance style array declaration naming
 # is at odds with original style array naming  

 define "THROWAWAY 0"

 # when we just need to declare an array, or need more control, such as specific type requirements
 array "byte page_data[20] = {'R', 'A', 'D', ' ', 'i', 's', ' ', 'B', 'A', 'D', '*', '!', ')', '=', 'P', '-', '+', 'R', 'I', 'K'}"
 array "byte in_buffer[20]"
 
 output_pin 19, :as => :mem0, :device => :i2c_eeprom, :address => 1     # w/o :address defaults to  :address => 0  which is  0x50
 output_pin 14, :as => :my_lcd, :device => :pa_lcd, :rate => 19200
 
 
 def setup
   
   my_lcd.clearscr    "  I2C EEPROM Demo"
   my_lcd.setxy 0, 1, "block write and read"
   my_lcd.setxy 0, 2, "  back and display"
   my_lcd.setxy 0, 3, "    to the LCD"
   
   delay 2000
   
   my_lcd.clearscr    "  I2C EEPROM Demo?n    block write"

   mem0.write_page 0x0100, page_data, 20 

   delay 1000
   
   my_lcd.clearline 1, "  block readback"
   
   mem0.read_buffer 0x0100, in_buffer, 20 
   
   my_lcd.setxy 0, 2
   
   1.upto(20) do |x|
     my_lcd.print in_buffer[x-1]
     my_lcd.print " "
   end
   
 end
 
 def loop
    x = THROWAWAY
 end

end

Version data entries

21 entries across 21 versions & 4 rubygems

Version Path
neo_rad-0.4.0 lib/examples/hello_array_eeprom.rb
atduskgreg-rad-0.2.5 lib/examples/hello_array_eeprom.rb
atduskgreg-rad-0.3.0.1 lib/examples/hello_array_eeprom.rb
atduskgreg-rad-0.3.1 lib/examples/hello_array_eeprom.rb
madrona-rad-0.3.1.1 lib/examples/hello_array_eeprom.rb
madrona-rad-0.3.1 lib/examples/hello_array_eeprom.rb
madrona-rad-0.3.2 lib/examples/hello_array_eeprom.rb
madrona-rad-0.3.3 lib/examples/hello_array_eeprom.rb
madrona-rad-0.3.4 lib/examples/hello_array_eeprom.rb
madrona-rad-0.3.5 lib/examples/hello_array_eeprom.rb
madrona-rad-0.3.6 lib/examples/hello_array_eeprom.rb
madrona-rad-0.3.7 lib/examples/hello_array_eeprom.rb
madrona-rad-0.3.8 lib/examples/hello_array_eeprom.rb
madrona-rad-0.3.9 lib/examples/hello_array_eeprom.rb
madrona-rad-0.4.0 lib/examples/hello_array_eeprom.rb
madrona-rad-0.5.0 lib/examples/hello_array_eeprom.rb
madrona-rad-0.4.3 lib/examples/hello_array_eeprom.rb
madrona-rad-0.4.2 lib/examples/hello_array_eeprom.rb
madrona-rad-0.4.1 lib/examples/hello_array_eeprom.rb
rad-0.2.9 lib/examples/hello_array_eeprom.rb