Merged multiple extruder support.

Soft PWM. (Sanguinololu can also have PID temperature control)
Interrupt save WRITE for addresses > 0x0FF
This commit is contained in:
Erik van der Zalm 2011-12-12 19:34:37 +01:00
parent 3664ed6aad
commit e017228569
11 changed files with 5525 additions and 5413 deletions

View file

@ -4,11 +4,11 @@
// This determines the communication speed of the printer
//#define BAUDRATE 250000
#define BAUDRATE 115200
#define BAUDRATE 250000
//#define BAUDRATE 115200
//#define BAUDRATE 230400
#define EXTRUDERS 2
#define EXTRUDERS 1
// Frequency limit
// See nophead's blog for more info
@ -32,7 +32,7 @@
// Sanguinololu 1.2 and above = 62
// Ultimaker = 7,
// Teensylu = 8
#define MOTHERBOARD 33
#define MOTHERBOARD 7
//===========================================================================
//=============================Thermal Settings ============================
@ -46,16 +46,21 @@
// 5 is ParCan supplied 104GT-2 100K
// 6 is EPCOS 100k
// 7 is 100k Honeywell thermistor 135-104LAG-J01
#define THERMISTORHEATER_0 1
#define THERMISTORHEATER_1 1
#define HEATER_0_USES_THERMISTOR
#define HEATER_1_USES_THERMISTOR
//#define HEATER_0_USES_AD595
//#define THERMISTORHEATER_0 3
//#define THERMISTORHEATER_1 1
//#define THERMISTORHEATER_2 1
//#define HEATER_0_USES_THERMISTOR
//#define HEATER_1_USES_THERMISTOR
//#define HEATER_2_USES_THERMISTOR
#define HEATER_0_USES_AD595
//#define HEATER_1_USES_AD595
//#define HEATER_2_USES_AD595
// Select one of these only to define how the bed temp is read.
#define THERMISTORBED 1
#define BED_USES_THERMISTOR
//#define THERMISTORBED 1
//#define BED_USES_THERMISTOR
//#define BED_USES_AD595
#define BED_CHECK_INTERVAL 5000 //ms
@ -73,7 +78,8 @@
//// The minimal temperature defines the temperature below which the heater will not be enabled
#define HEATER_0_MINTEMP 5
//#define HEATER_1_MINTEMP 5
#define BED_MINTEMP 5
//#define HEATER_2_MINTEMP 5
//#define BED_MINTEMP 5
// When temperature exceeds max temp, your heater will be switched off.
@ -81,7 +87,8 @@
// You should use MINTEMP for thermistor short/failure protection.
#define HEATER_0_MAXTEMP 275
//#define HEATER_1_MAXTEMP 275
#define BED_MAXTEMP 150
//#define HEATER_2_MAXTEMP 275
//#define BED_MAXTEMP 150
// Wait for Cooldown
@ -92,21 +99,17 @@
// Heating is finished if a temperature close to this degree shift is reached
#define HEATING_EARLY_FINISH_DEG_OFFSET 1 //Degree
// PID settings:
// Uncomment the following line to enable PID support.
#define PIDTEMP
#define PID_MAX 255 // limits current to nozzle; 255=full current
#ifdef PIDTEMP
#if MOTHERBOARD == 62
#error Sanguinololu does not support PID, sorry. Please disable it.
#endif
//#define PID_DEBUG // Sends debug data to the serial port.
//#define PID_OPENLOOP 1 // Puts PID in open loop. M104 sets the output power in %
#define PID_MAX 255 // limits current to nozzle; 255=full current
#define PID_INTEGRAL_DRIVE_MAX 255 //limit for the integral term
#define K1 0.95 //smoothing factor withing the PID
#define PID_dT 0.1 //sampling period of the PID
#define PID_dT 0.128 //sampling period of the PID
//To develop some PID settings for your machine, you can initiall follow
// the Ziegler-Nichols method.
@ -130,14 +133,14 @@
// #define DEFAULT_Kd (PID_SWING_AT_CRITIAL/8./PID_dT)
// Ultitmaker
// #define DEFAULT_Kp 22.2
// #define DEFAULT_Ki (1.25*PID_dT)
// #define DEFAULT_Kd (99/PID_dT)
#define DEFAULT_Kp 22.2
#define DEFAULT_Ki (1.25*PID_dT)
#define DEFAULT_Kd (99/PID_dT)
// Makergear
#define DEFAULT_Kp 7.0
#define DEFAULT_Ki 0.1
#define DEFAULT_Kd 12
// #define DEFAULT_Kp 7.0
// #define DEFAULT_Ki 0.1
// #define DEFAULT_Kd 12
// Mendel Parts V9 on 12V
// #define DEFAULT_Kp 63.0
@ -170,12 +173,12 @@
#define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors
// The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
const bool X_ENDSTOPS_INVERTING = false; // set to true to invert the logic of the endstops.
const bool Y_ENDSTOPS_INVERTING = false; // set to true to invert the logic of the endstops.
const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of the endstops.
const bool X_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
const bool Y_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
// For optos H21LOB set to true, for Mendel-Parts newer optos TCST2103 set to false
//#define ENDSTOPS_ONLY_FOR_HOMING // If defined the endstops will only be used for homing
#define ENDSTOPS_ONLY_FOR_HOMING // If defined the endstops will only be used for homing
// For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
#define X_ENABLE_ON 0
@ -186,7 +189,7 @@ const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of t
// Disables axis when it's not being used.
#define DISABLE_X false
#define DISABLE_Y false
#define DISABLE_Z true
#define DISABLE_Z false
#define DISABLE_E false // For all extruders
// Inverting axis direction
@ -195,11 +198,11 @@ const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of t
//#define INVERT_Z_DIR false // for Mendel set to false, for Orca set to true
//#define INVERT_E*_DIR true // for direct drive extruder v9 set to true, for geared extruder set to false, used for all extruders
#define INVERT_X_DIR false // for Mendel set to false, for Orca set to true
#define INVERT_X_DIR true // for Mendel set to false, for Orca set to true
#define INVERT_Y_DIR false // for Mendel set to true, for Orca set to false
#define INVERT_Z_DIR true // for Mendel set to false, for Orca set to true
#define INVERT_E0_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_E1_DIR true // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_E1_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_E2_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false
//// ENDSTOP SETTINGS:
@ -208,15 +211,15 @@ const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of t
#define Y_HOME_DIR -1
#define Z_HOME_DIR -1
#define min_software_endstops false //If true, axis won't move to coordinates less than zero.
#define max_software_endstops false //If true, axis won't move to coordinates greater than the defined lengths below.
#define X_MAX_LENGTH 210
#define Y_MAX_LENGTH 210
#define Z_MAX_LENGTH 210
#define min_software_endstops true //If true, axis won't move to coordinates less than zero.
#define max_software_endstops true //If true, axis won't move to coordinates greater than the defined lengths below.
#define X_MAX_LENGTH 205
#define Y_MAX_LENGTH 205
#define Z_MAX_LENGTH 200
//// MOVEMENT SETTINGS
#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
#define HOMING_FEEDRATE {30*60, 30*60, 2*60, 0} // set the homing speeds (mm/min)
#define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0} // set the homing speeds (mm/min)
//homing hits the endstop, then retracts by this distance, before it tries to slowly bump again:
#define X_HOME_RETRACT_MM 5
@ -230,9 +233,9 @@ const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of t
// default settings
//#define DEFAULT_AXIS_STEPS_PER_UNIT {78.7402,78.7402,200*8/3,760*1.1} // default steps per unit for ultimaker
//#define DEFAULT_AXIS_STEPS_PER_UNIT {40, 40, 3333.92, 67} //sells mendel with v9 extruder
#define DEFAULT_AXIS_STEPS_PER_UNIT {80.3232, 80.8900, 2284.7651, 757.2218} // SAE Prusa w/ Wade extruder
#define DEFAULT_AXIS_STEPS_PER_UNIT {78.7402,78.7402,200*8/3,760*1.1} // default steps per unit for ultimaker
//#define DEFAULT_AXIS_STEPS_PER_UNIT {40, 40, 3333.92, 360} //sells mendel with v9 extruder
//#define DEFAULT_AXIS_STEPS_PER_UNIT {80.3232, 80.8900, 2284.7651, 757.2218} // SAE Prusa w/ Wade extruder
#define DEFAULT_MAX_FEEDRATE {500, 500, 5, 45} // (mm/sec)
#define DEFAULT_MAX_ACCELERATION {9000,9000,100,10000} // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for skeinforge 40+, for older versions raise them a lot.
@ -283,10 +286,10 @@ const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of t
// hooke's law says: force = k * distance
// bernoulli's priniciple says: v ^ 2 / 2 + g . h + pressure / density = constant
// so: v ^ 2 is proportional to number of steps we advance the extruder
//#define ADVANCE
#define ADVANCE
#ifdef ADVANCE
#define EXTRUDER_ADVANCE_K .3
#define EXTRUDER_ADVANCE_K .0
#define D_FILAMENT 2.85
#define STEPS_MM_E 836
@ -298,10 +301,10 @@ const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of t
//LCD and SD support
//#define ULTRA_LCD //general lcd support, also 16x2
#define SDSUPPORT // Enable SD Card Support in Hardware Console
//#define SDSUPPORT // Enable SD Card Support in Hardware Console
#define SD_FINISHED_STEPPERRELEASE true //if sd support and the file is finished: disable steppers?
//#define ULTIPANEL
#define ULTIPANEL
#ifdef ULTIPANEL
//#define NEWPANEL //enable this if you have a click-encoder panel
#define SDSUPPORT

View file

@ -57,8 +57,6 @@ const prog_char echomagic[] PROGMEM ="echo:";
#define SERIAL_ECHOPAIR(name,value) {SERIAL_ECHOPGM(name);SERIAL_ECHO(value);}
// Macro for getting current active extruder
#define ACTIVE_EXTRUDER (active_extruder)
//things to write to serial from Programmemory. saves 400 to 2k of RAM.
#define SerialprintPGM(x) serialprintPGM(MYPGM(x))

View file

@ -465,16 +465,16 @@ FORCE_INLINE bool code_seen(char code)
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); \
destination[LETTER##_AXIS] = 1.5 * LETTER##_MAX_LENGTH * LETTER##_HOME_DIR; \
feedrate = homing_feedrate[LETTER##_AXIS]; \
prepare_move(); \
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); \
\
current_position[LETTER##_AXIS] = 0;\
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);\
destination[LETTER##_AXIS] = -LETTER##_HOME_RETRACT_MM * LETTER##_HOME_DIR;\
prepare_move(); \
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); \
\
destination[LETTER##_AXIS] = 2*LETTER##_HOME_RETRACT_MM * LETTER##_HOME_DIR;\
feedrate = homing_feedrate[LETTER##_AXIS]/2 ; \
prepare_move(); \
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); \
\
current_position[LETTER##_AXIS] = (LETTER##_HOME_DIR == -1) ? 0 : LETTER##_MAX_LENGTH;\
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);\
@ -541,6 +541,7 @@ FORCE_INLINE void process_commands()
if( code_seen(axis_codes[0]) && code_seen(axis_codes[1]) ) //first diagonal move
{
current_position[X_AXIS] = 0; current_position[Y_AXIS] = 0;
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
destination[X_AXIS] = 1.5 * X_MAX_LENGTH * X_HOME_DIR;
destination[Y_AXIS] = 1.5 * Y_MAX_LENGTH * Y_HOME_DIR;
@ -723,7 +724,7 @@ FORCE_INLINE void process_commands()
if (code_seen('S')) setTargetBed(code_value());
break;
case 105 : // M105
tmp_extruder = ACTIVE_EXTRUDER;
tmp_extruder = active_extruder;
if(code_seen('T')) {
tmp_extruder = code_value();
if(tmp_extruder >= EXTRUDERS) {
@ -743,6 +744,10 @@ FORCE_INLINE void process_commands()
#else
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM("No thermistors - no temp");
#endif
#ifdef PIDTEMP
SERIAL_PROTOCOLPGM(" @:");
SERIAL_PROTOCOL(getHeaterPower(tmp_extruder));
#endif
SERIAL_PROTOCOLLN("");
return;
@ -788,24 +793,26 @@ FORCE_INLINE void process_commands()
while((residencyStart == -1) ||
(residencyStart > -1 && (millis() - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) {
#else
while ( target_direction ? (isHeatingHotend(tmp_extruder)) : (isCoolingHotend(tmp_extruder)&&(CooldownNoWait==false)) ) {
while ( target_direction ? (isHeatingHotend(tmp_extruder)) : (isCoolingHotend(tmp_extruder)&&(CooldownNoWait==false)) ) {
#endif //TEMP_RESIDENCY_TIME
if( (millis() - codenum) > 1000 )
{ //Print Temp Reading and remaining time every 1 second while heating up/cooling down
SERIAL_PROTOCOLPGM("T:");
SERIAL_PROTOCOLLN( degHotend(tmp_extruder) );
SERIAL_PROTOCOL( degHotend(tmp_extruder) );
SERIAL_PROTOCOLPGM(" E:");
SERIAL_PROTOCOLLN( (int)tmp_extruder );
SERIAL_PROTOCOLPGM(" W:");
if(residencyStart > -1)
{
codenum = TEMP_RESIDENCY_TIME - ((millis() - residencyStart) / 1000);
SERIAL_PROTOCOLLN( codenum );
}
else
{
SERIAL_PROTOCOLLN( "?" );
}
#ifdef TEMP_RESIDENCY_TIME
SERIAL_PROTOCOLPGM(" W:");
if(residencyStart > -1)
{
codenum = TEMP_RESIDENCY_TIME - ((millis() - residencyStart) / 1000);
SERIAL_PROTOCOLLN( codenum );
}
else
{
SERIAL_PROTOCOLLN( "?" );
}
#endif
codenum = millis();
}
manage_heater();
@ -834,11 +841,11 @@ FORCE_INLINE void process_commands()
{
if( (millis()-codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
{
float tt=degHotend(ACTIVE_EXTRUDER);
float tt=degHotend(active_extruder);
SERIAL_PROTOCOLPGM("T:");
SERIAL_PROTOCOL(tt);
SERIAL_PROTOCOLPGM(" E:");
SERIAL_PROTOCOLLN( (int)tmp_extruder );
SERIAL_PROTOCOLLN( (int)active_extruder );
SERIAL_PROTOCOLPGM(" B:");
SERIAL_PROTOCOLLN(degBed());
codenum = millis();
@ -1191,6 +1198,7 @@ void manage_inactivity(byte debug)
void kill()
{
cli(); // Stop interrupts
disable_heater();
disable_x();
@ -1207,4 +1215,4 @@ void kill()
while(1); // Wait for reset
}

View file

@ -1,2573 +1,2582 @@
/*
This code contibuted by Triffid_Hunter and modified by Kliment
why double up on these macros? see http://gcc.gnu.org/onlinedocs/cpp/Stringification.html
*/
#ifndef _ARDUINO_H
#define _ARDUINO_H
#include <avr/io.h>
/*
utility functions
*/
#ifndef MASK
/// MASKING- returns \f$2^PIN\f$
#define MASK(PIN) (1 << PIN)
#endif
/*
magic I/O routines
now you can simply SET_OUTPUT(STEP); WRITE(STEP, 1); WRITE(STEP, 0);
*/
/// Read a pin
#define _READ(IO) ((bool)(DIO ## IO ## _RPORT & MASK(DIO ## IO ## _PIN)))
/// write to a pin
#define _WRITE(IO, v) do { if (v) {DIO ## IO ## _WPORT |= MASK(DIO ## IO ## _PIN); } else {DIO ## IO ## _WPORT &= ~MASK(DIO ## IO ## _PIN); }; } while (0)
//#define _WRITE(IO, v) do { #if (DIO ## IO ## _WPORT >= 0x100) CRITICAL_SECTION_START; if (v) {DIO ## IO ## _WPORT |= MASK(DIO ## IO ## _PIN); } else {DIO ## IO ## _WPORT &= ~MASK(DIO ## IO ## _PIN); };#if (DIO ## IO ## _WPORT >= 0x100) CRITICAL_SECTION_END; } while (0)
/// toggle a pin
#define _TOGGLE(IO) do {DIO ## IO ## _RPORT = MASK(DIO ## IO ## _PIN); } while (0)
/// set pin as input
#define _SET_INPUT(IO) do {DIO ## IO ## _DDR &= ~MASK(DIO ## IO ## _PIN); } while (0)
/// set pin as output
#define _SET_OUTPUT(IO) do {DIO ## IO ## _DDR |= MASK(DIO ## IO ## _PIN); } while (0)
/// check if pin is an input
#define _GET_INPUT(IO) ((DIO ## IO ## _DDR & MASK(DIO ## IO ## _PIN)) == 0)
/// check if pin is an output
#define _GET_OUTPUT(IO) ((DIO ## IO ## _DDR & MASK(DIO ## IO ## _PIN)) != 0)
// why double up on these macros? see http://gcc.gnu.org/onlinedocs/cpp/Stringification.html
/// Read a pin wrapper
#define READ(IO) _READ(IO)
/// Write to a pin wrapper
#define WRITE(IO, v) _WRITE(IO, v)
#if EXTRUDERS > 2
#define WRITE_E_STEP(v) { if(ACTIVE_EXTRUDER == 2) { WRITE(E2_STEP_PIN, v); } else { if(ACTIVE_EXTRUDER == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }}}
#define NORM_E_DIR() { if(ACTIVE_EXTRUDER == 2) { WRITE(E2_DIR_PIN, INVERT_E2_DIR); } else { if(ACTIVE_EXTRUDER == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }}}
#define REV_E_DIR() { if(ACTIVE_EXTRUDER == 2) { WRITE(E2_DIR_PIN, !INVERT_E2_DIR); } else { if(ACTIVE_EXTRUDER == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }}}
#elif EXTRUDERS > 1
#define WRITE_E_STEP(v) { if(ACTIVE_EXTRUDER == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }}
#define NORM_E_DIR() { if(ACTIVE_EXTRUDER == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }}
#define REV_E_DIR() { if(ACTIVE_EXTRUDER == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }}
#else
#define WRITE_E_STEP(v) WRITE(E0_STEP_PIN, v)
#define NORM_E_DIR() WRITE(E0_DIR_PIN, INVERT_E0_DIR)
#define REV_E_DIR() WRITE(E0_DIR_PIN, !INVERT_E0_DIR)
#endif
/// toggle a pin wrapper
#define TOGGLE(IO) _TOGGLE(IO)
/// set pin as input wrapper
#define SET_INPUT(IO) _SET_INPUT(IO)
/// set pin as output wrapper
#define SET_OUTPUT(IO) _SET_OUTPUT(IO)
/// check if pin is an input wrapper
#define GET_INPUT(IO) _GET_INPUT(IO)
/// check if pin is an output wrapper
#define GET_OUTPUT(IO) _GET_OUTPUT(IO)
/*
ports and functions
added as necessary or if I feel like it- not a comprehensive list!
*/
#if defined (__AVR_ATmega168__) || defined (__AVR_ATmega328__) || defined (__AVR_ATmega328P__)
// UART
#define RXD DIO0
#define TXD DIO1
// SPI
#define SCK DIO13
#define MISO DIO12
#define MOSI DIO11
#define SS DIO10
// TWI (I2C)
#define SCL AIO5
#define SDA AIO4
// timers and PWM
#define OC0A DIO6
#define OC0B DIO5
#define OC1A DIO9
#define OC1B DIO10
#define OC2A DIO11
#define OC2B DIO3
#define DEBUG_LED AIO5
/*
pins
*/
#define DIO0_PIN PIND0
#define DIO0_RPORT PIND
#define DIO0_WPORT PORTD
#define DIO0_DDR DDRD
#define DIO0_PWM NULL
#define DIO1_PIN PIND1
#define DIO1_RPORT PIND
#define DIO1_WPORT PORTD
#define DIO1_DDR DDRD
#define DIO1_PWM NULL
#define DIO2_PIN PIND2
#define DIO2_RPORT PIND
#define DIO2_WPORT PORTD
#define DIO2_DDR DDRD
#define DIO2_PWM NULL
#define DIO3_PIN PIND3
#define DIO3_RPORT PIND
#define DIO3_WPORT PORTD
#define DIO3_DDR DDRD
#define DIO3_PWM &OCR2B
#define DIO4_PIN PIND4
#define DIO4_RPORT PIND
#define DIO4_WPORT PORTD
#define DIO4_DDR DDRD
#define DIO4_PWM NULL
#define DIO5_PIN PIND5
#define DIO5_RPORT PIND
#define DIO5_WPORT PORTD
#define DIO5_DDR DDRD
#define DIO5_PWM &OCR0B
#define DIO6_PIN PIND6
#define DIO6_RPORT PIND
#define DIO6_WPORT PORTD
#define DIO6_DDR DDRD
#define DIO6_PWM &OCR0A
#define DIO7_PIN PIND7
#define DIO7_RPORT PIND
#define DIO7_WPORT PORTD
#define DIO7_DDR DDRD
#define DIO7_PWM NULL
#define DIO8_PIN PINB0
#define DIO8_RPORT PINB
#define DIO8_WPORT PORTB
#define DIO8_DDR DDRB
#define DIO8_PWM NULL
#define DIO9_PIN PINB1
#define DIO9_RPORT PINB
#define DIO9_WPORT PORTB
#define DIO9_DDR DDRB
#define DIO9_PWM NULL
#define DIO10_PIN PINB2
#define DIO10_RPORT PINB
#define DIO10_WPORT PORTB
#define DIO10_DDR DDRB
#define DIO10_PWM NULL
#define DIO11_PIN PINB3
#define DIO11_RPORT PINB
#define DIO11_WPORT PORTB
#define DIO11_DDR DDRB
#define DIO11_PWM &OCR2A
#define DIO12_PIN PINB4
#define DIO12_RPORT PINB
#define DIO12_WPORT PORTB
#define DIO12_DDR DDRB
#define DIO12_PWM NULL
#define DIO13_PIN PINB5
#define DIO13_RPORT PINB
#define DIO13_WPORT PORTB
#define DIO13_DDR DDRB
#define DIO13_PWM NULL
#define DIO14_PIN PINC0
#define DIO14_RPORT PINC
#define DIO14_WPORT PORTC
#define DIO14_DDR DDRC
#define DIO14_PWM NULL
#define DIO15_PIN PINC1
#define DIO15_RPORT PINC
#define DIO15_WPORT PORTC
#define DIO15_DDR DDRC
#define DIO15_PWM NULL
#define DIO16_PIN PINC2
#define DIO16_RPORT PINC
#define DIO16_WPORT PORTC
#define DIO16_DDR DDRC
#define DIO16_PWM NULL
#define DIO17_PIN PINC3
#define DIO17_RPORT PINC
#define DIO17_WPORT PORTC
#define DIO17_DDR DDRC
#define DIO17_PWM NULL
#define DIO18_PIN PINC4
#define DIO18_RPORT PINC
#define DIO18_WPORT PORTC
#define DIO18_DDR DDRC
#define DIO18_PWM NULL
#define DIO19_PIN PINC5
#define DIO19_RPORT PINC
#define DIO19_WPORT PORTC
#define DIO19_DDR DDRC
#define DIO19_PWM NULL
#define DIO20_PIN PINC6
#define DIO20_RPORT PINC
#define DIO20_WPORT PORTC
#define DIO20_DDR DDRC
#define DIO20_PWM NULL
#define DIO21_PIN PINC7
#define DIO21_RPORT PINC
#define DIO21_WPORT PORTC
#define DIO21_DDR DDRC
#define DIO21_PWM NULL
#undef PB0
#define PB0_PIN PINB0
#define PB0_RPORT PINB
#define PB0_WPORT PORTB
#define PB0_DDR DDRB
#define PB0_PWM NULL
#undef PB1
#define PB1_PIN PINB1
#define PB1_RPORT PINB
#define PB1_WPORT PORTB
#define PB1_DDR DDRB
#define PB1_PWM NULL
#undef PB2
#define PB2_PIN PINB2
#define PB2_RPORT PINB
#define PB2_WPORT PORTB
#define PB2_DDR DDRB
#define PB2_PWM NULL
#undef PB3
#define PB3_PIN PINB3
#define PB3_RPORT PINB
#define PB3_WPORT PORTB
#define PB3_DDR DDRB
#define PB3_PWM &OCR2A
#undef PB4
#define PB4_PIN PINB4
#define PB4_RPORT PINB
#define PB4_WPORT PORTB
#define PB4_DDR DDRB
#define PB4_PWM NULL
#undef PB5
#define PB5_PIN PINB5
#define PB5_RPORT PINB
#define PB5_WPORT PORTB
#define PB5_DDR DDRB
#define PB5_PWM NULL
#undef PB6
#define PB6_PIN PINB6
#define PB6_RPORT PINB
#define PB6_WPORT PORTB
#define PB6_DDR DDRB
#define PB6_PWM NULL
#undef PB7
#define PB7_PIN PINB7
#define PB7_RPORT PINB
#define PB7_WPORT PORTB
#define PB7_DDR DDRB
#define PB7_PWM NULL
#undef PC0
#define PC0_PIN PINC0
#define PC0_RPORT PINC
#define PC0_WPORT PORTC
#define PC0_DDR DDRC
#define PC0_PWM NULL
#undef PC1
#define PC1_PIN PINC1
#define PC1_RPORT PINC
#define PC1_WPORT PORTC
#define PC1_DDR DDRC
#define PC1_PWM NULL
#undef PC2
#define PC2_PIN PINC2
#define PC2_RPORT PINC
#define PC2_WPORT PORTC
#define PC2_DDR DDRC
#define PC2_PWM NULL
#undef PC3
#define PC3_PIN PINC3
#define PC3_RPORT PINC
#define PC3_WPORT PORTC
#define PC3_DDR DDRC
#define PC3_PWM NULL
#undef PC4
#define PC4_PIN PINC4
#define PC4_RPORT PINC
#define PC4_WPORT PORTC
#define PC4_DDR DDRC
#define PC4_PWM NULL
#undef PC5
#define PC5_PIN PINC5
#define PC5_RPORT PINC
#define PC5_WPORT PORTC
#define PC5_DDR DDRC
#define PC5_PWM NULL
#undef PC6
#define PC6_PIN PINC6
#define PC6_RPORT PINC
#define PC6_WPORT PORTC
#define PC6_DDR DDRC
#define PC6_PWM NULL
#undef PC7
#define PC7_PIN PINC7
#define PC7_RPORT PINC
#define PC7_WPORT PORTC
#define PC7_DDR DDRC
#define PC7_PWM NULL
#undef PD0
#define PD0_PIN PIND0
#define PD0_RPORT PIND
#define PD0_WPORT PORTD
#define PD0_DDR DDRD
#define PD0_PWM NULL
#undef PD1
#define PD1_PIN PIND1
#define PD1_RPORT PIND
#define PD1_WPORT PORTD
#define PD1_DDR DDRD
#define PD1_PWM NULL
#undef PD2
#define PD2_PIN PIND2
#define PD2_RPORT PIND
#define PD2_WPORT PORTD
#define PD2_DDR DDRD
#define PD2_PWM NULL
#undef PD3
#define PD3_PIN PIND3
#define PD3_RPORT PIND
#define PD3_WPORT PORTD
#define PD3_DDR DDRD
#define PD3_PWM &OCR2B
#undef PD4
#define PD4_PIN PIND4
#define PD4_RPORT PIND
#define PD4_WPORT PORTD
#define PD4_DDR DDRD
#define PD4_PWM NULL
#undef PD5
#define PD5_PIN PIND5
#define PD5_RPORT PIND
#define PD5_WPORT PORTD
#define PD5_DDR DDRD
#define PD5_PWM &OCR0B
#undef PD6
#define PD6_PIN PIND6
#define PD6_RPORT PIND
#define PD6_WPORT PORTD
#define PD6_DDR DDRD
#define PD6_PWM &OCR0A
#undef PD7
#define PD7_PIN PIND7
#define PD7_RPORT PIND
#define PD7_WPORT PORTD
#define PD7_DDR DDRD
#define PD7_PWM NULL
#endif /* _AVR_ATmega{168,328,328P}__ */
#if defined (__AVR_ATmega644__) || defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644PA__)
// UART
#define RXD DIO8
#define TXD DIO9
#define RXD0 DIO8
#define TXD0 DIO9
#define RXD1 DIO10
#define TXD1 DIO11
// SPI
#define SCK DIO7
#define MISO DIO6
#define MOSI DIO5
#define SS DIO4
// TWI (I2C)
#define SCL DIO16
#define SDA DIO17
// timers and PWM
#define OC0A DIO3
#define OC0B DIO4
#define OC1A DIO13
#define OC1B DIO12
#define OC2A DIO15
#define OC2B DIO14
#define DEBUG_LED DIO0
/*
pins
*/
#define DIO0_PIN PINB0
#define DIO0_RPORT PINB
#define DIO0_WPORT PORTB
#define DIO0_DDR DDRB
#define DIO0_PWM NULL
#define DIO1_PIN PINB1
#define DIO1_RPORT PINB
#define DIO1_WPORT PORTB
#define DIO1_DDR DDRB
#define DIO1_PWM NULL
#define DIO2_PIN PINB2
#define DIO2_RPORT PINB
#define DIO2_WPORT PORTB
#define DIO2_DDR DDRB
#define DIO2_PWM NULL
#define DIO3_PIN PINB3
#define DIO3_RPORT PINB
#define DIO3_WPORT PORTB
#define DIO3_DDR DDRB
#define DIO3_PWM &OCR0A
#define DIO4_PIN PINB4
#define DIO4_RPORT PINB
#define DIO4_WPORT PORTB
#define DIO4_DDR DDRB
#define DIO4_PWM &OCR0B
#define DIO5_PIN PINB5
#define DIO5_RPORT PINB
#define DIO5_WPORT PORTB
#define DIO5_DDR DDRB
#define DIO5_PWM NULL
#define DIO6_PIN PINB6
#define DIO6_RPORT PINB
#define DIO6_WPORT PORTB
#define DIO6_DDR DDRB
#define DIO6_PWM NULL
#define DIO7_PIN PINB7
#define DIO7_RPORT PINB
#define DIO7_WPORT PORTB
#define DIO7_DDR DDRB
#define DIO7_PWM NULL
#define DIO8_PIN PIND0
#define DIO8_RPORT PIND
#define DIO8_WPORT PORTD
#define DIO8_DDR DDRD
#define DIO8_PWM NULL
#define DIO9_PIN PIND1
#define DIO9_RPORT PIND
#define DIO9_WPORT PORTD
#define DIO9_DDR DDRD
#define DIO9_PWM NULL
#define DIO10_PIN PIND2
#define DIO10_RPORT PIND
#define DIO10_WPORT PORTD
#define DIO10_DDR DDRD
#define DIO10_PWM NULL
#define DIO11_PIN PIND3
#define DIO11_RPORT PIND
#define DIO11_WPORT PORTD
#define DIO11_DDR DDRD
#define DIO11_PWM NULL
#define DIO12_PIN PIND4
#define DIO12_RPORT PIND
#define DIO12_WPORT PORTD
#define DIO12_DDR DDRD
#define DIO12_PWM NULL
#define DIO13_PIN PIND5
#define DIO13_RPORT PIND
#define DIO13_WPORT PORTD
#define DIO13_DDR DDRD
#define DIO13_PWM NULL
#define DIO14_PIN PIND6
#define DIO14_RPORT PIND
#define DIO14_WPORT PORTD
#define DIO14_DDR DDRD
#define DIO14_PWM &OCR2B
#define DIO15_PIN PIND7
#define DIO15_RPORT PIND
#define DIO15_WPORT PORTD
#define DIO15_DDR DDRD
#define DIO15_PWM &OCR2A
#define DIO16_PIN PINC0
#define DIO16_RPORT PINC
#define DIO16_WPORT PORTC
#define DIO16_DDR DDRC
#define DIO16_PWM NULL
#define DIO17_PIN PINC1
#define DIO17_RPORT PINC
#define DIO17_WPORT PORTC
#define DIO17_DDR DDRC
#define DIO17_PWM NULL
#define DIO18_PIN PINC2
#define DIO18_RPORT PINC
#define DIO18_WPORT PORTC
#define DIO18_DDR DDRC
#define DIO18_PWM NULL
#define DIO19_PIN PINC3
#define DIO19_RPORT PINC
#define DIO19_WPORT PORTC
#define DIO19_DDR DDRC
#define DIO19_PWM NULL
#define DIO20_PIN PINC4
#define DIO20_RPORT PINC
#define DIO20_WPORT PORTC
#define DIO20_DDR DDRC
#define DIO20_PWM NULL
#define DIO21_PIN PINC5
#define DIO21_RPORT PINC
#define DIO21_WPORT PORTC
#define DIO21_DDR DDRC
#define DIO21_PWM NULL
#define DIO22_PIN PINC6
#define DIO22_RPORT PINC
#define DIO22_WPORT PORTC
#define DIO22_DDR DDRC
#define DIO22_PWM NULL
#define DIO23_PIN PINC7
#define DIO23_RPORT PINC
#define DIO23_WPORT PORTC
#define DIO23_DDR DDRC
#define DIO23_PWM NULL
#define DIO24_PIN PINA7
#define DIO24_RPORT PINA
#define DIO24_WPORT PORTA
#define DIO24_DDR DDRA
#define DIO24_PWM NULL
#define DIO25_PIN PINA6
#define DIO25_RPORT PINA
#define DIO25_WPORT PORTA
#define DIO25_DDR DDRA
#define DIO25_PWM NULL
#define DIO26_PIN PINA5
#define DIO26_RPORT PINA
#define DIO26_WPORT PORTA
#define DIO26_DDR DDRA
#define DIO26_PWM NULL
#define DIO27_PIN PINA4
#define DIO27_RPORT PINA
#define DIO27_WPORT PORTA
#define DIO27_DDR DDRA
#define DIO27_PWM NULL
#define DIO28_PIN PINA3
#define DIO28_RPORT PINA
#define DIO28_WPORT PORTA
#define DIO28_DDR DDRA
#define DIO28_PWM NULL
#define DIO29_PIN PINA2
#define DIO29_RPORT PINA
#define DIO29_WPORT PORTA
#define DIO29_DDR DDRA
#define DIO29_PWM NULL
#define DIO30_PIN PINA1
#define DIO30_RPORT PINA
#define DIO30_WPORT PORTA
#define DIO30_DDR DDRA
#define DIO30_PWM NULL
#define DIO31_PIN PINA0
#define DIO31_RPORT PINA
#define DIO31_WPORT PORTA
#define DIO31_DDR DDRA
#define DIO31_PWM NULL
#define AIO0_PIN PINA0
#define AIO0_RPORT PINA
#define AIO0_WPORT PORTA
#define AIO0_DDR DDRA
#define AIO0_PWM NULL
#define AIO1_PIN PINA1
#define AIO1_RPORT PINA
#define AIO1_WPORT PORTA
#define AIO1_DDR DDRA
#define AIO1_PWM NULL
#define AIO2_PIN PINA2
#define AIO2_RPORT PINA
#define AIO2_WPORT PORTA
#define AIO2_DDR DDRA
#define AIO2_PWM NULL
#define AIO3_PIN PINA3
#define AIO3_RPORT PINA
#define AIO3_WPORT PORTA
#define AIO3_DDR DDRA
#define AIO3_PWM NULL
#define AIO4_PIN PINA4
#define AIO4_RPORT PINA
#define AIO4_WPORT PORTA
#define AIO4_DDR DDRA
#define AIO4_PWM NULL
#define AIO5_PIN PINA5
#define AIO5_RPORT PINA
#define AIO5_WPORT PORTA
#define AIO5_DDR DDRA
#define AIO5_PWM NULL
#define AIO6_PIN PINA6
#define AIO6_RPORT PINA
#define AIO6_WPORT PORTA
#define AIO6_DDR DDRA
#define AIO6_PWM NULL
#define AIO7_PIN PINA7
#define AIO7_RPORT PINA
#define AIO7_WPORT PORTA
#define AIO7_DDR DDRA
#define AIO7_PWM NULL
#undef PA0
#define PA0_PIN PINA0
#define PA0_RPORT PINA
#define PA0_WPORT PORTA
#define PA0_DDR DDRA
#define PA0_PWM NULL
#undef PA1
#define PA1_PIN PINA1
#define PA1_RPORT PINA
#define PA1_WPORT PORTA
#define PA1_DDR DDRA
#define PA1_PWM NULL
#undef PA2
#define PA2_PIN PINA2
#define PA2_RPORT PINA
#define PA2_WPORT PORTA
#define PA2_DDR DDRA
#define PA2_PWM NULL
#undef PA3
#define PA3_PIN PINA3
#define PA3_RPORT PINA
#define PA3_WPORT PORTA
#define PA3_DDR DDRA
#define PA3_PWM NULL
#undef PA4
#define PA4_PIN PINA4
#define PA4_RPORT PINA
#define PA4_WPORT PORTA
#define PA4_DDR DDRA
#define PA4_PWM NULL
#undef PA5
#define PA5_PIN PINA5
#define PA5_RPORT PINA
#define PA5_WPORT PORTA
#define PA5_DDR DDRA
#define PA5_PWM NULL
#undef PA6
#define PA6_PIN PINA6
#define PA6_RPORT PINA
#define PA6_WPORT PORTA
#define PA6_DDR DDRA
#define PA6_PWM NULL
#undef PA7
#define PA7_PIN PINA7
#define PA7_RPORT PINA
#define PA7_WPORT PORTA
#define PA7_DDR DDRA
#define PA7_PWM NULL
#undef PB0
#define PB0_PIN PINB0
#define PB0_RPORT PINB
#define PB0_WPORT PORTB
#define PB0_DDR DDRB
#define PB0_PWM NULL
#undef PB1
#define PB1_PIN PINB1
#define PB1_RPORT PINB
#define PB1_WPORT PORTB
#define PB1_DDR DDRB
#define PB1_PWM NULL
#undef PB2
#define PB2_PIN PINB2
#define PB2_RPORT PINB
#define PB2_WPORT PORTB
#define PB2_DDR DDRB
#define PB2_PWM NULL
#undef PB3
#define PB3_PIN PINB3
#define PB3_RPORT PINB
#define PB3_WPORT PORTB
#define PB3_DDR DDRB
#define PB3_PWM &OCR0A
#undef PB4
#define PB4_PIN PINB4
#define PB4_RPORT PINB
#define PB4_WPORT PORTB
#define PB4_DDR DDRB
#define PB4_PWM &OCR0B
#undef PB5
#define PB5_PIN PINB5
#define PB5_RPORT PINB
#define PB5_WPORT PORTB
#define PB5_DDR DDRB
#define PB5_PWM NULL
#undef PB6
#define PB6_PIN PINB6
#define PB6_RPORT PINB
#define PB6_WPORT PORTB
#define PB6_DDR DDRB
#define PB6_PWM NULL
#undef PB7
#define PB7_PIN PINB7
#define PB7_RPORT PINB
#define PB7_WPORT PORTB
#define PB7_DDR DDRB
#define PB7_PWM NULL
#undef PC0
#define PC0_PIN PINC0
#define PC0_RPORT PINC
#define PC0_WPORT PORTC
#define PC0_DDR DDRC
#define PC0_PWM NULL
#undef PC1
#define PC1_PIN PINC1
#define PC1_RPORT PINC
#define PC1_WPORT PORTC
#define PC1_DDR DDRC
#define PC1_PWM NULL
#undef PC2
#define PC2_PIN PINC2
#define PC2_RPORT PINC
#define PC2_WPORT PORTC
#define PC2_DDR DDRC
#define PC2_PWM NULL
#undef PC3
#define PC3_PIN PINC3
#define PC3_RPORT PINC
#define PC3_WPORT PORTC
#define PC3_DDR DDRC
#define PC3_PWM NULL
#undef PC4
#define PC4_PIN PINC4
#define PC4_RPORT PINC
#define PC4_WPORT PORTC
#define PC4_DDR DDRC
#define PC4_PWM NULL
#undef PC5
#define PC5_PIN PINC5
#define PC5_RPORT PINC
#define PC5_WPORT PORTC
#define PC5_DDR DDRC
#define PC5_PWM NULL
#undef PC6
#define PC6_PIN PINC6
#define PC6_RPORT PINC
#define PC6_WPORT PORTC
#define PC6_DDR DDRC
#define PC6_PWM NULL
#undef PC7
#define PC7_PIN PINC7
#define PC7_RPORT PINC
#define PC7_WPORT PORTC
#define PC7_DDR DDRC
#define PC7_PWM NULL
#undef PD0
#define PD0_PIN PIND0
#define PD0_RPORT PIND
#define PD0_WPORT PORTD
#define PD0_DDR DDRD
#define PD0_PWM NULL
#undef PD1
#define PD1_PIN PIND1
#define PD1_RPORT PIND
#define PD1_WPORT PORTD
#define PD1_DDR DDRD
#define PD1_PWM NULL
#undef PD2
#define PD2_PIN PIND2
#define PD2_RPORT PIND
#define PD2_WPORT PORTD
#define PD2_DDR DDRD
#define PD2_PWM NULL
#undef PD3
#define PD3_PIN PIND3
#define PD3_RPORT PIND
#define PD3_WPORT PORTD
#define PD3_DDR DDRD
#define PD3_PWM NULL
#undef PD4
#define PD4_PIN PIND4
#define PD4_RPORT PIND
#define PD4_WPORT PORTD
#define PD4_DDR DDRD
#define PD4_PWM NULL
#undef PD5
#define PD5_PIN PIND5
#define PD5_RPORT PIND
#define PD5_WPORT PORTD
#define PD5_DDR DDRD
#define PD5_PWM NULL
#undef PD6
#define PD6_PIN PIND6
#define PD6_RPORT PIND
#define PD6_WPORT PORTD
#define PD6_DDR DDRD
#define PD6_PWM &OCR2B
#undef PD7
#define PD7_PIN PIND7
#define PD7_RPORT PIND
#define PD7_WPORT PORTD
#define PD7_DDR DDRD
#define PD7_PWM &OCR2A
#endif /* _AVR_ATmega{644,644P,644PA}__ */
#if defined (__AVR_ATmega1280__) || defined (__AVR_ATmega2560__)
// UART
#define RXD DIO0
#define TXD DIO1
// SPI
#define SCK DIO52
#define MISO DIO50
#define MOSI DIO51
#define SS DIO53
// TWI (I2C)
#define SCL DIO21
#define SDA DIO20
// timers and PWM
#define OC0A DIO13
#define OC0B DIO4
#define OC1A DIO11
#define OC1B DIO12
#define OC2A DIO10
#define OC2B DIO9
#define OC3A DIO5
#define OC3B DIO2
#define OC3C DIO3
#define OC4A DIO6
#define OC4B DIO7
#define OC4C DIO8
#define OC5A DIO46
#define OC5B DIO45
#define OC5C DIO44
// change for your board
#define DEBUG_LED DIO21
/*
pins
*/
#define DIO0_PIN PINE0
#define DIO0_RPORT PINE
#define DIO0_WPORT PORTE
#define DIO0_DDR DDRE
#define DIO0_PWM NULL
#define DIO1_PIN PINE1
#define DIO1_RPORT PINE
#define DIO1_WPORT PORTE
#define DIO1_DDR DDRE
#define DIO1_PWM NULL
#define DIO2_PIN PINE4
#define DIO2_RPORT PINE
#define DIO2_WPORT PORTE
#define DIO2_DDR DDRE
#define DIO2_PWM &OCR3BL
#define DIO3_PIN PINE5
#define DIO3_RPORT PINE
#define DIO3_WPORT PORTE
#define DIO3_DDR DDRE
#define DIO3_PWM &OCR3CL
#define DIO4_PIN PING5
#define DIO4_RPORT PING
#define DIO4_WPORT PORTG
#define DIO4_DDR DDRG
#define DIO4_PWM &OCR0B
#define DIO5_PIN PINE3
#define DIO5_RPORT PINE
#define DIO5_WPORT PORTE
#define DIO5_DDR DDRE
#define DIO5_PWM &OCR3AL
#define DIO6_PIN PINH3
#define DIO6_RPORT PINH
#define DIO6_WPORT PORTH
#define DIO6_DDR DDRH
#define DIO6_PWM &OCR4AL
#define DIO7_PIN PINH4
#define DIO7_RPORT PINH
#define DIO7_WPORT PORTH
#define DIO7_DDR DDRH
#define DIO7_PWM &OCR4BL
#define DIO8_PIN PINH5
#define DIO8_RPORT PINH
#define DIO8_WPORT PORTH
#define DIO8_DDR DDRH
#define DIO8_PWM &OCR4CL
#define DIO9_PIN PINH6
#define DIO9_RPORT PINH
#define DIO9_WPORT PORTH
#define DIO9_DDR DDRH
#define DIO9_PWM &OCR2B
#define DIO10_PIN PINB4
#define DIO10_RPORT PINB
#define DIO10_WPORT PORTB
#define DIO10_DDR DDRB
#define DIO10_PWM &OCR2A
#define DIO11_PIN PINB5
#define DIO11_RPORT PINB
#define DIO11_WPORT PORTB
#define DIO11_DDR DDRB
#define DIO11_PWM NULL
#define DIO12_PIN PINB6
#define DIO12_RPORT PINB
#define DIO12_WPORT PORTB
#define DIO12_DDR DDRB
#define DIO12_PWM NULL
#define DIO13_PIN PINB7
#define DIO13_RPORT PINB
#define DIO13_WPORT PORTB
#define DIO13_DDR DDRB
#define DIO13_PWM &OCR0A
#define DIO14_PIN PINJ1
#define DIO14_RPORT PINJ
#define DIO14_WPORT PORTJ
#define DIO14_DDR DDRJ
#define DIO14_PWM NULL
#define DIO15_PIN PINJ0
#define DIO15_RPORT PINJ
#define DIO15_WPORT PORTJ
#define DIO15_DDR DDRJ
#define DIO15_PWM NULL
#define DIO16_PIN PINH1
#define DIO16_RPORT PINH
#define DIO16_WPORT PORTH
#define DIO16_DDR DDRH
#define DIO16_PWM NULL
#define DIO17_PIN PINH0
#define DIO17_RPORT PINH
#define DIO17_WPORT PORTH
#define DIO17_DDR DDRH
#define DIO17_PWM NULL
#define DIO18_PIN PIND3
#define DIO18_RPORT PIND
#define DIO18_WPORT PORTD
#define DIO18_DDR DDRD
#define DIO18_PWM NULL
#define DIO19_PIN PIND2
#define DIO19_RPORT PIND
#define DIO19_WPORT PORTD
#define DIO19_DDR DDRD
#define DIO19_PWM NULL
#define DIO20_PIN PIND1
#define DIO20_RPORT PIND
#define DIO20_WPORT PORTD
#define DIO20_DDR DDRD
#define DIO20_PWM NULL
#define DIO21_PIN PIND0
#define DIO21_RPORT PIND
#define DIO21_WPORT PORTD
#define DIO21_DDR DDRD
#define DIO21_PWM NULL
#define DIO22_PIN PINA0
#define DIO22_RPORT PINA
#define DIO22_WPORT PORTA
#define DIO22_DDR DDRA
#define DIO22_PWM NULL
#define DIO23_PIN PINA1
#define DIO23_RPORT PINA
#define DIO23_WPORT PORTA
#define DIO23_DDR DDRA
#define DIO23_PWM NULL
#define DIO24_PIN PINA2
#define DIO24_RPORT PINA
#define DIO24_WPORT PORTA
#define DIO24_DDR DDRA
#define DIO24_PWM NULL
#define DIO25_PIN PINA3
#define DIO25_RPORT PINA
#define DIO25_WPORT PORTA
#define DIO25_DDR DDRA
#define DIO25_PWM NULL
#define DIO26_PIN PINA4
#define DIO26_RPORT PINA
#define DIO26_WPORT PORTA
#define DIO26_DDR DDRA
#define DIO26_PWM NULL
#define DIO27_PIN PINA5
#define DIO27_RPORT PINA
#define DIO27_WPORT PORTA
#define DIO27_DDR DDRA
#define DIO27_PWM NULL
#define DIO28_PIN PINA6
#define DIO28_RPORT PINA
#define DIO28_WPORT PORTA
#define DIO28_DDR DDRA
#define DIO28_PWM NULL
#define DIO29_PIN PINA7
#define DIO29_RPORT PINA
#define DIO29_WPORT PORTA
#define DIO29_DDR DDRA
#define DIO29_PWM NULL
#define DIO30_PIN PINC7
#define DIO30_RPORT PINC
#define DIO30_WPORT PORTC
#define DIO30_DDR DDRC
#define DIO30_PWM NULL
#define DIO31_PIN PINC6
#define DIO31_RPORT PINC
#define DIO31_WPORT PORTC
#define DIO31_DDR DDRC
#define DIO31_PWM NULL
#define DIO32_PIN PINC5
#define DIO32_RPORT PINC
#define DIO32_WPORT PORTC
#define DIO32_DDR DDRC
#define DIO32_PWM NULL
#define DIO33_PIN PINC4
#define DIO33_RPORT PINC
#define DIO33_WPORT PORTC
#define DIO33_DDR DDRC
#define DIO33_PWM NULL
#define DIO34_PIN PINC3
#define DIO34_RPORT PINC
#define DIO34_WPORT PORTC
#define DIO34_DDR DDRC
#define DIO34_PWM NULL
#define DIO35_PIN PINC2
#define DIO35_RPORT PINC
#define DIO35_WPORT PORTC
#define DIO35_DDR DDRC
#define DIO35_PWM NULL
#define DIO36_PIN PINC1
#define DIO36_RPORT PINC
#define DIO36_WPORT PORTC
#define DIO36_DDR DDRC
#define DIO36_PWM NULL
#define DIO37_PIN PINC0
#define DIO37_RPORT PINC
#define DIO37_WPORT PORTC
#define DIO37_DDR DDRC
#define DIO37_PWM NULL
#define DIO38_PIN PIND7
#define DIO38_RPORT PIND
#define DIO38_WPORT PORTD
#define DIO38_DDR DDRD
#define DIO38_PWM NULL
#define DIO39_PIN PING2
#define DIO39_RPORT PING
#define DIO39_WPORT PORTG
#define DIO39_DDR DDRG
#define DIO39_PWM NULL
#define DIO40_PIN PING1
#define DIO40_RPORT PING
#define DIO40_WPORT PORTG
#define DIO40_DDR DDRG
#define DIO40_PWM NULL
#define DIO41_PIN PING0
#define DIO41_RPORT PING
#define DIO41_WPORT PORTG
#define DIO41_DDR DDRG
#define DIO41_PWM NULL
#define DIO42_PIN PINL7
#define DIO42_RPORT PINL
#define DIO42_WPORT PORTL
#define DIO42_DDR DDRL
#define DIO42_PWM NULL
#define DIO43_PIN PINL6
#define DIO43_RPORT PINL
#define DIO43_WPORT PORTL
#define DIO43_DDR DDRL
#define DIO43_PWM NULL
#define DIO44_PIN PINL5
#define DIO44_RPORT PINL
#define DIO44_WPORT PORTL
#define DIO44_DDR DDRL
#define DIO44_PWM &OCR5CL
#define DIO45_PIN PINL4
#define DIO45_RPORT PINL
#define DIO45_WPORT PORTL
#define DIO45_DDR DDRL
#define DIO45_PWM &OCR5BL
#define DIO46_PIN PINL3
#define DIO46_RPORT PINL
#define DIO46_WPORT PORTL
#define DIO46_DDR DDRL
#define DIO46_PWM &OCR5AL
#define DIO47_PIN PINL2
#define DIO47_RPORT PINL
#define DIO47_WPORT PORTL
#define DIO47_DDR DDRL
#define DIO47_PWM NULL
#define DIO48_PIN PINL1
#define DIO48_RPORT PINL
#define DIO48_WPORT PORTL
#define DIO48_DDR DDRL
#define DIO48_PWM NULL
#define DIO49_PIN PINL0
#define DIO49_RPORT PINL
#define DIO49_WPORT PORTL
#define DIO49_DDR DDRL
#define DIO49_PWM NULL
#define DIO50_PIN PINB3
#define DIO50_RPORT PINB
#define DIO50_WPORT PORTB
#define DIO50_DDR DDRB
#define DIO50_PWM NULL
#define DIO51_PIN PINB2
#define DIO51_RPORT PINB
#define DIO51_WPORT PORTB
#define DIO51_DDR DDRB
#define DIO51_PWM NULL
#define DIO52_PIN PINB1
#define DIO52_RPORT PINB
#define DIO52_WPORT PORTB
#define DIO52_DDR DDRB
#define DIO52_PWM NULL
#define DIO53_PIN PINB0
#define DIO53_RPORT PINB
#define DIO53_WPORT PORTB
#define DIO53_DDR DDRB
#define DIO53_PWM NULL
#define DIO54_PIN PINF0
#define DIO54_RPORT PINF
#define DIO54_WPORT PORTF
#define DIO54_DDR DDRF
#define DIO54_PWM NULL
#define DIO55_PIN PINF1
#define DIO55_RPORT PINF
#define DIO55_WPORT PORTF
#define DIO55_DDR DDRF
#define DIO55_PWM NULL
#define DIO56_PIN PINF2
#define DIO56_RPORT PINF
#define DIO56_WPORT PORTF
#define DIO56_DDR DDRF
#define DIO56_PWM NULL
#define DIO57_PIN PINF3
#define DIO57_RPORT PINF
#define DIO57_WPORT PORTF
#define DIO57_DDR DDRF
#define DIO57_PWM NULL
#define DIO58_PIN PINF4
#define DIO58_RPORT PINF
#define DIO58_WPORT PORTF
#define DIO58_DDR DDRF
#define DIO58_PWM NULL
#define DIO59_PIN PINF5
#define DIO59_RPORT PINF
#define DIO59_WPORT PORTF
#define DIO59_DDR DDRF
#define DIO59_PWM NULL
#define DIO60_PIN PINF6
#define DIO60_RPORT PINF
#define DIO60_WPORT PORTF
#define DIO60_DDR DDRF
#define DIO60_PWM NULL
#define DIO61_PIN PINF7
#define DIO61_RPORT PINF
#define DIO61_WPORT PORTF
#define DIO61_DDR DDRF
#define DIO61_PWM NULL
#define DIO62_PIN PINK0
#define DIO62_RPORT PINK
#define DIO62_WPORT PORTK
#define DIO62_DDR DDRK
#define DIO62_PWM NULL
#define DIO63_PIN PINK1
#define DIO63_RPORT PINK
#define DIO63_WPORT PORTK
#define DIO63_DDR DDRK
#define DIO63_PWM NULL
#define DIO64_PIN PINK2
#define DIO64_RPORT PINK
#define DIO64_WPORT PORTK
#define DIO64_DDR DDRK
#define DIO64_PWM NULL
#define DIO65_PIN PINK3
#define DIO65_RPORT PINK
#define DIO65_WPORT PORTK
#define DIO65_DDR DDRK
#define DIO65_PWM NULL
#define DIO66_PIN PINK4
#define DIO66_RPORT PINK
#define DIO66_WPORT PORTK
#define DIO66_DDR DDRK
#define DIO66_PWM NULL
#define DIO67_PIN PINK5
#define DIO67_RPORT PINK
#define DIO67_WPORT PORTK
#define DIO67_DDR DDRK
#define DIO67_PWM NULL
#define DIO68_PIN PINK6
#define DIO68_RPORT PINK
#define DIO68_WPORT PORTK
#define DIO68_DDR DDRK
#define DIO68_PWM NULL
#define DIO69_PIN PINK7
#define DIO69_RPORT PINK
#define DIO69_WPORT PORTK
#define DIO69_DDR DDRK
#define DIO69_PWM NULL
#undef PA0
#define PA0_PIN PINA0
#define PA0_RPORT PINA
#define PA0_WPORT PORTA
#define PA0_DDR DDRA
#define PA0_PWM NULL
#undef PA1
#define PA1_PIN PINA1
#define PA1_RPORT PINA
#define PA1_WPORT PORTA
#define PA1_DDR DDRA
#define PA1_PWM NULL
#undef PA2
#define PA2_PIN PINA2
#define PA2_RPORT PINA
#define PA2_WPORT PORTA
#define PA2_DDR DDRA
#define PA2_PWM NULL
#undef PA3
#define PA3_PIN PINA3
#define PA3_RPORT PINA
#define PA3_WPORT PORTA
#define PA3_DDR DDRA
#define PA3_PWM NULL
#undef PA4
#define PA4_PIN PINA4
#define PA4_RPORT PINA
#define PA4_WPORT PORTA
#define PA4_DDR DDRA
#define PA4_PWM NULL
#undef PA5
#define PA5_PIN PINA5
#define PA5_RPORT PINA
#define PA5_WPORT PORTA
#define PA5_DDR DDRA
#define PA5_PWM NULL
#undef PA6
#define PA6_PIN PINA6
#define PA6_RPORT PINA
#define PA6_WPORT PORTA
#define PA6_DDR DDRA
#define PA6_PWM NULL
#undef PA7
#define PA7_PIN PINA7
#define PA7_RPORT PINA
#define PA7_WPORT PORTA
#define PA7_DDR DDRA
#define PA7_PWM NULL
#undef PB0
#define PB0_PIN PINB0
#define PB0_RPORT PINB
#define PB0_WPORT PORTB
#define PB0_DDR DDRB
#define PB0_PWM NULL
#undef PB1
#define PB1_PIN PINB1
#define PB1_RPORT PINB
#define PB1_WPORT PORTB
#define PB1_DDR DDRB
#define PB1_PWM NULL
#undef PB2
#define PB2_PIN PINB2
#define PB2_RPORT PINB
#define PB2_WPORT PORTB
#define PB2_DDR DDRB
#define PB2_PWM NULL
#undef PB3
#define PB3_PIN PINB3
#define PB3_RPORT PINB
#define PB3_WPORT PORTB
#define PB3_DDR DDRB
#define PB3_PWM NULL
#undef PB4
#define PB4_PIN PINB4
#define PB4_RPORT PINB
#define PB4_WPORT PORTB
#define PB4_DDR DDRB
#define PB4_PWM &OCR2A
#undef PB5
#define PB5_PIN PINB5
#define PB5_RPORT PINB
#define PB5_WPORT PORTB
#define PB5_DDR DDRB
#define PB5_PWM NULL
#undef PB6
#define PB6_PIN PINB6
#define PB6_RPORT PINB
#define PB6_WPORT PORTB
#define PB6_DDR DDRB
#define PB6_PWM NULL
#undef PB7
#define PB7_PIN PINB7
#define PB7_RPORT PINB
#define PB7_WPORT PORTB
#define PB7_DDR DDRB
#define PB7_PWM &OCR0A
#undef PC0
#define PC0_PIN PINC0
#define PC0_RPORT PINC
#define PC0_WPORT PORTC
#define PC0_DDR DDRC
#define PC0_PWM NULL
#undef PC1
#define PC1_PIN PINC1
#define PC1_RPORT PINC
#define PC1_WPORT PORTC
#define PC1_DDR DDRC
#define PC1_PWM NULL
#undef PC2
#define PC2_PIN PINC2
#define PC2_RPORT PINC
#define PC2_WPORT PORTC
#define PC2_DDR DDRC
#define PC2_PWM NULL
#undef PC3
#define PC3_PIN PINC3
#define PC3_RPORT PINC
#define PC3_WPORT PORTC
#define PC3_DDR DDRC
#define PC3_PWM NULL
#undef PC4
#define PC4_PIN PINC4
#define PC4_RPORT PINC
#define PC4_WPORT PORTC
#define PC4_DDR DDRC
#define PC4_PWM NULL
#undef PC5
#define PC5_PIN PINC5
#define PC5_RPORT PINC
#define PC5_WPORT PORTC
#define PC5_DDR DDRC
#define PC5_PWM NULL
#undef PC6
#define PC6_PIN PINC6
#define PC6_RPORT PINC
#define PC6_WPORT PORTC
#define PC6_DDR DDRC
#define PC6_PWM NULL
#undef PC7
#define PC7_PIN PINC7
#define PC7_RPORT PINC
#define PC7_WPORT PORTC
#define PC7_DDR DDRC
#define PC7_PWM NULL
#undef PD0
#define PD0_PIN PIND0
#define PD0_RPORT PIND
#define PD0_WPORT PORTD
#define PD0_DDR DDRD
#define PD0_PWM NULL
#undef PD1
#define PD1_PIN PIND1
#define PD1_RPORT PIND
#define PD1_WPORT PORTD
#define PD1_DDR DDRD
#define PD1_PWM NULL
#undef PD2
#define PD2_PIN PIND2
#define PD2_RPORT PIND
#define PD2_WPORT PORTD
#define PD2_DDR DDRD
#define PD2_PWM NULL
#undef PD3
#define PD3_PIN PIND3
#define PD3_RPORT PIND
#define PD3_WPORT PORTD
#define PD3_DDR DDRD
#define PD3_PWM NULL
#undef PD4
#define PD4_PIN PIND4
#define PD4_RPORT PIND
#define PD4_WPORT PORTD
#define PD4_DDR DDRD
#define PD4_PWM NULL
#undef PD5
#define PD5_PIN PIND5
#define PD5_RPORT PIND
#define PD5_WPORT PORTD
#define PD5_DDR DDRD
#define PD5_PWM NULL
#undef PD6
#define PD6_PIN PIND6
#define PD6_RPORT PIND
#define PD6_WPORT PORTD
#define PD6_DDR DDRD
#define PD6_PWM NULL
#undef PD7
#define PD7_PIN PIND7
#define PD7_RPORT PIND
#define PD7_WPORT PORTD
#define PD7_DDR DDRD
#define PD7_PWM NULL
#undef PE0
#define PE0_PIN PINE0
#define PE0_RPORT PINE
#define PE0_WPORT PORTE
#define PE0_DDR DDRE
#define PE0_PWM NULL
#undef PE1
#define PE1_PIN PINE1
#define PE1_RPORT PINE
#define PE1_WPORT PORTE
#define PE1_DDR DDRE
#define PE1_PWM NULL
#undef PE2
#define PE2_PIN PINE2
#define PE2_RPORT PINE
#define PE2_WPORT PORTE
#define PE2_DDR DDRE
#define PE2_PWM NULL
#undef PE3
#define PE3_PIN PINE3
#define PE3_RPORT PINE
#define PE3_WPORT PORTE
#define PE3_DDR DDRE
#define PE3_PWM &OCR3AL
#undef PE4
#define PE4_PIN PINE4
#define PE4_RPORT PINE
#define PE4_WPORT PORTE
#define PE4_DDR DDRE
#define PE4_PWM &OCR3BL
#undef PE5
#define PE5_PIN PINE5
#define PE5_RPORT PINE
#define PE5_WPORT PORTE
#define PE5_DDR DDRE
#define PE5_PWM &OCR3CL
#undef PE6
#define PE6_PIN PINE6
#define PE6_RPORT PINE
#define PE6_WPORT PORTE
#define PE6_DDR DDRE
#define PE6_PWM NULL
#undef PE7
#define PE7_PIN PINE7
#define PE7_RPORT PINE
#define PE7_WPORT PORTE
#define PE7_DDR DDRE
#define PE7_PWM NULL
#undef PF0
#define PF0_PIN PINF0
#define PF0_RPORT PINF
#define PF0_WPORT PORTF
#define PF0_DDR DDRF
#define PF0_PWM NULL
#undef PF1
#define PF1_PIN PINF1
#define PF1_RPORT PINF
#define PF1_WPORT PORTF
#define PF1_DDR DDRF
#define PF1_PWM NULL
#undef PF2
#define PF2_PIN PINF2
#define PF2_RPORT PINF
#define PF2_WPORT PORTF
#define PF2_DDR DDRF
#define PF2_PWM NULL
#undef PF3
#define PF3_PIN PINF3
#define PF3_RPORT PINF
#define PF3_WPORT PORTF
#define PF3_DDR DDRF
#define PF3_PWM NULL
#undef PF4
#define PF4_PIN PINF4
#define PF4_RPORT PINF
#define PF4_WPORT PORTF
#define PF4_DDR DDRF
#define PF4_PWM NULL
#undef PF5
#define PF5_PIN PINF5
#define PF5_RPORT PINF
#define PF5_WPORT PORTF
#define PF5_DDR DDRF
#define PF5_PWM NULL
#undef PF6
#define PF6_PIN PINF6
#define PF6_RPORT PINF
#define PF6_WPORT PORTF
#define PF6_DDR DDRF
#define PF6_PWM NULL
#undef PF7
#define PF7_PIN PINF7
#define PF7_RPORT PINF
#define PF7_WPORT PORTF
#define PF7_DDR DDRF
#define PF7_PWM NULL
#undef PG0
#define PG0_PIN PING0
#define PG0_RPORT PING
#define PG0_WPORT PORTG
#define PG0_DDR DDRG
#define PG0_PWM NULL
#undef PG1
#define PG1_PIN PING1
#define PG1_RPORT PING
#define PG1_WPORT PORTG
#define PG1_DDR DDRG
#define PG1_PWM NULL
#undef PG2
#define PG2_PIN PING2
#define PG2_RPORT PING
#define PG2_WPORT PORTG
#define PG2_DDR DDRG
#define PG2_PWM NULL
#undef PG3
#define PG3_PIN PING3
#define PG3_RPORT PING
#define PG3_WPORT PORTG
#define PG3_DDR DDRG
#define PG3_PWM NULL
#undef PG4
#define PG4_PIN PING4
#define PG4_RPORT PING
#define PG4_WPORT PORTG
#define PG4_DDR DDRG
#define PG4_PWM NULL
#undef PG5
#define PG5_PIN PING5
#define PG5_RPORT PING
#define PG5_WPORT PORTG
#define PG5_DDR DDRG
#define PG5_PWM &OCR0B
#undef PG6
#define PG6_PIN PING6
#define PG6_RPORT PING
#define PG6_WPORT PORTG
#define PG6_DDR DDRG
#define PG6_PWM NULL
#undef PG7
#define PG7_PIN PING7
#define PG7_RPORT PING
#define PG7_WPORT PORTG
#define PG7_DDR DDRG
#define PG7_PWM NULL
#undef PH0
#define PH0_PIN PINH0
#define PH0_RPORT PINH
#define PH0_WPORT PORTH
#define PH0_DDR DDRH
#define PH0_PWM NULL
#undef PH1
#define PH1_PIN PINH1
#define PH1_RPORT PINH
#define PH1_WPORT PORTH
#define PH1_DDR DDRH
#define PH1_PWM NULL
#undef PH2
#define PH2_PIN PINH2
#define PH2_RPORT PINH
#define PH2_WPORT PORTH
#define PH2_DDR DDRH
#define PH2_PWM NULL
#undef PH3
#define PH3_PIN PINH3
#define PH3_RPORT PINH
#define PH3_WPORT PORTH
#define PH3_DDR DDRH
#define PH3_PWM &OCR4AL
#undef PH4
#define PH4_PIN PINH4
#define PH4_RPORT PINH
#define PH4_WPORT PORTH
#define PH4_DDR DDRH
#define PH4_PWM &OCR4BL
#undef PH5
#define PH5_PIN PINH5
#define PH5_RPORT PINH
#define PH5_WPORT PORTH
#define PH5_DDR DDRH
#define PH5_PWM &OCR4CL
#undef PH6
#define PH6_PIN PINH6
#define PH6_RPORT PINH
#define PH6_WPORT PORTH
#define PH6_DDR DDRH
#define PH6_PWM &OCR2B
#undef PH7
#define PH7_PIN PINH7
#define PH7_RPORT PINH
#define PH7_WPORT PORTH
#define PH7_DDR DDRH
#define PH7_PWM NULL
#undef PJ0
#define PJ0_PIN PINJ0
#define PJ0_RPORT PINJ
#define PJ0_WPORT PORTJ
#define PJ0_DDR DDRJ
#define PJ0_PWM NULL
#undef PJ1
#define PJ1_PIN PINJ1
#define PJ1_RPORT PINJ
#define PJ1_WPORT PORTJ
#define PJ1_DDR DDRJ
#define PJ1_PWM NULL
#undef PJ2
#define PJ2_PIN PINJ2
#define PJ2_RPORT PINJ
#define PJ2_WPORT PORTJ
#define PJ2_DDR DDRJ
#define PJ2_PWM NULL
#undef PJ3
#define PJ3_PIN PINJ3
#define PJ3_RPORT PINJ
#define PJ3_WPORT PORTJ
#define PJ3_DDR DDRJ
#define PJ3_PWM NULL
#undef PJ4
#define PJ4_PIN PINJ4
#define PJ4_RPORT PINJ
#define PJ4_WPORT PORTJ
#define PJ4_DDR DDRJ
#define PJ4_PWM NULL
#undef PJ5
#define PJ5_PIN PINJ5
#define PJ5_RPORT PINJ
#define PJ5_WPORT PORTJ
#define PJ5_DDR DDRJ
#define PJ5_PWM NULL
#undef PJ6
#define PJ6_PIN PINJ6
#define PJ6_RPORT PINJ
#define PJ6_WPORT PORTJ
#define PJ6_DDR DDRJ
#define PJ6_PWM NULL
#undef PJ7
#define PJ7_PIN PINJ7
#define PJ7_RPORT PINJ
#define PJ7_WPORT PORTJ
#define PJ7_DDR DDRJ
#define PJ7_PWM NULL
#undef PK0
#define PK0_PIN PINK0
#define PK0_RPORT PINK
#define PK0_WPORT PORTK
#define PK0_DDR DDRK
#define PK0_PWM NULL
#undef PK1
#define PK1_PIN PINK1
#define PK1_RPORT PINK
#define PK1_WPORT PORTK
#define PK1_DDR DDRK
#define PK1_PWM NULL
#undef PK2
#define PK2_PIN PINK2
#define PK2_RPORT PINK
#define PK2_WPORT PORTK
#define PK2_DDR DDRK
#define PK2_PWM NULL
#undef PK3
#define PK3_PIN PINK3
#define PK3_RPORT PINK
#define PK3_WPORT PORTK
#define PK3_DDR DDRK
#define PK3_PWM NULL
#undef PK4
#define PK4_PIN PINK4
#define PK4_RPORT PINK
#define PK4_WPORT PORTK
#define PK4_DDR DDRK
#define PK4_PWM NULL
#undef PK5
#define PK5_PIN PINK5
#define PK5_RPORT PINK
#define PK5_WPORT PORTK
#define PK5_DDR DDRK
#define PK5_PWM NULL
#undef PK6
#define PK6_PIN PINK6
#define PK6_RPORT PINK
#define PK6_WPORT PORTK
#define PK6_DDR DDRK
#define PK6_PWM NULL
#undef PK7
#define PK7_PIN PINK7
#define PK7_RPORT PINK
#define PK7_WPORT PORTK
#define PK7_DDR DDRK
#define PK7_PWM NULL
#undef PL0
#define PL0_PIN PINL0
#define PL0_RPORT PINL
#define PL0_WPORT PORTL
#define PL0_DDR DDRL
#define PL0_PWM NULL
#undef PL1
#define PL1_PIN PINL1
#define PL1_RPORT PINL
#define PL1_WPORT PORTL
#define PL1_DDR DDRL
#define PL1_PWM NULL
#undef PL2
#define PL2_PIN PINL2
#define PL2_RPORT PINL
#define PL2_WPORT PORTL
#define PL2_DDR DDRL
#define PL2_PWM NULL
#undef PL3
#define PL3_PIN PINL3
#define PL3_RPORT PINL
#define PL3_WPORT PORTL
#define PL3_DDR DDRL
#define PL3_PWM &OCR5AL
#undef PL4
#define PL4_PIN PINL4
#define PL4_RPORT PINL
#define PL4_WPORT PORTL
#define PL4_DDR DDRL
#define PL4_PWM &OCR5BL
#undef PL5
#define PL5_PIN PINL5
#define PL5_RPORT PINL
#define PL5_WPORT PORTL
#define PL5_DDR DDRL
#define PL5_PWM &OCR5CL
#undef PL6
#define PL6_PIN PINL6
#define PL6_RPORT PINL
#define PL6_WPORT PORTL
#define PL6_DDR DDRL
#define PL6_PWM NULL
#undef PL7
#define PL7_PIN PINL7
#define PL7_RPORT PINL
#define PL7_WPORT PORTL
#define PL7_DDR DDRL
#define PL7_PWM NULL
#endif
#if defined (__AVR_AT90USB1287__)
// SPI
#define SCK DIO9
#define MISO DIO11
#define MOSI DIO10
#define SS DIO8
// change for your board
#define DEBUG_LED DIO31 /* led D5 red */
/*
pins
*/
#define DIO0_PIN PINA0
#define DIO0_RPORT PINA
#define DIO0_WPORT PORTA
#define DIO0_PWM NULL
#define DIO0_DDR DDRA
#define DIO1_PIN PINA1
#define DIO1_RPORT PINA
#define DIO1_WPORT PORTA
#define DIO1_PWM NULL
#define DIO1_DDR DDRA
#define DIO2_PIN PINA2
#define DIO2_RPORT PINA
#define DIO2_WPORT PORTA
#define DIO2_PWM NULL
#define DIO2_DDR DDRA
#define DIO3_PIN PINA3
#define DIO3_RPORT PINA
#define DIO3_WPORT PORTA
#define DIO3_PWM NULL
#define DIO3_DDR DDRA
#define DIO4_PIN PINA4
#define DIO4_RPORT PINA
#define DIO4_WPORT PORTA
#define DIO4_PWM NULL
#define DIO4_DDR DDRA
#define DIO5_PIN PINA5
#define DIO5_RPORT PINA
#define DIO5_WPORT PORTA
#define DIO5_PWM NULL
#define DIO5_DDR DDRA
#define DIO6_PIN PINA6
#define DIO6_RPORT PINA
#define DIO6_WPORT PORTA
#define DIO6_PWM NULL
#define DIO6_DDR DDRA
#define DIO7_PIN PINA7
#define DIO7_RPORT PINA
#define DIO7_WPORT PORTA
#define DIO7_PWM NULL
#define DIO7_DDR DDRA
#define DIO8_PIN PINB0
#define DIO8_RPORT PINB
#define DIO8_WPORT PORTB
#define DIO8_PWM NULL
#define DIO8_DDR DDRB
#define DIO9_PIN PINB1
#define DIO9_RPORT PINB
#define DIO9_WPORT PORTB
#define DIO9_PWM NULL
#define DIO9_DDR DDRB
#define DIO10_PIN PINB2
#define DIO10_RPORT PINB
#define DIO10_WPORT PORTB
#define DIO10_PWM NULL
#define DIO10_DDR DDRB
#define DIO11_PIN PINB3
#define DIO11_RPORT PINB
#define DIO11_WPORT PORTB
#define DIO11_PWM NULL
#define DIO11_DDR DDRB
#define DIO12_PIN PINB4
#define DIO12_RPORT PINB
#define DIO12_WPORT PORTB
#define DIO12_PWM NULL
#define DIO12_DDR DDRB
#define DIO13_PIN PINB5
#define DIO13_RPORT PINB
#define DIO13_WPORT PORTB
#define DIO13_PWM NULL
#define DIO13_DDR DDRB
#define DIO14_PIN PINB6
#define DIO14_RPORT PINB
#define DIO14_WPORT PORTB
#define DIO14_PWM NULL
#define DIO14_DDR DDRB
#define DIO15_PIN PINB7
#define DIO15_RPORT PINB
#define DIO15_WPORT PORTB
#define DIO15_PWM NULL
#define DIO15_DDR DDRB
#define DIO16_PIN PINC0
#define DIO16_RPORT PINC
#define DIO16_WPORT PORTC
#define DIO16_PWM NULL
#define DIO16_DDR DDRC
#define DIO17_PIN PINC1
#define DIO17_RPORT PINC
#define DIO17_WPORT PORTC
#define DIO17_PWM NULL
#define DIO17_DDR DDRC
#define DIO18_PIN PINC2
#define DIO18_RPORT PINC
#define DIO18_WPORT PORTC
#define DIO18_PWM NULL
#define DIO18_DDR DDRC
#define DIO19_PIN PINC3
#define DIO19_RPORT PINC
#define DIO19_WPORT PORTC
#define DIO19_PWM NULL
#define DIO19_DDR DDRC
#define DIO20_PIN PINC4
#define DIO20_RPORT PINC
#define DIO20_WPORT PORTC
#define DIO20_PWM NULL
#define DIO20_DDR DDRC
#define DIO21_PIN PINC5
#define DIO21_RPORT PINC
#define DIO21_WPORT PORTC
#define DIO21_PWM NULL
#define DIO21_DDR DDRC
#define DIO22_PIN PINC6
#define DIO22_RPORT PINC
#define DIO22_WPORT PORTC
#define DIO22_PWM NULL
#define DIO22_DDR DDRC
#define DIO23_PIN PINC7
#define DIO23_RPORT PINC
#define DIO23_WPORT PORTC
#define DIO23_PWM NULL
#define DIO23_DDR DDRC
#define DIO24_PIN PIND0
#define DIO24_RPORT PIND
#define DIO24_WPORT PORTD
#define DIO24_PWM NULL
#define DIO24_DDR DDRD
#define DIO25_PIN PIND1
#define DIO25_RPORT PIND
#define DIO25_WPORT PORTD
#define DIO25_PWM NULL
#define DIO25_DDR DDRD
#define DIO26_PIN PIND2
#define DIO26_RPORT PIND
#define DIO26_WPORT PORTD
#define DIO26_PWM NULL
#define DIO26_DDR DDRD
#define DIO27_PIN PIND3
#define DIO27_RPORT PIND
#define DIO27_WPORT PORTD
#define DIO27_PWM NULL
#define DIO27_DDR DDRD
#define DIO28_PIN PIND4
#define DIO28_RPORT PIND
#define DIO28_WPORT PORTD
#define DIO28_PWM NULL
#define DIO28_DDR DDRD
#define DIO29_PIN PIND5
#define DIO29_RPORT PIND
#define DIO29_WPORT PORTD
#define DIO29_PWM NULL
#define DIO29_DDR DDRD
#define DIO30_PIN PIND6
#define DIO30_RPORT PIND
#define DIO30_WPORT PORTD
#define DIO30_PWM NULL
#define DIO30_DDR DDRD
#define DIO31_PIN PIND7
#define DIO31_RPORT PIND
#define DIO31_WPORT PORTD
#define DIO31_PWM NULL
#define DIO31_DDR DDRD
#define DIO32_PIN PINE0
#define DIO32_RPORT PINE
#define DIO32_WPORT PORTE
#define DIO32_PWM NULL
#define DIO32_DDR DDRE
#define DIO33_PIN PINE1
#define DIO33_RPORT PINE
#define DIO33_WPORT PORTE
#define DIO33_PWM NULL
#define DIO33_DDR DDRE
#define DIO34_PIN PINE2
#define DIO34_RPORT PINE
#define DIO34_WPORT PORTE
#define DIO34_PWM NULL
#define DIO34_DDR DDRE
#define DIO35_PIN PINE3
#define DIO35_RPORT PINE
#define DIO35_WPORT PORTE
#define DIO35_PWM NULL
#define DIO35_DDR DDRE
#define DIO36_PIN PINE4
#define DIO36_RPORT PINE
#define DIO36_WPORT PORTE
#define DIO36_PWM NULL
#define DIO36_DDR DDRE
#define DIO37_PIN PINE5
#define DIO37_RPORT PINE
#define DIO37_WPORT PORTE
#define DIO37_PWM NULL
#define DIO37_DDR DDRE
#define DIO38_PIN PINE6
#define DIO38_RPORT PINE
#define DIO38_WPORT PORTE
#define DIO38_PWM NULL
#define DIO38_DDR DDRE
#define DIO39_PIN PINE7
#define DIO39_RPORT PINE
#define DIO39_WPORT PORTE
#define DIO39_PWM NULL
#define DIO39_DDR DDRE
#define AIO0_PIN PINF0
#define AIO0_RPORT PINF
#define AIO0_WPORT PORTF
#define AIO0_PWM NULL
#define AIO0_DDR DDRF
#define AIO1_PIN PINF1
#define AIO1_RPORT PINF
#define AIO1_WPORT PORTF
#define AIO1_PWM NULL
#define AIO1_DDR DDRF
#define AIO2_PIN PINF2
#define AIO2_RPORT PINF
#define AIO2_WPORT PORTF
#define AIO2_PWM NULL
#define AIO2_DDR DDRF
#define AIO3_PIN PINF3
#define AIO3_RPORT PINF
#define AIO3_WPORT PORTF
#define AIO3_PWM NULL
#define AIO3_DDR DDRF
#define AIO4_PIN PINF4
#define AIO4_RPORT PINF
#define AIO4_WPORT PORTF
#define AIO4_PWM NULL
#define AIO4_DDR DDRF
#define AIO5_PIN PINF5
#define AIO5_RPORT PINF
#define AIO5_WPORT PORTF
#define AIO5_PWM NULL
#define AIO5_DDR DDRF
#define AIO6_PIN PINF6
#define AIO6_RPORT PINF
#define AIO6_WPORT PORTF
#define AIO6_PWM NULL
#define AIO6_DDR DDRF
#define AIO7_PIN PINF7
#define AIO7_RPORT PINF
#define AIO7_WPORT PORTF
#define AIO7_PWM NULL
#define AIO7_DDR DDRF
#define DIO40_PIN PINF0
#define DIO40_RPORT PINF
#define DIO40_WPORT PORTF
#define DIO40_PWM NULL
#define DIO40_DDR DDRF
#define DIO41_PIN PINF1
#define DIO41_RPORT PINF
#define DIO41_WPORT PORTF
#define DIO41_PWM NULL
#define DIO41_DDR DDRF
#define DIO42_PIN PINF2
#define DIO42_RPORT PINF
#define DIO42_WPORT PORTF
#define DIO42_PWM NULL
#define DIO42_DDR DDRF
#define DIO43_PIN PINF3
#define DIO43_RPORT PINF
#define DIO43_WPORT PORTF
#define DIO43_PWM NULL
#define DIO43_DDR DDRF
#define DIO44_PIN PINF4
#define DIO44_RPORT PINF
#define DIO44_WPORT PORTF
#define DIO44_PWM NULL
#define DIO44_DDR DDRF
#define DIO45_PIN PINF5
#define DIO45_RPORT PINF
#define DIO45_WPORT PORTF
#define DIO45_PWM NULL
#define DIO45_DDR DDRF
#define DIO46_PIN PINF6
#define DIO46_RPORT PINF
#define DIO46_WPORT PORTF
#define DIO46_PWM NULL
#define DIO46_DDR DDRF
#define DIO47_PIN PINF7
#define DIO47_RPORT PINF
#define DIO47_WPORT PORTF
#define DIO47_PWM NULL
#define DIO47_DDR DDRF
#undef PA0
#define PA0_PIN PINA0
#define PA0_RPORT PINA
#define PA0_WPORT PORTA
#define PA0_PWM NULL
#define PA0_DDR DDRA
#undef PA1
#define PA1_PIN PINA1
#define PA1_RPORT PINA
#define PA1_WPORT PORTA
#define PA1_PWM NULL
#define PA1_DDR DDRA
#undef PA2
#define PA2_PIN PINA2
#define PA2_RPORT PINA
#define PA2_WPORT PORTA
#define PA2_PWM NULL
#define PA2_DDR DDRA
#undef PA3
#define PA3_PIN PINA3
#define PA3_RPORT PINA
#define PA3_WPORT PORTA
#define PA3_PWM NULL
#define PA3_DDR DDRA
#undef PA4
#define PA4_PIN PINA4
#define PA4_RPORT PINA
#define PA4_WPORT PORTA
#define PA4_PWM NULL
#define PA4_DDR DDRA
#undef PA5
#define PA5_PIN PINA5
#define PA5_RPORT PINA
#define PA5_WPORT PORTA
#define PA5_PWM NULL
#define PA5_DDR DDRA
#undef PA6
#define PA6_PIN PINA6
#define PA6_RPORT PINA
#define PA6_WPORT PORTA
#define PA6_PWM NULL
#define PA6_DDR DDRA
#undef PA7
#define PA7_PIN PINA7
#define PA7_RPORT PINA
#define PA7_WPORT PORTA
#define PA7_PWM NULL
#define PA7_DDR DDRA
#undef PB0
#define PB0_PIN PINB0
#define PB0_RPORT PINB
#define PB0_WPORT PORTB
#define PB0_PWM NULL
#define PB0_DDR DDRB
#undef PB1
#define PB1_PIN PINB1
#define PB1_RPORT PINB
#define PB1_WPORT PORTB
#define PB1_PWM NULL
#define PB1_DDR DDRB
#undef PB2
#define PB2_PIN PINB2
#define PB2_RPORT PINB
#define PB2_WPORT PORTB
#define PB2_PWM NULL
#define PB2_DDR DDRB
#undef PB3
#define PB3_PIN PINB3
#define PB3_RPORT PINB
#define PB3_WPORT PORTB
#define PB3_PWM NULL
#define PB3_DDR DDRB
#undef PB4
#define PB4_PIN PINB4
#define PB4_RPORT PINB
#define PB4_WPORT PORTB
#define PB4_PWM NULL
#define PB4_DDR DDRB
#undef PB5
#define PB5_PIN PINB5
#define PB5_RPORT PINB
#define PB5_WPORT PORTB
#define PB5_PWM NULL
#define PB5_DDR DDRB
#undef PB6
#define PB6_PIN PINB6
#define PB6_RPORT PINB
#define PB6_WPORT PORTB
#define PB6_PWM NULL
#define PB6_DDR DDRB
#undef PB7
#define PB7_PIN PINB7
#define PB7_RPORT PINB
#define PB7_WPORT PORTB
#define PB7_PWM NULL
#define PB7_DDR DDRB
#undef PC0
#define PC0_PIN PINC0
#define PC0_RPORT PINC
#define PC0_WPORT PORTC
#define PC0_PWM NULL
#define PC0_DDR DDRC
#undef PC1
#define PC1_PIN PINC1
#define PC1_RPORT PINC
#define PC1_WPORT PORTC
#define PC1_PWM NULL
#define PC1_DDR DDRC
#undef PC2
#define PC2_PIN PINC2
#define PC2_RPORT PINC
#define PC2_WPORT PORTC
#define PC2_PWM NULL
#define PC2_DDR DDRC
#undef PC3
#define PC3_PIN PINC3
#define PC3_RPORT PINC
#define PC3_WPORT PORTC
#define PC3_PWM NULL
#define PC3_DDR DDRC
#undef PC4
#define PC4_PIN PINC4
#define PC4_RPORT PINC
#define PC4_WPORT PORTC
#define PC4_PWM NULL
#define PC4_DDR DDRC
#undef PC5
#define PC5_PIN PINC5
#define PC5_RPORT PINC
#define PC5_WPORT PORTC
#define PC5_PWM NULL
#define PC5_DDR DDRC
#undef PC6
#define PC6_PIN PINC6
#define PC6_RPORT PINC
#define PC6_WPORT PORTC
#define PC6_PWM NULL
#define PC6_DDR DDRC
#undef PC7
#define PC7_PIN PINC7
#define PC7_RPORT PINC
#define PC7_WPORT PORTC
#define PC7_PWM NULL
#define PC7_DDR DDRC
#undef PD0
#define PD0_PIN PIND0
#define PD0_RPORT PIND
#define PD0_WPORT PORTD
#define PD0_PWM NULL
#define PD0_DDR DDRD
#undef PD1
#define PD1_PIN PIND1
#define PD1_RPORT PIND
#define PD1_WPORT PORTD
#define PD1_PWM NULL
#define PD1_DDR DDRD
#undef PD2
#define PD2_PIN PIND2
#define PD2_RPORT PIND
#define PD2_WPORT PORTD
#define PD2_PWM NULL
#define PD2_DDR DDRD
#undef PD3
#define PD3_PIN PIND3
#define PD3_RPORT PIND
#define PD3_WPORT PORTD
#define PD3_PWM NULL
#define PD3_DDR DDRD
#undef PD4
#define PD4_PIN PIND4
#define PD4_RPORT PIND
#define PD4_WPORT PORTD
#define PD4_PWM NULL
#define PD4_DDR DDRD
#undef PD5
#define PD5_PIN PIND5
#define PD5_RPORT PIND
#define PD5_WPORT PORTD
#define PD5_PWM NULL
#define PD5_DDR DDRD
#undef PD6
#define PD6_PIN PIND6
#define PD6_RPORT PIND
#define PD6_WPORT PORTD
#define PD6_PWM NULL
#define PD6_DDR DDRD
#undef PD7
#define PD7_PIN PIND7
#define PD7_RPORT PIND
#define PD7_WPORT PORTD
#define PD7_PWM NULL
#define PD7_DDR DDRD
#undef PE0
#define PE0_PIN PINE0
#define PE0_RPORT PINE
#define PE0_WPORT PORTE
#define PE0_PWM NULL
#define PE0_DDR DDRE
#undef PE1
#define PE1_PIN PINE1
#define PE1_RPORT PINE
#define PE1_WPORT PORTE
#define PE1_PWM NULL
#define PE1_DDR DDRE
#undef PE2
#define PE2_PIN PINE2
#define PE2_RPORT PINE
#define PE2_WPORT PORTE
#define PE2_PWM NULL
#define PE2_DDR DDRE
#undef PE3
#define PE3_PIN PINE3
#define PE3_RPORT PINE
#define PE3_WPORT PORTE
#define PE3_PWM NULL
#define PE3_DDR DDRE
#undef PE4
#define PE4_PIN PINE4
#define PE4_RPORT PINE
#define PE4_WPORT PORTE
#define PE4_PWM NULL
#define PE4_DDR DDRE
#undef PE5
#define PE5_PIN PINE5
#define PE5_RPORT PINE
#define PE5_WPORT PORTE
#define PE5_PWM NULL
#define PE5_DDR DDRE
#undef PE6
#define PE6_PIN PINE6
#define PE6_RPORT PINE
#define PE6_WPORT PORTE
#define PE6_PWM NULL
#define PE6_DDR DDRE
#undef PE7
#define PE7_PIN PINE7
#define PE7_RPORT PINE
#define PE7_WPORT PORTE
#define PE7_PWM NULL
#define PE7_DDR DDRE
#undef PF0
#define PF0_PIN PINF0
#define PF0_RPORT PINF
#define PF0_WPORT PORTF
#define PF0_PWM NULL
#define PF0_DDR DDRF
#undef PF1
#define PF1_PIN PINF1
#define PF1_RPORT PINF
#define PF1_WPORT PORTF
#define PF1_PWM NULL
#define PF1_DDR DDRF
#undef PF2
#define PF2_PIN PINF2
#define PF2_RPORT PINF
#define PF2_WPORT PORTF
#define PF2_PWM NULL
#define PF2_DDR DDRF
#undef PF3
#define PF3_PIN PINF3
#define PF3_RPORT PINF
#define PF3_WPORT PORTF
#define PF3_PWM NULL
#define PF3_DDR DDRF
#undef PF4
#define PF4_PIN PINF4
#define PF4_RPORT PINF
#define PF4_WPORT PORTF
#define PF4_PWM NULL
#define PF4_DDR DDRF
#undef PF5
#define PF5_PIN PINF5
#define PF5_RPORT PINF
#define PF5_WPORT PORTF
#define PF5_PWM NULL
#define PF5_DDR DDRF
#undef PF6
#define PF6_PIN PINF6
#define PF6_RPORT PINF
#define PF6_WPORT PORTF
#define PF6_PWM NULL
#define PF6_DDR DDRF
#undef PF7
#define PF7_PIN PINF7
#define PF7_RPORT PINF
#define PF7_WPORT PORTF
#define PF7_PWM NULL
#define PF7_DDR DDRF
#endif
#ifndef DIO0_PIN
#error pins for this chip not defined in arduino.h! If you write an appropriate pin definition and have this firmware work on your chip, please submit a pull request
#endif
/*
This code contibuted by Triffid_Hunter and modified by Kliment
why double up on these macros? see http://gcc.gnu.org/onlinedocs/cpp/Stringification.html
*/
#ifndef _ARDUINO_H
#define _ARDUINO_H
#include <avr/io.h>
/*
utility functions
*/
#ifndef MASK
/// MASKING- returns \f$2^PIN\f$
#define MASK(PIN) (1 << PIN)
#endif
/*
magic I/O routines
now you can simply SET_OUTPUT(STEP); WRITE(STEP, 1); WRITE(STEP, 0);
*/
/// Read a pin
#define _READ(IO) ((bool)(DIO ## IO ## _RPORT & MASK(DIO ## IO ## _PIN)))
/// write to a pin
// On some boards pins > 0x100 are used. These are not converted to atomic actions. An critical section is needed.
#define _WRITE_NC(IO, v) do { if (v) {DIO ## IO ## _WPORT |= MASK(DIO ## IO ## _PIN); } else {DIO ## IO ## _WPORT &= ~MASK(DIO ## IO ## _PIN); }; } while (0)
#define _WRITE_C(IO, v) do { if (v) { \
CRITICAL_SECTION_START; \
{DIO ## IO ## _WPORT |= MASK(DIO ## IO ## _PIN); }\
CRITICAL_SECTION_END; \
}\
else {\
CRITICAL_SECTION_START; \
{DIO ## IO ## _WPORT &= ~MASK(DIO ## IO ## _PIN); }\
CRITICAL_SECTION_END; \
}\
}\
while (0)
#define _WRITE(IO, v) do { if (&(DIO ## IO ## _RPORT) >= (uint8_t *)0x100) {_WRITE_C(IO, v); } else {_WRITE_NC(IO, v); }; } while (0)
/// toggle a pin
#define _TOGGLE(IO) do {DIO ## IO ## _RPORT = MASK(DIO ## IO ## _PIN); } while (0)
/// set pin as input
#define _SET_INPUT(IO) do {DIO ## IO ## _DDR &= ~MASK(DIO ## IO ## _PIN); } while (0)
/// set pin as output
#define _SET_OUTPUT(IO) do {DIO ## IO ## _DDR |= MASK(DIO ## IO ## _PIN); } while (0)
/// check if pin is an input
#define _GET_INPUT(IO) ((DIO ## IO ## _DDR & MASK(DIO ## IO ## _PIN)) == 0)
/// check if pin is an output
#define _GET_OUTPUT(IO) ((DIO ## IO ## _DDR & MASK(DIO ## IO ## _PIN)) != 0)
/// check if pin is an timer
#define _GET_TIMER(IO) ((DIO ## IO ## _PWM)
// why double up on these macros? see http://gcc.gnu.org/onlinedocs/cpp/Stringification.html
/// Read a pin wrapper
#define READ(IO) _READ(IO)
/// Write to a pin wrapper
#define WRITE(IO, v) _WRITE(IO, v)
/// toggle a pin wrapper
#define TOGGLE(IO) _TOGGLE(IO)
/// set pin as input wrapper
#define SET_INPUT(IO) _SET_INPUT(IO)
/// set pin as output wrapper
#define SET_OUTPUT(IO) _SET_OUTPUT(IO)
/// check if pin is an input wrapper
#define GET_INPUT(IO) _GET_INPUT(IO)
/// check if pin is an output wrapper
#define GET_OUTPUT(IO) _GET_OUTPUT(IO)
/// check if pin is an timer wrapper
#define GET_TIMER(IO) _GET_TIMER(IO)
/*
ports and functions
added as necessary or if I feel like it- not a comprehensive list!
*/
#if defined (__AVR_ATmega168__) || defined (__AVR_ATmega328__) || defined (__AVR_ATmega328P__)
// UART
#define RXD DIO0
#define TXD DIO1
// SPI
#define SCK DIO13
#define MISO DIO12
#define MOSI DIO11
#define SS DIO10
// TWI (I2C)
#define SCL AIO5
#define SDA AIO4
// timers and PWM
#define OC0A DIO6
#define OC0B DIO5
#define OC1A DIO9
#define OC1B DIO10
#define OC2A DIO11
#define OC2B DIO3
#define DEBUG_LED AIO5
/*
pins
*/
#define DIO0_PIN PIND0
#define DIO0_RPORT PIND
#define DIO0_WPORT PORTD
#define DIO0_DDR DDRD
#define DIO0_PWM NULL
#define DIO1_PIN PIND1
#define DIO1_RPORT PIND
#define DIO1_WPORT PORTD
#define DIO1_DDR DDRD
#define DIO1_PWM NULL
#define DIO2_PIN PIND2
#define DIO2_RPORT PIND
#define DIO2_WPORT PORTD
#define DIO2_DDR DDRD
#define DIO2_PWM NULL
#define DIO3_PIN PIND3
#define DIO3_RPORT PIND
#define DIO3_WPORT PORTD
#define DIO3_DDR DDRD
#define DIO3_PWM &OCR2B
#define DIO4_PIN PIND4
#define DIO4_RPORT PIND
#define DIO4_WPORT PORTD
#define DIO4_DDR DDRD
#define DIO4_PWM NULL
#define DIO5_PIN PIND5
#define DIO5_RPORT PIND
#define DIO5_WPORT PORTD
#define DIO5_DDR DDRD
#define DIO5_PWM &OCR0B
#define DIO6_PIN PIND6
#define DIO6_RPORT PIND
#define DIO6_WPORT PORTD
#define DIO6_DDR DDRD
#define DIO6_PWM &OCR0A
#define DIO7_PIN PIND7
#define DIO7_RPORT PIND
#define DIO7_WPORT PORTD
#define DIO7_DDR DDRD
#define DIO7_PWM NULL
#define DIO8_PIN PINB0
#define DIO8_RPORT PINB
#define DIO8_WPORT PORTB
#define DIO8_DDR DDRB
#define DIO8_PWM NULL
#define DIO9_PIN PINB1
#define DIO9_RPORT PINB
#define DIO9_WPORT PORTB
#define DIO9_DDR DDRB
#define DIO9_PWM NULL
#define DIO10_PIN PINB2
#define DIO10_RPORT PINB
#define DIO10_WPORT PORTB
#define DIO10_DDR DDRB
#define DIO10_PWM NULL
#define DIO11_PIN PINB3
#define DIO11_RPORT PINB
#define DIO11_WPORT PORTB
#define DIO11_DDR DDRB
#define DIO11_PWM &OCR2A
#define DIO12_PIN PINB4
#define DIO12_RPORT PINB
#define DIO12_WPORT PORTB
#define DIO12_DDR DDRB
#define DIO12_PWM NULL
#define DIO13_PIN PINB5
#define DIO13_RPORT PINB
#define DIO13_WPORT PORTB
#define DIO13_DDR DDRB
#define DIO13_PWM NULL
#define DIO14_PIN PINC0
#define DIO14_RPORT PINC
#define DIO14_WPORT PORTC
#define DIO14_DDR DDRC
#define DIO14_PWM NULL
#define DIO15_PIN PINC1
#define DIO15_RPORT PINC
#define DIO15_WPORT PORTC
#define DIO15_DDR DDRC
#define DIO15_PWM NULL
#define DIO16_PIN PINC2
#define DIO16_RPORT PINC
#define DIO16_WPORT PORTC
#define DIO16_DDR DDRC
#define DIO16_PWM NULL
#define DIO17_PIN PINC3
#define DIO17_RPORT PINC
#define DIO17_WPORT PORTC
#define DIO17_DDR DDRC
#define DIO17_PWM NULL
#define DIO18_PIN PINC4
#define DIO18_RPORT PINC
#define DIO18_WPORT PORTC
#define DIO18_DDR DDRC
#define DIO18_PWM NULL
#define DIO19_PIN PINC5
#define DIO19_RPORT PINC
#define DIO19_WPORT PORTC
#define DIO19_DDR DDRC
#define DIO19_PWM NULL
#define DIO20_PIN PINC6
#define DIO20_RPORT PINC
#define DIO20_WPORT PORTC
#define DIO20_DDR DDRC
#define DIO20_PWM NULL
#define DIO21_PIN PINC7
#define DIO21_RPORT PINC
#define DIO21_WPORT PORTC
#define DIO21_DDR DDRC
#define DIO21_PWM NULL
#undef PB0
#define PB0_PIN PINB0
#define PB0_RPORT PINB
#define PB0_WPORT PORTB
#define PB0_DDR DDRB
#define PB0_PWM NULL
#undef PB1
#define PB1_PIN PINB1
#define PB1_RPORT PINB
#define PB1_WPORT PORTB
#define PB1_DDR DDRB
#define PB1_PWM NULL
#undef PB2
#define PB2_PIN PINB2
#define PB2_RPORT PINB
#define PB2_WPORT PORTB
#define PB2_DDR DDRB
#define PB2_PWM NULL
#undef PB3
#define PB3_PIN PINB3
#define PB3_RPORT PINB
#define PB3_WPORT PORTB
#define PB3_DDR DDRB
#define PB3_PWM &OCR2A
#undef PB4
#define PB4_PIN PINB4
#define PB4_RPORT PINB
#define PB4_WPORT PORTB
#define PB4_DDR DDRB
#define PB4_PWM NULL
#undef PB5
#define PB5_PIN PINB5
#define PB5_RPORT PINB
#define PB5_WPORT PORTB
#define PB5_DDR DDRB
#define PB5_PWM NULL
#undef PB6
#define PB6_PIN PINB6
#define PB6_RPORT PINB
#define PB6_WPORT PORTB
#define PB6_DDR DDRB
#define PB6_PWM NULL
#undef PB7
#define PB7_PIN PINB7
#define PB7_RPORT PINB
#define PB7_WPORT PORTB
#define PB7_DDR DDRB
#define PB7_PWM NULL
#undef PC0
#define PC0_PIN PINC0
#define PC0_RPORT PINC
#define PC0_WPORT PORTC
#define PC0_DDR DDRC
#define PC0_PWM NULL
#undef PC1
#define PC1_PIN PINC1
#define PC1_RPORT PINC
#define PC1_WPORT PORTC
#define PC1_DDR DDRC
#define PC1_PWM NULL
#undef PC2
#define PC2_PIN PINC2
#define PC2_RPORT PINC
#define PC2_WPORT PORTC
#define PC2_DDR DDRC
#define PC2_PWM NULL
#undef PC3
#define PC3_PIN PINC3
#define PC3_RPORT PINC
#define PC3_WPORT PORTC
#define PC3_DDR DDRC
#define PC3_PWM NULL
#undef PC4
#define PC4_PIN PINC4
#define PC4_RPORT PINC
#define PC4_WPORT PORTC
#define PC4_DDR DDRC
#define PC4_PWM NULL
#undef PC5
#define PC5_PIN PINC5
#define PC5_RPORT PINC
#define PC5_WPORT PORTC
#define PC5_DDR DDRC
#define PC5_PWM NULL
#undef PC6
#define PC6_PIN PINC6
#define PC6_RPORT PINC
#define PC6_WPORT PORTC
#define PC6_DDR DDRC
#define PC6_PWM NULL
#undef PC7
#define PC7_PIN PINC7
#define PC7_RPORT PINC
#define PC7_WPORT PORTC
#define PC7_DDR DDRC
#define PC7_PWM NULL
#undef PD0
#define PD0_PIN PIND0
#define PD0_RPORT PIND
#define PD0_WPORT PORTD
#define PD0_DDR DDRD
#define PD0_PWM NULL
#undef PD1
#define PD1_PIN PIND1
#define PD1_RPORT PIND
#define PD1_WPORT PORTD
#define PD1_DDR DDRD
#define PD1_PWM NULL
#undef PD2
#define PD2_PIN PIND2
#define PD2_RPORT PIND
#define PD2_WPORT PORTD
#define PD2_DDR DDRD
#define PD2_PWM NULL
#undef PD3
#define PD3_PIN PIND3
#define PD3_RPORT PIND
#define PD3_WPORT PORTD
#define PD3_DDR DDRD
#define PD3_PWM &OCR2B
#undef PD4
#define PD4_PIN PIND4
#define PD4_RPORT PIND
#define PD4_WPORT PORTD
#define PD4_DDR DDRD
#define PD4_PWM NULL
#undef PD5
#define PD5_PIN PIND5
#define PD5_RPORT PIND
#define PD5_WPORT PORTD
#define PD5_DDR DDRD
#define PD5_PWM &OCR0B
#undef PD6
#define PD6_PIN PIND6
#define PD6_RPORT PIND
#define PD6_WPORT PORTD
#define PD6_DDR DDRD
#define PD6_PWM &OCR0A
#undef PD7
#define PD7_PIN PIND7
#define PD7_RPORT PIND
#define PD7_WPORT PORTD
#define PD7_DDR DDRD
#define PD7_PWM NULL
#endif /* _AVR_ATmega{168,328,328P}__ */
#if defined (__AVR_ATmega644__) || defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644PA__)
// UART
#define RXD DIO8
#define TXD DIO9
#define RXD0 DIO8
#define TXD0 DIO9
#define RXD1 DIO10
#define TXD1 DIO11
// SPI
#define SCK DIO7
#define MISO DIO6
#define MOSI DIO5
#define SS DIO4
// TWI (I2C)
#define SCL DIO16
#define SDA DIO17
// timers and PWM
#define OC0A DIO3
#define OC0B DIO4
#define OC1A DIO13
#define OC1B DIO12
#define OC2A DIO15
#define OC2B DIO14
#define DEBUG_LED DIO0
/*
pins
*/
#define DIO0_PIN PINB0
#define DIO0_RPORT PINB
#define DIO0_WPORT PORTB
#define DIO0_DDR DDRB
#define DIO0_PWM NULL
#define DIO1_PIN PINB1
#define DIO1_RPORT PINB
#define DIO1_WPORT PORTB
#define DIO1_DDR DDRB
#define DIO1_PWM NULL
#define DIO2_PIN PINB2
#define DIO2_RPORT PINB
#define DIO2_WPORT PORTB
#define DIO2_DDR DDRB
#define DIO2_PWM NULL
#define DIO3_PIN PINB3
#define DIO3_RPORT PINB
#define DIO3_WPORT PORTB
#define DIO3_DDR DDRB
#define DIO3_PWM OCR0A
#define DIO4_PIN PINB4
#define DIO4_RPORT PINB
#define DIO4_WPORT PORTB
#define DIO4_DDR DDRB
#define DIO4_PWM OCR0B
#define DIO5_PIN PINB5
#define DIO5_RPORT PINB
#define DIO5_WPORT PORTB
#define DIO5_DDR DDRB
#define DIO5_PWM NULL
#define DIO6_PIN PINB6
#define DIO6_RPORT PINB
#define DIO6_WPORT PORTB
#define DIO6_DDR DDRB
#define DIO6_PWM NULL
#define DIO7_PIN PINB7
#define DIO7_RPORT PINB
#define DIO7_WPORT PORTB
#define DIO7_DDR DDRB
#define DIO7_PWM NULL
#define DIO8_PIN PIND0
#define DIO8_RPORT PIND
#define DIO8_WPORT PORTD
#define DIO8_DDR DDRD
#define DIO8_PWM NULL
#define DIO9_PIN PIND1
#define DIO9_RPORT PIND
#define DIO9_WPORT PORTD
#define DIO9_DDR DDRD
#define DIO9_PWM NULL
#define DIO10_PIN PIND2
#define DIO10_RPORT PIND
#define DIO10_WPORT PORTD
#define DIO10_DDR DDRD
#define DIO10_PWM NULL
#define DIO11_PIN PIND3
#define DIO11_RPORT PIND
#define DIO11_WPORT PORTD
#define DIO11_DDR DDRD
#define DIO11_PWM NULL
#define DIO12_PIN PIND4
#define DIO12_RPORT PIND
#define DIO12_WPORT PORTD
#define DIO12_DDR DDRD
#define DIO12_PWM OCR1B
#define DIO13_PIN PIND5
#define DIO13_RPORT PIND
#define DIO13_WPORT PORTD
#define DIO13_DDR DDRD
#define DIO13_PWM OCR1A
#define DIO14_PIN PIND6
#define DIO14_RPORT PIND
#define DIO14_WPORT PORTD
#define DIO14_DDR DDRD
#define DIO14_PWM OCR2B
#define DIO15_PIN PIND7
#define DIO15_RPORT PIND
#define DIO15_WPORT PORTD
#define DIO15_DDR DDRD
#define DIO15_PWM OCR2A
#define DIO16_PIN PINC0
#define DIO16_RPORT PINC
#define DIO16_WPORT PORTC
#define DIO16_DDR DDRC
#define DIO16_PWM NULL
#define DIO17_PIN PINC1
#define DIO17_RPORT PINC
#define DIO17_WPORT PORTC
#define DIO17_DDR DDRC
#define DIO17_PWM NULL
#define DIO18_PIN PINC2
#define DIO18_RPORT PINC
#define DIO18_WPORT PORTC
#define DIO18_DDR DDRC
#define DIO18_PWM NULL
#define DIO19_PIN PINC3
#define DIO19_RPORT PINC
#define DIO19_WPORT PORTC
#define DIO19_DDR DDRC
#define DIO19_PWM NULL
#define DIO20_PIN PINC4
#define DIO20_RPORT PINC
#define DIO20_WPORT PORTC
#define DIO20_DDR DDRC
#define DIO20_PWM NULL
#define DIO21_PIN PINC5
#define DIO21_RPORT PINC
#define DIO21_WPORT PORTC
#define DIO21_DDR DDRC
#define DIO21_PWM NULL
#define DIO22_PIN PINC6
#define DIO22_RPORT PINC
#define DIO22_WPORT PORTC
#define DIO22_DDR DDRC
#define DIO22_PWM NULL
#define DIO23_PIN PINC7
#define DIO23_RPORT PINC
#define DIO23_WPORT PORTC
#define DIO23_DDR DDRC
#define DIO23_PWM NULL
#define DIO24_PIN PINA7
#define DIO24_RPORT PINA
#define DIO24_WPORT PORTA
#define DIO24_DDR DDRA
#define DIO24_PWM NULL
#define DIO25_PIN PINA6
#define DIO25_RPORT PINA
#define DIO25_WPORT PORTA
#define DIO25_DDR DDRA
#define DIO25_PWM NULL
#define DIO26_PIN PINA5
#define DIO26_RPORT PINA
#define DIO26_WPORT PORTA
#define DIO26_DDR DDRA
#define DIO26_PWM NULL
#define DIO27_PIN PINA4
#define DIO27_RPORT PINA
#define DIO27_WPORT PORTA
#define DIO27_DDR DDRA
#define DIO27_PWM NULL
#define DIO28_PIN PINA3
#define DIO28_RPORT PINA
#define DIO28_WPORT PORTA
#define DIO28_DDR DDRA
#define DIO28_PWM NULL
#define DIO29_PIN PINA2
#define DIO29_RPORT PINA
#define DIO29_WPORT PORTA
#define DIO29_DDR DDRA
#define DIO29_PWM NULL
#define DIO30_PIN PINA1
#define DIO30_RPORT PINA
#define DIO30_WPORT PORTA
#define DIO30_DDR DDRA
#define DIO30_PWM NULL
#define DIO31_PIN PINA0
#define DIO31_RPORT PINA
#define DIO31_WPORT PORTA
#define DIO31_DDR DDRA
#define DIO31_PWM NULL
#define AIO0_PIN PINA0
#define AIO0_RPORT PINA
#define AIO0_WPORT PORTA
#define AIO0_DDR DDRA
#define AIO0_PWM NULL
#define AIO1_PIN PINA1
#define AIO1_RPORT PINA
#define AIO1_WPORT PORTA
#define AIO1_DDR DDRA
#define AIO1_PWM NULL
#define AIO2_PIN PINA2
#define AIO2_RPORT PINA
#define AIO2_WPORT PORTA
#define AIO2_DDR DDRA
#define AIO2_PWM NULL
#define AIO3_PIN PINA3
#define AIO3_RPORT PINA
#define AIO3_WPORT PORTA
#define AIO3_DDR DDRA
#define AIO3_PWM NULL
#define AIO4_PIN PINA4
#define AIO4_RPORT PINA
#define AIO4_WPORT PORTA
#define AIO4_DDR DDRA
#define AIO4_PWM NULL
#define AIO5_PIN PINA5
#define AIO5_RPORT PINA
#define AIO5_WPORT PORTA
#define AIO5_DDR DDRA
#define AIO5_PWM NULL
#define AIO6_PIN PINA6
#define AIO6_RPORT PINA
#define AIO6_WPORT PORTA
#define AIO6_DDR DDRA
#define AIO6_PWM NULL
#define AIO7_PIN PINA7
#define AIO7_RPORT PINA
#define AIO7_WPORT PORTA
#define AIO7_DDR DDRA
#define AIO7_PWM NULL
#undef PA0
#define PA0_PIN PINA0
#define PA0_RPORT PINA
#define PA0_WPORT PORTA
#define PA0_DDR DDRA
#define PA0_PWM NULL
#undef PA1
#define PA1_PIN PINA1
#define PA1_RPORT PINA
#define PA1_WPORT PORTA
#define PA1_DDR DDRA
#define PA1_PWM NULL
#undef PA2
#define PA2_PIN PINA2
#define PA2_RPORT PINA
#define PA2_WPORT PORTA
#define PA2_DDR DDRA
#define PA2_PWM NULL
#undef PA3
#define PA3_PIN PINA3
#define PA3_RPORT PINA
#define PA3_WPORT PORTA
#define PA3_DDR DDRA
#define PA3_PWM NULL
#undef PA4
#define PA4_PIN PINA4
#define PA4_RPORT PINA
#define PA4_WPORT PORTA
#define PA4_DDR DDRA
#define PA4_PWM NULL
#undef PA5
#define PA5_PIN PINA5
#define PA5_RPORT PINA
#define PA5_WPORT PORTA
#define PA5_DDR DDRA
#define PA5_PWM NULL
#undef PA6
#define PA6_PIN PINA6
#define PA6_RPORT PINA
#define PA6_WPORT PORTA
#define PA6_DDR DDRA
#define PA6_PWM NULL
#undef PA7
#define PA7_PIN PINA7
#define PA7_RPORT PINA
#define PA7_WPORT PORTA
#define PA7_DDR DDRA
#define PA7_PWM NULL
#undef PB0
#define PB0_PIN PINB0
#define PB0_RPORT PINB
#define PB0_WPORT PORTB
#define PB0_DDR DDRB
#define PB0_PWM NULL
#undef PB1
#define PB1_PIN PINB1
#define PB1_RPORT PINB
#define PB1_WPORT PORTB
#define PB1_DDR DDRB
#define PB1_PWM NULL
#undef PB2
#define PB2_PIN PINB2
#define PB2_RPORT PINB
#define PB2_WPORT PORTB
#define PB2_DDR DDRB
#define PB2_PWM NULL
#undef PB3
#define PB3_PIN PINB3
#define PB3_RPORT PINB
#define PB3_WPORT PORTB
#define PB3_DDR DDRB
#define PB3_PWM OCR0A
#undef PB4
#define PB4_PIN PINB4
#define PB4_RPORT PINB
#define PB4_WPORT PORTB
#define PB4_DDR DDRB
#define PB4_PWM OCR0B
#undef PB5
#define PB5_PIN PINB5
#define PB5_RPORT PINB
#define PB5_WPORT PORTB
#define PB5_DDR DDRB
#define PB5_PWM NULL
#undef PB6
#define PB6_PIN PINB6
#define PB6_RPORT PINB
#define PB6_WPORT PORTB
#define PB6_DDR DDRB
#define PB6_PWM NULL
#undef PB7
#define PB7_PIN PINB7
#define PB7_RPORT PINB
#define PB7_WPORT PORTB
#define PB7_DDR DDRB
#define PB7_PWM NULL
#undef PC0
#define PC0_PIN PINC0
#define PC0_RPORT PINC
#define PC0_WPORT PORTC
#define PC0_DDR DDRC
#define PC0_PWM NULL
#undef PC1
#define PC1_PIN PINC1
#define PC1_RPORT PINC
#define PC1_WPORT PORTC
#define PC1_DDR DDRC
#define PC1_PWM NULL
#undef PC2
#define PC2_PIN PINC2
#define PC2_RPORT PINC
#define PC2_WPORT PORTC
#define PC2_DDR DDRC
#define PC2_PWM NULL
#undef PC3
#define PC3_PIN PINC3
#define PC3_RPORT PINC
#define PC3_WPORT PORTC
#define PC3_DDR DDRC
#define PC3_PWM NULL
#undef PC4
#define PC4_PIN PINC4
#define PC4_RPORT PINC
#define PC4_WPORT PORTC
#define PC4_DDR DDRC
#define PC4_PWM NULL
#undef PC5
#define PC5_PIN PINC5
#define PC5_RPORT PINC
#define PC5_WPORT PORTC
#define PC5_DDR DDRC
#define PC5_PWM NULL
#undef PC6
#define PC6_PIN PINC6
#define PC6_RPORT PINC
#define PC6_WPORT PORTC
#define PC6_DDR DDRC
#define PC6_PWM NULL
#undef PC7
#define PC7_PIN PINC7
#define PC7_RPORT PINC
#define PC7_WPORT PORTC
#define PC7_DDR DDRC
#define PC7_PWM NULL
#undef PD0
#define PD0_PIN PIND0
#define PD0_RPORT PIND
#define PD0_WPORT PORTD
#define PD0_DDR DDRD
#define PD0_PWM NULL
#undef PD1
#define PD1_PIN PIND1
#define PD1_RPORT PIND
#define PD1_WPORT PORTD
#define PD1_DDR DDRD
#define PD1_PWM NULL
#undef PD2
#define PD2_PIN PIND2
#define PD2_RPORT PIND
#define PD2_WPORT PORTD
#define PD2_DDR DDRD
#define PD2_PWM NULL
#undef PD3
#define PD3_PIN PIND3
#define PD3_RPORT PIND
#define PD3_WPORT PORTD
#define PD3_DDR DDRD
#define PD3_PWM NULL
#undef PD4
#define PD4_PIN PIND4
#define PD4_RPORT PIND
#define PD4_WPORT PORTD
#define PD4_DDR DDRD
#define PD4_PWM NULL
#undef PD5
#define PD5_PIN PIND5
#define PD5_RPORT PIND
#define PD5_WPORT PORTD
#define PD5_DDR DDRD
#define PD5_PWM NULL
#undef PD6
#define PD6_PIN PIND6
#define PD6_RPORT PIND
#define PD6_WPORT PORTD
#define PD6_DDR DDRD
#define PD6_PWM OCR2B
#undef PD7
#define PD7_PIN PIND7
#define PD7_RPORT PIND
#define PD7_WPORT PORTD
#define PD7_DDR DDRD
#define PD7_PWM OCR2A
#endif /* _AVR_ATmega{644,644P,644PA}__ */
#if defined (__AVR_ATmega1280__) || defined (__AVR_ATmega2560__)
// UART
#define RXD DIO0
#define TXD DIO1
// SPI
#define SCK DIO52
#define MISO DIO50
#define MOSI DIO51
#define SS DIO53
// TWI (I2C)
#define SCL DIO21
#define SDA DIO20
// timers and PWM
#define OC0A DIO13
#define OC0B DIO4
#define OC1A DIO11
#define OC1B DIO12
#define OC2A DIO10
#define OC2B DIO9
#define OC3A DIO5
#define OC3B DIO2
#define OC3C DIO3
#define OC4A DIO6
#define OC4B DIO7
#define OC4C DIO8
#define OC5A DIO46
#define OC5B DIO45
#define OC5C DIO44
// change for your board
#define DEBUG_LED DIO21
/*
pins
*/
#define DIO0_PIN PINE0
#define DIO0_RPORT PINE
#define DIO0_WPORT PORTE
#define DIO0_DDR DDRE
#define DIO0_PWM NULL
#define DIO1_PIN PINE1
#define DIO1_RPORT PINE
#define DIO1_WPORT PORTE
#define DIO1_DDR DDRE
#define DIO1_PWM NULL
#define DIO2_PIN PINE4
#define DIO2_RPORT PINE
#define DIO2_WPORT PORTE
#define DIO2_DDR DDRE
#define DIO2_PWM &OCR3BL
#define DIO3_PIN PINE5
#define DIO3_RPORT PINE
#define DIO3_WPORT PORTE
#define DIO3_DDR DDRE
#define DIO3_PWM &OCR3CL
#define DIO4_PIN PING5
#define DIO4_RPORT PING
#define DIO4_WPORT PORTG
#define DIO4_DDR DDRG
#define DIO4_PWM &OCR0B
#define DIO5_PIN PINE3
#define DIO5_RPORT PINE
#define DIO5_WPORT PORTE
#define DIO5_DDR DDRE
#define DIO5_PWM &OCR3AL
#define DIO6_PIN PINH3
#define DIO6_RPORT PINH
#define DIO6_WPORT PORTH
#define DIO6_DDR DDRH
#define DIO6_PWM &OCR4AL
#define DIO7_PIN PINH4
#define DIO7_RPORT PINH
#define DIO7_WPORT PORTH
#define DIO7_DDR DDRH
#define DIO7_PWM &OCR4BL
#define DIO8_PIN PINH5
#define DIO8_RPORT PINH
#define DIO8_WPORT PORTH
#define DIO8_DDR DDRH
#define DIO8_PWM &OCR4CL
#define DIO9_PIN PINH6
#define DIO9_RPORT PINH
#define DIO9_WPORT PORTH
#define DIO9_DDR DDRH
#define DIO9_PWM &OCR2B
#define DIO10_PIN PINB4
#define DIO10_RPORT PINB
#define DIO10_WPORT PORTB
#define DIO10_DDR DDRB
#define DIO10_PWM &OCR2A
#define DIO11_PIN PINB5
#define DIO11_RPORT PINB
#define DIO11_WPORT PORTB
#define DIO11_DDR DDRB
#define DIO11_PWM NULL
#define DIO12_PIN PINB6
#define DIO12_RPORT PINB
#define DIO12_WPORT PORTB
#define DIO12_DDR DDRB
#define DIO12_PWM NULL
#define DIO13_PIN PINB7
#define DIO13_RPORT PINB
#define DIO13_WPORT PORTB
#define DIO13_DDR DDRB
#define DIO13_PWM &OCR0A
#define DIO14_PIN PINJ1
#define DIO14_RPORT PINJ
#define DIO14_WPORT PORTJ
#define DIO14_DDR DDRJ
#define DIO14_PWM NULL
#define DIO15_PIN PINJ0
#define DIO15_RPORT PINJ
#define DIO15_WPORT PORTJ
#define DIO15_DDR DDRJ
#define DIO15_PWM NULL
#define DIO16_PIN PINH1
#define DIO16_RPORT PINH
#define DIO16_WPORT PORTH
#define DIO16_DDR DDRH
#define DIO16_PWM NULL
#define DIO17_PIN PINH0
#define DIO17_RPORT PINH
#define DIO17_WPORT PORTH
#define DIO17_DDR DDRH
#define DIO17_PWM NULL
#define DIO18_PIN PIND3
#define DIO18_RPORT PIND
#define DIO18_WPORT PORTD
#define DIO18_DDR DDRD
#define DIO18_PWM NULL
#define DIO19_PIN PIND2
#define DIO19_RPORT PIND
#define DIO19_WPORT PORTD
#define DIO19_DDR DDRD
#define DIO19_PWM NULL
#define DIO20_PIN PIND1
#define DIO20_RPORT PIND
#define DIO20_WPORT PORTD
#define DIO20_DDR DDRD
#define DIO20_PWM NULL
#define DIO21_PIN PIND0
#define DIO21_RPORT PIND
#define DIO21_WPORT PORTD
#define DIO21_DDR DDRD
#define DIO21_PWM NULL
#define DIO22_PIN PINA0
#define DIO22_RPORT PINA
#define DIO22_WPORT PORTA
#define DIO22_DDR DDRA
#define DIO22_PWM NULL
#define DIO23_PIN PINA1
#define DIO23_RPORT PINA
#define DIO23_WPORT PORTA
#define DIO23_DDR DDRA
#define DIO23_PWM NULL
#define DIO24_PIN PINA2
#define DIO24_RPORT PINA
#define DIO24_WPORT PORTA
#define DIO24_DDR DDRA
#define DIO24_PWM NULL
#define DIO25_PIN PINA3
#define DIO25_RPORT PINA
#define DIO25_WPORT PORTA
#define DIO25_DDR DDRA
#define DIO25_PWM NULL
#define DIO26_PIN PINA4
#define DIO26_RPORT PINA
#define DIO26_WPORT PORTA
#define DIO26_DDR DDRA
#define DIO26_PWM NULL
#define DIO27_PIN PINA5
#define DIO27_RPORT PINA
#define DIO27_WPORT PORTA
#define DIO27_DDR DDRA
#define DIO27_PWM NULL
#define DIO28_PIN PINA6
#define DIO28_RPORT PINA
#define DIO28_WPORT PORTA
#define DIO28_DDR DDRA
#define DIO28_PWM NULL
#define DIO29_PIN PINA7
#define DIO29_RPORT PINA
#define DIO29_WPORT PORTA
#define DIO29_DDR DDRA
#define DIO29_PWM NULL
#define DIO30_PIN PINC7
#define DIO30_RPORT PINC
#define DIO30_WPORT PORTC
#define DIO30_DDR DDRC
#define DIO30_PWM NULL
#define DIO31_PIN PINC6
#define DIO31_RPORT PINC
#define DIO31_WPORT PORTC
#define DIO31_DDR DDRC
#define DIO31_PWM NULL
#define DIO32_PIN PINC5
#define DIO32_RPORT PINC
#define DIO32_WPORT PORTC
#define DIO32_DDR DDRC
#define DIO32_PWM NULL
#define DIO33_PIN PINC4
#define DIO33_RPORT PINC
#define DIO33_WPORT PORTC
#define DIO33_DDR DDRC
#define DIO33_PWM NULL
#define DIO34_PIN PINC3
#define DIO34_RPORT PINC
#define DIO34_WPORT PORTC
#define DIO34_DDR DDRC
#define DIO34_PWM NULL
#define DIO35_PIN PINC2
#define DIO35_RPORT PINC
#define DIO35_WPORT PORTC
#define DIO35_DDR DDRC
#define DIO35_PWM NULL
#define DIO36_PIN PINC1
#define DIO36_RPORT PINC
#define DIO36_WPORT PORTC
#define DIO36_DDR DDRC
#define DIO36_PWM NULL
#define DIO37_PIN PINC0
#define DIO37_RPORT PINC
#define DIO37_WPORT PORTC
#define DIO37_DDR DDRC
#define DIO37_PWM NULL
#define DIO38_PIN PIND7
#define DIO38_RPORT PIND
#define DIO38_WPORT PORTD
#define DIO38_DDR DDRD
#define DIO38_PWM NULL
#define DIO39_PIN PING2
#define DIO39_RPORT PING
#define DIO39_WPORT PORTG
#define DIO39_DDR DDRG
#define DIO39_PWM NULL
#define DIO40_PIN PING1
#define DIO40_RPORT PING
#define DIO40_WPORT PORTG
#define DIO40_DDR DDRG
#define DIO40_PWM NULL
#define DIO41_PIN PING0
#define DIO41_RPORT PING
#define DIO41_WPORT PORTG
#define DIO41_DDR DDRG
#define DIO41_PWM NULL
#define DIO42_PIN PINL7
#define DIO42_RPORT PINL
#define DIO42_WPORT PORTL
#define DIO42_DDR DDRL
#define DIO42_PWM NULL
#define DIO43_PIN PINL6
#define DIO43_RPORT PINL
#define DIO43_WPORT PORTL
#define DIO43_DDR DDRL
#define DIO43_PWM NULL
#define DIO44_PIN PINL5
#define DIO44_RPORT PINL
#define DIO44_WPORT PORTL
#define DIO44_DDR DDRL
#define DIO44_PWM &OCR5CL
#define DIO45_PIN PINL4
#define DIO45_RPORT PINL
#define DIO45_WPORT PORTL
#define DIO45_DDR DDRL
#define DIO45_PWM &OCR5BL
#define DIO46_PIN PINL3
#define DIO46_RPORT PINL
#define DIO46_WPORT PORTL
#define DIO46_DDR DDRL
#define DIO46_PWM &OCR5AL
#define DIO47_PIN PINL2
#define DIO47_RPORT PINL
#define DIO47_WPORT PORTL
#define DIO47_DDR DDRL
#define DIO47_PWM NULL
#define DIO48_PIN PINL1
#define DIO48_RPORT PINL
#define DIO48_WPORT PORTL
#define DIO48_DDR DDRL
#define DIO48_PWM NULL
#define DIO49_PIN PINL0
#define DIO49_RPORT PINL
#define DIO49_WPORT PORTL
#define DIO49_DDR DDRL
#define DIO49_PWM NULL
#define DIO50_PIN PINB3
#define DIO50_RPORT PINB
#define DIO50_WPORT PORTB
#define DIO50_DDR DDRB
#define DIO50_PWM NULL
#define DIO51_PIN PINB2
#define DIO51_RPORT PINB
#define DIO51_WPORT PORTB
#define DIO51_DDR DDRB
#define DIO51_PWM NULL
#define DIO52_PIN PINB1
#define DIO52_RPORT PINB
#define DIO52_WPORT PORTB
#define DIO52_DDR DDRB
#define DIO52_PWM NULL
#define DIO53_PIN PINB0
#define DIO53_RPORT PINB
#define DIO53_WPORT PORTB
#define DIO53_DDR DDRB
#define DIO53_PWM NULL
#define DIO54_PIN PINF0
#define DIO54_RPORT PINF
#define DIO54_WPORT PORTF
#define DIO54_DDR DDRF
#define DIO54_PWM NULL
#define DIO55_PIN PINF1
#define DIO55_RPORT PINF
#define DIO55_WPORT PORTF
#define DIO55_DDR DDRF
#define DIO55_PWM NULL
#define DIO56_PIN PINF2
#define DIO56_RPORT PINF
#define DIO56_WPORT PORTF
#define DIO56_DDR DDRF
#define DIO56_PWM NULL
#define DIO57_PIN PINF3
#define DIO57_RPORT PINF
#define DIO57_WPORT PORTF
#define DIO57_DDR DDRF
#define DIO57_PWM NULL
#define DIO58_PIN PINF4
#define DIO58_RPORT PINF
#define DIO58_WPORT PORTF
#define DIO58_DDR DDRF
#define DIO58_PWM NULL
#define DIO59_PIN PINF5
#define DIO59_RPORT PINF
#define DIO59_WPORT PORTF
#define DIO59_DDR DDRF
#define DIO59_PWM NULL
#define DIO60_PIN PINF6
#define DIO60_RPORT PINF
#define DIO60_WPORT PORTF
#define DIO60_DDR DDRF
#define DIO60_PWM NULL
#define DIO61_PIN PINF7
#define DIO61_RPORT PINF
#define DIO61_WPORT PORTF
#define DIO61_DDR DDRF
#define DIO61_PWM NULL
#define DIO62_PIN PINK0
#define DIO62_RPORT PINK
#define DIO62_WPORT PORTK
#define DIO62_DDR DDRK
#define DIO62_PWM NULL
#define DIO63_PIN PINK1
#define DIO63_RPORT PINK
#define DIO63_WPORT PORTK
#define DIO63_DDR DDRK
#define DIO63_PWM NULL
#define DIO64_PIN PINK2
#define DIO64_RPORT PINK
#define DIO64_WPORT PORTK
#define DIO64_DDR DDRK
#define DIO64_PWM NULL
#define DIO65_PIN PINK3
#define DIO65_RPORT PINK
#define DIO65_WPORT PORTK
#define DIO65_DDR DDRK
#define DIO65_PWM NULL
#define DIO66_PIN PINK4
#define DIO66_RPORT PINK
#define DIO66_WPORT PORTK
#define DIO66_DDR DDRK
#define DIO66_PWM NULL
#define DIO67_PIN PINK5
#define DIO67_RPORT PINK
#define DIO67_WPORT PORTK
#define DIO67_DDR DDRK
#define DIO67_PWM NULL
#define DIO68_PIN PINK6
#define DIO68_RPORT PINK
#define DIO68_WPORT PORTK
#define DIO68_DDR DDRK
#define DIO68_PWM NULL
#define DIO69_PIN PINK7
#define DIO69_RPORT PINK
#define DIO69_WPORT PORTK
#define DIO69_DDR DDRK
#define DIO69_PWM NULL
#undef PA0
#define PA0_PIN PINA0
#define PA0_RPORT PINA
#define PA0_WPORT PORTA
#define PA0_DDR DDRA
#define PA0_PWM NULL
#undef PA1
#define PA1_PIN PINA1
#define PA1_RPORT PINA
#define PA1_WPORT PORTA
#define PA1_DDR DDRA
#define PA1_PWM NULL
#undef PA2
#define PA2_PIN PINA2
#define PA2_RPORT PINA
#define PA2_WPORT PORTA
#define PA2_DDR DDRA
#define PA2_PWM NULL
#undef PA3
#define PA3_PIN PINA3
#define PA3_RPORT PINA
#define PA3_WPORT PORTA
#define PA3_DDR DDRA
#define PA3_PWM NULL
#undef PA4
#define PA4_PIN PINA4
#define PA4_RPORT PINA
#define PA4_WPORT PORTA
#define PA4_DDR DDRA
#define PA4_PWM NULL
#undef PA5
#define PA5_PIN PINA5
#define PA5_RPORT PINA
#define PA5_WPORT PORTA
#define PA5_DDR DDRA
#define PA5_PWM NULL
#undef PA6
#define PA6_PIN PINA6
#define PA6_RPORT PINA
#define PA6_WPORT PORTA
#define PA6_DDR DDRA
#define PA6_PWM NULL
#undef PA7
#define PA7_PIN PINA7
#define PA7_RPORT PINA
#define PA7_WPORT PORTA
#define PA7_DDR DDRA
#define PA7_PWM NULL
#undef PB0
#define PB0_PIN PINB0
#define PB0_RPORT PINB
#define PB0_WPORT PORTB
#define PB0_DDR DDRB
#define PB0_PWM NULL
#undef PB1
#define PB1_PIN PINB1
#define PB1_RPORT PINB
#define PB1_WPORT PORTB
#define PB1_DDR DDRB
#define PB1_PWM NULL
#undef PB2
#define PB2_PIN PINB2
#define PB2_RPORT PINB
#define PB2_WPORT PORTB
#define PB2_DDR DDRB
#define PB2_PWM NULL
#undef PB3
#define PB3_PIN PINB3
#define PB3_RPORT PINB
#define PB3_WPORT PORTB
#define PB3_DDR DDRB
#define PB3_PWM NULL
#undef PB4
#define PB4_PIN PINB4
#define PB4_RPORT PINB
#define PB4_WPORT PORTB
#define PB4_DDR DDRB
#define PB4_PWM &OCR2A
#undef PB5
#define PB5_PIN PINB5
#define PB5_RPORT PINB
#define PB5_WPORT PORTB
#define PB5_DDR DDRB
#define PB5_PWM NULL
#undef PB6
#define PB6_PIN PINB6
#define PB6_RPORT PINB
#define PB6_WPORT PORTB
#define PB6_DDR DDRB
#define PB6_PWM NULL
#undef PB7
#define PB7_PIN PINB7
#define PB7_RPORT PINB
#define PB7_WPORT PORTB
#define PB7_DDR DDRB
#define PB7_PWM &OCR0A
#undef PC0
#define PC0_PIN PINC0
#define PC0_RPORT PINC
#define PC0_WPORT PORTC
#define PC0_DDR DDRC
#define PC0_PWM NULL
#undef PC1
#define PC1_PIN PINC1
#define PC1_RPORT PINC
#define PC1_WPORT PORTC
#define PC1_DDR DDRC
#define PC1_PWM NULL
#undef PC2
#define PC2_PIN PINC2
#define PC2_RPORT PINC
#define PC2_WPORT PORTC
#define PC2_DDR DDRC
#define PC2_PWM NULL
#undef PC3
#define PC3_PIN PINC3
#define PC3_RPORT PINC
#define PC3_WPORT PORTC
#define PC3_DDR DDRC
#define PC3_PWM NULL
#undef PC4
#define PC4_PIN PINC4
#define PC4_RPORT PINC
#define PC4_WPORT PORTC
#define PC4_DDR DDRC
#define PC4_PWM NULL
#undef PC5
#define PC5_PIN PINC5
#define PC5_RPORT PINC
#define PC5_WPORT PORTC
#define PC5_DDR DDRC
#define PC5_PWM NULL
#undef PC6
#define PC6_PIN PINC6
#define PC6_RPORT PINC
#define PC6_WPORT PORTC
#define PC6_DDR DDRC
#define PC6_PWM NULL
#undef PC7
#define PC7_PIN PINC7
#define PC7_RPORT PINC
#define PC7_WPORT PORTC
#define PC7_DDR DDRC
#define PC7_PWM NULL
#undef PD0
#define PD0_PIN PIND0
#define PD0_RPORT PIND
#define PD0_WPORT PORTD
#define PD0_DDR DDRD
#define PD0_PWM NULL
#undef PD1
#define PD1_PIN PIND1
#define PD1_RPORT PIND
#define PD1_WPORT PORTD
#define PD1_DDR DDRD
#define PD1_PWM NULL
#undef PD2
#define PD2_PIN PIND2
#define PD2_RPORT PIND
#define PD2_WPORT PORTD
#define PD2_DDR DDRD
#define PD2_PWM NULL
#undef PD3
#define PD3_PIN PIND3
#define PD3_RPORT PIND
#define PD3_WPORT PORTD
#define PD3_DDR DDRD
#define PD3_PWM NULL
#undef PD4
#define PD4_PIN PIND4
#define PD4_RPORT PIND
#define PD4_WPORT PORTD
#define PD4_DDR DDRD
#define PD4_PWM NULL
#undef PD5
#define PD5_PIN PIND5
#define PD5_RPORT PIND
#define PD5_WPORT PORTD
#define PD5_DDR DDRD
#define PD5_PWM NULL
#undef PD6
#define PD6_PIN PIND6
#define PD6_RPORT PIND
#define PD6_WPORT PORTD
#define PD6_DDR DDRD
#define PD6_PWM NULL
#undef PD7
#define PD7_PIN PIND7
#define PD7_RPORT PIND
#define PD7_WPORT PORTD
#define PD7_DDR DDRD
#define PD7_PWM NULL
#undef PE0
#define PE0_PIN PINE0
#define PE0_RPORT PINE
#define PE0_WPORT PORTE
#define PE0_DDR DDRE
#define PE0_PWM NULL
#undef PE1
#define PE1_PIN PINE1
#define PE1_RPORT PINE
#define PE1_WPORT PORTE
#define PE1_DDR DDRE
#define PE1_PWM NULL
#undef PE2
#define PE2_PIN PINE2
#define PE2_RPORT PINE
#define PE2_WPORT PORTE
#define PE2_DDR DDRE
#define PE2_PWM NULL
#undef PE3
#define PE3_PIN PINE3
#define PE3_RPORT PINE
#define PE3_WPORT PORTE
#define PE3_DDR DDRE
#define PE3_PWM &OCR3AL
#undef PE4
#define PE4_PIN PINE4
#define PE4_RPORT PINE
#define PE4_WPORT PORTE
#define PE4_DDR DDRE
#define PE4_PWM &OCR3BL
#undef PE5
#define PE5_PIN PINE5
#define PE5_RPORT PINE
#define PE5_WPORT PORTE
#define PE5_DDR DDRE
#define PE5_PWM &OCR3CL
#undef PE6
#define PE6_PIN PINE6
#define PE6_RPORT PINE
#define PE6_WPORT PORTE
#define PE6_DDR DDRE
#define PE6_PWM NULL
#undef PE7
#define PE7_PIN PINE7
#define PE7_RPORT PINE
#define PE7_WPORT PORTE
#define PE7_DDR DDRE
#define PE7_PWM NULL
#undef PF0
#define PF0_PIN PINF0
#define PF0_RPORT PINF
#define PF0_WPORT PORTF
#define PF0_DDR DDRF
#define PF0_PWM NULL
#undef PF1
#define PF1_PIN PINF1
#define PF1_RPORT PINF
#define PF1_WPORT PORTF
#define PF1_DDR DDRF
#define PF1_PWM NULL
#undef PF2
#define PF2_PIN PINF2
#define PF2_RPORT PINF
#define PF2_WPORT PORTF
#define PF2_DDR DDRF
#define PF2_PWM NULL
#undef PF3
#define PF3_PIN PINF3
#define PF3_RPORT PINF
#define PF3_WPORT PORTF
#define PF3_DDR DDRF
#define PF3_PWM NULL
#undef PF4
#define PF4_PIN PINF4
#define PF4_RPORT PINF
#define PF4_WPORT PORTF
#define PF4_DDR DDRF
#define PF4_PWM NULL
#undef PF5
#define PF5_PIN PINF5
#define PF5_RPORT PINF
#define PF5_WPORT PORTF
#define PF5_DDR DDRF
#define PF5_PWM NULL
#undef PF6
#define PF6_PIN PINF6
#define PF6_RPORT PINF
#define PF6_WPORT PORTF
#define PF6_DDR DDRF
#define PF6_PWM NULL
#undef PF7
#define PF7_PIN PINF7
#define PF7_RPORT PINF
#define PF7_WPORT PORTF
#define PF7_DDR DDRF
#define PF7_PWM NULL
#undef PG0
#define PG0_PIN PING0
#define PG0_RPORT PING
#define PG0_WPORT PORTG
#define PG0_DDR DDRG
#define PG0_PWM NULL
#undef PG1
#define PG1_PIN PING1
#define PG1_RPORT PING
#define PG1_WPORT PORTG
#define PG1_DDR DDRG
#define PG1_PWM NULL
#undef PG2
#define PG2_PIN PING2
#define PG2_RPORT PING
#define PG2_WPORT PORTG
#define PG2_DDR DDRG
#define PG2_PWM NULL
#undef PG3
#define PG3_PIN PING3
#define PG3_RPORT PING
#define PG3_WPORT PORTG
#define PG3_DDR DDRG
#define PG3_PWM NULL
#undef PG4
#define PG4_PIN PING4
#define PG4_RPORT PING
#define PG4_WPORT PORTG
#define PG4_DDR DDRG
#define PG4_PWM NULL
#undef PG5
#define PG5_PIN PING5
#define PG5_RPORT PING
#define PG5_WPORT PORTG
#define PG5_DDR DDRG
#define PG5_PWM &OCR0B
#undef PG6
#define PG6_PIN PING6
#define PG6_RPORT PING
#define PG6_WPORT PORTG
#define PG6_DDR DDRG
#define PG6_PWM NULL
#undef PG7
#define PG7_PIN PING7
#define PG7_RPORT PING
#define PG7_WPORT PORTG
#define PG7_DDR DDRG
#define PG7_PWM NULL
#undef PH0
#define PH0_PIN PINH0
#define PH0_RPORT PINH
#define PH0_WPORT PORTH
#define PH0_DDR DDRH
#define PH0_PWM NULL
#undef PH1
#define PH1_PIN PINH1
#define PH1_RPORT PINH
#define PH1_WPORT PORTH
#define PH1_DDR DDRH
#define PH1_PWM NULL
#undef PH2
#define PH2_PIN PINH2
#define PH2_RPORT PINH
#define PH2_WPORT PORTH
#define PH2_DDR DDRH
#define PH2_PWM NULL
#undef PH3
#define PH3_PIN PINH3
#define PH3_RPORT PINH
#define PH3_WPORT PORTH
#define PH3_DDR DDRH
#define PH3_PWM &OCR4AL
#undef PH4
#define PH4_PIN PINH4
#define PH4_RPORT PINH
#define PH4_WPORT PORTH
#define PH4_DDR DDRH
#define PH4_PWM &OCR4BL
#undef PH5
#define PH5_PIN PINH5
#define PH5_RPORT PINH
#define PH5_WPORT PORTH
#define PH5_DDR DDRH
#define PH5_PWM &OCR4CL
#undef PH6
#define PH6_PIN PINH6
#define PH6_RPORT PINH
#define PH6_WPORT PORTH
#define PH6_DDR DDRH
#define PH6_PWM &OCR2B
#undef PH7
#define PH7_PIN PINH7
#define PH7_RPORT PINH
#define PH7_WPORT PORTH
#define PH7_DDR DDRH
#define PH7_PWM NULL
#undef PJ0
#define PJ0_PIN PINJ0
#define PJ0_RPORT PINJ
#define PJ0_WPORT PORTJ
#define PJ0_DDR DDRJ
#define PJ0_PWM NULL
#undef PJ1
#define PJ1_PIN PINJ1
#define PJ1_RPORT PINJ
#define PJ1_WPORT PORTJ
#define PJ1_DDR DDRJ
#define PJ1_PWM NULL
#undef PJ2
#define PJ2_PIN PINJ2
#define PJ2_RPORT PINJ
#define PJ2_WPORT PORTJ
#define PJ2_DDR DDRJ
#define PJ2_PWM NULL
#undef PJ3
#define PJ3_PIN PINJ3
#define PJ3_RPORT PINJ
#define PJ3_WPORT PORTJ
#define PJ3_DDR DDRJ
#define PJ3_PWM NULL
#undef PJ4
#define PJ4_PIN PINJ4
#define PJ4_RPORT PINJ
#define PJ4_WPORT PORTJ
#define PJ4_DDR DDRJ
#define PJ4_PWM NULL
#undef PJ5
#define PJ5_PIN PINJ5
#define PJ5_RPORT PINJ
#define PJ5_WPORT PORTJ
#define PJ5_DDR DDRJ
#define PJ5_PWM NULL
#undef PJ6
#define PJ6_PIN PINJ6
#define PJ6_RPORT PINJ
#define PJ6_WPORT PORTJ
#define PJ6_DDR DDRJ
#define PJ6_PWM NULL
#undef PJ7
#define PJ7_PIN PINJ7
#define PJ7_RPORT PINJ
#define PJ7_WPORT PORTJ
#define PJ7_DDR DDRJ
#define PJ7_PWM NULL
#undef PK0
#define PK0_PIN PINK0
#define PK0_RPORT PINK
#define PK0_WPORT PORTK
#define PK0_DDR DDRK
#define PK0_PWM NULL
#undef PK1
#define PK1_PIN PINK1
#define PK1_RPORT PINK
#define PK1_WPORT PORTK
#define PK1_DDR DDRK
#define PK1_PWM NULL
#undef PK2
#define PK2_PIN PINK2
#define PK2_RPORT PINK
#define PK2_WPORT PORTK
#define PK2_DDR DDRK
#define PK2_PWM NULL
#undef PK3
#define PK3_PIN PINK3
#define PK3_RPORT PINK
#define PK3_WPORT PORTK
#define PK3_DDR DDRK
#define PK3_PWM NULL
#undef PK4
#define PK4_PIN PINK4
#define PK4_RPORT PINK
#define PK4_WPORT PORTK
#define PK4_DDR DDRK
#define PK4_PWM NULL
#undef PK5
#define PK5_PIN PINK5
#define PK5_RPORT PINK
#define PK5_WPORT PORTK
#define PK5_DDR DDRK
#define PK5_PWM NULL
#undef PK6
#define PK6_PIN PINK6
#define PK6_RPORT PINK
#define PK6_WPORT PORTK
#define PK6_DDR DDRK
#define PK6_PWM NULL
#undef PK7
#define PK7_PIN PINK7
#define PK7_RPORT PINK
#define PK7_WPORT PORTK
#define PK7_DDR DDRK
#define PK7_PWM NULL
#undef PL0
#define PL0_PIN PINL0
#define PL0_RPORT PINL
#define PL0_WPORT PORTL
#define PL0_DDR DDRL
#define PL0_PWM NULL
#undef PL1
#define PL1_PIN PINL1
#define PL1_RPORT PINL
#define PL1_WPORT PORTL
#define PL1_DDR DDRL
#define PL1_PWM NULL
#undef PL2
#define PL2_PIN PINL2
#define PL2_RPORT PINL
#define PL2_WPORT PORTL
#define PL2_DDR DDRL
#define PL2_PWM NULL
#undef PL3
#define PL3_PIN PINL3
#define PL3_RPORT PINL
#define PL3_WPORT PORTL
#define PL3_DDR DDRL
#define PL3_PWM &OCR5AL
#undef PL4
#define PL4_PIN PINL4
#define PL4_RPORT PINL
#define PL4_WPORT PORTL
#define PL4_DDR DDRL
#define PL4_PWM &OCR5BL
#undef PL5
#define PL5_PIN PINL5
#define PL5_RPORT PINL
#define PL5_WPORT PORTL
#define PL5_DDR DDRL
#define PL5_PWM &OCR5CL
#undef PL6
#define PL6_PIN PINL6
#define PL6_RPORT PINL
#define PL6_WPORT PORTL
#define PL6_DDR DDRL
#define PL6_PWM NULL
#undef PL7
#define PL7_PIN PINL7
#define PL7_RPORT PINL
#define PL7_WPORT PORTL
#define PL7_DDR DDRL
#define PL7_PWM NULL
#endif
#if defined (__AVR_AT90USB1287__)
// SPI
#define SCK DIO9
#define MISO DIO11
#define MOSI DIO10
#define SS DIO8
// change for your board
#define DEBUG_LED DIO31 /* led D5 red */
/*
pins
*/
#define DIO0_PIN PINA0
#define DIO0_RPORT PINA
#define DIO0_WPORT PORTA
#define DIO0_PWM NULL
#define DIO0_DDR DDRA
#define DIO1_PIN PINA1
#define DIO1_RPORT PINA
#define DIO1_WPORT PORTA
#define DIO1_PWM NULL
#define DIO1_DDR DDRA
#define DIO2_PIN PINA2
#define DIO2_RPORT PINA
#define DIO2_WPORT PORTA
#define DIO2_PWM NULL
#define DIO2_DDR DDRA
#define DIO3_PIN PINA3
#define DIO3_RPORT PINA
#define DIO3_WPORT PORTA
#define DIO3_PWM NULL
#define DIO3_DDR DDRA
#define DIO4_PIN PINA4
#define DIO4_RPORT PINA
#define DIO4_WPORT PORTA
#define DIO4_PWM NULL
#define DIO4_DDR DDRA
#define DIO5_PIN PINA5
#define DIO5_RPORT PINA
#define DIO5_WPORT PORTA
#define DIO5_PWM NULL
#define DIO5_DDR DDRA
#define DIO6_PIN PINA6
#define DIO6_RPORT PINA
#define DIO6_WPORT PORTA
#define DIO6_PWM NULL
#define DIO6_DDR DDRA
#define DIO7_PIN PINA7
#define DIO7_RPORT PINA
#define DIO7_WPORT PORTA
#define DIO7_PWM NULL
#define DIO7_DDR DDRA
#define DIO8_PIN PINB0
#define DIO8_RPORT PINB
#define DIO8_WPORT PORTB
#define DIO8_PWM NULL
#define DIO8_DDR DDRB
#define DIO9_PIN PINB1
#define DIO9_RPORT PINB
#define DIO9_WPORT PORTB
#define DIO9_PWM NULL
#define DIO9_DDR DDRB
#define DIO10_PIN PINB2
#define DIO10_RPORT PINB
#define DIO10_WPORT PORTB
#define DIO10_PWM NULL
#define DIO10_DDR DDRB
#define DIO11_PIN PINB3
#define DIO11_RPORT PINB
#define DIO11_WPORT PORTB
#define DIO11_PWM NULL
#define DIO11_DDR DDRB
#define DIO12_PIN PINB4
#define DIO12_RPORT PINB
#define DIO12_WPORT PORTB
#define DIO12_PWM NULL
#define DIO12_DDR DDRB
#define DIO13_PIN PINB5
#define DIO13_RPORT PINB
#define DIO13_WPORT PORTB
#define DIO13_PWM NULL
#define DIO13_DDR DDRB
#define DIO14_PIN PINB6
#define DIO14_RPORT PINB
#define DIO14_WPORT PORTB
#define DIO14_PWM NULL
#define DIO14_DDR DDRB
#define DIO15_PIN PINB7
#define DIO15_RPORT PINB
#define DIO15_WPORT PORTB
#define DIO15_PWM NULL
#define DIO15_DDR DDRB
#define DIO16_PIN PINC0
#define DIO16_RPORT PINC
#define DIO16_WPORT PORTC
#define DIO16_PWM NULL
#define DIO16_DDR DDRC
#define DIO17_PIN PINC1
#define DIO17_RPORT PINC
#define DIO17_WPORT PORTC
#define DIO17_PWM NULL
#define DIO17_DDR DDRC
#define DIO18_PIN PINC2
#define DIO18_RPORT PINC
#define DIO18_WPORT PORTC
#define DIO18_PWM NULL
#define DIO18_DDR DDRC
#define DIO19_PIN PINC3
#define DIO19_RPORT PINC
#define DIO19_WPORT PORTC
#define DIO19_PWM NULL
#define DIO19_DDR DDRC
#define DIO20_PIN PINC4
#define DIO20_RPORT PINC
#define DIO20_WPORT PORTC
#define DIO20_PWM NULL
#define DIO20_DDR DDRC
#define DIO21_PIN PINC5
#define DIO21_RPORT PINC
#define DIO21_WPORT PORTC
#define DIO21_PWM NULL
#define DIO21_DDR DDRC
#define DIO22_PIN PINC6
#define DIO22_RPORT PINC
#define DIO22_WPORT PORTC
#define DIO22_PWM NULL
#define DIO22_DDR DDRC
#define DIO23_PIN PINC7
#define DIO23_RPORT PINC
#define DIO23_WPORT PORTC
#define DIO23_PWM NULL
#define DIO23_DDR DDRC
#define DIO24_PIN PIND0
#define DIO24_RPORT PIND
#define DIO24_WPORT PORTD
#define DIO24_PWM NULL
#define DIO24_DDR DDRD
#define DIO25_PIN PIND1
#define DIO25_RPORT PIND
#define DIO25_WPORT PORTD
#define DIO25_PWM NULL
#define DIO25_DDR DDRD
#define DIO26_PIN PIND2
#define DIO26_RPORT PIND
#define DIO26_WPORT PORTD
#define DIO26_PWM NULL
#define DIO26_DDR DDRD
#define DIO27_PIN PIND3
#define DIO27_RPORT PIND
#define DIO27_WPORT PORTD
#define DIO27_PWM NULL
#define DIO27_DDR DDRD
#define DIO28_PIN PIND4
#define DIO28_RPORT PIND
#define DIO28_WPORT PORTD
#define DIO28_PWM NULL
#define DIO28_DDR DDRD
#define DIO29_PIN PIND5
#define DIO29_RPORT PIND
#define DIO29_WPORT PORTD
#define DIO29_PWM NULL
#define DIO29_DDR DDRD
#define DIO30_PIN PIND6
#define DIO30_RPORT PIND
#define DIO30_WPORT PORTD
#define DIO30_PWM NULL
#define DIO30_DDR DDRD
#define DIO31_PIN PIND7
#define DIO31_RPORT PIND
#define DIO31_WPORT PORTD
#define DIO31_PWM NULL
#define DIO31_DDR DDRD
#define DIO32_PIN PINE0
#define DIO32_RPORT PINE
#define DIO32_WPORT PORTE
#define DIO32_PWM NULL
#define DIO32_DDR DDRE
#define DIO33_PIN PINE1
#define DIO33_RPORT PINE
#define DIO33_WPORT PORTE
#define DIO33_PWM NULL
#define DIO33_DDR DDRE
#define DIO34_PIN PINE2
#define DIO34_RPORT PINE
#define DIO34_WPORT PORTE
#define DIO34_PWM NULL
#define DIO34_DDR DDRE
#define DIO35_PIN PINE3
#define DIO35_RPORT PINE
#define DIO35_WPORT PORTE
#define DIO35_PWM NULL
#define DIO35_DDR DDRE
#define DIO36_PIN PINE4
#define DIO36_RPORT PINE
#define DIO36_WPORT PORTE
#define DIO36_PWM NULL
#define DIO36_DDR DDRE
#define DIO37_PIN PINE5
#define DIO37_RPORT PINE
#define DIO37_WPORT PORTE
#define DIO37_PWM NULL
#define DIO37_DDR DDRE
#define DIO38_PIN PINE6
#define DIO38_RPORT PINE
#define DIO38_WPORT PORTE
#define DIO38_PWM NULL
#define DIO38_DDR DDRE
#define DIO39_PIN PINE7
#define DIO39_RPORT PINE
#define DIO39_WPORT PORTE
#define DIO39_PWM NULL
#define DIO39_DDR DDRE
#define AIO0_PIN PINF0
#define AIO0_RPORT PINF
#define AIO0_WPORT PORTF
#define AIO0_PWM NULL
#define AIO0_DDR DDRF
#define AIO1_PIN PINF1
#define AIO1_RPORT PINF
#define AIO1_WPORT PORTF
#define AIO1_PWM NULL
#define AIO1_DDR DDRF
#define AIO2_PIN PINF2
#define AIO2_RPORT PINF
#define AIO2_WPORT PORTF
#define AIO2_PWM NULL
#define AIO2_DDR DDRF
#define AIO3_PIN PINF3
#define AIO3_RPORT PINF
#define AIO3_WPORT PORTF
#define AIO3_PWM NULL
#define AIO3_DDR DDRF
#define AIO4_PIN PINF4
#define AIO4_RPORT PINF
#define AIO4_WPORT PORTF
#define AIO4_PWM NULL
#define AIO4_DDR DDRF
#define AIO5_PIN PINF5
#define AIO5_RPORT PINF
#define AIO5_WPORT PORTF
#define AIO5_PWM NULL
#define AIO5_DDR DDRF
#define AIO6_PIN PINF6
#define AIO6_RPORT PINF
#define AIO6_WPORT PORTF
#define AIO6_PWM NULL
#define AIO6_DDR DDRF
#define AIO7_PIN PINF7
#define AIO7_RPORT PINF
#define AIO7_WPORT PORTF
#define AIO7_PWM NULL
#define AIO7_DDR DDRF
#define DIO40_PIN PINF0
#define DIO40_RPORT PINF
#define DIO40_WPORT PORTF
#define DIO40_PWM NULL
#define DIO40_DDR DDRF
#define DIO41_PIN PINF1
#define DIO41_RPORT PINF
#define DIO41_WPORT PORTF
#define DIO41_PWM NULL
#define DIO41_DDR DDRF
#define DIO42_PIN PINF2
#define DIO42_RPORT PINF
#define DIO42_WPORT PORTF
#define DIO42_PWM NULL
#define DIO42_DDR DDRF
#define DIO43_PIN PINF3
#define DIO43_RPORT PINF
#define DIO43_WPORT PORTF
#define DIO43_PWM NULL
#define DIO43_DDR DDRF
#define DIO44_PIN PINF4
#define DIO44_RPORT PINF
#define DIO44_WPORT PORTF
#define DIO44_PWM NULL
#define DIO44_DDR DDRF
#define DIO45_PIN PINF5
#define DIO45_RPORT PINF
#define DIO45_WPORT PORTF
#define DIO45_PWM NULL
#define DIO45_DDR DDRF
#define DIO46_PIN PINF6
#define DIO46_RPORT PINF
#define DIO46_WPORT PORTF
#define DIO46_PWM NULL
#define DIO46_DDR DDRF
#define DIO47_PIN PINF7
#define DIO47_RPORT PINF
#define DIO47_WPORT PORTF
#define DIO47_PWM NULL
#define DIO47_DDR DDRF
#undef PA0
#define PA0_PIN PINA0
#define PA0_RPORT PINA
#define PA0_WPORT PORTA
#define PA0_PWM NULL
#define PA0_DDR DDRA
#undef PA1
#define PA1_PIN PINA1
#define PA1_RPORT PINA
#define PA1_WPORT PORTA
#define PA1_PWM NULL
#define PA1_DDR DDRA
#undef PA2
#define PA2_PIN PINA2
#define PA2_RPORT PINA
#define PA2_WPORT PORTA
#define PA2_PWM NULL
#define PA2_DDR DDRA
#undef PA3
#define PA3_PIN PINA3
#define PA3_RPORT PINA
#define PA3_WPORT PORTA
#define PA3_PWM NULL
#define PA3_DDR DDRA
#undef PA4
#define PA4_PIN PINA4
#define PA4_RPORT PINA
#define PA4_WPORT PORTA
#define PA4_PWM NULL
#define PA4_DDR DDRA
#undef PA5
#define PA5_PIN PINA5
#define PA5_RPORT PINA
#define PA5_WPORT PORTA
#define PA5_PWM NULL
#define PA5_DDR DDRA
#undef PA6
#define PA6_PIN PINA6
#define PA6_RPORT PINA
#define PA6_WPORT PORTA
#define PA6_PWM NULL
#define PA6_DDR DDRA
#undef PA7
#define PA7_PIN PINA7
#define PA7_RPORT PINA
#define PA7_WPORT PORTA
#define PA7_PWM NULL
#define PA7_DDR DDRA
#undef PB0
#define PB0_PIN PINB0
#define PB0_RPORT PINB
#define PB0_WPORT PORTB
#define PB0_PWM NULL
#define PB0_DDR DDRB
#undef PB1
#define PB1_PIN PINB1
#define PB1_RPORT PINB
#define PB1_WPORT PORTB
#define PB1_PWM NULL
#define PB1_DDR DDRB
#undef PB2
#define PB2_PIN PINB2
#define PB2_RPORT PINB
#define PB2_WPORT PORTB
#define PB2_PWM NULL
#define PB2_DDR DDRB
#undef PB3
#define PB3_PIN PINB3
#define PB3_RPORT PINB
#define PB3_WPORT PORTB
#define PB3_PWM NULL
#define PB3_DDR DDRB
#undef PB4
#define PB4_PIN PINB4
#define PB4_RPORT PINB
#define PB4_WPORT PORTB
#define PB4_PWM NULL
#define PB4_DDR DDRB
#undef PB5
#define PB5_PIN PINB5
#define PB5_RPORT PINB
#define PB5_WPORT PORTB
#define PB5_PWM NULL
#define PB5_DDR DDRB
#undef PB6
#define PB6_PIN PINB6
#define PB6_RPORT PINB
#define PB6_WPORT PORTB
#define PB6_PWM NULL
#define PB6_DDR DDRB
#undef PB7
#define PB7_PIN PINB7
#define PB7_RPORT PINB
#define PB7_WPORT PORTB
#define PB7_PWM NULL
#define PB7_DDR DDRB
#undef PC0
#define PC0_PIN PINC0
#define PC0_RPORT PINC
#define PC0_WPORT PORTC
#define PC0_PWM NULL
#define PC0_DDR DDRC
#undef PC1
#define PC1_PIN PINC1
#define PC1_RPORT PINC
#define PC1_WPORT PORTC
#define PC1_PWM NULL
#define PC1_DDR DDRC
#undef PC2
#define PC2_PIN PINC2
#define PC2_RPORT PINC
#define PC2_WPORT PORTC
#define PC2_PWM NULL
#define PC2_DDR DDRC
#undef PC3
#define PC3_PIN PINC3
#define PC3_RPORT PINC
#define PC3_WPORT PORTC
#define PC3_PWM NULL
#define PC3_DDR DDRC
#undef PC4
#define PC4_PIN PINC4
#define PC4_RPORT PINC
#define PC4_WPORT PORTC
#define PC4_PWM NULL
#define PC4_DDR DDRC
#undef PC5
#define PC5_PIN PINC5
#define PC5_RPORT PINC
#define PC5_WPORT PORTC
#define PC5_PWM NULL
#define PC5_DDR DDRC
#undef PC6
#define PC6_PIN PINC6
#define PC6_RPORT PINC
#define PC6_WPORT PORTC
#define PC6_PWM NULL
#define PC6_DDR DDRC
#undef PC7
#define PC7_PIN PINC7
#define PC7_RPORT PINC
#define PC7_WPORT PORTC
#define PC7_PWM NULL
#define PC7_DDR DDRC
#undef PD0
#define PD0_PIN PIND0
#define PD0_RPORT PIND
#define PD0_WPORT PORTD
#define PD0_PWM NULL
#define PD0_DDR DDRD
#undef PD1
#define PD1_PIN PIND1
#define PD1_RPORT PIND
#define PD1_WPORT PORTD
#define PD1_PWM NULL
#define PD1_DDR DDRD
#undef PD2
#define PD2_PIN PIND2
#define PD2_RPORT PIND
#define PD2_WPORT PORTD
#define PD2_PWM NULL
#define PD2_DDR DDRD
#undef PD3
#define PD3_PIN PIND3
#define PD3_RPORT PIND
#define PD3_WPORT PORTD
#define PD3_PWM NULL
#define PD3_DDR DDRD
#undef PD4
#define PD4_PIN PIND4
#define PD4_RPORT PIND
#define PD4_WPORT PORTD
#define PD4_PWM NULL
#define PD4_DDR DDRD
#undef PD5
#define PD5_PIN PIND5
#define PD5_RPORT PIND
#define PD5_WPORT PORTD
#define PD5_PWM NULL
#define PD5_DDR DDRD
#undef PD6
#define PD6_PIN PIND6
#define PD6_RPORT PIND
#define PD6_WPORT PORTD
#define PD6_PWM NULL
#define PD6_DDR DDRD
#undef PD7
#define PD7_PIN PIND7
#define PD7_RPORT PIND
#define PD7_WPORT PORTD
#define PD7_PWM NULL
#define PD7_DDR DDRD
#undef PE0
#define PE0_PIN PINE0
#define PE0_RPORT PINE
#define PE0_WPORT PORTE
#define PE0_PWM NULL
#define PE0_DDR DDRE
#undef PE1
#define PE1_PIN PINE1
#define PE1_RPORT PINE
#define PE1_WPORT PORTE
#define PE1_PWM NULL
#define PE1_DDR DDRE
#undef PE2
#define PE2_PIN PINE2
#define PE2_RPORT PINE
#define PE2_WPORT PORTE
#define PE2_PWM NULL
#define PE2_DDR DDRE
#undef PE3
#define PE3_PIN PINE3
#define PE3_RPORT PINE
#define PE3_WPORT PORTE
#define PE3_PWM NULL
#define PE3_DDR DDRE
#undef PE4
#define PE4_PIN PINE4
#define PE4_RPORT PINE
#define PE4_WPORT PORTE
#define PE4_PWM NULL
#define PE4_DDR DDRE
#undef PE5
#define PE5_PIN PINE5
#define PE5_RPORT PINE
#define PE5_WPORT PORTE
#define PE5_PWM NULL
#define PE5_DDR DDRE
#undef PE6
#define PE6_PIN PINE6
#define PE6_RPORT PINE
#define PE6_WPORT PORTE
#define PE6_PWM NULL
#define PE6_DDR DDRE
#undef PE7
#define PE7_PIN PINE7
#define PE7_RPORT PINE
#define PE7_WPORT PORTE
#define PE7_PWM NULL
#define PE7_DDR DDRE
#undef PF0
#define PF0_PIN PINF0
#define PF0_RPORT PINF
#define PF0_WPORT PORTF
#define PF0_PWM NULL
#define PF0_DDR DDRF
#undef PF1
#define PF1_PIN PINF1
#define PF1_RPORT PINF
#define PF1_WPORT PORTF
#define PF1_PWM NULL
#define PF1_DDR DDRF
#undef PF2
#define PF2_PIN PINF2
#define PF2_RPORT PINF
#define PF2_WPORT PORTF
#define PF2_PWM NULL
#define PF2_DDR DDRF
#undef PF3
#define PF3_PIN PINF3
#define PF3_RPORT PINF
#define PF3_WPORT PORTF
#define PF3_PWM NULL
#define PF3_DDR DDRF
#undef PF4
#define PF4_PIN PINF4
#define PF4_RPORT PINF
#define PF4_WPORT PORTF
#define PF4_PWM NULL
#define PF4_DDR DDRF
#undef PF5
#define PF5_PIN PINF5
#define PF5_RPORT PINF
#define PF5_WPORT PORTF
#define PF5_PWM NULL
#define PF5_DDR DDRF
#undef PF6
#define PF6_PIN PINF6
#define PF6_RPORT PINF
#define PF6_WPORT PORTF
#define PF6_PWM NULL
#define PF6_DDR DDRF
#undef PF7
#define PF7_PIN PINF7
#define PF7_RPORT PINF
#define PF7_WPORT PORTF
#define PF7_PWM NULL
#define PF7_DDR DDRF
#endif
#ifndef DIO0_PIN
#error pins for this chip not defined in arduino.h! If you write an appropriate pin definition and have this firmware work on your chip, please submit a pull request
#endif
#endif /* _ARDUINO_H */

View file

@ -1,738 +1,737 @@
#ifndef PINS_H
#define PINS_H
/****************************************************************************************
* Arduino pin assignment
*
* ATMega168
* +-\/-+
* PC6 1| |28 PC5 (AI 5 / D19)
* (D 0) PD0 2| |27 PC4 (AI 4 / D18)
* (D 1) PD1 3| |26 PC3 (AI 3 / D17)
* (D 2) PD2 4| |25 PC2 (AI 2 / D16)
* PWM+ (D 3) PD3 5| |24 PC1 (AI 1 / D15)
* (D 4) PD4 6| |23 PC0 (AI 0 / D14)
* VCC 7| |22 GND
* GND 8| |21 AREF
* PB6 9| |20 AVCC
* PB7 10| |19 PB5 (D 13)
* PWM+ (D 5) PD5 11| |18 PB4 (D 12)
* PWM+ (D 6) PD6 12| |17 PB3 (D 11) PWM
* (D 7) PD7 13| |16 PB2 (D 10) PWM
* (D 8) PB0 14| |15 PB1 (D 9) PWM
* +----+
****************************************************************************************/
#if MOTHERBOARD == 0
#define KNOWN_BOARD 1
#ifndef __AVR_ATmega168__
#error Oops! Make sure you have 'Arduino Diecimila' selected from the boards menu.
#endif
#define X_STEP_PIN 2
#define X_DIR_PIN 3
#define X_ENABLE_PIN -1
#define X_MIN_PIN 4
#define X_MAX_PIN 9
#define Y_STEP_PIN 10
#define Y_DIR_PIN 7
#define Y_ENABLE_PIN -1
#define Y_MIN_PIN 8
#define Y_MAX_PIN 13
#define Z_STEP_PIN 19
#define Z_DIR_PIN 18
#define Z_ENABLE_PIN 5
#define Z_MIN_PIN 17
#define Z_MAX_PIN 16
#define E0_STEP_PIN 11
#define E0_DIR_PIN 12
#define E0_ENABLE_PIN -1
#define SDPOWER -1
#define SDSS -1
#define LED_PIN -1
#define FAN_PIN -1
#define PS_ON_PIN 15
#define KILL_PIN -1
#define HEATER_0_PIN 6
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#define TEMP_0_PIN 0 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
#define TEMP_1_PIN -1 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
#define TEMP_2_PIN -1 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
#define HEATER_BED_PIN -1
#define TEMP_BED_PIN -1
#endif
/****************************************************************************************
* Sanguino/RepRap Motherboard with direct-drive extruders
*
* ATMega644P
*
* +---\/---+
* (D 0) PB0 1| |40 PA0 (AI 0 / D31)
* (D 1) PB1 2| |39 PA1 (AI 1 / D30)
* INT2 (D 2) PB2 3| |38 PA2 (AI 2 / D29)
* PWM (D 3) PB3 4| |37 PA3 (AI 3 / D28)
* PWM (D 4) PB4 5| |36 PA4 (AI 4 / D27)
* MOSI (D 5) PB5 6| |35 PA5 (AI 5 / D26)
* MISO (D 6) PB6 7| |34 PA6 (AI 6 / D25)
* SCK (D 7) PB7 8| |33 PA7 (AI 7 / D24)
* RST 9| |32 AREF
* VCC 10| |31 GND
* GND 11| |30 AVCC
* XTAL2 12| |29 PC7 (D 23)
* XTAL1 13| |28 PC6 (D 22)
* RX0 (D 8) PD0 14| |27 PC5 (D 21) TDI
* TX0 (D 9) PD1 15| |26 PC4 (D 20) TDO
* INT0 RX1 (D 10) PD2 16| |25 PC3 (D 19) TMS
* INT1 TX1 (D 11) PD3 17| |24 PC2 (D 18) TCK
* PWM (D 12) PD4 18| |23 PC1 (D 17) SDA
* PWM (D 13) PD5 19| |22 PC0 (D 16) SCL
* PWM (D 14) PD6 20| |21 PD7 (D 15) PWM
* +--------+
*
****************************************************************************************/
#if MOTHERBOARD == 1
#define KNOWN_BOARD 1
#ifndef __AVR_ATmega644P__
#error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu.
#endif
#define X_STEP_PIN 15
#define X_DIR_PIN 18
#define X_ENABLE_PIN 19
#define X_MIN_PIN 20
#define X_MAX_PIN 21
#define Y_STEP_PIN 23
#define Y_DIR_PIN 22
#define Y_ENABLE_PIN 19
#define Y_MIN_PIN 25
#define Y_MAX_PIN 26
#define Z_STEP_PIN 29
#define Z_DIR_PIN 30
#define Z_ENABLE_PIN 31
#define Z_MIN_PIN 2
#define Z_MAX_PIN 1
#define E0_STEP_PIN 12
#define E0_DIR_PIN 16
#define E0_ENABLE_PIN 3
#define SDPOWER -1
#define SDSS -1
#define LED_PIN 0
#define FAN_PIN -1
#define PS_ON_PIN -1
#define KILL_PIN -1
#define HEATER_0_PIN 14
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#define TEMP_0_PIN 4 //D27 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
#define TEMP_1_PIN -1
#define TEMP_2_PIN -1
#define HEATER_BED_PIN -1
#define TEMP_BED_PIN -1
/* Unused (1) (2) (3) 4 5 6 7 8 9 10 11 12 13 (14) (15) (16) 17 (18) (19) (20) (21) (22) (23) 24 (25) (26) (27) 28 (29) (30) (31) */
#endif
/****************************************************************************************
* RepRap Motherboard ****---NOOOOOO RS485/EXTRUDER CONTROLLER!!!!!!!!!!!!!!!!!---*******
*
****************************************************************************************/
#if MOTHERBOARD == 2
#define KNOWN_BOARD 1
#ifndef __AVR_ATmega644P__
#error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu.
#endif
#define X_STEP_PIN 15
#define X_DIR_PIN 18
#define X_ENABLE_PIN 19
#define X_MIN_PIN 20
#define X_MAX_PIN 21
#define Y_STEP_PIN 23
#define Y_DIR_PIN 22
#define Y_ENABLE_PIN 24
#define Y_MIN_PIN 25
#define Y_MAX_PIN 26
#define Z_STEP_PINN 27
#define Z_DIR_PINN 28
#define Z_ENABLE_PIN 29
#define Z_MIN_PIN 30
#define Z_MAX_PIN 31
#define E0_STEP_PIN 17
#define E0_DIR_PIN 16
#define E0_ENABLE_PIN -1
#define SDPOWER -1
#define SDSS 4
#define LED_PIN 0
#define SD_CARD_WRITE 2
#define SD_CARD_DETECT 3
#define SD_CARD_SELECT 4
//our RS485 pins
#define TX_ENABLE_PIN 12
#define RX_ENABLE_PIN 13
//pin for controlling the PSU.
#define PS_ON_PIN 14
#define FAN_PIN -1
#define KILL_PIN -1
#define HEATER_0_PIN -1
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#define TEMP_0_PIN -1 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
#define TEMP_1_PIN -1
#define TEMP_2_PIN -1
#define HEATER_BED_PIN -1
#define TEMP_BED_PIN -1
#endif
/****************************************************************************************
* Arduino Mega pin assignment
*
****************************************************************************************/
#if MOTHERBOARD == 33
#define MOTHERBOARD 3
#define RAMPS_V_1_3
#endif
#if MOTHERBOARD == 3
#define KNOWN_BOARD 1
//////////////////FIX THIS//////////////
#ifndef __AVR_ATmega1280__
#ifndef __AVR_ATmega2560__
#error Oops! Make sure you have 'Arduino Mega' selected from the 'Tools -> Boards' menu.
#endif
#endif
// uncomment one of the following lines for RAMPS v1.3 or v1.0, comment both for v1.2 or 1.1
// #define RAMPS_V_1_3
// #define RAMPS_V_1_0
#ifdef RAMPS_V_1_3
#define X_STEP_PIN 54
#define X_DIR_PIN 55
#define X_ENABLE_PIN 38
#define X_MIN_PIN 3
#define X_MAX_PIN 2 //2 //Max endstops default to disabled "-1", set to commented value to enable.
#define Y_STEP_PIN 60
#define Y_DIR_PIN 61
#define Y_ENABLE_PIN 56
#define Y_MIN_PIN 14
#define Y_MAX_PIN 15 //15
#define Z_STEP_PIN 46
#define Z_DIR_PIN 48
#define Z_ENABLE_PIN 62
#define Z_MIN_PIN 18
#define Z_MAX_PIN 19 //19
#define E0_STEP_PIN 26
#define E0_DIR_PIN 28
#define E0_ENABLE_PIN 24
#define E1_STEP_PIN 36
#define E1_DIR_PIN 34
#define E1_ENABLE_PIN 30
#define SDPOWER -1
#define SDSS 53
#define LED_PIN 13
#define FAN_PIN 4
#define PS_ON_PIN 12
#define KILL_PIN -1
#define HEATER_0_PIN 10 // EXTRUDER 1
#define HEATER_1_PIN 9 // EXTRUDER 2
#define HEATER_2_PIN -1 // EXTRUDER 2
#define TEMP_0_PIN 13 // ANALOG NUMBERING
#define TEMP_1_PIN 15 // ANALOG NUMBERING
#define TEMP_2_PIN -1 // ANALOG NUMBERING
#define HEATER_BED_PIN 8 // BED
#define TEMP_BED_PIN 14 // ANALOG NUMBERING
#else // RAMPS_V_1_1 or RAMPS_V_1_2 as default
#define X_STEP_PIN 26
#define X_DIR_PIN 28
#define X_ENABLE_PIN 24
#define X_MIN_PIN 3
#define X_MAX_PIN -1 //2
#define Y_STEP_PIN 38
#define Y_DIR_PIN 40
#define Y_ENABLE_PIN 36
#define Y_MIN_PIN 16
#define Y_MAX_PIN -1 //17
#define Z_STEP_PIN 44
#define Z_DIR_PIN 46
#define Z_ENABLE_PIN 42
#define Z_MIN_PIN 18
#define Z_MAX_PIN -1 //19
#define E0_STEP_PIN 32
#define E0_DIR_PIN 34
#define E0_ENABLE_PIN 30
#define SDPOWER 48
#define SDSS 53
#define LED_PIN 13
#define PS_ON_PIN -1
#define KILL_PIN -1
#ifdef RAMPS_V_1_0 // RAMPS_V_1_0
#define HEATER_0_PIN 12 // RAMPS 1.0
#define HEATER_BED_PIN -1 // RAMPS 1.0
#define FAN_PIN 11 // RAMPS 1.0
#else // RAMPS_V_1_1 or RAMPS_V_1_2
#define HEATER_0_PIN 10 // RAMPS 1.1
#define HEATER_BED_PIN 8 // RAMPS 1.1
#define FAN_PIN 9 // RAMPS 1.1
#endif
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#define TEMP_0_PIN 2 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
#define TEMP_1_PIN -1
#define TEMP_2_PIN -1
#define TEMP_BED_PIN 1 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
#endif
// SPI for Max6675 Thermocouple
#ifndef SDSUPPORT
// these pins are defined in the SD library if building with SD support #define SCK_PIN 52
#define MISO_PIN 50
#define MOSI_PIN 51
#define MAX6675_SS 53
#else
#define MAX6675_SS 49
#endif
#endif
/****************************************************************************************
* Duemilanove w/ ATMega328P pin assignment
*
****************************************************************************************/
#if MOTHERBOARD == 4
#define KNOWN_BOARD 1
#ifndef __AVR_ATmega328P__
#error Oops! Make sure you have 'Arduino Duemilanove w/ ATMega328' selected from the 'Tools -> Boards' menu.
#endif
#define X_STEP_PIN 19
#define X_DIR_PIN 18
#define X_ENABLE_PIN -1
#define X_MIN_PIN 17
#define X_MAX_PIN -1
#define Y_STEP_PIN 10
#define Y_DIR_PIN 7
#define Y_ENABLE_PIN -1
#define Y_MIN_PIN 8
#define Y_MAX_PIN -1
#define Z_STEP_PIN 13
#define Z_DIR_PIN 3
#define Z_ENABLE_PIN 2
#define Z_MIN_PIN 4
#define Z_MAX_PIN -1
#define E0_STEP_PIN 11
#define E0_DIR_PIN 12
#define E0_ENABLE_PIN -1
#define SDPOWER -1
#define SDSS -1
#define LED_PIN -1
#define FAN_PIN 5
#define PS_ON_PIN -1
#define KILL_PIN -1
#define HEATER_0_PIN 6
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#define TEMP_0_PIN 0 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
#define TEMP_1_PIN -1
#define TEMP_2_PIN -1
#define HEATER_BED_PIN -1
#define TEMP_BED_PIN -1
#endif
/****************************************************************************************
* Gen6 pin assignment
*
****************************************************************************************/
#if MOTHERBOARD == 5
#define KNOWN_BOARD 1
#ifndef __AVR_ATmega644P__
#error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu.
#endif
//x axis pins
#define X_STEP_PIN 15
#define X_DIR_PIN 18
#define X_ENABLE_PIN 19
#define X_MIN_PIN 20
#define X_MAX_PIN -1
//y axis pins
#define Y_STEP_PIN 23
#define Y_DIR_PIN 22
#define Y_ENABLE_PIN 24
#define Y_MIN_PIN 25
#define Y_MAX_PIN -1
//z axis pins
#define Z_STEP_PIN 27
#define Z_DIR_PIN 28
#define Z_ENABLE_PIN 29
#define Z_MIN_PIN 30
#define Z_MAX_PIN -1
//extruder pins
#define E0_STEP_PIN 4 //Edited @ EJE Electronics 20100715
#define E0_DIR_PIN 2 //Edited @ EJE Electronics 20100715
#define E0_ENABLE_PIN 3 //Added @ EJE Electronics 20100715
#define TEMP_0_PIN 5 //changed @ rkoeppl 20110410
#define TEMP_1_PIN -1 //changed @ rkoeppl 20110410
#define TEMP_2_PIN -1 //changed @ rkoeppl 20110410
#define HEATER_0_PIN 14 //changed @ rkoeppl 20110410
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#define HEATER_BED_PIN -1 //changed @ rkoeppl 20110410
#define TEMP_BED_PIN -1 //changed @ rkoeppl 20110410
#define SDPOWER -1
#define SDSS 17
#define LED_PIN -1 //changed @ rkoeppl 20110410
#define FAN_PIN -1 //changed @ rkoeppl 20110410
#define PS_ON_PIN -1 //changed @ rkoeppl 20110410
//our pin for debugging.
#define DEBUG_PIN 0
//our RS485 pins
#define TX_ENABLE_PIN 12
#define RX_ENABLE_PIN 13
#endif
/****************************************************************************************
* Sanguinololu pin assignment
*
****************************************************************************************/
#if MOTHERBOARD == 62
#define MOTHERBOARD 6
#define SANGUINOLOLU_V_1_2
#endif
#if MOTHERBOARD == 6
#define KNOWN_BOARD 1
#ifndef __AVR_ATmega644P__
#error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu.
#endif
#define X_STEP_PIN 15
#define X_DIR_PIN 21
#define X_MIN_PIN 18
#define X_MAX_PIN -2
#define Y_STEP_PIN 22
#define Y_DIR_PIN 23
#define Y_MIN_PIN 19
#define Y_MAX_PIN -1
#define Z_STEP_PIN 3
#define Z_DIR_PIN 2
#define Z_MIN_PIN 20
#define Z_MAX_PIN -1
#define E0_STEP_PIN 1
#define E0_DIR_PIN 0
#define LED_PIN -1
#define FAN_PIN -1
#define PS_ON_PIN -1
#define KILL_PIN -1
#define HEATER_0_PIN 13 // (extruder)
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#ifdef SANGUINOLOLU_V_1_2
#define HEATER_BED_PIN 12 // (bed)
#define X_ENABLE_PIN 14
#define Y_ENABLE_PIN 14
#define Z_ENABLE_PIN 26
#define E0_ENABLE_PIN 14
#else
#define HEATER_BED_PIN 14 // (bed)
#define X_ENABLE_PIN -1
#define Y_ENABLE_PIN -1
#define Z_ENABLE_PIN -1
#define E0_ENABLE_PIN -1
#endif
#define TEMP_0_PIN 7 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!! (pin 33 extruder)
#define TEMP_1_PIN -1
#define TEMP_2_PIN -1
#define TEMP_BED_PIN 6 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!! (pin 34 bed)
#define SDPOWER -1
#define SDSS 31
#endif
#if MOTHERBOARD == 7
#define KNOWN_BOARD
/*****************************************************************
* Ultimaker pin assignment
******************************************************************/
#ifndef __AVR_ATmega1280__
#ifndef __AVR_ATmega2560__
#error Oops! Make sure you have 'Arduino Mega' selected from the 'Tools -> Boards' menu.
#endif
#endif
#define X_STEP_PIN 25
#define X_DIR_PIN 23
#define X_MIN_PIN 22
#define X_MAX_PIN 24
#define X_ENABLE_PIN 27
#define Y_STEP_PIN 31
#define Y_DIR_PIN 33
#define Y_MIN_PIN 26
#define Y_MAX_PIN 28
#define Y_ENABLE_PIN 29
#define Z_STEP_PIN 37
#define Z_DIR_PIN 39
#define Z_MIN_PIN 30
#define Z_MAX_PIN 32
#define Z_ENABLE_PIN 35
#define HEATER_BED_PIN 4
#define TEMP_BED_PIN 11
#define EXTRUDER_0_STEP_PIN 43
#define EXTRUDER_0_DIR_PIN 45
#define EXTRUDER_0_ENABLE_PIN 41
#define HEATER_0_PIN 2
#define TEMP_0_PIN 8
#define EXTRUDER_1_STEP_PIN 49
#define EXTRUDER_1_DIR_PIN 47
#define EXTRUDER_1_ENABLE_PIN 51
#define EXTRUDER_1_HEATER_PIN 3
#define EXTRUDER_1_TEMPERATURE_PIN 10
#define HEATER_1_PIN 51
#define TEMP_1_PIN 3
#define E0_STEP_PIN EXTRUDER_0_STEP_PIN
#define E0_DIR_PIN EXTRUDER_0_DIR_PIN
#define E0_ENABLE_PIN EXTRUDER_0_ENABLE_PIN
#define SDPOWER -1
#define SDSS 53
#define LED_PIN 13
#define FAN_PIN 7
#define PS_ON_PIN 12
#define KILL_PIN -1
#ifdef ULTRA_LCD
#ifdef NEWPANEL
//arduino pin witch triggers an piezzo beeper
#define BEEPER 18
#define LCD_PINS_RS 20
#define LCD_PINS_ENABLE 17
#define LCD_PINS_D4 16
#define LCD_PINS_D5 21
#define LCD_PINS_D6 5
#define LCD_PINS_D7 6
//buttons are directly attached
#define BTN_EN1 40
#define BTN_EN2 42
#define BTN_ENC 19 //the click
#define BLEN_C 2
#define BLEN_B 1
#define BLEN_A 0
#define SDCARDDETECT 38
//encoder rotation values
#define encrot0 0
#define encrot1 2
#define encrot2 3
#define encrot3 1
#else //old style panel with shift register
//arduino pin witch triggers an piezzo beeper
#define BEEPER 18
//buttons are attached to a shift register
#define SHIFT_CLK 38
#define SHIFT_LD 42
#define SHIFT_OUT 40
#define SHIFT_EN 17
#define LCD_PINS_RS 16
#define LCD_PINS_ENABLE 5
#define LCD_PINS_D4 6
#define LCD_PINS_D5 21
#define LCD_PINS_D6 20
#define LCD_PINS_D7 19
//encoder rotation values
#define encrot0 0
#define encrot1 2
#define encrot2 3
#define encrot3 1
//bits in the shift register that carry the buttons for:
// left up center down right red
#define BL_LE 7
#define BL_UP 6
#define BL_MI 5
#define BL_DW 4
#define BL_RI 3
#define BL_ST 2
#define BLEN_B 1
#define BLEN_A 0
#endif
#endif //ULTRA_LCD
#endif
/****************************************************************************************
* Teensylu 0.7 pin assingments (ATMEGA90USB)
* Requires the Teensyduino software with Teensy2.0++ selected in arduino IDE!
****************************************************************************************/
#if MOTHERBOARD == 8
#define MOTHERBOARD 8
#define KNOWN_BOARD 1
#define X_STEP_PIN 0
#define X_DIR_PIN 1
#define X_ENABLE_PIN 39
#define X_MIN_PIN 13
#define X_MAX_PIN -1
#define Y_STEP_PIN 2
#define Y_DIR_PIN 3
#define Y_ENABLE_PIN 38
#define Y_MIN_PIN 14
#define Y_MAX_PIN -1
#define Z_STEP_PIN 4
#define Z_DIR_PIN 5
#define Z_ENABLE_PIN 23
#define Z_MIN_PIN 15
#define Z_MAX_PIN -1
#define E0_STEP_PIN 6
#define E0_DIR_PIN 7
#define E0_ENABLE_PIN 19
#define HEATER_0_PIN 21 // Extruder
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#define HEATER_BED_PIN 20 // Bed
#define FAN_PIN 22 // Fan
#define TEMP_0_PIN 7 // Extruder
#define TEMP_1_PIN -1
#define TEMP_2_PIN -1
#define TEMP_BED_PIN 6 // Bed
#define SDPOWER -1
#define SDSS 8
#define LED_PIN -1
#define PS_ON_PIN -1
#define KILL_PIN -1
#define ALARM_PIN -1
#ifndef SDSUPPORT
// these pins are defined in the SD library if building with SD support
#define SCK_PIN 9
#define MISO_PIN 11
#define MOSI_PIN 10
#endif
#endif
#ifndef KNOWN_BOARD
#error Unknown MOTHERBOARD value in configuration.h
#endif
//List of pins which to ignore when asked to change by gcode, 0 and 1 are RX and TX, do not mess with those!
#define _E0_PINS E0_STEP_PIN, E0_DIR_PIN, E0_ENABLE_PIN
#if EXTRUDERS == 3
#define _E1_PINS E1_STEP_PIN, E1_DIR_PIN, E1_ENABLE_PIN
#define _E2_PINS E2_STEP_PIN, E2_DIR_PIN, E2_ENABLE_PIN
#elif EXTRUDERS == 2
#define _E1_PINS E1_STEP_PIN, E1_DIR_PIN, E1_ENABLE_PIN
#define _E2_PINS -1
#elif EXTRUDERS == 1
#define _E1_PINS -1
#define _E2_PINS -1
#else
#error Unsupported number of extruders
#endif
#define SENSITIVE_PINS {0, 1, X_STEP_PIN, X_DIR_PIN, X_ENABLE_PIN, X_MIN_PIN, X_MAX_PIN, Y_STEP_PIN, Y_DIR_PIN, Y_ENABLE_PIN, Y_MIN_PIN, Y_MAX_PIN, Z_STEP_PIN, Z_DIR_PIN, Z_ENABLE_PIN, Z_MIN_PIN, Z_MAX_PIN, LED_PIN, PS_ON_PIN, \
HEATER_0_PIN, HEATER_1_PIN, HEATER_2_PIN, \
HEATER_BED_PIN, FAN_PIN, \
_E0_PINS, _E1_PINS, _E2_PINS, \
TEMP_0_PIN, TEMP_1_PIN, TEMP_2_PIN, TEMP_BED_PIN }
#ifndef PINS_H
#define PINS_H
/****************************************************************************************
* Arduino pin assignment
*
* ATMega168
* +-\/-+
* PC6 1| |28 PC5 (AI 5 / D19)
* (D 0) PD0 2| |27 PC4 (AI 4 / D18)
* (D 1) PD1 3| |26 PC3 (AI 3 / D17)
* (D 2) PD2 4| |25 PC2 (AI 2 / D16)
* PWM+ (D 3) PD3 5| |24 PC1 (AI 1 / D15)
* (D 4) PD4 6| |23 PC0 (AI 0 / D14)
* VCC 7| |22 GND
* GND 8| |21 AREF
* PB6 9| |20 AVCC
* PB7 10| |19 PB5 (D 13)
* PWM+ (D 5) PD5 11| |18 PB4 (D 12)
* PWM+ (D 6) PD6 12| |17 PB3 (D 11) PWM
* (D 7) PD7 13| |16 PB2 (D 10) PWM
* (D 8) PB0 14| |15 PB1 (D 9) PWM
* +----+
****************************************************************************************/
#if MOTHERBOARD == 0
#define KNOWN_BOARD 1
#ifndef __AVR_ATmega168__
#error Oops! Make sure you have 'Arduino Diecimila' selected from the boards menu.
#endif
#define X_STEP_PIN 2
#define X_DIR_PIN 3
#define X_ENABLE_PIN -1
#define X_MIN_PIN 4
#define X_MAX_PIN 9
#define Y_STEP_PIN 10
#define Y_DIR_PIN 7
#define Y_ENABLE_PIN -1
#define Y_MIN_PIN 8
#define Y_MAX_PIN 13
#define Z_STEP_PIN 19
#define Z_DIR_PIN 18
#define Z_ENABLE_PIN 5
#define Z_MIN_PIN 17
#define Z_MAX_PIN 16
#define E0_STEP_PIN 11
#define E0_DIR_PIN 12
#define E0_ENABLE_PIN -1
#define SDPOWER -1
#define SDSS -1
#define LED_PIN -1
#define FAN_PIN -1
#define PS_ON_PIN 15
#define KILL_PIN -1
#define HEATER_0_PIN 6
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#define TEMP_0_PIN 0 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
#define TEMP_1_PIN -1 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
#define TEMP_2_PIN -1 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
#define HEATER_BED_PIN -1
#define TEMP_BED_PIN -1
#endif
/****************************************************************************************
* Sanguino/RepRap Motherboard with direct-drive extruders
*
* ATMega644P
*
* +---\/---+
* (D 0) PB0 1| |40 PA0 (AI 0 / D31)
* (D 1) PB1 2| |39 PA1 (AI 1 / D30)
* INT2 (D 2) PB2 3| |38 PA2 (AI 2 / D29)
* PWM (D 3) PB3 4| |37 PA3 (AI 3 / D28)
* PWM (D 4) PB4 5| |36 PA4 (AI 4 / D27)
* MOSI (D 5) PB5 6| |35 PA5 (AI 5 / D26)
* MISO (D 6) PB6 7| |34 PA6 (AI 6 / D25)
* SCK (D 7) PB7 8| |33 PA7 (AI 7 / D24)
* RST 9| |32 AREF
* VCC 10| |31 GND
* GND 11| |30 AVCC
* XTAL2 12| |29 PC7 (D 23)
* XTAL1 13| |28 PC6 (D 22)
* RX0 (D 8) PD0 14| |27 PC5 (D 21) TDI
* TX0 (D 9) PD1 15| |26 PC4 (D 20) TDO
* INT0 RX1 (D 10) PD2 16| |25 PC3 (D 19) TMS
* INT1 TX1 (D 11) PD3 17| |24 PC2 (D 18) TCK
* PWM (D 12) PD4 18| |23 PC1 (D 17) SDA
* PWM (D 13) PD5 19| |22 PC0 (D 16) SCL
* PWM (D 14) PD6 20| |21 PD7 (D 15) PWM
* +--------+
*
****************************************************************************************/
#if MOTHERBOARD == 1
#define KNOWN_BOARD 1
#ifndef __AVR_ATmega644P__
#error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu.
#endif
#define X_STEP_PIN 15
#define X_DIR_PIN 18
#define X_ENABLE_PIN 19
#define X_MIN_PIN 20
#define X_MAX_PIN 21
#define Y_STEP_PIN 23
#define Y_DIR_PIN 22
#define Y_ENABLE_PIN 19
#define Y_MIN_PIN 25
#define Y_MAX_PIN 26
#define Z_STEP_PIN 29
#define Z_DIR_PIN 30
#define Z_ENABLE_PIN 31
#define Z_MIN_PIN 2
#define Z_MAX_PIN 1
#define E0_STEP_PIN 12
#define E0_DIR_PIN 16
#define E0_ENABLE_PIN 3
#define SDPOWER -1
#define SDSS -1
#define LED_PIN 0
#define FAN_PIN -1
#define PS_ON_PIN -1
#define KILL_PIN -1
#define HEATER_0_PIN 14
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#define TEMP_0_PIN 4 //D27 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
#define TEMP_1_PIN -1
#define TEMP_2_PIN -1
#define HEATER_BED_PIN -1
#define TEMP_BED_PIN -1
/* Unused (1) (2) (3) 4 5 6 7 8 9 10 11 12 13 (14) (15) (16) 17 (18) (19) (20) (21) (22) (23) 24 (25) (26) (27) 28 (29) (30) (31) */
#endif
/****************************************************************************************
* RepRap Motherboard ****---NOOOOOO RS485/EXTRUDER CONTROLLER!!!!!!!!!!!!!!!!!---*******
*
****************************************************************************************/
#if MOTHERBOARD == 2
#define KNOWN_BOARD 1
#ifndef __AVR_ATmega644P__
#error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu.
#endif
#define X_STEP_PIN 15
#define X_DIR_PIN 18
#define X_ENABLE_PIN 19
#define X_MIN_PIN 20
#define X_MAX_PIN 21
#define Y_STEP_PIN 23
#define Y_DIR_PIN 22
#define Y_ENABLE_PIN 24
#define Y_MIN_PIN 25
#define Y_MAX_PIN 26
#define Z_STEP_PINN 27
#define Z_DIR_PINN 28
#define Z_ENABLE_PIN 29
#define Z_MIN_PIN 30
#define Z_MAX_PIN 31
#define E0_STEP_PIN 17
#define E0_DIR_PIN 16
#define E0_ENABLE_PIN -1
#define SDPOWER -1
#define SDSS 4
#define LED_PIN 0
#define SD_CARD_WRITE 2
#define SD_CARD_DETECT 3
#define SD_CARD_SELECT 4
//our RS485 pins
#define TX_ENABLE_PIN 12
#define RX_ENABLE_PIN 13
//pin for controlling the PSU.
#define PS_ON_PIN 14
#define FAN_PIN -1
#define KILL_PIN -1
#define HEATER_0_PIN -1
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#define TEMP_0_PIN -1 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
#define TEMP_1_PIN -1
#define TEMP_2_PIN -1
#define HEATER_BED_PIN -1
#define TEMP_BED_PIN -1
#endif
/****************************************************************************************
* Arduino Mega pin assignment
*
****************************************************************************************/
#if MOTHERBOARD == 33
#define MOTHERBOARD 3
#define RAMPS_V_1_3
#endif
#if MOTHERBOARD == 3
#define KNOWN_BOARD 1
//////////////////FIX THIS//////////////
#ifndef __AVR_ATmega1280__
#ifndef __AVR_ATmega2560__
#error Oops! Make sure you have 'Arduino Mega' selected from the 'Tools -> Boards' menu.
#endif
#endif
// uncomment one of the following lines for RAMPS v1.3 or v1.0, comment both for v1.2 or 1.1
// #define RAMPS_V_1_3
// #define RAMPS_V_1_0
#ifdef RAMPS_V_1_3
#define X_STEP_PIN 54
#define X_DIR_PIN 55
#define X_ENABLE_PIN 38
#define X_MIN_PIN 3
#define X_MAX_PIN 2 //2 //Max endstops default to disabled "-1", set to commented value to enable.
#define Y_STEP_PIN 60
#define Y_DIR_PIN 61
#define Y_ENABLE_PIN 56
#define Y_MIN_PIN 14
#define Y_MAX_PIN 15 //15
#define Z_STEP_PIN 46
#define Z_DIR_PIN 48
#define Z_ENABLE_PIN 62
#define Z_MIN_PIN 18
#define Z_MAX_PIN 19 //19
#define E0_STEP_PIN 26
#define E0_DIR_PIN 28
#define E0_ENABLE_PIN 24
#define E1_STEP_PIN 36
#define E1_DIR_PIN 34
#define E1_ENABLE_PIN 30
#define SDPOWER -1
#define SDSS 53
#define LED_PIN 13
#define FAN_PIN 4
#define PS_ON_PIN 12
#define KILL_PIN -1
#define HEATER_0_PIN 10 // EXTRUDER 1
#define HEATER_1_PIN 9 // EXTRUDER 2
#define HEATER_2_PIN -1 // EXTRUDER 2
#define TEMP_0_PIN 13 // ANALOG NUMBERING
#define TEMP_1_PIN 15 // ANALOG NUMBERING
#define TEMP_2_PIN -1 // ANALOG NUMBERING
#define HEATER_BED_PIN 8 // BED
#define TEMP_BED_PIN 14 // ANALOG NUMBERING
#else // RAMPS_V_1_1 or RAMPS_V_1_2 as default
#define X_STEP_PIN 26
#define X_DIR_PIN 28
#define X_ENABLE_PIN 24
#define X_MIN_PIN 3
#define X_MAX_PIN -1 //2
#define Y_STEP_PIN 38
#define Y_DIR_PIN 40
#define Y_ENABLE_PIN 36
#define Y_MIN_PIN 16
#define Y_MAX_PIN -1 //17
#define Z_STEP_PIN 44
#define Z_DIR_PIN 46
#define Z_ENABLE_PIN 42
#define Z_MIN_PIN 18
#define Z_MAX_PIN -1 //19
#define E0_STEP_PIN 32
#define E0_DIR_PIN 34
#define E0_ENABLE_PIN 30
#define SDPOWER 48
#define SDSS 53
#define LED_PIN 13
#define PS_ON_PIN -1
#define KILL_PIN -1
#ifdef RAMPS_V_1_0 // RAMPS_V_1_0
#define HEATER_0_PIN 12 // RAMPS 1.0
#define HEATER_BED_PIN -1 // RAMPS 1.0
#define FAN_PIN 11 // RAMPS 1.0
#else // RAMPS_V_1_1 or RAMPS_V_1_2
#define HEATER_0_PIN 10 // RAMPS 1.1
#define HEATER_BED_PIN 8 // RAMPS 1.1
#define FAN_PIN 9 // RAMPS 1.1
#endif
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#define TEMP_0_PIN 2 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
#define TEMP_1_PIN -1
#define TEMP_2_PIN -1
#define TEMP_BED_PIN 1 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
#endif
// SPI for Max6675 Thermocouple
#ifndef SDSUPPORT
// these pins are defined in the SD library if building with SD support #define SCK_PIN 52
#define MISO_PIN 50
#define MOSI_PIN 51
#define MAX6675_SS 53
#else
#define MAX6675_SS 49
#endif
#endif
/****************************************************************************************
* Duemilanove w/ ATMega328P pin assignment
*
****************************************************************************************/
#if MOTHERBOARD == 4
#define KNOWN_BOARD 1
#ifndef __AVR_ATmega328P__
#error Oops! Make sure you have 'Arduino Duemilanove w/ ATMega328' selected from the 'Tools -> Boards' menu.
#endif
#define X_STEP_PIN 19
#define X_DIR_PIN 18
#define X_ENABLE_PIN -1
#define X_MIN_PIN 17
#define X_MAX_PIN -1
#define Y_STEP_PIN 10
#define Y_DIR_PIN 7
#define Y_ENABLE_PIN -1
#define Y_MIN_PIN 8
#define Y_MAX_PIN -1
#define Z_STEP_PIN 13
#define Z_DIR_PIN 3
#define Z_ENABLE_PIN 2
#define Z_MIN_PIN 4
#define Z_MAX_PIN -1
#define E0_STEP_PIN 11
#define E0_DIR_PIN 12
#define E0_ENABLE_PIN -1
#define SDPOWER -1
#define SDSS -1
#define LED_PIN -1
#define FAN_PIN 5
#define PS_ON_PIN -1
#define KILL_PIN -1
#define HEATER_0_PIN 6
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#define TEMP_0_PIN 0 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
#define TEMP_1_PIN -1
#define TEMP_2_PIN -1
#define HEATER_BED_PIN -1
#define TEMP_BED_PIN -1
#endif
/****************************************************************************************
* Gen6 pin assignment
*
****************************************************************************************/
#if MOTHERBOARD == 5
#define KNOWN_BOARD 1
#ifndef __AVR_ATmega644P__
#error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu.
#endif
//x axis pins
#define X_STEP_PIN 15
#define X_DIR_PIN 18
#define X_ENABLE_PIN 19
#define X_MIN_PIN 20
#define X_MAX_PIN -1
//y axis pins
#define Y_STEP_PIN 23
#define Y_DIR_PIN 22
#define Y_ENABLE_PIN 24
#define Y_MIN_PIN 25
#define Y_MAX_PIN -1
//z axis pins
#define Z_STEP_PIN 27
#define Z_DIR_PIN 28
#define Z_ENABLE_PIN 29
#define Z_MIN_PIN 30
#define Z_MAX_PIN -1
//extruder pins
#define E0_STEP_PIN 4 //Edited @ EJE Electronics 20100715
#define E0_DIR_PIN 2 //Edited @ EJE Electronics 20100715
#define E0_ENABLE_PIN 3 //Added @ EJE Electronics 20100715
#define TEMP_0_PIN 5 //changed @ rkoeppl 20110410
#define TEMP_1_PIN -1 //changed @ rkoeppl 20110410
#define TEMP_2_PIN -1 //changed @ rkoeppl 20110410
#define HEATER_0_PIN 14 //changed @ rkoeppl 20110410
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#define HEATER_BED_PIN -1 //changed @ rkoeppl 20110410
#define TEMP_BED_PIN -1 //changed @ rkoeppl 20110410
#define SDPOWER -1
#define SDSS 17
#define LED_PIN -1 //changed @ rkoeppl 20110410
#define FAN_PIN -1 //changed @ rkoeppl 20110410
#define PS_ON_PIN -1 //changed @ rkoeppl 20110410
//our pin for debugging.
#define DEBUG_PIN 0
//our RS485 pins
#define TX_ENABLE_PIN 12
#define RX_ENABLE_PIN 13
#endif
/****************************************************************************************
* Sanguinololu pin assignment
*
****************************************************************************************/
#if MOTHERBOARD == 62
#define MOTHERBOARD 6
#define SANGUINOLOLU_V_1_2
#endif
#if MOTHERBOARD == 6
#define KNOWN_BOARD 1
#ifndef __AVR_ATmega644P__
#error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu.
#endif
#define X_STEP_PIN 15
#define X_DIR_PIN 21
#define X_MIN_PIN 18
#define X_MAX_PIN -2
#define Y_STEP_PIN 22
#define Y_DIR_PIN 23
#define Y_MIN_PIN 19
#define Y_MAX_PIN -1
#define Z_STEP_PIN 3
#define Z_DIR_PIN 2
#define Z_MIN_PIN 20
#define Z_MAX_PIN -1
#define E0_STEP_PIN 1
#define E0_DIR_PIN 0
#define LED_PIN -1
#define FAN_PIN -1
#define PS_ON_PIN -1
#define KILL_PIN -1
#define HEATER_0_PIN 13 // (extruder)
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#ifdef SANGUINOLOLU_V_1_2
#define HEATER_BED_PIN 12 // (bed)
#define X_ENABLE_PIN 14
#define Y_ENABLE_PIN 14
#define Z_ENABLE_PIN 26
#define E0_ENABLE_PIN 14
#else
#define HEATER_BED_PIN 14 // (bed)
#define X_ENABLE_PIN -1
#define Y_ENABLE_PIN -1
#define Z_ENABLE_PIN -1
#define E0_ENABLE_PIN -1
#endif
#define TEMP_0_PIN 7 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!! (pin 33 extruder)
#define TEMP_1_PIN -1
#define TEMP_2_PIN -1
#define TEMP_BED_PIN 6 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!! (pin 34 bed)
#define SDPOWER -1
#define SDSS 31
#endif
#if MOTHERBOARD == 7
#define KNOWN_BOARD
/*****************************************************************
* Ultimaker pin assignment
******************************************************************/
#ifndef __AVR_ATmega1280__
#ifndef __AVR_ATmega2560__
#error Oops! Make sure you have 'Arduino Mega' selected from the 'Tools -> Boards' menu.
#endif
#endif
#define X_STEP_PIN 25
#define X_DIR_PIN 23
#define X_MIN_PIN 22
#define X_MAX_PIN 24
#define X_ENABLE_PIN 27
#define Y_STEP_PIN 31
#define Y_DIR_PIN 33
#define Y_MIN_PIN 26
#define Y_MAX_PIN 28
#define Y_ENABLE_PIN 29
#define Z_STEP_PIN 37
#define Z_DIR_PIN 39
#define Z_MIN_PIN 30
#define Z_MAX_PIN 32
#define Z_ENABLE_PIN 35
#define HEATER_BED_PIN 4
#define TEMP_BED_PIN 11
#define HEATER_0_PIN 2
#define TEMP_0_PIN 8
#define EXTRUDER_1_HEATER_PIN 3
#define EXTRUDER_1_TEMPERATURE_PIN 10
#define HEATER_1_PIN 51
#define TEMP_1_PIN 3
#define HEATER_2_PIN -1
#define TEMP_2_PIN -1
#define E0_STEP_PIN 43
#define E0_DIR_PIN 45
#define E0_ENABLE_PIN 41
#define E1_STEP_PIN 49
#define E1_DIR_PIN 47
#define E1_ENABLE_PIN 51
#define SDPOWER -1
#define SDSS 53
#define LED_PIN 13
#define FAN_PIN 7
#define PS_ON_PIN 12
#define KILL_PIN -1
#ifdef ULTRA_LCD
#ifdef NEWPANEL
//arduino pin witch triggers an piezzo beeper
#define BEEPER 18
#define LCD_PINS_RS 20
#define LCD_PINS_ENABLE 17
#define LCD_PINS_D4 16
#define LCD_PINS_D5 21
#define LCD_PINS_D6 5
#define LCD_PINS_D7 6
//buttons are directly attached
#define BTN_EN1 40
#define BTN_EN2 42
#define BTN_ENC 19 //the click
#define BLEN_C 2
#define BLEN_B 1
#define BLEN_A 0
#define SDCARDDETECT 38
//encoder rotation values
#define encrot0 0
#define encrot1 2
#define encrot2 3
#define encrot3 1
#else //old style panel with shift register
//arduino pin witch triggers an piezzo beeper
#define BEEPER 18
//buttons are attached to a shift register
#define SHIFT_CLK 38
#define SHIFT_LD 42
#define SHIFT_OUT 40
#define SHIFT_EN 17
#define LCD_PINS_RS 16
#define LCD_PINS_ENABLE 5
#define LCD_PINS_D4 6
#define LCD_PINS_D5 21
#define LCD_PINS_D6 20
#define LCD_PINS_D7 19
//encoder rotation values
#define encrot0 0
#define encrot1 2
#define encrot2 3
#define encrot3 1
//bits in the shift register that carry the buttons for:
// left up center down right red
#define BL_LE 7
#define BL_UP 6
#define BL_MI 5
#define BL_DW 4
#define BL_RI 3
#define BL_ST 2
#define BLEN_B 1
#define BLEN_A 0
#endif
#endif //ULTRA_LCD
#endif
/****************************************************************************************
* Teensylu 0.7 pin assingments (ATMEGA90USB)
* Requires the Teensyduino software with Teensy2.0++ selected in arduino IDE!
****************************************************************************************/
#if MOTHERBOARD == 8
#define MOTHERBOARD 8
#define KNOWN_BOARD 1
#define X_STEP_PIN 0
#define X_DIR_PIN 1
#define X_ENABLE_PIN 39
#define X_MIN_PIN 13
#define X_MAX_PIN -1
#define Y_STEP_PIN 2
#define Y_DIR_PIN 3
#define Y_ENABLE_PIN 38
#define Y_MIN_PIN 14
#define Y_MAX_PIN -1
#define Z_STEP_PIN 4
#define Z_DIR_PIN 5
#define Z_ENABLE_PIN 23
#define Z_MIN_PIN 15
#define Z_MAX_PIN -1
#define E0_STEP_PIN 6
#define E0_DIR_PIN 7
#define E0_ENABLE_PIN 19
#define HEATER_0_PIN 21 // Extruder
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#define HEATER_BED_PIN 20 // Bed
#define FAN_PIN 22 // Fan
#define TEMP_0_PIN 7 // Extruder
#define TEMP_1_PIN -1
#define TEMP_2_PIN -1
#define TEMP_BED_PIN 6 // Bed
#define SDPOWER -1
#define SDSS 8
#define LED_PIN -1
#define PS_ON_PIN -1
#define KILL_PIN -1
#define ALARM_PIN -1
#ifndef SDSUPPORT
// these pins are defined in the SD library if building with SD support
#define SCK_PIN 9
#define MISO_PIN 11
#define MOSI_PIN 10
#endif
#endif
#ifndef KNOWN_BOARD
#error Unknown MOTHERBOARD value in configuration.h
#endif
//List of pins which to ignore when asked to change by gcode, 0 and 1 are RX and TX, do not mess with those!
#define _E0_PINS E0_STEP_PIN, E0_DIR_PIN, E0_ENABLE_PIN
#if EXTRUDERS == 3
#define _E1_PINS E1_STEP_PIN, E1_DIR_PIN, E1_ENABLE_PIN
#define _E2_PINS E2_STEP_PIN, E2_DIR_PIN, E2_ENABLE_PIN
#elif EXTRUDERS == 2
#define _E1_PINS E1_STEP_PIN, E1_DIR_PIN, E1_ENABLE_PIN
#define _E2_PINS -1
#elif EXTRUDERS == 1
#define _E1_PINS -1
#define _E2_PINS -1
#else
#error Unsupported number of extruders
#endif
#define SENSITIVE_PINS {0, 1, X_STEP_PIN, X_DIR_PIN, X_ENABLE_PIN, X_MIN_PIN, X_MAX_PIN, Y_STEP_PIN, Y_DIR_PIN, Y_ENABLE_PIN, Y_MIN_PIN, Y_MAX_PIN, Z_STEP_PIN, Z_DIR_PIN, Z_ENABLE_PIN, Z_MIN_PIN, Z_MAX_PIN, LED_PIN, PS_ON_PIN, \
HEATER_0_PIN, HEATER_1_PIN, HEATER_2_PIN, \
HEATER_BED_PIN, FAN_PIN, \
_E0_PINS, _E1_PINS, _E2_PINS, \
TEMP_0_PIN, TEMP_1_PIN, TEMP_2_PIN, TEMP_BED_PIN }
#endif

View file

@ -191,8 +191,8 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi
}
#ifdef ADVANCE
long initial_advance = block->advance*entry_factor*entry_factor;
long final_advance = block->advance*exit_factor*exit_factor;
volatile long initial_advance = block->advance*entry_factor*entry_factor;
volatile long final_advance = block->advance*exit_factor*exit_factor;
#endif // ADVANCE
// block->accelerate_until = accelerate_steps;

View file

@ -57,7 +57,7 @@ volatile static unsigned long step_events_completed; // The number of step event
static long advance_rate, advance, final_advance = 0;
static long old_advance = 0;
#endif
static long e_steps;
static long e_steps[3];
static unsigned char busy = false; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler.
static long acceleration_time, deceleration_time;
//static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;
@ -266,7 +266,7 @@ FORCE_INLINE void trapezoid_generator_reset() {
advance = current_block->initial_advance;
final_advance = current_block->final_advance;
// Do E steps + advance steps
e_steps += ((advance >>8) - old_advance);
e_steps[current_block->active_extruder] += ((advance >>8) - old_advance);
old_advance = advance >>8;
#endif
deceleration_time = 0;
@ -303,8 +303,8 @@ ISR(TIMER1_COMPA_vect)
counter_z = counter_x;
counter_e = counter_x;
step_events_completed = 0;
// #ifdef ADVANCE
e_steps = 0;
// #ifdef ADVANCE
// e_steps[current_block->active_extruder] = 0;
// #endif
}
else {
@ -418,11 +418,11 @@ ISR(TIMER1_COMPA_vect)
#ifndef ADVANCE
if ((out_bits & (1<<E_AXIS)) != 0) { // -direction
NORM_E_DIR();
REV_E_DIR();
count_direction[E_AXIS]=-1;
}
else { // +direction
REV_E_DIR();
NORM_E_DIR();
count_direction[E_AXIS]=-1;
}
#endif //!ADVANCE
@ -437,10 +437,10 @@ ISR(TIMER1_COMPA_vect)
if (counter_e > 0) {
counter_e -= current_block->step_event_count;
if ((out_bits & (1<<E_AXIS)) != 0) { // - direction
e_steps--;
e_steps[current_block->active_extruder]--;
}
else {
e_steps++;
e_steps[current_block->active_extruder]++;
}
}
#endif //ADVANCE
@ -503,7 +503,7 @@ ISR(TIMER1_COMPA_vect)
}
//if(advance > current_block->advance) advance = current_block->advance;
// Do E steps + advance steps
e_steps += ((advance >>8) - old_advance);
e_steps[current_block->active_extruder] += ((advance >>8) - old_advance);
old_advance = advance >>8;
#endif
@ -532,7 +532,7 @@ ISR(TIMER1_COMPA_vect)
}
if(advance < final_advance) advance = final_advance;
// Do E steps + advance steps
e_steps += ((advance >>8) - old_advance);
e_steps[current_block->active_extruder] += ((advance >>8) - old_advance);
old_advance = advance >>8;
#endif //ADVANCE
}
@ -557,20 +557,50 @@ ISR(TIMER1_COMPA_vect)
old_OCR0A += 52; // ~10kHz interrupt (250000 / 26 = 9615kHz)
OCR0A = old_OCR0A;
// Set E direction (Depends on E direction + advance)
for(unsigned char i=0; i<4;) {
WRITE_E_STEP(LOW);
if (e_steps == 0) break;
i++;
if (e_steps < 0) {
WRITE_E_DIR(INVERT_E_DIR);
e_steps++;
WRITE_E_STEP(HIGH);
}
else if (e_steps > 0) {
WRITE_E_DIR(!INVERT_E_DIR);
e_steps--;
WRITE_E_STEP(HIGH);
for(unsigned char i=0; i<4;i++) {
if (e_steps[0] != 0) {
WRITE(E0_STEP_PIN, LOW);
if (e_steps[0] < 0) {
WRITE(E0_DIR_PIN, INVERT_E0_DIR);
e_steps[0]++;
WRITE(E0_STEP_PIN, HIGH);
}
else if (e_steps[0] > 0) {
WRITE(E0_DIR_PIN, !INVERT_E0_DIR);
e_steps[0]--;
WRITE(E0_STEP_PIN, HIGH);
}
}
#if EXTRUDERS > 1
if (e_steps[1] != 0) {
WRITE(E1_STEP_PIN, LOW);
if (e_steps[1] < 0) {
WRITE(E1_DIR_PIN, INVERT_E1_DIR);
e_steps[1]++;
WRITE(E1_STEP_PIN, HIGH);
}
else if (e_steps[1] > 0) {
WRITE(E1_DIR_PIN, !INVERT_E1_DIR);
e_steps[1]--;
WRITE(E1_STEP_PIN, HIGH);
}
}
#endif
#if EXTRUDERS > 2
if (e_steps[2] != 0) {
WRITE(E2_STEP_PIN, LOW);
if (e_steps[2] < 0) {
WRITE(E2_DIR_PIN, INVERT_E2_DIR);
e_steps[2]++;
WRITE(E2_STEP_PIN, HIGH);
}
else if (e_steps[2] > 0) {
WRITE(E2_DIR_PIN, !INVERT_E2_DIR);
e_steps[2]--;
WRITE(E2_STEP_PIN, HIGH);
}
}
#endif
}
}
#endif // ADVANCE
@ -712,7 +742,9 @@ void st_init()
TCCR0A &= ~(1<<WGM01);
TCCR0A &= ~(1<<WGM00);
#endif
e_steps = 0;
e_steps[0] = 0;
e_steps[1] = 0;
e_steps[2] = 0;
TIMSK0 |= (1<<OCIE0A);
#endif //ADVANCE

View file

@ -23,6 +23,21 @@
#include "planner.h"
#if EXTRUDERS > 2
#define WRITE_E_STEP(v) { if(current_block->active_extruder == 2) { WRITE(E2_STEP_PIN, v); } else { if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }}}
#define NORM_E_DIR() { if(current_block->active_extruder == 2) { WRITE(!E2_DIR_PIN, INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { WRITE(!E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }}}
#define REV_E_DIR() { if(current_block->active_extruder == 2) { WRITE(E2_DIR_PIN, INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }}}
#elif EXTRUDERS > 1
#define WRITE_E_STEP(v) { if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }}
#define NORM_E_DIR() { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }}
#define REV_E_DIR() { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }}
#else
#define WRITE_E_STEP(v) WRITE(E0_STEP_PIN, v)
#define NORM_E_DIR() WRITE(E0_DIR_PIN, !INVERT_E0_DIR)
#define REV_E_DIR() WRITE(E0_DIR_PIN, INVERT_E0_DIR)
#endif
// Initialize and start the stepper motor subsystem
void st_init();

View file

@ -26,7 +26,6 @@
It has preliminary support for Matthew Roberts advance algorithm
http://reprap.org/pipermail/reprap-dev/2011-May/003323.html
This firmware is optimized for gen6 electronics.
*/
#include <avr/pgmspace.h>
@ -82,6 +81,7 @@ static unsigned long previous_millis_bed_heater;
// static float pid_output[EXTRUDERS];
static bool pid_reset[EXTRUDERS];
#endif //PIDTEMP
static unsigned char soft_pwm[EXTRUDERS];
#ifdef WATCHPERIOD
static int watch_raw[EXTRUDERS] = { -1000 }; // the first value used for all
@ -140,6 +140,10 @@ void updatePID()
#endif
}
int getHeaterPower(int heater) {
return soft_pwm[heater];
}
void manage_heater()
{
#ifdef USE_WATCHDOG
@ -198,15 +202,16 @@ void manage_heater()
}
#endif
// Check if temperature is within the correct range
if((current_raw[e] > minttemp[e]) && (current_raw[e] < maxttemp[e]))
{
analogWrite(heater_pin_map[e], pid_output);
}
else {
analogWrite(heater_pin_map[e], 0);
}
// Check if temperature is within the correct range
if((current_raw[e] > minttemp[e]) && (current_raw[e] < maxttemp[e]))
{
//analogWrite(heater_pin_map[e], pid_output);
soft_pwm[e] = (int)pid_output >> 1;
}
else {
//analogWrite(heater_pin_map[e], 0);
soft_pwm[e] = 0;
}
} // End extruder for loop
if(millis() - previous_millis_bed_heater < BED_CHECK_INTERVAL)
@ -418,7 +423,6 @@ void tp_init()
DIDR0 |= 1 << TEMP_0_PIN;
#else
DIDR2 |= 1<<(TEMP_0_PIN - 8);
ADCSRB = 1<<MUX5;
#endif
#endif
#if (TEMP_1_PIN > -1)
@ -426,7 +430,6 @@ void tp_init()
DIDR0 |= 1<<TEMP_1_PIN;
#else
DIDR2 |= 1<<(TEMP_1_PIN - 8);
ADCSRB = 1<<MUX5;
#endif
#endif
#if (TEMP_2_PIN > -1)
@ -434,7 +437,6 @@ void tp_init()
DIDR0 |= 1 << TEMP_2_PIN;
#else
DIDR2 = 1<<(TEMP_2_PIN - 8);
ADCSRB = 1<<MUX5;
#endif
#endif
#if (TEMP_BED_PIN > -1)
@ -442,7 +444,6 @@ void tp_init()
DIDR0 |= 1<<TEMP_BED_PIN;
#else
DIDR2 |= 1<<(TEMP_BED_PIN - 8);
ADCSRB = 1<<MUX5;
#endif
#endif
@ -506,6 +507,7 @@ void disable_heater()
{
#if TEMP_0_PIN > -1
target_raw[0]=0;
soft_pwm[0]=0;
#if HEATER_0_PIN > -1
digitalWrite(HEATER_0_PIN,LOW);
#endif
@ -513,6 +515,7 @@ void disable_heater()
#if TEMP_1_PIN > -1
target_raw[1]=0;
soft_pwm[1]=0;
#if HEATER_1_PIN > -1
digitalWrite(HEATER_1_PIN,LOW);
#endif
@ -520,6 +523,7 @@ void disable_heater()
#if TEMP_2_PIN > -1
target_raw[2]=0;
soft_pwm[2]=0;
#if HEATER_2_PIN > -1
digitalWrite(HEATER_2_PIN,LOW);
#endif
@ -533,6 +537,26 @@ void disable_heater()
#endif
}
void max_temp_error(uint8_t e) {
digitalWrite(heater_pin_map[e], 0);
SERIAL_ERROR_START;
SERIAL_ERRORLN(e);
SERIAL_ERRORLNPGM(": Extruder switched off. MAXTEMP triggered !");
}
void min_temp_error(uint8_t e) {
digitalWrite(heater_pin_map[e], 0);
SERIAL_ERROR_START;
SERIAL_ERRORLN(e);
SERIAL_ERRORLNPGM(": Extruder switched off. MINTEMP triggered !");
}
void bed_max_temp_error(void) {
digitalWrite(HEATER_BED_PIN, 0);
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM("Temperature heated bed switched off. MAXTEMP triggered !!");
}
// Timer 0 is shared with millies
ISR(TIMER0_COMPB_vect)
{
@ -543,6 +567,33 @@ ISR(TIMER0_COMPB_vect)
static unsigned long raw_temp_2_value = 0;
static unsigned long raw_temp_bed_value = 0;
static unsigned char temp_state = 0;
static unsigned char pwm_count = 1;
static unsigned char soft_pwm_0;
static unsigned char soft_pwm_1;
static unsigned char soft_pwm_2;
if(pwm_count == 0){
soft_pwm_0 = soft_pwm[0];
if(soft_pwm_0 > 0) WRITE(HEATER_0_PIN,1);
#if EXTRUDERS > 1
soft_pwm_1 = soft_pwm[1];
if(soft_pwm_1 > 0) WRITE(HEATER_1_PIN,1);
#endif
#if EXTRUDERS > 2
soft_pwm_2 = soft_pwm[2];
if(soft_pwm_2 > 0) WRITE(HEATER_2_PIN,1);
#endif
}
if(soft_pwm_0 <= pwm_count) WRITE(HEATER_0_PIN,0);
#if EXTRUDERS > 1
if(soft_pwm_1 <= pwm_count) WRITE(HEATER_1_PIN,0);
#endif
#if EXTRUDERS > 2
if(soft_pwm_2 <= pwm_count) WRITE(HEATER_2_PIN,0);
#endif
pwm_count++;
pwm_count &= 0x7f;
switch(temp_state) {
case 0: // Prepare TEMP_0
@ -628,10 +679,10 @@ ISR(TIMER0_COMPB_vect)
temp_state = 0;
temp_count++;
break;
default:
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM("Temp measurement error!");
break;
// default:
// SERIAL_ERROR_START;
// SERIAL_ERRORLNPGM("Temp measurement error!");
// break;
}
if(temp_count >= 16) // 8 ms * 16 = 128ms.
@ -671,21 +722,15 @@ ISR(TIMER0_COMPB_vect)
raw_temp_2_value = 0;
raw_temp_bed_value = 0;
for(int e = 0; e < EXTRUDERS; e++) {
for(unsigned char e = 0; e < EXTRUDERS; e++) {
if(current_raw[e] >= maxttemp[e]) {
target_raw[e] = 0;
digitalWrite(heater_pin_map[e], 0);
SERIAL_ERROR_START;
SERIAL_ERRORLN((int)e);
SERIAL_ERRORLNPGM(": Extruder switched off. MAXTEMP triggered !");
kill();
max_temp_error(e);
kill();;
}
if(current_raw[e] <= minttemp[e]) {
target_raw[e] = 0;
digitalWrite(heater_pin_map[e], 0);
SERIAL_ERROR_START;
SERIAL_ERRORLN(e);
SERIAL_ERRORLNPGM(": Extruder switched off. MINTEMP triggered !");
min_temp_error(e);
kill();
}
}
@ -693,9 +738,7 @@ ISR(TIMER0_COMPB_vect)
#if defined(BED_MAXTEMP) && (HEATER_BED_PIN > -1)
if(current_raw_bed >= bed_maxttemp) {
target_raw_bed = 0;
digitalWrite(HEATER_BED_PIN, 0);
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM("Temperature heated bed switched off. MAXTEMP triggered !!");
bed_max_temp_error();
kill();
}
#endif

View file

@ -1,143 +1,144 @@
/*
temperature.h - temperature controller
Part of Marlin
Copyright (c) 2011 Erik van der Zalm
Grbl is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Grbl is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef temperature_h
#define temperature_h
#include "Marlin.h"
#include "fastio.h"
#ifdef PID_ADD_EXTRUSION_RATE
#include "stepper.h"
#endif
// public functions
void tp_init(); //initialise the heating
void manage_heater(); //it is critical that this is called periodically.
//low leven conversion routines
// do not use this routines and variables outsie of temperature.cpp
int temp2analog(int celsius, uint8_t e);
int temp2analogBed(int celsius);
float analog2temp(int raw, uint8_t e);
float analog2tempBed(int raw);
extern int target_raw[EXTRUDERS];
extern int heatingtarget_raw[EXTRUDERS];
extern int current_raw[EXTRUDERS];
extern int target_raw_bed;
extern int current_raw_bed;
extern float Kp,Ki,Kd,Kc;
#ifdef PIDTEMP
extern float pid_setpoint[EXTRUDERS];
#endif
#ifdef WATCHPERIOD
extern int watch_raw[EXTRUDERS] ;
extern unsigned long watchmillis;
#endif
//high level conversion routines, for use outside of temperature.cpp
//inline so that there is no performance decrease.
//deg=degreeCelsius
FORCE_INLINE float degHotend(uint8_t extruder) {
return analog2temp(current_raw[extruder], extruder);
};
FORCE_INLINE float degBed() {
return analog2tempBed(current_raw_bed);
};
FORCE_INLINE float degTargetHotend(uint8_t extruder) {
return analog2temp(target_raw[extruder], extruder);
};
FORCE_INLINE float degTargetBed() {
return analog2tempBed(target_raw_bed);
};
FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) {
target_raw[extruder] = temp2analog(celsius, extruder);
#ifdef PIDTEMP
pid_setpoint[extruder] = celsius;
#endif //PIDTEMP
};
FORCE_INLINE void setTargetBed(const float &celsius) {
target_raw_bed = temp2analogBed(celsius);
};
FORCE_INLINE bool isHeatingHotend(uint8_t extruder){
return target_raw[extruder] > current_raw[extruder];
};
FORCE_INLINE bool isHeatingBed() {
return target_raw_bed > current_raw_bed;
};
FORCE_INLINE bool isCoolingHotend(uint8_t extruder) {
return target_raw[extruder] < current_raw[extruder];
};
FORCE_INLINE bool isCoolingBed() {
return target_raw_bed < current_raw_bed;
};
#define degHotend0() degHotend(0)
#define degTargetHotend0() degTargetHotend(0)
#define setTargetHotend0(_celsius) setTargetHotend((_celsius), 0)
#define isHeatingHotend0() isHeatingHotend(0)
#define isCoolingHotend0() isCoolingHotend(0)
#if EXTRUDERS > 1
#define degHotend1() degHotend(1)
#define degTargetHotend1() degTargetHotend(1)
#define setTargetHotend1(_celsius) setTargetHotend((_celsius), 1)
#define isHeatingHotend1() isHeatingHotend(1)
#define isCoolingHotend1() isCoolingHotend(1)
#endif
#if EXTRUDERS > 2
#define degHotend2() degHotend(2)
#define degTargetHotend2() degTargetHotend(2)
#define setTargetHotend2(_celsius) setTargetHotend((_celsius), 2)
#define isHeatingHotend2() isHeatingHotend(2)
#define isCoolingHotend2() isCoolingHotend(2)
#endif
#if EXTRUDERS > 3
#error Invalid number of extruders
#endif
FORCE_INLINE void autotempShutdown(){
#ifdef AUTOTEMP
if(autotemp_enabled)
{
autotemp_enabled=false;
if(degTargetHotend(ACTIVE_EXTRUDER)>autotemp_min)
setTargetHotend(0,ACTIVE_EXTRUDER);
}
#endif
}
void disable_heater();
void setWatch();
void updatePID();
#endif
/*
temperature.h - temperature controller
Part of Marlin
Copyright (c) 2011 Erik van der Zalm
Grbl is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Grbl is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef temperature_h
#define temperature_h
#include "Marlin.h"
#include "fastio.h"
#ifdef PID_ADD_EXTRUSION_RATE
#include "stepper.h"
#endif
// public functions
void tp_init(); //initialise the heating
void manage_heater(); //it is critical that this is called periodically.
//low leven conversion routines
// do not use this routines and variables outsie of temperature.cpp
int temp2analog(int celsius, uint8_t e);
int temp2analogBed(int celsius);
float analog2temp(int raw, uint8_t e);
float analog2tempBed(int raw);
extern int target_raw[EXTRUDERS];
extern int heatingtarget_raw[EXTRUDERS];
extern int current_raw[EXTRUDERS];
extern int target_raw_bed;
extern int current_raw_bed;
extern float Kp,Ki,Kd,Kc;
#ifdef PIDTEMP
extern float pid_setpoint[EXTRUDERS];
#endif
#ifdef WATCHPERIOD
extern int watch_raw[EXTRUDERS] ;
extern unsigned long watchmillis;
#endif
//high level conversion routines, for use outside of temperature.cpp
//inline so that there is no performance decrease.
//deg=degreeCelsius
FORCE_INLINE float degHotend(uint8_t extruder) {
return analog2temp(current_raw[extruder], extruder);
};
FORCE_INLINE float degBed() {
return analog2tempBed(current_raw_bed);
};
FORCE_INLINE float degTargetHotend(uint8_t extruder) {
return analog2temp(target_raw[extruder], extruder);
};
FORCE_INLINE float degTargetBed() {
return analog2tempBed(target_raw_bed);
};
FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) {
target_raw[extruder] = temp2analog(celsius, extruder);
#ifdef PIDTEMP
pid_setpoint[extruder] = celsius;
#endif //PIDTEMP
};
FORCE_INLINE void setTargetBed(const float &celsius) {
target_raw_bed = temp2analogBed(celsius);
};
FORCE_INLINE bool isHeatingHotend(uint8_t extruder){
return target_raw[extruder] > current_raw[extruder];
};
FORCE_INLINE bool isHeatingBed() {
return target_raw_bed > current_raw_bed;
};
FORCE_INLINE bool isCoolingHotend(uint8_t extruder) {
return target_raw[extruder] < current_raw[extruder];
};
FORCE_INLINE bool isCoolingBed() {
return target_raw_bed < current_raw_bed;
};
#define degHotend0() degHotend(0)
#define degTargetHotend0() degTargetHotend(0)
#define setTargetHotend0(_celsius) setTargetHotend((_celsius), 0)
#define isHeatingHotend0() isHeatingHotend(0)
#define isCoolingHotend0() isCoolingHotend(0)
#if EXTRUDERS > 1
#define degHotend1() degHotend(1)
#define degTargetHotend1() degTargetHotend(1)
#define setTargetHotend1(_celsius) setTargetHotend((_celsius), 1)
#define isHeatingHotend1() isHeatingHotend(1)
#define isCoolingHotend1() isCoolingHotend(1)
#endif
#if EXTRUDERS > 2
#define degHotend2() degHotend(2)
#define degTargetHotend2() degTargetHotend(2)
#define setTargetHotend2(_celsius) setTargetHotend((_celsius), 2)
#define isHeatingHotend2() isHeatingHotend(2)
#define isCoolingHotend2() isCoolingHotend(2)
#endif
#if EXTRUDERS > 3
#error Invalid number of extruders
#endif
FORCE_INLINE void autotempShutdown(){
#ifdef AUTOTEMP
if(autotemp_enabled)
{
autotemp_enabled=false;
if(degTargetHotend(ACTIVE_EXTRUDER)>autotemp_min)
setTargetHotend(0,ACTIVE_EXTRUDER);
}
#endif
}
int getHeaterPower(int heater);
void disable_heater();
void setWatch();
void updatePID();
#endif

View file

@ -1,1839 +1,1843 @@
#include "ultralcd.h"
#ifdef ULTRA_LCD
//===========================================================================
//=============================imported variables============================
//===========================================================================
extern volatile int feedmultiply;
extern volatile bool feedmultiplychanged;
extern long position[4];
extern CardReader card;
//===========================================================================
//=============================public variables============================
//===========================================================================
volatile char buttons=0; //the last checked buttons in a bit array.
int encoderpos=0;
short lastenc=0;
//===========================================================================
//=============================private variables============================
//===========================================================================
static char messagetext[LCD_WIDTH]="";
//return for string conversion routines
static char conv[8];
#include <LiquidCrystal.h>
LiquidCrystal lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7
static unsigned long previous_millis_lcd=0;
static long previous_millis_buttons=0;
#ifdef NEWPANEL
static long blocking=0;
#else
static long blocking[8]={0,0,0,0,0,0,0,0};
#endif
static MainMenu menu;
#include <avr/pgmspace.h>
void lcdProgMemprint(const char *str)
{
char ch=pgm_read_byte(str);
while(ch)
{
lcd.print(ch);
ch=pgm_read_byte(++str);
}
}
#define lcdprintPGM(x) lcdProgMemprint(MYPGM(x))
//===========================================================================
//=============================functions ============================
//===========================================================================
FORCE_INLINE int intround(const float &x){return int(0.5+x);}
void lcd_status(const char* message)
{
strncpy(messagetext,message,LCD_WIDTH);
messagetext[strlen(message)]=0;
}
void lcd_statuspgm(const char* message)
{
char ch=pgm_read_byte(message);
char *target=messagetext;
uint8_t cnt=0;
while(ch &&cnt<LCD_WIDTH)
{
*target=ch;
target++;
cnt++;
ch=pgm_read_byte(++message);
}
*target=0;
}
FORCE_INLINE void clear()
{
lcd.clear();
}
void lcd_init()
{
//beep();
byte Degree[8] =
{
B01100,
B10010,
B10010,
B01100,
B00000,
B00000,
B00000,
B00000
};
byte Thermometer[8] =
{
B00100,
B01010,
B01010,
B01010,
B01010,
B10001,
B10001,
B01110
};
byte uplevel[8]={0x04, 0x0e, 0x1f, 0x04, 0x1c, 0x00, 0x00, 0x00};//thanks joris
byte refresh[8]={0x00, 0x06, 0x19, 0x18, 0x03, 0x13, 0x0c, 0x00}; //thanks joris
byte folder [8]={0x00, 0x1c, 0x1f, 0x11, 0x11, 0x1f, 0x00, 0x00}; //thanks joris
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
lcd.createChar(1,Degree);
lcd.createChar(2,Thermometer);
lcd.createChar(3,uplevel);
lcd.createChar(4,refresh);
lcd.createChar(5,folder);
LCD_MESSAGEPGM("UltiMarlin ready.");
}
void beep()
{
//return;
#ifdef ULTIPANEL
pinMode(BEEPER,OUTPUT);
for(int8_t i=0;i<20;i++){
WRITE(BEEPER,HIGH);
delay(5);
WRITE(BEEPER,LOW);
delay(5);
}
#endif
}
void beepshort()
{
//return;
#ifdef ULTIPANEL
pinMode(BEEPER,OUTPUT);
for(int8_t i=0;i<10;i++){
WRITE(BEEPER,HIGH);
delay(3);
WRITE(BEEPER,LOW);
delay(3);
}
#endif
}
void lcd_status()
{
#ifdef ULTIPANEL
static uint8_t oldbuttons=0;
//static long previous_millis_buttons=0;
//static long previous_lcdinit=0;
// buttons_check(); // Done in temperature interrupt
//previous_millis_buttons=millis();
if((buttons==oldbuttons) && ((millis() - previous_millis_lcd) < LCD_UPDATE_INTERVAL) )
return;
oldbuttons=buttons;
#else
if(((millis() - previous_millis_lcd) < LCD_UPDATE_INTERVAL) )
return;
#endif
previous_millis_lcd=millis();
menu.update();
}
#ifdef ULTIPANEL
void buttons_init()
{
#ifdef NEWPANEL
pinMode(BTN_EN1,INPUT);
pinMode(BTN_EN2,INPUT);
pinMode(BTN_ENC,INPUT);
pinMode(SDCARDDETECT,INPUT);
WRITE(BTN_EN1,HIGH);
WRITE(BTN_EN2,HIGH);
WRITE(BTN_ENC,HIGH);
WRITE(SDCARDDETECT,HIGH);
#else
pinMode(SHIFT_CLK,OUTPUT);
pinMode(SHIFT_LD,OUTPUT);
pinMode(SHIFT_EN,OUTPUT);
pinMode(SHIFT_OUT,INPUT);
WRITE(SHIFT_OUT,HIGH);
WRITE(SHIFT_LD,HIGH);
WRITE(SHIFT_EN,LOW);
#endif
}
void buttons_check()
{
#ifdef NEWPANEL
uint8_t newbutton=0;
if(READ(BTN_EN1)==0) newbutton|=EN_A;
if(READ(BTN_EN2)==0) newbutton|=EN_B;
if((blocking<millis()) &&(READ(BTN_ENC)==0))
newbutton|=EN_C;
buttons=newbutton;
#else //read it from the shift register
uint8_t newbutton=0;
WRITE(SHIFT_LD,LOW);
WRITE(SHIFT_LD,HIGH);
unsigned char tmp_buttons=0;
for(int8_t i=0;i<8;i++)
{
newbutton = newbutton>>1;
if(READ(SHIFT_OUT))
newbutton|=(1<<7);
WRITE(SHIFT_CLK,HIGH);
WRITE(SHIFT_CLK,LOW);
}
buttons=~newbutton; //invert it, because a pressed switch produces a logical 0
#endif
//manage encoder rotation
char enc=0;
if(buttons&EN_A)
enc|=(1<<0);
if(buttons&EN_B)
enc|=(1<<1);
if(enc!=lastenc)
{
switch(enc)
{
case encrot0:
if(lastenc==encrot3)
encoderpos++;
else if(lastenc==encrot1)
encoderpos--;
break;
case encrot1:
if(lastenc==encrot0)
encoderpos++;
else if(lastenc==encrot2)
encoderpos--;
break;
case encrot2:
if(lastenc==encrot1)
encoderpos++;
else if(lastenc==encrot3)
encoderpos--;
break;
case encrot3:
if(lastenc==encrot2)
encoderpos++;
else if(lastenc==encrot0)
encoderpos--;
break;
default:
;
}
}
lastenc=enc;
}
#endif
MainMenu::MainMenu()
{
status=Main_Status;
displayStartingRow=0;
activeline=0;
force_lcd_update=true;
#ifdef ULTIPANEL
buttons_init();
#endif
lcd_init();
linechanging=false;
tune=false;
}
void MainMenu::showStatus()
{
#if LCD_HEIGHT==4
static int olddegHotEnd0=-1;
static int oldtargetHotEnd0=-1;
//force_lcd_update=true;
if(force_lcd_update||feedmultiplychanged) //initial display of content
{
feedmultiplychanged=false;
encoderpos=feedmultiply;
clear();
lcd.setCursor(0,0);lcdprintPGM("\002123/567\001 ");
#if defined BED_USES_THERMISTOR || defined BED_USES_AD595
lcd.setCursor(10,0);lcdprintPGM("B123/567\001 ");
#endif
}
int tHotEnd0=intround(degHotend0());
if((abs(tHotEnd0-olddegHotEnd0)>1)||force_lcd_update) //>1 because otherwise the lcd is refreshed to often.
{
lcd.setCursor(1,0);
lcd.print(ftostr3(tHotEnd0));
olddegHotEnd0=tHotEnd0;
}
int ttHotEnd0=intround(degTargetHotend0());
if((ttHotEnd0!=oldtargetHotEnd0)||force_lcd_update)
{
lcd.setCursor(5,0);
lcd.print(ftostr3(ttHotEnd0));
oldtargetHotEnd0=ttHotEnd0;
}
#if defined BED_USES_THERMISTOR || defined BED_USES_AD595
static int oldtBed=-1;
static int oldtargetBed=-1;
int tBed=intround(degBed());
if((tBed!=oldtBed)||force_lcd_update)
{
lcd.setCursor(1,0);
lcd.print(ftostr3(tBed));
oldtBed=tBed;
}
int targetBed=intround(degTargetBed());
if((targetBed!=oldtargetBed)||force_lcd_update)
{
lcd.setCursor(5,0);
lcd.print(ftostr3(targetBed));
oldtargetBed=targetBed;
}
#endif
//starttime=2;
static uint16_t oldtime=0;
if(starttime!=0)
{
lcd.setCursor(0,1);
uint16_t time=millis()/60000-starttime/60000;
if(starttime!=oldtime)
{
lcd.print(itostr2(time/60));lcdprintPGM("h ");lcd.print(itostr2(time%60));lcdprintPGM("m");
oldtime=time;
}
}
static int oldzpos=0;
int currentz=current_position[2]*10;
if((currentz!=oldzpos)||force_lcd_update)
{
lcd.setCursor(10,1);
lcdprintPGM("Z:");lcd.print(itostr31(currentz));
oldzpos=currentz;
}
static int oldfeedmultiply=0;
int curfeedmultiply=feedmultiply;
if(encoderpos!=curfeedmultiply||force_lcd_update)
{
curfeedmultiply=encoderpos;
if(curfeedmultiply<10)
curfeedmultiply=10;
if(curfeedmultiply>999)
curfeedmultiply=999;
feedmultiply=curfeedmultiply;
encoderpos=curfeedmultiply;
}
if((curfeedmultiply!=oldfeedmultiply)||force_lcd_update)
{
oldfeedmultiply=curfeedmultiply;
lcd.setCursor(0,2);
lcd.print(itostr3(curfeedmultiply));lcdprintPGM("% ");
}
if(messagetext[0]!='\0')
{
lcd.setCursor(0,LCD_HEIGHT-1);
lcd.print(messagetext);
uint8_t n=strlen(messagetext);
for(int8_t i=0;i<LCD_WIDTH-n;i++)
lcd.print(" ");
messagetext[0]='\0';
}
static uint8_t oldpercent=101;
uint8_t percent=card.percentDone();
if(oldpercent!=percent ||force_lcd_update)
{
lcd.setCursor(7,2);
lcd.print(itostr3((int)percent));
lcdprintPGM("%SD");
}
#else //smaller LCDS----------------------------------
static int olddegHotEnd0=-1;
static int oldtargetHotEnd0=-1;
if(force_lcd_update) //initial display of content
{
encoderpos=feedmultiply;
lcd.setCursor(0,0);lcdprintPGM("\002123/567\001 ");
#if defined BED_USES_THERMISTOR || defined BED_USES_AD595
lcd.setCursor(10,0);lcdprintPGM("B123/567\001 ");
#endif
}
int tHotEnd0=intround(degHotend0());
int ttHotEnd0=intround(degTargetHotend0());
if((abs(tHotEnd0-olddegHotEnd0)>1)||force_lcd_update)
{
lcd.setCursor(1,0);
lcd.print(ftostr3(tHotEnd0));
olddegHotEnd0=tHotEnd0;
}
if((ttHotEnd0!=oldtargetHotEnd0)||force_lcd_update)
{
lcd.setCursor(5,0);
lcd.print(ftostr3(ttHotEnd0));
oldtargetHotEnd0=ttHotEnd0;
}
if(messagetext[0]!='\0')
{
lcd.setCursor(0,LCD_HEIGHT-1);
lcd.print(messagetext);
uint8_t n=strlen(messagetext);
for(int8_t i=0;i<LCD_WIDTH-n;i++)
lcd.print(" ");
messagetext[0]='\0';
}
#endif
force_lcd_update=false;
}
enum {ItemP_exit, ItemP_home, ItemP_origin, ItemP_preheat, ItemP_extrude, ItemP_disstep};
//any action must not contain a ',' character anywhere, or this breaks:
#define MENUITEM(repaint_action, click_action) \
{\
if(force_lcd_update) { lcd.setCursor(0,line); repaint_action; } \
if((activeline==line) && CLICKED) {click_action} \
}
void MainMenu::showPrepare()
{
uint8_t line=0;
clearIfNecessary();
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
{
//Serial.println((int)(line-lineoffset));
switch(i)
{
case ItemP_exit:
MENUITEM( lcdprintPGM(" Main \003") , BLOCK;status=Main_Menu;beepshort(); ) ;
break;
case ItemP_home:
MENUITEM( lcdprintPGM(" Auto Home") , BLOCK;enquecommand("G28 X-105 Y-105 Z0");beepshort(); ) ;
break;
case ItemP_origin:
MENUITEM( lcdprintPGM(" Set Origin") , BLOCK;enquecommand("G92 X0 Y0 Z0");beepshort(); ) ;
break;
case ItemP_preheat:
MENUITEM( lcdprintPGM(" Preheat") , BLOCK;setTargetHotend0(170);beepshort(); ) ;
break;
case ItemP_extrude:
MENUITEM( lcdprintPGM(" Extrude") , BLOCK;enquecommand("G92 E0");enquecommand("G1 F700 E50");beepshort(); ) ;
break;
case ItemP_disstep:
MENUITEM( lcdprintPGM(" Disable Steppers") , BLOCK;enquecommand("M84");beepshort(); ) ;
break;
default:
break;
}
line++;
}
updateActiveLines(ItemP_disstep,encoderpos);
}
enum {ItemT_exit,ItemT_speed,ItemT_flow,ItemT_nozzle,ItemT_fan};
void MainMenu::showTune()
{
uint8_t line=0;
clearIfNecessary();
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
{
//Serial.println((int)(line-lineoffset));
switch(i)
{
case ItemT_exit:
MENUITEM( lcdprintPGM(" Main \003") , BLOCK;status=Main_Menu;beepshort(); ) ;
break;
case ItemT_speed:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Speed:");
lcd.setCursor(13,line);lcd.print(ftostr3(feedmultiply));
}
if((activeline!=line) )
break;
if(CLICKED) //nalogWrite(FAN_PIN, fanpwm);
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=feedmultiply;
}
else
{
encoderpos=activeline*lcdslow;
beepshort();
}
BLOCK;
}
if(linechanging)
{
if(encoderpos<1) encoderpos=1;
if(encoderpos>400) encoderpos=400;
feedmultiply = encoderpos;
feedmultiplychanged=true;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
case ItemT_nozzle:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" \002Nozzle:");
lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend0())));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=intround(degTargetHotend0());
}
else
{
setTargetHotend0(encoderpos);
encoderpos=activeline*lcdslow;
beepshort();
}
BLOCK;
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>260) encoderpos=260;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
case ItemT_fan:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Fan speed:");
lcd.setCursor(13,line);lcd.print(ftostr3(fanpwm));
}
if((activeline!=line) )
break;
if(CLICKED) //nalogWrite(FAN_PIN, fanpwm);
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=fanpwm;
}
else
{
encoderpos=activeline*lcdslow;
beepshort();
}
BLOCK;
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>255) encoderpos=255;
fanpwm=encoderpos;
analogWrite(FAN_PIN, fanpwm);
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
case ItemT_flow://axis_steps_per_unit[i] = code_value();
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Flow:");
lcd.setCursor(13,line);lcd.print(itostr4(axis_steps_per_unit[3]));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)axis_steps_per_unit[3];
}
else
{
float factor=float(encoderpos)/float(axis_steps_per_unit[3]);
position[E_AXIS]=lround(position[E_AXIS]*factor);
//current_position[3]*=factor;
axis_steps_per_unit[E_AXIS]= encoderpos;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<5) encoderpos=5;
if(encoderpos>9999) encoderpos=9999;
lcd.setCursor(13,line);lcd.print(itostr4(encoderpos));
}
}break;
default:
break;
}
line++;
}
updateActiveLines(ItemT_fan,encoderpos);
}
//does not work
// #define MENUCHANGEITEM(repaint_action, enter_action, accept_action, change_action) \
// {\
// if(force_lcd_update) { lcd.setCursor(0,line); repaint_action; } \
// if(activeline==line) \
// { \
// if(CLICKED) \
// { \
// linechanging=!linechanging; \
// if(linechanging) {enter_action;} \
// else {accept_action;} \
// } \
// else \
// if(linechanging) {change_action};}\
// }
//
enum {
ItemCT_exit,ItemCT_nozzle,
#ifdef AUTOTEMP
ItemCT_autotempactive,
ItemCT_autotempmin,ItemCT_autotempmax,ItemCT_autotempfact,
#endif
ItemCT_fan,
ItemCT_PID_P,ItemCT_PID_I,ItemCT_PID_D,ItemCT_PID_C
};
void MainMenu::showControlTemp()
{
uint8_t line=0;
clearIfNecessary();
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
{
switch(i)
{
case ItemCT_exit:
MENUITEM( lcdprintPGM(" Control \003") , BLOCK;status=Main_Control;beepshort(); ) ;
break;
case ItemCT_nozzle:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" \002Nozzle:");
lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend0())));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=intround(degTargetHotend0());
}
else
{
setTargetHotend0(encoderpos);
encoderpos=activeline*lcdslow;
beepshort();
}
BLOCK;
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>260) encoderpos=260;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
#ifdef AUTOTEMP
case ItemCT_autotempmin:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" \002 Min:");
lcd.setCursor(13,line);lcd.print(ftostr3(autotemp_min));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=intround(autotemp_min);
}
else
{
autotemp_min=encoderpos;
encoderpos=activeline*lcdslow;
beepshort();
}
BLOCK;
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>260) encoderpos=260;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
case ItemCT_autotempmax:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" \002 Max:");
lcd.setCursor(13,line);lcd.print(ftostr3(autotemp_max));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=intround(autotemp_max);
}
else
{
autotemp_max=encoderpos;
encoderpos=activeline*lcdslow;
beepshort();
}
BLOCK;
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>260) encoderpos=260;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
case ItemCT_autotempfact:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" \002 Fact:");
lcd.setCursor(13,line);lcd.print(ftostr32(autotemp_factor));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=intround(autotemp_factor*100);
}
else
{
autotemp_max=encoderpos;
encoderpos=activeline*lcdslow;
beepshort();
}
BLOCK;
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>99) encoderpos=99;
lcd.setCursor(13,line);lcd.print(ftostr32(encoderpos/100.));
}
}break;
case ItemCT_autotempactive:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Autotemp:");
lcd.setCursor(13,line);
if(autotemp_enabled)
lcdprintPGM("On");
else
lcdprintPGM("Off");
}
if((activeline!=line) )
break;
if(CLICKED)
{
autotemp_enabled=!autotemp_enabled;
lcd.setCursor(13,line);
if(autotemp_enabled)
lcdprintPGM("On ");
else
lcdprintPGM("Off");
BLOCK;
}
}break;
#endif //autotemp
case ItemCT_fan:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Fan speed:");
lcd.setCursor(13,line);lcd.print(ftostr3(fanpwm));
}
if((activeline!=line) )
break;
if(CLICKED) //nalogWrite(FAN_PIN, fanpwm);
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=fanpwm;
}
else
{
encoderpos=activeline*lcdslow;
beepshort();
}
BLOCK;
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>255) encoderpos=255;
fanpwm=encoderpos;
analogWrite(FAN_PIN, fanpwm);
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
case ItemCT_PID_P:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" PID-P: ");
lcd.setCursor(13,line);lcd.print(itostr4(Kp));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)Kp;
}
else
{
Kp= encoderpos;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<1) encoderpos=1;
if(encoderpos>9990) encoderpos=9990;
lcd.setCursor(13,line);lcd.print(itostr4(encoderpos));
}
}break;
case ItemCT_PID_I:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" PID-I: ");
lcd.setCursor(13,line);lcd.print(ftostr51(Ki/PID_dT));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)(Ki*10/PID_dT);
}
else
{
Ki= encoderpos/10.*PID_dT;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>9990) encoderpos=9990;
lcd.setCursor(13,line);lcd.print(ftostr51(encoderpos/10.));
}
}break;
case ItemCT_PID_D:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" PID-D: ");
lcd.setCursor(13,line);lcd.print(itostr4(Kd*PID_dT));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)(Kd/5./PID_dT);
}
else
{
Kd= encoderpos;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>9990) encoderpos=9990;
lcd.setCursor(13,line);lcd.print(itostr4(encoderpos));
}
}break;
case ItemCT_PID_C:
#ifdef PID_ADD_EXTRUSION_RATE
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" PID-C: ");
lcd.setCursor(13,line);lcd.print(itostr3(Kc));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)Kc;
}
else
{
Kc= encoderpos;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>990) encoderpos=990;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}
#endif
break;
default:
break;
}
line++;
}
#ifdef PID_ADD_EXTRUSION_RATE
updateActiveLines(ItemCT_PID_C,encoderpos);
#else
updateActiveLines(ItemCT_PID_D,encoderpos);
#endif
}
enum {
ItemCM_exit,
ItemCM_acc, ItemCM_xyjerk,
ItemCM_vmaxx, ItemCM_vmaxy, ItemCM_vmaxz, ItemCM_vmaxe,
ItemCM_vtravmin,ItemCM_vmin,
ItemCM_amaxx, ItemCM_amaxy, ItemCM_amaxz, ItemCM_amaxe,
ItemCM_aret,ItemCM_esteps
};
void MainMenu::showControlMotion()
{
uint8_t line=0;
clearIfNecessary();
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
{
switch(i)
{
case ItemCM_exit:
MENUITEM( lcdprintPGM(" Control \003") , BLOCK;status=Main_Control;beepshort(); ) ;
break;
case ItemCM_acc:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Acc:");
lcd.setCursor(13,line);lcd.print(itostr3(acceleration/100));lcdprintPGM("00");
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)acceleration/100;
}
else
{
acceleration= encoderpos*100;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<5) encoderpos=5;
if(encoderpos>990) encoderpos=990;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcdprintPGM("00");
}
}break;
case ItemCM_xyjerk: //max_xy_jerk
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Vxy-jerk: ");
lcd.setCursor(13,line);lcd.print(itostr3(max_xy_jerk));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)max_xy_jerk;
}
else
{
max_xy_jerk= encoderpos;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<1) encoderpos=1;
if(encoderpos>990) encoderpos=990;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
case ItemCM_vmaxx:
case ItemCM_vmaxy:
case ItemCM_vmaxz:
case ItemCM_vmaxe:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Vmax ");
if(i==ItemCM_vmaxx)lcdprintPGM("x:");
if(i==ItemCM_vmaxy)lcdprintPGM("y:");
if(i==ItemCM_vmaxz)lcdprintPGM("z:");
if(i==ItemCM_vmaxe)lcdprintPGM("e:");
lcd.setCursor(13,line);lcd.print(itostr3(max_feedrate[i-ItemCM_vmaxx]));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)max_feedrate[i-ItemCM_vmaxx];
}
else
{
max_feedrate[i-ItemCM_vmaxx]= encoderpos;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<1) encoderpos=1;
if(encoderpos>990) encoderpos=990;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
case ItemCM_vmin:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Vmin:");
lcd.setCursor(13,line);lcd.print(itostr3(minimumfeedrate));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)(minimumfeedrate);
}
else
{
minimumfeedrate= encoderpos;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>990) encoderpos=990;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
case ItemCM_vtravmin:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" VTrav min:");
lcd.setCursor(13,line);lcd.print(itostr3(mintravelfeedrate));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)mintravelfeedrate;
}
else
{
mintravelfeedrate= encoderpos;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>990) encoderpos=990;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
case ItemCM_amaxx:
case ItemCM_amaxy:
case ItemCM_amaxz:
case ItemCM_amaxe:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Amax ");
if(i==ItemCM_amaxx)lcdprintPGM("x:");
if(i==ItemCM_amaxy)lcdprintPGM("y:");
if(i==ItemCM_amaxz)lcdprintPGM("z:");
if(i==ItemCM_amaxe)lcdprintPGM("e:");
lcd.setCursor(13,line);lcd.print(itostr3(max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100));lcdprintPGM("00");
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100;
}
else
{
max_acceleration_units_per_sq_second[i-ItemCM_amaxx]= encoderpos*100;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<1) encoderpos=1;
if(encoderpos>990) encoderpos=990;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcdprintPGM("00");
}
}break;
case ItemCM_aret://float retract_acceleration = 7000;
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" A-retract:");
lcd.setCursor(13,line);lcd.print(ftostr3(retract_acceleration/100));lcdprintPGM("00");
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)retract_acceleration/100;
}
else
{
retract_acceleration= encoderpos*100;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<10) encoderpos=10;
if(encoderpos>990) encoderpos=990;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcdprintPGM("00");
}
}break;
case ItemCM_esteps://axis_steps_per_unit[i] = code_value();
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Esteps/mm:");
lcd.setCursor(13,line);lcd.print(itostr4(axis_steps_per_unit[3]));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)axis_steps_per_unit[3];
}
else
{
float factor=float(encoderpos)/float(axis_steps_per_unit[3]);
position[E_AXIS]=lround(position[E_AXIS]*factor);
//current_position[3]*=factor;
axis_steps_per_unit[E_AXIS]= encoderpos;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<5) encoderpos=5;
if(encoderpos>9999) encoderpos=9999;
lcd.setCursor(13,line);lcd.print(itostr4(encoderpos));
}
}break;
default:
break;
}
line++;
}
updateActiveLines(ItemCM_esteps,encoderpos);
}
enum {
ItemC_exit,ItemC_temp,ItemC_move,
ItemC_store, ItemC_load,ItemC_failsafe
};
void MainMenu::showControl()
{
uint8_t line=0;
clearIfNecessary();
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
{
switch(i)
{
case ItemC_exit:
MENUITEM( lcdprintPGM(" Main \003") , BLOCK;status=Main_Menu;beepshort(); ) ;
break;
case ItemC_temp:
MENUITEM( lcdprintPGM(" Temperature \x7E") , BLOCK;status=Sub_TempControl;beepshort(); ) ;
break;
case ItemC_move:
MENUITEM( lcdprintPGM(" Motion \x7E") , BLOCK;status=Sub_MotionControl;beepshort(); ) ;
break;
case ItemC_store:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Store EPROM");
}
if((activeline==line) && CLICKED)
{
//enquecommand("M84");
beepshort();
BLOCK;
EEPROM_StoreSettings();
}
}break;
case ItemC_load:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Load EPROM");
}
if((activeline==line) && CLICKED)
{
//enquecommand("M84");
beepshort();
BLOCK;
EEPROM_RetrieveSettings();
}
}break;
case ItemC_failsafe:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Restore Failsafe");
}
if((activeline==line) && CLICKED)
{
//enquecommand("M84");
beepshort();
BLOCK;
EEPROM_RetrieveSettings(true);
}
}break;
default:
break;
}
line++;
}
updateActiveLines(ItemC_failsafe,encoderpos);
}
void MainMenu::showSD()
{
#ifdef SDSUPPORT
uint8_t line=0;
clearIfNecessary();
static uint8_t nrfiles=0;
if(force_lcd_update)
{
if(card.cardOK)
{
nrfiles=card.getnrfilenames();
}
else
{
nrfiles=0;
lineoffset=0;
}
}
bool enforceupdate=false;
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
{
switch(i)
{
case 0:
MENUITEM( lcdprintPGM(" Main \003") , BLOCK;status=Main_Menu;beepshort(); ) ;
break;
// case 1:
// {
// if(force_lcd_update)
// {
// lcd.setCursor(0,line);
// #ifdef CARDINSERTED
// if(CARDINSERTED)
// #else
// if(true)
// #endif
// {
// lcdprintPGM(" \004Refresh");
// }
// else
// {
// lcdprintPGM(" \004Insert Card");
// }
//
// }
// if((activeline==line) && CLICKED)
// {
// BLOCK;
// beepshort();
// card.initsd();
// force_lcd_update=true;
// nrfiles=card.getnrfilenames();
// }
// }break;
case 1:
MENUITEM( lcd.print(" ");card.getWorkDirName();if(card.filename[0]=='/') lcdprintPGM("\004Refresh");else {lcd.print("\005");lcd.print(card.filename);lcd.print("/..");} , BLOCK;card.updir();enforceupdate=true;lineoffset=0;beepshort(); ) ;
break;
default:
{
#define FIRSTITEM 2
if(i-FIRSTITEM<nrfiles)
{
if(force_lcd_update)
{
card.getfilename(i-FIRSTITEM);
//Serial.print("Filenr:");Serial.println(i-2);
lcd.setCursor(0,line);lcdprintPGM(" ");
if(card.filenameIsDir) lcd.print("\005");
lcd.print(card.filename);
}
if((activeline==line) && CLICKED)
{
BLOCK
card.getfilename(i-FIRSTITEM);
if(card.filenameIsDir)
{
for(int8_t i=0;i<strlen(card.filename);i++)
card.filename[i]=tolower(card.filename[i]);
card.chdir(card.filename);
lineoffset=0;
enforceupdate=true;
}
else
{
char cmd[30];
for(int8_t i=0;i<strlen(card.filename);i++)
card.filename[i]=tolower(card.filename[i]);
sprintf(cmd,"M23 %s",card.filename);
//sprintf(cmd,"M115");
enquecommand(cmd);
enquecommand("M24");
beep();
status=Main_Status;
lcd_status(card.filename);
}
}
}
}
break;
}
line++;
}
updateActiveLines(FIRSTITEM+nrfiles-1,encoderpos);
if(enforceupdate)
{
force_lcd_update=true;
enforceupdate=false;
}
#endif
}
enum {ItemM_watch, ItemM_prepare, ItemM_control, ItemM_file };
void MainMenu::showMainMenu()
{
#ifndef ULTIPANEL
force_lcd_update=false;
#endif
if(tune)
{
if(!(movesplanned() ||card.sdprinting))
{
force_lcd_update=true;
tune=false;
}
}
else
{
if(movesplanned() ||card.sdprinting)
{
force_lcd_update=true;
tune=true;
}
}
clearIfNecessary();
for(int8_t line=0;line<LCD_HEIGHT;line++)
{
switch(line)
{
case ItemM_watch:
MENUITEM( lcdprintPGM(" Watch \003") , BLOCK;status=Main_Status;beepshort(); ) ;
break;
case ItemM_prepare:
MENUITEM( if(!tune) lcdprintPGM(" Prepare \x7E");else lcdprintPGM(" Tune \x7E"); , BLOCK;status=Main_Prepare;beepshort(); ) ;
break;
case ItemM_control:
MENUITEM( lcdprintPGM(" Control \x7E") , BLOCK;status=Main_Control;beepshort(); ) ;
break;
#ifdef SDSUPPORT
case ItemM_file:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);
#ifdef CARDINSERTED
if(CARDINSERTED)
#else
if(true)
#endif
{
if(card.sdprinting)
lcdprintPGM(" Stop Print \x7E");
else
lcdprintPGM(" Card Menu \x7E");
}
else
{
lcdprintPGM(" No Card");
}
}
#ifdef CARDINSERTED
if(CARDINSERTED)
#endif
if((activeline==line)&&CLICKED)
{
card.printingHasFinished();
BLOCK;
status=Main_SD;
beepshort();
}
}break;
#else
case ItemM_file:
break;
#endif
default:
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM("Something is wrong in the MenuStructure.");
break;
}
}
updateActiveLines(3,encoderpos);
}
void MainMenu::update()
{
static MainStatus oldstatus=Main_Menu; //init automatically causes foce_lcd_update=true
static long timeoutToStatus=0;
static bool oldcardstatus=false;
#ifdef CARDINSERTED
if((CARDINSERTED != oldcardstatus))
{
force_lcd_update=true;
oldcardstatus=CARDINSERTED;
//Serial.println("echo: SD CHANGE");
if(CARDINSERTED)
{
card.initsd();
LCD_MESSAGEPGM("Card inserted");
}
else
{
card.release();
LCD_MESSAGEPGM("Card removed");
}
}
#endif
if(status!=oldstatus)
{
force_lcd_update=true;
encoderpos=0;
lineoffset=0;
oldstatus=status;
}
if( (encoderpos!=lastencoderpos) || CLICKED)
timeoutToStatus=millis()+STATUSTIMEOUT;
switch(status)
{
case Main_Status:
{
showStatus();
if(CLICKED)
{
linechanging=false;
BLOCK
status=Main_Menu;
timeoutToStatus=millis()+STATUSTIMEOUT;
}
}break;
case Main_Menu:
{
showMainMenu();
linechanging=false;
}break;
case Main_Prepare:
{
if(tune)
{
showTune();
}
else
{
showPrepare();
}
}break;
case Main_Control:
{
showControl();
}break;
case Sub_MotionControl:
{
showControlMotion();
}break;
case Sub_TempControl:
{
showControlTemp();
}break;
case Main_SD:
{
showSD();
}break;
}
if(timeoutToStatus<millis())
status=Main_Status;
//force_lcd_update=false;
lastencoderpos=encoderpos;
}
// convert float to string with +123.4 format
char *ftostr3(const float &x)
{
//sprintf(conv,"%5.1f",x);
int xx=x;
conv[0]=(xx/100)%10+'0';
conv[1]=(xx/10)%10+'0';
conv[2]=(xx)%10+'0';
conv[3]=0;
return conv;
}
char *itostr2(const uint8_t &x)
{
//sprintf(conv,"%5.1f",x);
int xx=x;
conv[0]=(xx/10)%10+'0';
conv[1]=(xx)%10+'0';
conv[2]=0;
return conv;
}
// convert float to string with +123.4 format
char *ftostr31(const float &x)
{
int xx=x*10;
conv[0]=(xx>=0)?'+':'-';
xx=abs(xx);
conv[1]=(xx/1000)%10+'0';
conv[2]=(xx/100)%10+'0';
conv[3]=(xx/10)%10+'0';
conv[4]='.';
conv[5]=(xx)%10+'0';
conv[6]=0;
return conv;
}
char *ftostr32(const float &x)
{
int xx=x*100;
conv[0]=(xx>=0)?'+':'-';
xx=abs(xx);
conv[1]=(xx/100)%10+'0';
conv[2]='.';
conv[3]=(xx/10)%10+'0';
conv[4]=(xx)%10+'0';
conv[6]=0;
return conv;
}
char *itostr31(const int &xx)
{
conv[0]=(xx>=0)?'+':'-';
conv[1]=(xx/1000)%10+'0';
conv[2]=(xx/100)%10+'0';
conv[3]=(xx/10)%10+'0';
conv[4]='.';
conv[5]=(xx)%10+'0';
conv[6]=0;
return conv;
}
char *itostr3(const int &xx)
{
conv[0]=(xx/100)%10+'0';
conv[1]=(xx/10)%10+'0';
conv[2]=(xx)%10+'0';
conv[3]=0;
return conv;
}
char *itostr4(const int &xx)
{
conv[0]=(xx/1000)%10+'0';
conv[1]=(xx/100)%10+'0';
conv[2]=(xx/10)%10+'0';
conv[3]=(xx)%10+'0';
conv[4]=0;
return conv;
}
// convert float to string with +1234.5 format
char *ftostr51(const float &x)
{
int xx=x*10;
conv[0]=(xx>=0)?'+':'-';
xx=abs(xx);
conv[1]=(xx/10000)%10+'0';
conv[2]=(xx/1000)%10+'0';
conv[3]=(xx/100)%10+'0';
conv[4]=(xx/10)%10+'0';
conv[5]='.';
conv[6]=(xx)%10+'0';
conv[7]=0;
return conv;
}
#endif //ULTRA_LCD
#include "ultralcd.h"
#ifdef ULTRA_LCD
//===========================================================================
//=============================imported variables============================
//===========================================================================
extern volatile int feedmultiply;
extern volatile bool feedmultiplychanged;
extern long position[4];
extern CardReader card;
//===========================================================================
//=============================public variables============================
//===========================================================================
volatile char buttons=0; //the last checked buttons in a bit array.
int encoderpos=0;
short lastenc=0;
//===========================================================================
//=============================private variables============================
//===========================================================================
static char messagetext[LCD_WIDTH]="";
//return for string conversion routines
static char conv[8];
#include <LiquidCrystal.h>
LiquidCrystal lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7
static unsigned long previous_millis_lcd=0;
static long previous_millis_buttons=0;
#ifdef NEWPANEL
static long blocking=0;
#else
static long blocking[8]={0,0,0,0,0,0,0,0};
#endif
static MainMenu menu;
#include <avr/pgmspace.h>
void lcdProgMemprint(const char *str)
{
char ch=pgm_read_byte(str);
while(ch)
{
lcd.print(ch);
ch=pgm_read_byte(++str);
}
}
#define lcdprintPGM(x) lcdProgMemprint(MYPGM(x))
//===========================================================================
//=============================functions ============================
//===========================================================================
FORCE_INLINE int intround(const float &x){return int(0.5+x);}
void lcd_status(const char* message)
{
strncpy(messagetext,message,LCD_WIDTH);
messagetext[strlen(message)]=0;
}
void lcd_statuspgm(const char* message)
{
char ch=pgm_read_byte(message);
char *target=messagetext;
uint8_t cnt=0;
while(ch &&cnt<LCD_WIDTH)
{
*target=ch;
target++;
cnt++;
ch=pgm_read_byte(++message);
}
*target=0;
}
FORCE_INLINE void clear()
{
lcd.clear();
}
void lcd_init()
{
//beep();
byte Degree[8] =
{
B01100,
B10010,
B10010,
B01100,
B00000,
B00000,
B00000,
B00000
};
byte Thermometer[8] =
{
B00100,
B01010,
B01010,
B01010,
B01010,
B10001,
B10001,
B01110
};
byte uplevel[8]={0x04, 0x0e, 0x1f, 0x04, 0x1c, 0x00, 0x00, 0x00};//thanks joris
byte refresh[8]={0x00, 0x06, 0x19, 0x18, 0x03, 0x13, 0x0c, 0x00}; //thanks joris
byte folder [8]={0x00, 0x1c, 0x1f, 0x11, 0x11, 0x1f, 0x00, 0x00}; //thanks joris
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
lcd.createChar(1,Degree);
lcd.createChar(2,Thermometer);
lcd.createChar(3,uplevel);
lcd.createChar(4,refresh);
lcd.createChar(5,folder);
LCD_MESSAGEPGM("UltiMarlin ready.");
}
void beep()
{
//return;
#ifdef ULTIPANEL
pinMode(BEEPER,OUTPUT);
for(int8_t i=0;i<20;i++){
WRITE(BEEPER,HIGH);
delay(5);
WRITE(BEEPER,LOW);
delay(5);
}
#endif
}
void beepshort()
{
//return;
#ifdef ULTIPANEL
pinMode(BEEPER,OUTPUT);
for(int8_t i=0;i<10;i++){
WRITE(BEEPER,HIGH);
delay(3);
WRITE(BEEPER,LOW);
delay(3);
}
#endif
}
void lcd_status()
{
#ifdef ULTIPANEL
static uint8_t oldbuttons=0;
//static long previous_millis_buttons=0;
//static long previous_lcdinit=0;
// buttons_check(); // Done in temperature interrupt
//previous_millis_buttons=millis();
long ms=millis();
for(int8_t i=0; i<8; i++) {
if((blocking[i]>ms))
buttons &= ~(1<<i);
}
if((buttons==oldbuttons) && ((millis() - previous_millis_lcd) < LCD_UPDATE_INTERVAL) )
return;
oldbuttons=buttons;
#else
if(((millis() - previous_millis_lcd) < LCD_UPDATE_INTERVAL) )
return;
#endif
previous_millis_lcd=millis();
menu.update();
}
#ifdef ULTIPANEL
void buttons_init()
{
#ifdef NEWPANEL
pinMode(BTN_EN1,INPUT);
pinMode(BTN_EN2,INPUT);
pinMode(BTN_ENC,INPUT);
pinMode(SDCARDDETECT,INPUT);
WRITE(BTN_EN1,HIGH);
WRITE(BTN_EN2,HIGH);
WRITE(BTN_ENC,HIGH);
WRITE(SDCARDDETECT,HIGH);
#else
pinMode(SHIFT_CLK,OUTPUT);
pinMode(SHIFT_LD,OUTPUT);
pinMode(SHIFT_EN,OUTPUT);
pinMode(SHIFT_OUT,INPUT);
WRITE(SHIFT_OUT,HIGH);
WRITE(SHIFT_LD,HIGH);
WRITE(SHIFT_EN,LOW);
#endif
}
void buttons_check()
{
#ifdef NEWPANEL
uint8_t newbutton=0;
if(READ(BTN_EN1)==0) newbutton|=EN_A;
if(READ(BTN_EN2)==0) newbutton|=EN_B;
if((blocking<millis()) &&(READ(BTN_ENC)==0))
newbutton|=EN_C;
buttons=newbutton;
#else //read it from the shift register
uint8_t newbutton=0;
WRITE(SHIFT_LD,LOW);
WRITE(SHIFT_LD,HIGH);
unsigned char tmp_buttons=0;
for(int8_t i=0;i<8;i++)
{
newbutton = newbutton>>1;
if(READ(SHIFT_OUT))
newbutton|=(1<<7);
WRITE(SHIFT_CLK,HIGH);
WRITE(SHIFT_CLK,LOW);
}
buttons=~newbutton; //invert it, because a pressed switch produces a logical 0
#endif
//manage encoder rotation
char enc=0;
if(buttons&EN_A)
enc|=(1<<0);
if(buttons&EN_B)
enc|=(1<<1);
if(enc!=lastenc)
{
switch(enc)
{
case encrot0:
if(lastenc==encrot3)
encoderpos++;
else if(lastenc==encrot1)
encoderpos--;
break;
case encrot1:
if(lastenc==encrot0)
encoderpos++;
else if(lastenc==encrot2)
encoderpos--;
break;
case encrot2:
if(lastenc==encrot1)
encoderpos++;
else if(lastenc==encrot3)
encoderpos--;
break;
case encrot3:
if(lastenc==encrot2)
encoderpos++;
else if(lastenc==encrot0)
encoderpos--;
break;
default:
;
}
}
lastenc=enc;
}
#endif
MainMenu::MainMenu()
{
status=Main_Status;
displayStartingRow=0;
activeline=0;
force_lcd_update=true;
#ifdef ULTIPANEL
buttons_init();
#endif
lcd_init();
linechanging=false;
tune=false;
}
void MainMenu::showStatus()
{
#if LCD_HEIGHT==4
static int olddegHotEnd0=-1;
static int oldtargetHotEnd0=-1;
//force_lcd_update=true;
if(force_lcd_update||feedmultiplychanged) //initial display of content
{
feedmultiplychanged=false;
encoderpos=feedmultiply;
clear();
lcd.setCursor(0,0);lcdprintPGM("\002123/567\001 ");
#if defined BED_USES_THERMISTOR || defined BED_USES_AD595
lcd.setCursor(10,0);lcdprintPGM("B123/567\001 ");
#endif
}
int tHotEnd0=intround(degHotend0());
if((abs(tHotEnd0-olddegHotEnd0)>1)||force_lcd_update) //>1 because otherwise the lcd is refreshed to often.
{
lcd.setCursor(1,0);
lcd.print(ftostr3(tHotEnd0));
olddegHotEnd0=tHotEnd0;
}
int ttHotEnd0=intround(degTargetHotend0());
if((ttHotEnd0!=oldtargetHotEnd0)||force_lcd_update)
{
lcd.setCursor(5,0);
lcd.print(ftostr3(ttHotEnd0));
oldtargetHotEnd0=ttHotEnd0;
}
#if defined BED_USES_THERMISTOR || defined BED_USES_AD595
static int oldtBed=-1;
static int oldtargetBed=-1;
int tBed=intround(degBed());
if((tBed!=oldtBed)||force_lcd_update)
{
lcd.setCursor(1,0);
lcd.print(ftostr3(tBed));
oldtBed=tBed;
}
int targetBed=intround(degTargetBed());
if((targetBed!=oldtargetBed)||force_lcd_update)
{
lcd.setCursor(5,0);
lcd.print(ftostr3(targetBed));
oldtargetBed=targetBed;
}
#endif
//starttime=2;
static uint16_t oldtime=0;
if(starttime!=0)
{
lcd.setCursor(0,1);
uint16_t time=millis()/60000-starttime/60000;
if(starttime!=oldtime)
{
lcd.print(itostr2(time/60));lcdprintPGM("h ");lcd.print(itostr2(time%60));lcdprintPGM("m");
oldtime=time;
}
}
static int oldzpos=0;
int currentz=current_position[2]*10;
if((currentz!=oldzpos)||force_lcd_update)
{
lcd.setCursor(10,1);
lcdprintPGM("Z:");lcd.print(itostr31(currentz));
oldzpos=currentz;
}
static int oldfeedmultiply=0;
int curfeedmultiply=feedmultiply;
if(encoderpos!=curfeedmultiply||force_lcd_update)
{
curfeedmultiply=encoderpos;
if(curfeedmultiply<10)
curfeedmultiply=10;
if(curfeedmultiply>999)
curfeedmultiply=999;
feedmultiply=curfeedmultiply;
encoderpos=curfeedmultiply;
}
if((curfeedmultiply!=oldfeedmultiply)||force_lcd_update)
{
oldfeedmultiply=curfeedmultiply;
lcd.setCursor(0,2);
lcd.print(itostr3(curfeedmultiply));lcdprintPGM("% ");
}
if(messagetext[0]!='\0')
{
lcd.setCursor(0,LCD_HEIGHT-1);
lcd.print(messagetext);
uint8_t n=strlen(messagetext);
for(int8_t i=0;i<LCD_WIDTH-n;i++)
lcd.print(" ");
messagetext[0]='\0';
}
static uint8_t oldpercent=101;
uint8_t percent=card.percentDone();
if(oldpercent!=percent ||force_lcd_update)
{
lcd.setCursor(7,2);
lcd.print(itostr3((int)percent));
lcdprintPGM("%SD");
}
#else //smaller LCDS----------------------------------
static int olddegHotEnd0=-1;
static int oldtargetHotEnd0=-1;
if(force_lcd_update) //initial display of content
{
encoderpos=feedmultiply;
lcd.setCursor(0,0);lcdprintPGM("\002123/567\001 ");
#if defined BED_USES_THERMISTOR || defined BED_USES_AD595
lcd.setCursor(10,0);lcdprintPGM("B123/567\001 ");
#endif
}
int tHotEnd0=intround(degHotend0());
int ttHotEnd0=intround(degTargetHotend0());
if((abs(tHotEnd0-olddegHotEnd0)>1)||force_lcd_update)
{
lcd.setCursor(1,0);
lcd.print(ftostr3(tHotEnd0));
olddegHotEnd0=tHotEnd0;
}
if((ttHotEnd0!=oldtargetHotEnd0)||force_lcd_update)
{
lcd.setCursor(5,0);
lcd.print(ftostr3(ttHotEnd0));
oldtargetHotEnd0=ttHotEnd0;
}
if(messagetext[0]!='\0')
{
lcd.setCursor(0,LCD_HEIGHT-1);
lcd.print(messagetext);
uint8_t n=strlen(messagetext);
for(int8_t i=0;i<LCD_WIDTH-n;i++)
lcd.print(" ");
messagetext[0]='\0';
}
#endif
force_lcd_update=false;
}
enum {ItemP_exit, ItemP_home, ItemP_origin, ItemP_preheat, ItemP_extrude, ItemP_disstep};
//any action must not contain a ',' character anywhere, or this breaks:
#define MENUITEM(repaint_action, click_action) \
{\
if(force_lcd_update) { lcd.setCursor(0,line); repaint_action; } \
if((activeline==line) && CLICKED) {click_action} \
}
void MainMenu::showPrepare()
{
uint8_t line=0;
clearIfNecessary();
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
{
//Serial.println((int)(line-lineoffset));
switch(i)
{
case ItemP_exit:
MENUITEM( lcdprintPGM(" Main \003") , BLOCK;status=Main_Menu;beepshort(); ) ;
break;
case ItemP_home:
MENUITEM( lcdprintPGM(" Auto Home") , BLOCK;enquecommand("G28 X-105 Y-105 Z0");beepshort(); ) ;
break;
case ItemP_origin:
MENUITEM( lcdprintPGM(" Set Origin") , BLOCK;enquecommand("G92 X0 Y0 Z0");beepshort(); ) ;
break;
case ItemP_preheat:
MENUITEM( lcdprintPGM(" Preheat") , BLOCK;setTargetHotend0(170);beepshort(); ) ;
break;
case ItemP_extrude:
MENUITEM( lcdprintPGM(" Extrude") , BLOCK;enquecommand("G92 E0");enquecommand("G1 F700 E50");beepshort(); ) ;
break;
case ItemP_disstep:
MENUITEM( lcdprintPGM(" Disable Steppers") , BLOCK;enquecommand("M84");beepshort(); ) ;
break;
default:
break;
}
line++;
}
updateActiveLines(ItemP_disstep,encoderpos);
}
enum {ItemT_exit,ItemT_speed,ItemT_flow,ItemT_nozzle,ItemT_fan};
void MainMenu::showTune()
{
uint8_t line=0;
clearIfNecessary();
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
{
//Serial.println((int)(line-lineoffset));
switch(i)
{
case ItemT_exit:
MENUITEM( lcdprintPGM(" Main \003") , BLOCK;status=Main_Menu;beepshort(); ) ;
break;
case ItemT_speed:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Speed:");
lcd.setCursor(13,line);lcd.print(ftostr3(feedmultiply));
}
if((activeline!=line) )
break;
if(CLICKED) //nalogWrite(FAN_PIN, fanpwm);
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=feedmultiply;
}
else
{
encoderpos=activeline*lcdslow;
beepshort();
}
BLOCK;
}
if(linechanging)
{
if(encoderpos<1) encoderpos=1;
if(encoderpos>400) encoderpos=400;
feedmultiply = encoderpos;
feedmultiplychanged=true;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
case ItemT_nozzle:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" \002Nozzle:");
lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend0())));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=intround(degTargetHotend0());
}
else
{
setTargetHotend0(encoderpos);
encoderpos=activeline*lcdslow;
beepshort();
}
BLOCK;
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>260) encoderpos=260;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
case ItemT_fan:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Fan speed:");
lcd.setCursor(13,line);lcd.print(ftostr3(fanpwm));
}
if((activeline!=line) )
break;
if(CLICKED) //nalogWrite(FAN_PIN, fanpwm);
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=fanpwm;
}
else
{
encoderpos=activeline*lcdslow;
beepshort();
}
BLOCK;
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>255) encoderpos=255;
fanpwm=encoderpos;
analogWrite(FAN_PIN, fanpwm);
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
case ItemT_flow://axis_steps_per_unit[i] = code_value();
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Flow:");
lcd.setCursor(13,line);lcd.print(itostr4(axis_steps_per_unit[3]));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)axis_steps_per_unit[3];
}
else
{
float factor=float(encoderpos)/float(axis_steps_per_unit[3]);
position[E_AXIS]=lround(position[E_AXIS]*factor);
//current_position[3]*=factor;
axis_steps_per_unit[E_AXIS]= encoderpos;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<5) encoderpos=5;
if(encoderpos>9999) encoderpos=9999;
lcd.setCursor(13,line);lcd.print(itostr4(encoderpos));
}
}break;
default:
break;
}
line++;
}
updateActiveLines(ItemT_fan,encoderpos);
}
//does not work
// #define MENUCHANGEITEM(repaint_action, enter_action, accept_action, change_action) \
// {\
// if(force_lcd_update) { lcd.setCursor(0,line); repaint_action; } \
// if(activeline==line) \
// { \
// if(CLICKED) \
// { \
// linechanging=!linechanging; \
// if(linechanging) {enter_action;} \
// else {accept_action;} \
// } \
// else \
// if(linechanging) {change_action};}\
// }
//
enum {
ItemCT_exit,ItemCT_nozzle,
#ifdef AUTOTEMP
ItemCT_autotempactive,
ItemCT_autotempmin,ItemCT_autotempmax,ItemCT_autotempfact,
#endif
ItemCT_fan,
ItemCT_PID_P,ItemCT_PID_I,ItemCT_PID_D,ItemCT_PID_C
};
void MainMenu::showControlTemp()
{
uint8_t line=0;
clearIfNecessary();
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
{
switch(i)
{
case ItemCT_exit:
MENUITEM( lcdprintPGM(" Control \003") , BLOCK;status=Main_Control;beepshort(); ) ;
break;
case ItemCT_nozzle:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" \002Nozzle:");
lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend0())));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=intround(degTargetHotend0());
}
else
{
setTargetHotend0(encoderpos);
encoderpos=activeline*lcdslow;
beepshort();
}
BLOCK;
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>260) encoderpos=260;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
#ifdef AUTOTEMP
case ItemCT_autotempmin:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" \002 Min:");
lcd.setCursor(13,line);lcd.print(ftostr3(autotemp_min));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=intround(autotemp_min);
}
else
{
autotemp_min=encoderpos;
encoderpos=activeline*lcdslow;
beepshort();
}
BLOCK;
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>260) encoderpos=260;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
case ItemCT_autotempmax:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" \002 Max:");
lcd.setCursor(13,line);lcd.print(ftostr3(autotemp_max));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=intround(autotemp_max);
}
else
{
autotemp_max=encoderpos;
encoderpos=activeline*lcdslow;
beepshort();
}
BLOCK;
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>260) encoderpos=260;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
case ItemCT_autotempfact:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" \002 Fact:");
lcd.setCursor(13,line);lcd.print(ftostr32(autotemp_factor));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=intround(autotemp_factor*100);
}
else
{
autotemp_max=encoderpos;
encoderpos=activeline*lcdslow;
beepshort();
}
BLOCK;
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>99) encoderpos=99;
lcd.setCursor(13,line);lcd.print(ftostr32(encoderpos/100.));
}
}break;
case ItemCT_autotempactive:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Autotemp:");
lcd.setCursor(13,line);
if(autotemp_enabled)
lcdprintPGM("On");
else
lcdprintPGM("Off");
}
if((activeline!=line) )
break;
if(CLICKED)
{
autotemp_enabled=!autotemp_enabled;
lcd.setCursor(13,line);
if(autotemp_enabled)
lcdprintPGM("On ");
else
lcdprintPGM("Off");
BLOCK;
}
}break;
#endif //autotemp
case ItemCT_fan:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Fan speed:");
lcd.setCursor(13,line);lcd.print(ftostr3(fanpwm));
}
if((activeline!=line) )
break;
if(CLICKED) //nalogWrite(FAN_PIN, fanpwm);
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=fanpwm;
}
else
{
encoderpos=activeline*lcdslow;
beepshort();
}
BLOCK;
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>255) encoderpos=255;
fanpwm=encoderpos;
analogWrite(FAN_PIN, fanpwm);
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
case ItemCT_PID_P:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" PID-P: ");
lcd.setCursor(13,line);lcd.print(itostr4(Kp));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)Kp;
}
else
{
Kp= encoderpos;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<1) encoderpos=1;
if(encoderpos>9990) encoderpos=9990;
lcd.setCursor(13,line);lcd.print(itostr4(encoderpos));
}
}break;
case ItemCT_PID_I:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" PID-I: ");
lcd.setCursor(13,line);lcd.print(ftostr51(Ki/PID_dT));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)(Ki*10/PID_dT);
}
else
{
Ki= encoderpos/10.*PID_dT;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>9990) encoderpos=9990;
lcd.setCursor(13,line);lcd.print(ftostr51(encoderpos/10.));
}
}break;
case ItemCT_PID_D:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" PID-D: ");
lcd.setCursor(13,line);lcd.print(itostr4(Kd*PID_dT));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)(Kd/5./PID_dT);
}
else
{
Kd= encoderpos;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>9990) encoderpos=9990;
lcd.setCursor(13,line);lcd.print(itostr4(encoderpos));
}
}break;
case ItemCT_PID_C:
#ifdef PID_ADD_EXTRUSION_RATE
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" PID-C: ");
lcd.setCursor(13,line);lcd.print(itostr3(Kc));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)Kc;
}
else
{
Kc= encoderpos;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>990) encoderpos=990;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}
#endif
break;
default:
break;
}
line++;
}
#ifdef PID_ADD_EXTRUSION_RATE
updateActiveLines(ItemCT_PID_C,encoderpos);
#else
updateActiveLines(ItemCT_PID_D,encoderpos);
#endif
}
enum {
ItemCM_exit,
ItemCM_acc, ItemCM_xyjerk,
ItemCM_vmaxx, ItemCM_vmaxy, ItemCM_vmaxz, ItemCM_vmaxe,
ItemCM_vtravmin,ItemCM_vmin,
ItemCM_amaxx, ItemCM_amaxy, ItemCM_amaxz, ItemCM_amaxe,
ItemCM_aret,ItemCM_esteps
};
void MainMenu::showControlMotion()
{
uint8_t line=0;
clearIfNecessary();
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
{
switch(i)
{
case ItemCM_exit:
MENUITEM( lcdprintPGM(" Control \003") , BLOCK;status=Main_Control;beepshort(); ) ;
break;
case ItemCM_acc:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Acc:");
lcd.setCursor(13,line);lcd.print(itostr3(acceleration/100));lcdprintPGM("00");
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)acceleration/100;
}
else
{
acceleration= encoderpos*100;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<5) encoderpos=5;
if(encoderpos>990) encoderpos=990;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcdprintPGM("00");
}
}break;
case ItemCM_xyjerk: //max_xy_jerk
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Vxy-jerk: ");
lcd.setCursor(13,line);lcd.print(itostr3(max_xy_jerk));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)max_xy_jerk;
}
else
{
max_xy_jerk= encoderpos;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<1) encoderpos=1;
if(encoderpos>990) encoderpos=990;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
case ItemCM_vmaxx:
case ItemCM_vmaxy:
case ItemCM_vmaxz:
case ItemCM_vmaxe:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Vmax ");
if(i==ItemCM_vmaxx)lcdprintPGM("x:");
if(i==ItemCM_vmaxy)lcdprintPGM("y:");
if(i==ItemCM_vmaxz)lcdprintPGM("z:");
if(i==ItemCM_vmaxe)lcdprintPGM("e:");
lcd.setCursor(13,line);lcd.print(itostr3(max_feedrate[i-ItemCM_vmaxx]));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)max_feedrate[i-ItemCM_vmaxx];
}
else
{
max_feedrate[i-ItemCM_vmaxx]= encoderpos;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<1) encoderpos=1;
if(encoderpos>990) encoderpos=990;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
case ItemCM_vmin:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Vmin:");
lcd.setCursor(13,line);lcd.print(itostr3(minimumfeedrate));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)(minimumfeedrate);
}
else
{
minimumfeedrate= encoderpos;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>990) encoderpos=990;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
case ItemCM_vtravmin:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" VTrav min:");
lcd.setCursor(13,line);lcd.print(itostr3(mintravelfeedrate));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)mintravelfeedrate;
}
else
{
mintravelfeedrate= encoderpos;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>990) encoderpos=990;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
case ItemCM_amaxx:
case ItemCM_amaxy:
case ItemCM_amaxz:
case ItemCM_amaxe:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Amax ");
if(i==ItemCM_amaxx)lcdprintPGM("x:");
if(i==ItemCM_amaxy)lcdprintPGM("y:");
if(i==ItemCM_amaxz)lcdprintPGM("z:");
if(i==ItemCM_amaxe)lcdprintPGM("e:");
lcd.setCursor(13,line);lcd.print(itostr3(max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100));lcdprintPGM("00");
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100;
}
else
{
max_acceleration_units_per_sq_second[i-ItemCM_amaxx]= encoderpos*100;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<1) encoderpos=1;
if(encoderpos>990) encoderpos=990;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcdprintPGM("00");
}
}break;
case ItemCM_aret://float retract_acceleration = 7000;
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" A-retract:");
lcd.setCursor(13,line);lcd.print(ftostr3(retract_acceleration/100));lcdprintPGM("00");
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)retract_acceleration/100;
}
else
{
retract_acceleration= encoderpos*100;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<10) encoderpos=10;
if(encoderpos>990) encoderpos=990;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcdprintPGM("00");
}
}break;
case ItemCM_esteps://axis_steps_per_unit[i] = code_value();
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Esteps/mm:");
lcd.setCursor(13,line);lcd.print(itostr4(axis_steps_per_unit[3]));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)axis_steps_per_unit[3];
}
else
{
float factor=float(encoderpos)/float(axis_steps_per_unit[3]);
position[E_AXIS]=lround(position[E_AXIS]*factor);
//current_position[3]*=factor;
axis_steps_per_unit[E_AXIS]= encoderpos;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<5) encoderpos=5;
if(encoderpos>9999) encoderpos=9999;
lcd.setCursor(13,line);lcd.print(itostr4(encoderpos));
}
}break;
default:
break;
}
line++;
}
updateActiveLines(ItemCM_esteps,encoderpos);
}
enum {
ItemC_exit,ItemC_temp,ItemC_move,
ItemC_store, ItemC_load,ItemC_failsafe
};
void MainMenu::showControl()
{
uint8_t line=0;
clearIfNecessary();
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
{
switch(i)
{
case ItemC_exit:
MENUITEM( lcdprintPGM(" Main \003") , BLOCK;status=Main_Menu;beepshort(); ) ;
break;
case ItemC_temp:
MENUITEM( lcdprintPGM(" Temperature \x7E") , BLOCK;status=Sub_TempControl;beepshort(); ) ;
break;
case ItemC_move:
MENUITEM( lcdprintPGM(" Motion \x7E") , BLOCK;status=Sub_MotionControl;beepshort(); ) ;
break;
case ItemC_store:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Store EPROM");
}
if((activeline==line) && CLICKED)
{
//enquecommand("M84");
beepshort();
BLOCK;
EEPROM_StoreSettings();
}
}break;
case ItemC_load:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Load EPROM");
}
if((activeline==line) && CLICKED)
{
//enquecommand("M84");
beepshort();
BLOCK;
EEPROM_RetrieveSettings();
}
}break;
case ItemC_failsafe:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Restore Failsafe");
}
if((activeline==line) && CLICKED)
{
//enquecommand("M84");
beepshort();
BLOCK;
EEPROM_RetrieveSettings(true);
}
}break;
default:
break;
}
line++;
}
updateActiveLines(ItemC_failsafe,encoderpos);
}
void MainMenu::showSD()
{
#ifdef SDSUPPORT
uint8_t line=0;
clearIfNecessary();
static uint8_t nrfiles=0;
if(force_lcd_update)
{
if(card.cardOK)
{
nrfiles=card.getnrfilenames();
}
else
{
nrfiles=0;
lineoffset=0;
}
}
bool enforceupdate=false;
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
{
switch(i)
{
case 0:
MENUITEM( lcdprintPGM(" Main \003") , BLOCK;status=Main_Menu;beepshort(); ) ;
break;
// case 1:
// {
// if(force_lcd_update)
// {
// lcd.setCursor(0,line);
// #ifdef CARDINSERTED
// if(CARDINSERTED)
// #else
// if(true)
// #endif
// {
// lcdprintPGM(" \004Refresh");
// }
// else
// {
// lcdprintPGM(" \004Insert Card");
// }
//
// }
// if((activeline==line) && CLICKED)
// {
// BLOCK;
// beepshort();
// card.initsd();
// force_lcd_update=true;
// nrfiles=card.getnrfilenames();
// }
// }break;
case 1:
MENUITEM( lcd.print(" ");card.getWorkDirName();if(card.filename[0]=='/') lcdprintPGM("\004Refresh");else {lcd.print("\005");lcd.print(card.filename);lcd.print("/..");} , BLOCK;card.updir();enforceupdate=true;lineoffset=0;beepshort(); ) ;
break;
default:
{
#define FIRSTITEM 2
if(i-FIRSTITEM<nrfiles)
{
if(force_lcd_update)
{
card.getfilename(i-FIRSTITEM);
//Serial.print("Filenr:");Serial.println(i-2);
lcd.setCursor(0,line);lcdprintPGM(" ");
if(card.filenameIsDir) lcd.print("\005");
lcd.print(card.filename);
}
if((activeline==line) && CLICKED)
{
BLOCK
card.getfilename(i-FIRSTITEM);
if(card.filenameIsDir)
{
for(int8_t i=0;i<strlen(card.filename);i++)
card.filename[i]=tolower(card.filename[i]);
card.chdir(card.filename);
lineoffset=0;
enforceupdate=true;
}
else
{
char cmd[30];
for(int8_t i=0;i<strlen(card.filename);i++)
card.filename[i]=tolower(card.filename[i]);
sprintf(cmd,"M23 %s",card.filename);
//sprintf(cmd,"M115");
enquecommand(cmd);
enquecommand("M24");
beep();
status=Main_Status;
lcd_status(card.filename);
}
}
}
}
break;
}
line++;
}
updateActiveLines(FIRSTITEM+nrfiles-1,encoderpos);
if(enforceupdate)
{
force_lcd_update=true;
enforceupdate=false;
}
#endif
}
enum {ItemM_watch, ItemM_prepare, ItemM_control, ItemM_file };
void MainMenu::showMainMenu()
{
#ifndef ULTIPANEL
force_lcd_update=false;
#endif
if(tune)
{
if(!(movesplanned() ||card.sdprinting))
{
force_lcd_update=true;
tune=false;
}
}
else
{
if(movesplanned() ||card.sdprinting)
{
force_lcd_update=true;
tune=true;
}
}
clearIfNecessary();
for(int8_t line=0;line<LCD_HEIGHT;line++)
{
switch(line)
{
case ItemM_watch:
MENUITEM( lcdprintPGM(" Watch \003") , BLOCK;status=Main_Status;beepshort(); ) ;
break;
case ItemM_prepare:
MENUITEM( if(!tune) lcdprintPGM(" Prepare \x7E");else lcdprintPGM(" Tune \x7E"); , BLOCK;status=Main_Prepare;beepshort(); ) ;
break;
case ItemM_control:
MENUITEM( lcdprintPGM(" Control \x7E") , BLOCK;status=Main_Control;beepshort(); ) ;
break;
#ifdef SDSUPPORT
case ItemM_file:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);
#ifdef CARDINSERTED
if(CARDINSERTED)
#else
if(true)
#endif
{
if(card.sdprinting)
lcdprintPGM(" Stop Print \x7E");
else
lcdprintPGM(" Card Menu \x7E");
}
else
{
lcdprintPGM(" No Card");
}
}
#ifdef CARDINSERTED
if(CARDINSERTED)
#endif
if((activeline==line)&&CLICKED)
{
card.printingHasFinished();
BLOCK;
status=Main_SD;
beepshort();
}
}break;
#else
case ItemM_file:
break;
#endif
default:
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM("Something is wrong in the MenuStructure.");
break;
}
}
updateActiveLines(3,encoderpos);
}
void MainMenu::update()
{
static MainStatus oldstatus=Main_Menu; //init automatically causes foce_lcd_update=true
static long timeoutToStatus=0;
static bool oldcardstatus=false;
#ifdef CARDINSERTED
if((CARDINSERTED != oldcardstatus))
{
force_lcd_update=true;
oldcardstatus=CARDINSERTED;
//Serial.println("echo: SD CHANGE");
if(CARDINSERTED)
{
card.initsd();
LCD_MESSAGEPGM("Card inserted");
}
else
{
card.release();
LCD_MESSAGEPGM("Card removed");
}
}
#endif
if(status!=oldstatus)
{
force_lcd_update=true;
encoderpos=0;
lineoffset=0;
oldstatus=status;
}
if( (encoderpos!=lastencoderpos) || CLICKED)
timeoutToStatus=millis()+STATUSTIMEOUT;
switch(status)
{
case Main_Status:
{
showStatus();
if(CLICKED)
{
linechanging=false;
BLOCK
status=Main_Menu;
timeoutToStatus=millis()+STATUSTIMEOUT;
}
}break;
case Main_Menu:
{
showMainMenu();
linechanging=false;
}break;
case Main_Prepare:
{
if(tune)
{
showTune();
}
else
{
showPrepare();
}
}break;
case Main_Control:
{
showControl();
}break;
case Sub_MotionControl:
{
showControlMotion();
}break;
case Sub_TempControl:
{
showControlTemp();
}break;
case Main_SD:
{
showSD();
}break;
}
if(timeoutToStatus<millis())
status=Main_Status;
//force_lcd_update=false;
lastencoderpos=encoderpos;
}
// convert float to string with +123.4 format
char *ftostr3(const float &x)
{
//sprintf(conv,"%5.1f",x);
int xx=x;
conv[0]=(xx/100)%10+'0';
conv[1]=(xx/10)%10+'0';
conv[2]=(xx)%10+'0';
conv[3]=0;
return conv;
}
char *itostr2(const uint8_t &x)
{
//sprintf(conv,"%5.1f",x);
int xx=x;
conv[0]=(xx/10)%10+'0';
conv[1]=(xx)%10+'0';
conv[2]=0;
return conv;
}
// convert float to string with +123.4 format
char *ftostr31(const float &x)
{
int xx=x*10;
conv[0]=(xx>=0)?'+':'-';
xx=abs(xx);
conv[1]=(xx/1000)%10+'0';
conv[2]=(xx/100)%10+'0';
conv[3]=(xx/10)%10+'0';
conv[4]='.';
conv[5]=(xx)%10+'0';
conv[6]=0;
return conv;
}
char *ftostr32(const float &x)
{
int xx=x*100;
conv[0]=(xx>=0)?'+':'-';
xx=abs(xx);
conv[1]=(xx/100)%10+'0';
conv[2]='.';
conv[3]=(xx/10)%10+'0';
conv[4]=(xx)%10+'0';
conv[6]=0;
return conv;
}
char *itostr31(const int &xx)
{
conv[0]=(xx>=0)?'+':'-';
conv[1]=(xx/1000)%10+'0';
conv[2]=(xx/100)%10+'0';
conv[3]=(xx/10)%10+'0';
conv[4]='.';
conv[5]=(xx)%10+'0';
conv[6]=0;
return conv;
}
char *itostr3(const int &xx)
{
conv[0]=(xx/100)%10+'0';
conv[1]=(xx/10)%10+'0';
conv[2]=(xx)%10+'0';
conv[3]=0;
return conv;
}
char *itostr4(const int &xx)
{
conv[0]=(xx/1000)%10+'0';
conv[1]=(xx/100)%10+'0';
conv[2]=(xx/10)%10+'0';
conv[3]=(xx)%10+'0';
conv[4]=0;
return conv;
}
// convert float to string with +1234.5 format
char *ftostr51(const float &x)
{
int xx=x*10;
conv[0]=(xx>=0)?'+':'-';
xx=abs(xx);
conv[1]=(xx/10000)%10+'0';
conv[2]=(xx/1000)%10+'0';
conv[3]=(xx/100)%10+'0';
conv[4]=(xx/10)%10+'0';
conv[5]='.';
conv[6]=(xx)%10+'0';
conv[7]=0;
return conv;
}
#endif //ULTRA_LCD