microsoft / pxt-arcade

Arcade game editor based on Microsoft MakeCode
https://arcade.makecode.com
MIT License
477 stars 206 forks source link

analog read pin block does not work in the simulator #1210

Closed kevinjwalters closed 4 years ago

kevinjwalters commented 5 years ago

Describe the bug The analog read pin does not work in the current beta beta (0.13.22 5.19.9) simulator. It gives an error Program Error: Cannot read property 'analogReadPin' of null when the simulator executes the program. This is from the feather extensions intended for use on the PyGamer and occurs when D2 and/or D3 are used. Those pins are valid despite sounding like digital pins.

To Reproduce Steps to reproduce the behavior:

  1. Go to https://arcade.makecode.com/beta/ then select New Project
  2. Load feather extensions
  3. Make a simple program that uses analog read pin
  4. Run in simulator, observe error that flashes up.

Expected behavior Normally a fake value within the normal range appears in the simulator for hardware.

Screenshots

arcade-Input-Experiment-screenshot-simulatorprogramerror-20190814

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context The code does work on PyGamer.

Also discussed in: https://forum.makecode.com/t/analog-inputs-error-in-simulator/446

Code embedded in png:

arcade-Input-Experiment-v1

kevinjwalters commented 5 years ago

A workaround here to aid development productivity is to mock the value.

Is there anyway for code to tell that it's running in the simulator in a non-hacky way?