paul@11 | 1 | /* |
paul@11 | 2 | * Keypad event loop functionality. |
paul@11 | 3 | * |
paul@31 | 4 | * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> |
paul@11 | 5 | * |
paul@11 | 6 | * This program is free software; you can redistribute it and/or |
paul@11 | 7 | * modify it under the terms of the GNU General Public License as |
paul@11 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@11 | 9 | * the License, or (at your option) any later version. |
paul@11 | 10 | * |
paul@11 | 11 | * This program is distributed in the hope that it will be useful, |
paul@11 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@11 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@11 | 14 | * GNU General Public License for more details. |
paul@11 | 15 | * |
paul@11 | 16 | * You should have received a copy of the GNU General Public License |
paul@11 | 17 | * along with this program; if not, write to the Free Software |
paul@11 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@11 | 19 | * Boston, MA 02110-1301, USA |
paul@11 | 20 | */ |
paul@11 | 21 | |
paul@11 | 22 | #pragma once |
paul@11 | 23 | |
paul@11 | 24 | #ifdef __cplusplus |
paul@11 | 25 | |
paul@11 | 26 | #include <l4/devices/event-loop.h> |
paul@11 | 27 | #include <l4/util/util.h> |
paul@11 | 28 | |
paul@11 | 29 | /* Keypad event loop abstraction. */ |
paul@11 | 30 | |
paul@11 | 31 | class Keypad_event_loop : public Event_handler_loop<void> |
paul@11 | 32 | { |
paul@11 | 33 | public: |
paul@11 | 34 | /* Initialise the event loop with a thread priority. */ |
paul@11 | 35 | |
paul@11 | 36 | explicit Keypad_event_loop(int priority=0x20) |
paul@11 | 37 | : Event_handler_loop(priority) |
paul@11 | 38 | { |
paul@11 | 39 | } |
paul@11 | 40 | |
paul@11 | 41 | /* Event handler method. */ |
paul@11 | 42 | |
paul@11 | 43 | virtual void handle() |
paul@11 | 44 | { |
paul@11 | 45 | _handler(); |
paul@11 | 46 | l4_sleep(20); /* 20ms -> 50Hz */ |
paul@11 | 47 | } |
paul@11 | 48 | }; |
paul@11 | 49 | |
paul@11 | 50 | #endif |