dino
dino copied to clipboard
Dino 0.12.0
New Boards
-
The
dino sketch
shell command now accepts a--target
argument that will automatically add/remove features when generating a sketch, tailoring it to fit specific boards/chips. Rundino targets
for more info. -
ESP8266 support (
--target esp8266
):- Works with
Dino::Board.new
, but callingDino::Board::ESP8266.new
instead allows pins to be referred to as any of'GPIO4'
,4
, or'D2'
, as printed on popular boards like the NodeMCU or WeMos, with the printed names automatically mapping to the correct GPIO. - Works with either built in WiFi or Serial.
- WiFi version supports OTA (over-the-air) update in the Arduino IDE. Initial flash must still be done via serial.
- Note: SoftwareSerial and LCD are currently incompatible with the ESP8266. Setting the correct target will automatically exclude these.
- Works with
-
Arduino Due support (
--target arm
) :- Up to 12-bit analog in/out. Pass a
bits:
option toBoard#new
to set resolution for both. - DAC support. Refer to DAC pins as
'DAC0'
,'DAC1'
, just as labeled on the board. Call#analog_write
or just#write
on anAnalogOutput
component that uses the pin. - Uses the native ARM serial port by default. Configurable in sketch to use programming port.
- Note: SoftwareSerial, Infrared, and Tone are currently incompatible with the Arduino Due. Setting the correct target will automatically exclude these.
- Up to 12-bit analog in/out. Pass a
-
ATmega168 support (
--target atmega168
):- Thanks to omitting libraries with the CLI, and general optimization, we can now fit the memory constraints of the ATmega168 chips found in older Arduinos.
- SoftwareSerial, LCD, and Shift Register are compatible, but left out to meet memory requirements.
- Included libraries can be customized in
DinoDefines.h
for any generated sketch. - Note: Aux message is limited to 264 bytes on the mega168, or less depending on included libraries. The only feature currently affected by this is sending long infrared signals, like those on AC units.
New Components
-
Shift Register support (uses Arduino native ShiftOut and ShiftIn functions).
-
SPI bus support (uses SPI library from Arduino IDE) :
- Read-Only Transfers
- Write-Only Transfers
- Read/Write Transfers
- Read-Only Listeners (like digital/analog listeners, but read X bytes from MISO)
-
BoardProxy
abstraction for shift/SPI registers:- Connect something to a register's parallel in/out pins. Initialize the register object, then pass it as a "board" when initializing the component.
- Registers implement enough of the
Board
interface to satisfyDigitalInput
,DigitalOutput
andMultiPin
classes built out of either type, such asLed
,Button
orSSD
(seven segment display). - This lets you call methods on components directly, rather than manipulating the register data to control components indirectly. See
examples/register
for more.
-
I2C support (Read/Write) Uses Wire library from the Arduino IDE
-
Dallas/Maxim 1-Wire bus support:
- High level implementation in Ruby, with low level timing functions in C, running on the board. Thanks to Kevin Darrah's video for explaining the timings better than the data sheet.
- Most bus features implemented: reset/presence detect, parasite power handling, bus search and slave device identification, CRC. No overdrive support.
- Only DS18B20 (temperature sensor) slave device implemented. Further slave implementation should be doable in pure Ruby.
-
Rotary encoder support. Using polling method @ 1ms interval. WARNING: Do not use at high speeds or if requiring precise position. It will definitely miss steps. This is meant to be just good enough for making things like rotary knobs, which it accomplishes.
-
Seven Segment Display support. Ruby implementation as multiple LEDs.
-
Infrared Emitter support. Uses Arduino-IRremote, and the ESP8266 fork where applicable. Takes IR codes as arrays of raw millisecond durations. Max code length is 255 marks/spaces. Max mark/space duration is 65535 microseconds. Emitter always connects to the default pin specified by the included library. Note: The ESP8266 is an exception here. Since it bitbangs the infrared carrier frequency, it can be used on any pin.
-
Hitachi HD44780 LCD support. Uses LiquidCrystal library from Arduino IDE.
-
DHT11 / DHT 21 (AM2301) / DHT22 temperature and relative humidity sensor support. Pulse times are measured on the board in C. Everything else is done in Ruby.
-
Tone (piezo) support. Maps native
tone
,noTone
Arduino functions. -
SoftwareSerial: Use 2 of the Arduino pins as a secondary serial interface. (write only / experimental)
-
WiFi shield support (untested)
Minor Changes
-
Serial communication now uses the
rubyserial
gem instead ofserialport
. -
Added more useful information and errors during the connect & handshake process.
-
Extended message syntax so the Arduino can receive arbitrary length messages.
-
Created
Dino::Message
class to handle message construction. -
Moved CLI into it's own class,
Dino::CLI
. -
Added simple flow control to avoid overrunning the typical 64 byte serial input buffer when sending data to the board. No flow control for Ruby receiving data.
-
Servos can now be connected to arbitrary pins as long as they are supported by the board.
-
Digital and analog listeners now have dividers on a per-pin basis. Timing is based on 1ms. Just call
#listen
with a value as the first argument. Eg.sensor.listen(64)
will tell the board to read the sensor's state every ~64ms, or about 16 times per second, without affecting any other component's update rate. Valid dividers are:1, 2, 4, 8, 16, 32, 64, 128
. Defaults are same as before: 4 for digital, 16 for analog. -
Input Components & Callbacks:
- Callback functionality for components has been extracted into
Mixins::Callbacks
. - Adding a component no longer causes
Board
to implicitly send the listen command for that pin. The component classes themselves are in control of this now. -
DigitalInput
and its inheritors start listening on initialize. -
AnalogInput
and its inheritors do not. - Input components typically have
#read
,#poll
and#listen
methods now. - All 3 of these take an optional callback as a block, but behave very differently.
-
#read
sends a single read command, blocks until a response is received, and returns it. - If
#read
is given a callback as a block, it sends the read command, then blocks the current thread, waiting for a single value to arrive. The callback is run exactly once with that value as its parameter, and then removed. The original value passed to the callback is returned. -
#poll
accepts an additional interval (in seconds) before the block. It starts a thread, managed byMixins::Threaded
, and uses this to send the read command to the board at the given interval, without blocking the main thread. Returns immediately. -
#listen
adds its block as a callback, sends the listen command and returns immediately. -
#stop
stops polling and listening, and also removes all callbacks that were given as blocks to either#poll
or#listen
. - Explicit
#add_callback
and#remove_callback
methods are also available for finer control. - Both accept a symbol before the block so you can manage callbacks based on keys. This is how the callbacks for
#read
,#poll
, and#listen
are added and removed. - Multiple callbacks can share the same key.
- Values received are run through all callbacks, regardless of how they were added.
-
@value
has been renamed to@state
, and updates after callbacks run, instead of before, so the new value can be compared to the old value within the callback.
- Callback functionality for components has been extracted into
Awesome pull request, I'd love to see this merged, so I can adapt my LCD implementation to this
@supherman I was just about to suggest that. You can branch off 0.12.0-wip
and submit another pull request to this. I really like the approach you took in #32, but as you already said, you'll need to make some changes to get it to work with this version:
-
You'll want to send entire strings to the board, instead of one character at a time. Use the new
:aux_message
option ofDino::Message.encode
for that. Handles up to 255 chars right now. You can let theDino::LCD
class split up messages > 255 into separate messages if you want, but the overhead involved with sending one char at a time is pointless. -
Try not to put arbitrary data (like the LCD's cols and rows values) into message slots where pin and value should go. That feels like a hack. It should go into aux_message as well, and parse it inside your LCD lib. The general pattern should be something like:
10..1.16,2\n
would translate tolcd.begin(16,2)
Assuming we use
cmd == 10
to access your LCD library, val can correspond to the command in your library we want to acces. That's fine. Then the data for the command in your library gets stored in auxMsg. This pattern should work for anything where we're taking advantage of an Arduino library that needs more than just pin and value data. -
See if you can figure out how to dynamically initialize the LCD. Not all shields have the same pins. I have one with some buttons on it that uses
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
I'm in for a chat discussion or something like that, I'm not an expert with arduino, but I'd like to see the progress in this project
I opened irc room on freenode.net calls #dino-rb because looks like #dino is reserved.
You can use online irc client: http://webchat.freenode.net/ or irssi.
@supherman You should be able to just drop in your code from #39 now and it'll work. Couple changes I made:
- Changed the class name to
DinoLCD
. - The
Dino
class doesn't need to know about theLiquidCrystal
instance, so that's insideDinoLCD
instead ofDino
. - There's only one function on
DinoLCD
that gets called fromDino
,dinoLCD.process()
. You'll need to handle everything in there. It receivesval
and a pointer toauxMsg
. -
cmd
for accessingDinoLCD
is 10.
And the CLI includes the DinoLCD
library files now, so it should build the sketch properly.
@austinbv this feels pretty solid now. I made a 0.11.x release branch from current master. Going to merge this into master and make a 0.12.x release branch. Trunk-based going forward. Can we release on RubyGems?