├── keywords.txt ├── README.md ├── STM32_olimexino_stepper_motor_emulator ├── Arduino_stepper_motor_emulator_v1.0.0.pde ├── Arduino_stepper_motor_emulator_v1.0.1_direct_port_manipulation.pde ├── digitalWriteFast.h └── LICENSE /keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For DigitalWriteFast 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | DigitalWriteFast KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | 15 | digitalWriteFast KEYWORD2 16 | digitalWriteFast2 KEYWORD2 17 | pinModeFast KEYWORD2 18 | pinModeFast2 KEYWORD2 19 | digitalReadFast KEYWORD2 20 | digitalReadFast2 KEYWORD2 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ServoStrap 2 | ========== 3 | 4 | servo-controlled reprap 3D printer: 5 | 6 | this code take as input stepper information from a standard 3D printer motherboard 7 | and use it to control a servo-motor with active position tracker. 8 | 9 | i have made this code for the LMD18245 motor controller, 10 | i have merged the pid code of Josh Kopel 11 | whith the code of makerbot servo-controller board, 12 | you can use this code on the some board changing some values. 13 | Daniele Poddighe 14 | 15 | external ardware require a quadrature encoder, timing slit strip and a dc motor, 16 | all you can find inside an old printer, i have took it from canon and hp printers(psc1510) 17 | 18 | for motor controll you can choose different type of H-bridge, i have used LMD18245, 19 | you can order 3 of it on ti.com sample request, the hardware needed is explained on the datasheet but i'm drowing 20 | the schematic and PCB layout on eagle to make an integrated board aesy to add to ramps 1.4 or other printer motherboard 21 | 22 | improvements: 23 | 24 | 1)moore faster movements on x-y axys, it mean less time to wait to print a part 25 | 26 | 2)less noise from the motors, it will be silent 27 | 28 | 3)the couple of the motor not decrease with the speed (like in a stepper motor) 29 | 30 | 4)active position tracking, no more step losses, 31 | almost all prints will end in perfect condition because if something stop 32 | the head it will return to the print position 33 | 34 | 5)less price to build a printer, almost all electronic woste (like 2D printers) 35 | have inside dc motors with all needed to control it 36 | 37 | 6)resolution increased by fine setting PID costants and using angular encoder, doesn't matter if is slit disk or magnetic 38 | 39 | 7)potentially endstops are not needed because the timing strip have special code at the begin/end 40 | that can be interpreted as endstop 41 | 42 | 43 | To use the code you need first to put the two files called digitalWriteFast.h and Keywords.txt in a folder inside arduino/libraries 44 | 45 | 46 | here the youtube link of the test with this code: http://goo.gl/gAia5y 47 | -------------------------------------------------------------------------------- /STM32_olimexino_stepper_motor_emulator: -------------------------------------------------------------------------------- 1 | /* i have made this code for the LMD18245 motor controller, 2 | i have merged the pid code of Josh Kopel 3 | whith the code of makerbot servo-controller board, 4 | you can use this code on the some board changing some values. 5 | Daniele Poddighe 6 | 7 | external ardware require a quadrature encoder, timing slit strip and a dc motor, 8 | all you can find inside an old printer, i have took it from canon and hp printers(psc1510) 9 | 10 | for motor controll you can choose different type of H-bridge, i have used LMD18245, 11 | you can order 3 of it on ti.com sample request, the hardware needed is explained on the datasheet but i'm drowing 12 | the schematic and PCB layout on eagle. 13 | 14 | 15 | read a rotary encoder with interrupts 16 | Encoder hooked up with common to GROUND, 17 | encoder0PinA to pin 2, encoder0PinB to pin 4 (or pin 3 see below) 18 | it doesn't matter which encoder pin you use for A or B 19 | 20 | is possible to change PID costants by sending on SerialUSB interfaces the values separated by ',' in this order: KP,KD,KI 21 | example: 5.2,3.1,0 so we have KP=5.2 KD=3.1 KI=0 is only for testing purposes, but i will leave this function with eeprom storage 22 | 23 | */ 24 | 25 | #define encoder0PinA 2 26 | #define encoder0PinB 4 27 | 28 | #define SpeedPin 9 29 | #define DirectionPin 8 30 | 31 | //from ramps 1.4 stepper driver 32 | #define STEP_PIN 3 33 | #define DIR_PIN 12 34 | #define ENABLE_PIN 13 35 | 36 | 37 | volatile long encoder0Pos = 0; 38 | 39 | long target = 0; 40 | long target1 = 0; 41 | int amp=212; 42 | //correction = Kp * error + Kd * (error - prevError) + kI * (sum of errors) 43 | //PID controller constants 44 | float KP = 6.0 ; //position multiplier (gain) 2.25 45 | float KI = 0.1; // Intergral multiplier (gain) .25 46 | float KD = 1.3; // derivative multiplier (gain) 1.0 47 | 48 | int lastError = 0; 49 | int sumError = 0; 50 | 51 | //Integral term min/max (random value and not yet tested/verified) 52 | int iMax = 100; 53 | int iMin = 0; 54 | 55 | long previousTarget = 0; 56 | long previousMillis = 0; // will store last time LED was updated 57 | long interval = 5; // interval at which to blink (milliseconds) 58 | 59 | //for motor control ramps 1.4 60 | bool newStep = false; 61 | bool oldStep = false; 62 | bool dir = false; 63 | 64 | void setup() { 65 | 66 | pinMode(encoder0PinA, INPUT); 67 | pinMode(encoder0PinB, INPUT); 68 | 69 | pinMode(DirectionPin, OUTPUT); 70 | pinMode(SpeedPin, OUTPUT); 71 | 72 | //ramps 1.4 motor control 73 | pinMode(STEP_PIN, INPUT); 74 | pinMode(DIR_PIN, INPUT); 75 | 76 | attachInterrupt(2, doEncoderMotor0, CHANGE); // encoder pin on interrupt 0 - pin 2 77 | attachInterrupt(3, countStep, RISING); //on pin 3 78 | 79 | SerialUSB.println("start"); // a personal quirk 80 | 81 | } 82 | 83 | void loop(){ 84 | 85 | while (SerialUSB.available() > 0) { 86 | KP = SerialUSB.read(); 87 | KD = SerialUSB.read(); 88 | KI = SerialUSB.read(); 89 | 90 | 91 | SerialUSB.println(KP); 92 | SerialUSB.println(KD); 93 | SerialUSB.println(KI); 94 | } 95 | 96 | if(millis() - previousTarget > 500){ //enable this code only for test purposes 97 | SerialUSB.print(encoder0Pos); 98 | SerialUSB.print(','); 99 | SerialUSB.println(target1); 100 | previousTarget=millis(); 101 | } 102 | 103 | target = target1; 104 | docalc(); 105 | } 106 | 107 | void docalc() { 108 | 109 | if (millis() - previousMillis > interval) 110 | { 111 | previousMillis = millis(); // remember the last time we blinked the LED 112 | 113 | long error = encoder0Pos - target ; // find the error term of current position - target 114 | 115 | //generalized PID formula 116 | //correction = Kp * error + Kd * (error - prevError) + kI * (sum of errors) 117 | long ms = KP * error + KD * (error - lastError) +KI * (sumError); 118 | 119 | lastError = error; 120 | sumError += error; 121 | 122 | //scale the sum for the integral term 123 | if(sumError > iMax) { 124 | sumError = iMax; 125 | } else if(sumError < iMin){ 126 | sumError = iMin; 127 | } 128 | 129 | if(ms > 0){ 130 | digitalWrite ( DirectionPin ,HIGH ); 131 | } 132 | if(ms < 0){ 133 | digitalWrite ( DirectionPin , LOW ); 134 | ms = -1 * ms; 135 | } 136 | 137 | int motorspeed = map(ms,0,amp,0,255); 138 | if( motorspeed >= 255) motorspeed=255; 139 | //analogWrite ( SpeedPin, (255 - motorSpeed) ); 140 | analogWrite ( SpeedPin, motorspeed ); 141 | //SerialUSB.print ( ms ); 142 | //SerialUSB.print ( ',' ); 143 | //SerialUSB.println ( motorspeed ); 144 | } 145 | } 146 | 147 | void doEncoderMotor0(){ 148 | if (digitalRead(encoder0PinA) == HIGH) { // found a low-to-high on channel A 149 | if (digitalRead(encoder0PinB) == LOW) { // check channel B to see which way 150 | // encoder is turning 151 | encoder0Pos = encoder0Pos - 1; // CCW 152 | } 153 | else { 154 | encoder0Pos = encoder0Pos + 1; // CW 155 | } 156 | } 157 | else // found a high-to-low on channel A 158 | { 159 | if (digitalRead(encoder0PinB) == LOW) { // check channel B to see which way 160 | // encoder is turning 161 | encoder0Pos = encoder0Pos + 1; // CW 162 | } 163 | else { 164 | encoder0Pos = encoder0Pos - 1; // CCW 165 | } 166 | 167 | } 168 | 169 | } 170 | 171 | void countStep(){ 172 | dir = digitalRead(DIR_PIN); 173 | if (dir) target1++; 174 | else target1--; 175 | } 176 | -------------------------------------------------------------------------------- /Arduino_stepper_motor_emulator_v1.0.0.pde: -------------------------------------------------------------------------------- 1 | /* i have made this code for the LMD18245 motor controller, 2 | i have merged the pid code of Josh Kopel 3 | whith the code of makerbot servo-controller board, 4 | you can use this code on the some board changing some values. 5 | Daniele Poddighe 6 | 7 | external ardware require a quadrature encoder, timing slit strip and a dc motor, 8 | all you can find inside an old printer, i have took it from canon and hp printers(psc1510) 9 | 10 | for motor controll you can choose different type of H-bridge, i have used LMD18245, 11 | you can order 3 of it on ti.com sample request, the hardware needed is explained on the datasheet but i'm drowing 12 | the schematic and PCB layout on eagle. 13 | 14 | 15 | read a rotary encoder with interrupts 16 | Encoder hooked up with common to GROUND, 17 | encoder0PinA to pin 2, encoder0PinB to pin 4 (or pin 3 see below) 18 | it doesn't matter which encoder pin you use for A or B 19 | 20 | is possible to change PID costants by sending on serial interfaces the values separated by ',' in this order: KP,KD,KI 21 | example: 5.2,3.1,0 so we have KP=5.2 KD=3.1 KI=0 is only for testing purposes, 22 | but i will leave this function with eeprom storage 23 | 24 | */ 25 | 26 | #include //this is to use DWF library, it will increase the speed of digitalRead/Write command 27 | //used in the interrupt function doEncoderMotor0, but may be used everywhere. 28 | 29 | #define encoder0PinA 2 30 | #define encoder0PinB 4 31 | 32 | #define SpeedPin 9 33 | #define DirectionPin 8 34 | 35 | //from ramps 1.4 stepper driver 36 | #define STEP_PIN 3 37 | #define DIR_PIN 12 38 | #define ENABLE_PIN 13 39 | 40 | 41 | volatile long encoder0Pos = 0; 42 | 43 | long target = 0; 44 | long target1 = 0; 45 | int amp=212; 46 | //correction = Kp * error + Kd * (error - prevError) + kI * (sum of errors) 47 | //PID controller constants 48 | float KP = 6.0 ; //position multiplier (gain) 2.25 49 | float KI = 0.1; // Intergral multiplier (gain) .25 50 | float KD = 1.3; // derivative multiplier (gain) 1.0 51 | 52 | int lastError = 0; 53 | int sumError = 0; 54 | 55 | //Integral term min/max (random value and not yet tested/verified) 56 | int iMax = 100; 57 | int iMin = 0; 58 | 59 | long previousTarget = 0; 60 | long previousMillis = 0; // will store last time LED was updated 61 | long interval = 5; // interval at which to blink (milliseconds) 62 | 63 | //for motor control ramps 1.4 64 | bool newStep = false; 65 | bool oldStep = false; 66 | bool dir = false; 67 | 68 | void setup() { 69 | 70 | pinMode(encoder0PinA, INPUT); 71 | pinMode(encoder0PinB, INPUT); 72 | 73 | pinMode(DirectionPin, OUTPUT); 74 | pinMode(SpeedPin, OUTPUT); 75 | 76 | //ramps 1.4 motor control 77 | pinMode(STEP_PIN, INPUT); 78 | pinMode(DIR_PIN, INPUT); 79 | 80 | attachInterrupt(0, doEncoderMotor0, CHANGE); // encoder pin on interrupt 0 - pin 2 81 | attachInterrupt(1, countStep, RISING); //on pin 3 82 | 83 | Serial.begin (115200); 84 | Serial.println("start"); // a personal quirk 85 | 86 | } 87 | 88 | void loop(){ 89 | 90 | while (Serial.available() > 0) { 91 | KP = Serial.parseFloat(); 92 | KD = Serial.parseFloat(); 93 | KI = Serial.parseFloat(); 94 | 95 | 96 | Serial.println(KP); 97 | Serial.println(KD); 98 | Serial.println(KI); 99 | } 100 | 101 | /*if(millis() - previousTarget > 500){ //enable this code only for test purposes 102 | Serial.print(encoder0Pos); 103 | Serial.print(','); 104 | Serial.println(target1); 105 | previousTarget=millis(); 106 | }*/ 107 | 108 | target = target1; 109 | docalc(); 110 | } 111 | 112 | void docalc() { 113 | 114 | if (millis() - previousMillis > interval) 115 | { 116 | previousMillis = millis(); // remember the last time we blinked the LED 117 | 118 | long error = encoder0Pos - target ; // find the error term of current position - target 119 | 120 | //generalized PID formula 121 | //correction = Kp * error + Kd * (error - prevError) + kI * (sum of errors) 122 | long ms = KP * error + KD * (error - lastError) +KI * (sumError); 123 | 124 | lastError = error; 125 | sumError += error; 126 | 127 | //scale the sum for the integral term 128 | if(sumError > iMax) { 129 | sumError = iMax; 130 | } else if(sumError < iMin){ 131 | sumError = iMin; 132 | } 133 | 134 | if(ms > 0){ 135 | digitalWrite ( DirectionPin ,HIGH ); 136 | } 137 | if(ms < 0){ 138 | digitalWrite ( DirectionPin , LOW ); 139 | ms = -1 * ms; 140 | } 141 | 142 | int motorspeed = map(ms,0,amp,0,255); 143 | if( motorspeed >= 255) motorspeed=255; 144 | //analogWrite ( SpeedPin, (255 - motorSpeed) ); 145 | analogWrite ( SpeedPin, motorspeed ); 146 | //Serial.print ( ms ); 147 | //Serial.print ( ',' ); 148 | //Serial.println ( motorspeed ); 149 | } 150 | } 151 | 152 | void doEncoderMotor0(){ 153 | if (digitalReadFast2(encoder0PinA) == HIGH) { // found a low-to-high on channel A 154 | if (digitalReadFast2(encoder0PinB) == LOW) { // check channel B to see which way 155 | // encoder is turning 156 | encoder0Pos = encoder0Pos - 1; // CCW 157 | } 158 | else { 159 | encoder0Pos = encoder0Pos + 1; // CW 160 | } 161 | } 162 | else // found a high-to-low on channel A 163 | { 164 | if (digitalReadFast2(encoder0PinB) == LOW) { // check channel B to see which way 165 | // encoder is turning 166 | encoder0Pos = encoder0Pos + 1; // CW 167 | } 168 | else { 169 | encoder0Pos = encoder0Pos - 1; // CCW 170 | } 171 | 172 | } 173 | 174 | } 175 | 176 | void countStep(){ 177 | dir = digitalRead(DIR_PIN); 178 | if (dir) target1++; 179 | else target1--; 180 | } 181 | -------------------------------------------------------------------------------- /Arduino_stepper_motor_emulator_v1.0.1_direct_port_manipulation.pde: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* i have made this code for the LMD18245 motor controller, 4 | i have merged the pid code of Josh Kopel 5 | whith the code of makerbot servo-controller board, 6 | you can use this code on the some board changing some values. 7 | Daniele Poddighe 8 | 9 | external ardware require a quadrature encoder, timing slit strip and a dc motor, 10 | all you can find inside an old printer, i have took it from canon and hp printers(psc1510) 11 | 12 | for motor controll you can choose different type of H-bridge, i have used LMD18245, 13 | you can order 3 of it on ti.com sample request, the hardware needed is explained on the datasheet but i'm drowing 14 | the schematic and PCB layout on eagle. 15 | 16 | 17 | read a rotary encoder with interrupts 18 | Encoder hooked up with common to GROUND, 19 | encoder0PinA to pin 2, encoder0PinB to pin 4 (or pin 3 see below) 20 | it doesn't matter which encoder pin you use for A or B 21 | 22 | is possible to change PID costants by sending on serial interfaces the values separated by ',' in this order: KP,KD,KI 23 | example: 5.2,3.1,0 so we have KP=5.2 KD=3.1 KI=0 is only for testing purposes, but i will leave this function with eeprom storage 24 | 25 | */ 26 | 27 | #define encoder0PinA 2 // PD2; 28 | #define encoder0PinB 8 // PB0; 29 | 30 | #define SpeedPin 6 31 | #define DirectionPin 15 //PC1; 32 | 33 | //from ramps 1.4 stepper driver 34 | #define STEP_PIN 3 //PD3; 35 | #define DIR_PIN 14 //PC0; 36 | //#define ENABLE_PIN 13 //PB5; for now is USELESS 37 | 38 | //to use current motor as speed control, the LMD18245 has 4 bit cuttent output 39 | //#define M0 9 //assign 4 bit from PORTB register to current control -> Bxx0000x (x mean any) 40 | //#define M1 10 // PB1; PB2; PB3; PB4 41 | //#define M2 11 42 | //#define M3 12 43 | 44 | 45 | volatile long encoder0Pos = 0; 46 | 47 | long target = 0; 48 | long target1 = 0; 49 | int amp=212; 50 | //correction = Kp * error + Kd * (error - prevError) + kI * (sum of errors) 51 | //PID controller constants 52 | float KP = 6.0 ; //position multiplier (gain) 2.25 53 | float KI = 0.1; // Intergral multiplier (gain) .25 54 | float KD = 1.3; // derivative multiplier (gain) 1.0 55 | 56 | int lastError = 0; 57 | int sumError = 0; 58 | 59 | //Integral term min/max (random value and not yet tested/verified) 60 | int iMax = 100; 61 | int iMin = 0; 62 | 63 | long previousTarget = 0; 64 | long previousMillis = 0; // will store last time LED was updated 65 | long interval = 5; // interval at which to blink (milliseconds) 66 | 67 | //for motor control ramps 1.4 68 | bool newStep = false; 69 | bool oldStep = false; 70 | bool dir = false; 71 | 72 | void setup() { 73 | pinModeFast(2, INPUT); 74 | pinModeFast(encoder0PinA, INPUT); 75 | pinModeFast(encoder0PinB, INPUT); 76 | 77 | pinModeFast(DirectionPin, OUTPUT); 78 | //pinMode(SpeedPin, OUTPUT); 79 | 80 | //ramps 1.4 motor control 81 | pinModeFast(STEP_PIN, INPUT); 82 | pinModeFast(DIR_PIN, INPUT); 83 | //pinModeFast(M0,OUTPUT); 84 | //pinModeFast(M1,OUTPUT); 85 | //pinModeFast(M2,OUTPUT); 86 | //pinModeFast(M3,OUTPUT); 87 | 88 | attachInterrupt(0, doEncoderMotor0, CHANGE); // encoder pin on interrupt 0 - pin 2 89 | attachInterrupt(1, countStep, RISING); //on pin 3 90 | 91 | Serial.begin (115200); 92 | Serial.println("start"); // a personal quirk 93 | 94 | } 95 | 96 | void loop(){ 97 | 98 | while (Serial.available() > 0) { 99 | KP = Serial.parseFloat(); 100 | KD = Serial.parseFloat(); 101 | KI = Serial.parseFloat(); 102 | 103 | 104 | Serial.println(KP); 105 | Serial.println(KD); 106 | Serial.println(KI); 107 | } 108 | 109 | if(millis() - previousTarget > 1000){ //enable this code only for test purposes because it loss a lot of time 110 | Serial.print(encoder0Pos); 111 | Serial.print(','); 112 | Serial.println(target1); 113 | previousTarget=millis(); 114 | } 115 | 116 | target = target1; 117 | docalc(); 118 | } 119 | 120 | void docalc() { 121 | 122 | if (millis() - previousMillis > interval) 123 | { 124 | previousMillis = millis(); // remember the last time we blinked the LED 125 | 126 | long error = encoder0Pos - target ; // find the error term of current position - target 127 | 128 | //generalized PID formula 129 | //correction = Kp * error + Kd * (error - prevError) + kI * (sum of errors) 130 | long ms = KP * error + KD * (error - lastError) +KI * (sumError); 131 | 132 | lastError = error; 133 | sumError += error; 134 | 135 | //scale the sum for the integral term 136 | if(sumError > iMax) { 137 | sumError = iMax; 138 | } else if(sumError < iMin){ 139 | sumError = iMin; 140 | } 141 | 142 | if(ms > 0){ 143 | PORTC |=B00000010; //digitalWriteFast2 ( DirectionPin ,HIGH ); write PC1 HIGH 144 | } 145 | if(ms < 0){ 146 | PORTC &=(B11111101); //digitalWriteFast2 ( DirectionPin , LOW ); write PC1 LOW 147 | ms = -1 * ms; 148 | } 149 | 150 | int motorspeed = map(ms,0,amp,0,255); 151 | if( motorspeed >= 255) motorspeed=255; 152 | //PORTB |=(motorspeed<<1); // is a sort of: digitalwrite(M0 M1 M2 M3, 0 0 0 0 to 1 1 1 1); it set directly PORTB to B**M3M2M1M0*; 153 | //analogWrite ( SpeedPin, (255 - motorSpeed) ); 154 | analogWrite ( SpeedPin, motorspeed ); 155 | //Serial.print ( ms ); 156 | //Serial.print ( ',' ); 157 | //Serial.println ( motorspeed ); 158 | } 159 | } 160 | 161 | void doEncoderMotor0(){ 162 | if (((PIND&B0000100)>>2) == HIGH) { // found a low-to-high on channel A; if(digitalRead(encoderPinA)==HIGH){.... read PB0 163 | // because PD0is used for serial, i will change in the stable version TO USE PD2 164 | if ((PINB&B0000001) == LOW) { // check channel B to see which way; if(digitalRead(encoderPinB)==LOW){.... read PB0 165 | // encoder is turning 166 | encoder0Pos-- ; // CCW 167 | } 168 | else { 169 | encoder0Pos++ ; // CW 170 | } 171 | } 172 | else // found a high-to-low on channel A 173 | { 174 | if ((PINB&B0000001) == LOW) { // check channel B to see which way; if(digitalRead(encoderPinB)==LOW){.... read PB0 175 | // encoder is turning 176 | encoder0Pos++ ; // CW 177 | } 178 | else { 179 | encoder0Pos-- ; // CCW 180 | } 181 | 182 | } 183 | 184 | } 185 | 186 | void countStep(){ 187 | dir = (PINC&B0000001); // dir=digitalRead(dir_pin) read PC0, 14 digital; 188 | //here will be (PINB&B0000001) to not use shift in the stable version 189 | if (dir) target1++; 190 | else target1--; 191 | } 192 | -------------------------------------------------------------------------------- /digitalWriteFast.h: -------------------------------------------------------------------------------- 1 | #if !defined(digitalPinToPortReg) 2 | #if !defined(__AVR_ATmega1280__) 3 | 4 | // Standard Arduino Pins 5 | #define digitalPinToPortReg(P) \ 6 | (((P) >= 0 && (P) <= 7) ? &PORTD : (((P) >= 8 && (P) <= 13) ? &PORTB : &PORTC)) 7 | #define digitalPinToDDRReg(P) \ 8 | (((P) >= 0 && (P) <= 7) ? &DDRD : (((P) >= 8 && (P) <= 13) ? &DDRB : &DDRC)) 9 | #define digitalPinToPINReg(P) \ 10 | (((P) >= 0 && (P) <= 7) ? &PIND : (((P) >= 8 && (P) <= 13) ? &PINB : &PINC)) 11 | #define digitalPinToBit(P) \ 12 | (((P) >= 0 && (P) <= 7) ? (P) : (((P) >= 8 && (P) <= 13) ? (P) - 8 : (P) - 14)) 13 | 14 | #if defined(__AVR_ATmega8__) 15 | 16 | // 3 PWM 17 | #define digitalPinToTimer(P) \ 18 | (((P) == 9 || (P) == 10) ? &TCCR1A : (((P) == 11) ? &TCCR2 : 0)) 19 | #define digitalPinToTimerBit(P) \ 20 | (((P) == 9) ? COM1A1 : (((P) == 10) ? COM1B1 : COM21)) 21 | #else 22 | 23 | // 6 PWM 24 | #define digitalPinToTimer(P) \ 25 | (((P) == 6 || (P) == 5) ? &TCCR0A : \ 26 | (((P) == 9 || (P) == 10) ? &TCCR1A : \ 27 | (((P) == 11 || (P) == 3) ? &TCCR2A : 0))) 28 | #define digitalPinToTimerBit(P) \ 29 | (((P) == 6) ? COM0A1 : (((P) == 5) ? COM0B1 : \ 30 | (((P) == 9) ? COM1A1 : (((P) == 10) ? COM1B1 : \ 31 | (((P) == 11) ? COM2A1 : COM2B1))))) 32 | #endif 33 | 34 | #else 35 | // Arduino Mega Pins 36 | #define digitalPinToPortReg(P) \ 37 | (((P) >= 22 && (P) <= 29) ? &PORTA : \ 38 | ((((P) >= 10 && (P) <= 13) || ((P) >= 50 && (P) <= 53)) ? &PORTB : \ 39 | (((P) >= 30 && (P) <= 37) ? &PORTC : \ 40 | ((((P) >= 18 && (P) <= 21) || (P) == 38) ? &PORTD : \ 41 | ((((P) >= 0 && (P) <= 3) || (P) == 5) ? &PORTE : \ 42 | (((P) >= 54 && (P) <= 61) ? &PORTF : \ 43 | ((((P) >= 39 && (P) <= 41) || (P) == 4) ? &PORTG : \ 44 | ((((P) >= 6 && (P) <= 9) || (P) == 16 || (P) == 17) ? &PORTH : \ 45 | (((P) == 14 || (P) == 15) ? &PORTJ : \ 46 | (((P) >= 62 && (P) <= 69) ? &PORTK : &PORTL)))))))))) 47 | 48 | #define digitalPinToDDRReg(P) \ 49 | (((P) >= 22 && (P) <= 29) ? &DDRA : \ 50 | ((((P) >= 10 && (P) <= 13) || ((P) >= 50 && (P) <= 53)) ? &DDRB : \ 51 | (((P) >= 30 && (P) <= 37) ? &DDRC : \ 52 | ((((P) >= 18 && (P) <= 21) || (P) == 38) ? &DDRD : \ 53 | ((((P) >= 0 && (P) <= 3) || (P) == 5) ? &DDRE : \ 54 | (((P) >= 54 && (P) <= 61) ? &DDRF : \ 55 | ((((P) >= 39 && (P) <= 41) || (P) == 4) ? &DDRG : \ 56 | ((((P) >= 6 && (P) <= 9) || (P) == 16 || (P) == 17) ? &DDRH : \ 57 | (((P) == 14 || (P) == 15) ? &DDRJ : \ 58 | (((P) >= 62 && (P) <= 69) ? &DDRK : &DDRL)))))))))) 59 | 60 | #define digitalPinToPINReg(P) \ 61 | (((P) >= 22 && (P) <= 29) ? &PINA : \ 62 | ((((P) >= 10 && (P) <= 13) || ((P) >= 50 && (P) <= 53)) ? &PINB : \ 63 | (((P) >= 30 && (P) <= 37) ? &PINC : \ 64 | ((((P) >= 18 && (P) <= 21) || (P) == 38) ? &PIND : \ 65 | ((((P) >= 0 && (P) <= 3) || (P) == 5) ? &PINE : \ 66 | (((P) >= 54 && (P) <= 61) ? &PINF : \ 67 | ((((P) >= 39 && (P) <= 41) || (P) == 4) ? &PING : \ 68 | ((((P) >= 6 && (P) <= 9) || (P) == 16 || (P) == 17) ? &PINH : \ 69 | (((P) == 14 || (P) == 15) ? &PINJ : \ 70 | (((P) >= 62 && (P) <= 69) ? &PINK : &PINL)))))))))) 71 | 72 | #define digitalPinToBit(P) \ 73 | (((P) >= 7 && (P) <= 9) ? (P) - 3 : \ 74 | (((P) >= 10 && (P) <= 13) ? (P) - 6 : \ 75 | (((P) >= 22 && (P) <= 29) ? (P) - 22 : \ 76 | (((P) >= 30 && (P) <= 37) ? 37 - (P) : \ 77 | (((P) >= 39 && (P) <= 41) ? 41 - (P) : \ 78 | (((P) >= 42 && (P) <= 49) ? 49 - (P) : \ 79 | (((P) >= 50 && (P) <= 53) ? 53 - (P) : \ 80 | (((P) >= 54 && (P) <= 61) ? (P) - 54 : \ 81 | (((P) >= 62 && (P) <= 69) ? (P) - 62 : \ 82 | (((P) == 0 || (P) == 15 || (P) == 17 || (P) == 21) ? 0 : \ 83 | (((P) == 1 || (P) == 14 || (P) == 16 || (P) == 20) ? 1 : \ 84 | (((P) == 19) ? 2 : \ 85 | (((P) == 5 || (P) == 6 || (P) == 18) ? 3 : \ 86 | (((P) == 2) ? 4 : \ 87 | (((P) == 3 || (P) == 4) ? 5 : 7))))))))))))))) 88 | 89 | // 15 PWM 90 | #define digitalPinToTimer(P) \ 91 | (((P) == 13 || (P) == 4) ? &TCCR0A : \ 92 | (((P) == 11 || (P) == 12) ? &TCCR1A : \ 93 | (((P) == 10 || (P) == 9) ? &TCCR2A : \ 94 | (((P) == 5 || (P) == 2 || (P) == 3) ? &TCCR3A : \ 95 | (((P) == 6 || (P) == 7 || (P) == 8) ? &TCCR4A : \ 96 | (((P) == 46 || (P) == 45 || (P) == 44) ? &TCCR5A : 0)))))) 97 | #define digitalPinToTimerBit(P) \ 98 | (((P) == 13) ? COM0A1 : (((P) == 4) ? COM0B1 : \ 99 | (((P) == 11) ? COM1A1 : (((P) == 12) ? COM1B1 : \ 100 | (((P) == 10) ? COM2A1 : (((P) == 9) ? COM2B1 : \ 101 | (((P) == 5) ? COM3A1 : (((P) == 2) ? COM3B1 : (((P) == 3) ? COM3C1 : \ 102 | (((P) == 6) ? COM4A1 : (((P) == 7) ? COM4B1 : (((P) == 8) ? COM4C1 : \ 103 | (((P) == 46) ? COM5A1 : (((P) == 45) ? COM5B1 : COM5C1)))))))))))))) 104 | 105 | #endif 106 | #endif 107 | 108 | #if !defined(digitalWriteFast) 109 | #define digitalWriteFast(P, V) \ 110 | if (__builtin_constant_p(P) && __builtin_constant_p(V)) { \ 111 | if (digitalPinToTimer(P)) \ 112 | bitClear(*digitalPinToTimer(P), digitalPinToTimerBit(P)); \ 113 | bitWrite(*digitalPinToPortReg(P), digitalPinToBit(P), (V)); \ 114 | } else { \ 115 | digitalWrite((P), (V)); \ 116 | } 117 | #endif 118 | 119 | #if !defined(pinModeFast) 120 | #define pinModeFast(P, V) \ 121 | if (__builtin_constant_p(P) && __builtin_constant_p(V)) { \ 122 | bitWrite(*digitalPinToDDRReg(P), digitalPinToBit(P), (V)); \ 123 | } else { \ 124 | pinMode((P), (V)); \ 125 | } 126 | #endif 127 | 128 | #if !defined(digitalReadFast) 129 | #define digitalReadFast(P) ( (int) __digitalReadFast__((P)) ) 130 | #define __digitalReadFast__(P ) \ 131 | (__builtin_constant_p(P) ) ? ( \ 132 | digitalPinToTimer(P) ? ( \ 133 | bitClear(*digitalPinToTimer(P), digitalPinToTimerBit(P)) , \ 134 | bitRead(*digitalPinToPINReg(P), digitalPinToBit(P))) : \ 135 | bitRead(*digitalPinToPINReg(P), digitalPinToBit(P))) : \ 136 | digitalRead((P)) 137 | #endif 138 | 139 | #if !defined(digitalWriteFast2) 140 | #define digitalWriteFast2(P, V) \ 141 | if (__builtin_constant_p(P) && __builtin_constant_p(V)) { \ 142 | bitWrite(*digitalPinToPortReg(P), digitalPinToBit(P), (V)); \ 143 | } else { \ 144 | digitalWrite((P), (V)); \ 145 | } 146 | #endif 147 | 148 | #if !defined(pinModeFast2) 149 | #define pinModeFast2(P, V) \ 150 | if (__builtin_constant_p(P) && __builtin_constant_p(V)) { \ 151 | if (digitalPinToTimer(P)) \ 152 | bitClear(*digitalPinToTimer(P), digitalPinToTimerBit(P)); \ 153 | bitWrite(*digitalPinToDDRReg(P), digitalPinToBit(P), (V)); \ 154 | } else { \ 155 | pinMode((P), (V)); \ 156 | } 157 | #endif 158 | 159 | #if !defined(digitalReadFast2) 160 | #define digitalReadFast2(P) ( (int) __digitalReadFast2__((P)) ) 161 | #define __digitalReadFast2__(P ) \ 162 | (__builtin_constant_p(P) ) ? ( \ 163 | ( bitRead(*digitalPinToPINReg(P), digitalPinToBit(P))) ) : \ 164 | digitalRead((P)) 165 | #endif 166 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | --------------------------------------------------------------------------------