- A wireless scale that the keg sits on.
- Measures the weight of the beer.
- Not overly accurate.
devmotron is there beer?
- charts
+
|=~
__|___
{ keg }
{______}
{ }
{______}
^~~^
(fsr)
|
|
------\
| xbee ] ~~UDP~~> +xbee_hex.rb+
------/ |
V
+campfire_notifier.rb+
└- ~~HTTP~~> +hubot-kegmotron.coffee+ -> campfire
|
└- keg-log.dat
|
V
+keg-log.ru+
1kΩ resistor
| fsr (variable)
| |
^^^^ ^~~~^
| \ | |
(+)║ \║ ║(gnd)
------------\
|1 4 9 \
| (ADC) ]
|xbee /
------------/
- pin 1 is always 3.3v
- pin 9 is always 0v
- pin 4 voltage is the ratio of 1kΩ to the fsr resistance
- negative zero!?
- OptParse shenanigans
- I don't really understand @ and @@
- OptParse can do the conversion.
- Repetition
- Even Better!
-
Strings are not real IO, do not use them as buffers.
rd, wr = IO.pipe spawn "./xbee-hex.rb -p -c", out: wr puts "[Setting up Xbee Read Pipe]" rd.each_line do |status_update| # do something each time there's a \n on stdout end
Ok, Take a file and turn it into stdin. Usefull when you want to give the file a generic name inside the program (this_plotter):
#!/usr/bin/env gnuplot set term dumb plot "/dev/stdin"
usage:
./this_plotter < file_of_the_moment.dat
Now, do it in Ruby:
spawn "this_plotter", out: in_memory_buffer, in: File.open("file_of_the_moment.dat") puts in_memory_buffer # No such object exists that can be used as `in_memory_buffer` # Why can I not use a string, if strings are ruby's buffers? # Why is there no IO::Buffer? # Why is StringIO not an IO!?
Maybe a different way?
require 'open3' stdout, _ = Open3.capture2 "this_plotter", stdin_data: File.read("file_of_the_moment.dat")
This is not great, we have to read the entire file!
~ Maybe that makes sense
spawn
is non-blockingcapture2
is blocking ~