From 1020d4d52aa1c4b9f587aa9ad02ab0fbb1183389 Mon Sep 17 00:00:00 2001 From: Matt Mets Date: Fri, 18 Mar 2011 14:30:25 -0400 Subject: [PATCH] Add InterfaceBoard class --- v2/src/Motherboard/boards/mb24/InterfaceBoard.cc | 15 +++++++++++++++ v2/src/Motherboard/boards/mb24/InterfaceBoard.hh | 9 +++++++++ v2/src/Motherboard/boards/mb24/LiquidCrystal.cc | 9 +++++++++ v2/src/Motherboard/boards/mb24/LiquidCrystal.hh | 7 +++++++ v2/src/Motherboard/boards/mb24/Motherboard.cc | 15 ++++----------- v2/src/Motherboard/boards/mb24/Motherboard.hh | 4 ++++ 6 files changed, 48 insertions(+), 11 deletions(-) create mode 100644 v2/src/Motherboard/boards/mb24/InterfaceBoard.cc create mode 100644 v2/src/Motherboard/boards/mb24/InterfaceBoard.hh diff --git a/v2/src/Motherboard/boards/mb24/InterfaceBoard.cc b/v2/src/Motherboard/boards/mb24/InterfaceBoard.cc new file mode 100644 index 0000000..d36f587 --- /dev/null +++ b/v2/src/Motherboard/boards/mb24/InterfaceBoard.cc @@ -0,0 +1,15 @@ +#include "InterfaceBoard.hh" +#include + +static PROGMEM prog_uchar welcomeMessage[] = {"MakerBot TOM"}; + + +InterfaceBoard::InterfaceBoard() : + lcd(Pin(PortC,4), Pin(PortC,3), Pin(PortD,7), Pin(PortG,2), Pin(PortG,1), Pin(PortG,0)) +{ + lcd.begin(16,4); + lcd.clear(); + lcd.home(); + + lcd.write_from_pgmspace(welcomeMessage); +} \ No newline at end of file diff --git a/v2/src/Motherboard/boards/mb24/InterfaceBoard.hh b/v2/src/Motherboard/boards/mb24/InterfaceBoard.hh new file mode 100644 index 0000000..b13cf90 --- /dev/null +++ b/v2/src/Motherboard/boards/mb24/InterfaceBoard.hh @@ -0,0 +1,9 @@ +#include "LiquidCrystal.hh" + +class InterfaceBoard { +private: + LiquidCrystal lcd; + +public: + InterfaceBoard(); +}; diff --git a/v2/src/Motherboard/boards/mb24/LiquidCrystal.cc b/v2/src/Motherboard/boards/mb24/LiquidCrystal.cc index e06de34..50c6b44 100755 --- a/v2/src/Motherboard/boards/mb24/LiquidCrystal.cc +++ b/v2/src/Motherboard/boards/mb24/LiquidCrystal.cc @@ -259,6 +259,15 @@ inline void LiquidCrystal::write(uint8_t value) { send(value, true); } + +void LiquidCrystal::write_from_pgmspace(const prog_uchar message[]) { + char letter; + if(!message) return; + while (letter = pgm_read_byte(message++)) { + write(letter); + } +} + /************ low level data pushing commands **********/ // write either command or data, with automatic 4/8-bit selection diff --git a/v2/src/Motherboard/boards/mb24/LiquidCrystal.hh b/v2/src/Motherboard/boards/mb24/LiquidCrystal.hh index 418e357..eb272e8 100755 --- a/v2/src/Motherboard/boards/mb24/LiquidCrystal.hh +++ b/v2/src/Motherboard/boards/mb24/LiquidCrystal.hh @@ -1,7 +1,10 @@ #ifndef LIQUID_CRYSTAL_HH #define LIQUID_CRYSTAL_HH +// TODO: Proper attribution + #include +#include #include "AvrPort.hh" // commands @@ -80,6 +83,10 @@ public: void createChar(uint8_t, uint8_t[]); void setCursor(uint8_t, uint8_t); virtual void write(uint8_t); + + /** Added by MakerBot Industries to support storing strings in flash **/ + void write_from_pgmspace(const prog_uchar message[]); + void command(uint8_t); private: void send(uint8_t, bool); diff --git a/v2/src/Motherboard/boards/mb24/Motherboard.cc b/v2/src/Motherboard/boards/mb24/Motherboard.cc index b3fa320..1bc2e30 100644 --- a/v2/src/Motherboard/boards/mb24/Motherboard.cc +++ b/v2/src/Motherboard/boards/mb24/Motherboard.cc @@ -23,14 +23,14 @@ #include "Configuration.hh" #include "Steppers.hh" #include "Command.hh" -#include "LiquidCrystal.hh" /// Instantiate static motherboard instance Motherboard Motherboard::motherboard; -LiquidCrystal lcd(Pin(PortC,4), Pin(PortC,3), Pin(PortD,7), Pin(PortG,2), Pin(PortG,1), Pin(PortG,0)); /// Create motherboard object -Motherboard::Motherboard() { +Motherboard::Motherboard() : + board() +{ /// Set up the stepper pins on board creation #if STEPPER_COUNT > 0 stepper[0] = StepperInterface(X_DIR_PIN,X_STEP_PIN,X_ENABLE_PIN,X_MAX_PIN,X_MIN_PIN); @@ -49,6 +49,7 @@ Motherboard::Motherboard() { #endif } + /// Reset the motherboard to its initial state. /// This only resets the board, and does not send a reset /// to any attached toolheads. @@ -81,14 +82,6 @@ void Motherboard::reset() { TIMSK2 = 0x01; // OVF flag on // Configure the debug pin. DEBUG_PIN.setDirection(true); -// lcd.begin(16,4); -// lcd.clear(); -// lcd.home(); -// lcd.write('H'); -// lcd.write('e'); -// lcd.write('l'); -// lcd.write('l'); -// lcd.write('o'); } /// Get the number of microseconds that have passed since diff --git a/v2/src/Motherboard/boards/mb24/Motherboard.hh b/v2/src/Motherboard/boards/mb24/Motherboard.hh index 599d6fe..cff42ff 100644 --- a/v2/src/Motherboard/boards/mb24/Motherboard.hh +++ b/v2/src/Motherboard/boards/mb24/Motherboard.hh @@ -32,6 +32,7 @@ #include "Types.hh" #include "PSU.hh" #include "Configuration.hh" +#include "InterfaceBoard.hh" class Motherboard { private: @@ -44,6 +45,9 @@ private: /// Private constructor; use the singleton Motherboard(); + // Interface board + InterfaceBoard board; + static Motherboard motherboard; public: /// Reset the motherboard to its initial state.