From 8188b44439aaf2802966344ba91e9419d2de55e4 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Wed, 27 Apr 2016 12:02:17 -0700 Subject: [PATCH] Add Signal for per-second tick callbacks. --- firmware/application/Makefile | 1 + firmware/application/event_m0.cpp | 3 +++ firmware/application/time.cpp | 32 ++++++++++++++++++++++++++++ firmware/application/time.hpp | 35 +++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 firmware/application/time.cpp create mode 100644 firmware/application/time.hpp diff --git a/firmware/application/Makefile b/firmware/application/Makefile index 5efd06ce..cf50b8e1 100755 --- a/firmware/application/Makefile +++ b/firmware/application/Makefile @@ -181,6 +181,7 @@ CPPSRC = main.cpp \ ../common/ert_packet.cpp \ capture_app.cpp \ sd_card.cpp \ + time.cpp \ file.cpp \ log_file.cpp \ png_writer.cpp \ diff --git a/firmware/application/event_m0.cpp b/firmware/application/event_m0.cpp index e82faa3b..388695ef 100644 --- a/firmware/application/event_m0.cpp +++ b/firmware/application/event_m0.cpp @@ -24,6 +24,7 @@ #include "portapack.hpp" #include "sd_card.hpp" +#include "time.hpp" #include "message.hpp" #include "message_queue.hpp" @@ -145,6 +146,8 @@ void EventDispatcher::handle_rtc_tick() { sd_card::poll_inserted(); portapack::temperature_logger.second_tick(); + + time::on_tick_second(); } ui::Widget* EventDispatcher::touch_widget(ui::Widget* const w, ui::TouchEvent event) { diff --git a/firmware/application/time.cpp b/firmware/application/time.cpp new file mode 100644 index 00000000..10ba7f3b --- /dev/null +++ b/firmware/application/time.cpp @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc. + * + * This file is part of PortaPack. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include "time.hpp" + +namespace time { + +Signal<> signal_tick_second; + +void on_tick_second() { + signal_tick_second.emit(); +} + +} /* namespace time */ diff --git a/firmware/application/time.hpp b/firmware/application/time.hpp new file mode 100644 index 00000000..470c894d --- /dev/null +++ b/firmware/application/time.hpp @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc. + * + * This file is part of PortaPack. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __TIME_H__ +#define __TIME_H__ + +#include "signal.hpp" + +namespace time { + +extern Signal<> signal_tick_second; + +void on_tick_second(); + +} /* namespace time */ + +#endif/*__TIME_H__*/