Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ forking is welcome and always will be, just under your own name.
| State | Riverpod 3.x with codegen |
| Canvas | Custom `CustomPainter` |
| Editor | `re_editor` |
| AVR emulation | `avr8_dart` (native), `avr8js` (web) |
| AVR emulation | `avr8_dart` (native, and WebAssembly on the web) |
| Analog solver | `ngspice_dart` — a pure-Dart port, no FFI or native libngspice |
| Audio | `flutter_soloud` (native), Web Audio (web) |
| Multi-window | `multiview_desktop` |
Expand Down
4 changes: 2 additions & 2 deletions lib/core/telemetry/otel_backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// `dartastic_opentelemetry`'s OTLP exporters import `dart:io`, so they can only
// compile for native targets. Native builds use the real backend; the web (and
// wasm) build overrides to the stub, which never references the package —
// keeping `dart:io` out of the web compilation. This mirrors the `avr_interop`
// idiom used elsewhere in the app (native default, web override).
// keeping `dart:io` out of the web compilation (native default, web
// override).
//
// Both variants expose `Future<TracingService> initOpenTelemetry(OtelConfig)`.
export 'otel_backend_io.dart' if (dart.library.js_interop) 'otel_backend_stub.dart';
26 changes: 26 additions & 0 deletions packages/pinbench_parts/assets/parts/aht20/aht20.pdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# AHT20 temperature and humidity sensor.
#
# The I²C answer to "DHT11/22": the same two readings, but over a bus the
# emulator already models, where a DHT's single-wire timing would need a part
# that can drive a pin. Served by `LOGIC aht20` at its fixed address, 0x38:
# a status byte, 20 bits each of humidity and temperature, and a CRC.

PART "Temperature + Humidity (AHT20)"
ID aht20
CATEGORY sensors
DESCRIPTION "I²C temperature and relative humidity sensor"

SIZE 10.16mm 12.7mm
SVG "aht20.svg"

LOGIC aht20

PINS
vcc 4px 68px power "VIN"
gnd 20px 68px ground "GND"
scl 36px 68px input "SCL"
sda 52px 68px passive "SDA"

PROPERTIES
temperature number 25 unit:"°C" label:"Temperature"
humidity number 50 unit:"%" label:"Relative humidity"
18 changes: 18 additions & 0 deletions packages/pinbench_parts/assets/parts/aht20/aht20.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions packages/pinbench_parts/assets/parts/battery_9v/battery_9v.pdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 9 V battery (PP3).
#
# Like the coin cell: an ideal source. It does not sag under load or run
# down. Enough to power a circuit off-board, or to show what 9 V does to an
# LED with no resistor.

PART "Battery (9V)"
ID battery_9v
CATEGORY basic
DESCRIPTION "9V PP3 battery"

SIZE 48.26mm 25.4mm
SVG "battery_9v.svg"

PINS
plus 292px 52px power "+"
minus 292px 100px ground "-"

PROPERTIES
voltage number 9 unit:"V" label:"Battery voltage"

BEHAVIOR
physics.voltage = max(prop.voltage, 0)

PHYSICS voltageSource
n1 = plus
n2 = minus
12 changes: 12 additions & 0 deletions packages/pinbench_parts/assets/parts/battery_9v/battery_9v.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions packages/pinbench_parts/assets/parts/bh1750/bh1750.pdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# BH1750 ambient light sensor on the GY-302 module.
#
# An I²C part: everything the sketch sees is two bytes of result, so the whole
# behaviour is `LOGIC bh1750` serving them. The logic tracks the opcodes the
# sketch sends (the measurement mode and time) in STATE, and answers 0 until a
# measurement has been asked for, as a freshly powered chip does.
#
# ADDR low or unconnected puts it at 0x23; tied to 5V or 3.3V, at 0x5C. It is
# only acknowledged when powered and wired to A4/A5.

PART "Light Sensor (BH1750)"
ID bh1750
CATEGORY sensors
DESCRIPTION "I²C ambient light sensor, 1–65535 lx"

SIZE 12.7mm 19.05mm
SVG "bh1750.svg"

LOGIC bh1750

PINS
vcc 4px 116px power "VCC"
gnd 20px 116px ground "GND"
scl 36px 116px input "SCL"
sda 52px 116px passive "SDA"
addr 68px 116px input "ADDR"

PROPERTIES
illuminance number 250 unit:"lx" label:"Light level"

STATE
# The last measurement opcode the sketch sent; 0 until it sends one.
mode integer 0
# Measurement time register. 69 is the chip's default; libraries change it
# to trade range for resolution.
mtreg integer 69
23 changes: 23 additions & 0 deletions packages/pinbench_parts/assets/parts/bh1750/bh1750.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions packages/pinbench_parts/assets/parts/ds1307/ds1307.pdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# DS1307 real-time clock module.
#
# An I²C part served by `LOGIC ds1307`: seven BCD time registers, plus control
# and 56 bytes of RAM that the bus stores and reads back on its own. The clock
# counts simulated time, so it keeps pace with millis() and stops while the run
# is paused.
#
# "Clock at start" picks between a module whose battery kept it set (it starts
# at the computer's current time) and a fresh chip, halted at 2000-01-01 until
# the sketch sets it — the case `if (!rtc.isrunning()) rtc.adjust(...)` is for.
#
# The DS1307 needs 5 V; wired to 3.3V it does not answer.

PART "Real-Time Clock (DS1307)"
ID ds1307
CATEGORY sensors
DESCRIPTION "I²C real-time clock with battery backup"

SIZE 20.32mm 15.24mm
SVG "ds1307.svg"

LOGIC ds1307

PINS
gnd 36px 84px ground "GND"
vcc 52px 84px power "VCC"
sda 68px 84px passive "SDA"
scl 84px 84px input "SCL"

PROPERTIES
startsAt enum now options:"now,unset" label:"Clock at start"

STATE
booted boolean false
# Clock-halt bit (bit 7 of the seconds register).
halted boolean false
# The time, as seconds since 2000-01-01, when it was last set...
baseSeconds decimal 0
# ...and the simulated millisecond it was set at. The time now is the one
# plus however far the other has moved on.
anchorMs decimal 0
22 changes: 22 additions & 0 deletions packages/pinbench_parts/assets/parts/ds1307/ds1307.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions packages/pinbench_parts/assets/parts/lm35/lm35.pdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# LM35 analog temperature sensor (TO-92).
#
# Vout = 10 mV/°C from 0 V at 0 °C, so 250 mV at 25 °C. Wired with a single
# supply, as in every Arduino tutorial, it cannot go below 0 V, so it reads
# 2 °C to 150 °C. Modelled as a voltage source between Vout and GND; +Vs is
# there because the real part needs it, and the model does not read it.
#
# Legs left to right with the flat face towards you: +Vs, Vout, GND.

PART "Temperature Sensor (LM35)"
ID lm35
CATEGORY sensors
DESCRIPTION "Analog temperature sensor, 10 mV/°C"

SIZE 7.62mm 10.16mm
SVG "lm35.svg"

PINS
vs 4px 52px power "+Vs"
vout 20px 52px output "Vout"
gnd 36px 52px ground "GND"

PROPERTIES
temperature number 25 unit:"°C" label:"Temperature"

BEHAVIOR
physics.voltage = clamp(prop.temperature, 2, 150) * 0.01

PHYSICS voltageSource
n1 = vout
n2 = gnd
7 changes: 7 additions & 0 deletions packages/pinbench_parts/assets/parts/lm35/lm35.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions packages/pinbench_parts/assets/parts/mpu6050/mpu6050.pdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# MPU-6050 accelerometer and gyroscope on the GY-521 module.
#
# An I²C part served by `LOGIC mpu6050`: WHO_AM_I, the power and range
# registers, and the 14-byte sample from 0x3B. Like the chip it boots asleep,
# so a sketch that never clears the sleep bit reads zeros, and it scales each
# reading to the range the sketch selected.
#
# The readings are properties: set the tilt and rotation you want the sketch to
# see. At rest and level, a sensor feels 1 g on Z.
#
# AD0 low or unconnected puts it at 0x68; tied to 5V or 3.3V, at 0x69. XDA,
# XCL and INT are there because the module has them; they are not modelled.

PART "Accelerometer + Gyro (MPU-6050)"
ID mpu6050
CATEGORY sensors
DESCRIPTION "I²C 6-axis motion sensor"

SIZE 20.32mm 15.24mm
SVG "mpu6050.svg"

LOGIC mpu6050

PINS
vcc 4px 84px power "VCC"
gnd 20px 84px ground "GND"
scl 36px 84px input "SCL"
sda 52px 84px passive "SDA"
xda 68px 84px passive "XDA"
xcl 84px 84px passive "XCL"
ad0 100px 84px input "AD0"
int 116px 84px output "INT"

PROPERTIES
accelX number 0 unit:"g" label:"Acceleration X"
accelY number 0 unit:"g" label:"Acceleration Y"
accelZ number 1 unit:"g" label:"Acceleration Z"
gyroX number 0 unit:"°/s" label:"Rotation X"
gyroY number 0 unit:"°/s" label:"Rotation Y"
gyroZ number 0 unit:"°/s" label:"Rotation Z"
temperature number 25 unit:"°C" label:"Die temperature"

STATE
# Set once the power-on register values have been published this run.
booted boolean false
# PWR_MGMT_1, GYRO_CONFIG and ACCEL_CONFIG as the sketch last wrote them.
# 0x40 is asleep, the chip's power-on value.
powerManagement integer 64
gyroConfig integer 0
accelConfig integer 0
35 changes: 35 additions & 0 deletions packages/pinbench_parts/assets/parts/mpu6050/mpu6050.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Capacitive soil moisture sensor (v1.2).
#
# The output falls as the soil gets wetter: about 2.8 V in dry air down to
# about 1.3 V in water, which is roughly analogRead() 570 dry and 265 wet on a
# 5 V board. Calibrating those two numbers is the first step of every
# soil-moisture tutorial, so the model keeps the inverted, offset range rather
# than a tidy 0–5 V.
#
# Modelled as a voltage source between AOUT and GND. VCC is there because the
# real module needs it; the model does not read it.

PART "Soil Moisture Sensor"
ID soil_moisture
CATEGORY sensors
DESCRIPTION "Capacitive soil moisture probe with analog output"

SIZE 10.16mm 35.56mm
SVG "soil_moisture.svg"

PINS
gnd 4px 4px ground "GND"
vcc 20px 4px power "VCC"
aout 36px 4px output "AOUT"

PROPERTIES
moisture number 40 unit:"%" label:"Soil moisture"
dryVolts number 2.8 unit:"V" label:"Output in dry air"
wetVolts number 1.3 unit:"V" label:"Output in water"

STATE
level decimal 0

BEHAVIOR
state.level = clamp(prop.moisture, 0, 100) / 100
physics.voltage = prop.dryVolts - state.level * (prop.dryVolts - prop.wetVolts)

PHYSICS voltageSource
n1 = aout
n2 = gnd
Loading
Loading