// In diagram.json these lines
// [ "pico:GP0", "$serialMonitor:RX", "", [] ],
// [ "pico:GP1", "$serialMonitor:TX", "", [] ],
// were removed, so that
// Serial instead of Serial1
// can be used. (RK)
// configuration macros so that cpp-excercises.h,
// utils.h etc work for different boards (STM32 C031C6, ESP32
// and Raspberry Pico), gcc compiler versions and IDEs
#define RASPI_PICO // so that utils.h works for all boards
#define RASPI RASPI_PICO_2 | RASPI_PICO_W | RASPI_PICO
#define WOKWI_USED
#ifdef WOKWI_USED
# ifdef RASPI
# define PRINTF_DOES_NOT_WORK
# include <stdio.h> // ??? does not enable printf for Wokwi Raspberry projects
# include "pico/stdlib.h" // ??? does not enable printf for Wokwi Raspberry projects
# endif
#endif // WOKWI_USED
#if __cpp_constexpr < 201603L // April 2025: The Wokwi Raspberry Compiler is old and restricted
# define OLD_COMPILER_INCOMPLETE_CONSTEXPR_MEMBER_FUNCTION
# define OLD_COMPILER_NO_VARIANT
??? raus
#endif
enum class Examples { // a list of all examples
First_Example, // see section ???
TrafficLights_in_C, // see section ???
TrafficLights_with_phases,
TrafficLights_FSM_with_busy_waiting,
TrafficLights_FSM_without_busy_waiting,
TrafficLights_table_driven_state_machine,
// Digital_Out, // see section ???
// Digital_In, // see section ???
AnalogIn_read_raw_values_in_C, // see section ???
AnalogIn_read_onboard_voltmeter_with_class, // see section ???
AnalogIn_Voltmeter,
AnalogIn_Temperature,
AnalogOut_Fade_LED_in_absolute_steps_ohne_Klassen,
AnalogOut_Fade_LED_in_percent_ohne_Klassen,
AnalogOut_Fade_LED_with_PWM_DA_Converter,
#ifdef ESP32
AnalogOut_Fade_LED_with_DAC_DA_Converter,
#endif
HC_SR04_Ultrasonic_Distance, // see section ???
last_value_without_comma
};
Examples example = Examples::AnalogOut_Fade_LED_in_absolute_steps_ohne_Klassen;
#include <functional>
#include "utils.h"
#include "Trafficlights-in-C.h"
#include "Trafficlights.h"
#include "cpp-exercises.h"
void setup()
{
setup_serial_port();
Serial.println("Raspberry Pi Pico circuit for Embedded C++ (www.rkaiser.de)");
N_Cpp_Exercises::setup(example);
}
void loop()
{
N_Cpp_Exercises::loop(example);
}