Skip to content

Commit

Permalink
Add InterfaceBoard class
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Mets committed Mar 18, 2011
1 parent ae84de7 commit 1020d4d
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 11 deletions.
15 changes: 15 additions & 0 deletions v2/src/Motherboard/boards/mb24/InterfaceBoard.cc
@@ -0,0 +1,15 @@
#include "InterfaceBoard.hh"
#include <AvrPort.hh>

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);
}
9 changes: 9 additions & 0 deletions v2/src/Motherboard/boards/mb24/InterfaceBoard.hh
@@ -0,0 +1,9 @@
#include "LiquidCrystal.hh"

class InterfaceBoard {
private:
LiquidCrystal lcd;

public:
InterfaceBoard();
};
9 changes: 9 additions & 0 deletions v2/src/Motherboard/boards/mb24/LiquidCrystal.cc
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions v2/src/Motherboard/boards/mb24/LiquidCrystal.hh
@@ -1,7 +1,10 @@
#ifndef LIQUID_CRYSTAL_HH
#define LIQUID_CRYSTAL_HH

// TODO: Proper attribution

#include <stdint.h>
#include <avr/pgmspace.h>
#include "AvrPort.hh"

// commands
Expand Down Expand Up @@ -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);
Expand Down
15 changes: 4 additions & 11 deletions v2/src/Motherboard/boards/mb24/Motherboard.cc
Expand Up @@ -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);
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions v2/src/Motherboard/boards/mb24/Motherboard.hh
Expand Up @@ -32,6 +32,7 @@
#include "Types.hh"
#include "PSU.hh"
#include "Configuration.hh"
#include "InterfaceBoard.hh"

class Motherboard {
private:
Expand All @@ -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.
Expand Down

0 comments on commit 1020d4d

Please sign in to comment.