| 1 | /* |
| 2 | |
| 3 | MUIU8g2.h |
| 4 | |
| 5 | C++ Arduino wrapper for clib/mui.h (monochome minimal user interface) |
| 6 | |
| 7 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) |
| 8 | |
| 9 | Copyright (c) 2016, olikraus@gmail.com |
| 10 | All rights reserved. |
| 11 | |
| 12 | Redistribution and use in source and binary forms, with or without modification, |
| 13 | are permitted provided that the following conditions are met: |
| 14 | |
| 15 | * Redistributions of source code must retain the above copyright notice, this list |
| 16 | of conditions and the following disclaimer. |
| 17 | |
| 18 | * Redistributions in binary form must reproduce the above copyright notice, this |
| 19 | list of conditions and the following disclaimer in the documentation and/or other |
| 20 | materials provided with the distribution. |
| 21 | |
| 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
| 23 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
| 24 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 25 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 26 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR |
| 27 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 28 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 29 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 30 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 31 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 32 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 33 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 34 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 35 | |
| 36 | |
| 37 | */ |
| 38 | |
| 39 | |
| 40 | #ifndef MUIU8G2_HH |
| 41 | #define MUIU8G2_HH |
| 42 | |
| 43 | #include "clib/mui.h" |
| 44 | #include "clib/mui_u8g2.h" |
| 45 | |
| 46 | class MUIU8G2 |
| 47 | { |
| 48 | protected: |
| 49 | mui_t mui; |
| 50 | public: |
| 51 | MUIU8G2(void) { } |
| 52 | |
| 53 | MUIU8G2(U8G2 &u8g2, fds_t *fds, muif_t *muif_list, size_t muif_cnt) { |
| 54 | mui_Init(&mui, (void *)u8g2.getU8g2(), fds, muif_list, muif_cnt); |
| 55 | } |
| 56 | void begin(U8G2 &u8g2, fds_t *fds, muif_t *muif_list, size_t muif_cnt) { |
| 57 | mui_Init(&mui, (void *)u8g2.getU8g2(), fds, muif_list, muif_cnt); |
| 58 | } |
| 59 | mui_t *getMUI(void) { return &mui; } |
| 60 | |
| 61 | uint8_t getCurrentCursorFocusPosition(void) { return mui_GetCurrentCursorFocusPosition(&mui); } |
| 62 | |
| 63 | int getCurrentFormId(void) { return mui_GetCurrentFormId(&mui); } |
| 64 | |
| 65 | |
| 66 | void draw(void) { mui_Draw(&mui); } |
| 67 | //void getSelectableFieldTextOption(fds_t *fds, uint8_t nth_token) |
| 68 | // { mui_GetSelectableFieldTextOption(&mui, fds, nth_token); } |
| 69 | void enterForm(fds_t *fds, uint8_t initial_cursor_position) { mui_EnterForm(&mui, fds, initial_cursor_position); } |
| 70 | void leaveForm(void) { mui_LeaveForm(&mui); } |
| 71 | uint8_t gotoForm(uint8_t form_id, uint8_t initial_cursor_position) { return mui_GotoForm(&mui, form_id, initial_cursor_position); } |
| 72 | |
| 73 | void saveForm(void) { mui_SaveForm(&mui); } |
| 74 | void restoreForm(void) { mui_RestoreForm(&mui); } |
| 75 | void nextField(void) { mui_NextField(&mui); } |
| 76 | void prevField(void) { mui_PrevField(&mui); } |
| 77 | void sendSelect(void) { mui_SendSelect(&mui); } |
| 78 | |
| 79 | void sendSelectWithExecuteOnSelectFieldSearch(void) { mui_SendSelectWithExecuteOnSelectFieldSearch(&mui); } |
| 80 | |
| 81 | |
| 82 | int isFormActive(void) { return mui_IsFormActive(&mui); } |
| 83 | }; |
| 84 | |
| 85 | |
| 86 | #endif /* MUIU8G2_HH */ |