kopia lustrzana https://github.com/pimoroni/pimoroni-pico
C++: Don't assume PICO_DEFAULT_LED_PIN is defined.
rodzic
2d28880529
commit
b548d67609
|
@ -12,8 +12,10 @@ BME280 bme280(&i2c);
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||||
|
#endif
|
||||||
|
|
||||||
stdio_init_all();
|
stdio_init_all();
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,10 @@ I2C i2c(BOARD::BREAKOUT_GARDEN);
|
||||||
BME68X bme68x(&i2c);
|
BME68X bme68x(&i2c);
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||||
|
#endif
|
||||||
|
|
||||||
stdio_init_all();
|
stdio_init_all();
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,10 @@ uint16_t durations[profile_length] = { 5, 2, 10, 30, 5, 5, 5, 5, 5, 5 };
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||||
|
#endif
|
||||||
|
|
||||||
stdio_init_all();
|
stdio_init_all();
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,10 @@ BMP280 bmp280(&i2c);
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||||
|
#endif
|
||||||
|
|
||||||
stdio_init_all();
|
stdio_init_all();
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,18 @@ uint8_t values[HALF_WIDTH] = { 0, 0, 0, 0, 0 };
|
||||||
uint8_t next_value = 0;
|
uint8_t next_value = 0;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||||
|
#endif
|
||||||
|
|
||||||
display.init();
|
display.init();
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
|
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, true);
|
gpio_put(PICO_DEFAULT_LED_PIN, true);
|
||||||
|
#endif
|
||||||
|
|
||||||
absolute_time_t at = get_absolute_time();
|
absolute_time_t at = get_absolute_time();
|
||||||
uint64_t t = to_us_since_boot(at) / 1000000;
|
uint64_t t = to_us_since_boot(at) / 1000000;
|
||||||
|
@ -49,7 +54,9 @@ int main() {
|
||||||
|
|
||||||
display.show();
|
display.show();
|
||||||
|
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, false);
|
gpio_put(PICO_DEFAULT_LED_PIN, false);
|
||||||
|
#endif
|
||||||
|
|
||||||
sleep_ms(1000 / HEIGHT);
|
sleep_ms(1000 / HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,10 @@ void eye(uint8_t x, uint8_t y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||||
|
#endif
|
||||||
|
|
||||||
display.init();
|
display.init();
|
||||||
|
|
||||||
|
@ -50,7 +52,9 @@ int main() {
|
||||||
// This gives our crude blink code time to not look like a random flicker
|
// This gives our crude blink code time to not look like a random flicker
|
||||||
display.show();
|
display.show();
|
||||||
|
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, led_toggle);
|
gpio_put(PICO_DEFAULT_LED_PIN, led_toggle);
|
||||||
|
#endif
|
||||||
led_toggle = !led_toggle;
|
led_toggle = !led_toggle;
|
||||||
|
|
||||||
sleep_ms(100);
|
sleep_ms(100);
|
||||||
|
|
|
@ -27,8 +27,10 @@ uint8_t offset = 0;
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||||
|
#endif
|
||||||
|
|
||||||
display.init();
|
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.set_image(image, IMAGE_WIDTH, IMAGE_HEIGHT, offset, 0, true, false, ON_LEVEL, IMAGE_PADDING);
|
||||||
display.show();
|
display.show();
|
||||||
|
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, led_toggle);
|
gpio_put(PICO_DEFAULT_LED_PIN, led_toggle);
|
||||||
|
#endif
|
||||||
led_toggle = !led_toggle;
|
led_toggle = !led_toggle;
|
||||||
|
|
||||||
sleep_ms(500);
|
sleep_ms(500);
|
||||||
|
|
|
@ -11,8 +11,10 @@ BreakoutDotMatrix display(&i2c);
|
||||||
bool led_toggle = false;
|
bool led_toggle = false;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||||
|
#endif
|
||||||
|
|
||||||
display.init();
|
display.init();
|
||||||
display.show();
|
display.show();
|
||||||
|
@ -37,7 +39,9 @@ int main() {
|
||||||
display.set_character(5, right);
|
display.set_character(5, right);
|
||||||
display.show();
|
display.show();
|
||||||
|
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, led_toggle);
|
gpio_put(PICO_DEFAULT_LED_PIN, led_toggle);
|
||||||
|
#endif
|
||||||
led_toggle = !led_toggle;
|
led_toggle = !led_toggle;
|
||||||
|
|
||||||
sleep_ms(1000 / 60);
|
sleep_ms(1000 / 60);
|
||||||
|
|
|
@ -42,8 +42,10 @@ void count_changed(int16_t count) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||||
|
#endif
|
||||||
|
|
||||||
stdio_init_all();
|
stdio_init_all();
|
||||||
|
|
||||||
|
@ -57,7 +59,9 @@ int main() {
|
||||||
enc.clear_interrupt_flag();
|
enc.clear_interrupt_flag();
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, toggle);
|
gpio_put(PICO_DEFAULT_LED_PIN, toggle);
|
||||||
|
#endif
|
||||||
toggle = !toggle;
|
toggle = !toggle;
|
||||||
|
|
||||||
if(enc.get_interrupt_flag()) {
|
if(enc.get_interrupt_flag()) {
|
||||||
|
@ -75,7 +79,9 @@ int main() {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("Encoder not found :'(\n");
|
printf("Encoder not found :'(\n");
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, true);
|
gpio_put(PICO_DEFAULT_LED_PIN, true);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -11,8 +11,10 @@ BreakoutIOExpander ioe(0x18);
|
||||||
bool toggle = false;
|
bool toggle = false;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||||
|
#endif
|
||||||
|
|
||||||
stdio_init_all();
|
stdio_init_all();
|
||||||
|
|
||||||
|
@ -23,7 +25,9 @@ int main() {
|
||||||
ioe.set_mode(IOE_ADC_PIN, IOExpander::PIN_ADC);
|
ioe.set_mode(IOE_ADC_PIN, IOExpander::PIN_ADC);
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, toggle);
|
gpio_put(PICO_DEFAULT_LED_PIN, toggle);
|
||||||
|
#endif
|
||||||
toggle = !toggle;
|
toggle = !toggle;
|
||||||
|
|
||||||
float voltage = ioe.input_as_voltage(IOE_ADC_PIN);
|
float voltage = ioe.input_as_voltage(IOE_ADC_PIN);
|
||||||
|
@ -35,7 +39,10 @@ int main() {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("IOExpander not found :'(\n");
|
printf("IOExpander not found :'(\n");
|
||||||
|
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, true);
|
gpio_put(PICO_DEFAULT_LED_PIN, true);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -12,8 +12,10 @@ BreakoutIOExpander ioe(0x18);
|
||||||
bool last_state = true;
|
bool last_state = true;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||||
|
#endif
|
||||||
|
|
||||||
stdio_init_all();
|
stdio_init_all();
|
||||||
|
|
||||||
|
@ -27,11 +29,15 @@ int main() {
|
||||||
if(state != last_state) {
|
if(state != last_state) {
|
||||||
if(state) {
|
if(state) {
|
||||||
printf("Button has been released\n");
|
printf("Button has been released\n");
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, false);
|
gpio_put(PICO_DEFAULT_LED_PIN, false);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("Button has been pressed\n");
|
printf("Button has been pressed\n");
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, true);
|
gpio_put(PICO_DEFAULT_LED_PIN, true);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
last_state = state;
|
last_state = state;
|
||||||
|
@ -42,7 +48,9 @@ int main() {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("IOExpander not found :'(\n");
|
printf("IOExpander not found :'(\n");
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, true);
|
gpio_put(PICO_DEFAULT_LED_PIN, true);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -20,8 +20,10 @@ BreakoutIOExpander ioe(0x18);
|
||||||
bool toggle = false;
|
bool toggle = false;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||||
|
#endif
|
||||||
|
|
||||||
stdio_init_all();
|
stdio_init_all();
|
||||||
|
|
||||||
|
@ -34,7 +36,9 @@ int main() {
|
||||||
ioe.set_mode(IOE_SERVO_PIN, IOExpander::PIN_PWM);
|
ioe.set_mode(IOE_SERVO_PIN, IOExpander::PIN_PWM);
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, toggle);
|
gpio_put(PICO_DEFAULT_LED_PIN, toggle);
|
||||||
|
#endif
|
||||||
toggle = !toggle;
|
toggle = !toggle;
|
||||||
|
|
||||||
absolute_time_t at = get_absolute_time();
|
absolute_time_t at = get_absolute_time();
|
||||||
|
@ -53,7 +57,9 @@ int main() {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("IOExpander not found :'(\n");
|
printf("IOExpander not found :'(\n");
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, true);
|
gpio_put(PICO_DEFAULT_LED_PIN, true);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -8,8 +8,10 @@ I2C i2c(BOARD::BREAKOUT_GARDEN);
|
||||||
BreakoutMatrix11x7 matrix11x7(&i2c, 0x75);
|
BreakoutMatrix11x7 matrix11x7(&i2c, 0x75);
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||||
|
#endif
|
||||||
|
|
||||||
matrix11x7.init();
|
matrix11x7.init();
|
||||||
|
|
||||||
|
@ -20,7 +22,9 @@ int main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
matrix11x7.update(0);
|
matrix11x7.update(0);
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, true);
|
gpio_put(PICO_DEFAULT_LED_PIN, true);
|
||||||
|
#endif
|
||||||
sleep_ms(1000);
|
sleep_ms(1000);
|
||||||
for(auto x = 0; x < matrix11x7.WIDTH; x++) {
|
for(auto x = 0; x < matrix11x7.WIDTH; x++) {
|
||||||
for(auto y = 0; y < matrix11x7.HEIGHT; y++) {
|
for(auto y = 0; y < matrix11x7.HEIGHT; y++) {
|
||||||
|
@ -28,7 +32,9 @@ int main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
matrix11x7.update(0);
|
matrix11x7.update(0);
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, false);
|
gpio_put(PICO_DEFAULT_LED_PIN, false);
|
||||||
|
#endif
|
||||||
sleep_ms(1000);
|
sleep_ms(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,10 @@ BreakoutMICS6814 mics6814;
|
||||||
int main() {
|
int main() {
|
||||||
stdio_init_all();
|
stdio_init_all();
|
||||||
|
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||||
|
#endif
|
||||||
|
|
||||||
mics6814.init();
|
mics6814.init();
|
||||||
mics6814.set_heater(true);
|
mics6814.set_heater(true);
|
||||||
|
|
|
@ -32,8 +32,10 @@ void from_hsv(float h, float s, float v, uint8_t &r, uint8_t &g, uint8_t &b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||||
|
#endif
|
||||||
|
|
||||||
stdio_init_all();
|
stdio_init_all();
|
||||||
|
|
||||||
|
@ -43,7 +45,9 @@ int main() {
|
||||||
//pot.set_direction(BreakoutPotentiometer::DIRECTION_CCW); // Uncomment this to flip the direction
|
//pot.set_direction(BreakoutPotentiometer::DIRECTION_CCW); // Uncomment this to flip the direction
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, toggle);
|
gpio_put(PICO_DEFAULT_LED_PIN, toggle);
|
||||||
|
#endif
|
||||||
toggle = !toggle;
|
toggle = !toggle;
|
||||||
|
|
||||||
float percent = pot.read();
|
float percent = pot.read();
|
||||||
|
@ -58,7 +62,9 @@ int main() {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("Potentiometer not found :'(\n");
|
printf("Potentiometer not found :'(\n");
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, true);
|
gpio_put(PICO_DEFAULT_LED_PIN, true);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -10,8 +10,10 @@ BreakoutRTC rtc(&i2c);
|
||||||
int main() {
|
int main() {
|
||||||
stdio_init_all();
|
stdio_init_all();
|
||||||
|
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||||
|
#endif
|
||||||
|
|
||||||
if(!rtc.init()) {
|
if(!rtc.init()) {
|
||||||
printf("Init failed! Check your connections and i2c pin choices.\n");
|
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
|
// Update the locally stored time from the RTC
|
||||||
if(rtc.update_time()) {
|
if(rtc.update_time()) {
|
||||||
printf("Date: %s, Time: %s\n", rtc.string_date(), rtc.string_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);
|
gpio_put(PICO_DEFAULT_LED_PIN, true);
|
||||||
|
#endif
|
||||||
sleep_ms(100);
|
sleep_ms(100);
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, false);
|
gpio_put(PICO_DEFAULT_LED_PIN, false);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sleep_ms(100);
|
sleep_ms(100);
|
||||||
|
|
|
@ -21,8 +21,10 @@ int main() {
|
||||||
uint16_t eCO2, TVOC;
|
uint16_t eCO2, TVOC;
|
||||||
uint16_t rawCO2, rawTVOC;
|
uint16_t rawCO2, rawTVOC;
|
||||||
|
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||||
|
#endif
|
||||||
|
|
||||||
stdio_init_all();
|
stdio_init_all();
|
||||||
|
|
||||||
|
@ -47,12 +49,14 @@ int main() {
|
||||||
uint16_t j = 0;
|
uint16_t j = 0;
|
||||||
while(true) {
|
while(true) {
|
||||||
j++;
|
j++;
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
for(uint8_t i=0; i<prd; i++) {
|
for(uint8_t i=0; i<prd; i++) {
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, true);
|
gpio_put(PICO_DEFAULT_LED_PIN, true);
|
||||||
sleep_ms(50);
|
sleep_ms(50);
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, false);
|
gpio_put(PICO_DEFAULT_LED_PIN, false);
|
||||||
sleep_ms(50);
|
sleep_ms(50);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
sleep_ms(1000 - (100 * prd));
|
sleep_ms(1000 - (100 * prd));
|
||||||
if(prd == 1) {
|
if(prd == 1) {
|
||||||
sgp30.get_air_quality(&eCO2, &TVOC);
|
sgp30.get_air_quality(&eCO2, &TVOC);
|
||||||
|
|
|
@ -97,8 +97,10 @@ void count_changed(int16_t count) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||||
|
#endif
|
||||||
|
|
||||||
stdio_init_all();
|
stdio_init_all();
|
||||||
|
|
||||||
|
@ -110,7 +112,9 @@ int main() {
|
||||||
enc.clear_interrupt_flag();
|
enc.clear_interrupt_flag();
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, toggle);
|
gpio_put(PICO_DEFAULT_LED_PIN, toggle);
|
||||||
|
#endif
|
||||||
toggle = !toggle;
|
toggle = !toggle;
|
||||||
|
|
||||||
if(enc.get_interrupt_flag()) {
|
if(enc.get_interrupt_flag()) {
|
||||||
|
@ -126,7 +130,9 @@ int main() {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("Encoder not found :'(\n");
|
printf("Encoder not found :'(\n");
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, true);
|
gpio_put(PICO_DEFAULT_LED_PIN, true);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -217,8 +217,10 @@ bool repeating_timer_callback(struct repeating_timer *t) {
|
||||||
void setup() {
|
void setup() {
|
||||||
stdio_init_all();
|
stdio_init_all();
|
||||||
|
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||||
|
#endif
|
||||||
|
|
||||||
if(ENCODER_SWITCH_PIN != PIN_UNUSED) {
|
if(ENCODER_SWITCH_PIN != PIN_UNUSED) {
|
||||||
gpio_init(ENCODER_SWITCH_PIN);
|
gpio_init(ENCODER_SWITCH_PIN);
|
||||||
|
@ -270,7 +272,9 @@ int main() {
|
||||||
if(current_time > last_time + MAIN_LOOP_TIME_US) {
|
if(current_time > last_time + MAIN_LOOP_TIME_US) {
|
||||||
last_time = current_time;
|
last_time = current_time;
|
||||||
|
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, true); // Show the screen refresh has stated
|
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 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)) {
|
if(ENCODER_SWITCH_PIN != PIN_UNUSED && gpio_get(ENCODER_SWITCH_PIN)) {
|
||||||
|
@ -384,7 +388,10 @@ int main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
st7789.update(&graphics); // Refresh the screen
|
st7789.update(&graphics); // Refresh the screen
|
||||||
|
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, false); // Show the screen refresh has ended
|
gpio_put(PICO_DEFAULT_LED_PIN, false); // Show the screen refresh has ended
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -59,9 +59,11 @@ bool check_button_toggle() {
|
||||||
int main() {
|
int main() {
|
||||||
stdio_init_all();
|
stdio_init_all();
|
||||||
|
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
//Initialise the LED. We use this to indicate that the sequence is running.
|
//Initialise the LED. We use this to indicate that the sequence is running.
|
||||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Se the two motor's decay modes
|
// Se the two motor's decay modes
|
||||||
motor_1.decay_mode(DECAY_MODE);
|
motor_1.decay_mode(DECAY_MODE);
|
||||||
|
@ -76,8 +78,11 @@ int main() {
|
||||||
while(true) {
|
while(true) {
|
||||||
// Has the button been toggled?
|
// Has the button been toggled?
|
||||||
if(check_button_toggle()) {
|
if(check_button_toggle()) {
|
||||||
|
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
// Turn the Pico's LED on to show that the song has started
|
// Turn the Pico's LED on to show that the song has started
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, true);
|
gpio_put(PICO_DEFAULT_LED_PIN, true);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Play the song
|
// Play the song
|
||||||
for(uint i = 0; i < SONG_LENGTH && check_button_toggle(); i++) {
|
for(uint i = 0; i < SONG_LENGTH && check_button_toggle(); i++) {
|
||||||
|
@ -117,7 +122,9 @@ int main() {
|
||||||
button_toggle = false;
|
button_toggle = false;
|
||||||
|
|
||||||
// The song has finished, so turn off the Pico's LED and disable the motors
|
// 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);
|
gpio_put(PICO_DEFAULT_LED_PIN, false);
|
||||||
|
#endif
|
||||||
motor_1.disable();
|
motor_1.disable();
|
||||||
motor_2.disable();
|
motor_2.disable();
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,10 @@ void from_hsv(float h, float s, float v, uint8_t &r, uint8_t &g, uint8_t &b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||||
|
#endif
|
||||||
|
|
||||||
stdio_init_all();
|
stdio_init_all();
|
||||||
|
|
||||||
|
@ -56,7 +58,9 @@ int main() {
|
||||||
printf("Potentiometer found...\n");
|
printf("Potentiometer found...\n");
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, toggle);
|
gpio_put(PICO_DEFAULT_LED_PIN, toggle);
|
||||||
|
#endif
|
||||||
toggle = !toggle;
|
toggle = !toggle;
|
||||||
|
|
||||||
float percent = pot.read();
|
float percent = pot.read();
|
||||||
|
@ -113,7 +117,9 @@ int main() {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("No Potentiometer found :'(\n");
|
printf("No Potentiometer found :'(\n");
|
||||||
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, true);
|
gpio_put(PICO_DEFAULT_LED_PIN, true);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Ładowanie…
Reference in New Issue