Enhance Arduino API coverage with new helpers and examples#1
Draft
josephschito wants to merge 33 commits into
Draft
Enhance Arduino API coverage with new helpers and examples#1josephschito wants to merge 33 commits into
josephschito wants to merge 33 commits into
Conversation
Inventory of Arduino core API and bundled libraries against what Rubyduino currently exposes. Tracks what's covered vs. missing as a checklist to work through.
…ow_byte) FFI bindings + C runtime + tests covering codegen, native logic, and AVR compile. Brings parity with Arduino bit/byte macros, adapted to Ruby's no-byref-ints convention (mutators return the new value).
Named map_value to avoid clashing with Ruby's Enumerable#map. Uses int64 intermediates in map_value to match Arduino's overflow-safe math on long arguments.
Each is a pure logic function returning 0/1. Names are snake_case (is_alpha, is_digit, is_hexadecimal_digit, ...) per Ruby convention.
random_seed, random_range, random_max as FFI bindings backed by C runtime that wraps stdlib's rand/srand. Codegen for non-literal rand(low..high) now compiles to random_range(low, high+1) instead of falling through to a meaningless Spinel default. Predicate aliases (is_alpha?, is_digit?, ...) added for the 12 character classification helpers — Ruby idiom for boolean-returning methods. Spinel handles ? cleanly (translates to sp_*_p).
Single FFI binding tone_for(pin, freq, duration_ms); top-level Ruby tone(pin, freq, duration_ms = 0) wraps it. duration_ms = 0 means run indefinitely until no_tone(pin). Searches the prescaler table at runtime to keep OCR2A in 8-bit range. Conflicts with analog_write on pins 3 and 11 (same Timer2) — matches Arduino behavior.
Aliases to pulse_in_timeout since the existing implementation already uses micros() rather than cycle counting. Default timeout matches Arduino: 1,000,000 us.
Flag-based model: attach_interrupt(num, mode) wires the ISR which sets a volatile flag, interrupt_fired?(num) reads & clears it. Doesn't support callback function pointers (Ruby blocks → C function pointers isn't tractable through Spinel's compile model), but covers the common 'wake the main loop on a hardware event' use case. INT_LOW/INT_CHANGE/INT_FALLING/INT_RISING constants map directly to ATmega328P EICRA ISC bits. digital_pin_to_interrupt returns -1 for non-INT pins so users can guard against accidental wiring.
State held in rd_uno_admux_ref so analog_read picks up the latest choice; constants AREF_EXTERNAL=0, AREF_DEFAULT=1, AREF_INTERNAL=3 match ATmega328P REFS1:0 bit pairs directly.
…_timeout) peek uses a 1-byte stash so the next read consumes it; set/get_timeout expose the millisecond budget used by the upcoming parse/find helpers. available_for_write returns 1/0 since this runtime polls UDRE0 rather than buffering — adequate for byte-at-a-time writes.
…ead_byte_timeout) parse_int/float honor serial_set_timeout, skip leading non-digits, support negative numbers, and stop at the first non-digit. find scans for a literal target until timeout; find_until additionally bails when the terminator is hit. read_byte_timeout returns -1 when no byte arrives within the configured timeout window. Predicate aliases serial_find? and serial_find_until? added per the boolean-method convention.
Codegen-special-cased two-arg form: serial_print(value, BIN/OCT/DEC/HEX) routes to dedicated emitters; serial_print(float, decimals) emits the float helper. Direct callers can also use serial_print_hex etc. Float formatter is hand-rolled — pulling vfprintf_flt from avr-libc adds ~2KB which is unwelcome on UNO. Manual rounding produces Arduino-compatible 'round half away from zero' output.
Wraps avr-libc <avr/eeprom.h> helpers. eeprom_update only writes when the value differs (matches Arduino's EEPROM.update); eeprom_write also uses update internally to preserve cell life. Range-checked against E2END. eeprom_length returns 1024 on UNO. The 4-byte int helpers operate on addresses with 4-byte payloads; out-of-range reads return 0 silently to match the surrounding API style.
Hardware SPI on D11/12/13 with D10 forced as output (master mode guard). Clock divider mapping picks both SPR1:0 and SPI2X to cover all seven Arduino SPI_CLOCK_DIV* values. transfer16 honors DORD for endianness. Doesn't yet implement SPI.beginTransaction — get/set_clock_divider plus set_data_mode/set_bit_order cover the same configuration surface.
Master-only TWI implementation for ATmega328P. Internal 32-byte TX/RX buffers mirror Arduino's Wire defaults. wire_end_transmission returns the same status codes (0 ok, 2 SLA+W NACK, 3 data NACK, 4 other). Slave mode is intentionally omitted — the master flow covers the vast majority of UNO sensor sketches. set_clock formula assumes prescaler=1, which is fine for the standard 100 kHz / 400 kHz speeds; lower bus speeds would need the TWPS bits and aren't common enough to justify the code.
Single-servo implementation backed by Timer1 CTC + COMPA ISR with a two-phase state machine (high pulse 544–2400 us, then low to fill out the 20 ms frame). Pulse range matches Arduino's modern Servo defaults. Also adds forward declarations near the top of sp_runtime.h to fix implicit-declaration warnings/errors when later helpers (servo_write, rd_uno_print_float, etc.) call earlier-defined functions whose actual definitions sit further down in the same file.
Named arduino_yield because plain 'yield' is a Ruby keyword that Spinel won't accept as a method name. Compiles to a no-op on UNO since there's no scheduler — exists so sketches written to be portable across ESP32 / RP2040 still compile against rubyduino.
All 12 batches done; covered items now include analog_reference, tone/no_tone, pulse_in_long, external interrupts, all 12 character predicates (with ? aliases), bit/byte macros, map_value/constrain/sq, random_seed + non-literal random range, complete Serial extensions (end/flush/peek/timeout), Serial input parsing (parse_int/float, find, find_until, read_byte_timeout), Serial print formatting (HEX/BIN/OCT/ float), EEPROM, SPI, Wire (master), Servo, and arduino_yield.
Ruby ports of the six built-in 01.Basics sketches: BareMinimum, Blink, DigitalReadSerial, AnalogReadSerial, ReadAnalogVoltage, Fade. Sketches follow the existing rubyduino convention (top-level setup, then loop do ... end). All compile end-to-end through avr-gcc.
Nine UNO-compatible Ruby ports: BlinkWithoutDelay, Button, Debounce, DigitalInputPullup, StateChangeDetection, toneKeyboard, toneMelody, toneMultiple, tonePitchFollower. toneMelody inlines a few note constants from pitches.h directly. All compile end-to-end.
Five UNO-compatible Ruby ports: AnalogInOutSerial, AnalogInput, Calibration, Fading, Smoothing. Smoothing exercises mutable arrays; Calibration uses constrain + map_value. Skipped AnalogWriteMega since it's Mega-only.
Nine UNO-compatible Ruby ports: ASCIITable, Dimmer, Graph, Midi, PhysicalPixel, ReadASCIIString, SerialCallResponse, SerialCallResponseASCII, VirtualColorMixer. Skipped SerialEvent (needs serialEvent callback), MultiSerial and SerialPassthrough (Mega-only). ASCIITable exercises codegen-routed Serial.print(value, base) with all of HEX/OCT/BIN. ReadASCIIString uses serial_parse_int and the ?\n.ord char-literal idiom. ?A.ord works through Spinel for byte constants without needing additional codegen surgery.
Six Ruby ports: Arrays, ForLoopIteration, IfStatementConditional, switchCase, switchCase2, WhileStatementConditional. Switches use Ruby case/when which Spinel handles cleanly. switchCase2 reads single ASCII bytes via ?a.ord through ?e.ord.
Four Ruby ports: ADXL3xx, Knock, Memsic2125, Ping. ADXL3xx exercises the analog-pin-as-digital trick (using pins 18/19 = A4/A5 as power/gnd outputs). Ping demonstrates def-with-no-state helper functions (microseconds_to_inches/centimeters).
Two ports: BarGraph and RowColumnScanning. RowColumnScanning flattens the 8x8 pixel matrix to a 64-element 1D array indexed by row*8+col, since Spinel doesn't have native 2D array literals.
is_graph completes the Arduino character-classification set (printable AND not whitespace). The 08.Strings category otherwise depends on the Arduino String class — added a README documenting which sketches are blocked on that, with character_analysis.rb being the one we can port today.
One test per .rb in examples/builtin/**, each running the full Ruby -> avr-gcc compile pipeline. Skips cleanly when avr-gcc isn't installed. 43 example sketches compile end-to-end; combined with the unit suite the project now has 106 runs and 374 assertions, all green.
Pure additive changes: every existing Arduino-named method stays. - alpha?, digit?, alphanumeric?, space?, whitespace?, uppercase?, lowercase?, ascii?, control?, printable?, punctuation?, hex_digit?, graph? — Ruby idiom drops the is_ prefix - clamp(value, low, high) — Ruby's clamp naming for constrain - square(value) — clearer than sq - sleep_ms / sleep_us — read more naturally to Rubyists than delay_* - srand(seed) — matches Ruby's stdlib name for random_seed - stop_tone(pin) — clearer pair for tone(pin, freq)
Each facade is a thin module-method wrapper around the Arduino-named
top-level functions, giving sketches a more namespaced feel:
Pin.mode(13, ArduinoUno::OUTPUT); Pin.high(13); Pin.high?(2)
Serial.begin(9600); Serial.timeout = 500; Serial.println_int(42)
Eeprom.write(0, 0xAB); v = Eeprom.read(0)
Spi.begin; Spi.data_mode = ArduinoUno::SPI_MODE0; r = Spi.transfer(0x9F)
Wire.begin; Wire.clock = 100_000; Wire.transmit(0x68)
Servo.attach(9); Servo.angle = 90; Servo.attached?
Plus the without_interrupts { ... } block wrapper around no_interrupts
+ interrupts. Polymorphic Serial.print/println kept at the top level
through the existing codegen special case — Spinel monomorphizes
module methods, so a single Serial.print used with both String and
Integer would create an sp_RbVal type the runtime doesn't carry. The
facade exposes Serial.print_str / print_int / print_hex etc. for
explicit forms, and the canonical mixed-type print stays as the
top-level serial_print(...).
bin/rubyduino is now a thin shim that calls Rubyduino::CLI.run(ARGV). All the option parsing, environment validation, parser bootstrap, and compile/flash logic now lives in lib/rubyduino/cli.rb as a class with private helpers — no more top-level Object pollution. Also moves the spinel codegen loader (`load_spinel_compiler`) and its ROOT/SPINEL_ROOT constants inside the SpinelArduinoCodegen module so they don't leak to top level when the codegen file is required.
… + examples Common third-party Arduino hardware that doesn't ship in the built-in examples now has first-class rubyduino bindings: - neopixel_* — WS2812 bit-bang, up to 64 pixels, 16 MHz timing tuned via __builtin_avr_delay_cycles for stable T0H/T1H phases - dht_read / dht_temperature_x10 / dht_humidity_x10 — DHT11 + DHT22 with a single FFI entry point that auto-decodes both formats - onewire_reset/read_byte/write_byte and ds18b20 helpers for Dallas 1-Wire temperature sensors - lcd_* — HD44780 16x2 character LCDs in 4-bit mode, R/W tied low - stepper_begin / stepper_set_speed / stepper_step — equivalent of the bundled Arduino Stepper library, full-step 4-wire mode - soft_serial_* — bit-banged UART for talking to GPS/GSM/ESP-01 while the hardware UART is busy - ir_receive? + ir_command — NEC-protocol IR remote frame decoder Each driver ships with a Ruby example sketch in examples/hardware/ and a test that exercises codegen + full avr-gcc compile. The bulk-compile test now walks examples/hardware/** as well as examples/builtin/**. README rewritten to surface both API styles (Arduino-compatible vs. Ruby-style facades), document every covered helper, and link to all example sketches.
Ports the Tasmanian S4-S5 coding workbook examples (originally
.ino sketches from /Users/admin/code/thinkershield/tas-s4-s5-coding-samples)
into the rubyduino API. Each file lives under
examples/crack_the_code/ so bundle_examples.rb picks them up
automatically under a new "Crack the Code" category.
Sketches cover the progression:
01 Blink — single LED on pin 12, then four LEDs at once
02 Button / Toggle / Toggle2 — debounced button + latch
03 Int — same blink with a named constant for the pin
04 Fade — PWM fade on pin 11
05 Analog input / Night light / Pot reverse — LDR + pot reads
06 Serial print — pot value to Serial Monitor
07-09 Buzzer — single beep, two-tone siren, swept tone
10 Alarm — basic switch trigger, LDR trigger, LDR + reset,
and a five-state machine with status LEDs
Pinouts match the ThinkerShield: LEDs 9-13, button 7, buzzer
2-3, LDR 4, potentiometer A5/5. All 18 compile cleanly against
the live Lambda (verified end-to-end).
The auto-generated compile tests used to walk only builtin/** and
hardware/**, which left the 18 Crack the Code sketches and the two
loose root sketches (hello.rb, hc_sr04.rb) unverified. Expand to
{builtin,hardware,crack_the_code}/** plus examples/*.rb at the root,
and add a count assertion for the Crack the Code directory.
Result: 49 generated compile tests → 70, all passing.
There was a problem hiding this comment.
Pull request overview
This PR expands Rubyduino’s Arduino UNO API surface (including Ruby-idiomatic facades/aliases), adds a CLI wrapper module to avoid top-level namespace pollution, and ships a large library of example sketches plus compile/logic tests to validate the new helpers and codegen behavior.
Changes:
- Added/extended Arduino UNO helper bindings, Ruby-style aliases/facades (e.g.,
ArduinoUno,Pin/Serial/Spi/Wire/Servo), and new helper behaviors (interrupt blocks, extra Serial formatting, etc.). - Updated Spinel Arduino codegen to support additional
serial_print/serial_printlnoverload patterns and improvedrand(range)handling. - Added many new example sketches (builtin ports + hardware + “Crack the Code”) and a broad test suite to validate codegen and AVR compilation.
Reviewed changes
Copilot reviewed 106 out of 107 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Expanded usage docs, API styles, coverage list, examples, and test strategy. |
| bin/rubyduino | Slimmed executable shim to delegate to Rubyduino::CLI. |
| lib/rubyduino/cli.rb | Introduced Rubyduino::CLI class encapsulating compile/flash workflow and argv parsing. |
| lib/rubyduino/arduino_uno.rb | Added many UNO constants/bindings, Ruby-idiomatic aliases, and module facades. |
| lib/rubyduino/spinel_arduino_codegen.rb | Namespaced compiler loader; enhanced codegen for serial formatting + rand(range). |
| plans/arduino_api_coverage.md | New checklist documenting Arduino API/library coverage and gaps. |
| plans/ruby_api_convention_audit.md | New audit documenting Ruby API convention tradeoffs and migration ideas. |
| test/support/compile_helper.rb | Helper to compile Ruby→C and optionally AVR objects/ELFs; native C runner for logic tests. |
| test/test_cli.rb | Tests that CLI loads correctly and bin shim stays thin/non-polluting. |
| test/test_codegen_module_shape.rb | Ensures codegen loader is namespaced (no top-level helper leakage). |
| test/test_builtin_examples.rb | Bulk-compiles all example sketches (when avr-gcc is available). |
| test/test_analog_reference.rb | Tests analog_reference codegen and UNO AREF constants. |
| test/test_arduino_uno_alias.rb | Tests ArduinoUno alias constants and compatibility with legacy ArduinoUNO. |
| test/test_bits_and_bytes.rb | Tests bit/byte helper codegen and native logic. |
| test/test_char_classification.rb | Tests character classifier helpers, predicates, and native semantics. |
| test/test_dht.rb | Tests DHT helpers codegen and AVR compilation. |
| test/test_eeprom.rb | Tests EEPROM helper bindings and AVR linkage expectations. |
| test/test_external_interrupts.rb | Tests interrupt helpers, mapping table, and ISR presence in ELF. |
| test/test_ir_remote.rb | Tests NEC IR helpers codegen and AVR compilation. |
| test/test_lcd.rb | Tests HD44780 LCD helpers codegen and AVR compilation. |
| test/test_math_helpers.rb | Tests map/constrain/sq helpers codegen and native semantics. |
| test/test_module_facades.rb | Tests Ruby-style facades (Pin, Serial, Eeprom, Spi, Wire, Servo) compile. |
| test/test_neopixel.rb | Tests NeoPixel helpers codegen and AVR compilation. |
| test/test_onewire_ds18b20.rb | Tests 1-Wire/DS18B20 helpers codegen and AVR compilation. |
| test/test_pulse_in_long.rb | Tests pulse_in_long default/explicit timeout propagation. |
| test/test_random.rb | Tests rand/range codegen paths and native random_range semantics. |
| test/test_ruby_aliases.rb | Tests Ruby-idiomatic aliases (clamp, square, srand, predicates, etc.) routing. |
| test/test_serial_extensions.rb | Tests Serial extension helpers (peek, timeout, flush, etc.) and native peek buffering. |
| test/test_serial_input.rb | Tests Serial parse/find helpers codegen and native parsing semantics. |
| test/test_serial_print_formatting.rb | Tests Serial formatting routing (HEX/BIN/OCT/float) and native formatting logic. |
| test/test_servo.rb | Tests Servo helpers codegen, native mapping logic, and ISR presence in ELF. |
| test/test_software_serial.rb | Tests SoftwareSerial helpers codegen and AVR compilation. |
| test/test_spi.rb | Tests SPI helpers codegen, native clock-divider logic, and AVR compilation. |
| test/test_stepper.rb | Tests Stepper helpers codegen and AVR compilation. |
| test/test_tone.rb | Tests tone/no_tone codegen and ISR presence in ELF. |
| test/test_wire.rb | Tests Wire helpers codegen, native TWBR calc logic, and AVR compilation flow. |
| test/test_without_interrupts.rb | Tests without_interrupts codegen and AVR compilation. |
| test/test_yield.rb | Tests arduino_yield codegen and AVR compilation. |
| examples/hardware/dht22_serial.rb | Hardware example for DHT22 readings over Serial. |
| examples/hardware/ds18b20_serial.rb | Hardware example for DS18B20 readings over Serial. |
| examples/hardware/ir_remote_decode.rb | Hardware example for decoding NEC IR frames. |
| examples/hardware/lcd_hello.rb | Hardware example for HD44780 LCD output. |
| examples/hardware/neopixel_rainbow.rb | Hardware example for WS2812/NeoPixel rainbow animation. |
| examples/hardware/software_serial_passthrough.rb | Hardware example bridging HW serial and SoftwareSerial. |
| examples/hardware/stepper_loop.rb | Hardware example driving a stepper motor loop. |
| examples/crack_the_code/01_blink.rb | “Crack the Code” example sketch port. |
| examples/crack_the_code/01_blink_x4.rb | “Crack the Code” example sketch port. |
| examples/crack_the_code/02_button.rb | “Crack the Code” example sketch port. |
| examples/crack_the_code/02_toggle.rb | “Crack the Code” example sketch port. |
| examples/crack_the_code/02_toggle2.rb | “Crack the Code” example sketch port. |
| examples/crack_the_code/03_int.rb | “Crack the Code” example sketch port. |
| examples/crack_the_code/04_fade.rb | “Crack the Code” example sketch port. |
| examples/crack_the_code/05_analog_input.rb | “Crack the Code” example sketch port. |
| examples/crack_the_code/05_night_light.rb | “Crack the Code” example sketch port. |
| examples/crack_the_code/05_pot_reverse.rb | “Crack the Code” example sketch port. |
| examples/crack_the_code/06_serial_print.rb | “Crack the Code” example sketch port. |
| examples/crack_the_code/07_buzzer1.rb | “Crack the Code” example sketch port. |
| examples/crack_the_code/08_buzzer2.rb | “Crack the Code” example sketch port. |
| examples/crack_the_code/09_buzzer3.rb | “Crack the Code” example sketch port. |
| examples/crack_the_code/10_alarm_basic.rb | “Crack the Code” example sketch port. |
| examples/crack_the_code/10_alarm_basic_ldr.rb | “Crack the Code” example sketch port. |
| examples/crack_the_code/10_alarm_basic_ldr_reset.rb | “Crack the Code” example sketch port. |
| examples/crack_the_code/10_alarm_complex.rb | “Crack the Code” example sketch port. |
| examples/builtin/01_basics/analog_read_serial.rb | Built-in Arduino example port. |
| examples/builtin/01_basics/bare_minimum.rb | Built-in Arduino example port. |
| examples/builtin/01_basics/blink.rb | Built-in Arduino example port. |
| examples/builtin/01_basics/digital_read_serial.rb | Built-in Arduino example port. |
| examples/builtin/01_basics/fade.rb | Built-in Arduino example port. |
| examples/builtin/01_basics/read_analog_voltage.rb | Built-in Arduino example port. |
| examples/builtin/02_digital/blink_without_delay.rb | Built-in Arduino example port. |
| examples/builtin/02_digital/button.rb | Built-in Arduino example port. |
| examples/builtin/02_digital/debounce.rb | Built-in Arduino example port. |
| examples/builtin/02_digital/digital_input_pullup.rb | Built-in Arduino example port. |
| examples/builtin/02_digital/state_change_detection.rb | Built-in Arduino example port. |
| examples/builtin/02_digital/tone_keyboard.rb | Built-in Arduino example port. |
| examples/builtin/02_digital/tone_melody.rb | Built-in Arduino example port. |
| examples/builtin/02_digital/tone_multiple.rb | Built-in Arduino example port. |
| examples/builtin/02_digital/tone_pitch_follower.rb | Built-in Arduino example port. |
| examples/builtin/03_analog/analog_in_out_serial.rb | Built-in Arduino example port. |
| examples/builtin/03_analog/analog_input.rb | Built-in Arduino example port. |
| examples/builtin/03_analog/calibration.rb | Built-in Arduino example port. |
| examples/builtin/03_analog/fading.rb | Built-in Arduino example port. |
| examples/builtin/03_analog/smoothing.rb | Built-in Arduino example port. |
| examples/builtin/04_communication/ascii_table.rb | Built-in Arduino example port. |
| examples/builtin/04_communication/dimmer.rb | Built-in Arduino example port. |
| examples/builtin/04_communication/graph.rb | Built-in Arduino example port. |
| examples/builtin/04_communication/midi.rb | Built-in Arduino example port. |
| examples/builtin/04_communication/physical_pixel.rb | Built-in Arduino example port. |
| examples/builtin/04_communication/read_ascii_string.rb | Built-in Arduino example port. |
| examples/builtin/04_communication/serial_call_response.rb | Built-in Arduino example port. |
| examples/builtin/04_communication/serial_call_response_ascii.rb | Built-in Arduino example port. |
| examples/builtin/04_communication/virtual_color_mixer.rb | Built-in Arduino example port. |
| examples/builtin/05_control/arrays.rb | Built-in Arduino example port. |
| examples/builtin/05_control/for_loop_iteration.rb | Built-in Arduino example port. |
| examples/builtin/05_control/if_statement_conditional.rb | Built-in Arduino example port. |
| examples/builtin/05_control/switch_case.rb | Built-in Arduino example port. |
| examples/builtin/05_control/switch_case_2.rb | Built-in Arduino example port. |
| examples/builtin/05_control/while_statement_conditional.rb | Built-in Arduino example port. |
| examples/builtin/06_sensors/adxl3xx.rb | Built-in Arduino example port. |
| examples/builtin/06_sensors/knock.rb | Built-in Arduino example port. |
| examples/builtin/06_sensors/memsic2125.rb | Built-in Arduino example port. |
| examples/builtin/06_sensors/ping.rb | Built-in Arduino example port. |
| examples/builtin/07_display/bar_graph.rb | Built-in Arduino example port. |
| examples/builtin/07_display/row_column_scanning.rb | Built-in Arduino example port. |
| examples/builtin/08_strings/README.md | Notes on skipped String-dependent sketches; documents what’s ported. |
| examples/builtin/08_strings/character_analysis.rb | Built-in Arduino example port (String-free). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+316
to
+320
| def without_interrupts | ||
| ArduinoUNO.no_interrupts | ||
| yield | ||
| ArduinoUNO.interrupts | ||
| end |
Comment on lines
+959
to
+960
| def self.analog_read(pin); analog_read(pin); end | ||
| def self.analog_write(pin, value); analog_write(pin, value); end |
Comment on lines
+97
to
+105
| def arduino_base_print_func(base_arg, newline) | ||
| return nil unless integer_literal_node?(base_arg) | ||
| case @nd_value[base_arg].to_i | ||
| when 2 then newline ? "serial_println_bin" : "serial_print_bin" | ||
| when 8 then newline ? "serial_println_oct" : "serial_print_oct" | ||
| when 10 then newline ? "serial_println_int" : "serial_print_int" | ||
| when 16 then newline ? "serial_println_hex" : "serial_print_hex" | ||
| end | ||
| end |
Comment on lines
+77
to
+81
| base_fn = arduino_base_print_func(base_or_dec_arg, newline) | ||
| return nil unless base_fn | ||
|
|
||
| return "(" + base_fn + "((uint32_t)(" + compile_expr(value_arg) + ")), (mrb_int)0)" | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds comprehensive documentation and a suite of example sketches to the project, significantly expanding both the README and the available sample code. The main focus is to provide clear guidance on usage, demonstrate API options, and supply direct Ruby ports of Arduino built-in examples for the UNO board.
Documentation improvements:
README.mdhas been extensively updated to clarify usage, introduce two API styles (Arduino-compatible and Ruby-idiomatic), list supported APIs and libraries, and document available examples and tests. It now includes detailed tables and sections on hardware support and testing methodology. [1] [2]Example sketches added:
examples/builtin/01_basics,examples/builtin/02_digital, andexamples/builtin/03_analog. These cover analog/digital I/O, PWM, serial communication, tone generation, debouncing, state change detection, and more. Each example is well-commented and closely matches the corresponding Arduino documentation. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19]These changes make it much easier for users to get started, understand the API, and port or write their own Arduino-style sketches in Ruby.