Skip to content

Commit

Permalink
Now no longer including the SD and SPI libraries for UNO builds
Browse files Browse the repository at this point in the history
  • Loading branch information
euphy committed May 19, 2015
1 parent d83dfb9 commit b666496
Show file tree
Hide file tree
Showing 11 changed files with 3,792 additions and 2,030 deletions.
3 changes: 0 additions & 3 deletions EEPROMAnything.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//#include <EEPROM.h>
//#include <Arduino.h> // for type definitions

template <class T> int EEPROM_writeAnything(int ee, const T& value)
{
const byte* p = (const byte*)(const void*)&value;
Expand Down
3 changes: 2 additions & 1 deletion comms.ino
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ boolean comms_waitForNextCommand(char *buf)
int bufPos = 0;
for (int i = 0; i<INLENGTH; i++) {
buf[i] = 0;
}
}
long lastRxTime = 0L;

// loop while there's there isn't a terminated command.
Expand Down Expand Up @@ -262,3 +262,4 @@ void comms_unrecognisedCommand(String &com)
Serial.println(F(" not recognised."));
}


27 changes: 0 additions & 27 deletions configuration.ino
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,8 @@ This is one of the core files for the polargraph server program.
It sets up the motor objects (AccelSteppers), and has default
values for the motor, sprocket and microstepping combinations used
by polargraphs so far.
Comment out the #include lines for the electrical drivers you DON'T need.
So, if you are using Adafruit Motorshield v1: Make sure the #include lines
under V2 are preceded with //.
Equally, if you are using Adafruit Motorshield v2, make sure the #include
lines under V1 are precede with //.
If you are using generic serial stepper drivers (eg EasyDrivers,
stepsticks, Pololu gear), then look
*/

// =================================================================
// Configuring Adafruit motorshield version 1.
// Using Adafruit Motorshield V1? Make sure the #include line below is NOT commented-out.
// Using Adafruit Motorshield V2? Comment out the line below.
#include <AFMotor.h>

// =================================================================
// Configuring Adafruit motorshield version 2.
// Using Adafruit Motorshield V1? Comment out the three INCLUDE lines below.
// Using Adafruit Motorshield V2? Make sure these three lines are NOT commented-out.
//#include <Wire.h>
//#include <Adafruit_MotorShield.h>
//#include "utility/Adafruit_PWMServoDriver.h"

// Adafruiters, you don't need to worry about anything more in this file.

#ifdef ADAFRUIT_MOTORSHIELD_V1
const int stepType = INTERLEAVE;
AF_Stepper afMotorA(motorStepsPerRev, 1);
Expand Down
10 changes: 9 additions & 1 deletion exec.ino
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,14 @@ void exec_setPosition()
reportPosition();
}

void exec_changeLengthRelative()
{
long lenA = multiplier(atol(inParam1));
long lenB = multiplier(atol(inParam2));

changeLengthRelative(lenA, lenB);
}

void exec_changeLength()
{
float lenA = multiplier((float)atof(inParam1));
Expand Down Expand Up @@ -360,7 +368,7 @@ void exec_drawBetweenPoints(float p1a, float p1b, float p2a, float p2b, int maxS
else
{
Serial.print(MSG_E_STR);
Serial.println(F("Line not on page. Skipping it."));
Serial.println(F("Line is not on the page. Skipping it."));
}
// outputAvailableMemory();
}
Expand Down
6 changes: 2 additions & 4 deletions impl_uno.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ without "store" features. Doesn't actually do anything except
pass the command to the real executeCommand. */
void impl_processCommand(String com)
{
#if MICROCONTROLLER == MC_UNO
impl_executeCommand(com);
#endif
#if MICROCONTROLLER == MC_MEGA
// check for change mode commands
if (com.startsWith(CMD_MODE_STORE_COMMANDS)
Expand All @@ -33,8 +35,6 @@ void impl_processCommand(String com)
#endif
}



void impl_executeCommand(String &com)
{
if (exec_executeBasicCommand(com))
Expand Down Expand Up @@ -245,8 +245,6 @@ void impl_exec_changeToLiveCommandMode()
Serial.println(F("Changing back to live mode."));
storeCommands = false;
}


#endif

void impl_engageMotors()
Expand Down
2 changes: 2 additions & 0 deletions pixel.ino
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ void pixel_drawScribblePixel()

density = pixel_scaleDensity(density, 255, maxDens);
pixel_drawScribblePixel(originA, originB, size*1.1, density);

// outputAvailableMemory();
}

void pixel_drawScribblePixel(long originA, long originB, int size, int density)
Expand Down
125 changes: 72 additions & 53 deletions polargraph_server_a1.ino
Original file line number Diff line number Diff line change
@@ -1,80 +1,103 @@
/**
* Polargraph Server for ATMEGA328-based arduino boards.
* Polargraph Server for Arduino UNO and MEGA compatible boards.
* Written by Sandy Noble
* Released under GNU License version 3.
* http://www.polargraph.co.uk
* https://github.com/euphy/polargraph_server_a1
The program has a core part that consists of the following files:
- comms.ino
- configuration.ino
- eeprom.ino
- exec.ino
- penlift.ino
- pixel.ino
- util.ino
and the first portion of the main file, probably called
something like polargraph_server_a1.ino.
CONFIGURATION!! Read this!
==========================
CONFIGURATION!! Read this! Really.
==================================
Kung fu is like a game of chess. You must think first! Before you move.
This is a unified codebase for a few different versions of Polargraph Server.
You can control how it is compiled by changing the #define lines below.
Comment the lines below in or out to control what gets compiled.
There are five config sections:
1. Specify what kind of controller board you are using
2. Add some libraries if you have a MEGA
3. Specify what kind of motor driver you are using:
i. Adafruit Motorshield v1
ii. Adafruit Motorshield v2
iii. Discrete stepper drivers (eg EasyDriver, stepstick, Pololu gear).*
iv. Signal amplifier like a UNL2003*
4. Turn on some debugging code
5. Disable program features if you need to free up space
* For motor drivers iii and iv, you will need to change the values in
configuration.ino to set the exact pins the drivers are wired up to.
*/


//http://forum.arduino.cc/index.php?topic=173584.0
#include <SPI.h>
#include <SD.h>


// Specify what kind of controller board you are using
// ===================================================
// UNO or MEGA
// 1. Specify what kind of controller board you are using
// ======================================================
// UNO or MEGA. Uncomment the line for the kind of board you have.
#ifndef MICROCONTROLLER
#define MICROCONTROLLER MC_UNO
//#define MICROCONTROLLER MC_MEGA
#endif

// Turn on some debugging code
// ===========================

// 2. Add some libraries if you have a MEGA
// ========================================
// Uncomment the SPI and SD lines below if you have a MEGA, and are going to use
// the SD features. http://forum.arduino.cc/index.php?topic=173584.0
//#include <SPI.h>
//#include <SD.h>


// 3. Specify what kind of motor driver you are using
// ==================================================
// Only ONE set of lines below should be uncommented.

// i. Adafruit Motorshield v1. The original, and still the best.
// -------------------------------------------------------------
#define ADAFRUIT_MOTORSHIELD_V1
#include <AFMotor.h>

// ii. Adafruit Motorshield v2. It's all squealy.
// ----------------------------------------------
//#define ADAFRUIT_MOTORSHIELD_V2
//#include <Wire.h>
//#include <Adafruit_MotorShield.h>
//#include "utility/Adafruit_PWMServoDriver.h"

// iii. Using discrete stepper drivers? (eg EasyDriver, stepstick, Pololu gear)
// ----------------------------------------------------------------------------
// Don't forget to define your pins in 'configuration.ino'.
//#define SERIAL_STEPPER_DRIVERS

// iv. Using a signal amplifier like a UNL2003?
// --------------------------------------------
// Don't forget to define your pins in 'configuration.ino'.
// #define UNL2003_DRIVER


// 4. Turn on some debugging code if you want horror
// =================================================
//#define DEBUG
//#define DEBUG_COMMS
//#define DEBUG_PENLIFT
//#define DEBUG_PIXEL

// Program features
// ================

// 5. Disable program features if you need to free up space
// ========================================================
#define PIXEL_DRAWING
#define PENLIFT
#define VECTOR_LINES

// Specify what kind of motor driver you are using
// ===============================================
// Make sure the version of motorshield you have is listed below WITHOUT "//" on the front.
// REMEMBER!!! You need to comment out the matching library imports in the 'configuration.ino' tab too.
// So regardless of what you choose here, remember to sort out the #includes in configuration.ino.

#define ADAFRUIT_MOTORSHIELD_V1
//#define ADAFRUIT_MOTORSHIELD_V2

// Using discrete stepper drivers? (eg EasyDriver, stepstick, Pololu gear),
// choose SERIAL_STEPPER_DRIVERS and define your pins at the bottom of 'configuration.ino'.
//#define SERIAL_STEPPER_DRIVERS

// Using a signal amplifier like a UNL2003?
//#define UNL2003_DRIVER

/* ===========================================================
These variables are common to all polargraph server builds
=========================================================== */

// The names of the different microcontrollers
// ==========================================================
// Some microcontroller's names
#define MC_UNO 1
#define MC_MEGA 2

Expand All @@ -83,11 +106,7 @@ Comment the lines below in or out to control what gets compiled.
#include <EEPROM.h>
#include "EEPROMAnything.h"

/* ===========================================================
These variables are common to all polargraph server builds
=========================================================== */

const String FIRMWARE_VERSION_NO = "2.0";
const String FIRMWARE_VERSION_NO = "1.2";

// EEPROM addresses
const byte EEPROM_MACHINE_WIDTH = 0;
Expand All @@ -112,7 +131,7 @@ const int DEFAULT_DOWN_POSITION = 90;
const int DEFAULT_UP_POSITION = 180;
static int upPosition = DEFAULT_UP_POSITION; // defaults
static int downPosition = DEFAULT_DOWN_POSITION;
static byte penLiftSpeed = 3; // ms between steps of moving motor
static int penLiftSpeed = 3; // ms between steps of moving motor
byte const PEN_HEIGHT_SERVO_PIN = 9; //UNL2003 driver uses pin 9
boolean isPenUp = false;

Expand All @@ -127,7 +146,7 @@ static int defaultMachineWidth = 650;
static int defaultMachineHeight = 650;
static int defaultMmPerRev = 95;
static int defaultStepsPerRev = 800;
static byte defaultStepMultiplier = 1;
static int defaultStepMultiplier = 1;

float currentMaxSpeed = 800.0;
float currentAcceleration = 400.0;
Expand All @@ -143,7 +162,7 @@ long pageHeight = machineHeight * stepsPerMM;
long maxLength = 0;

//static char rowAxis = 'A';
const byte INLENGTH = 50;
const int INLENGTH = 50;
const char INTERMINATOR = 10;
const char SEMICOLON = ';';

Expand Down Expand Up @@ -244,8 +263,8 @@ void setup()
{
Serial.begin(57600); // set up Serial library at 57600 bps
Serial.println("POLARGRAPH ON!");
// Serial.print("Hardware: ");
// Serial.println(MICROCONTROLLER);
Serial.print("Hardware: ");
Serial.println(MICROCONTROLLER);

#if MICROCONTROLLER == MC_MEGA
Serial.println("MC_MEGA");
Expand Down
Loading

0 comments on commit b666496

Please sign in to comment.