Compare commits

..

2 Commits

Author SHA1 Message Date
9083b98882 I dont even know 2025-10-04 22:25:57 +02:00
fa9a43dd52 addtions for allarm sheduling 2025-09-30 18:23:19 +02:00
19 changed files with 757 additions and 9 deletions

View File

@ -41,6 +41,9 @@ add_executable(smart_alarm smart_alarm.cpp
ui.cpp
fonts/Font5x7FixedMono.c
alarm.cpp
dateutils.cpp
bell.c
multicore_utils.cpp
)
pico_set_program_name(smart_alarm "smart_alarm")

View File

@ -103,6 +103,7 @@ void gc9a01_vline(gc9a01_GC9A01_obj_t *self, uint16_t x, uint16_t y, uint16_t w,
void gc9a01_text(gc9a01_GC9A01_obj_t *self, const GFXfont *font, char *str, uint16_t x0, uint16_t y0, uint16_t fg_color, uint16_t bg_color);
void gc9a01_text_gfx_transparent(gc9a01_GC9A01_obj_t *self, const GFXfont *font, const char *str, uint16_t x0, uint16_t y0, uint16_t color);
void gc9a01_text_gfx_buffered(gc9a01_GC9A01_obj_t *self, const GFXfont *font, const char *str, uint16_t x0, uint16_t y0, uint16_t fg_color, uint16_t bg_color);
void gc9a01_blit_buffer(gc9a01_GC9A01_obj_t *self, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint8_t *buf, int len);
uint8_t gc9a01_get_color(uint8_t bpp);
uint16_t color565(uint8_t r, uint8_t g, uint8_t b);
#ifdef __cplusplus

214
alarm.cpp
View File

@ -4,6 +4,15 @@
#include <vector>
#include "alarm.h"
#include <cstdio>
#include <cstring>
#include "dateutils.h"
#include "link.h"
#include "ui.h"
#include "hardware/rtc.h"
#include "pico/multicore.h"
#include "pico/util/datetime.h"
alarm::alarm(uint8_t hours, uint8_t minutes, const std::array<bool, 7> &days_enabled, bool every_other_week, bool even_week){
@ -122,4 +131,207 @@ void alarm::set_even_week(bool even_week) {
}
}
std::vector<alarm> alarms;
#include "pico/util/datetime.h"
void alarm::get_next_ring_time(datetime_t &ret) const {
if (!enabled()) {
ret = {0};
return;
}
datetime_t now;
rtc_get_datetime(&now);
datetime_t candidate = now;
candidate.hour = hours();
candidate.min = minutes();
candidate.sec = 0;
std::array<bool, 7> days = days_enabled();
bool any_day_enabled = false;
for (uint8_t i = 0; i < 7; i++) {
if (days[i]) {
any_day_enabled = true;
break;
}
}
if (!any_day_enabled) {
// One-time alarm: schedule for tomorrow if time passed today
if (candidate.hour < now.hour ||
(candidate.hour == now.hour && candidate.min <= now.min)) {
candidate.day++;
// Handle month overflow
const uint8_t days_in_month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
uint8_t max_days = days_in_month[candidate.month];
if (candidate.month == 2 && (candidate.year % 4 == 0 &&
(candidate.year % 100 != 0 || candidate.year % 400 == 0))) {
max_days = 29;
}
if (candidate.day > max_days) {
candidate.day = 1;
candidate.month++;
if (candidate.month > 12) {
candidate.month = 1;
candidate.year++;
}
}
candidate.dotw = (now.dotw + 1) % 7;
}
memcpy(&ret, &candidate, sizeof(datetime_t));
return;
}
// Optimized ISO 8601 week calculation
auto get_iso_week_number = [](const datetime_t& dt) -> uint8_t {
uint16_t ordinal = dt.day;
const uint8_t days_in_month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
for (uint8_t m = 1; m < dt.month; m++) {
ordinal += days_in_month[m];
if (m == 2 && (dt.year % 4 == 0 && (dt.year % 100 != 0 || dt.year % 400 == 0))) {
ordinal++;
}
}
uint8_t iso_weekday = (dt.dotw == 0) ? 7 : dt.dotw;
uint8_t week = (ordinal - iso_weekday + 10) / 7;
if (week == 0) {
int16_t prev_year = dt.year - 1; // fix warning
bool leap = (prev_year % 4 == 0 && (prev_year % 100 != 0 || prev_year % 400 == 0));
datetime_t prev_jan1 = {prev_year, 1, 1, 0, 0, 0, 0};
uint8_t jan1_weekday = (prev_jan1.dotw == 0) ? 7 : prev_jan1.dotw;
if (jan1_weekday == 4 || jan1_weekday == 5 || (leap && jan1_weekday == 3)) {
return 53;
}
return 52;
}
if (week == 53) {
bool leap = (dt.year % 4 == 0 && (dt.year % 100 != 0 || dt.year % 400 == 0));
uint16_t year_length = leap ? 366 : 365;
uint16_t remaining_days = year_length - ordinal;
uint8_t dec31_weekday = (iso_weekday + remaining_days) % 7;
if (dec31_weekday == 0) dec31_weekday = 7;
if (dec31_weekday <= 3) {
return 1;
}
}
return week;
};
for (uint8_t days_ahead = 0; days_ahead < 14; days_ahead++) {
datetime_t test_date = now;
test_date.day += days_ahead;
const uint8_t days_in_month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
uint8_t max_days = days_in_month[test_date.month];
if (test_date.month == 2 && (test_date.year % 4 == 0 &&
(test_date.year % 100 != 0 || test_date.year % 400 == 0))) {
max_days = 29;
}
while (test_date.day > max_days) {
test_date.day -= max_days;
test_date.month++;
if (test_date.month > 12) {
test_date.month = 1;
test_date.year++;
}
max_days = days_in_month[test_date.month];
if (test_date.month == 2 && (test_date.year % 4 == 0 &&
(test_date.year % 100 != 0 || test_date.year % 400 == 0))) {
max_days = 29;
}
}
uint8_t dotw = (now.dotw + days_ahead) % 7;
test_date.dotw = dotw;
if (!days[dotw]) continue;
test_date.hour = hours();
test_date.min = minutes();
test_date.sec = 0;
if (days_ahead == 0) {
if (test_date.hour < now.hour ||
(test_date.hour == now.hour && test_date.min <= now.min)) {
continue;
}
}
if (every_other_week()) {
uint8_t current_week = get_iso_week_number(now);
uint8_t test_week = get_iso_week_number(test_date);
bool is_even_week = (test_week % 2 == 0);
if (even_week() != is_even_week) {
continue;
}
}
memcpy(&ret, &test_date, sizeof(datetime_t));
return;
}
ret = {0};
return;
}
std::vector<alarm> alarms;
uint8_t armed_alarm = 0;
void alarm_trigger_callback() {
printf("alarm triggered!\n");
{
std::array<bool, 7> days_enabled = alarms[armed_alarm].days_enabled();
bool one_time = true;
for (bool b : days_enabled) {
if (b) {one_time = false;break;}
}
if (one_time) {alarms[armed_alarm].disable();}
}
rearm_alarm_timers();
if (get_core_num()) {
alarm_gone_off_page();
} else {
multicore_launch_core1(&alarm_gone_off_page);
}
}
void rearm_alarm_timers() {
printf("arming alarm...\n");
rtc_disable_alarm();
if (alarms.empty()) return;
datetime_t first_alarm;
alarms[0].get_next_ring_time(first_alarm);
datetime_t testing;
for (uint8_t i = 1; i < alarms.size(); i++) {
if (alarms[i].enabled()) {
alarms[i].get_next_ring_time(testing);
if (compare_datetime(&testing, &first_alarm) == SMALLER_THAN) {
memcpy(&first_alarm, &testing, sizeof(datetime_t));
armed_alarm = i;
}
}
}
printf("alarm set to %d:%d:%d %d.%d.%d\n",first_alarm.hour,first_alarm.min,first_alarm.sec,first_alarm.day,first_alarm.month,first_alarm.year);
rtc_set_alarm(&first_alarm,&alarm_trigger_callback);
rtc_enable_alarm();
}

View File

@ -4,6 +4,8 @@
#include <cstdint>
#include <vector>
#include "pico/types.h"
struct alarm
{
private:
@ -19,6 +21,7 @@ public:
[[nodiscard]] bool every_other_week() const;
[[nodiscard]] bool even_week() const;
[[nodiscard]] bool enabled() const;
void get_next_ring_time(datetime_t &ret) const;
// Enable/disable methods
void enable();
@ -33,4 +36,5 @@ public:
};
extern std::vector<alarm> alarms;
void rearm_alarm_timers();
#endif //SMART_ALARM_PERSISTANCE_H

391
bell.c Normal file
View File

@ -0,0 +1,391 @@
/* GIMP RGB C-Source image dump (bell.c) */
#include <stdint.h>
#include <bell.h>
const struct bell_image_t bell_image = {
64, 64,
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000"
"\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000"
"\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\000\370\000\370\000\370\000"
"\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000"
"\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000"
"\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000"
"\370\000\370\000\370\000\370\000\370\000\370\000\370\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370"
"\000\370\000\370\000\370\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\000\370\000\370\000\370\000\370\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000"
"\370\000\370\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\000\370\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000"
"\370\000\370\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\000\370\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\000"
"\370\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\000\370\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\000\370\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\000\370\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\000\370\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\000\370\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\000\370\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\000"
"\370\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\000\370\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000"
"\370\000\370\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\000\370\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000"
"\370\000\370\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\000\370\000\370\000\370\000\370\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370"
"\000\370\000\370\000\370\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\000\370\000\370\000\370\000\370\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\000\370\000\370\000\370\000\370\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\000\370\000\370\000\370\000\370\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\000\370\000\370\000\370\000\370\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\000\370\000\370\000\370\000\370\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\000\370\000\370\000\370\000\370\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\000\370\000\370\000\370\000\370\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\000\370\000\370\000\370\000\370\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\000\370\000\370\000\370\000\370\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\000\370\000\370\000\370\000\370\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000"
"\370\000\370\000\370\000\370\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\000\370\000\370\000\370\000\370\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370"
"\000\370\000\370\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\000\370\000\370\000\370\000\370\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370"
"\000\370\000\370\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\000\370\000\370\000\370\000\370\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370"
"\000\370\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\000\370\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\000\370"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\000\370"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\000\370\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\000\370"
"\202\020\202\020\202\020\202\020\000\370\000\370\000\370\000\370\000\370\000\370\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\000\370\000\370\000\370\000\370\000\370"
"\000\370\202\020\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370"
"\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370"
"\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370"
"\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370"
"\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370"
"\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370"
"\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370"
"\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370"
"\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370"
"\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370"
"\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\000\350\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370"
"\000\370\000\370\000\370\000\350\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020A\300\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370"
"\000\370\000\370A\300\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"ap\000\360\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\360"
"ap\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020A\250\000"
"\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370\000\370A\250\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020A\250\000"
"\360\000\370\000\370\000\370\000\370\000\370\000\370\000\360A\250\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020ap"
"A\300\000\350\000\370\000\370\000\350A\300ap\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020"
"\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202\020\202"
"\020\202\020",
};

11
bell.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef SMART_ALARM_BELL_H
#define SMART_ALARM_BELL_H
#include <stdint.h>
struct bell_image_t{
uint8_t width;
uint8_t height;
uint8_t pixel_data[64 * 64 * 2 + 1];
};
extern const struct bell_image_t bell_image;
#endif //SMART_ALARM_BELL_H

33
dateutils.cpp Normal file
View File

@ -0,0 +1,33 @@
#include "dateutils.h"
#include "pico/types.h"
datetime_compare_res compare_datetime(const datetime_t *dt1, const datetime_t *dt2) {
// Compare year first
if (dt1->year > dt2->year) return BIGGER_THAN;
if (dt1->year < dt2->year) return SMALLER_THAN;
// Years are equal, compare month
if (dt1->month > dt2->month) return BIGGER_THAN;
if (dt1->month < dt2->month) return SMALLER_THAN;
// Months are equal, compare day
if (dt1->day > dt2->day) return BIGGER_THAN;
if (dt1->day < dt2->day) return SMALLER_THAN;
// Days are equal, compare hour
if (dt1->hour > dt2->hour) return BIGGER_THAN;
if (dt1->hour < dt2->hour) return SMALLER_THAN;
// Hours are equal, compare minute
if (dt1->min > dt2->min) return BIGGER_THAN;
if (dt1->min < dt2->min) return SMALLER_THAN;
// Minutes are equal, compare second
if (dt1->sec > dt2->sec) return BIGGER_THAN;
if (dt1->sec < dt2->sec) return SMALLER_THAN;
// All fields are equal
return EQUALS;
}

11
dateutils.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef SMART_ALARM_DATEUTILS_H
#define SMART_ALARM_DATEUTILS_H
#include "pico/types.h"
enum datetime_compare_res {
EQUALS,
BIGGER_THAN,
SMALLER_THAN,
};
datetime_compare_res compare_datetime(const datetime_t *dt1, const datetime_t *dt2);
#endif //SMART_ALARM_DATEUTILS_H

View File

@ -243,6 +243,7 @@ void print_alarm(alarm *alarm, selected_t selected, uint8_t x, u_int8_t y) {
break;
case 2: // enable/disable
alarm->set_state(!alarm->enabled());
rearm_alarm_timers();
break;
case 10: // every other week
alarm->set_every_other_week(!alarm->every_other_week());

View File

@ -25,4 +25,6 @@ void print_add_button(uint8_t center_x, uint8_t center_y,uint8_t w, uint16_t col
#define MAX_Y 240
#define ALARM_BOX_WIDTH 70
#define ALARM_BOX_HEIGHT 30
#define ORANGE 0xf420
#endif //SMART_ALARM_DISPLAY_H

8
link.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef SMART_ALARM_LINK_H
#define SMART_ALARM_LINK_H
#include <cstdint>
extern uint32_t __StackTop; // Core 0 stack top
extern uint32_t __StackBottom; // Core 0 stack bottom
extern uint32_t __StackOneTop; // Core 1 stack top
extern uint32_t __StackOneBottom; // Core 1 stack bottom
#endif //SMART_ALARM_LINK_H

17
multicore_utils.cpp Normal file
View File

@ -0,0 +1,17 @@
#include <iostream>
#include "pins.h"
#include "hardware/gpio.h"
#include "pico/platform.h"
#include "pico/time.h"
[[noreturn]] void core1_launch_with_reset_self() {
assert(get_core_num());// assert if called with core0
gpio_put(INTERUPT_PIN, true);
while (true) {
sleep_ms(UINT32_MAX);
}
}
void core0_launch_interupt_handler() {}

3
pins.h
View File

@ -10,4 +10,5 @@
#define BUTTON_SECONDARY_PW 7
#define BUTTON_SECONDARY_IN 6
#define LED_PIN 5
#define LED_PIN 5
#define INTERUPT_PIN 2

View File

@ -87,6 +87,8 @@ extern "C" void sync_system_time(unsigned int sec, unsigned int usec) {
}
}
uint8_t page_selected = 1;
int main() {
stdio_init_all();
if (cyw43_arch_init()) {
@ -162,7 +164,7 @@ int main() {
printf("SNTP initialized, waiting for time sync...\n");
uint8_t page_selected = 1;
multicore_launch_core1(page_functions[page_selected]);

5
smart_alarm.h Normal file
View File

@ -0,0 +1,5 @@
#ifndef SMART_ALARM_SMART_ALARM_H
#define SMART_ALARM_SMART_ALARM_H
#include <cstdint>
extern uint8_t page_selected;
#endif //SMART_ALARM_SMART_ALARM_H

View File

@ -58,7 +58,7 @@ void setup_pwm_audio() {
pwm_set_gpio_level(SPEAKER_PIN, 128); // Set to middle level (silence)
}
void play_audio() {
void play_alarm_audio() {
audio_pos = 0;
audio_playing = true;
@ -68,7 +68,7 @@ void play_audio() {
add_repeating_timer_us(delay_us, audio_timer_callback, NULL, &timer);
}
void stop_audio() {
void stop_alarm_audio() {
audio_playing = false;
pwm_set_gpio_level(SPEAKER_PIN, 128); // Return to silence level
}

View File

@ -2,8 +2,8 @@
#define SMART_ALARM_SOUND_H
void setup_pwm_audio();
void play_audio();
void stop_audio();
void play_alarm_audio();
void stop_alarm_audio();
extern volatile float volume_multiplier;

49
ui.cpp
View File

@ -12,10 +12,15 @@
#include "macros.h"
#include "lwip/arch.h"
#include "multicore_events.h"
#include "pins.h"
#include "smart_alarm.h"
#include "pico/multicore.h"
#include "pico/time.h"
#include "sound.h"
#include "timezones.h"
#include "hardware/gpio.h"
#include "bell.h"
#include "link.h"
bool secondary_button_override = false;
@ -51,7 +56,7 @@ void volume_update(configuration* self,bool hard)
}
}
void config_page() {
[[noreturn]] void config_page() {
char volume_str[17];
char timezone_str[41];
std::array<configuration, 2> options = {{{timezone_str,&timezone_set_text,&timezone_update,timezone_index, 0,true}, {volume_str,&volume_set_text,&volume_update,*(uint32_t*)&volume_multiplier, 0, false}}};
@ -161,7 +166,7 @@ void config_page() {
}
void time_page() {
[[noreturn]] void time_page() {
draw_ui_circle(MAGENTA);
print_time(true);
while (true) {
@ -235,3 +240,43 @@ static uint8_t get_alarm_y(uint8_t index) {
std::array<void (*)(), 3> page_functions = {config_page, time_page,
alarm_set_page};
[[noreturn]] void alarm_gone_off_page() {
printf("alarm went off\n");
clear_display();
page_selected = 1;
secondary_button_override = false;
draw_ui_circle(ORANGE);
gc9a01_blit_buffer(&display,120-(bell_image.width/2),180-(bell_image.height/2),bell_image.width,bell_image.height,const_cast<uint8_t*>(bell_image.pixel_data),std::size(bell_image.pixel_data));
gpio_put(LED_PIN, true);
play_alarm_audio();
print_time(true);
multicore_fifo_drain();
while (true) {
{
uint32_t event;
if (multicore_fifo_pop_timeout_us(500000,&event)) {
if (event == PRIMARY_BUTTON_PRESSED) {
stop_alarm_audio();
gpio_put(LED_PIN, false);
clear_display();
if (get_core_num()) {
asm volatile (
"ldr r3, %[stack_top] \n\t"
"mov sp, r3 \n\t"
:
: [stack_top] "m" (__StackOneTop)
: "r3"
);// clear the stack to prevent stack overflow from circular function calling
time_page();
} else {
multicore_launch_core1(&time_page);
}
}
}
multicore_fifo_drain();
}
print_time();
}
}

1
ui.h
View File

@ -3,4 +3,5 @@
#include <array>
extern std::array<void(*)(), 3> page_functions;
extern bool secondary_button_override;
void alarm_gone_off_page();
#endif //SMART_ALARM_UI_H