···2828use embassy_rp::rtc::{DateTime, DayOfWeek};
2929use embassy_rp::spi::Spi;
3030use embassy_rp::spi::{self};
3131+use embassy_rp::watchdog::Watchdog;
3132use embassy_rp::{bind_interrupts, gpio, i2c};
3233use embassy_sync::blocking_mutex::NoopMutex;
3334use embassy_sync::blocking_mutex::raw::NoopRawMutex;
···123124 let btn_b = Input::new(p.PIN_13, Pull::Down);
124125 let btn_c = Input::new(p.PIN_14, Pull::Down);
125126 let rtc_alarm = Input::new(p.PIN_8, Pull::Down);
127127+ let mut watchdog = Watchdog::new(p.WATCHDOG);
126128127129 //Setup i2c bus
128130 let config = embassy_rp::i2c::Config::default();
···171173 RESOURCES.init(StackResources::new()),
172174 seed,
173175 );
176176+177177+ //If the watch dog isn't fed in 60 seconds reboot to help with hang up
178178+ watchdog.start(Duration::from_secs(8));
174179175180 spawner.must_spawn(net_task(runner));
176181 //Attempt to connect to wifi to get RTC time loop for 2 minutes
···180185 let wifi_ssid = env_value("WIFI_SSID");
181186 let wifi_password = env_value("WIFI_PASSWORD");
182187 while wifi_connection_attempts < 30 {
188188+ watchdog.feed();
183189 match control
184190 .join(wifi_ssid, JoinOptions::new(wifi_password.as_bytes()))
185191 .await
···198204 }
199205200206 if connected_to_wifi {
207207+ //Feed the dog if it makes it this far
208208+ watchdog.feed();
201209 info!("waiting for DHCP...");
202210 while !stack.is_config_up() {
203211 Timer::after_millis(100).await;
···235243 let url = env_value("TIME_API");
236244 info!("connecting to {}", &url);
237245246246+ // Feeds the dog again for one last time
247247+ watchdog.feed();
248248+238249 //If the call goes through set the rtc
239250 match http_client.request(Method::GET, &url).await {
240251 Ok(mut request) => {
···334345 let reset_cycle = 3_000;
335346336347 //Turn off led to signify that the badge is ready
337337- user_led.set_low();
348348+ // user_led.set_low();
338349339350 //RTC alarm stuff
340351 let mut go_to_sleep = false;
···353364 }
354365355366 loop {
367367+ //Keep feeding the dog
368368+ watchdog.feed();
369369+356370 //Change Image Button
357371 if btn_c.is_high() {
358372 info!("Button C pressed");
···486500 //goes to sleep for 15 mins
487501 _ = rtc_device.disable_all_alarms();
488502 _ = rtc_device.clear_alarm_flag();
489489- _ = rtc_device.set_alarm_seconds(5);
490490- _ = rtc_device.control_alarm_seconds(Control::On);
503503+ _ = rtc_device.set_alarm_minutes(15);
504504+ _ = rtc_device.control_alarm_minutes(Control::On);
491505 _ = rtc_device.control_alarm_interrupt(Control::On);
492506 power.set_low();
493507 }