MUIU8g2.h 3.1 KB

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