From fe5df7dc6d0071dfaf2cfdc136d0830aa588e2ef Mon Sep 17 00:00:00 2001 From: Eric Ratliff Date: Sun, 22 Feb 2026 08:07:42 -0600 Subject: [PATCH] Updated svg to make it more informative on readme --- docs/terminal-demo.svg | 196 ++++++++++++++++++++++++----------------- 1 file changed, 115 insertions(+), 81 deletions(-) diff --git a/docs/terminal-demo.svg b/docs/terminal-demo.svg index 5a8cfb2..0ca0a02 100644 --- a/docs/terminal-demo.svg +++ b/docs/terminal-demo.svg @@ -1,90 +1,124 @@ - + - - - - - + + + - anvil -- terminal + anvil -- from zero to tested in 30 seconds - - - $ - anvil new weather_station --template weather --board uno - + + $ anvil new blink --board uno + create blink/blink/blink.ino + create blink/lib/hal/hal.h + create blink/lib/app/blink_app.h your code goes here + create blink/test/mocks/mock_hal.h, sim_hal.h + create blink/test/test_unit.cpp your tests go here + create blink/build.sh, upload.sh, monitor.sh, test.sh + create blink/.anvil.toml, .anvilignore, .gitignore + done Project ready! cd blink + One command. Complete project. No boilerplate to write. + Let's look at what Anvil generated... - - create weather_station/weather_station/weather_station.ino - create weather_station/lib/app/weather_app.h - create weather_station/lib/hal/hal.h - create weather_station/lib/drivers/tmp36/tmp36.h - create weather_station/test/test_weather.cpp - create weather_station/test/test_unit.cpp - create weather_station/build.sh, build.bat - create weather_station/.anvil.toml - create weather_station/.anvilignore - ... 28 more files - done Project ready. cd weather_station && ./test.sh + + $ cat lib/app/blink_app.h // what did Anvil generate? + #include "hal.h" // the only dependency -- no Arduino.h + class BlinkApp { + public: + BlinkApp(Hal* hal) : hal_(hal) {} // real hardware OR test mock + void setup() { + hal_->pinMode(13, OUTPUT); + } + void loop() { + hal_->digitalWrite(13, HIGH); // LED on + hal_->delay(500); + hal_->digitalWrite(13, LOW); // LED off + hal_->delay(500); + } + }; + Clean C++. No hardware coupling. Change the delay, add Serial output, + read a sensor -- just edit this file. Now let's test it without a board... - - - $ - cd weather_station && ./test.sh - - - - [==========] Running 14 tests from 4 test suites. - [ PASSED ] WeatherMockTest.ReadsTemperature - [ PASSED ] WeatherSimTest.NoisyReadingsInRange - ... 10 more tests - [ PASSED ] Tmp36PolymorphismTest.AllImplsWorkThroughBasePointer - - - [==========] 14 tests ran. (12 ms total) - [ PASSED ] 14 tests. - - - - $ - ./upload.sh --monitor - - - - + + $ cat test/test_unit.cpp // the student writes a quick test + #include "blink_app.h" + #include "sim_hal.h" // simulated Arduino -- runs on laptop + TEST(BlinkTest, LedTurnsOn) { + SimHal hal; // fake hardware + BlinkApp app(&hal); // inject it + app.setup(); + app.loop(); + EXPECT_EQ(hal.getPin(13), LOW); // ended on LOW after blink + } + $ ./test.sh + [==========] Running 3 tests from 2 test suites. + [ PASSED ] BlinkTest.LedTurnsOn + [ PASSED ] BlinkTest.LedToggles + [ PASSED ] BlinkTest.SetsPinMode + [ PASSED ] 3 tests. (8 ms) + $ ./upload.sh --monitor + Upload complete. Opening serial monitor at 115200 baud. + Tests run on your laptop in milliseconds. No board needed. + Find bugs in 5 minutes instead of 2 hours staring at a serial monitor. +