/firmware/src/shared/InterfaceBoard.hh

http://github.com/makerbot/G3Firmware · C++ Header · 105 lines · 37 code · 20 blank · 48 comment · 0 complexity · 6c6d0e457a3b82deac7d56effa0cc548 MD5 · raw file

  1. /*
  2. * Copyright 2011 by Matt Mets <matt.mets@makerbot.com>
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>
  16. */
  17. #ifndef INTERFACE_BOARD_HH_
  18. #define INTERFACE_BOARD_HH_
  19. #include "Configuration.hh"
  20. #include "Pin.hh"
  21. #include "ButtonArray.hh"
  22. #include "Menu.hh"
  23. /// Maximum number of screens that can be active at once.
  24. #define SCREEN_STACK_DEPTH 5
  25. /// Character LCD screen geometry
  26. ///
  27. /// Porting Note: Screens may need to be rewritten to support different sizes.
  28. #define LCD_SCREEN_WIDTH 16
  29. #define LCD_SCREEN_HEIGHT 4
  30. /// The InterfaceBoard module provides support for the MakerBot Industries
  31. /// Gen4 Interface Board. It could very likely be adopted to support other
  32. /// LCD/button setups as well.
  33. /// \ingroup HardwareLibraries
  34. class InterfaceBoard {
  35. public:
  36. LiquidCrystal& lcd; ///< LCD to write to
  37. private:
  38. ButtonArray& buttons; ///< Button array to read from
  39. // TODO: Drop this?
  40. Screen* buildScreen; ///< Screen to display while building
  41. // TODO: Drop this?
  42. Screen* mainScreen; ///< Root menu screen
  43. /// Stack of screens to display; the topmost one will actually
  44. /// be drawn to the screen, while the other will remain resident
  45. /// but not active.
  46. Screen* screenStack[SCREEN_STACK_DEPTH];
  47. int8_t screenIndex; ///< Stack index of the current screen.
  48. Pin foo_pin; ///< Pin connected to the 'foo' LED
  49. Pin bar_pin; ///< Pin connected to the 'bar' LED
  50. /// TODO: Delete this.
  51. bool building; ///< True if the bot is building
  52. public:
  53. /// Construct an interface board.
  54. /// \param[in] button array to read from
  55. /// \param[in] LCD to display on
  56. /// \param[in] Pin connected to the foo LED
  57. /// \param[in] Pin connected to the bar LED
  58. /// \param[in] Main screen, shown as root display
  59. /// \param[in] Screen to display while building
  60. InterfaceBoard(ButtonArray& buttons_in,
  61. LiquidCrystal& lcd_in,
  62. const Pin& foo_pin_in,
  63. const Pin& bar_pin_in,
  64. Screen* mainScreen_in,
  65. Screen* buildScreen_in);
  66. /// Initialze the interface board. This needs to be called once
  67. /// at system startup (or reset).
  68. void init();
  69. /// This should be called periodically by a high-speed interrupt to
  70. /// service the button input pad.
  71. void doInterrupt();
  72. /// Add a new screen to the stack. This automatically calls reset()
  73. /// and then update() on the screen, to ensure that it displays
  74. /// properly. If there are more than SCREEN_STACK_DEPTH screens already
  75. /// in the stack, than this function does nothing.
  76. /// \param[in] newScreen Screen to display.
  77. void pushScreen(Screen* newScreen);
  78. /// Remove the current screen from the stack. If there is only one screen
  79. /// being displayed, then this function does nothing.
  80. void popScreen();
  81. micros_t getUpdateRate();
  82. void doUpdate();
  83. void showMonitorMode();
  84. };
  85. #endif