wokwi / wokwi-features

Wokwi Feature requests & Bug Reports
https://wokwi.com
73 stars 17 forks source link

Make a non-Arduino simulator for the RPi Pico #311

Closed eleciawhite closed 2 years ago

eleciawhite commented 2 years ago

I want to use Wokwi for a remote-classroom. However, the Arduino IDE is one I'm trying to get the students away from.

Can you make an RPi Pico Project that is C/C++ based? It would still hook to the Pico SDK as it does now. Instead of setup() and loop(), the new Project type would show a main function like:

#include "pico/stdlib.h"

const uint LED_PIN = 2;

int main() {
  gpio_init(LED_PIN);
  gpio_set_dir(LED_PIN, GPIO_OUT);
  while (true) {
    gpio_put(LED_PIN, 1);
    sleep_ms(250);
    gpio_put(LED_PIN, 0);
    sleep_ms(250);
  }
}

I want to be able to give students PWM code for an LED and have them modify it to hear a buzzer in driven by PWM. I also want them to be able to construct final projects (your peripheral list is great!).

urish commented 2 years ago

Thanks Elecia! I just opened this request for voting

arcostasi commented 2 years ago

It is possible to use many features of the Pico SDK with the Arduino core (Pico SDK). Here are some examples that may be useful until the oficial Pico SDK is available in Wokwi.

urish commented 2 years ago

First working prototype: https://wokwi.com/projects/new/pi-pico-sdk

It compiles against Pi Pico SDK 1.3.0. Only "main.c" is currently supported - you can add additional .h files and it'll probably work, but additional ".c" files won't get compiled.

@arcostasi Thanks for the comment! I did some testing and figured out that the Arduino core is missing some of the basic functionality (e.g. stdio_init_all() is missing), so now we're going to have native Pi Pico SDK builds.

arcostasi commented 2 years ago

Hooray, thanks @urish an alternative I found to add a file in c is instead of the ".h" was to include the ".c" as in the vector example

urish commented 2 years ago

Cool workaround :) Thanks for sharing!

urish commented 2 years ago

Good news - multiple .c/.cpp source file are now supported!

Here's @arcostasi's example without the "include" workaround: https://wokwi.com/projects/325323976447361620

And our beloved blink: https://wokwi.com/projects/325324198971966034