PageRenderTime 19ms CodeModel.GetById 13ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 18#ifndef INTERFACE_BOARD_HH_
 19#define INTERFACE_BOARD_HH_
 20
 21#include "Configuration.hh"
 22#include "Pin.hh"
 23#include "ButtonArray.hh"
 24#include "Menu.hh"
 25
 26/// Maximum number of screens that can be active at once.
 27#define SCREEN_STACK_DEPTH      5
 28
 29/// Character LCD screen geometry
 30///
 31/// Porting Note: Screens may need to be rewritten to support different sizes.
 32#define LCD_SCREEN_WIDTH        16
 33#define LCD_SCREEN_HEIGHT       4
 34
 35
 36/// The InterfaceBoard module provides support for the MakerBot Industries
 37/// Gen4 Interface Board. It could very likely be adopted to support other
 38/// LCD/button setups as well.
 39/// \ingroup HardwareLibraries
 40class InterfaceBoard {
 41public:
 42        LiquidCrystal& lcd;              ///< LCD to write to
 43private:
 44        ButtonArray& buttons;            ///< Button array to read from
 45
 46        // TODO: Drop this?
 47        Screen* buildScreen;            ///< Screen to display while building
 48
 49        // TODO: Drop this?
 50        Screen* mainScreen;            ///< Root menu screen
 51
 52        /// Stack of screens to display; the topmost one will actually
 53        /// be drawn to the screen, while the other will remain resident
 54        /// but not active.
 55        Screen* screenStack[SCREEN_STACK_DEPTH];
 56        int8_t screenIndex;             ///< Stack index of the current screen.
 57
 58        Pin foo_pin;                    ///< Pin connected to the 'foo' LED
 59        Pin bar_pin;                    ///< Pin connected to the 'bar' LED
 60
 61        /// TODO: Delete this.
 62        bool building;                  ///< True if the bot is building
 63
 64public:
 65        /// Construct an interface board.
 66        /// \param[in] button array to read from
 67        /// \param[in] LCD to display on
 68        /// \param[in] Pin connected to the foo LED
 69        /// \param[in] Pin connected to the bar LED
 70        /// \param[in] Main screen, shown as root display
 71        /// \param[in] Screen to display while building
 72        InterfaceBoard(ButtonArray& buttons_in,
 73                       LiquidCrystal& lcd_in,
 74                       const Pin& foo_pin_in,
 75                       const Pin& bar_pin_in,
 76                       Screen* mainScreen_in,
 77                       Screen* buildScreen_in);
 78
 79        /// Initialze the interface board. This needs to be called once
 80        /// at system startup (or reset).
 81	void init();
 82
 83        /// This should be called periodically by a high-speed interrupt to
 84        /// service the button input pad.
 85	void doInterrupt();
 86
 87        /// Add a new screen to the stack. This automatically calls reset()
 88        /// and then update() on the screen, to ensure that it displays
 89        /// properly. If there are more than SCREEN_STACK_DEPTH screens already
 90        /// in the stack, than this function does nothing.
 91        /// \param[in] newScreen Screen to display.
 92	void pushScreen(Screen* newScreen);
 93
 94        /// Remove the current screen from the stack. If there is only one screen
 95        /// being displayed, then this function does nothing.
 96	void popScreen();
 97
 98	micros_t getUpdateRate();
 99
100	void doUpdate();
101
102	void showMonitorMode();
103};
104
105#endif