diff --git a/examples/breakout_bme280/bme280_basic.cpp b/examples/breakout_bme280/bme280_basic.cpp index 8ba35a5e..1c1ad764 100644 --- a/examples/breakout_bme280/bme280_basic.cpp +++ b/examples/breakout_bme280/bme280_basic.cpp @@ -12,8 +12,10 @@ BME280 bme280(&i2c); int main() { +#ifdef PICO_DEFAULT_LED_PIN gpio_init(PICO_DEFAULT_LED_PIN); gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT); +#endif stdio_init_all(); diff --git a/examples/breakout_bme688/bme688_forced.cpp b/examples/breakout_bme688/bme688_forced.cpp index 63855507..67e0ac0b 100644 --- a/examples/breakout_bme688/bme688_forced.cpp +++ b/examples/breakout_bme688/bme688_forced.cpp @@ -15,8 +15,10 @@ I2C i2c(BOARD::BREAKOUT_GARDEN); BME68X bme68x(&i2c); int main() { +#ifdef PICO_DEFAULT_LED_PIN gpio_init(PICO_DEFAULT_LED_PIN); gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT); +#endif stdio_init_all(); diff --git a/examples/breakout_bme688/bme688_parallel.cpp b/examples/breakout_bme688/bme688_parallel.cpp index b5bc0d73..74d177a4 100644 --- a/examples/breakout_bme688/bme688_parallel.cpp +++ b/examples/breakout_bme688/bme688_parallel.cpp @@ -28,8 +28,10 @@ uint16_t durations[profile_length] = { 5, 2, 10, 30, 5, 5, 5, 5, 5, 5 }; int main() { +#ifdef PICO_DEFAULT_LED_PIN gpio_init(PICO_DEFAULT_LED_PIN); gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT); +#endif stdio_init_all(); diff --git a/examples/breakout_bmp280/bmp280_basic.cpp b/examples/breakout_bmp280/bmp280_basic.cpp index 76511c3b..188b1c56 100644 --- a/examples/breakout_bmp280/bmp280_basic.cpp +++ b/examples/breakout_bmp280/bmp280_basic.cpp @@ -12,8 +12,10 @@ BMP280 bmp280(&i2c); int main() { +#ifdef PICO_DEFAULT_LED_PIN gpio_init(PICO_DEFAULT_LED_PIN); gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT); +#endif stdio_init_all(); diff --git a/examples/breakout_dotmatrix/bargraph/bargraph.cpp b/examples/breakout_dotmatrix/bargraph/bargraph.cpp index 819e3564..50bc4b70 100644 --- a/examples/breakout_dotmatrix/bargraph/bargraph.cpp +++ b/examples/breakout_dotmatrix/bargraph/bargraph.cpp @@ -15,13 +15,18 @@ uint8_t values[HALF_WIDTH] = { 0, 0, 0, 0, 0 }; uint8_t next_value = 0; int main() { +#ifdef PICO_DEFAULT_LED_PIN gpio_init(PICO_DEFAULT_LED_PIN); gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT); +#endif display.init(); while(true) { + +#ifdef PICO_DEFAULT_LED_PIN gpio_put(PICO_DEFAULT_LED_PIN, true); +#endif absolute_time_t at = get_absolute_time(); uint64_t t = to_us_since_boot(at) / 1000000; @@ -49,7 +54,9 @@ int main() { display.show(); +#ifdef PICO_DEFAULT_LED_PIN gpio_put(PICO_DEFAULT_LED_PIN, false); +#endif sleep_ms(1000 / HEIGHT); } diff --git a/examples/breakout_dotmatrix/eyes/eyes.cpp b/examples/breakout_dotmatrix/eyes/eyes.cpp index 05bf455d..ea5dedf3 100644 --- a/examples/breakout_dotmatrix/eyes/eyes.cpp +++ b/examples/breakout_dotmatrix/eyes/eyes.cpp @@ -17,8 +17,10 @@ void eye(uint8_t x, uint8_t y) { } int main() { +#ifdef PICO_DEFAULT_LED_PIN gpio_init(PICO_DEFAULT_LED_PIN); gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT); +#endif display.init(); @@ -50,7 +52,9 @@ int main() { // This gives our crude blink code time to not look like a random flicker display.show(); +#ifdef PICO_DEFAULT_LED_PIN gpio_put(PICO_DEFAULT_LED_PIN, led_toggle); +#endif led_toggle = !led_toggle; sleep_ms(100); diff --git a/examples/breakout_dotmatrix/image/image.cpp b/examples/breakout_dotmatrix/image/image.cpp index ed678cd8..5cf901cf 100644 --- a/examples/breakout_dotmatrix/image/image.cpp +++ b/examples/breakout_dotmatrix/image/image.cpp @@ -27,8 +27,10 @@ uint8_t offset = 0; int main() { +#ifdef PICO_DEFAULT_LED_PIN gpio_init(PICO_DEFAULT_LED_PIN); gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT); +#endif display.init(); @@ -36,7 +38,9 @@ int main() { display.set_image(image, IMAGE_WIDTH, IMAGE_HEIGHT, offset, 0, true, false, ON_LEVEL, IMAGE_PADDING); display.show(); +#ifdef PICO_DEFAULT_LED_PIN gpio_put(PICO_DEFAULT_LED_PIN, led_toggle); +#endif led_toggle = !led_toggle; sleep_ms(500); diff --git a/examples/breakout_dotmatrix/timer/timer.cpp b/examples/breakout_dotmatrix/timer/timer.cpp index eb865de3..a60b7b4d 100644 --- a/examples/breakout_dotmatrix/timer/timer.cpp +++ b/examples/breakout_dotmatrix/timer/timer.cpp @@ -11,8 +11,10 @@ BreakoutDotMatrix display(&i2c); bool led_toggle = false; int main() { +#ifdef PICO_DEFAULT_LED_PIN gpio_init(PICO_DEFAULT_LED_PIN); gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT); +#endif display.init(); display.show(); @@ -37,7 +39,9 @@ int main() { display.set_character(5, right); display.show(); +#ifdef PICO_DEFAULT_LED_PIN gpio_put(PICO_DEFAULT_LED_PIN, led_toggle); +#endif led_toggle = !led_toggle; sleep_ms(1000 / 60); diff --git a/examples/breakout_encoder/demo.cpp b/examples/breakout_encoder/demo.cpp index aeb627d7..2f23afcf 100644 --- a/examples/breakout_encoder/demo.cpp +++ b/examples/breakout_encoder/demo.cpp @@ -42,8 +42,10 @@ void count_changed(int16_t count) { } int main() { +#ifdef PICO_DEFAULT_LED_PIN gpio_init(PICO_DEFAULT_LED_PIN); gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT); +#endif stdio_init_all(); @@ -57,7 +59,9 @@ int main() { enc.clear_interrupt_flag(); while(true) { +#ifdef PICO_DEFAULT_LED_PIN gpio_put(PICO_DEFAULT_LED_PIN, toggle); +#endif toggle = !toggle; if(enc.get_interrupt_flag()) { @@ -75,7 +79,9 @@ int main() { } else { printf("Encoder not found :'(\n"); +#ifdef PICO_DEFAULT_LED_PIN gpio_put(PICO_DEFAULT_LED_PIN, true); +#endif } return 0; diff --git a/examples/breakout_ioexpander/adc/adc.cpp b/examples/breakout_ioexpander/adc/adc.cpp index 0e8de8ef..1a049267 100644 --- a/examples/breakout_ioexpander/adc/adc.cpp +++ b/examples/breakout_ioexpander/adc/adc.cpp @@ -11,8 +11,10 @@ BreakoutIOExpander ioe(0x18); bool toggle = false; int main() { +#ifdef PICO_DEFAULT_LED_PIN gpio_init(PICO_DEFAULT_LED_PIN); gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT); +#endif stdio_init_all(); @@ -23,7 +25,9 @@ int main() { ioe.set_mode(IOE_ADC_PIN, IOExpander::PIN_ADC); while(true) { +#ifdef PICO_DEFAULT_LED_PIN gpio_put(PICO_DEFAULT_LED_PIN, toggle); +#endif toggle = !toggle; float voltage = ioe.input_as_voltage(IOE_ADC_PIN); @@ -35,7 +39,10 @@ int main() { } else { printf("IOExpander not found :'(\n"); + +#ifdef PICO_DEFAULT_LED_PIN gpio_put(PICO_DEFAULT_LED_PIN, true); +#endif } return 0; diff --git a/examples/breakout_ioexpander/button/button.cpp b/examples/breakout_ioexpander/button/button.cpp index 03035c71..7edf701e 100644 --- a/examples/breakout_ioexpander/button/button.cpp +++ b/examples/breakout_ioexpander/button/button.cpp @@ -12,8 +12,10 @@ BreakoutIOExpander ioe(0x18); bool last_state = true; int main() { +#ifdef PICO_DEFAULT_LED_PIN gpio_init(PICO_DEFAULT_LED_PIN); gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT); +#endif stdio_init_all(); @@ -27,11 +29,15 @@ int main() { if(state != last_state) { if(state) { printf("Button has been released\n"); +#ifdef PICO_DEFAULT_LED_PIN gpio_put(PICO_DEFAULT_LED_PIN, false); +#endif } else { printf("Button has been pressed\n"); +#ifdef PICO_DEFAULT_LED_PIN gpio_put(PICO_DEFAULT_LED_PIN, true); +#endif } last_state = state; @@ -42,7 +48,9 @@ int main() { } else { printf("IOExpander not found :'(\n"); +#ifdef PICO_DEFAULT_LED_PIN gpio_put(PICO_DEFAULT_LED_PIN, true); +#endif } return 0; diff --git a/examples/breakout_ioexpander/servo/servo.cpp b/examples/breakout_ioexpander/servo/servo.cpp index 860cb17f..dd949ec6 100644 --- a/examples/breakout_ioexpander/servo/servo.cpp +++ b/examples/breakout_ioexpander/servo/servo.cpp @@ -20,8 +20,10 @@ BreakoutIOExpander ioe(0x18); bool toggle = false; int main() { +#ifdef PICO_DEFAULT_LED_PIN gpio_init(PICO_DEFAULT_LED_PIN); gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT); +#endif stdio_init_all(); @@ -34,7 +36,9 @@ int main() { ioe.set_mode(IOE_SERVO_PIN, IOExpander::PIN_PWM); while(true) { +#ifdef PICO_DEFAULT_LED_PIN gpio_put(PICO_DEFAULT_LED_PIN, toggle); +#endif toggle = !toggle; absolute_time_t at = get_absolute_time(); @@ -53,7 +57,9 @@ int main() { } else { printf("IOExpander not found :'(\n"); +#ifdef PICO_DEFAULT_LED_PIN gpio_put(PICO_DEFAULT_LED_PIN, true); +#endif } return 0; diff --git a/examples/breakout_matrix11x7/demo.cpp b/examples/breakout_matrix11x7/demo.cpp index 80449bf2..c196d8f9 100644 --- a/examples/breakout_matrix11x7/demo.cpp +++ b/examples/breakout_matrix11x7/demo.cpp @@ -8,8 +8,10 @@ I2C i2c(BOARD::BREAKOUT_GARDEN); BreakoutMatrix11x7 matrix11x7(&i2c, 0x75); int main() { +#ifdef PICO_DEFAULT_LED_PIN gpio_init(PICO_DEFAULT_LED_PIN); gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT); +#endif matrix11x7.init(); @@ -20,7 +22,9 @@ int main() { } } matrix11x7.update(0); +#ifdef PICO_DEFAULT_LED_PIN gpio_put(PICO_DEFAULT_LED_PIN, true); +#endif sleep_ms(1000); for(auto x = 0; x < matrix11x7.WIDTH; x++) { for(auto y = 0; y < matrix11x7.HEIGHT; y++) { @@ -28,7 +32,9 @@ int main() { } } matrix11x7.update(0); +#ifdef PICO_DEFAULT_LED_PIN gpio_put(PICO_DEFAULT_LED_PIN, false); +#endif sleep_ms(1000); } diff --git a/examples/breakout_mics6814/demo.cpp b/examples/breakout_mics6814/demo.cpp index 31a9de42..c77aa6bd 100644 --- a/examples/breakout_mics6814/demo.cpp +++ b/examples/breakout_mics6814/demo.cpp @@ -10,8 +10,10 @@ BreakoutMICS6814 mics6814; int main() { stdio_init_all(); +#ifdef PICO_DEFAULT_LED_PIN gpio_init(PICO_DEFAULT_LED_PIN); gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT); +#endif mics6814.init(); mics6814.set_heater(true); diff --git a/examples/breakout_potentiometer/demo.cpp b/examples/breakout_potentiometer/demo.cpp index 8de69c65..979019d8 100644 --- a/examples/breakout_potentiometer/demo.cpp +++ b/examples/breakout_potentiometer/demo.cpp @@ -32,8 +32,10 @@ void from_hsv(float h, float s, float v, uint8_t &r, uint8_t &g, uint8_t &b) { } int main() { +#ifdef PICO_DEFAULT_LED_PIN gpio_init(PICO_DEFAULT_LED_PIN); gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT); +#endif stdio_init_all(); @@ -43,7 +45,9 @@ int main() { //pot.set_direction(BreakoutPotentiometer::DIRECTION_CCW); // Uncomment this to flip the direction while(true) { +#ifdef PICO_DEFAULT_LED_PIN gpio_put(PICO_DEFAULT_LED_PIN, toggle); +#endif toggle = !toggle; float percent = pot.read(); @@ -58,7 +62,9 @@ int main() { } else { printf("Potentiometer not found :'(\n"); +#ifdef PICO_DEFAULT_LED_PIN gpio_put(PICO_DEFAULT_LED_PIN, true); +#endif } return 0; diff --git a/examples/breakout_rtc/demo.cpp b/examples/breakout_rtc/demo.cpp index c0c3669d..ce0e5139 100644 --- a/examples/breakout_rtc/demo.cpp +++ b/examples/breakout_rtc/demo.cpp @@ -10,8 +10,10 @@ BreakoutRTC rtc(&i2c); int main() { stdio_init_all(); +#ifdef PICO_DEFAULT_LED_PIN gpio_init(PICO_DEFAULT_LED_PIN); gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT); +#endif if(!rtc.init()) { printf("Init failed! Check your connections and i2c pin choices.\n"); @@ -36,9 +38,13 @@ int main() { // Update the locally stored time from the RTC if(rtc.update_time()) { printf("Date: %s, Time: %s\n", rtc.string_date(), rtc.string_time()); +#ifdef PICO_DEFAULT_LED_PIN gpio_put(PICO_DEFAULT_LED_PIN, true); +#endif sleep_ms(100); +#ifdef PICO_DEFAULT_LED_PIN gpio_put(PICO_DEFAULT_LED_PIN, false); +#endif } } sleep_ms(100); diff --git a/examples/breakout_sgp30/demo.cpp b/examples/breakout_sgp30/demo.cpp index c743712e..fe93c5a3 100644 --- a/examples/breakout_sgp30/demo.cpp +++ b/examples/breakout_sgp30/demo.cpp @@ -21,8 +21,10 @@ int main() { uint16_t eCO2, TVOC; uint16_t rawCO2, rawTVOC; +#ifdef PICO_DEFAULT_LED_PIN gpio_init(PICO_DEFAULT_LED_PIN); gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT); +#endif stdio_init_all(); @@ -47,12 +49,14 @@ int main() { uint16_t j = 0; while(true) { j++; +#ifdef PICO_DEFAULT_LED_PIN for(uint8_t i=0; i last_time + MAIN_LOOP_TIME_US) { last_time = current_time; +#ifdef PICO_DEFAULT_LED_PIN gpio_put(PICO_DEFAULT_LED_PIN, true); // Show the screen refresh has stated +#endif // If the user has wired up their encoder switch, and it is pressed, set the encoder count to zero if(ENCODER_SWITCH_PIN != PIN_UNUSED && gpio_get(ENCODER_SWITCH_PIN)) { @@ -384,7 +388,10 @@ int main() { } st7789.update(&graphics); // Refresh the screen + +#ifdef PICO_DEFAULT_LED_PIN gpio_put(PICO_DEFAULT_LED_PIN, false); // Show the screen refresh has ended +#endif } } } \ No newline at end of file diff --git a/examples/pico_motor_shim/motorshim_motor_song.cpp b/examples/pico_motor_shim/motorshim_motor_song.cpp index 134295fc..09630680 100644 --- a/examples/pico_motor_shim/motorshim_motor_song.cpp +++ b/examples/pico_motor_shim/motorshim_motor_song.cpp @@ -59,9 +59,11 @@ bool check_button_toggle() { int main() { stdio_init_all(); +#ifdef PICO_DEFAULT_LED_PIN //Initialise the LED. We use this to indicate that the sequence is running. gpio_init(PICO_DEFAULT_LED_PIN); gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT); +#endif // Se the two motor's decay modes motor_1.decay_mode(DECAY_MODE); @@ -76,8 +78,11 @@ int main() { while(true) { // Has the button been toggled? if(check_button_toggle()) { + +#ifdef PICO_DEFAULT_LED_PIN // Turn the Pico's LED on to show that the song has started gpio_put(PICO_DEFAULT_LED_PIN, true); +#endif // Play the song for(uint i = 0; i < SONG_LENGTH && check_button_toggle(); i++) { @@ -117,7 +122,9 @@ int main() { button_toggle = false; // The song has finished, so turn off the Pico's LED and disable the motors +#ifdef PICO_DEFAULT_LED_PIN gpio_put(PICO_DEFAULT_LED_PIN, false); +#endif motor_1.disable(); motor_2.disable(); } diff --git a/examples/pico_pot_explorer/pico_pot_explorer.cpp b/examples/pico_pot_explorer/pico_pot_explorer.cpp index a375b8f0..96c98d24 100644 --- a/examples/pico_pot_explorer/pico_pot_explorer.cpp +++ b/examples/pico_pot_explorer/pico_pot_explorer.cpp @@ -45,8 +45,10 @@ void from_hsv(float h, float s, float v, uint8_t &r, uint8_t &g, uint8_t &b) { } int main() { +#ifdef PICO_DEFAULT_LED_PIN gpio_init(PICO_DEFAULT_LED_PIN); gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT); +#endif stdio_init_all(); @@ -56,7 +58,9 @@ int main() { printf("Potentiometer found...\n"); while(true) { +#ifdef PICO_DEFAULT_LED_PIN gpio_put(PICO_DEFAULT_LED_PIN, toggle); +#endif toggle = !toggle; float percent = pot.read(); @@ -113,7 +117,9 @@ int main() { } else { printf("No Potentiometer found :'(\n"); +#ifdef PICO_DEFAULT_LED_PIN gpio_put(PICO_DEFAULT_LED_PIN, true); +#endif } return 0;