-
Notifications
You must be signed in to change notification settings - Fork 83
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
The execute.ts function differs between the two examples (mega and normal boards) - this always trips me up between examples.
It seems to be because the new CPU has an offset second parameter:
this.cpu = new CPU(this.program, 0x2200);
Would it be possible to set board type on AVRRunner, and then do the offset depending on what the board is set to, so the user can just use the AvrRunner directly from avr8js without redeclaring it?
import { AVRRunner } from "avr8js";
new AVRRunner(hex, { board: 'mega' });
I also don't really know what portB/portC/portD refer to. I wonder whether the AVRRunner class could expose a pin(int pinNumber) function that calls portB.pinState(X) internally.
const arduino = new AVRRunner(hex, { board: 'mega' });
const ledController = new WS2812Controller(cols * rows);
// Send pin 6 state to the matrixController
arduino.addPinListener(6, (state) => {
ledController.feedValue(state, cpuNanos())
});
Or even tidier, the WS2812Controller could set up the listener itself:
// pin 12 is the pin set in the FastLED code example
ledController.setInputPin(arduino, 12);
Thanks!
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request