Compare commits
342 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 12a4d60e18 | |||
| 5a998558a9 | |||
| f6ff0ab767 | |||
| 5d471e0f34 | |||
| d3ebc34958 | |||
| b6ff45254e | |||
| 7e348fcb5f | |||
| 06b58a9c4f | |||
| 539f3b3fe4 | |||
| 2f20df3f55 | |||
| 65c9a0728f | |||
| ab9d183024 | |||
| f5631a89e8 | |||
| a4f9e1ebf2 | |||
| 2873d67b17 | |||
| a7e40b2903 | |||
| 23b0f8ed4b | |||
| 6ed02c86be | |||
| 2a67363e27 | |||
| 205304ddee | |||
| 58bca87c72 | |||
| febeb43197 | |||
| 8178dec4c3 | |||
| 70f57a6844 | |||
| ff14199e58 | |||
| bfdf0932c1 | |||
| 695938ba3f | |||
| cb02c2f9d8 | |||
| e4a5e333ef | |||
| e10d3136c8 | |||
| 9f089756b7 | |||
| 654387297f | |||
| 326423719f | |||
| d07b6e93d5 | |||
| efcc28d347 | |||
| cfc193cdac | |||
| 24bcc9647d | |||
| bc27d809fb | |||
| bf7e453d02 | |||
| 36a746d7d5 | |||
| 50daf27e5a | |||
| df09e2adce | |||
| ddf6603d81 | |||
| 4bf8b1aeee | |||
| 7afd202b89 | |||
| ebc4601185 | |||
| c0aad4c28a | |||
| d197f8504b | |||
| eb06a886c4 | |||
| 04631d2250 | |||
| 0a5ad3ab85 | |||
| 8ac5b29e02 | |||
| 0a31ccb1d1 | |||
| c6caa45ae2 | |||
| dc566d654f | |||
| ba898faa7d | |||
| 0152ee71a5 | |||
| 348d543425 | |||
| 6ccbfeb80c | |||
| c433142abf | |||
| 1d389ad3a8 | |||
| 5bfccab650 | |||
| 9698f4ea64 | |||
| 769796ed4c | |||
| e8c92e0a95 | |||
| abf0693e8e | |||
| 47319cf64e | |||
| e358a2d7af | |||
| 044a64a1fb | |||
| cd91e0e3e1 | |||
| d728e35658 | |||
| dcd3e8a211 | |||
| ddd9d0cfd4 | |||
| 0e58ef6805 | |||
| 0e89022cc3 | |||
| 47d4f55bc0 | |||
| 6cd150842f | |||
| 299c18596f | |||
| b86336c3f5 | |||
| b69e75c89a | |||
| 825adbd67b | |||
| 1d224cc031 | |||
| 06c03fe2f0 | |||
| 87ff61a8a6 | |||
| 8c94ad0d26 | |||
| aacbebbebe | |||
| 31873ec707 | |||
| de0448343f | |||
| 69961dbba3 | |||
| f67feea093 | |||
| 6c050b8440 | |||
| b9f9f8f7d3 | |||
| d38b96fff1 | |||
| 9f7f7354f5 | |||
| d3b8edb6a2 | |||
| aee475aa55 | |||
| 9083966c22 | |||
| 5406c533db | |||
| f92dc91c3d | |||
| 35a1dd081f | |||
| 5131ab19ca | |||
| 96f4f90cb3 | |||
| e10355500d | |||
| a97c006bbf | |||
| f062794a0d | |||
| 57468d3c21 | |||
| 22aae62ccd | |||
| 6b45e9f167 | |||
| adee81170d | |||
| 1dba212e18 | |||
| 7bb326d389 | |||
| 957e966d2d | |||
| faccb35850 | |||
| 3f15b7c7b8 | |||
| 0c35facc94 | |||
| 71404eef29 | |||
| a873541ef6 | |||
| 50cde90324 | |||
| 603a5e25b3 | |||
| 538189cc19 | |||
| 686011a548 | |||
| cd57bf305b | |||
| ea2c19f978 | |||
| aa65fe22ed | |||
| 12de8fff81 | |||
| b67dacdc8f | |||
| d3002ef741 | |||
| 0c123950e9 | |||
| bf077125b9 | |||
| 88d2a671cc | |||
| 0e5e249ab5 | |||
| e792d62f47 | |||
| 6b14f95b3e | |||
| c7ce99d495 | |||
| b7fc14bc65 | |||
| 9e1021efbe | |||
| e9bec9b6fe | |||
| fbd282b3ba | |||
| 2e8c5049c5 | |||
| 2d0d8e5272 | |||
| 4d7fe7115f | |||
| 9e9db65c3f | |||
| bd966ef389 | |||
| 775da3f103 | |||
| 96a4baa0be | |||
| 2aa9f7b131 | |||
| c4490f5f3d | |||
| dd9144994e | |||
| 4c37d0d9f1 | |||
| b59724e42b | |||
| 16413bb8f2 | |||
| b3941fce5c | |||
| d494688565 | |||
| 516ec90242 | |||
| 7244aa7eb7 | |||
| de2ca3b2e8 | |||
| c2fc466e1b | |||
| 241f5a4c0e | |||
| 9f9f498491 | |||
| e31bef31ad | |||
| b2a9ccdb97 | |||
| d459fb41b7 | |||
| 804e0d6117 | |||
| bb499421e9 | |||
| ba96059203 | |||
| fbd91ab0b5 | |||
| b51c06e2b3 | |||
| 159ae90874 | |||
| e48f5aa6a7 | |||
| 1efe9ab497 | |||
| 602c8ee02b | |||
| 279d00da9f | |||
| 830972ce3c | |||
| 451f9cc6d1 | |||
| e3fe1f0d00 | |||
| d88205d89d | |||
| 5aa80e6c05 | |||
| b657a18449 | |||
| 108011085b | |||
| d188ae4c9d | |||
| 3682d9bd5b | |||
| 032df0b2c6 | |||
| bd1ad7c76a | |||
| 060b38de5c | |||
| 789ba02d43 | |||
| 1874cb71a6 | |||
| 6a5a34e0ff | |||
| e3821bd86f | |||
| 02af69911e | |||
| e203b8c754 | |||
| 362ddc4efc | |||
| 58cad83253 | |||
| c27081aa4a | |||
| e11e072eca | |||
| 8e68c6cf89 | |||
| 8503b78876 | |||
| 8446c9dc92 | |||
| 3eacb4c16d | |||
| e4d2138dbd | |||
| 464b755918 | |||
| 44fd8d46d2 | |||
| 33bb044d7c | |||
| ffea8008ca | |||
| c2557abc03 | |||
| 67cf105bc6 | |||
| 8aee9d51b6 | |||
| 939f1fab46 | |||
| 414408b2d0 | |||
| 77d503fa13 | |||
| cf7c8c458f | |||
| 325f0651ac | |||
| 03b0850e63 | |||
| 2a019a53d2 | |||
| ad8bc71d3e | |||
| 46feae79c6 | |||
| 4ca2f336f0 | |||
| ae0bf8068b | |||
| 0c1b863755 | |||
| 63aec3c56e | |||
| 8b785f75a6 | |||
| 5b8758f42b | |||
| 520f1a54a8 | |||
| 5550e893d5 | |||
| aa6e6e914e | |||
| 0183e6332a | |||
| 1532200435 | |||
| 7f775c142c | |||
| b985e4a134 | |||
| 2e749d60c3 | |||
| 33f5697888 | |||
| b44055cc51 | |||
| f5eae52098 | |||
| 19a47dae4a | |||
| 910f4e77a2 | |||
| 7cefad3744 | |||
| 87ff2f8867 | |||
| 387fe51a56 | |||
| 421264e58a | |||
| 15ad923310 | |||
| 61e09e6be2 | |||
| 87c4e06c24 | |||
| 7b1e295f34 | |||
| c077316b2b | |||
| 49b228c4b3 | |||
| 96509494f0 | |||
| 6d7e6a11fc | |||
| f3095493b0 | |||
| ce07c9186d | |||
| 116dc86b8a | |||
| 02ee9e3d30 | |||
| e056bf8081 | |||
| 4deeffbc88 | |||
| 632528aa95 | |||
| aac7aa3bf0 | |||
| fde51084f3 | |||
| 21e2bae063 | |||
| e509bbf636 | |||
| 072011a3ef | |||
| 2422a857a1 | |||
| f598077af3 | |||
| cb0c84e075 | |||
| 1d5809d458 | |||
| ed951b1977 | |||
| 4879de08e8 | |||
| f278e1c00f | |||
| 046a8e0039 | |||
| 79a466ca26 | |||
| 5f3a422e68 | |||
| fa2e3a40e9 | |||
| a92b3afe64 | |||
| 9fa586bbed | |||
| 00d33e6b82 | |||
| 7d124478fa | |||
| 3d83109028 | |||
| cb02914687 | |||
| 10bf2bb8e1 | |||
| d47b666630 | |||
| 88d289caa1 | |||
| b4833d55c2 | |||
| c6f2ec3c82 | |||
| b48d67ce10 | |||
| 071eec7aa7 | |||
| 1ebe7d1ab6 | |||
| de37b2264a | |||
| b65ef8d66c | |||
| 740f0c7690 | |||
| ba8500a236 | |||
| 09469add55 | |||
| f3101e96d9 | |||
| 245dca4bee | |||
| 97d42ca2b2 | |||
| 2faa0852b9 | |||
| 7b14953c99 | |||
| 286d5003fa | |||
| 66d50562b6 | |||
| 27f595a444 | |||
| 018c567abf | |||
| 4fbda5c3f5 | |||
| ce714fe306 | |||
| 35e57bf149 | |||
| 84ea2d61e8 | |||
| adc108d79e | |||
| 5aa9c41ab1 | |||
| 00690f7ffd | |||
| 01d28c18ab | |||
| 2fd8c248fe | |||
| d9f2f509d5 | |||
| ae3e7586c6 | |||
| df1437bd86 | |||
| 8816ef1c64 | |||
| d298dd121f | |||
| 2cc9a89830 | |||
| a0a1f81913 | |||
| 8a8ea50f33 | |||
| b976692d0f | |||
| fe940a142d | |||
| b3fb09a20c | |||
| 6a3f8cf23f | |||
| a05a261b72 | |||
| 1b6765ed12 | |||
| 1ff99ae25f | |||
| 234fe8ea67 | |||
| e661578c84 | |||
| 73344e69c1 | |||
| d309565b56 | |||
| 3f20f37c78 | |||
| 0e3631ff4b | |||
| b447815de5 | |||
| bde30b2b48 | |||
| 4cc8e37bf1 | |||
| b5fae1104b | |||
| 25cd8af536 | |||
| 14702089ee | |||
| b51e8bf7e5 | |||
| 3183a14755 | |||
| 5edef148fe | |||
| 13e2ad2831 | |||
| 59cc5f889e | |||
| a11f3b2d2f | |||
| b0070a244a | |||
| c9005865ed | |||
| 1022a5eaa7 |
@@ -1 +1,5 @@
|
||||
*.o
|
||||
applet/
|
||||
*~
|
||||
*.orig
|
||||
*.rej
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
*.o
|
||||
*.~
|
||||
applet/
|
||||
+173
-157
@@ -1,23 +1,6 @@
|
||||
#ifndef CONFIGURATION_H
|
||||
#define CONFIGURATION_H
|
||||
|
||||
// Uncomment ONE of the next three lines - the one for your RepRap machine
|
||||
//#define REPRAPPRO_HUXLEY
|
||||
#define REPRAPPRO_MENDEL
|
||||
//#define REPRAPPRO_WALLACE
|
||||
|
||||
#ifndef REPRAPPRO_HUXLEY
|
||||
#ifndef REPRAPPRO_MENDEL
|
||||
#ifndef REPRAPPRO_WALLACE
|
||||
#error Uncomment one of #define REPRAPPRO_HUXLEY, REPRAPPRO_MENDEL or REPRAPPRO_WALLACE at the start of the file Configuration.h
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Uncomment this if you are experimenting, know what you are doing, and want to switch off some safety
|
||||
// features, e.g. allow extrude at low temperature etc.
|
||||
//#define DEVELOPING
|
||||
|
||||
// This configurtion file contains the basic settings.
|
||||
// Advanced settings can be found in Configuration_adv.h
|
||||
// BASIC SETTINGS: select your board type, temperature sensor type, axis scaling, and endstop configuration
|
||||
@@ -25,8 +8,13 @@
|
||||
//User specified version info of THIS file to display in [Pronterface, etc] terminal window during startup.
|
||||
//Implementation of an idea by Prof Braino to inform user that any changes made
|
||||
//to THIS file by the user have been successfully uploaded into firmware.
|
||||
#define STRING_VERSION_CONFIG_H "2012-06-03-1" //Personal revision number for changes to THIS file.
|
||||
#define STRING_CONFIG_H_AUTHOR "RepRapPro" //Who made the changes.
|
||||
#define STRING_VERSION_CONFIG_H "2012-05-02" //Personal revision number for changes to THIS file.
|
||||
#define STRING_CONFIG_H_AUTHOR "erik" //Who made the changes.
|
||||
|
||||
// SERIAL_PORT selects which serial port should be used for communication with the host.
|
||||
// This allows the connection of wireless adapters (for instance) to non-default port pins.
|
||||
// Serial port 0 is still used by the Arduino bootloader regardless of this setting.
|
||||
#define SERIAL_PORT 0
|
||||
|
||||
// This determines the communication speed of the printer
|
||||
#define BAUDRATE 250000
|
||||
@@ -43,59 +31,24 @@
|
||||
// Gen6 = 5
|
||||
// Gen6 deluxe = 51
|
||||
// Sanguinololu 1.2 and above = 62
|
||||
// Melzi 63
|
||||
// Melzi = 63
|
||||
// Ultimaker = 7
|
||||
// Teensylu = 8
|
||||
// Gen3+ =9
|
||||
#define MOTHERBOARD 63
|
||||
|
||||
//===========================================================================
|
||||
//=============================Thermal Settings ============================
|
||||
//===========================================================================
|
||||
|
||||
// Set this if you want to define the constants in the thermistor circuit
|
||||
// and work out temperatures algebraically - added by AB.
|
||||
//#define COMPUTE_THERMISTORS
|
||||
|
||||
#ifdef COMPUTE_THERMISTORS
|
||||
|
||||
// See http://en.wikipedia.org/wiki/Thermistor#B_or_.CE.B2_parameter_equation
|
||||
|
||||
// BETA is the B value
|
||||
// RS is the value of the series resistor in ohms
|
||||
// R_INF is R0.exp(-BETA/T0), where R0 is the thermistor resistance at T0 (T0 is in kelvin)
|
||||
// Normally T0 is 298.15K (25 C). If you write that expression in brackets in the #define the compiler
|
||||
// should compute it for you (i.e. it won't need to be calculated at run time).
|
||||
|
||||
// If the A->D converter has a range of 0..1023 and the measured voltage is V (between 0 and 1023)
|
||||
// then the thermistor resistance, R = V.RS/(1023 - V)
|
||||
// and the temperature, T = BETA/ln(R/R_INF)
|
||||
// To get degrees celsius (instead of kelvin) add -273.15 to T
|
||||
|
||||
// This DOES assume that all extruders use the same thermistor type.
|
||||
|
||||
#define ABS_ZERO -273.15
|
||||
#define AD_RANGE 16383
|
||||
|
||||
// RS 198-961
|
||||
#define E_BETA 3960.0
|
||||
#define E_RS 4700.0
|
||||
#define E_R_INF ( 100000.0*exp(-E_BETA/298.15) )
|
||||
|
||||
// RS 484-0149; EPCOS B57550G103J
|
||||
#define BED_BETA 3480.0
|
||||
#define BED_RS 4700.0
|
||||
#define BED_R_INF ( 10000.0*exp(-BED_BETA/298.15) )
|
||||
|
||||
#define BED_USES_THERMISTOR
|
||||
#define HEATER_0_USES_THERMISTOR
|
||||
//#define HEATER_1_USES_THERMISTOR
|
||||
//#define HEATER_2_USES_THERMISTOR
|
||||
// Megatronics =70
|
||||
|
||||
#ifndef MOTHERBOARD
|
||||
#define MOTHERBOARD 7
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//=============================Thermal Settings ============================
|
||||
//===========================================================================
|
||||
//
|
||||
//--NORMAL IS 4.7kohm PULLUP!-- 1kohm pullup can be used on hotend sensor, using correct resistor and table
|
||||
//
|
||||
//// Temperature sensor settings:
|
||||
// -2 is thermocouple with MAX6675 (only for sensor 0)
|
||||
// -1 is thermocouple with AD595
|
||||
@@ -104,97 +57,156 @@
|
||||
// 2 is 200k thermistor - ATC Semitec 204GT-2 (4.7k pullup)
|
||||
// 3 is mendel-parts thermistor (4.7k pullup)
|
||||
// 4 is 10k thermistor !! do not use it for a hotend. It gives bad resolution at high temp. !!
|
||||
// 5 is ParCan supplied 104GT-2 100K
|
||||
// 6 is EPCOS 100k
|
||||
// 7 is 100k Honeywell thermistor 135-104LAG-J01
|
||||
// 100 is 100k GE Sensing AL03006-58.2K-97-G1 with r2=4k7
|
||||
// 101 is 100k 0603 SMD Vishay NTCS0603E3104FXT with r2=4k7
|
||||
// 102 is 100k EPCOS G57540 Nozzle with r2=4k7
|
||||
// 103 is 100k EPCOS G57540 Bed with r2=4k7
|
||||
// 104 is 10k G57540 Bed with r2=4k7
|
||||
// 105 is 10k G57540 Bed with r2=10k
|
||||
// 110 is 100k RS thermistor 198-961 hot end with 10K resistor
|
||||
// 5 is 100K thermistor - ATC Semitec 104GT-2 (Used in ParCan) (4.7k pullup)
|
||||
// 6 is 100k EPCOS - Not as accurate as table 1 (created using a fluke thermocouple) (4.7k pullup)
|
||||
// 7 is 100k Honeywell thermistor 135-104LAG-J01 (4.7k pullup)
|
||||
//
|
||||
// 1k ohm pullup tables - This is not normal, you would have to have changed out your 4.7k for 1k
|
||||
// (but gives greater accuracy and more stable PID)
|
||||
// 51 is 100k thermistor - EPCOS (1k pullup)
|
||||
// 52 is 200k thermistor - ATC Semitec 204GT-2 (1k pullup)
|
||||
// 55 is 100k thermistor - ATC Semitec 104GT-2 (Used in ParCan) (1k pullup)
|
||||
|
||||
#define TEMP_SENSOR_0 110
|
||||
#define TEMP_SENSOR_0 -1
|
||||
#define TEMP_SENSOR_1 0
|
||||
#define TEMP_SENSOR_2 0
|
||||
#define TEMP_SENSOR_BED 105
|
||||
#define TEMP_SENSOR_BED 0
|
||||
|
||||
// Actual temperature must be close to target for this long before M109 returns success
|
||||
#define TEMP_RESIDENCY_TIME 10 // (seconds)
|
||||
#define TEMP_HYSTERESIS 5 // (C°) range of +/- temperatures considered "close" to the target one
|
||||
#define TEMP_WINDOW 2 // (degC) Window around target to start the recidency timer x degC early.
|
||||
#define TEMP_RESIDENCY_TIME 10 // (seconds)
|
||||
#define TEMP_HYSTERESIS 3 // (degC) range of +/- temperatures considered "close" to the target one
|
||||
#define TEMP_WINDOW 1 // (degC) Window around target to start the recidency timer x degC early.
|
||||
|
||||
// The minimal temperature defines the temperature below which the heater will not be enabled It is used
|
||||
// to check that the wiring to the thermistor is not broken.
|
||||
// Otherwise this would lead to the heater being powered on all the time.
|
||||
#define HEATER_0_MINTEMP 1
|
||||
//#define HEATER_1_MINTEMP 5
|
||||
//#define HEATER_2_MINTEMP 5
|
||||
#define BED_MINTEMP 1
|
||||
#define HEATER_0_MINTEMP 5
|
||||
#define HEATER_1_MINTEMP 5
|
||||
#define HEATER_2_MINTEMP 5
|
||||
#define BED_MINTEMP 5
|
||||
|
||||
// When temperature exceeds max temp, your heater will be switched off.
|
||||
// This feature exists to protect your hotend from overheating accidentally, but *NOT* from thermistor short/failure!
|
||||
// You should use MINTEMP for thermistor short/failure protection.
|
||||
#define HEATER_0_MAXTEMP 399
|
||||
//#define HEATER_1_MAXTEMP 275
|
||||
//#define HEATER_2_MAXTEMP 275
|
||||
#define HEATER_0_MAXTEMP 275
|
||||
#define HEATER_1_MAXTEMP 275
|
||||
#define HEATER_2_MAXTEMP 275
|
||||
#define BED_MAXTEMP 150
|
||||
|
||||
// If your bed has low resistance e.g. .6 ohm and throws the fuse you can duty cycle it to reduce the
|
||||
// average current. The value should be an integer and the heat bed will be turned on for 1 interval of
|
||||
// HEATER_BED_DUTY_CYCLE_DIVIDER intervals.
|
||||
//#define HEATER_BED_DUTY_CYCLE_DIVIDER 4
|
||||
|
||||
// PID settings:
|
||||
// Comment the following line to disable PID and enable bang-bang.
|
||||
#define PIDTEMP
|
||||
#define PID_MAX 255 // limits current to nozzle; 255=full current
|
||||
#define FULL_PID_BAND 150 // Full power is applied when pid_error[e] > FULL_PID_BAND
|
||||
#ifdef PIDTEMP
|
||||
//#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_INTEGRAL_DRIVE_MAX 100 //limit for the integral term
|
||||
//#define PID_OPENLOOP 1 // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX
|
||||
#define PID_INTEGRAL_DRIVE_MAX 255 //limit for the integral term
|
||||
#define K1 0.95 //smoothing factor withing the PID
|
||||
#define PID_dT 0.122 //sampling period of the PID
|
||||
#define PID_dT ((16.0 * 8.0)/(F_CPU / 64.0 / 256.0)) //sampling period of the
|
||||
|
||||
// If you are using a preconfigured hotend then you can use one of the value sets by uncommenting it
|
||||
// Ultimaker
|
||||
// #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.08
|
||||
#define DEFAULT_Kd 114
|
||||
|
||||
// Makergear
|
||||
// #define DEFAULT_Kp 7.0
|
||||
// #define DEFAULT_Ki 0.1
|
||||
// #define DEFAULT_Kd 12
|
||||
|
||||
// RepRapPro Huxley + Mendel
|
||||
#define DEFAULT_Kp 3.0
|
||||
#define DEFAULT_Ki (2*PID_dT)
|
||||
#define DEFAULT_Kd (80/PID_dT)
|
||||
|
||||
// Mendel Parts V9 on 12V
|
||||
// #define DEFAULT_Kp 63.0
|
||||
// #define DEFAULT_Ki (2.25*PID_dT)
|
||||
// #define DEFAULT_Kd (440/PID_dT)
|
||||
// #define DEFAULT_Kp 63.0
|
||||
// #define DEFAULT_Ki 2.25
|
||||
// #define DEFAULT_Kd 440
|
||||
#endif // PIDTEMP
|
||||
|
||||
#ifndef DEVELOPING
|
||||
// Bed Temperature Control
|
||||
// Select PID or bang-bang with PIDTEMPBED. If bang-bang, BED_LIMIT_SWITCHING will enable hysteresis
|
||||
//
|
||||
// uncomment this to enable PID on the bed. It uses the same ferquency PWM as the extruder.
|
||||
// If your PID_dT above is the default, and correct for your hardware/configuration, that means 7.689Hz,
|
||||
// which is fine for driving a square wave into a resistive load and does not significantly impact you FET heating.
|
||||
// This also works fine on a Fotek SSR-10DA Solid State Relay into a 250W heater.
|
||||
// If your configuration is significantly different than this and you don't understand the issues involved, you proabaly
|
||||
// shouldn't use bed PID until someone else verifies your hardware works.
|
||||
// If this is enabled, find your own PID constants below.
|
||||
//#define PIDTEMPBED
|
||||
//
|
||||
//#define BED_LIMIT_SWITCHING
|
||||
|
||||
// This sets the max power delived to the bed, and replaces the HEATER_BED_DUTY_CYCLE_DIVIDER option.
|
||||
// all forms of bed control obey this (PID, bang-bang, bang-bang with hysteresis)
|
||||
// setting this to anything other than 255 enables a form of PWM to the bed just like HEATER_BED_DUTY_CYCLE_DIVIDER did,
|
||||
// so you shouldn't use it unless you are OK with PWM on your bed. (see the comment on enabling PIDTEMPBED)
|
||||
#define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current
|
||||
|
||||
#ifdef PIDTEMPBED
|
||||
//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
|
||||
//from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, argressive factor of .15 (vs .1, 1, 10)
|
||||
#define DEFAULT_bedKp 10.00
|
||||
#define DEFAULT_bedKi .023
|
||||
#define DEFAULT_bedKd 305.4
|
||||
|
||||
//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
|
||||
//from pidautotune
|
||||
// #define DEFAULT_bedKp 97.1
|
||||
// #define DEFAULT_bedKi 1.41
|
||||
// #define DEFAULT_bedKd 1675.16
|
||||
|
||||
// FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles.
|
||||
#endif // PIDTEMPBED
|
||||
|
||||
|
||||
|
||||
//this prevents dangerous Extruder moves, i.e. if the temperature is under the limit
|
||||
//can be software-disabled for whatever purposes by
|
||||
#define PREVENT_DANGEROUS_EXTRUDE
|
||||
//if PREVENT_DANGEROUS_EXTRUDE is on, you can still disable (uncomment) very long bits of extrusion separately.
|
||||
#define PREVENT_LENGTHY_EXTRUDE
|
||||
|
||||
#define EXTRUDE_MINTEMP 170
|
||||
#define EXTRUDE_MAXLENGTH (X_MAX_LENGTH+Y_MAX_LENGTH) //prevent extrusion of very large distances.
|
||||
#endif
|
||||
|
||||
//===========================================================================
|
||||
//=============================Mechanical Settings===========================
|
||||
//===========================================================================
|
||||
|
||||
// Endstop Settings
|
||||
// Uncomment the following line to enable CoreXY kinematics
|
||||
// #define COREXY
|
||||
|
||||
// corse Endstop Settings
|
||||
#define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors
|
||||
|
||||
#ifndef ENDSTOPPULLUPS
|
||||
// fine Enstop settings: Individual Pullups. will be ignord if ENDSTOPPULLUPS is defined
|
||||
#define ENDSTOPPULLUP_XMAX
|
||||
#define ENDSTOPPULLUP_YMAX
|
||||
#define ENDSTOPPULLUP_ZMAX
|
||||
#define ENDSTOPPULLUP_XMIN
|
||||
#define ENDSTOPPULLUP_YMIN
|
||||
//#define ENDSTOPPULLUP_ZMIN
|
||||
#endif
|
||||
|
||||
#ifdef ENDSTOPPULLUPS
|
||||
#define ENDSTOPPULLUP_XMAX
|
||||
#define ENDSTOPPULLUP_YMAX
|
||||
#define ENDSTOPPULLUP_ZMAX
|
||||
#define ENDSTOPPULLUP_XMIN
|
||||
#define ENDSTOPPULLUP_YMIN
|
||||
#define ENDSTOPPULLUP_ZMIN
|
||||
#endif
|
||||
|
||||
// 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.
|
||||
//#define DISABLE_MAX_ENDSTOPS
|
||||
|
||||
// For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
|
||||
#define X_ENABLE_ON 0
|
||||
@@ -205,15 +217,15 @@ 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
|
||||
|
||||
#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 false // for Mendel set to false, for Orca set to true
|
||||
#define INVERT_E0_DIR true // 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_E2_DIR true // for direct drive extruder v9 set to true, for geared extruder 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 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:
|
||||
// Sets direction of endstops when homing; 1=MAX, -1=MIN
|
||||
@@ -221,54 +233,46 @@ 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 true //If true, axis won't move to coordinates less than zero.
|
||||
#define min_software_endstops true //If true, axis won't move to coordinates less than HOME_POS.
|
||||
#define max_software_endstops true //If true, axis won't move to coordinates greater than the defined lengths below.
|
||||
// Travel limits after homing
|
||||
#define X_MAX_POS 205
|
||||
#define X_MIN_POS 0
|
||||
#define Y_MAX_POS 205
|
||||
#define Y_MIN_POS 0
|
||||
#define Z_MAX_POS 200
|
||||
#define Z_MIN_POS 0
|
||||
|
||||
// The position of the homing switches. Use MAX_LENGTH * -0.5 if the center should be 0, 0, 0
|
||||
#define X_HOME_POS 0
|
||||
#define Y_HOME_POS 0
|
||||
#define Z_HOME_POS 0
|
||||
#define X_MAX_LENGTH (X_MAX_POS - X_MIN_POS)
|
||||
#define Y_MAX_LENGTH (Y_MAX_POS - Y_MIN_POS)
|
||||
#define Z_MAX_LENGTH (Z_MAX_POS - Z_MIN_POS)
|
||||
|
||||
// The position of the homing switches
|
||||
//#define MANUAL_HOME_POSITIONS // If defined, manualy programed locations will be used
|
||||
//#define BED_CENTER_AT_0_0 // If defined the center of the bed is defined as (0,0)
|
||||
|
||||
//Manual homing switch locations:
|
||||
#define MANUAL_X_HOME_POS 0
|
||||
#define MANUAL_Y_HOME_POS 0
|
||||
#define MANUAL_Z_HOME_POS 0
|
||||
|
||||
//// MOVEMENT SETTINGS
|
||||
#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
|
||||
|
||||
#ifdef REPRAPPRO_MENDEL
|
||||
|
||||
#define X_MAX_LENGTH 210
|
||||
#define Y_MAX_LENGTH 210
|
||||
#define Z_MAX_LENGTH 100
|
||||
#define HOMING_FEEDRATE {10*60, 10*60, 1*60, 0} // set the homing speeds (mm/min)
|
||||
#define FAST_HOME_FEEDRATE {50*60, 50*60, 1*60, 0} // set the homing speeds (mm/min)
|
||||
#define DEFAULT_MAX_FEEDRATE {500, 500, 3, 45}
|
||||
#define DEFAULT_MAX_FEEDRATE {300, 300, 3, 45} // (mm/sec)
|
||||
#define DEFAULT_MAX_ACCELERATION {800,800,30,250} // X, Y, Z, E maximum start speed for accelerated moves. E default values
|
||||
|
||||
#else
|
||||
|
||||
#define X_MAX_LENGTH 150
|
||||
#define Y_MAX_LENGTH 148
|
||||
#define Z_MAX_LENGTH 100
|
||||
#define HOMING_FEEDRATE {10*60, 10*60, 1*60, 0} // set the homing speeds (mm/min)
|
||||
#define FAST_HOME_FEEDRATE {80*60, 80*60, 4*60, 0} // set the homing speeds (mm/min)
|
||||
#define DEFAULT_MAX_FEEDRATE {500, 500, 5, 45} // (mm/sec)
|
||||
#define DEFAULT_MAX_FEEDRATE {500, 500, 5, 45} // (mm/sec)
|
||||
#define DEFAULT_MAX_ACCELERATION {1000,1000,50,250} // X, Y, Z, E maximum start speed for accelerated moves. E default values
|
||||
|
||||
#endif
|
||||
|
||||
#define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0} // set the homing speeds (mm/min)
|
||||
|
||||
// default settings
|
||||
|
||||
#define DEFAULT_AXIS_STEPS_PER_UNIT {91.4286, 91.4286,4000,875} // default steps per unit for ultimaker
|
||||
#define DEFAULT_AXIS_STEPS_PER_UNIT {78.7402,78.7402,200*8/3,760*1.1} // default steps per unit for ultimaker
|
||||
#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.
|
||||
|
||||
|
||||
#define DEFAULT_ACCELERATION 1000 // X, Y, Z and E max acceleration in mm/s^2 for printing moves
|
||||
#define DEFAULT_RETRACT_ACCELERATION 1000 // X, Y, Z and E max acceleration in mm/s^2 for r retracts
|
||||
#define DEFAULT_ACCELERATION 3000 // X, Y, Z and E max acceleration in mm/s^2 for printing moves
|
||||
#define DEFAULT_RETRACT_ACCELERATION 3000 // X, Y, Z and E max acceleration in mm/s^2 for r retracts
|
||||
|
||||
//
|
||||
#define DEFAULT_XYJERK 15.0 // (mm/sec)
|
||||
#define DEFAULT_XYJERK 20.0 // (mm/sec)
|
||||
#define DEFAULT_ZJERK 0.4 // (mm/sec)
|
||||
#define DEFAULT_EJERK 15.0 // (mm/sec)
|
||||
#define DEFAULT_EJERK 5.0 // (mm/sec)
|
||||
|
||||
//===========================================================================
|
||||
//=============================Additional Features===========================
|
||||
@@ -280,23 +284,32 @@ const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of t
|
||||
// M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
|
||||
// M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
|
||||
//define this to enable eeprom support
|
||||
#define EEPROM_SETTINGS
|
||||
//#define EEPROM_SETTINGS
|
||||
//to disable EEPROM Serial responses and decrease program space by ~1700 byte: comment this out:
|
||||
// please keep turned on if you can.
|
||||
#define EEPROM_CHITCHAT
|
||||
//#define EEPROM_CHITCHAT
|
||||
|
||||
//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 ULTIMAKERCONTROLLER //as available from the ultimaker online store.
|
||||
//#define ULTIPANEL //the ultipanel as on thingiverse
|
||||
|
||||
|
||||
#ifdef ULTIMAKERCONTROLLER //automatic expansion
|
||||
#define ULTIPANEL
|
||||
#define NEWPANEL
|
||||
#endif
|
||||
|
||||
|
||||
//#define ULTIPANEL
|
||||
#ifdef ULTIPANEL
|
||||
//#define NEWPANEL //enable this if you have a click-encoder panel
|
||||
// #define NEWPANEL //enable this if you have a click-encoder panel
|
||||
#define SDSUPPORT
|
||||
#define ULTRA_LCD
|
||||
#define LCD_WIDTH 20
|
||||
#define LCD_HEIGHT 4
|
||||
|
||||
|
||||
// Preheat Constants
|
||||
#define PLA_PREHEAT_HOTEND_TEMP 180
|
||||
#define PLA_PREHEAT_HPB_TEMP 70
|
||||
@@ -309,17 +322,20 @@ const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of t
|
||||
#else //no panel but just lcd
|
||||
#ifdef ULTRA_LCD
|
||||
#define LCD_WIDTH 16
|
||||
#define LCD_HEIGHT 2
|
||||
#define LCD_HEIGHT 2
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Enable uM-FPU support:
|
||||
#define UMFPUSUPPORT 1
|
||||
// Increase the FAN pwm frequency. Removes the PWM noise but increases heating in the FET/Arduino
|
||||
//#define FAST_PWM_FAN
|
||||
|
||||
// M240 Triggers a camera by emulating a Canon RC-1 Remote
|
||||
// Data from: http://www.doc-diy.net/photo/rc-1_hacked/
|
||||
// #define PHOTOGRAPH_PIN 23
|
||||
|
||||
// SF send wrong arc g-codes when using Arc Point as fillet procedure
|
||||
//#define SF_ARC_FIX
|
||||
|
||||
#include "Configuration_adv.h"
|
||||
#include "thermistortables.h"
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef CONFIG_STORE_H
|
||||
#define CONFIG_STORE_H
|
||||
|
||||
#include "Configuration.h"
|
||||
|
||||
#ifdef EEPROM_SETTINGS
|
||||
void Config_StoreSettings();
|
||||
void Config_RetrieveSettings();
|
||||
#else
|
||||
FORCE_INLINE void Config_StoreSettings() {}
|
||||
FORCE_INLINE void Config_RetrieveSettings() {}
|
||||
#endif
|
||||
|
||||
#ifdef EEPROM_CHITCHAT
|
||||
void Config_PrintSettings();
|
||||
#else
|
||||
FORCE_INLINE void Config_PrintSettings() {}
|
||||
#endif
|
||||
|
||||
void Config_ResetDefault();
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+102
-31
@@ -5,13 +5,10 @@
|
||||
//=============================Thermal Settings ============================
|
||||
//===========================================================================
|
||||
|
||||
// Select one of these only to define how the bed temp is read.
|
||||
//
|
||||
//#define BED_LIMIT_SWITCHING
|
||||
#ifdef BED_LIMIT_SWITCHING
|
||||
#define BED_HYSTERESIS 2 //only disable heating if T>target+BED_HYSTERESIS and enable heating if T>target-BED_HYSTERESIS
|
||||
#endif
|
||||
#define BED_CHECK_INTERVAL 5000 //ms
|
||||
#define BED_CHECK_INTERVAL 5000 //ms between checks in bang-bang control
|
||||
|
||||
//// Heating sanity check:
|
||||
// This waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
|
||||
@@ -28,7 +25,7 @@
|
||||
#ifdef PIDTEMP
|
||||
// this adds an experimental additional term to the heatingpower, proportional to the extrusion speed.
|
||||
// if Kc is choosen well, the additional required power due to increased melting should be compensated.
|
||||
//#define PID_ADD_EXTRUSION_RATE
|
||||
#define PID_ADD_EXTRUSION_RATE
|
||||
#ifdef PID_ADD_EXTRUSION_RATE
|
||||
#define DEFAULT_Kc (1) //heatingpower=Kc*(e_speed)
|
||||
#endif
|
||||
@@ -41,8 +38,8 @@
|
||||
// the target temperature is set to mintemp+factor*se[steps/sec] and limited by mintemp and maxtemp
|
||||
// you exit the value by any M109 without F*
|
||||
// Also, if the temperature is set to a value <mintemp, it is not changed by autotemp.
|
||||
// on an ultimaker, some initial testing worked with M109 S215 T260 F0.1 in the start.gcode
|
||||
//#define AUTOTEMP
|
||||
// on an ultimaker, some initial testing worked with M109 S215 B260 F1 in the start.gcode
|
||||
#define AUTOTEMP
|
||||
#ifdef AUTOTEMP
|
||||
#define AUTOTEMP_OLDWEIGHT 0.98
|
||||
#endif
|
||||
@@ -50,7 +47,7 @@
|
||||
// extruder run-out prevention.
|
||||
//if the machine is idle, and the temperature over MINTEMP, every couple of SECONDS some filament is extruded
|
||||
//#define EXTRUDER_RUNOUT_PREVENT
|
||||
#define EXTRUDER_RUNOUT_MINTEMP 175
|
||||
#define EXTRUDER_RUNOUT_MINTEMP 190
|
||||
#define EXTRUDER_RUNOUT_SECONDS 30.
|
||||
#define EXTRUDER_RUNOUT_ESTEPS 14. //mm filament
|
||||
#define EXTRUDER_RUNOUT_SPEED 1500. //extrusion speed
|
||||
@@ -74,22 +71,85 @@
|
||||
// This defines the number of extruders
|
||||
#define EXTRUDERS 1
|
||||
|
||||
#define Z_INCREMENT .0040 //Probe Movement Increment - 1 Full step on Huxley = 1/250
|
||||
#define PROBE_N 3
|
||||
|
||||
#define ENDSTOPS_ONLY_FOR_HOMING // If defined the endstops will only be used for homing
|
||||
|
||||
|
||||
//// AUTOSET LOCATIONS OF LIMIT SWITCHES
|
||||
//// Added by ZetaPhoenix 09-15-2012
|
||||
#ifdef MANUAL_HOME_POSITION //Use manual limit switch locations
|
||||
#define X_HOME_POS MANUAL_X_HOME_POS
|
||||
#define Y_HOME_POS MANUAL_Y_HOME_POS
|
||||
#define Z_HOME_POS MANUAL_Z_HOME_POS
|
||||
#else //Set min/max homing switch positions based upon homing direction and min/max travel limits
|
||||
//X axis
|
||||
#if X_HOME_DIR == -1
|
||||
#ifdef BED_CENTER_AT_0_0
|
||||
#define X_HOME_POS X_MAX_LENGTH * -0.5
|
||||
#else
|
||||
#define X_HOME_POS X_MIN_POS
|
||||
#endif //BED_CENTER_AT_0_0
|
||||
#else
|
||||
#ifdef BED_CENTER_AT_0_0
|
||||
#define X_HOME_POS X_MAX_LENGTH * 0.5
|
||||
#else
|
||||
#define X_HOME_POS X_MAX_POS
|
||||
#endif //BED_CENTER_AT_0_0
|
||||
#endif //X_HOME_DIR == -1
|
||||
|
||||
//Y axis
|
||||
#if Y_HOME_DIR == -1
|
||||
#ifdef BED_CENTER_AT_0_0
|
||||
#define Y_HOME_POS Y_MAX_LENGTH * -0.5
|
||||
#else
|
||||
#define Y_HOME_POS Y_MIN_POS
|
||||
#endif //BED_CENTER_AT_0_0
|
||||
#else
|
||||
#ifdef BED_CENTER_AT_0_0
|
||||
#define Y_HOME_POS Y_MAX_LENGTH * 0.5
|
||||
#else
|
||||
#define Y_HOME_POS Y_MAX_POS
|
||||
#endif //BED_CENTER_AT_0_0
|
||||
#endif //Y_HOME_DIR == -1
|
||||
|
||||
// Z axis
|
||||
#if Z_HOME_DIR == -1 //BED_CENTER_AT_0_0 not used
|
||||
#define Z_HOME_POS Z_MIN_POS
|
||||
#else
|
||||
#define Z_HOME_POS Z_MAX_POS
|
||||
#endif //Z_HOME_DIR == -1
|
||||
#endif //End auto min/max positions
|
||||
//END AUTOSET LOCATIONS OF LIMIT SWITCHES -ZP
|
||||
|
||||
|
||||
//#define Z_LATE_ENABLE // Enable Z the last moment. Needed if your Z driver overheats.
|
||||
|
||||
// A single Z stepper driver is usually used to drive 2 stepper motors.
|
||||
// Uncomment this define to utilize a separate stepper driver for each Z axis motor.
|
||||
// Only a few motherboards support this, like RAMPS, which have dual extruder support (the 2nd, often unused, extruder driver is used
|
||||
// to control the 2nd Z axis stepper motor). The pins are currently only defined for a RAMPS motherboards.
|
||||
// On a RAMPS (or other 5 driver) motherboard, using this feature will limit you to using 1 extruder.
|
||||
//#define Z_DUAL_STEPPER_DRIVERS
|
||||
|
||||
#ifdef Z_DUAL_STEPPER_DRIVERS
|
||||
#undef EXTRUDERS
|
||||
#define EXTRUDERS 1
|
||||
#endif
|
||||
|
||||
//homing hits the endstop, then retracts by this distance, before it tries to slowly bump again:
|
||||
#define X_HOME_RETRACT_MM 4
|
||||
#define Y_HOME_RETRACT_MM 4
|
||||
#define Z_HOME_RETRACT_MM 2
|
||||
#define X_HOME_RETRACT_MM 5
|
||||
#define Y_HOME_RETRACT_MM 5
|
||||
#define Z_HOME_RETRACT_MM 1
|
||||
//#define QUICK_HOME //if this is defined, if both x and y are to be homed, a diagonal move will be performed initially.
|
||||
|
||||
#define AXIS_RELATIVE_MODES {false, false, false, false}
|
||||
|
||||
#define MAX_STEP_FREQUENCY 50000 // Max step frequency for Ultimaker (5000 pps / half step)
|
||||
#define MAX_STEP_FREQUENCY 40000 // Max step frequency for Ultimaker (5000 pps / half step)
|
||||
|
||||
//By default pololu step drivers require an active high signal. However, some high power drivers require an active low signal as step.
|
||||
#define INVERT_X_STEP_PIN false
|
||||
#define INVERT_Y_STEP_PIN false
|
||||
#define INVERT_Z_STEP_PIN false
|
||||
#define INVERT_E_STEP_PIN false
|
||||
|
||||
//default stepper release if idle
|
||||
#define DEFAULT_STEPPER_DEACTIVE_TIME 60
|
||||
@@ -97,8 +157,8 @@
|
||||
#define DEFAULT_MINIMUMFEEDRATE 0.0 // minimum feedrate
|
||||
#define DEFAULT_MINTRAVELFEEDRATE 0.0
|
||||
|
||||
// minimum time in microseconds that a movement needs to take if the buffer is emptied. Increase this number if you see blobs while printing high speed & high detail. It will slowdown on the detailed stuff.
|
||||
#define DEFAULT_MINSEGMENTTIME 20000 // Obsolete delete this
|
||||
// minimum time in microseconds that a movement needs to take if the buffer is emptied.
|
||||
#define DEFAULT_MINSEGMENTTIME 20000
|
||||
|
||||
// If defined the movements slow down when the look ahead buffer is only half full
|
||||
#define SLOWDOWN
|
||||
@@ -111,7 +171,7 @@
|
||||
// Minimum planner junction speed. Sets the default minimum speed the planner plans for at the end
|
||||
// of the buffer and all stops. This should not be much greater than zero and should only be changed
|
||||
// if unwanted behavior is observed on a user's machine when running at very slow speeds.
|
||||
#define MINIMUM_PLANNER_SPEED 2.0 // (mm/sec)
|
||||
#define MINIMUM_PLANNER_SPEED 0.05// (mm/sec)
|
||||
|
||||
//===========================================================================
|
||||
//=============================Additional Features===========================
|
||||
@@ -119,17 +179,17 @@
|
||||
|
||||
|
||||
#define SD_FINISHED_STEPPERRELEASE true //if sd support and the file is finished: disable steppers?
|
||||
#define SD_FINISHED_RELEASECOMMAND "M84 X Y Z E" // no z because of layer shift.
|
||||
#define SD_FINISHED_RELEASECOMMAND "M84 X Y Z E" // You might want to keep the z enabled so your bed stays in place.
|
||||
|
||||
// The hardware watchdog should halt the Microcontroller, in case the firmware gets stuck somewhere. However:
|
||||
// the Watchdog is not working well, so please only enable this for testing
|
||||
// this enables the watchdog interrupt.
|
||||
// The hardware watchdog should reset the Microcontroller disabling all outputs, in case the firmware gets stuck and doesn't do temperature regulation.
|
||||
//#define USE_WATCHDOG
|
||||
//#ifdef USE_WATCHDOG
|
||||
// you cannot reboot on a mega2560 due to a bug in he bootloader. Hence, you have to reset manually, and this is done hereby:
|
||||
//#define RESET_MANUAL
|
||||
//#define WATCHDOG_TIMEOUT 4 //seconds
|
||||
//#endif
|
||||
|
||||
#ifdef USE_WATCHDOG
|
||||
// If you have a watchdog reboot in an ArduinoMega2560 then the device will hang forever, as a watchdog reset will leave the watchdog on.
|
||||
// The "WATCHDOG_RESET_MANUAL" goes around this by not using the hardware reset.
|
||||
// However, THIS FEATURE IS UNSAFE!, as it will only work if interrupts are disabled. And the code could hang in an interrupt routine with interrupts disabled.
|
||||
//#define WATCHDOG_RESET_MANUAL
|
||||
#endif
|
||||
|
||||
// extruder advance constant (s2/mm3)
|
||||
//
|
||||
@@ -154,14 +214,17 @@
|
||||
#define MM_PER_ARC_SEGMENT 1
|
||||
#define N_ARC_CORRECTION 25
|
||||
|
||||
const int dropsegments=5; //everything with less than this number of steps will be ignored as move and joined with the next movement
|
||||
const unsigned int dropsegments=5; //everything with less than this number of steps will be ignored as move and joined with the next movement
|
||||
|
||||
// If you are using a RAMPS board or cheap E-bay purchased boards that do not detect when an SD card is inserted
|
||||
// You can get round this by connecting a push button or single throw switch to the pin defined as SDCARDCARDDETECT
|
||||
// in the pins.h file. When using a push button pulling the pin to ground this will need inverted. This setting should
|
||||
// be commented out otherwise
|
||||
//#define SDCARDDETECTINVERTED
|
||||
#define SDCARDDETECTINVERTED
|
||||
|
||||
#ifdef ULTIPANEL
|
||||
#undef SDCARDDETECTINVERTED
|
||||
#endif
|
||||
//===========================================================================
|
||||
//=============================Buffers ============================
|
||||
//===========================================================================
|
||||
@@ -170,8 +233,6 @@ const int dropsegments=5; //everything with less than this number of steps will
|
||||
// THE BLOCK_BUFFER_SIZE NEEDS TO BE A POWER OF 2, i.g. 8,16,32 because shifts and ors are used to do the ringbuffering.
|
||||
#if defined SDSUPPORT
|
||||
#define BLOCK_BUFFER_SIZE 16 // SD,LCD,Buttons take more memory, block buffer needs to be smaller
|
||||
// Chuck size for fast sd transfer
|
||||
#define SD_FAST_XFER_CHUNK_SIZE 1024
|
||||
#else
|
||||
#define BLOCK_BUFFER_SIZE 16 // maximize block buffer
|
||||
#endif
|
||||
@@ -181,6 +242,16 @@ const int dropsegments=5; //everything with less than this number of steps will
|
||||
#define MAX_CMD_SIZE 96
|
||||
#define BUFSIZE 4
|
||||
|
||||
|
||||
// Firmware based and LCD controled retract
|
||||
// M207 and M208 can be used to define parameters for the retraction.
|
||||
// The retraction can be called by the slicer using G10 and G11
|
||||
// until then, intended retractions can be detected by moves that only extrude and the direction.
|
||||
// the moves are than replaced by the firmware controlled ones.
|
||||
|
||||
// #define FWRETRACT //ONLY PARTIALLY TESTED
|
||||
#define MIN_RETRACT 0.1 //minimum extruded mm to accept a automatic gcode retraction attempt
|
||||
|
||||
//===========================================================================
|
||||
//============================= Define Defines ============================
|
||||
//===========================================================================
|
||||
|
||||
@@ -1,218 +0,0 @@
|
||||
#ifndef EEPROM_H
|
||||
#define EEPROM_H
|
||||
|
||||
#include "Marlin.h"
|
||||
#include "planner.h"
|
||||
#include "temperature.h"
|
||||
#include "FPUTransform.h"
|
||||
//#include <EEPROM.h>
|
||||
|
||||
|
||||
|
||||
template <class T> int EEPROM_writeAnything(int &ee, const T& value)
|
||||
{
|
||||
const byte* p = (const byte*)(const void*)&value;
|
||||
int i;
|
||||
for (i = 0; i < (int)sizeof(value); i++)
|
||||
eeprom_write_byte((unsigned char *)ee++, *p++);
|
||||
return i;
|
||||
}
|
||||
|
||||
template <class T> int EEPROM_readAnything(int &ee, T& value)
|
||||
{
|
||||
byte* p = (byte*)(void*)&value;
|
||||
int i;
|
||||
for (i = 0; i < (int)sizeof(value); i++)
|
||||
*p++ = eeprom_read_byte((unsigned char *)ee++);
|
||||
return i;
|
||||
}
|
||||
//======================================================================================
|
||||
|
||||
|
||||
|
||||
|
||||
#define EEPROM_OFFSET 100
|
||||
|
||||
|
||||
// IMPORTANT: Whenever there are changes made to the variables stored in EEPROM
|
||||
// in the functions below, also increment the version number. This makes sure that
|
||||
// the default values are used whenever there is a change to the data, to prevent
|
||||
// wrong data being written to the variables.
|
||||
// ALSO: always make sure the variables in the Store and retrieve sections are in the same order.
|
||||
#define EEPROM_VERSION "V05"
|
||||
|
||||
inline void EEPROM_StoreSettings()
|
||||
{
|
||||
#ifdef EEPROM_SETTINGS
|
||||
char ver[4]= "000";
|
||||
int i=EEPROM_OFFSET;
|
||||
EEPROM_writeAnything(i,ver); // invalidate data first
|
||||
EEPROM_writeAnything(i,axis_steps_per_unit);
|
||||
EEPROM_writeAnything(i,max_feedrate);
|
||||
EEPROM_writeAnything(i,max_acceleration_units_per_sq_second);
|
||||
EEPROM_writeAnything(i,acceleration);
|
||||
EEPROM_writeAnything(i,retract_acceleration);
|
||||
EEPROM_writeAnything(i,minimumfeedrate);
|
||||
EEPROM_writeAnything(i,mintravelfeedrate);
|
||||
EEPROM_writeAnything(i,minsegmenttime);
|
||||
EEPROM_writeAnything(i,max_xy_jerk);
|
||||
EEPROM_writeAnything(i,max_z_jerk);
|
||||
EEPROM_writeAnything(i,max_e_jerk);
|
||||
EEPROM_writeAnything(i,add_homeing);
|
||||
#ifdef PIDTEMP
|
||||
EEPROM_writeAnything(i,Kp);
|
||||
EEPROM_writeAnything(i,Ki);
|
||||
EEPROM_writeAnything(i,Kd);
|
||||
EEPROM_writeAnything(i,Ki_Max);
|
||||
#else
|
||||
EEPROM_writeAnything(i,3000);
|
||||
EEPROM_writeAnything(i,0);
|
||||
EEPROM_writeAnything(i,0);
|
||||
#endif
|
||||
#if defined(UMFPUSUPPORT) && (UMFPUSUPPORT > -1)
|
||||
EEPROM_writeAnything(i,FPUEnabled);
|
||||
#endif
|
||||
char ver2[4]=EEPROM_VERSION;
|
||||
i=EEPROM_OFFSET;
|
||||
EEPROM_writeAnything(i,ver2); // validate data
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM("Settings Stored");
|
||||
#endif //EEPROM_SETTINGS
|
||||
}
|
||||
|
||||
|
||||
inline void EEPROM_printSettings()
|
||||
{ // if def=true, the default values will be used
|
||||
#ifdef EEPROM_SETTINGS
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM("Steps per unit:");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPAIR(" M92 X",axis_steps_per_unit[0]);
|
||||
SERIAL_ECHOPAIR(" Y",axis_steps_per_unit[1]);
|
||||
SERIAL_ECHOPAIR(" Z",axis_steps_per_unit[2]);
|
||||
SERIAL_ECHOPAIR(" E",axis_steps_per_unit[3]);
|
||||
SERIAL_ECHOLN("");
|
||||
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM("Maximum feedrates (mm/s):");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPAIR(" M203 X",max_feedrate[0]);
|
||||
SERIAL_ECHOPAIR(" Y",max_feedrate[1] );
|
||||
SERIAL_ECHOPAIR(" Z", max_feedrate[2] );
|
||||
SERIAL_ECHOPAIR(" E", max_feedrate[3]);
|
||||
SERIAL_ECHOLN("");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPAIR(" M201 X" ,max_acceleration_units_per_sq_second[0] );
|
||||
SERIAL_ECHOPAIR(" Y" , max_acceleration_units_per_sq_second[1] );
|
||||
SERIAL_ECHOPAIR(" Z" ,max_acceleration_units_per_sq_second[2] );
|
||||
SERIAL_ECHOPAIR(" E" ,max_acceleration_units_per_sq_second[3]);
|
||||
SERIAL_ECHOLN("");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM("Acceleration: S=acceleration, T=retract acceleration");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPAIR(" M204 S",acceleration );
|
||||
SERIAL_ECHOPAIR(" T" ,retract_acceleration);
|
||||
SERIAL_ECHOLN("");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM("Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum xY jerk (mm/s), Z=maximum Z jerk (mm/s)");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPAIR(" M205 S",minimumfeedrate );
|
||||
SERIAL_ECHOPAIR(" T" ,mintravelfeedrate );
|
||||
SERIAL_ECHOPAIR(" B" ,minsegmenttime );
|
||||
SERIAL_ECHOPAIR(" X" ,max_xy_jerk );
|
||||
SERIAL_ECHOPAIR(" Z" ,max_z_jerk);
|
||||
SERIAL_ECHOPAIR(" E" ,max_e_jerk);
|
||||
SERIAL_ECHOLN("");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPAIR(" M206 X",add_homeing[0]);
|
||||
SERIAL_ECHOPAIR(" Y",add_homeing[1] );
|
||||
SERIAL_ECHOPAIR(" Z", add_homeing[2] );
|
||||
SERIAL_ECHOLN("");
|
||||
#ifdef PIDTEMP
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM("PID settings:");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPAIR(" M301 P",Kp);
|
||||
SERIAL_ECHOPAIR(" I" ,Ki/PID_dT);
|
||||
SERIAL_ECHOPAIR(" D" ,Kd*PID_dT);
|
||||
SERIAL_ECHOPAIR(" W" ,Ki_Max);
|
||||
SERIAL_ECHOLN("");
|
||||
#endif
|
||||
#if defined(UMFPUSUPPORT) && (UMFPUSUPPORT > -1)
|
||||
SERIAL_ECHOPAIR(" FPU Enabled" , FPUEnabled?" yes":" no");
|
||||
SERIAL_ECHOLN("");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
inline void EEPROM_RetrieveSettings(bool def=false)
|
||||
{ // if def=true, the default values will be used
|
||||
#ifdef EEPROM_SETTINGS
|
||||
int i=EEPROM_OFFSET;
|
||||
char stored_ver[4];
|
||||
char ver[4]=EEPROM_VERSION;
|
||||
EEPROM_readAnything(i,stored_ver); //read stored version
|
||||
// SERIAL_ECHOLN("Version: [" << ver << "] Stored version: [" << stored_ver << "]");
|
||||
if ((!def)&&(strncmp(ver,stored_ver,3)==0))
|
||||
{ // version number match
|
||||
EEPROM_readAnything(i,axis_steps_per_unit);
|
||||
EEPROM_readAnything(i,max_feedrate);
|
||||
EEPROM_readAnything(i,max_acceleration_units_per_sq_second);
|
||||
EEPROM_readAnything(i,acceleration);
|
||||
EEPROM_readAnything(i,retract_acceleration);
|
||||
EEPROM_readAnything(i,minimumfeedrate);
|
||||
EEPROM_readAnything(i,mintravelfeedrate);
|
||||
EEPROM_readAnything(i,minsegmenttime);
|
||||
EEPROM_readAnything(i,max_xy_jerk);
|
||||
EEPROM_readAnything(i,max_z_jerk);
|
||||
EEPROM_readAnything(i,max_e_jerk);
|
||||
EEPROM_readAnything(i,add_homeing);
|
||||
#ifndef PIDTEMP
|
||||
float Kp,Ki,Kd;
|
||||
int Ki_Max;
|
||||
#endif
|
||||
EEPROM_readAnything(i,Kp);
|
||||
EEPROM_readAnything(i,Ki);
|
||||
EEPROM_readAnything(i,Kd);
|
||||
EEPROM_readAnything(i,Ki_Max);
|
||||
#if defined(UMFPUSUPPORT) && (UMFPUSUPPORT > -1)
|
||||
EEPROM_readAnything(i,FPUEnabled);
|
||||
#endif
|
||||
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM("Stored settings retreived:");
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
float tmp1[]=DEFAULT_AXIS_STEPS_PER_UNIT;
|
||||
float tmp2[]=DEFAULT_MAX_FEEDRATE;
|
||||
long tmp3[]=DEFAULT_MAX_ACCELERATION;
|
||||
for (short i=0;i<4;i++)
|
||||
{
|
||||
axis_steps_per_unit[i]=tmp1[i];
|
||||
max_feedrate[i]=tmp2[i];
|
||||
max_acceleration_units_per_sq_second[i]=tmp3[i];
|
||||
}
|
||||
acceleration=DEFAULT_ACCELERATION;
|
||||
retract_acceleration=DEFAULT_RETRACT_ACCELERATION;
|
||||
minimumfeedrate=DEFAULT_MINIMUMFEEDRATE;
|
||||
minsegmenttime=DEFAULT_MINSEGMENTTIME;
|
||||
mintravelfeedrate=DEFAULT_MINTRAVELFEEDRATE;
|
||||
max_xy_jerk=DEFAULT_XYJERK;
|
||||
max_z_jerk=DEFAULT_ZJERK;
|
||||
max_e_jerk=DEFAULT_EJERK;
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLN("Using Default settings:");
|
||||
}
|
||||
#ifdef EEPROM_CHITCHAT
|
||||
EEPROM_printSettings();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,190 +0,0 @@
|
||||
#include "FPUTransform.h"
|
||||
|
||||
#if defined(UMFPUSUPPORT) && (UMFPUSUPPORT > -1)
|
||||
|
||||
#include "MatrixMath.h"
|
||||
|
||||
float MasterTransform[4][4]; // this is the transform that describes how to move from
|
||||
// ideal coordinates to real world coords
|
||||
|
||||
// private functions
|
||||
void loadMatrix(float X4, float Y3, float Z1, float X2, float Y2, float Z2, float X3, float Z3, float Z4);
|
||||
void transformDestination(float &X, float &Y, float &Z);
|
||||
|
||||
bool FPUEnabled; // this is a bypass switch so that with one command the FPU can be
|
||||
// turned off
|
||||
|
||||
void loadMatrix(float X4, float Y1, float Z1, float X2, float Y2, float Z2, float X3, float Z3, float Z4)
|
||||
{
|
||||
float Xdiff = X4 - X3;
|
||||
serialPrintFloat(Xdiff);
|
||||
SERIAL_ECHOLN("");
|
||||
float Ydiff = Y2 - Y1;
|
||||
serialPrintFloat(Ydiff);
|
||||
SERIAL_ECHOLN("");
|
||||
//clockwise
|
||||
float ZdiffX = Z4 - Z3;
|
||||
serialPrintFloat(ZdiffX);
|
||||
SERIAL_ECHOLN("");
|
||||
//anti clockwise
|
||||
float ZdiffY = Z1 - Z2;
|
||||
serialPrintFloat(ZdiffY);
|
||||
SERIAL_ECHOLN("");
|
||||
|
||||
|
||||
//modified to take advantage of small angle trig.
|
||||
float Xtheta = ZdiffX / Xdiff;
|
||||
// serialPrintFloat(Xtheta);
|
||||
// SERIAL_ECHOLN("");
|
||||
float Ytheta = ZdiffY / Ydiff;
|
||||
// serialPrintFloat(Ytheta);
|
||||
// SERIAL_ECHOLN("");
|
||||
float cosxtheta = 1-(Xtheta*Xtheta)/2;
|
||||
// serialPrintFloat(cosxtheta);
|
||||
// SERIAL_ECHOLN("");
|
||||
float sinxtheta = Xtheta;
|
||||
// serialPrintFloat(sinxtheta);
|
||||
// SERIAL_ECHOLN("");
|
||||
float cosytheta = 1-(Ytheta*Ytheta)/2;
|
||||
// serialPrintFloat(cosytheta);
|
||||
// SERIAL_ECHOLN("");
|
||||
float sinytheta = Ytheta;
|
||||
// serialPrintFloat(sinytheta);
|
||||
// SERIAL_ECHOLN("");
|
||||
|
||||
//these transforms are to set the origin for each rotation
|
||||
float TranslateX0[4][4] = {{1.0, 0.0, 0.0, -X3},
|
||||
{0.0, 1.0, 0.0, -Y1},
|
||||
{0.0, 0.0, 1.0, -Z3},
|
||||
{0.0, 0.0, 0.0, 1.0}};
|
||||
|
||||
float TranslateY0[4][4] = {{1.0, 0.0, 0.0, -X2},
|
||||
{0.0, 1.0, 0.0, -Y1},
|
||||
{0.0, 0.0, 1.0, -Z1},
|
||||
{0.0, 0.0, 0.0, 1.0}};
|
||||
|
||||
//rotate in Y using XZ
|
||||
float TransformY[4][4] = {{cosxtheta, 0.0, sinxtheta, 0.0},
|
||||
{ 0.0, 1.0, 0.0, 0.0},
|
||||
{-sinxtheta, 0.0, cosxtheta, 0.0},
|
||||
{ 0.0, 0.0, 0.0, 1.0}};
|
||||
//rotate in X using YZ
|
||||
float TransformX[4][4] = {{ 1.0, 0.0, 0.0, 0.0},
|
||||
{ 0.0, cosytheta, sinytheta, 0.0},
|
||||
{ 0.0,sinytheta, cosytheta, 0.0},
|
||||
{ 0.0, 0.0, 0.0, 1.0}};
|
||||
|
||||
|
||||
// first translate point1 to 0 then rotate in Y then translate back
|
||||
float MatrixStage1[4][4];
|
||||
float MatrixStage2[4][4];
|
||||
//matrixMaths.MatrixMult((float*)TranslateY0, (float*)TransformX, 4, 4, 4, (float*)MatrixStage1);
|
||||
//matrixMaths.MatrixPrint((float*)MatrixStage1, 4, 4, "MatrixStage1");
|
||||
//TranslateY0[0][3] = -TranslateY0[0][3];
|
||||
//TranslateY0[1][3] = -TranslateY0[1][3];
|
||||
//TranslateY0[2][3] = -TranslateY0[2][3];
|
||||
//matrixMaths.MatrixPrint((float*)TranslateY0, 4, 4, "TranslateY0");
|
||||
//matrixMaths.MatrixMult((float*)MatrixStage1, (float*)TranslateY0, 4, 4, 4, (float*)MatrixStage2);
|
||||
//matrixMaths.MatrixPrint((float*)MatrixStage2, 4, 4, "MatrixStage2");
|
||||
//Now translate point3 to 0 and rotate in x before translating back
|
||||
float MatrixStage3[4][4];
|
||||
float MatrixStage4[4][4];
|
||||
//matrixMaths.MatrixMult((float*)MatrixStage2, (float*)TranslateX0, 4, 4, 4, (float*)MatrixStage3);
|
||||
//matrixMaths.MatrixPrint((float*)MatrixStage3, 4, 4, "MatrixStage3");
|
||||
//matrixMaths.MatrixMult((float*)MatrixStage3, (float*)TransformY, 4, 4, 4, (float*)MatrixStage4);
|
||||
matrixMaths.MatrixMult((float*)TransformX, (float*)TransformY, 4, 4, 4, (float*)MasterTransform);
|
||||
matrixMaths.MatrixPrint((float*)MatrixStage4, 4, 4, "MatrixStage4");
|
||||
//TranslateX0[0][3] = -TranslateX0[0][3];
|
||||
//TranslateX0[1][3] = -TranslateX0[1][3];
|
||||
//TranslateX0[2][3] = -TranslateX0[2][3];
|
||||
//matrixMaths.MatrixPrint((float*)TranslateX0, 4, 4, "TranslateX0");
|
||||
//matrixMaths.MatrixMult((float*)MatrixStage4, (float*)TranslateX0, 4, 4, 4, (float*)MasterTransform);
|
||||
//matrixMaths.MatrixPrint((float*)MasterTransform, 4, 4, "MasterTransform (pre-invert)");
|
||||
|
||||
// We now have a way to translate from real-world coordinates to idealised coortdinates,
|
||||
// but what we actually want is a way to transform from the idealised g-code coordinates
|
||||
// to real world coordinates.
|
||||
// This is simply the inverse.
|
||||
matrixMaths.MatrixInvert((float*)MasterTransform, 4);
|
||||
matrixMaths.MatrixPrint((float*)MasterTransform, 4, 4, "MasterTransform");
|
||||
}
|
||||
|
||||
void transformDestination(float &X, float &Y, float &Z)
|
||||
{
|
||||
float oldPoint[4][1]={{X}, {Y}, {Z}, {1.0}};
|
||||
float newPoint[1][4]={{0.0,0.0,0.0,0.0}};
|
||||
matrixMaths.MatrixMult((float*)MasterTransform, (float*)oldPoint, 4, 4, 1, (float*)newPoint);
|
||||
X=newPoint[0][0];
|
||||
Y=newPoint[0][1];
|
||||
Z=newPoint[0][2];
|
||||
}
|
||||
|
||||
void FPUTransform_init()
|
||||
{
|
||||
if (FPUEnabled == true)
|
||||
{
|
||||
// It is important to ensure that if the bed levelling routine has not been called the
|
||||
// printer behaves as if the real world and idealised world are one and the same
|
||||
matrixMaths.MatrixIdentity((float*)MasterTransform,4,4);
|
||||
SERIAL_ECHO("transform configured to identity");
|
||||
}
|
||||
else
|
||||
{
|
||||
SERIAL_ECHO("transform correction not enabled");
|
||||
}
|
||||
}
|
||||
|
||||
void FPUEnable()
|
||||
{
|
||||
FPUEnabled = true;
|
||||
FPUTransform_init();
|
||||
}
|
||||
|
||||
void FPUReset()
|
||||
{
|
||||
FPUTransform_init();
|
||||
}
|
||||
|
||||
void FPUDisable()
|
||||
{
|
||||
FPUEnabled = false;
|
||||
}
|
||||
|
||||
void FPUTransform_determineBedOrientation()
|
||||
{
|
||||
int X3 = 15;
|
||||
float X4 = X_MAX_LENGTH - 20;
|
||||
float X2 = (X4 + X3) / 2;
|
||||
int Y1 = 15;
|
||||
float Y2 = Y_MAX_LENGTH - 5;
|
||||
float Z1;
|
||||
float Z2;
|
||||
float Z3;
|
||||
float Z4;
|
||||
|
||||
//get Z for X15 Y15, X15 Y(Y_MAX_LENGTH - 15) and X(X_MAX_LENGTH - 15) Y15
|
||||
Z3 = Probe_Bed(X3,Y1,PROBE_N);
|
||||
Z4 = Probe_Bed(X4,Y1,PROBE_N);
|
||||
Z1 = (Z3 + Z4) / 2;
|
||||
Z2 = Probe_Bed(X2,Y2,PROBE_N);
|
||||
if(FPUEnabled)
|
||||
{
|
||||
loadMatrix(X4, Y1, Z1, X2, Y2, Z2, X3, Z3, Z4);
|
||||
}
|
||||
}
|
||||
|
||||
void FPUTransform_transformDestination()
|
||||
{
|
||||
float XPoint = destination[X_AXIS]; // float variable
|
||||
float YPoint = destination[Y_AXIS]; // float variable
|
||||
float ZPoint = destination[Z_AXIS]; // float variable
|
||||
if(FPUEnabled)
|
||||
{
|
||||
transformDestination(XPoint, YPoint, ZPoint);
|
||||
}
|
||||
modified_destination[X_AXIS] = XPoint; // float variable
|
||||
modified_destination[Y_AXIS] = YPoint; // float variable
|
||||
modified_destination[Z_AXIS] = ZPoint; // float variable
|
||||
}
|
||||
|
||||
#endif //UMFPUSUPPORT
|
||||
@@ -1,21 +0,0 @@
|
||||
#ifndef __FPUTRANSFORM
|
||||
|
||||
#define __FPUTRANSFORM
|
||||
#include "Marlin.h"
|
||||
#include "z_probe.h"
|
||||
|
||||
#if defined(UMFPUSUPPORT) && (UMFPUSUPPORT > -1)
|
||||
extern bool FPUEnabled;
|
||||
void FPUTransform_init();
|
||||
void FPUEnable();
|
||||
void FPUReset();
|
||||
void FPUDisable();
|
||||
void FPUTransform_determineBedOrientation();
|
||||
void FPUTransform_transformDestination();
|
||||
|
||||
#else //no UMFPU SUPPORT
|
||||
FORCE_INLINE void FPUTransform_init() {};
|
||||
|
||||
#endif //UMFPUSUPPORT
|
||||
|
||||
#endif //__FPUTRANSFORM
|
||||
@@ -0,0 +1,101 @@
|
||||
##############################################################
|
||||
|
||||
Gen7-644-16.name=Gen7 with ATmega644 and 16 MHz
|
||||
Gen7-644-16.upload.protocol=stk500v2
|
||||
Gen7-644-16.upload.maximum_size=63488
|
||||
Gen7-644-16.upload.speed=115200
|
||||
Gen7-644-16.bootloader.low_fuses=0xF7
|
||||
Gen7-644-16.bootloader.high_fuses=0xD4
|
||||
Gen7-644-16.bootloader.extended_fuses=0xFD
|
||||
Gen7-644-16.bootloader.path=Gen7
|
||||
Gen7-644-16.bootloader.file=bootloader-644-16MHz.hex
|
||||
Gen7-644-16.bootloader.unlock_bits=0x3F
|
||||
Gen7-644-16.bootloader.lock_bits=0x0F
|
||||
Gen7-644-16.build.mcu=atmega644
|
||||
Gen7-644-16.build.f_cpu=16000000L
|
||||
Gen7-644-16.build.core=arduino
|
||||
|
||||
##############################################################
|
||||
|
||||
Gen7-644-20.name=Gen7 with ATmega644 and 20 MHz
|
||||
Gen7-644-20.upload.protocol=stk500v2
|
||||
Gen7-644-20.upload.maximum_size=63488
|
||||
Gen7-644-20.upload.speed=115200
|
||||
Gen7-644-20.bootloader.low_fuses=0xF7
|
||||
Gen7-644-20.bootloader.high_fuses=0xD4
|
||||
Gen7-644-20.bootloader.extended_fuses=0xFD
|
||||
Gen7-644-20.bootloader.path=Gen7
|
||||
Gen7-644-20.bootloader.file=bootloader-644-20MHz.hex
|
||||
Gen7-644-20.bootloader.unlock_bits=0x3F
|
||||
Gen7-644-20.bootloader.lock_bits=0x0F
|
||||
Gen7-644-20.build.mcu=atmega644
|
||||
Gen7-644-20.build.f_cpu=20000000L
|
||||
Gen7-644-20.build.core=arduino
|
||||
|
||||
##############################################################
|
||||
|
||||
Gen7-644P-16.name=Gen7 with ATmega644P and 16 MHz
|
||||
Gen7-644P-16.upload.protocol=stk500v2
|
||||
Gen7-644P-16.upload.maximum_size=63488
|
||||
Gen7-644P-16.upload.speed=115200
|
||||
Gen7-644P-16.bootloader.low_fuses=0xF7
|
||||
Gen7-644P-16.bootloader.high_fuses=0xD4
|
||||
Gen7-644P-16.bootloader.extended_fuses=0xFD
|
||||
Gen7-644P-16.bootloader.path=Gen7
|
||||
Gen7-644P-16.bootloader.file=bootloader-644P-16MHz.hex
|
||||
Gen7-644P-16.bootloader.unlock_bits=0x3F
|
||||
Gen7-644P-16.bootloader.lock_bits=0x0F
|
||||
Gen7-644P-16.build.mcu=atmega644p
|
||||
Gen7-644P-16.build.f_cpu=16000000L
|
||||
Gen7-644P-16.build.core=arduino
|
||||
|
||||
##############################################################
|
||||
|
||||
Gen7-644P-20.name=Gen7 with ATmega644P and 20 MHz
|
||||
Gen7-644P-20.upload.protocol=stk500v2
|
||||
Gen7-644P-20.upload.maximum_size=63488
|
||||
Gen7-644P-20.upload.speed=115200
|
||||
Gen7-644P-20.bootloader.low_fuses=0xF7
|
||||
Gen7-644P-20.bootloader.high_fuses=0xD4
|
||||
Gen7-644P-20.bootloader.extended_fuses=0xFD
|
||||
Gen7-644P-20.bootloader.path=Gen7
|
||||
Gen7-644P-20.bootloader.file=bootloader-644P-20MHz.hex
|
||||
Gen7-644P-20.bootloader.unlock_bits=0x3F
|
||||
Gen7-644P-20.bootloader.lock_bits=0x0F
|
||||
Gen7-644P-20.build.mcu=atmega644p
|
||||
Gen7-644P-20.build.f_cpu=20000000L
|
||||
Gen7-644P-20.build.core=arduino
|
||||
|
||||
##############################################################
|
||||
|
||||
Gen7-1284p-16.name=Gen7 with ATmega1284 and 16 MHz
|
||||
Gen7-1284p-16.upload.protocol=stk500v2
|
||||
Gen7-1284p-16.upload.maximum_size=129024
|
||||
Gen7-1284p-16.upload.speed=115200
|
||||
Gen7-1284p-16.bootloader.low_fuses=0xF7
|
||||
Gen7-1284p-16.bootloader.high_fuses=0xD4
|
||||
Gen7-1284p-16.bootloader.extended_fuses=0xFD
|
||||
Gen7-1284p-16.bootloader.path=Gen7
|
||||
Gen7-1284p-16.bootloader.file=bootloader-1284P-16MHz.hex
|
||||
Gen7-1284p-16.bootloader.unlock_bits=0x3F
|
||||
Gen7-1284p-16.bootloader.lock_bits=0x2F
|
||||
Gen7-1284p-16.build.mcu=atmega1284p
|
||||
Gen7-1284p-16.build.f_cpu=16000000L
|
||||
Gen7-1284p-16.build.core=arduino
|
||||
|
||||
##############################################################
|
||||
|
||||
Gen7-1284p-20.name=Gen7 with ATmega1284 and 20 MHz
|
||||
Gen7-1284p-20.upload.protocol=stk500v2
|
||||
Gen7-1284p-20.upload.maximum_size=129024
|
||||
Gen7-1284p-20.upload.speed=115200
|
||||
Gen7-1284p-20.bootloader.low_fuses=0xF7
|
||||
Gen7-1284p-20.bootloader.high_fuses=0xD4
|
||||
Gen7-1284p-20.bootloader.extended_fuses=0xFD
|
||||
Gen7-1284p-20.bootloader.path=Gen7
|
||||
Gen7-1284p-20.bootloader.file=bootloader-1284P-16MHz.hex
|
||||
Gen7-1284p-20.bootloader.unlock_bits=0x3F
|
||||
Gen7-1284p-20.bootloader.lock_bits=0x2F
|
||||
Gen7-1284p-20.build.mcu=atmega1284p
|
||||
Gen7-1284p-20.build.f_cpu=20000000L
|
||||
Gen7-1284p-20.build.core=arduino
|
||||
@@ -0,0 +1,113 @@
|
||||
:020000021000EC
|
||||
:10F8000011241FBE8FEF90E49EBF8DBF01C32F92C6
|
||||
:10F810003F924F925F926F927F928F929F92AF92A0
|
||||
:10F82000BF92CF92DF92EF92FF920F931F93DF93DD
|
||||
:10F83000CF93CDB7DEB7C252D1400FB6F894DEBF3A
|
||||
:10F840000FBECDBF44245524DD24C25EDE4F188296
|
||||
:10F85000CE51D1408824992454013AC20E9428FFF5
|
||||
:10F86000282F133059F1143028F4113081F0123060
|
||||
:10F8700000F507C0153081F1153030F1163071F701
|
||||
:10F880003DC08B3159F711E05BE1D52EE7CF8130D8
|
||||
:10F8900041F0C25EDE4F3881CE51D140831709F06E
|
||||
:10F8A00019C2D226C25EDE4F2883CE51D14012E06B
|
||||
:10F8B000D5CFF82EEE24D82613E0D0CF90E0E82A5A
|
||||
:10F8C000F92AD22614E0CACF8E3009F003C2D82616
|
||||
:10F8D00015E044245524C2CFE1E0F0E0EC0FFD1F19
|
||||
:10F8E000E40DF51D80830894411C511CD8264E144C
|
||||
:10F8F0005F0409F0B3CF720116E0B0CF8D1509F0A7
|
||||
:10F90000E9C1EAC1CC2447C08D81803311F090E079
|
||||
:10F910000AC08F81882311F49EE105C0813011F067
|
||||
:10F9200095E001C097E91A821B828D818C838E81BC
|
||||
:10F930008D839E831F8247E0E42EF12C88C11A82BA
|
||||
:10F9400068E06B8383E58C8394E59D83EBE4EE8331
|
||||
:10F9500085E38F8380E3888789878FE58A8782E3C1
|
||||
:10F960008B873BE0E32EF12C72C18A81813941F013
|
||||
:10F97000823941F0803911F48FE005C080E003C086
|
||||
:10F9800082E001C08AE01A828B8323E0E22EF12C10
|
||||
:10F990005EC1CC24C3941A8292E0E92EF12C58C1A6
|
||||
:10F9A0008D81882311F48EE128C0813011F085E02B
|
||||
:10F9B00024C087E922C01A8229E0E1E0F0E0209328
|
||||
:10F9C000570084911BC08B81803589F48C818830ED
|
||||
:10F9D00039F439E0E2E0F0E03093570084910DC053
|
||||
:10F9E00069E0E0E0F0E060935700849106C099E0A0
|
||||
:10F9F000E3E0F0E09093570084911A828B831C829D
|
||||
:10FA000084E0E82EF12C23C18A8190E0A0E0B0E0F0
|
||||
:10FA1000B82EAA24992488248B8190E0A0E0B0E03D
|
||||
:10FA2000DC0199278827882A992AAA2ABB2A8D814E
|
||||
:10FA300090E0A0E0B0E0882A992AAA2ABB2A8C810B
|
||||
:10FA400090E0A0E0B0E0BA2FA92F982F8827882A4D
|
||||
:10FA5000992AAA2ABB2A88C0EA81C05EDE4FE883C1
|
||||
:10FA6000C052D140C15EDE4F1882CF51D1408B8150
|
||||
:10FA7000A82FB0E0C15EDE4F28813981CF51D1403F
|
||||
:10FA8000A22BB32B933109F042C075016401CC0C59
|
||||
:10FA9000DD1CEE1CFF1C33E0F601E0925B003093AE
|
||||
:10FAA0005700E89507B600FCFDCF8E01055F1F4F9C
|
||||
:10FAB000F801808161810E5F1F4FA5019401220F23
|
||||
:10FAC000331F441F551F362E222490E0822993298C
|
||||
:10FAD00061E00C01F90140935B0060935700E895E9
|
||||
:10FAE00011240894811C911CA11CB11C129701F7D0
|
||||
:10FAF00085E0F601E0925B0080935700E89507B639
|
||||
:10FB000000FCFDCF81E180935700E8952DC0FE01F8
|
||||
:10FB10003B9620E030E040E050E011977D0100E0AE
|
||||
:10FB200010E00894E11CF11C011D111D6081F99980
|
||||
:10FB3000FECF1FBAC901880D991D92BD81BD60BD60
|
||||
:10FB40000FB6F894FA9AF99A0FBE2F5F3F4F4F4FB6
|
||||
:10FB50005F4F2E153F054007510711F03196E6CF54
|
||||
:10FB6000820E931EA41EB51E1A826EC09A81CE5DAF
|
||||
:10FB7000DE4F9883C252D140CF5DDE4F1882C15212
|
||||
:10FB8000D1408B81C82EDD24CF5DDE4FE881F98125
|
||||
:10FB9000C152D140CE2ADF2A1A8289818431E1F410
|
||||
:10FBA0009601BE016D5F7F4FD501C401880F991F7B
|
||||
:10FBB000AA1FBB1FABBFFC0187919691FB018083FD
|
||||
:10FBC00091836E5F7F4F0894811C911CA11CB11C16
|
||||
:10FBD0002250304049F72EC0BE016D5F7F4F20E0BC
|
||||
:10FBE00030E040E050E00894C108D108760100E020
|
||||
:10FBF00010E00894C11CD11C0894E11CF11C011DEB
|
||||
:10FC0000111DF999FECFC901880D991D92BD81BDC5
|
||||
:10FC1000F89A80B5FB018193BF012F5F3F4F4F4F93
|
||||
:10FC20005F4F2E153F054007510759F7820E931E6F
|
||||
:10FC3000A41EB51E23E0E22EF12CEC0CFD1CFB01F2
|
||||
:10FC4000108205C080EC8A8392E0E92EF12CCC244E
|
||||
:10FC50008BE10E94C7FEC25EDE4F8881CE51D1404B
|
||||
:10FC60000E94C7FE8F2D0E94C7FE8E2D0E94C7FEE8
|
||||
:10FC70008EE00E94C7FE85E1D82EC25EDE4FF8817D
|
||||
:10FC8000CE51D140DF26DE24DF243E010894611CE2
|
||||
:10FC9000711C0AC0F30111913F01812F0E94C7FE20
|
||||
:10FCA000D1260894E108F108E114F10499F78D2DAB
|
||||
:10FCB0000E94C7FECC2009F044C0C25EDE4FF8812E
|
||||
:10FCC000CE51D140FF5FC25EDE4FF883CE51D140AE
|
||||
:10FCD000EE24FF2410E0C2CD9981933109F4BCCE0B
|
||||
:10FCE0009431B0F4933009F440CE943038F491302C
|
||||
:10FCF00009F425CE923009F0A5CF04CE903109F455
|
||||
:10FD000001CE913109F445CE963009F09BCF7CCEDF
|
||||
:10FD1000983109F458CE993150F4953109F49CCEBC
|
||||
:10FD2000953108F423CF963109F08CCF1FCF9B314A
|
||||
:10FD300009F436CE9D3109F4E7CD9A3109F082CF2E
|
||||
:10FD40003ACECE5DDE4F0FB6F894DEBF0FBECDBF0C
|
||||
:10FD5000CF91DF911F910F91FF90EF90DF90CF90A7
|
||||
:10FD6000BF90AF909F908F907F906F905F904F90DB
|
||||
:10FD70003F902F9008958091C00087FFFCCF089599
|
||||
:10FD80008091C00087FFFCCF8091C6000895982F16
|
||||
:10FD90008091C00085FFFCCF9093C60008959B0121
|
||||
:10FDA000AC0197FF11C08091C00082608093C000B9
|
||||
:10FDB00050954095309521953F4F4F4F5F4F60E0F4
|
||||
:10FDC00074E284EF90E009C08091C0008D7F809341
|
||||
:10FDD000C00060E072E18AE790E00E9447FF2C5F7C
|
||||
:10FDE0003F4F4F4F5F4F83E0569547953795279587
|
||||
:10FDF0008A95D1F7215030403093C5002093C4003C
|
||||
:10FE0000089518B817B81F921F921F920895FFCF38
|
||||
:10FE100084B714BE90E083709070892B39F418B8C1
|
||||
:10FE200017B81F921F921F920895FFCF88E1809309
|
||||
:10FE3000C10060E07EE38EEF9FEF0E94CFFE0E9444
|
||||
:10FE400007FC18B817B81F921F921F920895FFCF92
|
||||
:10FE500020E030E040E050E013C02F5F3F4F4F4FB5
|
||||
:10FE60005F4F21308AE6380788E1480780E058076D
|
||||
:10FE700039F418B817B81F921F921F920895FFCF38
|
||||
:10FE80008091C00087FFE9CF0E94C0FE0895A1E2E3
|
||||
:10FE90001A2EAA1BBB1BFD010DC0AA1FBB1FEE1F04
|
||||
:10FEA000FF1FA217B307E407F50720F0A21BB30B4F
|
||||
:10FEB000E40BF50B661F771F881F991F1A9469F7CB
|
||||
:10FEC00060957095809590959B01AC01BD01CF0127
|
||||
:02FED000089593
|
||||
:040000031000F800F1
|
||||
:00000001FF
|
||||
@@ -0,0 +1,75 @@
|
||||
:10F800008FEF90E19EBF8DBF11241FBE5A9A00C09A
|
||||
:10F81000CDB7DEB7CD51D140DEBFCDBF1092C50010
|
||||
:10F8200088E08093C40088E18093C100EE24FF2427
|
||||
:10F8300020E0552400E010E039E0432E9BE0292E23
|
||||
:10F84000312C2C0E3D1ECFC14150504060407040C5
|
||||
:10F8500011F43FE206C08091C00087FFF5CF3091E0
|
||||
:10F86000C600933021F1943028F4913099F0923011
|
||||
:10F87000C8F407C0953049F1953000F19630D1F5C4
|
||||
:10F8800035C03B3119F491E02BE134C03F3291F5A2
|
||||
:10F890003983BBC1313011F0351559F52327532E6B
|
||||
:10F8A00092E028C0B32FA0E0232793E023C0832F4A
|
||||
:10F8B00090E0A82BB92B232794E01CC03E30C9F45C
|
||||
:10F8C000232795E0EE24FF2415C0E1E0F0E0EC0FE3
|
||||
:10F8D000FD1FEE0DFF1D30830894E11CF11C232752
|
||||
:10F8E000EA16FB0639F4D70196E004C0321709F492
|
||||
:10F8F0008CC190E044E755E962E470E0ACCF90E061
|
||||
:10F9000044C08D81803311F090E00AC08F8188233C
|
||||
:10F9100011F49EE105C0813011F099E001C096E933
|
||||
:10F920001A821B828D818C838E818D839E831F82A0
|
||||
:10F9300047E050E0F4C01A8288E08B8381E48C8336
|
||||
:10F9400086E58D8382E58E8389E48F8383E58887CE
|
||||
:10F9500080E589878FE58A8782E38B874BE050E0DB
|
||||
:10F96000DEC08A81813941F0823941F0803911F459
|
||||
:10F970008FE005C080E003C082E001C08AE01A8207
|
||||
:10F980008B8343E050E0CBC091E01A8242E050E02C
|
||||
:10F99000C7C08D81882311F48EE124C0813011F01D
|
||||
:10F9A00089E020C086E91EC01A82E1E0F0E04092C2
|
||||
:10F9B0005700849118C08B81803579F48C81883010
|
||||
:10F9C00031F4E2E0F0E04092570084910BC0E0E0B7
|
||||
:10F9D000F0E040925700849105C0E3E0F0E04092EF
|
||||
:10F9E000570084911A828B831C8244E050E097C0B8
|
||||
:10F9F000BC80AA248D81082F10E00A291B29000F42
|
||||
:10FA0000111F1A828AC09A8088248B81682F70E027
|
||||
:10FA100068297929933109F033C0F7EF0F3F1F07A9
|
||||
:10FA200010F0A8013FC023E0F80120935700E895AB
|
||||
:10FA300007B600FCFDCFA801D1018C9111962C9145
|
||||
:10FA400011971296D22ECC2490E08C299D2921E08A
|
||||
:10FA5000FA010C0120935700E89511244E5F5F4F87
|
||||
:10FA60006250704051F725E0F80120935700E89567
|
||||
:10FA700007B600FCFDCF81E180935700E89512C0E6
|
||||
:10FA8000A801FB01D10141BD52BD4F5F5F4F8D9178
|
||||
:10FA900080BDFA9AF99AF999FECF3197A1F7A8019A
|
||||
:10FAA000460F571F1A828A0138C07A8066248B81DC
|
||||
:10FAB000A82FB0E0A629B7291A828981843191F450
|
||||
:10FAC000BD019E012D5F3F4FF80185919491F90191
|
||||
:10FAD000808391832E5F3F4F0E5F1F4F62507040B7
|
||||
:10FAE00099F713C0A801BD019E012D5F3F4F41BD95
|
||||
:10FAF00052BD4F5F5F4FF89A80B5F90181939F0126
|
||||
:10FB000061507040A1F70A0F1B1FAD014D5F5F4FA1
|
||||
:10FB1000F901108204C080EC8A8342E050E090E05A
|
||||
:10FB2000FBE1F093C6008091C00086FFFCCF80917E
|
||||
:10FB3000C00080648093C0005092C6008091C000D5
|
||||
:10FB400086FFFCCF8091C00080648093C000652F49
|
||||
:10FB50005093C6008091C00086FFFCCF8091C0000A
|
||||
:10FB600080648093C000342F4093C6008091C00011
|
||||
:10FB700086FFFCCF8091C00080648093C0008EE03F
|
||||
:10FB80008093C6008091C00086FFFCCF8091C000AA
|
||||
:10FB900080648093C00025E1252523272627FE01C8
|
||||
:10FBA000319610C030813093C6008091C00086FF2E
|
||||
:10FBB000FCCF31968091C00080648093C0002327E1
|
||||
:10FBC000415050404115510569F72093C60080917E
|
||||
:10FBD000C00086FFFCCF8091C00080648093C0008D
|
||||
:10FBE000992349F4539444E755E962E470E090E0C6
|
||||
:10FBF000A0E0B0E030CE5A9881E180935700E895BC
|
||||
:10FC000011241F921F920895FFCF9981933109F417
|
||||
:10FC1000FACE9431C8F4963009F4EACE973050F415
|
||||
:10FC2000923009F46CCE933009F49BCE913009F0F8
|
||||
:10FC300072CF81CE913109F4A7CE923108F0E1CE96
|
||||
:10FC4000903109F068CF5BCE983109F4B4CE993188
|
||||
:10FC500050F4953109F4D7CE953108F426CF96317A
|
||||
:10FC600009F059CF22CF9B3109F493CE9C3120F477
|
||||
:10FC70009A3109F050CF98CE9D3109F442CE9F328F
|
||||
:06FC800009F049CFB8CFE6
|
||||
:040000030000F80001
|
||||
:00000001FF
|
||||
@@ -0,0 +1,75 @@
|
||||
:10F800008FEF90E19EBF8DBF11241FBE5A9A00C09A
|
||||
:10F81000CDB7DEB7CD51D140DEBFCDBF1092C50010
|
||||
:10F820008AE08093C40088E18093C100EE24FF2425
|
||||
:10F8300020E0552400E010E039E0432E9BE0292E23
|
||||
:10F84000312C2C0E3D1ECFC14150504060407040C5
|
||||
:10F8500011F43FE206C08091C00087FFF5CF3091E0
|
||||
:10F86000C600933021F1943028F4913099F0923011
|
||||
:10F87000C8F407C0953049F1953000F19630D1F5C4
|
||||
:10F8800035C03B3119F491E02BE134C03F3291F5A2
|
||||
:10F890003983BBC1313011F0351559F52327532E6B
|
||||
:10F8A00092E028C0B32FA0E0232793E023C0832F4A
|
||||
:10F8B00090E0A82BB92B232794E01CC03E30C9F45C
|
||||
:10F8C000232795E0EE24FF2415C0E1E0F0E0EC0FE3
|
||||
:10F8D000FD1FEE0DFF1D30830894E11CF11C232752
|
||||
:10F8E000EA16FB0639F4D70196E004C0321709F492
|
||||
:10F8F0008CC190E041ED5AE363E570E0ACCF90E05D
|
||||
:10F9000044C08D81803311F090E00AC08F8188233C
|
||||
:10F9100011F49EE105C0813011F099E001C096E933
|
||||
:10F920001A821B828D818C838E818D839E831F82A0
|
||||
:10F9300047E050E0F4C01A8288E08B8381E48C8336
|
||||
:10F9400086E58D8382E58E8389E48F8383E58887CE
|
||||
:10F9500080E589878FE58A8782E38B874BE050E0DB
|
||||
:10F96000DEC08A81813941F0823941F0803911F459
|
||||
:10F970008FE005C080E003C082E001C08AE01A8207
|
||||
:10F980008B8343E050E0CBC091E01A8242E050E02C
|
||||
:10F99000C7C08D81882311F48EE124C0813011F01D
|
||||
:10F9A00089E020C086E91EC01A82E1E0F0E04092C2
|
||||
:10F9B0005700849118C08B81803579F48C81883010
|
||||
:10F9C00031F4E2E0F0E04092570084910BC0E0E0B7
|
||||
:10F9D000F0E040925700849105C0E3E0F0E04092EF
|
||||
:10F9E000570084911A828B831C8244E050E097C0B8
|
||||
:10F9F000BC80AA248D81082F10E00A291B29000F42
|
||||
:10FA0000111F1A828AC09A8088248B81682F70E027
|
||||
:10FA100068297929933109F033C0F7EF0F3F1F07A9
|
||||
:10FA200010F0A8013FC023E0F80120935700E895AB
|
||||
:10FA300007B600FCFDCFA801D1018C9111962C9145
|
||||
:10FA400011971296D22ECC2490E08C299D2921E08A
|
||||
:10FA5000FA010C0120935700E89511244E5F5F4F87
|
||||
:10FA60006250704051F725E0F80120935700E89567
|
||||
:10FA700007B600FCFDCF81E180935700E89512C0E6
|
||||
:10FA8000A801FB01D10141BD52BD4F5F5F4F8D9178
|
||||
:10FA900080BDFA9AF99AF999FECF3197A1F7A8019A
|
||||
:10FAA000460F571F1A828A0138C07A8066248B81DC
|
||||
:10FAB000A82FB0E0A629B7291A828981843191F450
|
||||
:10FAC000BD019E012D5F3F4FF80185919491F90191
|
||||
:10FAD000808391832E5F3F4F0E5F1F4F62507040B7
|
||||
:10FAE00099F713C0A801BD019E012D5F3F4F41BD95
|
||||
:10FAF00052BD4F5F5F4FF89A80B5F90181939F0126
|
||||
:10FB000061507040A1F70A0F1B1FAD014D5F5F4FA1
|
||||
:10FB1000F901108204C080EC8A8342E050E090E05A
|
||||
:10FB2000FBE1F093C6008091C00086FFFCCF80917E
|
||||
:10FB3000C00080648093C0005092C6008091C000D5
|
||||
:10FB400086FFFCCF8091C00080648093C000652F49
|
||||
:10FB50005093C6008091C00086FFFCCF8091C0000A
|
||||
:10FB600080648093C000342F4093C6008091C00011
|
||||
:10FB700086FFFCCF8091C00080648093C0008EE03F
|
||||
:10FB80008093C6008091C00086FFFCCF8091C000AA
|
||||
:10FB900080648093C00025E1252523272627FE01C8
|
||||
:10FBA000319610C030813093C6008091C00086FF2E
|
||||
:10FBB000FCCF31968091C00080648093C0002327E1
|
||||
:10FBC000415050404115510569F72093C60080917E
|
||||
:10FBD000C00086FFFCCF8091C00080648093C0008D
|
||||
:10FBE000992349F4539441ED5AE363E570E090E0C2
|
||||
:10FBF000A0E0B0E030CE5A9881E180935700E895BC
|
||||
:10FC000011241F921F920895FFCF9981933109F417
|
||||
:10FC1000FACE9431C8F4963009F4EACE973050F415
|
||||
:10FC2000923009F46CCE933009F49BCE913009F0F8
|
||||
:10FC300072CF81CE913109F4A7CE923108F0E1CE96
|
||||
:10FC4000903109F068CF5BCE983109F4B4CE993188
|
||||
:10FC500050F4953109F4D7CE953108F426CF96317A
|
||||
:10FC600009F059CF22CF9B3109F493CE9C3120F477
|
||||
:10FC70009A3109F050CF98CE9D3109F442CE9F328F
|
||||
:06FC800009F049CFB8CFE6
|
||||
:040000030000F80001
|
||||
:00000001FF
|
||||
@@ -0,0 +1,75 @@
|
||||
:10F800008FEF90E19EBF8DBF11241FBE5A9A00C09A
|
||||
:10F81000CDB7DEB7CD51D140DEBFCDBF1092C50010
|
||||
:10F8200088E08093C40088E18093C100EE24FF2427
|
||||
:10F8300020E0552400E010E039E0432E93E0292E2B
|
||||
:10F84000312C2C0E3D1ECDC14150504060407040C7
|
||||
:10F8500011F43FE206C08091C00087FFF5CF3091E0
|
||||
:10F86000C600933021F1943028F4913099F0923011
|
||||
:10F87000C8F407C0953049F1953000F19630D1F5C4
|
||||
:10F8800035C03B3119F491E02BE134C03F3291F5A2
|
||||
:10F890003983B9C1313011F0351559F52327532E6D
|
||||
:10F8A00092E028C0B32FA0E0232793E023C0832F4A
|
||||
:10F8B00090E0A82BB92B232794E01CC03E30C9F45C
|
||||
:10F8C000232795E0EE24FF2415C0E1E0F0E0EC0FE3
|
||||
:10F8D000FD1FEE0DFF1D30830894E11CF11C232752
|
||||
:10F8E000EA16FB0639F4D70196E004C0321709F492
|
||||
:10F8F0008AC190E044E755E962E470E0ACCF90E063
|
||||
:10F9000044C08D81803311F090E00AC08F8188233C
|
||||
:10F9100011F49EE105C0813011F09AE001C096E932
|
||||
:10F920001A821B828D818C838E818D839E831F82A0
|
||||
:10F9300047E050E0F2C01A8288E08B8381E48C8338
|
||||
:10F9400086E58D8382E58E8389E48F8383E58887CE
|
||||
:10F9500080E589878FE58A8782E38B874BE050E0DB
|
||||
:10F96000DCC08A81813941F0823941F0803911F45B
|
||||
:10F970008FE005C080E003C082E001C08AE01A8207
|
||||
:10F980008B8343E050E0C9C091E01A8242E050E02E
|
||||
:10F99000C5C08D81882311F48EE124C0813011F01F
|
||||
:10F9A0008AE020C086E91EC01A82E1E0F0E04092C1
|
||||
:10F9B0005700849118C08B81803579F48C81883010
|
||||
:10F9C00031F4E2E0F0E04092570084910BC0E0E0B7
|
||||
:10F9D000F0E040925700849105C0E3E0F0E04092EF
|
||||
:10F9E000570084911A828B831C8244E050E095C0BA
|
||||
:10F9F000BC80AA248D81082F10E00A291B29000F42
|
||||
:10FA0000111F1A8288C09A8088248B81682F70E029
|
||||
:10FA100068297929933109F034C0F7EF0F3F1F07A8
|
||||
:10FA200010F0A80141C023E0F80120935700E895A9
|
||||
:10FA300007B600FCFDCFA801DE011B968C91119644
|
||||
:10FA40002C9111971296D22ECC2490E08C299D29CE
|
||||
:10FA500021E0FA010C0120935700E89511244E5F34
|
||||
:10FA60005F4F6250704051F725E0F8012093570036
|
||||
:10FA7000E89507B600FCFDCF81E180935700E8953B
|
||||
:10FA800013C0A801FB01DE011B9641BD52BD4F5FB3
|
||||
:10FA90005F4F8D9180BDFA9AF99AF999FECF31970F
|
||||
:10FAA000A1F7A801460F571F1A828A0134C07A8035
|
||||
:10FAB00066248B81A82FB0E0A629B7291A828981F4
|
||||
:10FAC000843181F4BD019101F80185919491F9018E
|
||||
:10FAD000808391832E5F3F4F0E5F1F4F62507040B7
|
||||
:10FAE00099F711C0A801BD01910141BD52BD4F5F01
|
||||
:10FAF0005F4FF89A80B5F90181939F016150704082
|
||||
:10FB0000A1F70A0F1B1FAD014D5F5F4FF901108276
|
||||
:10FB100004C080EC8A8342E050E090E0FBE1F09387
|
||||
:10FB2000C6008091C00086FFFCCF8091C000806439
|
||||
:10FB30008093C0005092C6008091C00086FFFCCF29
|
||||
:10FB40008091C00080648093C000652F5093C600F0
|
||||
:10FB50008091C00086FFFCCF8091C00080648093BC
|
||||
:10FB6000C000342F4093C6008091C00086FFFCCFB8
|
||||
:10FB70008091C00080648093C0008EE08093C600B6
|
||||
:10FB80008091C00086FFFCCF8091C000806480938C
|
||||
:10FB9000C00025E1252523272627FE01319610C028
|
||||
:10FBA00030813093C6008091C00086FFFCCF319633
|
||||
:10FBB0008091C00080648093C00023274150504052
|
||||
:10FBC0004115510569F72093C6008091C00086FF5A
|
||||
:10FBD000FCCF8091C00080648093C000992349F4D9
|
||||
:10FBE000539444E755E962E470E090E0A0E0B0E0AF
|
||||
:10FBF00032CE5A9881E180935700E89511241F92E4
|
||||
:10FC00001F920895FFCF9981933109F4FCCE94316E
|
||||
:10FC1000C8F4963009F4ECCE973050F4923009F4E1
|
||||
:10FC20006ECE933009F49DCE913009F072CF83CE21
|
||||
:10FC3000913109F4A9CE923108F0E3CE903109F068
|
||||
:10FC400068CF5DCE983109F4B6CE993150F4953134
|
||||
:10FC500009F4D9CE953108F42ACF963109F059CF5D
|
||||
:10FC600026CF9B3109F495CE9C3120F49A3109F0CE
|
||||
:10FC700050CF9ACE9D3109F444CE9F3209F049CF3E
|
||||
:02FC8000B8CFFB
|
||||
:040000030000F80001
|
||||
:00000001FF
|
||||
@@ -0,0 +1,75 @@
|
||||
:10F800008FEF90E19EBF8DBF11241FBE5A9A00C09A
|
||||
:10F81000CDB7DEB7CD51D140DEBFCDBF1092C50010
|
||||
:10F820008AE08093C40088E18093C100EE24FF2425
|
||||
:10F8300020E0552400E010E039E0432E93E0292E2B
|
||||
:10F84000312C2C0E3D1ECDC14150504060407040C7
|
||||
:10F8500011F43FE206C08091C00087FFF5CF3091E0
|
||||
:10F86000C600933021F1943028F4913099F0923011
|
||||
:10F87000C8F407C0953049F1953000F19630D1F5C4
|
||||
:10F8800035C03B3119F491E02BE134C03F3291F5A2
|
||||
:10F890003983B9C1313011F0351559F52327532E6D
|
||||
:10F8A00092E028C0B32FA0E0232793E023C0832F4A
|
||||
:10F8B00090E0A82BB92B232794E01CC03E30C9F45C
|
||||
:10F8C000232795E0EE24FF2415C0E1E0F0E0EC0FE3
|
||||
:10F8D000FD1FEE0DFF1D30830894E11CF11C232752
|
||||
:10F8E000EA16FB0639F4D70196E004C0321709F492
|
||||
:10F8F0008AC190E041ED5AE363E570E0ACCF90E05F
|
||||
:10F9000044C08D81803311F090E00AC08F8188233C
|
||||
:10F9100011F49EE105C0813011F09AE001C096E932
|
||||
:10F920001A821B828D818C838E818D839E831F82A0
|
||||
:10F9300047E050E0F2C01A8288E08B8381E48C8338
|
||||
:10F9400086E58D8382E58E8389E48F8383E58887CE
|
||||
:10F9500080E589878FE58A8782E38B874BE050E0DB
|
||||
:10F96000DCC08A81813941F0823941F0803911F45B
|
||||
:10F970008FE005C080E003C082E001C08AE01A8207
|
||||
:10F980008B8343E050E0C9C091E01A8242E050E02E
|
||||
:10F99000C5C08D81882311F48EE124C0813011F01F
|
||||
:10F9A0008AE020C086E91EC01A82E1E0F0E04092C1
|
||||
:10F9B0005700849118C08B81803579F48C81883010
|
||||
:10F9C00031F4E2E0F0E04092570084910BC0E0E0B7
|
||||
:10F9D000F0E040925700849105C0E3E0F0E04092EF
|
||||
:10F9E000570084911A828B831C8244E050E095C0BA
|
||||
:10F9F000BC80AA248D81082F10E00A291B29000F42
|
||||
:10FA0000111F1A8288C09A8088248B81682F70E029
|
||||
:10FA100068297929933109F034C0F7EF0F3F1F07A8
|
||||
:10FA200010F0A80141C023E0F80120935700E895A9
|
||||
:10FA300007B600FCFDCFA801DE011B968C91119644
|
||||
:10FA40002C9111971296D22ECC2490E08C299D29CE
|
||||
:10FA500021E0FA010C0120935700E89511244E5F34
|
||||
:10FA60005F4F6250704051F725E0F8012093570036
|
||||
:10FA7000E89507B600FCFDCF81E180935700E8953B
|
||||
:10FA800013C0A801FB01DE011B9641BD52BD4F5FB3
|
||||
:10FA90005F4F8D9180BDFA9AF99AF999FECF31970F
|
||||
:10FAA000A1F7A801460F571F1A828A0134C07A8035
|
||||
:10FAB00066248B81A82FB0E0A629B7291A828981F4
|
||||
:10FAC000843181F4BD019101F80185919491F9018E
|
||||
:10FAD000808391832E5F3F4F0E5F1F4F62507040B7
|
||||
:10FAE00099F711C0A801BD01910141BD52BD4F5F01
|
||||
:10FAF0005F4FF89A80B5F90181939F016150704082
|
||||
:10FB0000A1F70A0F1B1FAD014D5F5F4FF901108276
|
||||
:10FB100004C080EC8A8342E050E090E0FBE1F09387
|
||||
:10FB2000C6008091C00086FFFCCF8091C000806439
|
||||
:10FB30008093C0005092C6008091C00086FFFCCF29
|
||||
:10FB40008091C00080648093C000652F5093C600F0
|
||||
:10FB50008091C00086FFFCCF8091C00080648093BC
|
||||
:10FB6000C000342F4093C6008091C00086FFFCCFB8
|
||||
:10FB70008091C00080648093C0008EE08093C600B6
|
||||
:10FB80008091C00086FFFCCF8091C000806480938C
|
||||
:10FB9000C00025E1252523272627FE01319610C028
|
||||
:10FBA00030813093C6008091C00086FFFCCF319633
|
||||
:10FBB0008091C00080648093C00023274150504052
|
||||
:10FBC0004115510569F72093C6008091C00086FF5A
|
||||
:10FBD000FCCF8091C00080648093C000992349F4D9
|
||||
:10FBE000539441ED5AE363E570E090E0A0E0B0E0AB
|
||||
:10FBF00032CE5A9881E180935700E89511241F92E4
|
||||
:10FC00001F920895FFCF9981933109F4FCCE94316E
|
||||
:10FC1000C8F4963009F4ECCE973050F4923009F4E1
|
||||
:10FC20006ECE933009F49DCE913009F072CF83CE21
|
||||
:10FC3000913109F4A9CE923108F0E3CE903109F068
|
||||
:10FC400068CF5DCE983109F4B6CE993150F4953134
|
||||
:10FC500009F4D9CE953108F42ACF963109F059CF5D
|
||||
:10FC600026CF9B3109F495CE9C3120F49A3109F0CE
|
||||
:10FC700050CF9ACE9D3109F444CE9F3209F049CF3E
|
||||
:02FC8000B8CFFB
|
||||
:040000030000F80001
|
||||
:00000001FF
|
||||
@@ -0,0 +1,239 @@
|
||||
/*
|
||||
HardwareSerial.cpp - Hardware serial library for Wiring
|
||||
Copyright (c) 2006 Nicholas Zambetti. All right reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Modified 23 November 2006 by David A. Mellis
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include "wiring.h"
|
||||
#include "wiring_private.h"
|
||||
|
||||
#include "HardwareSerial.h"
|
||||
|
||||
// Define constants and variables for buffering incoming serial data. We're
|
||||
// using a ring buffer (I think), in which rx_buffer_head is the index of the
|
||||
// location to which to write the next incoming character and rx_buffer_tail
|
||||
// is the index of the location from which to read.
|
||||
#define RX_BUFFER_SIZE 128
|
||||
|
||||
struct ring_buffer {
|
||||
unsigned char buffer[RX_BUFFER_SIZE];
|
||||
int head;
|
||||
int tail;
|
||||
};
|
||||
|
||||
ring_buffer rx_buffer = { { 0 }, 0, 0 };
|
||||
|
||||
#ifdef UDR1
|
||||
ring_buffer rx_buffer1 = { { 0 }, 0, 0 };
|
||||
#endif
|
||||
|
||||
#ifdef UDR2
|
||||
ring_buffer rx_buffer2 = { { 0 }, 0, 0 };
|
||||
#endif
|
||||
#ifdef UDR3
|
||||
ring_buffer rx_buffer3 = { { 0 }, 0, 0 };
|
||||
#endif
|
||||
|
||||
inline void store_char(unsigned char c, ring_buffer *rx_buffer)
|
||||
{
|
||||
int i = (rx_buffer->head + 1) % RX_BUFFER_SIZE;
|
||||
|
||||
// if we should be storing the received character into the location
|
||||
// just before the tail (meaning that the head would advance to the
|
||||
// current location of the tail), we're about to overflow the buffer
|
||||
// and so we don't write the character or advance the head.
|
||||
if (i != rx_buffer->tail) {
|
||||
rx_buffer->buffer[rx_buffer->head] = c;
|
||||
rx_buffer->head = i;
|
||||
}
|
||||
}
|
||||
|
||||
ISR(USART0_RX_vect)
|
||||
{
|
||||
unsigned char c = UDR0;
|
||||
store_char(c, &rx_buffer);
|
||||
}
|
||||
|
||||
#ifdef UDR1
|
||||
ISR(USART1_RX_vect)
|
||||
{
|
||||
unsigned char c = UDR1;
|
||||
store_char(c, &rx_buffer1);
|
||||
}
|
||||
|
||||
#ifdef UDR2
|
||||
ISR(USART2_RX_vect)
|
||||
{
|
||||
unsigned char c = UDR2;
|
||||
store_char(c, &rx_buffer2);
|
||||
}
|
||||
|
||||
#ifdef UDR2
|
||||
ISR(USART3_RX_vect)
|
||||
{
|
||||
unsigned char c = UDR3;
|
||||
store_char(c, &rx_buffer3);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#if defined(__AVR_ATmega8__)
|
||||
SIGNAL(SIG_UART_RECV)
|
||||
#else
|
||||
SIGNAL(USART_RX_vect)
|
||||
#endif
|
||||
{
|
||||
#if defined(__AVR_ATmega8__)
|
||||
unsigned char c = UDR;
|
||||
#else
|
||||
unsigned char c = UDR0;
|
||||
#endif
|
||||
store_char(c, &rx_buffer);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Constructors ////////////////////////////////////////////////////////////////
|
||||
|
||||
HardwareSerial::HardwareSerial(ring_buffer *rx_buffer,
|
||||
volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
|
||||
volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
|
||||
volatile uint8_t *udr,
|
||||
uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udre, uint8_t u2x)
|
||||
{
|
||||
_rx_buffer = rx_buffer;
|
||||
_ubrrh = ubrrh;
|
||||
_ubrrl = ubrrl;
|
||||
_ucsra = ucsra;
|
||||
_ucsrb = ucsrb;
|
||||
_udr = udr;
|
||||
_rxen = rxen;
|
||||
_txen = txen;
|
||||
_rxcie = rxcie;
|
||||
_udre = udre;
|
||||
_u2x = u2x;
|
||||
}
|
||||
|
||||
// Public Methods //////////////////////////////////////////////////////////////
|
||||
|
||||
void HardwareSerial::begin(long baud)
|
||||
{
|
||||
uint16_t baud_setting;
|
||||
bool use_u2x;
|
||||
|
||||
// U2X mode is needed for baud rates higher than (CPU Hz / 16)
|
||||
if (baud > F_CPU / 16) {
|
||||
use_u2x = true;
|
||||
} else {
|
||||
// figure out if U2X mode would allow for a better connection
|
||||
|
||||
// calculate the percent difference between the baud-rate specified and
|
||||
// the real baud rate for both U2X and non-U2X mode (0-255 error percent)
|
||||
uint8_t nonu2x_baud_error = abs((int)(255-((F_CPU/(16*(((F_CPU/8/baud-1)/2)+1))*255)/baud)));
|
||||
uint8_t u2x_baud_error = abs((int)(255-((F_CPU/(8*(((F_CPU/4/baud-1)/2)+1))*255)/baud)));
|
||||
|
||||
// prefer non-U2X mode because it handles clock skew better
|
||||
use_u2x = (nonu2x_baud_error > u2x_baud_error);
|
||||
}
|
||||
|
||||
if (use_u2x) {
|
||||
*_ucsra = 1 << _u2x;
|
||||
baud_setting = (F_CPU / 4 / baud - 1) / 2;
|
||||
} else {
|
||||
*_ucsra = 0;
|
||||
baud_setting = (F_CPU / 8 / baud - 1) / 2;
|
||||
}
|
||||
|
||||
// assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)
|
||||
*_ubrrh = baud_setting >> 8;
|
||||
*_ubrrl = baud_setting;
|
||||
|
||||
sbi(*_ucsrb, _rxen);
|
||||
sbi(*_ucsrb, _txen);
|
||||
sbi(*_ucsrb, _rxcie);
|
||||
}
|
||||
|
||||
void HardwareSerial::end()
|
||||
{
|
||||
cbi(*_ucsrb, _rxen);
|
||||
cbi(*_ucsrb, _txen);
|
||||
cbi(*_ucsrb, _rxcie);
|
||||
}
|
||||
|
||||
uint8_t HardwareSerial::available(void)
|
||||
{
|
||||
return (RX_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % RX_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
int HardwareSerial::read(void)
|
||||
{
|
||||
// if the head isn't ahead of the tail, we don't have any characters
|
||||
if (_rx_buffer->head == _rx_buffer->tail) {
|
||||
return -1;
|
||||
} else {
|
||||
unsigned char c = _rx_buffer->buffer[_rx_buffer->tail];
|
||||
_rx_buffer->tail = (_rx_buffer->tail + 1) % RX_BUFFER_SIZE;
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
void HardwareSerial::flush()
|
||||
{
|
||||
// don't reverse this or there may be problems if the RX interrupt
|
||||
// occurs after reading the value of rx_buffer_head but before writing
|
||||
// the value to rx_buffer_tail; the previous value of rx_buffer_head
|
||||
// may be written to rx_buffer_tail, making it appear as if the buffer
|
||||
// don't reverse this or there may be problems if the RX interrupt
|
||||
// occurs after reading the value of rx_buffer_head but before writing
|
||||
// the value to rx_buffer_tail; the previous value of rx_buffer_head
|
||||
// may be written to rx_buffer_tail, making it appear as if the buffer
|
||||
// were full, not empty.
|
||||
_rx_buffer->head = _rx_buffer->tail;
|
||||
}
|
||||
|
||||
void HardwareSerial::write(uint8_t c)
|
||||
{
|
||||
while (!((*_ucsra) & (1 << _udre)))
|
||||
;
|
||||
|
||||
*_udr = c;
|
||||
}
|
||||
|
||||
// Preinstantiate Objects //////////////////////////////////////////////////////
|
||||
|
||||
#if defined(__AVR_ATmega8__)
|
||||
HardwareSerial Serial(&rx_buffer, &UBRRH, &UBRRL, &UCSRA, &UCSRB, &UDR, RXEN, TXEN, RXCIE, UDRE, U2X);
|
||||
#else
|
||||
HardwareSerial Serial(&rx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRE0, U2X0);
|
||||
#endif
|
||||
|
||||
#ifdef UDR1
|
||||
HardwareSerial Serial1(&rx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UDR1, RXEN1, TXEN1, RXCIE1, UDRE1, U2X1);
|
||||
#endif
|
||||
|
||||
#ifdef UDR2
|
||||
HardwareSerial Serial2(&rx_buffer2, &UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UDR2, RXEN2, TXEN2, RXCIE2, UDRE2, U2X2);
|
||||
#endif
|
||||
#ifdef UDR3
|
||||
HardwareSerial Serial3(&rx_buffer3, &UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UDR3, RXEN3, TXEN3, RXCIE3, UDRE3, U2X3);
|
||||
#endif
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
HardwareSerial.h - Hardware serial library for Wiring
|
||||
Copyright (c) 2006 Nicholas Zambetti. All right reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef HardwareSerial_h
|
||||
#define HardwareSerial_h
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "Print.h"
|
||||
|
||||
struct ring_buffer;
|
||||
|
||||
class HardwareSerial : public Print
|
||||
{
|
||||
private:
|
||||
ring_buffer *_rx_buffer;
|
||||
volatile uint8_t *_ubrrh;
|
||||
volatile uint8_t *_ubrrl;
|
||||
volatile uint8_t *_ucsra;
|
||||
volatile uint8_t *_ucsrb;
|
||||
volatile uint8_t *_udr;
|
||||
uint8_t _rxen;
|
||||
uint8_t _txen;
|
||||
uint8_t _rxcie;
|
||||
uint8_t _udre;
|
||||
uint8_t _u2x;
|
||||
public:
|
||||
HardwareSerial(ring_buffer *rx_buffer,
|
||||
volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
|
||||
volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
|
||||
volatile uint8_t *udr,
|
||||
uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udre, uint8_t u2x);
|
||||
void begin(long);
|
||||
void end();
|
||||
uint8_t available(void);
|
||||
int read(void);
|
||||
void flush(void);
|
||||
virtual void write(uint8_t);
|
||||
using Print::write; // pull in write(str) and write(buf, size) from Print
|
||||
};
|
||||
|
||||
extern HardwareSerial Serial;
|
||||
|
||||
#if defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1280__)
|
||||
extern HardwareSerial Serial1;
|
||||
#endif
|
||||
|
||||
#if defined(__AVR_ATmega1280__)
|
||||
extern HardwareSerial Serial2;
|
||||
extern HardwareSerial Serial3;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,243 @@
|
||||
# Arduino 0011 Makefile
|
||||
# Arduino adaptation by mellis, eighthave, oli.keller
|
||||
#
|
||||
# This makefile allows you to build sketches from the command line
|
||||
# without the Arduino environment (or Java).
|
||||
#
|
||||
# Detailed instructions for using the makefile:
|
||||
#
|
||||
# 1. Copy this file into the folder with your sketch. There should be a
|
||||
# file with the same name as the folder and with the extension .pde
|
||||
# (e.g. foo.pde in the foo/ folder).
|
||||
#
|
||||
# 2. Modify the line containg "INSTALL_DIR" to point to the directory that
|
||||
# contains the Arduino installation (for example, under Mac OS X, this
|
||||
# might be /Applications/arduino-0012).
|
||||
#
|
||||
# 3. Modify the line containing "PORT" to refer to the filename
|
||||
# representing the USB or serial connection to your Arduino board
|
||||
# (e.g. PORT = /dev/tty.USB0). If the exact name of this file
|
||||
# changes, you can use * as a wildcard (e.g. PORT = /dev/tty.usb*).
|
||||
#
|
||||
# 4. Set the line containing "MCU" to match your board's processor.
|
||||
# Older one's are atmega8 based, newer ones like Arduino Mini, Bluetooth
|
||||
# or Diecimila have the atmega168. If you're using a LilyPad Arduino,
|
||||
# change F_CPU to 8000000.
|
||||
#
|
||||
# 5. At the command line, change to the directory containing your
|
||||
# program's file and the makefile.
|
||||
#
|
||||
# 6. Type "make" and press enter to compile/verify your program.
|
||||
#
|
||||
# 7. Type "make upload", reset your Arduino board, and press enter to
|
||||
# upload your program to the Arduino board.
|
||||
#
|
||||
# $Id$
|
||||
|
||||
TARGET = $(notdir $(CURDIR))
|
||||
INSTALL_DIR = /Users/dmellis/Source/arduino/trunk/build/macosx/build/work
|
||||
PORT = /dev/tty.usb*
|
||||
UPLOAD_RATE = 19200
|
||||
AVRDUDE_PROGRAMMER = stk500v1
|
||||
MCU = atmega168
|
||||
F_CPU = 16000000
|
||||
|
||||
############################################################################
|
||||
# Below here nothing should be changed...
|
||||
|
||||
ARDUINO = $(INSTALL_DIR)/hardware/cores/arduino
|
||||
AVR_TOOLS_PATH = $(INSTALL_DIR)/hardware/tools/avr/bin
|
||||
SRC = $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \
|
||||
$(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \
|
||||
$(ARDUINO)/wiring_pulse.c $(ARDUINO)/wiring_serial.c \
|
||||
$(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c
|
||||
CXXSRC = $(ARDUINO)/HardwareSerial.cpp $(ARDUINO)/WMath.cpp
|
||||
FORMAT = ihex
|
||||
|
||||
|
||||
# Name of this Makefile (used for "make depend").
|
||||
MAKEFILE = Makefile
|
||||
|
||||
# Debugging format.
|
||||
# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
|
||||
# AVR (extended) COFF requires stabs, plus an avr-objcopy run.
|
||||
DEBUG = stabs
|
||||
|
||||
OPT = s
|
||||
|
||||
# Place -D or -U options here
|
||||
CDEFS = -DF_CPU=$(F_CPU)
|
||||
CXXDEFS = -DF_CPU=$(F_CPU)
|
||||
|
||||
# Place -I options here
|
||||
CINCS = -I$(ARDUINO)
|
||||
CXXINCS = -I$(ARDUINO)
|
||||
|
||||
# Compiler flag to set the C Standard level.
|
||||
# c89 - "ANSI" C
|
||||
# gnu89 - c89 plus GCC extensions
|
||||
# c99 - ISO C99 standard (not yet fully implemented)
|
||||
# gnu99 - c99 plus GCC extensions
|
||||
CSTANDARD = -std=gnu99
|
||||
CDEBUG = -g$(DEBUG)
|
||||
CWARN = -Wall -Wstrict-prototypes
|
||||
CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
|
||||
#CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
|
||||
|
||||
CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA)
|
||||
CXXFLAGS = $(CDEFS) $(CINCS) -O$(OPT)
|
||||
#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
|
||||
LDFLAGS = -lm
|
||||
|
||||
|
||||
# Programming support using avrdude. Settings and variables.
|
||||
AVRDUDE_PORT = $(PORT)
|
||||
AVRDUDE_WRITE_FLASH = -U flash:w:applet/$(TARGET).hex
|
||||
AVRDUDE_FLAGS = -V -F -C $(INSTALL_DIR)/hardware/tools/avr/etc/avrdude.conf \
|
||||
-p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \
|
||||
-b $(UPLOAD_RATE)
|
||||
|
||||
# Program settings
|
||||
CC = $(AVR_TOOLS_PATH)/avr-gcc
|
||||
CXX = $(AVR_TOOLS_PATH)/avr-g++
|
||||
OBJCOPY = $(AVR_TOOLS_PATH)/avr-objcopy
|
||||
OBJDUMP = $(AVR_TOOLS_PATH)/avr-objdump
|
||||
AR = $(AVR_TOOLS_PATH)/avr-ar
|
||||
SIZE = $(AVR_TOOLS_PATH)/avr-size
|
||||
NM = $(AVR_TOOLS_PATH)/avr-nm
|
||||
AVRDUDE = $(AVR_TOOLS_PATH)/avrdude
|
||||
REMOVE = rm -f
|
||||
MV = mv -f
|
||||
|
||||
# Define all object files.
|
||||
OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o)
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst)
|
||||
|
||||
# Combine all necessary flags and optional flags.
|
||||
# Add target processor to flags.
|
||||
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
|
||||
ALL_CXXFLAGS = -mmcu=$(MCU) -I. $(CXXFLAGS)
|
||||
ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
|
||||
|
||||
|
||||
# Default target.
|
||||
all: applet_files build sizeafter
|
||||
|
||||
build: elf hex
|
||||
|
||||
applet_files: $(TARGET).pde
|
||||
# Here is the "preprocessing".
|
||||
# It creates a .cpp file based with the same name as the .pde file.
|
||||
# On top of the new .cpp file comes the WProgram.h header.
|
||||
# At the end there is a generic main() function attached.
|
||||
# Then the .cpp file will be compiled. Errors during compile will
|
||||
# refer to this new, automatically generated, file.
|
||||
# Not the original .pde file you actually edit...
|
||||
test -d applet || mkdir applet
|
||||
echo '#include "WProgram.h"' > applet/$(TARGET).cpp
|
||||
cat $(TARGET).pde >> applet/$(TARGET).cpp
|
||||
cat $(ARDUINO)/main.cxx >> applet/$(TARGET).cpp
|
||||
|
||||
elf: applet/$(TARGET).elf
|
||||
hex: applet/$(TARGET).hex
|
||||
eep: applet/$(TARGET).eep
|
||||
lss: applet/$(TARGET).lss
|
||||
sym: applet/$(TARGET).sym
|
||||
|
||||
# Program the device.
|
||||
upload: applet/$(TARGET).hex
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
|
||||
|
||||
|
||||
# Display size of file.
|
||||
HEXSIZE = $(SIZE) --target=$(FORMAT) applet/$(TARGET).hex
|
||||
ELFSIZE = $(SIZE) applet/$(TARGET).elf
|
||||
sizebefore:
|
||||
@if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
|
||||
|
||||
sizeafter:
|
||||
@if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(HEXSIZE); echo; fi
|
||||
|
||||
|
||||
# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
|
||||
COFFCONVERT=$(OBJCOPY) --debugging \
|
||||
--change-section-address .data-0x800000 \
|
||||
--change-section-address .bss-0x800000 \
|
||||
--change-section-address .noinit-0x800000 \
|
||||
--change-section-address .eeprom-0x810000
|
||||
|
||||
|
||||
coff: applet/$(TARGET).elf
|
||||
$(COFFCONVERT) -O coff-avr applet/$(TARGET).elf $(TARGET).cof
|
||||
|
||||
|
||||
extcoff: $(TARGET).elf
|
||||
$(COFFCONVERT) -O coff-ext-avr applet/$(TARGET).elf $(TARGET).cof
|
||||
|
||||
|
||||
.SUFFIXES: .elf .hex .eep .lss .sym
|
||||
|
||||
.elf.hex:
|
||||
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
|
||||
|
||||
.elf.eep:
|
||||
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
||||
--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
|
||||
|
||||
# Create extended listing file from ELF output file.
|
||||
.elf.lss:
|
||||
$(OBJDUMP) -h -S $< > $@
|
||||
|
||||
# Create a symbol table from ELF output file.
|
||||
.elf.sym:
|
||||
$(NM) -n $< > $@
|
||||
|
||||
# Link: create ELF output file from library.
|
||||
applet/$(TARGET).elf: $(TARGET).pde applet/core.a
|
||||
$(CC) $(ALL_CFLAGS) -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS)
|
||||
|
||||
applet/core.a: $(OBJ)
|
||||
@for i in $(OBJ); do echo $(AR) rcs applet/core.a $$i; $(AR) rcs applet/core.a $$i; done
|
||||
|
||||
|
||||
|
||||
# Compile: create object files from C++ source files.
|
||||
.cpp.o:
|
||||
$(CXX) -c $(ALL_CXXFLAGS) $< -o $@
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
.c.o:
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create assembler files from C source files.
|
||||
.c.s:
|
||||
$(CC) -S $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Assemble: create object files from assembler source files.
|
||||
.S.o:
|
||||
$(CC) -c $(ALL_ASFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
clean:
|
||||
$(REMOVE) applet/$(TARGET).hex applet/$(TARGET).eep applet/$(TARGET).cof applet/$(TARGET).elf \
|
||||
applet/$(TARGET).map applet/$(TARGET).sym applet/$(TARGET).lss applet/core.a \
|
||||
$(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
|
||||
|
||||
depend:
|
||||
if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \
|
||||
then \
|
||||
sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \
|
||||
$(MAKEFILE).$$$$ && \
|
||||
$(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \
|
||||
fi
|
||||
echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \
|
||||
>> $(MAKEFILE); \
|
||||
$(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE)
|
||||
|
||||
.PHONY: all build elf hex eep lss sym program coff extcoff clean depend applet_files sizebefore sizeafter
|
||||
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
Print.cpp - Base class that provides print() and println()
|
||||
Copyright (c) 2008 David A. Mellis. All right reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Modified 23 November 2006 by David A. Mellis
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <math.h>
|
||||
#include "wiring.h"
|
||||
|
||||
#include "Print.h"
|
||||
|
||||
// Public Methods //////////////////////////////////////////////////////////////
|
||||
|
||||
void Print::print(uint8_t b)
|
||||
{
|
||||
this->write(b);
|
||||
}
|
||||
|
||||
void Print::print(char c)
|
||||
{
|
||||
print((byte) c);
|
||||
}
|
||||
|
||||
void Print::print(const char c[])
|
||||
{
|
||||
while (*c)
|
||||
print(*c++);
|
||||
}
|
||||
|
||||
void Print::print(int n)
|
||||
{
|
||||
print((long) n);
|
||||
}
|
||||
|
||||
void Print::print(unsigned int n)
|
||||
{
|
||||
print((unsigned long) n);
|
||||
}
|
||||
|
||||
void Print::print(long n)
|
||||
{
|
||||
if (n < 0) {
|
||||
print('-');
|
||||
n = -n;
|
||||
}
|
||||
printNumber(n, 10);
|
||||
}
|
||||
|
||||
void Print::print(unsigned long n)
|
||||
{
|
||||
printNumber(n, 10);
|
||||
}
|
||||
|
||||
void Print::print(long n, int base)
|
||||
{
|
||||
if (base == 0)
|
||||
print((char) n);
|
||||
else if (base == 10)
|
||||
print(n);
|
||||
else
|
||||
printNumber(n, base);
|
||||
}
|
||||
|
||||
void Print::print(double n)
|
||||
{
|
||||
printFloat(n, 2);
|
||||
}
|
||||
|
||||
void Print::println(void)
|
||||
{
|
||||
print('\r');
|
||||
print('\n');
|
||||
}
|
||||
|
||||
void Print::println(char c)
|
||||
{
|
||||
print(c);
|
||||
println();
|
||||
}
|
||||
|
||||
void Print::println(const char c[])
|
||||
{
|
||||
print(c);
|
||||
println();
|
||||
}
|
||||
|
||||
void Print::println(uint8_t b)
|
||||
{
|
||||
print(b);
|
||||
println();
|
||||
}
|
||||
|
||||
void Print::println(int n)
|
||||
{
|
||||
print(n);
|
||||
println();
|
||||
}
|
||||
|
||||
void Print::println(unsigned int n)
|
||||
{
|
||||
print(n);
|
||||
println();
|
||||
}
|
||||
|
||||
void Print::println(long n)
|
||||
{
|
||||
print(n);
|
||||
println();
|
||||
}
|
||||
|
||||
void Print::println(unsigned long n)
|
||||
{
|
||||
print(n);
|
||||
println();
|
||||
}
|
||||
|
||||
void Print::println(long n, int base)
|
||||
{
|
||||
print(n, base);
|
||||
println();
|
||||
}
|
||||
|
||||
void Print::println(double n)
|
||||
{
|
||||
print(n);
|
||||
println();
|
||||
}
|
||||
|
||||
// Private Methods /////////////////////////////////////////////////////////////
|
||||
|
||||
void Print::printNumber(unsigned long n, uint8_t base)
|
||||
{
|
||||
unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars.
|
||||
unsigned long i = 0;
|
||||
|
||||
if (n == 0) {
|
||||
print('0');
|
||||
return;
|
||||
}
|
||||
|
||||
while (n > 0) {
|
||||
buf[i++] = n % base;
|
||||
n /= base;
|
||||
}
|
||||
|
||||
for (; i > 0; i--)
|
||||
print((char) (buf[i - 1] < 10 ?
|
||||
'0' + buf[i - 1] :
|
||||
'A' + buf[i - 1] - 10));
|
||||
}
|
||||
|
||||
void Print::printFloat(double number, uint8_t digits)
|
||||
{
|
||||
// Handle negative numbers
|
||||
if (number < 0.0)
|
||||
{
|
||||
print('-');
|
||||
number = -number;
|
||||
}
|
||||
|
||||
// Round correctly so that print(1.999, 2) prints as "2.00"
|
||||
double rounding = 0.5;
|
||||
for (uint8_t i=0; i<digits; ++i)
|
||||
rounding /= 10.0;
|
||||
|
||||
number += rounding;
|
||||
|
||||
// Extract the integer part of the number and print it
|
||||
unsigned long int_part = (unsigned long)number;
|
||||
double remainder = number - (double)int_part;
|
||||
print(int_part);
|
||||
|
||||
// Print the decimal point, but only if there are digits beyond
|
||||
if (digits > 0)
|
||||
print(".");
|
||||
|
||||
// Extract digits from the remainder one at a time
|
||||
while (digits-- > 0)
|
||||
{
|
||||
remainder *= 10.0;
|
||||
int toPrint = int(remainder);
|
||||
print(toPrint);
|
||||
remainder -= toPrint;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
Print.h - Base class that provides print() and println()
|
||||
Copyright (c) 2008 David A. Mellis. All right reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef Print_h
|
||||
#define Print_h
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#define DEC 10
|
||||
#define HEX 16
|
||||
#define OCT 8
|
||||
#define BIN 2
|
||||
#define BYTE 0
|
||||
|
||||
class Print
|
||||
{
|
||||
private:
|
||||
void printNumber(unsigned long, uint8_t);
|
||||
void printFloat(double, uint8_t);
|
||||
public:
|
||||
virtual void write(uint8_t);
|
||||
void print(char);
|
||||
void print(const char[]);
|
||||
void print(uint8_t);
|
||||
void print(int);
|
||||
void print(unsigned int);
|
||||
void print(long);
|
||||
void print(unsigned long);
|
||||
void print(long, int);
|
||||
void print(double);
|
||||
void println(void);
|
||||
void println(char);
|
||||
void println(const char[]);
|
||||
void println(uint8_t);
|
||||
void println(int);
|
||||
void println(unsigned int);
|
||||
void println(long);
|
||||
void println(unsigned long);
|
||||
void println(long, int);
|
||||
void println(double);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,515 @@
|
||||
/* Tone.cpp
|
||||
|
||||
A Tone Generator Library
|
||||
|
||||
Written by Brett Hagman
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- -------- --------
|
||||
0001 B Hagman 09/08/02 Initial coding
|
||||
0002 B Hagman 09/08/18 Multiple pins
|
||||
0003 B Hagman 09/08/18 Moved initialization from constructor to begin()
|
||||
0004 B Hagman 09/09/26 Fixed problems with ATmega8
|
||||
0005 B Hagman 09/11/23 Scanned prescalars for best fit on 8 bit timers
|
||||
09/11/25 Changed pin toggle method to XOR
|
||||
09/11/25 Fixed timer0 from being excluded
|
||||
0006 D Mellis 09/12/29 Replaced objects with functions
|
||||
|
||||
*************************************************/
|
||||
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <wiring.h>
|
||||
#include <pins_arduino.h>
|
||||
|
||||
#if defined(__AVR_ATmega8__)
|
||||
#define TCCR2A TCCR2
|
||||
#define TCCR2B TCCR2
|
||||
#define COM2A1 COM21
|
||||
#define COM2A0 COM20
|
||||
#define OCR2A OCR2
|
||||
#define TIMSK2 TIMSK
|
||||
#define OCIE2A OCIE2
|
||||
#define TIMER2_COMPA_vect TIMER2_COMP_vect
|
||||
#define TIMSK1 TIMSK
|
||||
#endif
|
||||
|
||||
// timerx_toggle_count:
|
||||
// > 0 - duration specified
|
||||
// = 0 - stopped
|
||||
// < 0 - infinitely (until stop() method called, or new play() called)
|
||||
|
||||
#if !defined(__AVR_ATmega8__)
|
||||
volatile long timer0_toggle_count;
|
||||
volatile uint8_t *timer0_pin_port;
|
||||
volatile uint8_t timer0_pin_mask;
|
||||
#endif
|
||||
|
||||
volatile long timer1_toggle_count;
|
||||
volatile uint8_t *timer1_pin_port;
|
||||
volatile uint8_t timer1_pin_mask;
|
||||
volatile long timer2_toggle_count;
|
||||
volatile uint8_t *timer2_pin_port;
|
||||
volatile uint8_t timer2_pin_mask;
|
||||
|
||||
#if defined(__AVR_ATmega1280__)
|
||||
volatile long timer3_toggle_count;
|
||||
volatile uint8_t *timer3_pin_port;
|
||||
volatile uint8_t timer3_pin_mask;
|
||||
volatile long timer4_toggle_count;
|
||||
volatile uint8_t *timer4_pin_port;
|
||||
volatile uint8_t timer4_pin_mask;
|
||||
volatile long timer5_toggle_count;
|
||||
volatile uint8_t *timer5_pin_port;
|
||||
volatile uint8_t timer5_pin_mask;
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__AVR_ATmega1280__)
|
||||
|
||||
#define AVAILABLE_TONE_PINS 1
|
||||
|
||||
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 3, 4, 5, 1, 0 */ };
|
||||
static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255, 255, 255, 255 */ };
|
||||
|
||||
#elif defined(__AVR_ATmega8__)
|
||||
|
||||
#define AVAILABLE_TONE_PINS 1
|
||||
|
||||
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1 */ };
|
||||
static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255 */ };
|
||||
|
||||
#else
|
||||
|
||||
#define AVAILABLE_TONE_PINS 1
|
||||
|
||||
// Leave timer 0 to last.
|
||||
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1, 0 */ };
|
||||
static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255 */ };
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
static int8_t toneBegin(uint8_t _pin)
|
||||
{
|
||||
int8_t _timer = -1;
|
||||
|
||||
// if we're already using the pin, the timer should be configured.
|
||||
for (int i = 0; i < AVAILABLE_TONE_PINS; i++) {
|
||||
if (tone_pins[i] == _pin) {
|
||||
return pgm_read_byte(tone_pin_to_timer_PGM + i);
|
||||
}
|
||||
}
|
||||
|
||||
// search for an unused timer.
|
||||
for (int i = 0; i < AVAILABLE_TONE_PINS; i++) {
|
||||
if (tone_pins[i] == 255) {
|
||||
tone_pins[i] = _pin;
|
||||
_timer = pgm_read_byte(tone_pin_to_timer_PGM + i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (_timer != -1)
|
||||
{
|
||||
// Set timer specific stuff
|
||||
// All timers in CTC mode
|
||||
// 8 bit timers will require changing prescalar values,
|
||||
// whereas 16 bit timers are set to either ck/1 or ck/64 prescalar
|
||||
switch (_timer)
|
||||
{
|
||||
#if !defined(__AVR_ATmega8__)
|
||||
case 0:
|
||||
// 8 bit timer
|
||||
TCCR0A = 0;
|
||||
TCCR0B = 0;
|
||||
bitWrite(TCCR0A, WGM01, 1);
|
||||
bitWrite(TCCR0B, CS00, 1);
|
||||
timer0_pin_port = portOutputRegister(digitalPinToPort(_pin));
|
||||
timer0_pin_mask = digitalPinToBitMask(_pin);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case 1:
|
||||
// 16 bit timer
|
||||
TCCR1A = 0;
|
||||
TCCR1B = 0;
|
||||
bitWrite(TCCR1B, WGM12, 1);
|
||||
bitWrite(TCCR1B, CS10, 1);
|
||||
timer1_pin_port = portOutputRegister(digitalPinToPort(_pin));
|
||||
timer1_pin_mask = digitalPinToBitMask(_pin);
|
||||
break;
|
||||
case 2:
|
||||
// 8 bit timer
|
||||
TCCR2A = 0;
|
||||
TCCR2B = 0;
|
||||
bitWrite(TCCR2A, WGM21, 1);
|
||||
bitWrite(TCCR2B, CS20, 1);
|
||||
timer2_pin_port = portOutputRegister(digitalPinToPort(_pin));
|
||||
timer2_pin_mask = digitalPinToBitMask(_pin);
|
||||
break;
|
||||
|
||||
#if defined(__AVR_ATmega1280__)
|
||||
case 3:
|
||||
// 16 bit timer
|
||||
TCCR3A = 0;
|
||||
TCCR3B = 0;
|
||||
bitWrite(TCCR3B, WGM32, 1);
|
||||
bitWrite(TCCR3B, CS30, 1);
|
||||
timer3_pin_port = portOutputRegister(digitalPinToPort(_pin));
|
||||
timer3_pin_mask = digitalPinToBitMask(_pin);
|
||||
break;
|
||||
case 4:
|
||||
// 16 bit timer
|
||||
TCCR4A = 0;
|
||||
TCCR4B = 0;
|
||||
bitWrite(TCCR4B, WGM42, 1);
|
||||
bitWrite(TCCR4B, CS40, 1);
|
||||
timer4_pin_port = portOutputRegister(digitalPinToPort(_pin));
|
||||
timer4_pin_mask = digitalPinToBitMask(_pin);
|
||||
break;
|
||||
case 5:
|
||||
// 16 bit timer
|
||||
TCCR5A = 0;
|
||||
TCCR5B = 0;
|
||||
bitWrite(TCCR5B, WGM52, 1);
|
||||
bitWrite(TCCR5B, CS50, 1);
|
||||
timer5_pin_port = portOutputRegister(digitalPinToPort(_pin));
|
||||
timer5_pin_mask = digitalPinToBitMask(_pin);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return _timer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// frequency (in hertz) and duration (in milliseconds).
|
||||
|
||||
void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
|
||||
{
|
||||
uint8_t prescalarbits = 0b001;
|
||||
long toggle_count = 0;
|
||||
uint32_t ocr = 0;
|
||||
int8_t _timer;
|
||||
|
||||
_timer = toneBegin(_pin);
|
||||
|
||||
if (_timer >= 0)
|
||||
{
|
||||
// Set the pinMode as OUTPUT
|
||||
pinMode(_pin, OUTPUT);
|
||||
|
||||
// if we are using an 8 bit timer, scan through prescalars to find the best fit
|
||||
if (_timer == 0 || _timer == 2)
|
||||
{
|
||||
ocr = F_CPU / frequency / 2 - 1;
|
||||
prescalarbits = 0b001; // ck/1: same for both timers
|
||||
if (ocr > 255)
|
||||
{
|
||||
ocr = F_CPU / frequency / 2 / 8 - 1;
|
||||
prescalarbits = 0b010; // ck/8: same for both timers
|
||||
|
||||
if (_timer == 2 && ocr > 255)
|
||||
{
|
||||
ocr = F_CPU / frequency / 2 / 32 - 1;
|
||||
prescalarbits = 0b011;
|
||||
}
|
||||
|
||||
if (ocr > 255)
|
||||
{
|
||||
ocr = F_CPU / frequency / 2 / 64 - 1;
|
||||
prescalarbits = _timer == 0 ? 0b011 : 0b100;
|
||||
|
||||
if (_timer == 2 && ocr > 255)
|
||||
{
|
||||
ocr = F_CPU / frequency / 2 / 128 - 1;
|
||||
prescalarbits = 0b101;
|
||||
}
|
||||
|
||||
if (ocr > 255)
|
||||
{
|
||||
ocr = F_CPU / frequency / 2 / 256 - 1;
|
||||
prescalarbits = _timer == 0 ? 0b100 : 0b110;
|
||||
if (ocr > 255)
|
||||
{
|
||||
// can't do any better than /1024
|
||||
ocr = F_CPU / frequency / 2 / 1024 - 1;
|
||||
prescalarbits = _timer == 0 ? 0b101 : 0b111;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(__AVR_ATmega8__)
|
||||
if (_timer == 0)
|
||||
TCCR0B = prescalarbits;
|
||||
else
|
||||
#endif
|
||||
TCCR2B = prescalarbits;
|
||||
}
|
||||
else
|
||||
{
|
||||
// two choices for the 16 bit timers: ck/1 or ck/64
|
||||
ocr = F_CPU / frequency / 2 - 1;
|
||||
|
||||
prescalarbits = 0b001;
|
||||
if (ocr > 0xffff)
|
||||
{
|
||||
ocr = F_CPU / frequency / 2 / 64 - 1;
|
||||
prescalarbits = 0b011;
|
||||
}
|
||||
|
||||
if (_timer == 1)
|
||||
TCCR1B = (TCCR1B & 0b11111000) | prescalarbits;
|
||||
#if defined(__AVR_ATmega1280__)
|
||||
else if (_timer == 3)
|
||||
TCCR3B = (TCCR3B & 0b11111000) | prescalarbits;
|
||||
else if (_timer == 4)
|
||||
TCCR4B = (TCCR4B & 0b11111000) | prescalarbits;
|
||||
else if (_timer == 5)
|
||||
TCCR5B = (TCCR5B & 0b11111000) | prescalarbits;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Calculate the toggle count
|
||||
if (duration > 0)
|
||||
{
|
||||
toggle_count = 2 * frequency * duration / 1000;
|
||||
}
|
||||
else
|
||||
{
|
||||
toggle_count = -1;
|
||||
}
|
||||
|
||||
// Set the OCR for the given timer,
|
||||
// set the toggle count,
|
||||
// then turn on the interrupts
|
||||
switch (_timer)
|
||||
{
|
||||
|
||||
#if !defined(__AVR_ATmega8__)
|
||||
case 0:
|
||||
OCR0A = ocr;
|
||||
timer0_toggle_count = toggle_count;
|
||||
bitWrite(TIMSK0, OCIE0A, 1);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case 1:
|
||||
OCR1A = ocr;
|
||||
timer1_toggle_count = toggle_count;
|
||||
bitWrite(TIMSK1, OCIE1A, 1);
|
||||
break;
|
||||
case 2:
|
||||
OCR2A = ocr;
|
||||
timer2_toggle_count = toggle_count;
|
||||
bitWrite(TIMSK2, OCIE2A, 1);
|
||||
break;
|
||||
|
||||
#if defined(__AVR_ATmega1280__)
|
||||
case 3:
|
||||
OCR3A = ocr;
|
||||
timer3_toggle_count = toggle_count;
|
||||
bitWrite(TIMSK3, OCIE3A, 1);
|
||||
break;
|
||||
case 4:
|
||||
OCR4A = ocr;
|
||||
timer4_toggle_count = toggle_count;
|
||||
bitWrite(TIMSK4, OCIE4A, 1);
|
||||
break;
|
||||
case 5:
|
||||
OCR5A = ocr;
|
||||
timer5_toggle_count = toggle_count;
|
||||
bitWrite(TIMSK5, OCIE5A, 1);
|
||||
break;
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void noTone(uint8_t _pin)
|
||||
{
|
||||
int8_t _timer = -1;
|
||||
|
||||
for (int i = 0; i < AVAILABLE_TONE_PINS; i++) {
|
||||
if (tone_pins[i] == _pin) {
|
||||
_timer = pgm_read_byte(tone_pin_to_timer_PGM + i);
|
||||
tone_pins[i] = 255;
|
||||
}
|
||||
}
|
||||
|
||||
switch (_timer)
|
||||
{
|
||||
#if defined(__AVR_ATmega8__)
|
||||
case 1:
|
||||
bitWrite(TIMSK1, OCIE1A, 0);
|
||||
break;
|
||||
case 2:
|
||||
bitWrite(TIMSK2, OCIE2A, 0);
|
||||
break;
|
||||
|
||||
#else
|
||||
case 0:
|
||||
TIMSK0 = 0;
|
||||
break;
|
||||
case 1:
|
||||
TIMSK1 = 0;
|
||||
break;
|
||||
case 2:
|
||||
TIMSK2 = 0;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(__AVR_ATmega1280__)
|
||||
case 3:
|
||||
TIMSK3 = 0;
|
||||
break;
|
||||
case 4:
|
||||
TIMSK4 = 0;
|
||||
break;
|
||||
case 5:
|
||||
TIMSK5 = 0;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
digitalWrite(_pin, 0);
|
||||
}
|
||||
|
||||
#if 0
|
||||
#if !defined(__AVR_ATmega8__)
|
||||
ISR(TIMER0_COMPA_vect)
|
||||
{
|
||||
if (timer0_toggle_count != 0)
|
||||
{
|
||||
// toggle the pin
|
||||
*timer0_pin_port ^= timer0_pin_mask;
|
||||
|
||||
if (timer0_toggle_count > 0)
|
||||
timer0_toggle_count--;
|
||||
}
|
||||
else
|
||||
{
|
||||
TIMSK0 = 0; // disable the interrupt
|
||||
*timer0_pin_port &= ~(timer0_pin_mask); // keep pin low after stop
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
ISR(TIMER1_COMPA_vect)
|
||||
{
|
||||
if (timer1_toggle_count != 0)
|
||||
{
|
||||
// toggle the pin
|
||||
*timer1_pin_port ^= timer1_pin_mask;
|
||||
|
||||
if (timer1_toggle_count > 0)
|
||||
timer1_toggle_count--;
|
||||
}
|
||||
else
|
||||
{
|
||||
TIMSK1 = 0; // disable the interrupt
|
||||
*timer1_pin_port &= ~(timer1_pin_mask); // keep pin low after stop
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
ISR(TIMER2_COMPA_vect)
|
||||
{
|
||||
|
||||
if (timer2_toggle_count != 0)
|
||||
{
|
||||
// toggle the pin
|
||||
*timer2_pin_port ^= timer2_pin_mask;
|
||||
|
||||
if (timer2_toggle_count > 0)
|
||||
timer2_toggle_count--;
|
||||
}
|
||||
else
|
||||
{
|
||||
TIMSK2 = 0; // disable the interrupt
|
||||
*timer2_pin_port &= ~(timer2_pin_mask); // keep pin low after stop
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//#if defined(__AVR_ATmega1280__)
|
||||
#if 0
|
||||
|
||||
ISR(TIMER3_COMPA_vect)
|
||||
{
|
||||
if (timer3_toggle_count != 0)
|
||||
{
|
||||
// toggle the pin
|
||||
*timer3_pin_port ^= timer3_pin_mask;
|
||||
|
||||
if (timer3_toggle_count > 0)
|
||||
timer3_toggle_count--;
|
||||
}
|
||||
else
|
||||
{
|
||||
TIMSK3 = 0; // disable the interrupt
|
||||
*timer3_pin_port &= ~(timer3_pin_mask); // keep pin low after stop
|
||||
}
|
||||
}
|
||||
|
||||
ISR(TIMER4_COMPA_vect)
|
||||
{
|
||||
if (timer4_toggle_count != 0)
|
||||
{
|
||||
// toggle the pin
|
||||
*timer4_pin_port ^= timer4_pin_mask;
|
||||
|
||||
if (timer4_toggle_count > 0)
|
||||
timer4_toggle_count--;
|
||||
}
|
||||
else
|
||||
{
|
||||
TIMSK4 = 0; // disable the interrupt
|
||||
*timer4_pin_port &= ~(timer4_pin_mask); // keep pin low after stop
|
||||
}
|
||||
}
|
||||
|
||||
ISR(TIMER5_COMPA_vect)
|
||||
{
|
||||
if (timer5_toggle_count != 0)
|
||||
{
|
||||
// toggle the pin
|
||||
*timer5_pin_port ^= timer5_pin_mask;
|
||||
|
||||
if (timer5_toggle_count > 0)
|
||||
timer5_toggle_count--;
|
||||
}
|
||||
else
|
||||
{
|
||||
TIMSK5 = 0; // disable the interrupt
|
||||
*timer5_pin_port &= ~(timer5_pin_mask); // keep pin low after stop
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
WCharacter.h - Character utility functions for Wiring & Arduino
|
||||
Copyright (c) 2010 Hernando Barragan. All right reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef Character_h
|
||||
#define Character_h
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
// WCharacter.h prototypes
|
||||
inline boolean isAlphaNumeric(int c) __attribute__((always_inline));
|
||||
inline boolean isAlpha(int c) __attribute__((always_inline));
|
||||
inline boolean isAscii(int c) __attribute__((always_inline));
|
||||
inline boolean isWhitespace(int c) __attribute__((always_inline));
|
||||
inline boolean isControl(int c) __attribute__((always_inline));
|
||||
inline boolean isDigit(int c) __attribute__((always_inline));
|
||||
inline boolean isGraph(int c) __attribute__((always_inline));
|
||||
inline boolean isLowerCase(int c) __attribute__((always_inline));
|
||||
inline boolean isPrintable(int c) __attribute__((always_inline));
|
||||
inline boolean isPunct(int c) __attribute__((always_inline));
|
||||
inline boolean isSpace(int c) __attribute__((always_inline));
|
||||
inline boolean isUpperCase(int c) __attribute__((always_inline));
|
||||
inline boolean isHexadecimalDigit(int c) __attribute__((always_inline));
|
||||
inline int toAscii(int c) __attribute__((always_inline));
|
||||
inline int toLowerCase(int c) __attribute__((always_inline));
|
||||
inline int toUpperCase(int c)__attribute__((always_inline));
|
||||
|
||||
|
||||
// Checks for an alphanumeric character.
|
||||
// It is equivalent to (isalpha(c) || isdigit(c)).
|
||||
inline boolean isAlphaNumeric(int c)
|
||||
{
|
||||
return ( isalnum(c) == 0 ? false : true);
|
||||
}
|
||||
|
||||
|
||||
// Checks for an alphabetic character.
|
||||
// It is equivalent to (isupper(c) || islower(c)).
|
||||
inline boolean isAlpha(int c)
|
||||
{
|
||||
return ( isalpha(c) == 0 ? false : true);
|
||||
}
|
||||
|
||||
|
||||
// Checks whether c is a 7-bit unsigned char value
|
||||
// that fits into the ASCII character set.
|
||||
inline boolean isAscii(int c)
|
||||
{
|
||||
return ( isascii (c) == 0 ? false : true);
|
||||
}
|
||||
|
||||
|
||||
// Checks for a blank character, that is, a space or a tab.
|
||||
inline boolean isWhitespace(int c)
|
||||
{
|
||||
return ( isblank (c) == 0 ? false : true);
|
||||
}
|
||||
|
||||
|
||||
// Checks for a control character.
|
||||
inline boolean isControl(int c)
|
||||
{
|
||||
return ( iscntrl (c) == 0 ? false : true);
|
||||
}
|
||||
|
||||
|
||||
// Checks for a digit (0 through 9).
|
||||
inline boolean isDigit(int c)
|
||||
{
|
||||
return ( isdigit (c) == 0 ? false : true);
|
||||
}
|
||||
|
||||
|
||||
// Checks for any printable character except space.
|
||||
inline boolean isGraph(int c)
|
||||
{
|
||||
return ( isgraph (c) == 0 ? false : true);
|
||||
}
|
||||
|
||||
|
||||
// Checks for a lower-case character.
|
||||
inline boolean isLowerCase(int c)
|
||||
{
|
||||
return (islower (c) == 0 ? false : true);
|
||||
}
|
||||
|
||||
|
||||
// Checks for any printable character including space.
|
||||
inline boolean isPrintable(int c)
|
||||
{
|
||||
return ( isprint (c) == 0 ? false : true);
|
||||
}
|
||||
|
||||
|
||||
// Checks for any printable character which is not a space
|
||||
// or an alphanumeric character.
|
||||
inline boolean isPunct(int c)
|
||||
{
|
||||
return ( ispunct (c) == 0 ? false : true);
|
||||
}
|
||||
|
||||
|
||||
// Checks for white-space characters. For the avr-libc library,
|
||||
// these are: space, formfeed ('\f'), newline ('\n'), carriage
|
||||
// return ('\r'), horizontal tab ('\t'), and vertical tab ('\v').
|
||||
inline boolean isSpace(int c)
|
||||
{
|
||||
return ( isspace (c) == 0 ? false : true);
|
||||
}
|
||||
|
||||
|
||||
// Checks for an uppercase letter.
|
||||
inline boolean isUpperCase(int c)
|
||||
{
|
||||
return ( isupper (c) == 0 ? false : true);
|
||||
}
|
||||
|
||||
|
||||
// Checks for a hexadecimal digits, i.e. one of 0 1 2 3 4 5 6 7
|
||||
// 8 9 a b c d e f A B C D E F.
|
||||
inline boolean isHexadecimalDigit(int c)
|
||||
{
|
||||
return ( isxdigit (c) == 0 ? false : true);
|
||||
}
|
||||
|
||||
|
||||
// Converts c to a 7-bit unsigned char value that fits into the
|
||||
// ASCII character set, by clearing the high-order bits.
|
||||
inline int toAscii(int c)
|
||||
{
|
||||
return toascii (c);
|
||||
}
|
||||
|
||||
|
||||
// Warning:
|
||||
// Many people will be unhappy if you use this function.
|
||||
// This function will convert accented letters into random
|
||||
// characters.
|
||||
|
||||
// Converts the letter c to lower case, if possible.
|
||||
inline int toLowerCase(int c)
|
||||
{
|
||||
return tolower (c);
|
||||
}
|
||||
|
||||
|
||||
// Converts the letter c to upper case, if possible.
|
||||
inline int toUpperCase(int c)
|
||||
{
|
||||
return toupper (c);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1 @@
|
||||
#include "wiring.h"
|
||||
@@ -0,0 +1,87 @@
|
||||
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Wiring project - http://wiring.uniandes.edu.co
|
||||
|
||||
Copyright (c) 2004-05 Hernando Barragan
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
|
||||
Modified 24 November 2006 by David A. Mellis
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "WConstants.h"
|
||||
#include "wiring_private.h"
|
||||
|
||||
volatile static voidFuncPtr intFunc[EXTERNAL_NUM_INTERRUPTS];
|
||||
// volatile static voidFuncPtr twiIntFunc;
|
||||
|
||||
void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode)
|
||||
{
|
||||
if(interruptNum < EXTERNAL_NUM_INTERRUPTS)
|
||||
{
|
||||
intFunc[interruptNum] = userFunc;
|
||||
|
||||
//clear the config for the change settings
|
||||
EICRA &= ~(B00000011 << (interruptNum * 2));
|
||||
|
||||
//set our mode.
|
||||
EICRA |= (mode << (interruptNum * 2));
|
||||
|
||||
// Enable the interrupt.
|
||||
EIMSK |= (1 << interruptNum);
|
||||
}
|
||||
}
|
||||
|
||||
void detachInterrupt(uint8_t interruptNum)
|
||||
{
|
||||
if(interruptNum < EXTERNAL_NUM_INTERRUPTS)
|
||||
{
|
||||
// Disable the interrupt.
|
||||
EIMSK &= ~(1 << interruptNum);
|
||||
|
||||
intFunc[interruptNum] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
ISR(INT0_vect) {
|
||||
if(intFunc[EXTERNAL_INT_0])
|
||||
intFunc[EXTERNAL_INT_0]();
|
||||
}
|
||||
|
||||
ISR(INT1_vect) {
|
||||
if(intFunc[EXTERNAL_INT_1])
|
||||
intFunc[EXTERNAL_INT_1]();
|
||||
}
|
||||
|
||||
ISR(INT2_vect) {
|
||||
if(intFunc[EXTERNAL_INT_2])
|
||||
intFunc[EXTERNAL_INT_2]();
|
||||
}
|
||||
|
||||
/*
|
||||
SIGNAL(SIG_2WIRE_SERIAL) {
|
||||
if(twiIntFunc)
|
||||
twiIntFunc();
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Wiring project - http://wiring.org.co
|
||||
Copyright (c) 2004-06 Hernando Barragan
|
||||
Modified 13 August 2006, David A. Mellis for Arduino - http://www.arduino.cc/
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
extern "C" {
|
||||
#include "stdlib.h"
|
||||
}
|
||||
|
||||
void randomSeed(unsigned int seed)
|
||||
{
|
||||
if (seed != 0){
|
||||
srandom(seed);
|
||||
}
|
||||
}
|
||||
|
||||
long random(long howbig)
|
||||
{
|
||||
if (howbig == 0) {
|
||||
return 0;
|
||||
}
|
||||
return random() % howbig;
|
||||
}
|
||||
|
||||
long random(long howsmall, long howbig)
|
||||
{
|
||||
if (howsmall >= howbig) {
|
||||
return howsmall;
|
||||
}
|
||||
long diff = howbig - howsmall;
|
||||
return random(diff) + howsmall;
|
||||
}
|
||||
|
||||
long map(long x, long in_min, long in_max, long out_min, long out_max)
|
||||
{
|
||||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||
}
|
||||
|
||||
unsigned int makeWord(unsigned int w) { return w; }
|
||||
unsigned int makeWord(unsigned char h, unsigned char l) { return (h << 8) | l; }
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef WProgram_h
|
||||
#define WProgram_h
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
#include "wiring.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "WCharacter.h"
|
||||
#include "WString.h"
|
||||
#include "HardwareSerial.h"
|
||||
|
||||
uint16_t makeWord(uint16_t w);
|
||||
uint16_t makeWord(byte h, byte l);
|
||||
|
||||
#define word(...) makeWord(__VA_ARGS__)
|
||||
|
||||
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
|
||||
|
||||
void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0);
|
||||
void noTone(uint8_t _pin);
|
||||
|
||||
// WMath prototypes
|
||||
long random(long);
|
||||
long random(long, long);
|
||||
void randomSeed(unsigned int);
|
||||
long map(long, long, long, long, long);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,443 @@
|
||||
/*
|
||||
WString.cpp - String library for Wiring & Arduino
|
||||
Copyright (c) 2009-10 Hernando Barragan. All rights reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "WProgram.h"
|
||||
#include "WString.h"
|
||||
|
||||
|
||||
String::String( const char *value )
|
||||
{
|
||||
if ( value == NULL )
|
||||
value = "";
|
||||
getBuffer( _length = strlen( value ) );
|
||||
if ( _buffer != NULL )
|
||||
strcpy( _buffer, value );
|
||||
}
|
||||
|
||||
String::String( const String &value )
|
||||
{
|
||||
getBuffer( _length = value._length );
|
||||
if ( _buffer != NULL )
|
||||
strcpy( _buffer, value._buffer );
|
||||
}
|
||||
|
||||
String::String( const char value )
|
||||
{
|
||||
_length = 1;
|
||||
getBuffer(1);
|
||||
if ( _buffer != NULL ) {
|
||||
_buffer[0] = value;
|
||||
_buffer[1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
String::String( const unsigned char value )
|
||||
{
|
||||
_length = 1;
|
||||
getBuffer(1);
|
||||
if ( _buffer != NULL) {
|
||||
_buffer[0] = value;
|
||||
_buffer[1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
String::String( const int value, const int base )
|
||||
{
|
||||
char buf[33];
|
||||
itoa((signed long)value, buf, base);
|
||||
getBuffer( _length = strlen(buf) );
|
||||
if ( _buffer != NULL )
|
||||
strcpy( _buffer, buf );
|
||||
}
|
||||
|
||||
String::String( const unsigned int value, const int base )
|
||||
{
|
||||
char buf[33];
|
||||
ultoa((unsigned long)value, buf, base);
|
||||
getBuffer( _length = strlen(buf) );
|
||||
if ( _buffer != NULL )
|
||||
strcpy( _buffer, buf );
|
||||
}
|
||||
|
||||
String::String( const long value, const int base )
|
||||
{
|
||||
char buf[33];
|
||||
ltoa(value, buf, base);
|
||||
getBuffer( _length = strlen(buf) );
|
||||
if ( _buffer != NULL )
|
||||
strcpy( _buffer, buf );
|
||||
}
|
||||
|
||||
String::String( const unsigned long value, const int base )
|
||||
{
|
||||
char buf[33];
|
||||
ultoa(value, buf, 10);
|
||||
getBuffer( _length = strlen(buf) );
|
||||
if ( _buffer != NULL )
|
||||
strcpy( _buffer, buf );
|
||||
}
|
||||
|
||||
char String::charAt( unsigned int loc ) const
|
||||
{
|
||||
return operator[]( loc );
|
||||
}
|
||||
|
||||
void String::setCharAt( unsigned int loc, const char aChar )
|
||||
{
|
||||
if(_buffer == NULL) return;
|
||||
if(_length > loc) {
|
||||
_buffer[loc] = aChar;
|
||||
}
|
||||
}
|
||||
|
||||
int String::compareTo( const String &s2 ) const
|
||||
{
|
||||
return strcmp( _buffer, s2._buffer );
|
||||
}
|
||||
|
||||
const String & String::concat( const String &s2 )
|
||||
{
|
||||
return (*this) += s2;
|
||||
}
|
||||
|
||||
const String & String::operator=( const String &rhs )
|
||||
{
|
||||
if ( this == &rhs )
|
||||
return *this;
|
||||
|
||||
if ( rhs._length > _length )
|
||||
{
|
||||
free(_buffer);
|
||||
getBuffer( rhs._length );
|
||||
}
|
||||
|
||||
if ( _buffer != NULL ) {
|
||||
_length = rhs._length;
|
||||
strcpy( _buffer, rhs._buffer );
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
//const String & String::operator+=( const char aChar )
|
||||
//{
|
||||
// if ( _length == _capacity )
|
||||
// doubleBuffer();
|
||||
//
|
||||
// _buffer[ _length++ ] = aChar;
|
||||
// _buffer[ _length ] = '\0';
|
||||
// return *this;
|
||||
//}
|
||||
|
||||
const String & String::operator+=( const String &other )
|
||||
{
|
||||
_length += other._length;
|
||||
if ( _length > _capacity )
|
||||
{
|
||||
char *temp = (char *)realloc(_buffer, _length + 1);
|
||||
if ( temp != NULL ) {
|
||||
_buffer = temp;
|
||||
_capacity = _length;
|
||||
} else {
|
||||
_length -= other._length;
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
strcat( _buffer, other._buffer );
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
int String::operator==( const String &rhs ) const
|
||||
{
|
||||
return ( _length == rhs._length && strcmp( _buffer, rhs._buffer ) == 0 );
|
||||
}
|
||||
|
||||
int String::operator!=( const String &rhs ) const
|
||||
{
|
||||
return ( _length != rhs.length() || strcmp( _buffer, rhs._buffer ) != 0 );
|
||||
}
|
||||
|
||||
int String::operator<( const String &rhs ) const
|
||||
{
|
||||
return strcmp( _buffer, rhs._buffer ) < 0;
|
||||
}
|
||||
|
||||
int String::operator>( const String &rhs ) const
|
||||
{
|
||||
return strcmp( _buffer, rhs._buffer ) > 0;
|
||||
}
|
||||
|
||||
int String::operator<=( const String &rhs ) const
|
||||
{
|
||||
return strcmp( _buffer, rhs._buffer ) <= 0;
|
||||
}
|
||||
|
||||
int String::operator>=( const String & rhs ) const
|
||||
{
|
||||
return strcmp( _buffer, rhs._buffer ) >= 0;
|
||||
}
|
||||
|
||||
char & String::operator[]( unsigned int index )
|
||||
{
|
||||
static char dummy_writable_char;
|
||||
if (index >= _length || !_buffer) {
|
||||
dummy_writable_char = 0;
|
||||
return dummy_writable_char;
|
||||
}
|
||||
return _buffer[ index ];
|
||||
}
|
||||
|
||||
char String::operator[]( unsigned int index ) const
|
||||
{
|
||||
// need to check for valid index, to do later
|
||||
return _buffer[ index ];
|
||||
}
|
||||
|
||||
boolean String::endsWith( const String &s2 ) const
|
||||
{
|
||||
if ( _length < s2._length )
|
||||
return 0;
|
||||
|
||||
return strcmp( &_buffer[ _length - s2._length], s2._buffer ) == 0;
|
||||
}
|
||||
|
||||
boolean String::equals( const String &s2 ) const
|
||||
{
|
||||
return ( _length == s2._length && strcmp( _buffer,s2._buffer ) == 0 );
|
||||
}
|
||||
|
||||
boolean String::equalsIgnoreCase( const String &s2 ) const
|
||||
{
|
||||
if ( this == &s2 )
|
||||
return true; //1;
|
||||
else if ( _length != s2._length )
|
||||
return false; //0;
|
||||
|
||||
return strcmp(toLowerCase()._buffer, s2.toLowerCase()._buffer) == 0;
|
||||
}
|
||||
|
||||
String String::replace( char findChar, char replaceChar )
|
||||
{
|
||||
if ( _buffer == NULL ) return *this;
|
||||
String theReturn = _buffer;
|
||||
char* temp = theReturn._buffer;
|
||||
while( (temp = strchr( temp, findChar )) != 0 )
|
||||
*temp = replaceChar;
|
||||
|
||||
return theReturn;
|
||||
}
|
||||
|
||||
String String::replace( const String& match, const String& replace )
|
||||
{
|
||||
if ( _buffer == NULL ) return *this;
|
||||
String temp = _buffer, newString;
|
||||
|
||||
int loc;
|
||||
while ( (loc = temp.indexOf( match )) != -1 )
|
||||
{
|
||||
newString += temp.substring( 0, loc );
|
||||
newString += replace;
|
||||
temp = temp.substring( loc + match._length );
|
||||
}
|
||||
newString += temp;
|
||||
return newString;
|
||||
}
|
||||
|
||||
int String::indexOf( char temp ) const
|
||||
{
|
||||
return indexOf( temp, 0 );
|
||||
}
|
||||
|
||||
int String::indexOf( char ch, unsigned int fromIndex ) const
|
||||
{
|
||||
if ( fromIndex >= _length )
|
||||
return -1;
|
||||
|
||||
const char* temp = strchr( &_buffer[fromIndex], ch );
|
||||
if ( temp == NULL )
|
||||
return -1;
|
||||
|
||||
return temp - _buffer;
|
||||
}
|
||||
|
||||
int String::indexOf( const String &s2 ) const
|
||||
{
|
||||
return indexOf( s2, 0 );
|
||||
}
|
||||
|
||||
int String::indexOf( const String &s2, unsigned int fromIndex ) const
|
||||
{
|
||||
if ( fromIndex >= _length )
|
||||
return -1;
|
||||
|
||||
const char *theFind = strstr( &_buffer[ fromIndex ], s2._buffer );
|
||||
|
||||
if ( theFind == NULL )
|
||||
return -1;
|
||||
|
||||
return theFind - _buffer; // pointer subtraction
|
||||
}
|
||||
|
||||
int String::lastIndexOf( char theChar ) const
|
||||
{
|
||||
return lastIndexOf( theChar, _length - 1 );
|
||||
}
|
||||
|
||||
int String::lastIndexOf( char ch, unsigned int fromIndex ) const
|
||||
{
|
||||
if ( fromIndex >= _length )
|
||||
return -1;
|
||||
|
||||
char tempchar = _buffer[fromIndex + 1];
|
||||
_buffer[fromIndex + 1] = '\0';
|
||||
char* temp = strrchr( _buffer, ch );
|
||||
_buffer[fromIndex + 1] = tempchar;
|
||||
|
||||
if ( temp == NULL )
|
||||
return -1;
|
||||
|
||||
return temp - _buffer;
|
||||
}
|
||||
|
||||
int String::lastIndexOf( const String &s2 ) const
|
||||
{
|
||||
return lastIndexOf( s2, _length - s2._length );
|
||||
}
|
||||
|
||||
int String::lastIndexOf( const String &s2, unsigned int fromIndex ) const
|
||||
{
|
||||
// check for empty strings
|
||||
if ( s2._length == 0 || s2._length - 1 > fromIndex || fromIndex >= _length )
|
||||
return -1;
|
||||
|
||||
// matching first character
|
||||
char temp = s2[ 0 ];
|
||||
|
||||
for ( int i = fromIndex; i >= 0; i-- )
|
||||
{
|
||||
if ( _buffer[ i ] == temp && (*this).substring( i, i + s2._length ).equals( s2 ) )
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
boolean String::startsWith( const String &s2 ) const
|
||||
{
|
||||
if ( _length < s2._length )
|
||||
return 0;
|
||||
|
||||
return startsWith( s2, 0 );
|
||||
}
|
||||
|
||||
boolean String::startsWith( const String &s2, unsigned int offset ) const
|
||||
{
|
||||
if ( offset > _length - s2._length )
|
||||
return 0;
|
||||
|
||||
return strncmp( &_buffer[offset], s2._buffer, s2._length ) == 0;
|
||||
}
|
||||
|
||||
String String::substring( unsigned int left ) const
|
||||
{
|
||||
return substring( left, _length );
|
||||
}
|
||||
|
||||
String String::substring( unsigned int left, unsigned int right ) const
|
||||
{
|
||||
if ( left > right )
|
||||
{
|
||||
int temp = right;
|
||||
right = left;
|
||||
left = temp;
|
||||
}
|
||||
|
||||
if ( right > _length )
|
||||
{
|
||||
right = _length;
|
||||
}
|
||||
|
||||
char temp = _buffer[ right ]; // save the replaced character
|
||||
_buffer[ right ] = '\0';
|
||||
String outPut = ( _buffer + left ); // pointer arithmetic
|
||||
_buffer[ right ] = temp; //restore character
|
||||
return outPut;
|
||||
}
|
||||
|
||||
String String::toLowerCase() const
|
||||
{
|
||||
String temp = _buffer;
|
||||
|
||||
for ( unsigned int i = 0; i < _length; i++ )
|
||||
temp._buffer[ i ] = (char)tolower( temp._buffer[ i ] );
|
||||
return temp;
|
||||
}
|
||||
|
||||
String String::toUpperCase() const
|
||||
{
|
||||
String temp = _buffer;
|
||||
|
||||
for ( unsigned int i = 0; i < _length; i++ )
|
||||
temp._buffer[ i ] = (char)toupper( temp._buffer[ i ] );
|
||||
return temp;
|
||||
}
|
||||
|
||||
String String::trim() const
|
||||
{
|
||||
if ( _buffer == NULL ) return *this;
|
||||
String temp = _buffer;
|
||||
unsigned int i,j;
|
||||
|
||||
for ( i = 0; i < _length; i++ )
|
||||
{
|
||||
if ( !isspace(_buffer[i]) )
|
||||
break;
|
||||
}
|
||||
|
||||
for ( j = temp._length - 1; j > i; j-- )
|
||||
{
|
||||
if ( !isspace(_buffer[j]) )
|
||||
break;
|
||||
}
|
||||
|
||||
return temp.substring( i, j + 1);
|
||||
}
|
||||
|
||||
void String::getBytes(unsigned char *buf, unsigned int bufsize)
|
||||
{
|
||||
if (!bufsize || !buf) return;
|
||||
unsigned int len = bufsize - 1;
|
||||
if (len > _length) len = _length;
|
||||
strncpy((char *)buf, _buffer, len);
|
||||
buf[len] = 0;
|
||||
}
|
||||
|
||||
void String::toCharArray(char *buf, unsigned int bufsize)
|
||||
{
|
||||
if (!bufsize || !buf) return;
|
||||
unsigned int len = bufsize - 1;
|
||||
if (len > _length) len = _length;
|
||||
strncpy(buf, _buffer, len);
|
||||
buf[len] = 0;
|
||||
}
|
||||
|
||||
|
||||
long String::toInt() {
|
||||
return atol(_buffer);
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
WString.h - String library for Wiring & Arduino
|
||||
Copyright (c) 2009-10 Hernando Barragan. All right reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef String_h
|
||||
#define String_h
|
||||
|
||||
//#include "WProgram.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
class String
|
||||
{
|
||||
public:
|
||||
// constructors
|
||||
String( const char *value = "" );
|
||||
String( const String &value );
|
||||
String( const char );
|
||||
String( const unsigned char );
|
||||
String( const int, const int base=10);
|
||||
String( const unsigned int, const int base=10 );
|
||||
String( const long, const int base=10 );
|
||||
String( const unsigned long, const int base=10 );
|
||||
~String() { free(_buffer); _length = _capacity = 0;} //added _length = _capacity = 0;
|
||||
|
||||
// operators
|
||||
const String & operator = ( const String &rhs );
|
||||
const String & operator +=( const String &rhs );
|
||||
//const String & operator +=( const char );
|
||||
int operator ==( const String &rhs ) const;
|
||||
int operator !=( const String &rhs ) const;
|
||||
int operator < ( const String &rhs ) const;
|
||||
int operator > ( const String &rhs ) const;
|
||||
int operator <=( const String &rhs ) const;
|
||||
int operator >=( const String &rhs ) const;
|
||||
char operator []( unsigned int index ) const;
|
||||
char& operator []( unsigned int index );
|
||||
//operator const char *() const { return _buffer; }
|
||||
|
||||
// general methods
|
||||
char charAt( unsigned int index ) const;
|
||||
int compareTo( const String &anotherString ) const;
|
||||
unsigned char endsWith( const String &suffix ) const;
|
||||
unsigned char equals( const String &anObject ) const;
|
||||
unsigned char equalsIgnoreCase( const String &anotherString ) const;
|
||||
int indexOf( char ch ) const;
|
||||
int indexOf( char ch, unsigned int fromIndex ) const;
|
||||
int indexOf( const String &str ) const;
|
||||
int indexOf( const String &str, unsigned int fromIndex ) const;
|
||||
int lastIndexOf( char ch ) const;
|
||||
int lastIndexOf( char ch, unsigned int fromIndex ) const;
|
||||
int lastIndexOf( const String &str ) const;
|
||||
int lastIndexOf( const String &str, unsigned int fromIndex ) const;
|
||||
const unsigned int length( ) const { return _length; }
|
||||
void setCharAt(unsigned int index, const char ch);
|
||||
unsigned char startsWith( const String &prefix ) const;
|
||||
unsigned char startsWith( const String &prefix, unsigned int toffset ) const;
|
||||
String substring( unsigned int beginIndex ) const;
|
||||
String substring( unsigned int beginIndex, unsigned int endIndex ) const;
|
||||
String toLowerCase( ) const;
|
||||
String toUpperCase( ) const;
|
||||
String trim( ) const;
|
||||
void getBytes(unsigned char *buf, unsigned int bufsize);
|
||||
void toCharArray(char *buf, unsigned int bufsize);
|
||||
long toInt( );
|
||||
const String& concat( const String &str );
|
||||
String replace( char oldChar, char newChar );
|
||||
String replace( const String& match, const String& replace );
|
||||
friend String operator + ( String lhs, const String &rhs );
|
||||
|
||||
protected:
|
||||
char *_buffer; // the actual char array
|
||||
unsigned int _capacity; // the array length minus one (for the '\0')
|
||||
unsigned int _length; // the String length (not counting the '\0')
|
||||
|
||||
void getBuffer(unsigned int maxStrLen);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
// allocate buffer space
|
||||
inline void String::getBuffer(unsigned int maxStrLen)
|
||||
{
|
||||
_capacity = maxStrLen;
|
||||
_buffer = (char *) malloc(_capacity + 1);
|
||||
if (_buffer == NULL) _length = _capacity = 0;
|
||||
}
|
||||
|
||||
inline String operator+( String lhs, const String &rhs )
|
||||
{
|
||||
return lhs += rhs;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,515 @@
|
||||
#ifndef Binary_h
|
||||
#define Binary_h
|
||||
|
||||
#define B0 0
|
||||
#define B00 0
|
||||
#define B000 0
|
||||
#define B0000 0
|
||||
#define B00000 0
|
||||
#define B000000 0
|
||||
#define B0000000 0
|
||||
#define B00000000 0
|
||||
#define B1 1
|
||||
#define B01 1
|
||||
#define B001 1
|
||||
#define B0001 1
|
||||
#define B00001 1
|
||||
#define B000001 1
|
||||
#define B0000001 1
|
||||
#define B00000001 1
|
||||
#define B10 2
|
||||
#define B010 2
|
||||
#define B0010 2
|
||||
#define B00010 2
|
||||
#define B000010 2
|
||||
#define B0000010 2
|
||||
#define B00000010 2
|
||||
#define B11 3
|
||||
#define B011 3
|
||||
#define B0011 3
|
||||
#define B00011 3
|
||||
#define B000011 3
|
||||
#define B0000011 3
|
||||
#define B00000011 3
|
||||
#define B100 4
|
||||
#define B0100 4
|
||||
#define B00100 4
|
||||
#define B000100 4
|
||||
#define B0000100 4
|
||||
#define B00000100 4
|
||||
#define B101 5
|
||||
#define B0101 5
|
||||
#define B00101 5
|
||||
#define B000101 5
|
||||
#define B0000101 5
|
||||
#define B00000101 5
|
||||
#define B110 6
|
||||
#define B0110 6
|
||||
#define B00110 6
|
||||
#define B000110 6
|
||||
#define B0000110 6
|
||||
#define B00000110 6
|
||||
#define B111 7
|
||||
#define B0111 7
|
||||
#define B00111 7
|
||||
#define B000111 7
|
||||
#define B0000111 7
|
||||
#define B00000111 7
|
||||
#define B1000 8
|
||||
#define B01000 8
|
||||
#define B001000 8
|
||||
#define B0001000 8
|
||||
#define B00001000 8
|
||||
#define B1001 9
|
||||
#define B01001 9
|
||||
#define B001001 9
|
||||
#define B0001001 9
|
||||
#define B00001001 9
|
||||
#define B1010 10
|
||||
#define B01010 10
|
||||
#define B001010 10
|
||||
#define B0001010 10
|
||||
#define B00001010 10
|
||||
#define B1011 11
|
||||
#define B01011 11
|
||||
#define B001011 11
|
||||
#define B0001011 11
|
||||
#define B00001011 11
|
||||
#define B1100 12
|
||||
#define B01100 12
|
||||
#define B001100 12
|
||||
#define B0001100 12
|
||||
#define B00001100 12
|
||||
#define B1101 13
|
||||
#define B01101 13
|
||||
#define B001101 13
|
||||
#define B0001101 13
|
||||
#define B00001101 13
|
||||
#define B1110 14
|
||||
#define B01110 14
|
||||
#define B001110 14
|
||||
#define B0001110 14
|
||||
#define B00001110 14
|
||||
#define B1111 15
|
||||
#define B01111 15
|
||||
#define B001111 15
|
||||
#define B0001111 15
|
||||
#define B00001111 15
|
||||
#define B10000 16
|
||||
#define B010000 16
|
||||
#define B0010000 16
|
||||
#define B00010000 16
|
||||
#define B10001 17
|
||||
#define B010001 17
|
||||
#define B0010001 17
|
||||
#define B00010001 17
|
||||
#define B10010 18
|
||||
#define B010010 18
|
||||
#define B0010010 18
|
||||
#define B00010010 18
|
||||
#define B10011 19
|
||||
#define B010011 19
|
||||
#define B0010011 19
|
||||
#define B00010011 19
|
||||
#define B10100 20
|
||||
#define B010100 20
|
||||
#define B0010100 20
|
||||
#define B00010100 20
|
||||
#define B10101 21
|
||||
#define B010101 21
|
||||
#define B0010101 21
|
||||
#define B00010101 21
|
||||
#define B10110 22
|
||||
#define B010110 22
|
||||
#define B0010110 22
|
||||
#define B00010110 22
|
||||
#define B10111 23
|
||||
#define B010111 23
|
||||
#define B0010111 23
|
||||
#define B00010111 23
|
||||
#define B11000 24
|
||||
#define B011000 24
|
||||
#define B0011000 24
|
||||
#define B00011000 24
|
||||
#define B11001 25
|
||||
#define B011001 25
|
||||
#define B0011001 25
|
||||
#define B00011001 25
|
||||
#define B11010 26
|
||||
#define B011010 26
|
||||
#define B0011010 26
|
||||
#define B00011010 26
|
||||
#define B11011 27
|
||||
#define B011011 27
|
||||
#define B0011011 27
|
||||
#define B00011011 27
|
||||
#define B11100 28
|
||||
#define B011100 28
|
||||
#define B0011100 28
|
||||
#define B00011100 28
|
||||
#define B11101 29
|
||||
#define B011101 29
|
||||
#define B0011101 29
|
||||
#define B00011101 29
|
||||
#define B11110 30
|
||||
#define B011110 30
|
||||
#define B0011110 30
|
||||
#define B00011110 30
|
||||
#define B11111 31
|
||||
#define B011111 31
|
||||
#define B0011111 31
|
||||
#define B00011111 31
|
||||
#define B100000 32
|
||||
#define B0100000 32
|
||||
#define B00100000 32
|
||||
#define B100001 33
|
||||
#define B0100001 33
|
||||
#define B00100001 33
|
||||
#define B100010 34
|
||||
#define B0100010 34
|
||||
#define B00100010 34
|
||||
#define B100011 35
|
||||
#define B0100011 35
|
||||
#define B00100011 35
|
||||
#define B100100 36
|
||||
#define B0100100 36
|
||||
#define B00100100 36
|
||||
#define B100101 37
|
||||
#define B0100101 37
|
||||
#define B00100101 37
|
||||
#define B100110 38
|
||||
#define B0100110 38
|
||||
#define B00100110 38
|
||||
#define B100111 39
|
||||
#define B0100111 39
|
||||
#define B00100111 39
|
||||
#define B101000 40
|
||||
#define B0101000 40
|
||||
#define B00101000 40
|
||||
#define B101001 41
|
||||
#define B0101001 41
|
||||
#define B00101001 41
|
||||
#define B101010 42
|
||||
#define B0101010 42
|
||||
#define B00101010 42
|
||||
#define B101011 43
|
||||
#define B0101011 43
|
||||
#define B00101011 43
|
||||
#define B101100 44
|
||||
#define B0101100 44
|
||||
#define B00101100 44
|
||||
#define B101101 45
|
||||
#define B0101101 45
|
||||
#define B00101101 45
|
||||
#define B101110 46
|
||||
#define B0101110 46
|
||||
#define B00101110 46
|
||||
#define B101111 47
|
||||
#define B0101111 47
|
||||
#define B00101111 47
|
||||
#define B110000 48
|
||||
#define B0110000 48
|
||||
#define B00110000 48
|
||||
#define B110001 49
|
||||
#define B0110001 49
|
||||
#define B00110001 49
|
||||
#define B110010 50
|
||||
#define B0110010 50
|
||||
#define B00110010 50
|
||||
#define B110011 51
|
||||
#define B0110011 51
|
||||
#define B00110011 51
|
||||
#define B110100 52
|
||||
#define B0110100 52
|
||||
#define B00110100 52
|
||||
#define B110101 53
|
||||
#define B0110101 53
|
||||
#define B00110101 53
|
||||
#define B110110 54
|
||||
#define B0110110 54
|
||||
#define B00110110 54
|
||||
#define B110111 55
|
||||
#define B0110111 55
|
||||
#define B00110111 55
|
||||
#define B111000 56
|
||||
#define B0111000 56
|
||||
#define B00111000 56
|
||||
#define B111001 57
|
||||
#define B0111001 57
|
||||
#define B00111001 57
|
||||
#define B111010 58
|
||||
#define B0111010 58
|
||||
#define B00111010 58
|
||||
#define B111011 59
|
||||
#define B0111011 59
|
||||
#define B00111011 59
|
||||
#define B111100 60
|
||||
#define B0111100 60
|
||||
#define B00111100 60
|
||||
#define B111101 61
|
||||
#define B0111101 61
|
||||
#define B00111101 61
|
||||
#define B111110 62
|
||||
#define B0111110 62
|
||||
#define B00111110 62
|
||||
#define B111111 63
|
||||
#define B0111111 63
|
||||
#define B00111111 63
|
||||
#define B1000000 64
|
||||
#define B01000000 64
|
||||
#define B1000001 65
|
||||
#define B01000001 65
|
||||
#define B1000010 66
|
||||
#define B01000010 66
|
||||
#define B1000011 67
|
||||
#define B01000011 67
|
||||
#define B1000100 68
|
||||
#define B01000100 68
|
||||
#define B1000101 69
|
||||
#define B01000101 69
|
||||
#define B1000110 70
|
||||
#define B01000110 70
|
||||
#define B1000111 71
|
||||
#define B01000111 71
|
||||
#define B1001000 72
|
||||
#define B01001000 72
|
||||
#define B1001001 73
|
||||
#define B01001001 73
|
||||
#define B1001010 74
|
||||
#define B01001010 74
|
||||
#define B1001011 75
|
||||
#define B01001011 75
|
||||
#define B1001100 76
|
||||
#define B01001100 76
|
||||
#define B1001101 77
|
||||
#define B01001101 77
|
||||
#define B1001110 78
|
||||
#define B01001110 78
|
||||
#define B1001111 79
|
||||
#define B01001111 79
|
||||
#define B1010000 80
|
||||
#define B01010000 80
|
||||
#define B1010001 81
|
||||
#define B01010001 81
|
||||
#define B1010010 82
|
||||
#define B01010010 82
|
||||
#define B1010011 83
|
||||
#define B01010011 83
|
||||
#define B1010100 84
|
||||
#define B01010100 84
|
||||
#define B1010101 85
|
||||
#define B01010101 85
|
||||
#define B1010110 86
|
||||
#define B01010110 86
|
||||
#define B1010111 87
|
||||
#define B01010111 87
|
||||
#define B1011000 88
|
||||
#define B01011000 88
|
||||
#define B1011001 89
|
||||
#define B01011001 89
|
||||
#define B1011010 90
|
||||
#define B01011010 90
|
||||
#define B1011011 91
|
||||
#define B01011011 91
|
||||
#define B1011100 92
|
||||
#define B01011100 92
|
||||
#define B1011101 93
|
||||
#define B01011101 93
|
||||
#define B1011110 94
|
||||
#define B01011110 94
|
||||
#define B1011111 95
|
||||
#define B01011111 95
|
||||
#define B1100000 96
|
||||
#define B01100000 96
|
||||
#define B1100001 97
|
||||
#define B01100001 97
|
||||
#define B1100010 98
|
||||
#define B01100010 98
|
||||
#define B1100011 99
|
||||
#define B01100011 99
|
||||
#define B1100100 100
|
||||
#define B01100100 100
|
||||
#define B1100101 101
|
||||
#define B01100101 101
|
||||
#define B1100110 102
|
||||
#define B01100110 102
|
||||
#define B1100111 103
|
||||
#define B01100111 103
|
||||
#define B1101000 104
|
||||
#define B01101000 104
|
||||
#define B1101001 105
|
||||
#define B01101001 105
|
||||
#define B1101010 106
|
||||
#define B01101010 106
|
||||
#define B1101011 107
|
||||
#define B01101011 107
|
||||
#define B1101100 108
|
||||
#define B01101100 108
|
||||
#define B1101101 109
|
||||
#define B01101101 109
|
||||
#define B1101110 110
|
||||
#define B01101110 110
|
||||
#define B1101111 111
|
||||
#define B01101111 111
|
||||
#define B1110000 112
|
||||
#define B01110000 112
|
||||
#define B1110001 113
|
||||
#define B01110001 113
|
||||
#define B1110010 114
|
||||
#define B01110010 114
|
||||
#define B1110011 115
|
||||
#define B01110011 115
|
||||
#define B1110100 116
|
||||
#define B01110100 116
|
||||
#define B1110101 117
|
||||
#define B01110101 117
|
||||
#define B1110110 118
|
||||
#define B01110110 118
|
||||
#define B1110111 119
|
||||
#define B01110111 119
|
||||
#define B1111000 120
|
||||
#define B01111000 120
|
||||
#define B1111001 121
|
||||
#define B01111001 121
|
||||
#define B1111010 122
|
||||
#define B01111010 122
|
||||
#define B1111011 123
|
||||
#define B01111011 123
|
||||
#define B1111100 124
|
||||
#define B01111100 124
|
||||
#define B1111101 125
|
||||
#define B01111101 125
|
||||
#define B1111110 126
|
||||
#define B01111110 126
|
||||
#define B1111111 127
|
||||
#define B01111111 127
|
||||
#define B10000000 128
|
||||
#define B10000001 129
|
||||
#define B10000010 130
|
||||
#define B10000011 131
|
||||
#define B10000100 132
|
||||
#define B10000101 133
|
||||
#define B10000110 134
|
||||
#define B10000111 135
|
||||
#define B10001000 136
|
||||
#define B10001001 137
|
||||
#define B10001010 138
|
||||
#define B10001011 139
|
||||
#define B10001100 140
|
||||
#define B10001101 141
|
||||
#define B10001110 142
|
||||
#define B10001111 143
|
||||
#define B10010000 144
|
||||
#define B10010001 145
|
||||
#define B10010010 146
|
||||
#define B10010011 147
|
||||
#define B10010100 148
|
||||
#define B10010101 149
|
||||
#define B10010110 150
|
||||
#define B10010111 151
|
||||
#define B10011000 152
|
||||
#define B10011001 153
|
||||
#define B10011010 154
|
||||
#define B10011011 155
|
||||
#define B10011100 156
|
||||
#define B10011101 157
|
||||
#define B10011110 158
|
||||
#define B10011111 159
|
||||
#define B10100000 160
|
||||
#define B10100001 161
|
||||
#define B10100010 162
|
||||
#define B10100011 163
|
||||
#define B10100100 164
|
||||
#define B10100101 165
|
||||
#define B10100110 166
|
||||
#define B10100111 167
|
||||
#define B10101000 168
|
||||
#define B10101001 169
|
||||
#define B10101010 170
|
||||
#define B10101011 171
|
||||
#define B10101100 172
|
||||
#define B10101101 173
|
||||
#define B10101110 174
|
||||
#define B10101111 175
|
||||
#define B10110000 176
|
||||
#define B10110001 177
|
||||
#define B10110010 178
|
||||
#define B10110011 179
|
||||
#define B10110100 180
|
||||
#define B10110101 181
|
||||
#define B10110110 182
|
||||
#define B10110111 183
|
||||
#define B10111000 184
|
||||
#define B10111001 185
|
||||
#define B10111010 186
|
||||
#define B10111011 187
|
||||
#define B10111100 188
|
||||
#define B10111101 189
|
||||
#define B10111110 190
|
||||
#define B10111111 191
|
||||
#define B11000000 192
|
||||
#define B11000001 193
|
||||
#define B11000010 194
|
||||
#define B11000011 195
|
||||
#define B11000100 196
|
||||
#define B11000101 197
|
||||
#define B11000110 198
|
||||
#define B11000111 199
|
||||
#define B11001000 200
|
||||
#define B11001001 201
|
||||
#define B11001010 202
|
||||
#define B11001011 203
|
||||
#define B11001100 204
|
||||
#define B11001101 205
|
||||
#define B11001110 206
|
||||
#define B11001111 207
|
||||
#define B11010000 208
|
||||
#define B11010001 209
|
||||
#define B11010010 210
|
||||
#define B11010011 211
|
||||
#define B11010100 212
|
||||
#define B11010101 213
|
||||
#define B11010110 214
|
||||
#define B11010111 215
|
||||
#define B11011000 216
|
||||
#define B11011001 217
|
||||
#define B11011010 218
|
||||
#define B11011011 219
|
||||
#define B11011100 220
|
||||
#define B11011101 221
|
||||
#define B11011110 222
|
||||
#define B11011111 223
|
||||
#define B11100000 224
|
||||
#define B11100001 225
|
||||
#define B11100010 226
|
||||
#define B11100011 227
|
||||
#define B11100100 228
|
||||
#define B11100101 229
|
||||
#define B11100110 230
|
||||
#define B11100111 231
|
||||
#define B11101000 232
|
||||
#define B11101001 233
|
||||
#define B11101010 234
|
||||
#define B11101011 235
|
||||
#define B11101100 236
|
||||
#define B11101101 237
|
||||
#define B11101110 238
|
||||
#define B11101111 239
|
||||
#define B11110000 240
|
||||
#define B11110001 241
|
||||
#define B11110010 242
|
||||
#define B11110011 243
|
||||
#define B11110100 244
|
||||
#define B11110101 245
|
||||
#define B11110110 246
|
||||
#define B11110111 247
|
||||
#define B11111000 248
|
||||
#define B11111001 249
|
||||
#define B11111010 250
|
||||
#define B11111011 251
|
||||
#define B11111100 252
|
||||
#define B11111101 253
|
||||
#define B11111110 254
|
||||
#define B11111111 255
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,14 @@
|
||||
#include <WProgram.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
init();
|
||||
|
||||
setup();
|
||||
|
||||
for (;;)
|
||||
loop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
int main(void)
|
||||
{
|
||||
init();
|
||||
|
||||
setup();
|
||||
|
||||
for (;;)
|
||||
loop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
pins_arduino.c - pin definitions for the Arduino board
|
||||
Part of Arduino / Wiring Lite
|
||||
|
||||
Copyright (c) 2005 David A. Mellis
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
|
||||
$Id: pins_arduino.c 254 2007-04-20 23:17:38Z mellis $
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
#include "wiring_private.h"
|
||||
#include "pins_arduino.h"
|
||||
|
||||
// On the Sanguino board, digital pins are also used
|
||||
// for the analog output (software PWM). Analog input
|
||||
// pins are a separate set.
|
||||
|
||||
// ATMEL ATMEGA644P / SANGUINO
|
||||
//
|
||||
// +---\/---+
|
||||
// INT0 (D 0) PB0 1| |40 PA0 (AI 0 / D31)
|
||||
// INT1 (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
|
||||
// RX1 (D 10) PD2 16| |25 PC3 (D 19) TMS
|
||||
// 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
|
||||
// +--------+
|
||||
//
|
||||
|
||||
#define PA 1
|
||||
#define PB 2
|
||||
#define PC 3
|
||||
#define PD 4
|
||||
|
||||
// these arrays map port names (e.g. port B) to the
|
||||
// appropriate addresses for various functions (e.g. reading
|
||||
// and writing)
|
||||
const uint8_t PROGMEM port_to_mode_PGM[] =
|
||||
{
|
||||
NOT_A_PORT,
|
||||
(uint8_t) &DDRA,
|
||||
(uint8_t) &DDRB,
|
||||
(uint8_t) &DDRC,
|
||||
(uint8_t) &DDRD,
|
||||
};
|
||||
|
||||
const uint8_t PROGMEM port_to_output_PGM[] =
|
||||
{
|
||||
NOT_A_PORT,
|
||||
(uint8_t) &PORTA,
|
||||
(uint8_t) &PORTB,
|
||||
(uint8_t) &PORTC,
|
||||
(uint8_t) &PORTD,
|
||||
};
|
||||
|
||||
const uint8_t PROGMEM port_to_input_PGM[] =
|
||||
{
|
||||
NOT_A_PORT,
|
||||
(uint8_t) &PINA,
|
||||
(uint8_t) &PINB,
|
||||
(uint8_t) &PINC,
|
||||
(uint8_t) &PIND,
|
||||
};
|
||||
|
||||
const uint8_t PROGMEM digital_pin_to_port_PGM[] =
|
||||
{
|
||||
PB, /* 0 */
|
||||
PB,
|
||||
PB,
|
||||
PB,
|
||||
PB,
|
||||
PB,
|
||||
PB,
|
||||
PB,
|
||||
PD, /* 8 */
|
||||
PD,
|
||||
PD,
|
||||
PD,
|
||||
PD,
|
||||
PD,
|
||||
PD,
|
||||
PD,
|
||||
PC, /* 16 */
|
||||
PC,
|
||||
PC,
|
||||
PC,
|
||||
PC,
|
||||
PC,
|
||||
PC,
|
||||
PC,
|
||||
PA, /* 24 */
|
||||
PA,
|
||||
PA,
|
||||
PA,
|
||||
PA,
|
||||
PA,
|
||||
PA,
|
||||
PA /* 31 */
|
||||
};
|
||||
|
||||
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
|
||||
{
|
||||
_BV(0), /* 0, port B */
|
||||
_BV(1),
|
||||
_BV(2),
|
||||
_BV(3),
|
||||
_BV(4),
|
||||
_BV(5),
|
||||
_BV(6),
|
||||
_BV(7),
|
||||
_BV(0), /* 8, port D */
|
||||
_BV(1),
|
||||
_BV(2),
|
||||
_BV(3),
|
||||
_BV(4),
|
||||
_BV(5),
|
||||
_BV(6),
|
||||
_BV(7),
|
||||
_BV(0), /* 16, port C */
|
||||
_BV(1),
|
||||
_BV(2),
|
||||
_BV(3),
|
||||
_BV(4),
|
||||
_BV(5),
|
||||
_BV(6),
|
||||
_BV(7),
|
||||
_BV(7), /* 24, port A */
|
||||
_BV(6),
|
||||
_BV(5),
|
||||
_BV(4),
|
||||
_BV(3),
|
||||
_BV(2),
|
||||
_BV(1),
|
||||
_BV(0)
|
||||
};
|
||||
|
||||
const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
|
||||
{
|
||||
NOT_ON_TIMER, /* 0 - PB0 */
|
||||
NOT_ON_TIMER, /* 1 - PB1 */
|
||||
NOT_ON_TIMER, /* 2 - PB2 */
|
||||
TIMER0A, /* 3 - PB3 */
|
||||
TIMER0B, /* 4 - PB4 */
|
||||
NOT_ON_TIMER, /* 5 - PB5 */
|
||||
NOT_ON_TIMER, /* 6 - PB6 */
|
||||
NOT_ON_TIMER, /* 7 - PB7 */
|
||||
NOT_ON_TIMER, /* 8 - PD0 */
|
||||
NOT_ON_TIMER, /* 9 - PD1 */
|
||||
NOT_ON_TIMER, /* 10 - PD2 */
|
||||
NOT_ON_TIMER, /* 11 - PD3 */
|
||||
TIMER1B, /* 12 - PD4 */
|
||||
TIMER1A, /* 13 - PD5 */
|
||||
TIMER2B, /* 14 - PD6 */
|
||||
TIMER2A, /* 15 - PD7 */
|
||||
NOT_ON_TIMER, /* 16 - PC0 */
|
||||
NOT_ON_TIMER, /* 17 - PC1 */
|
||||
NOT_ON_TIMER, /* 18 - PC2 */
|
||||
NOT_ON_TIMER, /* 19 - PC3 */
|
||||
NOT_ON_TIMER, /* 20 - PC4 */
|
||||
NOT_ON_TIMER, /* 21 - PC5 */
|
||||
NOT_ON_TIMER, /* 22 - PC6 */
|
||||
NOT_ON_TIMER, /* 23 - PC7 */
|
||||
NOT_ON_TIMER, /* 24 - PA0 */
|
||||
NOT_ON_TIMER, /* 25 - PA1 */
|
||||
NOT_ON_TIMER, /* 26 - PA2 */
|
||||
NOT_ON_TIMER, /* 27 - PA3 */
|
||||
NOT_ON_TIMER, /* 28 - PA4 */
|
||||
NOT_ON_TIMER, /* 29 - PA5 */
|
||||
NOT_ON_TIMER, /* 30 - PA6 */
|
||||
NOT_ON_TIMER /* 31 - PA7 */
|
||||
};
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
pins_arduino.h - Pin definition functions for Arduino
|
||||
Part of Arduino - http://www.arduino.cc/
|
||||
|
||||
Copyright (c) 2007 David A. Mellis
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
|
||||
$Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
|
||||
*/
|
||||
|
||||
#ifndef Pins_Arduino_h
|
||||
#define Pins_Arduino_h
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#define NOT_A_PIN 0
|
||||
#define NOT_A_PORT 0
|
||||
|
||||
#define NOT_ON_TIMER 0
|
||||
#define TIMER0A 1
|
||||
#define TIMER0B 2
|
||||
#define TIMER1A 3
|
||||
#define TIMER1B 4
|
||||
#define TIMER2 5
|
||||
#define TIMER2A 6
|
||||
#define TIMER2B 7
|
||||
|
||||
extern const uint8_t PROGMEM port_to_mode_PGM[];
|
||||
extern const uint8_t PROGMEM port_to_input_PGM[];
|
||||
extern const uint8_t PROGMEM port_to_output_PGM[];
|
||||
|
||||
extern const uint8_t PROGMEM digital_pin_to_port_PGM[];
|
||||
extern const uint8_t PROGMEM digital_pin_to_bit_PGM[];
|
||||
extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[];
|
||||
|
||||
extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
|
||||
|
||||
// Get the bit location within the hardware port of the given virtual pin.
|
||||
// This comes from the pins_*.c file for the active board configuration.
|
||||
//
|
||||
// These perform slightly better as macros compared to inline functions
|
||||
//
|
||||
#define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) )
|
||||
#define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) )
|
||||
#define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) )
|
||||
#define analogInPinToBit(P) (P)
|
||||
#define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_byte( port_to_output_PGM + (P))) )
|
||||
#define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_byte( port_to_input_PGM + (P))) )
|
||||
#define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_byte( port_to_mode_PGM + (P))) )
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
wiring.c - Partial implementation of the Wiring API for the ATmega8.
|
||||
Part of Arduino - http://www.arduino.cc/
|
||||
|
||||
Copyright (c) 2005-2006 David A. Mellis
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
|
||||
$Id: wiring.c 388 2008-03-08 22:05:23Z mellis $
|
||||
*/
|
||||
|
||||
#include "wiring_private.h"
|
||||
|
||||
volatile unsigned long timer0_overflow_count = 0;
|
||||
volatile unsigned long timer0_clock_cycles = 0;
|
||||
volatile unsigned long timer0_millis = 0;
|
||||
|
||||
SIGNAL(TIMER0_OVF_vect)
|
||||
{
|
||||
timer0_overflow_count++;
|
||||
// timer 0 prescale factor is 64 and the timer overflows at 256
|
||||
timer0_clock_cycles += 64UL * 256UL;
|
||||
while (timer0_clock_cycles > clockCyclesPerMicrosecond() * 1000UL) {
|
||||
timer0_clock_cycles -= clockCyclesPerMicrosecond() * 1000UL;
|
||||
timer0_millis++;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long millis()
|
||||
{
|
||||
unsigned long m;
|
||||
uint8_t oldSREG = SREG;
|
||||
|
||||
// disable interrupts while we read timer0_millis or we might get an
|
||||
// inconsistent value (e.g. in the middle of the timer0_millis++)
|
||||
cli();
|
||||
m = timer0_millis;
|
||||
SREG = oldSREG;
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
unsigned long micros() {
|
||||
unsigned long m, t;
|
||||
uint8_t oldSREG = SREG;
|
||||
|
||||
cli();
|
||||
t = TCNT0;
|
||||
|
||||
#ifdef TIFR0
|
||||
if ((TIFR0 & _BV(TOV0)) && (t == 0))
|
||||
t = 256;
|
||||
#else
|
||||
if ((TIFR & _BV(TOV0)) && (t == 0))
|
||||
t = 256;
|
||||
#endif
|
||||
|
||||
m = timer0_overflow_count;
|
||||
SREG = oldSREG;
|
||||
|
||||
return ((m << 8) + t) * (64 / clockCyclesPerMicrosecond());
|
||||
}
|
||||
|
||||
void delay(unsigned long ms)
|
||||
{
|
||||
unsigned long start = millis();
|
||||
|
||||
while (millis() - start <= ms)
|
||||
;
|
||||
}
|
||||
|
||||
/* Delay for the given number of microseconds. Assumes a 8 or 16 MHz clock.
|
||||
* Disables interrupts, which will disrupt the millis() function if used
|
||||
* too frequently. */
|
||||
void delayMicroseconds(unsigned int us)
|
||||
{
|
||||
uint8_t oldSREG;
|
||||
|
||||
// calling avrlib's delay_us() function with low values (e.g. 1 or
|
||||
// 2 microseconds) gives delays longer than desired.
|
||||
//delay_us(us);
|
||||
|
||||
#if F_CPU >= 16000000L
|
||||
// for the 16 MHz clock on most Arduino boards
|
||||
|
||||
// for a one-microsecond delay, simply return. the overhead
|
||||
// of the function call yields a delay of approximately 1 1/8 us.
|
||||
if (--us == 0)
|
||||
return;
|
||||
|
||||
// the following loop takes a quarter of a microsecond (4 cycles)
|
||||
// per iteration, so execute it four times for each microsecond of
|
||||
// delay requested.
|
||||
us <<= 2;
|
||||
|
||||
// account for the time taken in the preceeding commands.
|
||||
us -= 2;
|
||||
#else
|
||||
// for the 8 MHz internal clock on the ATmega168
|
||||
|
||||
// for a one- or two-microsecond delay, simply return. the overhead of
|
||||
// the function calls takes more than two microseconds. can't just
|
||||
// subtract two, since us is unsigned; we'd overflow.
|
||||
if (--us == 0)
|
||||
return;
|
||||
if (--us == 0)
|
||||
return;
|
||||
|
||||
// the following loop takes half of a microsecond (4 cycles)
|
||||
// per iteration, so execute it twice for each microsecond of
|
||||
// delay requested.
|
||||
us <<= 1;
|
||||
|
||||
// partially compensate for the time taken by the preceeding commands.
|
||||
// we can't subtract any more than this or we'd overflow w/ small delays.
|
||||
us--;
|
||||
#endif
|
||||
|
||||
// disable interrupts, otherwise the timer 0 overflow interrupt that
|
||||
// tracks milliseconds will make us delay longer than we want.
|
||||
oldSREG = SREG;
|
||||
cli();
|
||||
|
||||
// busy wait
|
||||
__asm__ __volatile__ (
|
||||
"1: sbiw %0,1" "\n\t" // 2 cycles
|
||||
"brne 1b" : "=w" (us) : "0" (us) // 2 cycles
|
||||
);
|
||||
|
||||
// reenable interrupts.
|
||||
SREG = oldSREG;
|
||||
}
|
||||
|
||||
void init()
|
||||
{
|
||||
// this needs to be called before setup() or some functions won't
|
||||
// work there
|
||||
sei();
|
||||
|
||||
// on the ATmega168, timer 0 is also used for fast hardware pwm
|
||||
// (using phase-correct PWM would mean that timer 0 overflowed half as often
|
||||
// resulting in different millis() behavior on the ATmega8 and ATmega168)
|
||||
sbi(TCCR0A, WGM01);
|
||||
sbi(TCCR0A, WGM00);
|
||||
|
||||
// set timer 0 prescale factor to 64
|
||||
sbi(TCCR0B, CS01);
|
||||
sbi(TCCR0B, CS00);
|
||||
|
||||
// enable timer 0 overflow interrupt
|
||||
sbi(TIMSK0, TOIE0);
|
||||
|
||||
// timers 1 and 2 are used for phase-correct hardware pwm
|
||||
// this is better for motors as it ensures an even waveform
|
||||
// note, however, that fast pwm mode can achieve a frequency of up
|
||||
// 8 MHz (with a 16 MHz clock) at 50% duty cycle
|
||||
|
||||
// set timer 1 prescale factor to 64
|
||||
sbi(TCCR1B, CS11);
|
||||
sbi(TCCR1B, CS10);
|
||||
|
||||
// put timer 1 in 8-bit phase correct pwm mode
|
||||
sbi(TCCR1A, WGM10);
|
||||
|
||||
// set timer 2 prescale factor to 64
|
||||
sbi(TCCR2B, CS22);
|
||||
|
||||
// configure timer 2 for phase correct pwm (8-bit)
|
||||
sbi(TCCR2A, WGM20);
|
||||
|
||||
// set a2d prescale factor to 128
|
||||
// 16 MHz / 128 = 125 KHz, inside the desired 50-200 KHz range.
|
||||
// XXX: this will not work properly for other clock speeds, and
|
||||
// this code should use F_CPU to determine the prescale factor.
|
||||
sbi(ADCSRA, ADPS2);
|
||||
sbi(ADCSRA, ADPS1);
|
||||
sbi(ADCSRA, ADPS0);
|
||||
|
||||
// enable a2d conversions
|
||||
sbi(ADCSRA, ADEN);
|
||||
|
||||
// the bootloader connects pins 0 and 1 to the USART; disconnect them
|
||||
// here so they can be used as normal digital i/o; they will be
|
||||
// reconnected in Serial.begin()
|
||||
UCSR0B = 0;
|
||||
#if defined(__AVR_ATmega644P__)
|
||||
//TODO: test to see if disabling this helps?
|
||||
//UCSR1B = 0;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
wiring.h - Partial implementation of the Wiring API for the ATmega8.
|
||||
Part of Arduino - http://www.arduino.cc/
|
||||
|
||||
Copyright (c) 2005-2006 David A. Mellis
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
|
||||
$Id: wiring.h 387 2008-03-08 21:30:00Z mellis $
|
||||
*/
|
||||
|
||||
#ifndef Wiring_h
|
||||
#define Wiring_h
|
||||
|
||||
#include <avr/io.h>
|
||||
#include "binary.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
#define HIGH 0x1
|
||||
#define LOW 0x0
|
||||
|
||||
#define INPUT 0x0
|
||||
#define OUTPUT 0x1
|
||||
|
||||
#define true 0x1
|
||||
#define false 0x0
|
||||
|
||||
#define PI 3.14159265
|
||||
#define HALF_PI 1.57079
|
||||
#define TWO_PI 6.283185
|
||||
#define DEG_TO_RAD 0.01745329
|
||||
#define RAD_TO_DEG 57.2957786
|
||||
|
||||
#define SERIAL 0x0
|
||||
#define DISPLAY 0x1
|
||||
|
||||
#define LSBFIRST 0
|
||||
#define MSBFIRST 1
|
||||
|
||||
#define CHANGE 1
|
||||
#define FALLING 2
|
||||
#define RISING 3
|
||||
|
||||
#define INTERNAL 3
|
||||
#define DEFAULT 1
|
||||
#define EXTERNAL 0
|
||||
|
||||
// undefine stdlib's abs if encountered
|
||||
#ifdef abs
|
||||
#undef abs
|
||||
#endif
|
||||
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
#define max(a,b) ((a)>(b)?(a):(b))
|
||||
#define abs(x) ((x)>0?(x):-(x))
|
||||
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
|
||||
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
|
||||
#define radians(deg) ((deg)*DEG_TO_RAD)
|
||||
#define degrees(rad) ((rad)*RAD_TO_DEG)
|
||||
#define sq(x) ((x)*(x))
|
||||
|
||||
#define interrupts() sei()
|
||||
#define noInterrupts() cli()
|
||||
|
||||
#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
|
||||
#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
|
||||
#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() )
|
||||
|
||||
#define lowByte(w) ((w) & 0xff)
|
||||
#define highByte(w) ((w) >> 8)
|
||||
|
||||
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
|
||||
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
|
||||
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
|
||||
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
|
||||
|
||||
typedef unsigned int word;
|
||||
|
||||
#define bit(b) (1 << (b))
|
||||
|
||||
typedef uint8_t boolean;
|
||||
typedef uint8_t byte;
|
||||
|
||||
void init(void);
|
||||
|
||||
void pinMode(uint8_t, uint8_t);
|
||||
void digitalWrite(uint8_t, uint8_t);
|
||||
int digitalRead(uint8_t);
|
||||
int analogRead(uint8_t);
|
||||
void analogReference(uint8_t mode);
|
||||
void analogWrite(uint8_t, int);
|
||||
|
||||
void beginSerial(uint8_t, long);
|
||||
void serialWrite(uint8_t, unsigned char);
|
||||
int serialAvailable(uint8_t);
|
||||
int serialRead(uint8_t);
|
||||
void serialFlush(uint8_t);
|
||||
|
||||
unsigned long millis(void);
|
||||
unsigned long micros(void);
|
||||
void delay(unsigned long);
|
||||
void delayMicroseconds(unsigned int us);
|
||||
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);
|
||||
|
||||
void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, byte val);
|
||||
|
||||
void attachInterrupt(uint8_t, void (*)(void), int mode);
|
||||
void detachInterrupt(uint8_t);
|
||||
|
||||
void setup(void);
|
||||
void loop(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
wiring_analog.c - analog input and output
|
||||
Part of Arduino - http://www.arduino.cc/
|
||||
|
||||
Copyright (c) 2005-2006 David A. Mellis
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
|
||||
$Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
|
||||
*/
|
||||
|
||||
#include "wiring_private.h"
|
||||
#include "pins_arduino.h"
|
||||
|
||||
uint8_t analog_reference = DEFAULT;
|
||||
|
||||
void analogReference(uint8_t mode)
|
||||
{
|
||||
// can't actually set the register here because the default setting
|
||||
// will connect AVCC and the AREF pin, which would cause a short if
|
||||
// there's something connected to AREF.
|
||||
analog_reference = mode;
|
||||
}
|
||||
|
||||
int analogRead(uint8_t pin)
|
||||
{
|
||||
uint8_t low, high, ch = analogInPinToBit(pin);
|
||||
|
||||
// set the analog reference (high two bits of ADMUX) and select the
|
||||
// channel (low 4 bits). this also sets ADLAR (left-adjust result)
|
||||
// to 0 (the default).
|
||||
// the final AND is to clear the pos/neg reference bits
|
||||
ADMUX = ((analog_reference << 6) | (pin & 0x0f)) & B11000111;
|
||||
|
||||
// without a delay, we seem to read from the wrong channel
|
||||
//delay(1);
|
||||
|
||||
// start the conversion
|
||||
sbi(ADCSRA, ADSC);
|
||||
|
||||
// ADSC is cleared when the conversion finishes
|
||||
while (bit_is_set(ADCSRA, ADSC));
|
||||
|
||||
// we have to read ADCL first; doing so locks both ADCL
|
||||
// and ADCH until ADCH is read. reading ADCL second would
|
||||
// cause the results of each conversion to be discarded,
|
||||
// as ADCL and ADCH would be locked when it completed.
|
||||
low = ADCL;
|
||||
high = ADCH;
|
||||
|
||||
// combine the two bytes
|
||||
return (high << 8) | low;
|
||||
}
|
||||
|
||||
// Right now, PWM output only works on the pins with
|
||||
// hardware support. These are defined in the appropriate
|
||||
// pins_*.c file. For the rest of the pins, we default
|
||||
// to digital output.
|
||||
void analogWrite(uint8_t pin, int val)
|
||||
{
|
||||
// We need to make sure the PWM output is enabled for those pins
|
||||
// that support it, as we turn it off when digitally reading or
|
||||
// writing with them. Also, make sure the pin is in output mode
|
||||
// for consistenty with Wiring, which doesn't require a pinMode
|
||||
// call for the analog output pins.
|
||||
pinMode(pin, OUTPUT);
|
||||
|
||||
if (digitalPinToTimer(pin) == TIMER1A) {
|
||||
// connect pwm to pin on timer 1, channel A
|
||||
sbi(TCCR1A, COM1A1);
|
||||
// set pwm duty
|
||||
OCR1A = val;
|
||||
} else if (digitalPinToTimer(pin) == TIMER1B) {
|
||||
// connect pwm to pin on timer 1, channel B
|
||||
sbi(TCCR1A, COM1B1);
|
||||
// set pwm duty
|
||||
OCR1B = val;
|
||||
} else if (digitalPinToTimer(pin) == TIMER0A) {
|
||||
// connect pwm to pin on timer 0, channel A
|
||||
sbi(TCCR0A, COM0A1);
|
||||
// set pwm duty
|
||||
OCR0A = val;
|
||||
} else if (digitalPinToTimer(pin) == TIMER0B) {
|
||||
// connect pwm to pin on timer 0, channel B
|
||||
sbi(TCCR0A, COM0B1);
|
||||
// set pwm duty
|
||||
OCR0B = val;
|
||||
} else if (digitalPinToTimer(pin) == TIMER2A) {
|
||||
// connect pwm to pin on timer 2, channel A
|
||||
sbi(TCCR2A, COM2A1);
|
||||
// set pwm duty
|
||||
OCR2A = val;
|
||||
} else if (digitalPinToTimer(pin) == TIMER2B) {
|
||||
// connect pwm to pin on timer 2, channel B
|
||||
sbi(TCCR2A, COM2B1);
|
||||
// set pwm duty
|
||||
OCR2B = val;
|
||||
} else if (val < 128)
|
||||
//fail semi-intelligently
|
||||
digitalWrite(pin, LOW);
|
||||
else
|
||||
digitalWrite(pin, HIGH);
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
wiring_digital.c - digital input and output functions
|
||||
Part of Arduino - http://www.arduino.cc/
|
||||
|
||||
Copyright (c) 2005-2006 David A. Mellis
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
|
||||
$Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
|
||||
*/
|
||||
|
||||
#include "wiring_private.h"
|
||||
#include "pins_arduino.h"
|
||||
|
||||
void pinMode(uint8_t pin, uint8_t mode)
|
||||
{
|
||||
uint8_t bit = digitalPinToBitMask(pin);
|
||||
uint8_t port = digitalPinToPort(pin);
|
||||
volatile uint8_t *reg;
|
||||
|
||||
if (port == NOT_A_PIN) return;
|
||||
|
||||
// JWS: can I let the optimizer do this?
|
||||
reg = portModeRegister(port);
|
||||
|
||||
if (mode == INPUT) *reg &= ~bit;
|
||||
else *reg |= bit;
|
||||
}
|
||||
|
||||
// Forcing this inline keeps the callers from having to push their own stuff
|
||||
// on the stack. It is a good performance win and only takes 1 more byte per
|
||||
// user than calling. (It will take more bytes on the 168.)
|
||||
//
|
||||
// But shouldn't this be moved into pinMode? Seems silly to check and do on
|
||||
// each digitalread or write.
|
||||
//
|
||||
static inline void turnOffPWM(uint8_t timer) __attribute__ ((always_inline));
|
||||
static inline void turnOffPWM(uint8_t timer)
|
||||
{
|
||||
if (timer == TIMER0A) cbi(TCCR0A, COM0A1);
|
||||
if (timer == TIMER0B) cbi(TCCR0A, COM0B1);
|
||||
if (timer == TIMER1A) cbi(TCCR1A, COM1A1);
|
||||
if (timer == TIMER1B) cbi(TCCR1A, COM1B1);
|
||||
if (timer == TIMER2A) cbi(TCCR2A, COM2A1);
|
||||
if (timer == TIMER2B) cbi(TCCR2A, COM2B1);
|
||||
}
|
||||
|
||||
void digitalWrite(uint8_t pin, uint8_t val)
|
||||
{
|
||||
uint8_t timer = digitalPinToTimer(pin);
|
||||
uint8_t bit = digitalPinToBitMask(pin);
|
||||
uint8_t port = digitalPinToPort(pin);
|
||||
volatile uint8_t *out;
|
||||
|
||||
if (port == NOT_A_PIN) return;
|
||||
|
||||
// If the pin that support PWM output, we need to turn it off
|
||||
// before doing a digital write.
|
||||
if (timer != NOT_ON_TIMER) turnOffPWM(timer);
|
||||
|
||||
out = portOutputRegister(port);
|
||||
|
||||
if (val == LOW) *out &= ~bit;
|
||||
else *out |= bit;
|
||||
}
|
||||
|
||||
int digitalRead(uint8_t pin)
|
||||
{
|
||||
uint8_t timer = digitalPinToTimer(pin);
|
||||
uint8_t bit = digitalPinToBitMask(pin);
|
||||
uint8_t port = digitalPinToPort(pin);
|
||||
|
||||
if (port == NOT_A_PIN) return LOW;
|
||||
|
||||
// If the pin that support PWM output, we need to turn it off
|
||||
// before getting a digital reading.
|
||||
if (timer != NOT_ON_TIMER) turnOffPWM(timer);
|
||||
|
||||
if (*portInputRegister(port) & bit) return HIGH;
|
||||
|
||||
return LOW;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
wiring_private.h - Internal header file.
|
||||
Part of Arduino - http://www.arduino.cc/
|
||||
|
||||
Copyright (c) 2005-2006 David A. Mellis
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
|
||||
$Id: wiring.h 239 2007-01-12 17:58:39Z mellis $
|
||||
*/
|
||||
|
||||
#ifndef WiringPrivate_h
|
||||
#define WiringPrivate_h
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/signal.h>
|
||||
#include <avr/delay.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "wiring.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
#ifndef cbi
|
||||
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
|
||||
#endif
|
||||
#ifndef sbi
|
||||
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
|
||||
#endif
|
||||
|
||||
#define EXTERNAL_INT_0 0
|
||||
#define EXTERNAL_INT_1 1
|
||||
#define EXTERNAL_INT_2 2
|
||||
|
||||
#define EXTERNAL_NUM_INTERRUPTS 3
|
||||
|
||||
typedef void (*voidFuncPtr)(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
wiring_pulse.c - pulseIn() function
|
||||
Part of Arduino - http://www.arduino.cc/
|
||||
|
||||
Copyright (c) 2005-2006 David A. Mellis
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
|
||||
$Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
|
||||
*/
|
||||
|
||||
#include "wiring_private.h"
|
||||
#include "pins_arduino.h"
|
||||
|
||||
/* Measures the length (in microseconds) of a pulse on the pin; state is HIGH
|
||||
* or LOW, the type of pulse to measure. Works on pulses from 2-3 microseconds
|
||||
* to 3 minutes in length, but must be called at least a few dozen microseconds
|
||||
* before the start of the pulse. */
|
||||
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout)
|
||||
{
|
||||
// cache the port and bit of the pin in order to speed up the
|
||||
// pulse width measuring loop and achieve finer resolution. calling
|
||||
// digitalRead() instead yields much coarser resolution.
|
||||
uint8_t bit = digitalPinToBitMask(pin);
|
||||
uint8_t port = digitalPinToPort(pin);
|
||||
uint8_t stateMask = (state ? bit : 0);
|
||||
unsigned long width = 0; // keep initialization out of time critical area
|
||||
|
||||
// convert the timeout from microseconds to a number of times through
|
||||
// the initial loop; it takes 16 clock cycles per iteration.
|
||||
unsigned long numloops = 0;
|
||||
unsigned long maxloops = microsecondsToClockCycles(timeout) / 16;
|
||||
|
||||
// wait for any previous pulse to end
|
||||
while ((*portInputRegister(port) & bit) == stateMask)
|
||||
if (numloops++ == maxloops)
|
||||
return 0;
|
||||
|
||||
// wait for the pulse to start
|
||||
while ((*portInputRegister(port) & bit) != stateMask)
|
||||
if (numloops++ == maxloops)
|
||||
return 0;
|
||||
|
||||
// wait for the pulse to stop
|
||||
while ((*portInputRegister(port) & bit) == stateMask)
|
||||
width++;
|
||||
|
||||
// convert the reading to microseconds. The loop has been determined
|
||||
// to be 10 clock cycles long and have about 16 clocks between the edge
|
||||
// and the start of the loop. There will be some error introduced by
|
||||
// the interrupt handlers.
|
||||
return clockCyclesToMicroseconds(width * 10 + 16);
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
wiring_serial.c - serial functions.
|
||||
Part of Arduino - http://www.arduino.cc/
|
||||
|
||||
Copyright (c) 2005-2006 David A. Mellis
|
||||
Modified 29 January 2009, Marius Kintel for Sanguino - http://www.sanguino.cc/
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
|
||||
$Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
|
||||
*/
|
||||
|
||||
|
||||
#include "wiring_private.h"
|
||||
|
||||
// Define constants and variables for buffering incoming serial data. We're
|
||||
// using a ring buffer (I think), in which rx_buffer_head is the index of the
|
||||
// location to which to write the next incoming character and rx_buffer_tail
|
||||
// is the index of the location from which to read.
|
||||
#define RX_BUFFER_SIZE 128
|
||||
|
||||
#if defined(__AVR_ATmega644P__)
|
||||
unsigned char rx_buffer[2][RX_BUFFER_SIZE];
|
||||
int rx_buffer_head[2] = {0, 0};
|
||||
int rx_buffer_tail[2] = {0, 0};
|
||||
#else
|
||||
unsigned char rx_buffer[1][RX_BUFFER_SIZE];
|
||||
int rx_buffer_head[1] = {0};
|
||||
int rx_buffer_tail[1] = {0};
|
||||
#endif
|
||||
|
||||
|
||||
#define BEGIN_SERIAL(uart_, baud_) \
|
||||
{ \
|
||||
UBRR##uart_##H = ((F_CPU / 16 + baud / 2) / baud - 1) >> 8; \
|
||||
UBRR##uart_##L = ((F_CPU / 16 + baud / 2) / baud - 1); \
|
||||
\
|
||||
/* reset config for UART */ \
|
||||
UCSR##uart_##A = 0; \
|
||||
UCSR##uart_##B = 0; \
|
||||
UCSR##uart_##C = 0; \
|
||||
\
|
||||
/* enable rx and tx */ \
|
||||
sbi(UCSR##uart_##B, RXEN##uart_);\
|
||||
sbi(UCSR##uart_##B, TXEN##uart_);\
|
||||
\
|
||||
/* enable interrupt on complete reception of a byte */ \
|
||||
sbi(UCSR##uart_##B, RXCIE##uart_); \
|
||||
UCSR##uart_##C = _BV(UCSZ##uart_##1)|_BV(UCSZ##uart_##0); \
|
||||
/* defaults to 8-bit, no parity, 1 stop bit */ \
|
||||
}
|
||||
|
||||
void beginSerial(uint8_t uart, long baud)
|
||||
{
|
||||
if (uart == 0) BEGIN_SERIAL(0, baud)
|
||||
#if defined(__AVR_ATmega644P__)
|
||||
else BEGIN_SERIAL(1, baud)
|
||||
#endif
|
||||
}
|
||||
|
||||
#define SERIAL_WRITE(uart_, c_) \
|
||||
while (!(UCSR##uart_##A & (1 << UDRE##uart_))) \
|
||||
; \
|
||||
UDR##uart_ = c
|
||||
|
||||
void serialWrite(uint8_t uart, unsigned char c)
|
||||
{
|
||||
if (uart == 0) {
|
||||
SERIAL_WRITE(0, c);
|
||||
}
|
||||
#if defined(__AVR_ATmega644P__)
|
||||
else {
|
||||
SERIAL_WRITE(1, c);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int serialAvailable(uint8_t uart)
|
||||
{
|
||||
return (RX_BUFFER_SIZE + rx_buffer_head[uart] - rx_buffer_tail[uart]) % RX_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
int serialRead(uint8_t uart)
|
||||
{
|
||||
// if the head isn't ahead of the tail, we don't have any characters
|
||||
if (rx_buffer_head[uart] == rx_buffer_tail[uart]) {
|
||||
return -1;
|
||||
} else {
|
||||
unsigned char c = rx_buffer[uart][rx_buffer_tail[uart]];
|
||||
rx_buffer_tail[uart] = (rx_buffer_tail[uart] + 1) % RX_BUFFER_SIZE;
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
void serialFlush(uint8_t uart)
|
||||
{
|
||||
// don't reverse this or there may be problems if the RX interrupt
|
||||
// occurs after reading the value of rx_buffer_head but before writing
|
||||
// the value to rx_buffer_tail; the previous value of rx_buffer_head
|
||||
// may be written to rx_buffer_tail, making it appear as if the buffer
|
||||
// were full, not empty.
|
||||
rx_buffer_head[uart] = rx_buffer_tail[uart];
|
||||
}
|
||||
|
||||
#define UART_ISR(uart_) \
|
||||
ISR(USART##uart_##_RX_vect) \
|
||||
{ \
|
||||
unsigned char c = UDR##uart_; \
|
||||
\
|
||||
int i = (rx_buffer_head[uart_] + 1) % RX_BUFFER_SIZE; \
|
||||
\
|
||||
/* if we should be storing the received character into the location \
|
||||
just before the tail (meaning that the head would advance to the \
|
||||
current location of the tail), we're about to overflow the buffer \
|
||||
and so we don't write the character or advance the head. */ \
|
||||
if (i != rx_buffer_tail[uart_]) { \
|
||||
rx_buffer[uart_][rx_buffer_head[uart_]] = c; \
|
||||
rx_buffer_head[uart_] = i; \
|
||||
} \
|
||||
}
|
||||
|
||||
UART_ISR(0)
|
||||
#if defined(__AVR_ATmega644P__)
|
||||
UART_ISR(1)
|
||||
#endif
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
wiring_shift.c - shiftOut() function
|
||||
Part of Arduino - http://www.arduino.cc/
|
||||
|
||||
Copyright (c) 2005-2006 David A. Mellis
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
|
||||
$Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
|
||||
*/
|
||||
|
||||
#include "wiring_private.h"
|
||||
|
||||
void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, byte val)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (bitOrder == LSBFIRST)
|
||||
digitalWrite(dataPin, !!(val & (1 << i)));
|
||||
else
|
||||
digitalWrite(dataPin, !!(val & (1 << (7 - i))));
|
||||
|
||||
digitalWrite(clockPin, HIGH);
|
||||
digitalWrite(clockPin, LOW);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,389 @@
|
||||
#include "LiquidCrystalRus.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#if defined(ARDUINO) && ARDUINO >= 100
|
||||
#include "Arduino.h"
|
||||
#else
|
||||
#include "WProgram.h"
|
||||
#endif
|
||||
|
||||
// it is a russian alphabet translation
|
||||
// except 0401 --> 0xa2 = ╗, 0451 --> 0xb5
|
||||
const PROGMEM uint8_t utf_recode[] =
|
||||
{ 0x41,0xa0,0x42,0xa1,0xe0,0x45,0xa3,0xa4,0xa5,0xa6,0x4b,0xa7,0x4d,0x48,0x4f,
|
||||
0xa8,0x50,0x43,0x54,0xa9,0xaa,0x58,0xe1,0xab,0xac,0xe2,0xad,0xae,0x62,0xaf,0xb0,0xb1,
|
||||
0x61,0xb2,0xb3,0xb4,0xe3,0x65,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0x6f,
|
||||
0xbe,0x70,0x63,0xbf,0x79,0xe4,0x78,0xe5,0xc0,0xc1,0xe6,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7
|
||||
};
|
||||
|
||||
// When the display powers up, it is configured as follows:
|
||||
//
|
||||
// 1. Display clear
|
||||
// 2. Function set:
|
||||
// DL = 1; 8-bit interface data
|
||||
// N = 0; 1-line display
|
||||
// F = 0; 5x8 dot character font
|
||||
// 3. Display on/off control:
|
||||
// D = 0; Display off
|
||||
// C = 0; Cursor off
|
||||
// B = 0; Blinking off
|
||||
// 4. Entry mode set:
|
||||
// I/D = 1; Increment by 1
|
||||
// S = 0; No shift
|
||||
//
|
||||
// Note, however, that resetting the Arduino doesn't reset the LCD, so we
|
||||
// can't assume that its in that state when a sketch starts (and the
|
||||
// LiquidCrystal constructor is called).
|
||||
//
|
||||
// modified 27 Jul 2011
|
||||
// by Ilya V. Danilov http://mk90.ru/
|
||||
|
||||
|
||||
LiquidCrystalRus::LiquidCrystalRus(uint8_t rs, uint8_t rw, uint8_t enable,
|
||||
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
|
||||
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7)
|
||||
{
|
||||
init(0, rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7);
|
||||
}
|
||||
|
||||
LiquidCrystalRus::LiquidCrystalRus(uint8_t rs, uint8_t enable,
|
||||
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
|
||||
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7)
|
||||
{
|
||||
init(0, rs, 255, enable, d0, d1, d2, d3, d4, d5, d6, d7);
|
||||
}
|
||||
|
||||
LiquidCrystalRus::LiquidCrystalRus(uint8_t rs, uint8_t rw, uint8_t enable,
|
||||
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3)
|
||||
{
|
||||
init(1, rs, rw, enable, d0, d1, d2, d3, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
LiquidCrystalRus::LiquidCrystalRus(uint8_t rs, uint8_t enable,
|
||||
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3)
|
||||
{
|
||||
init(1, rs, 255, enable, d0, d1, d2, d3, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
void LiquidCrystalRus::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable,
|
||||
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
|
||||
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7)
|
||||
{
|
||||
_rs_pin = rs;
|
||||
_rw_pin = rw;
|
||||
_enable_pin = enable;
|
||||
|
||||
_data_pins[0] = d0;
|
||||
_data_pins[1] = d1;
|
||||
_data_pins[2] = d2;
|
||||
_data_pins[3] = d3;
|
||||
_data_pins[4] = d4;
|
||||
_data_pins[5] = d5;
|
||||
_data_pins[6] = d6;
|
||||
_data_pins[7] = d7;
|
||||
|
||||
pinMode(_rs_pin, OUTPUT);
|
||||
// we can save 1 pin by not using RW. Indicate by passing 255 instead of pin#
|
||||
if (_rw_pin != 255) {
|
||||
pinMode(_rw_pin, OUTPUT);
|
||||
}
|
||||
pinMode(_enable_pin, OUTPUT);
|
||||
|
||||
if (fourbitmode)
|
||||
_displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS;
|
||||
else
|
||||
_displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS;
|
||||
|
||||
begin(16, 1);
|
||||
}
|
||||
|
||||
void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
|
||||
if (lines > 1) {
|
||||
_displayfunction |= LCD_2LINE;
|
||||
}
|
||||
_numlines = lines;
|
||||
_currline = 0;
|
||||
|
||||
// for some 1 line displays you can select a 10 pixel high font
|
||||
if ((dotsize != 0) && (lines == 1)) {
|
||||
_displayfunction |= LCD_5x10DOTS;
|
||||
}
|
||||
|
||||
// SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!
|
||||
// according to datasheet, we need at least 40ms after power rises above 2.7V
|
||||
// before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50
|
||||
delayMicroseconds(50000);
|
||||
// Now we pull both RS and R/W low to begin commands
|
||||
digitalWrite(_rs_pin, LOW);
|
||||
digitalWrite(_enable_pin, LOW);
|
||||
if (_rw_pin != 255) {
|
||||
digitalWrite(_rw_pin, LOW);
|
||||
}
|
||||
|
||||
//put the LCD into 4 bit or 8 bit mode
|
||||
if (! (_displayfunction & LCD_8BITMODE)) {
|
||||
// this is according to the hitachi HD44780 datasheet
|
||||
// figure 24, pg 46
|
||||
|
||||
// we start in 8bit mode, try to set 4 bit mode
|
||||
writeNbits(0x03,4);
|
||||
delayMicroseconds(4500); // wait min 4.1ms
|
||||
|
||||
// second try
|
||||
writeNbits(0x03,4);
|
||||
delayMicroseconds(4500); // wait min 4.1ms
|
||||
|
||||
// third go!
|
||||
writeNbits(0x03,4);
|
||||
delayMicroseconds(150);
|
||||
|
||||
// finally, set to 8-bit interface
|
||||
writeNbits(0x02,4);
|
||||
} else {
|
||||
// this is according to the hitachi HD44780 datasheet
|
||||
// page 45 figure 23
|
||||
|
||||
// Send function set command sequence
|
||||
command(LCD_FUNCTIONSET | _displayfunction);
|
||||
delayMicroseconds(4500); // wait more than 4.1ms
|
||||
|
||||
// second try
|
||||
command(LCD_FUNCTIONSET | _displayfunction);
|
||||
delayMicroseconds(150);
|
||||
|
||||
// third go
|
||||
command(LCD_FUNCTIONSET | _displayfunction);
|
||||
}
|
||||
|
||||
// finally, set # lines, font size, etc.
|
||||
command(LCD_FUNCTIONSET | _displayfunction);
|
||||
|
||||
// turn the display on with no cursor or blinking default
|
||||
_displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;
|
||||
display();
|
||||
|
||||
// clear it off
|
||||
clear();
|
||||
|
||||
// Initialize to default text direction (for romance languages)
|
||||
_displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;
|
||||
// set the entry mode
|
||||
command(LCD_ENTRYMODESET | _displaymode);
|
||||
|
||||
}
|
||||
|
||||
void LiquidCrystalRus::setDRAMModel(uint8_t model) {
|
||||
_dram_model = model;
|
||||
}
|
||||
|
||||
/********** high level commands, for the user! */
|
||||
void LiquidCrystalRus::clear()
|
||||
{
|
||||
command(LCD_CLEARDISPLAY); // clear display, set cursor position to zero
|
||||
delayMicroseconds(2000); // this command takes a long time!
|
||||
}
|
||||
|
||||
void LiquidCrystalRus::home()
|
||||
{
|
||||
command(LCD_RETURNHOME); // set cursor position to zero
|
||||
delayMicroseconds(2000); // this command takes a long time!
|
||||
}
|
||||
|
||||
void LiquidCrystalRus::setCursor(uint8_t col, uint8_t row)
|
||||
{
|
||||
int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };
|
||||
if ( row >= _numlines ) {
|
||||
row = _numlines-1; // we count rows starting w/0
|
||||
}
|
||||
|
||||
command(LCD_SETDDRAMADDR | (col + row_offsets[row]));
|
||||
}
|
||||
|
||||
// Turn the display on/off (quickly)
|
||||
void LiquidCrystalRus::noDisplay() {
|
||||
_displaycontrol &= ~LCD_DISPLAYON;
|
||||
command(LCD_DISPLAYCONTROL | _displaycontrol);
|
||||
}
|
||||
void LiquidCrystalRus::display() {
|
||||
_displaycontrol |= LCD_DISPLAYON;
|
||||
command(LCD_DISPLAYCONTROL | _displaycontrol);
|
||||
}
|
||||
|
||||
// Turns the underline cursor on/off
|
||||
void LiquidCrystalRus::noCursor() {
|
||||
_displaycontrol &= ~LCD_CURSORON;
|
||||
command(LCD_DISPLAYCONTROL | _displaycontrol);
|
||||
}
|
||||
void LiquidCrystalRus::cursor() {
|
||||
_displaycontrol |= LCD_CURSORON;
|
||||
command(LCD_DISPLAYCONTROL | _displaycontrol);
|
||||
}
|
||||
|
||||
// Turn on and off the blinking cursor
|
||||
void LiquidCrystalRus::noBlink() {
|
||||
_displaycontrol &= ~LCD_BLINKON;
|
||||
command(LCD_DISPLAYCONTROL | _displaycontrol);
|
||||
}
|
||||
void LiquidCrystalRus::blink() {
|
||||
_displaycontrol |= LCD_BLINKON;
|
||||
command(LCD_DISPLAYCONTROL | _displaycontrol);
|
||||
}
|
||||
|
||||
// These commands scroll the display without changing the RAM
|
||||
void LiquidCrystalRus::scrollDisplayLeft(void) {
|
||||
command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT);
|
||||
}
|
||||
void LiquidCrystalRus::scrollDisplayRight(void) {
|
||||
command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT);
|
||||
}
|
||||
|
||||
// This is for text that flows Left to Right
|
||||
void LiquidCrystalRus::leftToRight(void) {
|
||||
_displaymode |= LCD_ENTRYLEFT;
|
||||
command(LCD_ENTRYMODESET | _displaymode);
|
||||
}
|
||||
|
||||
// This is for text that flows Right to Left
|
||||
void LiquidCrystalRus::rightToLeft(void) {
|
||||
_displaymode &= ~LCD_ENTRYLEFT;
|
||||
command(LCD_ENTRYMODESET | _displaymode);
|
||||
}
|
||||
|
||||
// This will 'right justify' text from the cursor
|
||||
void LiquidCrystalRus::autoscroll(void) {
|
||||
_displaymode |= LCD_ENTRYSHIFTINCREMENT;
|
||||
command(LCD_ENTRYMODESET | _displaymode);
|
||||
}
|
||||
|
||||
// This will 'left justify' text from the cursor
|
||||
void LiquidCrystalRus::noAutoscroll(void) {
|
||||
_displaymode &= ~LCD_ENTRYSHIFTINCREMENT;
|
||||
command(LCD_ENTRYMODESET | _displaymode);
|
||||
}
|
||||
|
||||
// Allows us to fill the first 8 CGRAM locations
|
||||
// with custom characters
|
||||
void LiquidCrystalRus::createChar(uint8_t location, uint8_t charmap[]) {
|
||||
location &= 0x7; // we only have 8 locations 0-7
|
||||
command(LCD_SETCGRAMADDR | (location << 3));
|
||||
for (int i=0; i<8; i++) {
|
||||
write(charmap[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/*********** mid level commands, for sending data/cmds */
|
||||
|
||||
inline void LiquidCrystalRus::command(uint8_t value) {
|
||||
send(value, LOW);
|
||||
}
|
||||
|
||||
#if defined(ARDUINO) && ARDUINO >= 100
|
||||
size_t LiquidCrystalRus::write(uint8_t value)
|
||||
#else
|
||||
void LiquidCrystalRus::write(uint8_t value)
|
||||
#endif
|
||||
{
|
||||
uint8_t out_char=value;
|
||||
|
||||
if (_dram_model == LCD_DRAM_WH1601) {
|
||||
uint8_t ac=recv(LOW) & 0x7f;
|
||||
if (ac>7 && ac<0x14) command(LCD_SETDDRAMADDR | (0x40+ac-8));
|
||||
}
|
||||
|
||||
if (value>=0x80) { // UTF-8 handling
|
||||
if (value >= 0xc0) {
|
||||
utf_hi_char = value - 0xd0;
|
||||
} else {
|
||||
value &= 0x3f;
|
||||
if (!utf_hi_char && (value == 1))
|
||||
send(0xa2,HIGH); // ╗
|
||||
else if ((utf_hi_char == 1) && (value == 0x11))
|
||||
send(0xb5,HIGH); // ╦
|
||||
else
|
||||
send(pgm_read_byte_near(utf_recode + value + (utf_hi_char<<6) - 0x10), HIGH);
|
||||
}
|
||||
} else send(out_char, HIGH);
|
||||
#if defined(ARDUINO) && ARDUINO >= 100
|
||||
return 1; // assume sucess
|
||||
#endif
|
||||
}
|
||||
|
||||
/************ low level data pushing commands **********/
|
||||
|
||||
// write either command or data, with automatic 4/8-bit selection
|
||||
void LiquidCrystalRus::send(uint8_t value, uint8_t mode) {
|
||||
digitalWrite(_rs_pin, mode);
|
||||
|
||||
// if there is a RW pin indicated, set it low to Write
|
||||
if (_rw_pin != 255) {
|
||||
digitalWrite(_rw_pin, LOW);
|
||||
}
|
||||
|
||||
if (_displayfunction & LCD_8BITMODE) {
|
||||
writeNbits(value,8);
|
||||
} else {
|
||||
writeNbits(value>>4,4);
|
||||
writeNbits(value,4);
|
||||
}
|
||||
}
|
||||
|
||||
// read data, with automatic 4/8-bit selection
|
||||
uint8_t LiquidCrystalRus::recv(uint8_t mode) {
|
||||
uint8_t retval;
|
||||
digitalWrite(_rs_pin, mode);
|
||||
|
||||
// if there is a RW pin indicated, set it low to Write
|
||||
if (_rw_pin != 255) {
|
||||
digitalWrite(_rw_pin, HIGH);
|
||||
}
|
||||
|
||||
if (_displayfunction & LCD_8BITMODE) {
|
||||
retval = readNbits(8);
|
||||
} else {
|
||||
retval = readNbits(4) << 4;
|
||||
retval |= readNbits(4);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
void LiquidCrystalRus::pulseEnable() {
|
||||
digitalWrite(_enable_pin, LOW);
|
||||
delayMicroseconds(1);
|
||||
digitalWrite(_enable_pin, HIGH);
|
||||
delayMicroseconds(1); // enable pulse must be >450ns
|
||||
digitalWrite(_enable_pin, LOW);
|
||||
delayMicroseconds(100); // commands need > 37us to settle
|
||||
}
|
||||
|
||||
void LiquidCrystalRus::writeNbits(uint8_t value, uint8_t n) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
pinMode(_data_pins[i], OUTPUT);
|
||||
digitalWrite(_data_pins[i], (value >> i) & 0x01);
|
||||
}
|
||||
|
||||
pulseEnable();
|
||||
}
|
||||
|
||||
uint8_t LiquidCrystalRus::readNbits(uint8_t n) {
|
||||
uint8_t retval=0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
pinMode(_data_pins[i], INPUT);
|
||||
}
|
||||
|
||||
digitalWrite(_enable_pin, LOW);
|
||||
delayMicroseconds(1);
|
||||
digitalWrite(_enable_pin, HIGH);
|
||||
delayMicroseconds(1); // enable pulse must be >450ns
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
retval |= (digitalRead(_data_pins[i]) == HIGH)?(1 << i):0;
|
||||
}
|
||||
|
||||
digitalWrite(_enable_pin, LOW);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
//
|
||||
// based on LiquidCrystal library from ArduinoIDE, see http://arduino.cc
|
||||
// modified 27 Jul 2011
|
||||
// by Ilya V. Danilov http://mk90.ru/
|
||||
//
|
||||
|
||||
#ifndef LiquidCrystalRus_h
|
||||
#define LiquidCrystalRus_h
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "Print.h"
|
||||
|
||||
// commands
|
||||
#define LCD_CLEARDISPLAY 0x01
|
||||
#define LCD_RETURNHOME 0x02
|
||||
#define LCD_ENTRYMODESET 0x04
|
||||
#define LCD_DISPLAYCONTROL 0x08
|
||||
#define LCD_CURSORSHIFT 0x10
|
||||
#define LCD_FUNCTIONSET 0x20
|
||||
#define LCD_SETCGRAMADDR 0x40
|
||||
#define LCD_SETDDRAMADDR 0x80
|
||||
|
||||
// flags for display entry mode
|
||||
#define LCD_ENTRYRIGHT 0x00
|
||||
#define LCD_ENTRYLEFT 0x02
|
||||
#define LCD_ENTRYSHIFTINCREMENT 0x01
|
||||
#define LCD_ENTRYSHIFTDECREMENT 0x00
|
||||
|
||||
// flags for display on/off control
|
||||
#define LCD_DISPLAYON 0x04
|
||||
#define LCD_DISPLAYOFF 0x00
|
||||
#define LCD_CURSORON 0x02
|
||||
#define LCD_CURSOROFF 0x00
|
||||
#define LCD_BLINKON 0x01
|
||||
#define LCD_BLINKOFF 0x00
|
||||
|
||||
// flags for display/cursor shift
|
||||
#define LCD_DISPLAYMOVE 0x08
|
||||
#define LCD_CURSORMOVE 0x00
|
||||
#define LCD_MOVERIGHT 0x04
|
||||
#define LCD_MOVELEFT 0x00
|
||||
|
||||
// flags for function set
|
||||
#define LCD_8BITMODE 0x10
|
||||
#define LCD_4BITMODE 0x00
|
||||
#define LCD_2LINE 0x08
|
||||
#define LCD_1LINE 0x00
|
||||
#define LCD_5x10DOTS 0x04
|
||||
#define LCD_5x8DOTS 0x00
|
||||
|
||||
// enum for
|
||||
#define LCD_DRAM_Normal 0x00
|
||||
#define LCD_DRAM_WH1601 0x01
|
||||
|
||||
|
||||
class LiquidCrystalRus : public Print {
|
||||
public:
|
||||
LiquidCrystalRus(uint8_t rs, uint8_t enable,
|
||||
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
|
||||
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
|
||||
LiquidCrystalRus(uint8_t rs, uint8_t rw, uint8_t enable,
|
||||
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
|
||||
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
|
||||
LiquidCrystalRus(uint8_t rs, uint8_t rw, uint8_t enable,
|
||||
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3);
|
||||
LiquidCrystalRus(uint8_t rs, uint8_t enable,
|
||||
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3);
|
||||
|
||||
void init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable,
|
||||
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
|
||||
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
|
||||
|
||||
void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);
|
||||
|
||||
void clear();
|
||||
void home();
|
||||
|
||||
void noDisplay();
|
||||
void display();
|
||||
void noBlink();
|
||||
void blink();
|
||||
void noCursor();
|
||||
void cursor();
|
||||
void scrollDisplayLeft();
|
||||
void scrollDisplayRight();
|
||||
void leftToRight();
|
||||
void rightToLeft();
|
||||
void autoscroll();
|
||||
void noAutoscroll();
|
||||
|
||||
void createChar(uint8_t, uint8_t[]);
|
||||
void setCursor(uint8_t, uint8_t);
|
||||
|
||||
#if defined(ARDUINO) && ARDUINO >= 100
|
||||
virtual size_t write(uint8_t);
|
||||
using Print::write;
|
||||
#else
|
||||
virtual void write(uint8_t);
|
||||
#endif
|
||||
|
||||
void command(uint8_t);
|
||||
|
||||
void setDRAMModel(uint8_t);
|
||||
|
||||
private:
|
||||
void send(uint8_t, uint8_t);
|
||||
void writeNbits(uint8_t, uint8_t);
|
||||
uint8_t recv(uint8_t);
|
||||
uint8_t readNbits(uint8_t);
|
||||
void pulseEnable();
|
||||
|
||||
uint8_t _rs_pin; // LOW: command. HIGH: character.
|
||||
uint8_t _rw_pin; // LOW: write to LCD. HIGH: read from LCD.
|
||||
uint8_t _enable_pin; // activated by a HIGH pulse.
|
||||
uint8_t _data_pins[8];
|
||||
|
||||
uint8_t _displayfunction;
|
||||
uint8_t _displaycontrol;
|
||||
uint8_t _displaymode;
|
||||
|
||||
uint8_t _initialized;
|
||||
|
||||
uint8_t _numlines,_currline;
|
||||
|
||||
uint8_t _dram_model;
|
||||
uint8_t utf_hi_char; // UTF-8 high part
|
||||
};
|
||||
|
||||
#endif
|
||||
+111
-63
@@ -35,14 +35,31 @@
|
||||
# $Id$
|
||||
|
||||
#For "old" Arduino Mega
|
||||
MCU = atmega1280
|
||||
#MCU = atmega1280
|
||||
#For Arduino Mega2560
|
||||
#MCU = atmega2560
|
||||
#For Sanguinololu
|
||||
#MCU = atmega644p
|
||||
MCU = atmega644p
|
||||
|
||||
#Arduino install directory
|
||||
INSTALL_DIR = ../../arduino-0022/
|
||||
# Here you select "arduino", "Sanguino", "Gen7", ...
|
||||
HARDWARE_VARIANT = Sanguino
|
||||
# This defined the board you are compiling for
|
||||
HARDWARE_MOTHERBOARD = 91
|
||||
|
||||
# Arduino source install directory
|
||||
INSTALL_DIR = ../../arduino-0022
|
||||
|
||||
# Arduino containd the main source code for the Arduino
|
||||
# Libraries, the "hardware variant" are for boards
|
||||
# that derives from that, and their source are present in
|
||||
# the main Marlin source directory
|
||||
ARDUINO = $(INSTALL_DIR)/hardware/arduino/cores/arduino
|
||||
|
||||
ifeq (${HARDWARE_VARIANT}, arduino)
|
||||
HARDWARE_SRC= $(ARDUINO)
|
||||
else
|
||||
HARDWARE_SRC= $(HARDWARE_VARIANT)/cores/arduino
|
||||
endif
|
||||
|
||||
# Be sure to regenerate speed_lookuptable.h with create_speed_lookuptable.py
|
||||
# if you are setting this to something other than 16MHz
|
||||
@@ -54,21 +71,32 @@ PORT = /dev/arduino
|
||||
|
||||
TARGET = $(notdir $(CURDIR))
|
||||
|
||||
# VPATH tells make to look into these directory for source files,
|
||||
# there is no need to specify explicit pathnames as long as the
|
||||
# directory is added here
|
||||
|
||||
VPATH = .
|
||||
VPATH += applet
|
||||
VPATH += $(HARDWARE_SRC)
|
||||
VPATH += $(ARDUINO)
|
||||
VPATH += $(INSTALL_DIR)/libraries/LiquidCrystal
|
||||
|
||||
############################################################################
|
||||
# Below here nothing should be changed...
|
||||
|
||||
ARDUINO = $(INSTALL_DIR)/hardware/arduino/cores/arduino
|
||||
AVR_TOOLS_PATH =
|
||||
SRC = $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \
|
||||
$(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \
|
||||
$(ARDUINO)/wiring_pulse.c \
|
||||
$(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c
|
||||
CXXSRC = $(ARDUINO)/WMath.cpp $(ARDUINO)/WString.cpp\
|
||||
$(ARDUINO)/Print.cpp applet/Marlin.cpp MarlinSerial.cpp Sd2Card.cpp SdBaseFile.cpp SdFatUtil.cpp SdFile.cpp SdVolume.cpp motion_control.cpp planner.cpp stepper.cpp temperature.cpp cardreader.cpp
|
||||
SRC = pins_arduino.c wiring.c \
|
||||
wiring_analog.c wiring_digital.c \
|
||||
wiring_pulse.c \
|
||||
wiring_shift.c WInterrupts.c
|
||||
CXXSRC = WMath.cpp WString.cpp Print.cpp \
|
||||
Marlin.cpp MarlinSerial.cpp Sd2Card.cpp SdBaseFile.cpp \
|
||||
SdFatUtil.cpp SdFile.cpp SdVolume.cpp motion_control.cpp \
|
||||
planner.cpp stepper.cpp temperature.cpp cardreader.cpp
|
||||
#CXXSRC += LiquidCrystal.cpp ultralcd.cpp
|
||||
#CXXSRC += ultralcd.cpp
|
||||
FORMAT = ihex
|
||||
|
||||
|
||||
# Name of this Makefile (used for "make depend").
|
||||
MAKEFILE = Makefile
|
||||
|
||||
@@ -83,9 +111,9 @@ OPT = s
|
||||
CDEFS = -DF_CPU=$(F_CPU)
|
||||
CXXDEFS = -DF_CPU=$(F_CPU)
|
||||
|
||||
# Place -I options here
|
||||
CINCS = -I$(ARDUINO)
|
||||
CXXINCS = -I$(ARDUINO)
|
||||
# Add all the source directories as include directories too
|
||||
CINCS = ${addprefix -I ,${VPATH}}
|
||||
CXXINCS = ${addprefix -I ,${VPATH}}
|
||||
|
||||
# Compiler flag to set the C Standard level.
|
||||
# c89 - "ANSI" C
|
||||
@@ -95,7 +123,12 @@ CXXINCS = -I$(ARDUINO)
|
||||
#CSTANDARD = -std=gnu99
|
||||
CDEBUG = -g$(DEBUG)
|
||||
CWARN = -Wall -Wstrict-prototypes
|
||||
CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -w -ffunction-sections -fdata-sections -DARDUINO=22
|
||||
CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct \
|
||||
-fshort-enums -w -ffunction-sections -fdata-sections \
|
||||
-DARDUINO=22
|
||||
ifneq (${HARDWARE_MOTHERBOARD},)
|
||||
CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD}
|
||||
endif
|
||||
#CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
|
||||
|
||||
CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING)
|
||||
@@ -124,7 +157,9 @@ REMOVE = rm -f
|
||||
MV = mv -f
|
||||
|
||||
# Define all object files.
|
||||
OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o)
|
||||
OBJ = ${patsubst %.c, applet/%.o, ${SRC}}
|
||||
OBJ += ${patsubst %.cpp, applet/%.o, ${CXXSRC}}
|
||||
OBJ += ${patsubst %.S, applet/%.o, ${ASRC}}
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst)
|
||||
@@ -132,30 +167,40 @@ LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst)
|
||||
# Combine all necessary flags and optional flags.
|
||||
# Add target processor to flags.
|
||||
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
|
||||
ALL_CXXFLAGS = -mmcu=$(MCU) -I. $(CXXFLAGS)
|
||||
ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
|
||||
ALL_CXXFLAGS = -mmcu=$(MCU) $(CXXFLAGS)
|
||||
ALL_ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp $(ASFLAGS)
|
||||
|
||||
# set V=1 (eg, "make V=1") to print the full commands etc.
|
||||
ifneq ($V,1)
|
||||
Pecho=@echo
|
||||
P=@
|
||||
else
|
||||
Pecho=@:
|
||||
P=
|
||||
endif
|
||||
|
||||
# Default target.
|
||||
all: build sizeafter
|
||||
all: sizeafter
|
||||
|
||||
build: elf hex
|
||||
build: applet elf hex
|
||||
|
||||
applet/$(TARGET).cpp: $(TARGET).pde $(MAKEFILE)
|
||||
# Creates the object directory
|
||||
applet:
|
||||
$P mkdir -p applet
|
||||
|
||||
applet/%.cpp: %.pde
|
||||
# the .cpp for Marlin depends on the .pde
|
||||
#applet/$(TARGET).cpp: $(TARGET).pde
|
||||
# ..and the .o depends from the .cpp
|
||||
#applet/%.o: applet/%.cpp
|
||||
|
||||
applet/%.cpp: %.pde $(MAKEFILE)
|
||||
# Here is the "preprocessing".
|
||||
# It creates a .cpp file based with the same name as the .pde file.
|
||||
# On top of the new .cpp file comes the WProgram.h header.
|
||||
# At the end there is a generic main() function attached.
|
||||
# Then the .cpp file will be compiled. Errors during compile will
|
||||
# refer to this new, automatically generated, file.
|
||||
# Not the original .pde file you actually edit...
|
||||
@echo " WR $@"
|
||||
@test -d $(dir $@) || mkdir $(dir $@)
|
||||
@echo '#include "WProgram.h"' > $@
|
||||
@cat $< >> $@
|
||||
@cat $(ARDUINO)/main.cpp >> $@
|
||||
$(Pecho) " WR $@"
|
||||
$P echo '#include "WProgram.h"' > $@
|
||||
$P echo '#include "$<"' >>$@
|
||||
$P echo '#include "$(ARDUINO)/main.cpp"' >> $@
|
||||
|
||||
elf: applet/$(TARGET).elf
|
||||
hex: applet/$(TARGET).hex
|
||||
@@ -164,20 +209,25 @@ lss: applet/$(TARGET).lss
|
||||
sym: applet/$(TARGET).sym
|
||||
|
||||
# Program the device.
|
||||
# Do not try to reset an arduino if it's not one
|
||||
upload: applet/$(TARGET).hex
|
||||
ifeq (${AVRDUDE_PROGRAMMER}, arduino)
|
||||
stty hup < $(PORT); true
|
||||
endif
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
|
||||
ifeq (${AVRDUDE_PROGRAMMER}, arduino)
|
||||
stty -hup < $(PORT); true
|
||||
|
||||
endif
|
||||
|
||||
# Display size of file.
|
||||
HEXSIZE = $(SIZE) --target=$(FORMAT) applet/$(TARGET).hex
|
||||
ELFSIZE = $(SIZE) applet/$(TARGET).elf
|
||||
ELFSIZE = $(SIZE) --mcu=$(MCU) -C applet/$(TARGET).elf; \
|
||||
$(SIZE) applet/$(TARGET).elf
|
||||
sizebefore:
|
||||
@if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
|
||||
$P if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
|
||||
|
||||
sizeafter:
|
||||
@if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
|
||||
sizeafter: build
|
||||
$P if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
|
||||
|
||||
|
||||
# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
|
||||
@@ -200,8 +250,8 @@ extcoff: $(TARGET).elf
|
||||
.PRECIOUS: .o
|
||||
|
||||
.elf.hex:
|
||||
@echo " COPY $@"
|
||||
@$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
|
||||
$(Pecho) " COPY $@"
|
||||
$P $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
|
||||
|
||||
.elf.eep:
|
||||
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
||||
@@ -217,38 +267,36 @@ extcoff: $(TARGET).elf
|
||||
|
||||
# Link: create ELF output file from library.
|
||||
applet/$(TARGET).elf: applet/$(TARGET).cpp applet/core.a Configuration.h
|
||||
@echo " CXX $@"
|
||||
@$(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS)
|
||||
$(Pecho) " CXX $@"
|
||||
$P $(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS)
|
||||
|
||||
applet/core.a: $(OBJ) Configuration.h
|
||||
@for i in $(OBJ); do echo " AR $$i"; $(AR) rcs applet/core.a $$i; done
|
||||
applet/core.a: $(OBJ)
|
||||
$P for i in $(OBJ); do echo " AR $$i"; $(AR) rcs applet/core.a $$i; done
|
||||
|
||||
%.o: %.c Configuration.h $(MAKEFILE)
|
||||
@echo " CC $@"
|
||||
@$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
applet/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE)
|
||||
$(Pecho) " CC $@"
|
||||
$P $(CC) -MMD -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
applet/%.o: applet/%.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
|
||||
$(Pecho) " CXX $@"
|
||||
$P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@
|
||||
|
||||
applet/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
|
||||
$(Pecho) " CXX $@"
|
||||
$P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@
|
||||
|
||||
%.o: %.cpp Configuration.h $(MAKEFILE)
|
||||
@echo " CXX $@"
|
||||
@$(CXX) -c $(ALL_CXXFLAGS) $< -o $@
|
||||
|
||||
# Target: clean project.
|
||||
clean:
|
||||
@echo " RM applet/*"
|
||||
@$(REMOVE) applet/$(TARGET).hex applet/$(TARGET).eep applet/$(TARGET).cof applet/$(TARGET).elf \
|
||||
$(Pecho) " RM applet/*"
|
||||
$P $(REMOVE) applet/$(TARGET).hex applet/$(TARGET).eep applet/$(TARGET).cof applet/$(TARGET).elf \
|
||||
applet/$(TARGET).map applet/$(TARGET).sym applet/$(TARGET).lss applet/$(TARGET).cpp applet/core.a \
|
||||
$(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
|
||||
@echo " RMDIR applet/"
|
||||
@rmdir applet
|
||||
$(Pecho) " RMDIR applet/"
|
||||
$P rm -rf applet
|
||||
|
||||
depend:
|
||||
if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \
|
||||
then \
|
||||
sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \
|
||||
$(MAKEFILE).$$$$ && \
|
||||
$(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \
|
||||
fi
|
||||
echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \
|
||||
>> $(MAKEFILE); \
|
||||
$(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE)
|
||||
|
||||
.PHONY: all build elf hex eep lss sym program coff extcoff clean depend applet_files sizebefore sizeafter
|
||||
|
||||
# Automaticaly include the dependency files created by gcc
|
||||
-include ${wildcard applet/*.d}
|
||||
|
||||
+26
-36
@@ -17,8 +17,7 @@
|
||||
#include <util/delay.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/eeprom.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
|
||||
#include "fastio.h"
|
||||
@@ -26,7 +25,7 @@
|
||||
#include "pins.h"
|
||||
|
||||
#if ARDUINO >= 100
|
||||
#if defined(__AVR_ATmega644P__) || defined (__AVR_ATmega1284P__)
|
||||
#if defined(__AVR_ATmega644P__)
|
||||
#include "WProgram.h"
|
||||
#else
|
||||
#include "Arduino.h"
|
||||
@@ -52,22 +51,11 @@
|
||||
#define MYSERIAL MSerial
|
||||
#endif
|
||||
|
||||
//this is a unfinsihed attemp to removes a lot of warning messages, see:
|
||||
// http://www.avrfreaks.net/index.php?name=PNphpBB2&file=printview&t=57011
|
||||
//typedef char prog_char PROGMEM;
|
||||
// //#define PSTR (s ) ((const PROGMEM char *)(s))
|
||||
// //# define MYPGM(s) (__extension__({static prog_char __c[] = (s); &__c[0];}))
|
||||
// //#define MYPGM(s) ((const prog_char *g PROGMEM=s))
|
||||
#define MYPGM(s) PSTR(s)
|
||||
//#define MYPGM(s) (__extension__({static char __c[] __attribute__((__progmem__)) = (s); &__c[0];})) //This is the normal behaviour
|
||||
//#define MYPGM(s) (__extension__({static prog_char __c[] = (s); &__c[0];})) //this does not work but hides the warnings
|
||||
|
||||
|
||||
#define SERIAL_PROTOCOL(x) MYSERIAL.print(x);
|
||||
#define SERIAL_PROTOCOL_F(x,y) MYSERIAL.print(x,y);
|
||||
#define SERIAL_PROTOCOLPGM(x) serialprintPGM(MYPGM(x));
|
||||
#define SERIAL_PROTOCOLPGM(x) serialprintPGM(PSTR(x));
|
||||
#define SERIAL_PROTOCOLLN(x) {MYSERIAL.print(x);MYSERIAL.write('\n');}
|
||||
#define SERIAL_PROTOCOLLNPGM(x) {serialprintPGM(MYPGM(x));MYSERIAL.write('\n');}
|
||||
#define SERIAL_PROTOCOLLNPGM(x) {serialprintPGM(PSTR(x));MYSERIAL.write('\n');}
|
||||
|
||||
|
||||
const char errormagic[] PROGMEM ="Error:";
|
||||
@@ -84,11 +72,14 @@ const char echomagic[] PROGMEM ="echo:";
|
||||
#define SERIAL_ECHOLN(x) SERIAL_PROTOCOLLN(x)
|
||||
#define SERIAL_ECHOLNPGM(x) SERIAL_PROTOCOLLNPGM(x)
|
||||
|
||||
#define SERIAL_ECHOPAIR(name,value) {SERIAL_ECHOPGM(name);SERIAL_ECHO(value);}
|
||||
#define SERIAL_ECHOPAIR(name,value) (serial_echopair_P(PSTR(name),(value)))
|
||||
|
||||
void serial_echopair_P(const char *s_P, float v);
|
||||
void serial_echopair_P(const char *s_P, double v);
|
||||
void serial_echopair_P(const char *s_P, unsigned long v);
|
||||
|
||||
|
||||
//things to write to serial from Programmemory. saves 400 to 2k of RAM.
|
||||
#define SerialprintPGM(x) serialprintPGM(MYPGM(x))
|
||||
FORCE_INLINE void serialprintPGM(const char *str)
|
||||
{
|
||||
char ch=pgm_read_byte(str);
|
||||
@@ -99,18 +90,11 @@ FORCE_INLINE void serialprintPGM(const char *str)
|
||||
}
|
||||
}
|
||||
|
||||
// printing floats to 3DP
|
||||
FORCE_INLINE void serialPrintFloat( float f){
|
||||
SERIAL_ECHO((int)f);
|
||||
SERIAL_ECHOPGM(".");
|
||||
int mantissa = (f - (int)f) * 1000;
|
||||
SERIAL_ECHO( abs(mantissa) );
|
||||
}
|
||||
|
||||
void get_command();
|
||||
void process_commands();
|
||||
|
||||
void manage_inactivity(byte debug);
|
||||
void manage_inactivity();
|
||||
|
||||
#if X_ENABLE_PIN > -1
|
||||
#define enable_x() WRITE(X_ENABLE_PIN, X_ENABLE_ON)
|
||||
@@ -129,8 +113,13 @@ void manage_inactivity(byte debug);
|
||||
#endif
|
||||
|
||||
#if Z_ENABLE_PIN > -1
|
||||
#define enable_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON)
|
||||
#define disable_z() WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON)
|
||||
#ifdef Z_DUAL_STEPPER_DRIVERS
|
||||
#define enable_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); }
|
||||
#define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN,!Z_ENABLE_ON); }
|
||||
#else
|
||||
#define enable_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON)
|
||||
#define disable_z() WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON)
|
||||
#endif
|
||||
#else
|
||||
#define enable_z() ;
|
||||
#define disable_z() ;
|
||||
@@ -176,6 +165,11 @@ bool IsStopped();
|
||||
|
||||
void enquecommand(const char *cmd); //put an ascii command at the end of the current buffer.
|
||||
void prepare_arc_move(char isclockwise);
|
||||
void clamp_to_software_endstops(float target[3]);
|
||||
|
||||
#ifdef FAST_PWM_FAN
|
||||
void setPwmFrequency(uint8_t pin, int val);
|
||||
#endif
|
||||
|
||||
#ifndef CRITICAL_SECTION_START
|
||||
#define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli();
|
||||
@@ -183,19 +177,15 @@ void prepare_arc_move(char isclockwise);
|
||||
#endif //CRITICAL_SECTION_START
|
||||
|
||||
extern float homing_feedrate[];
|
||||
extern float fast_home_feedrate[];
|
||||
extern bool axis_relative_modes[];
|
||||
extern volatile int feedmultiply;
|
||||
extern int saved_feedmultiply;
|
||||
extern float current_position[NUM_AXIS] ;
|
||||
extern float add_homeing[3];
|
||||
extern float min_pos[3];
|
||||
extern float max_pos[3];
|
||||
extern unsigned char FanSpeed;
|
||||
|
||||
extern float destination[NUM_AXIS];
|
||||
extern float modified_destination[NUM_AXIS];
|
||||
extern float offset[3];
|
||||
extern float feedrate, next_feedrate, saved_feedrate;
|
||||
|
||||
extern unsigned long starttime;
|
||||
extern unsigned long stoptime;
|
||||
|
||||
// Handling multiple extruders pins
|
||||
extern uint8_t active_extruder;
|
||||
|
||||
+8
-1625
File diff suppressed because it is too large
Load Diff
+18
-24
@@ -28,7 +28,7 @@
|
||||
// this is so I can support Attiny series and any other chip without a uart
|
||||
#if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H)
|
||||
|
||||
#if defined(UBRRH) || defined(UBRR0H)
|
||||
#if UART_PRESENT(SERIAL_PORT)
|
||||
ring_buffer rx_buffer = { { 0 }, 0, 0 };
|
||||
#endif
|
||||
|
||||
@@ -48,18 +48,12 @@ FORCE_INLINE void store_char(unsigned char c)
|
||||
|
||||
|
||||
//#elif defined(SIG_USART_RECV)
|
||||
#if defined(USART0_RX_vect)
|
||||
#if defined(M_USARTx_RX_vect)
|
||||
// fixed by Mark Sproul this is on the 644/644p
|
||||
//SIGNAL(SIG_USART_RECV)
|
||||
SIGNAL(USART0_RX_vect)
|
||||
SIGNAL(M_USARTx_RX_vect)
|
||||
{
|
||||
#if defined(UDR0)
|
||||
unsigned char c = UDR0;
|
||||
#elif defined(UDR)
|
||||
unsigned char c = UDR; // atmega8, atmega32
|
||||
#else
|
||||
#error UDR not defined
|
||||
#endif
|
||||
unsigned char c = M_UDRx;
|
||||
store_char(c);
|
||||
}
|
||||
#endif
|
||||
@@ -76,39 +70,39 @@ MarlinSerial::MarlinSerial()
|
||||
void MarlinSerial::begin(long baud)
|
||||
{
|
||||
uint16_t baud_setting;
|
||||
bool useU2X0 = true;
|
||||
bool useU2X = true;
|
||||
|
||||
#if F_CPU == 16000000UL
|
||||
#if F_CPU == 16000000UL && SERIAL_PORT == 0
|
||||
// hardcoded exception for compatibility with the bootloader shipped
|
||||
// with the Duemilanove and previous boards and the firmware on the 8U2
|
||||
// on the Uno and Mega 2560.
|
||||
if (baud == 57600) {
|
||||
useU2X0 = false;
|
||||
useU2X = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (useU2X0) {
|
||||
UCSR0A = 1 << U2X0;
|
||||
if (useU2X) {
|
||||
M_UCSRxA = 1 << M_U2Xx;
|
||||
baud_setting = (F_CPU / 4 / baud - 1) / 2;
|
||||
} else {
|
||||
UCSR0A = 0;
|
||||
M_UCSRxA = 0;
|
||||
baud_setting = (F_CPU / 8 / baud - 1) / 2;
|
||||
}
|
||||
|
||||
// assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)
|
||||
UBRR0H = baud_setting >> 8;
|
||||
UBRR0L = baud_setting;
|
||||
M_UBRRxH = baud_setting >> 8;
|
||||
M_UBRRxL = baud_setting;
|
||||
|
||||
sbi(UCSR0B, RXEN0);
|
||||
sbi(UCSR0B, TXEN0);
|
||||
sbi(UCSR0B, RXCIE0);
|
||||
sbi(M_UCSRxB, M_RXENx);
|
||||
sbi(M_UCSRxB, M_TXENx);
|
||||
sbi(M_UCSRxB, M_RXCIEx);
|
||||
}
|
||||
|
||||
void MarlinSerial::end()
|
||||
{
|
||||
cbi(UCSR0B, RXEN0);
|
||||
cbi(UCSR0B, TXEN0);
|
||||
cbi(UCSR0B, RXCIE0);
|
||||
cbi(M_UCSRxB, M_RXENx);
|
||||
cbi(M_UCSRxB, M_TXENx);
|
||||
cbi(M_UCSRxB, M_RXCIEx);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+48
-6
@@ -23,6 +23,48 @@
|
||||
#define MarlinSerial_h
|
||||
#include "Marlin.h"
|
||||
|
||||
#if !defined(SERIAL_PORT)
|
||||
#error SERIAL_PORT not set
|
||||
#endif
|
||||
|
||||
// The presence of the UBRRH register is used to detect a UART.
|
||||
#define UART_PRESENT(port) ((port == 0 && (defined(UBRRH) || defined(UBRR0H))) || \
|
||||
(port == 1 && defined(UBRR1H)) || (port == 2 && defined(UBRR2H)) || \
|
||||
(port == 3 && defined(UBRR3H)))
|
||||
|
||||
// These are macros to build serial port register names for the selected SERIAL_PORT (C preprocessor
|
||||
// requires two levels of indirection to expand macro values properly)
|
||||
#define SERIAL_REGNAME(registerbase,number,suffix) SERIAL_REGNAME_INTERNAL(registerbase,number,suffix)
|
||||
#if SERIAL_PORT == 0 && !defined(UBRR0H)
|
||||
#define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##suffix
|
||||
#else
|
||||
#define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##number##suffix
|
||||
#endif
|
||||
|
||||
// Registers used by MarlinSerial class (these are expanded
|
||||
// depending on selected serial port
|
||||
#define M_UCSRxA SERIAL_REGNAME(UCSR,SERIAL_PORT,A) // defines M_UCSRxA to be UCSRxA where x is the serial port number
|
||||
#define M_UCSRxB SERIAL_REGNAME(UCSR,SERIAL_PORT,B)
|
||||
#define M_RXENx SERIAL_REGNAME(RXEN,SERIAL_PORT,)
|
||||
#define M_TXENx SERIAL_REGNAME(TXEN,SERIAL_PORT,)
|
||||
#define M_RXCIEx SERIAL_REGNAME(RXCIE,SERIAL_PORT,)
|
||||
#define M_UDREx SERIAL_REGNAME(UDRE,SERIAL_PORT,)
|
||||
#if SERIAL_PORT == 0 && !defined(UDR0)
|
||||
#if defined(UDR)
|
||||
#define M_UDRx UDR // atmega8, atmega32
|
||||
#else
|
||||
#error UDR not defined
|
||||
#endif
|
||||
#else
|
||||
#define M_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,)
|
||||
#endif
|
||||
#define M_UBRRxH SERIAL_REGNAME(UBRR,SERIAL_PORT,H)
|
||||
#define M_UBRRxL SERIAL_REGNAME(UBRR,SERIAL_PORT,L)
|
||||
#define M_RXCx SERIAL_REGNAME(RXC,SERIAL_PORT,)
|
||||
#define M_USARTx_RX_vect SERIAL_REGNAME(USART,SERIAL_PORT,_RX_vect)
|
||||
#define M_U2Xx SERIAL_REGNAME(U2X,SERIAL_PORT,)
|
||||
|
||||
|
||||
|
||||
#define DEC 10
|
||||
#define HEX 16
|
||||
@@ -46,7 +88,7 @@ struct ring_buffer
|
||||
int tail;
|
||||
};
|
||||
|
||||
#if defined(UBRRH) || defined(UBRR0H)
|
||||
#if UART_PRESENT(SERIAL_PORT)
|
||||
extern ring_buffer rx_buffer;
|
||||
#endif
|
||||
|
||||
@@ -68,17 +110,17 @@ class MarlinSerial //: public Stream
|
||||
|
||||
FORCE_INLINE void write(uint8_t c)
|
||||
{
|
||||
while (!((UCSR0A) & (1 << UDRE0)))
|
||||
while (!((M_UCSRxA) & (1 << M_UDREx)))
|
||||
;
|
||||
|
||||
UDR0 = c;
|
||||
M_UDRx = c;
|
||||
}
|
||||
|
||||
|
||||
FORCE_INLINE void checkRx(void)
|
||||
{
|
||||
if((UCSR0A & (1<<RXC0)) != 0) {
|
||||
unsigned char c = UDR0;
|
||||
if((M_UCSRxA & (1<<M_RXCx)) != 0) {
|
||||
unsigned char c = M_UDRx;
|
||||
int i = (unsigned int)(rx_buffer.head + 1) % RX_BUFFER_SIZE;
|
||||
|
||||
// if we should be storing the received character into the location
|
||||
@@ -147,4 +189,4 @@ class MarlinSerial //: public Stream
|
||||
extern MarlinSerial MSerial;
|
||||
#endif // ! teensylu
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,206 +0,0 @@
|
||||
/*
|
||||
* MatrixMath.cpp Library for MatrixMath
|
||||
*
|
||||
* Created by Charlie Matlack on 12/18/10.
|
||||
* Modified from code by RobH45345 on Arduino Forums, taken from unknown source.
|
||||
* MatrixMath.cpp
|
||||
*/
|
||||
|
||||
#include "Marlin.h"
|
||||
#include "MatrixMath.h"
|
||||
|
||||
#define NR_END 1
|
||||
|
||||
MatrixMath::MatrixMath()
|
||||
{
|
||||
}
|
||||
|
||||
// Matrix Printing Routine
|
||||
// Uses tabs to separate numbers under assumption printed float width won't cause problems
|
||||
void MatrixMath::MatrixPrint(float* A, int m, int n, String label){
|
||||
// A = input matrix (m x n)
|
||||
int i,j;
|
||||
SERIAL_ECHOLN(' ');
|
||||
SERIAL_ECHOLN(label);
|
||||
for (i=0; i<m; i++){
|
||||
for (j=0;j<n;j++){
|
||||
serialPrintFloat(A[n*i+j]);
|
||||
SERIAL_ECHO("\t");
|
||||
}
|
||||
SERIAL_ECHOLN(' ');
|
||||
}
|
||||
}
|
||||
|
||||
void MatrixMath::MatrixCopy(float* A, int n, int m, float* B)
|
||||
{
|
||||
int i, j, k;
|
||||
for (i=0;i<m;i++)
|
||||
for(j=0;j<n;j++)
|
||||
{
|
||||
B[n*i+j] = A[n*i+j];
|
||||
}
|
||||
}
|
||||
|
||||
//Matrix Multiplication Routine
|
||||
// C = A*B
|
||||
void MatrixMath::MatrixMult(float* A, float* B, int m, int p, int n, float* C)
|
||||
{
|
||||
// A = input matrix (m x p)
|
||||
// B = input matrix (p x n)
|
||||
// m = number of rows in A
|
||||
// p = number of columns in A = number of rows in B
|
||||
// n = number of columns in B
|
||||
// C = output matrix = A*B (m x n)
|
||||
int i, j, k;
|
||||
for (i=0;i<m;i++)
|
||||
for(j=0;j<n;j++)
|
||||
{
|
||||
C[n*i+j]=0;
|
||||
for (k=0;k<p;k++)
|
||||
C[n*i+j]= C[n*i+j]+A[p*i+k]*B[n*k+j];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Matrix Addition Routine
|
||||
void MatrixMath::MatrixAdd(float* A, float* B, int m, int n, float* C)
|
||||
{
|
||||
// A = input matrix (m x n)
|
||||
// B = input matrix (m x n)
|
||||
// m = number of rows in A = number of rows in B
|
||||
// n = number of columns in A = number of columns in B
|
||||
// C = output matrix = A+B (m x n)
|
||||
int i, j;
|
||||
for (i=0;i<m;i++)
|
||||
for(j=0;j<n;j++)
|
||||
C[n*i+j]=A[n*i+j]+B[n*i+j];
|
||||
}
|
||||
|
||||
|
||||
//Matrix Subtraction Routine
|
||||
void MatrixMath::MatrixSubtract(float* A, float* B, int m, int n, float* C)
|
||||
{
|
||||
// A = input matrix (m x n)
|
||||
// B = input matrix (m x n)
|
||||
// m = number of rows in A = number of rows in B
|
||||
// n = number of columns in A = number of columns in B
|
||||
// C = output matrix = A-B (m x n)
|
||||
int i, j;
|
||||
for (i=0;i<m;i++)
|
||||
for(j=0;j<n;j++)
|
||||
C[n*i+j]=A[n*i+j]-B[n*i+j];
|
||||
}
|
||||
|
||||
|
||||
//Matrix Transpose Routine
|
||||
void MatrixMath::MatrixTranspose(float* A, int m, int n, float* C)
|
||||
{
|
||||
// A = input matrix (m x n)
|
||||
// m = number of rows in A
|
||||
// n = number of columns in A
|
||||
// C = output matrix = the transpose of A (n x m)
|
||||
int i, j;
|
||||
for (i=0;i<m;i++)
|
||||
for(j=0;j<n;j++)
|
||||
C[m*j+i]=A[n*i+j];
|
||||
}
|
||||
|
||||
|
||||
//Matrix Inversion Routine
|
||||
// * This function inverts a matrix based on the Gauss Jordan method.
|
||||
// * Specifically, it uses partial pivoting to improve numeric stability.
|
||||
// * The algorithm is drawn from those presented in
|
||||
// NUMERICAL RECIPES: The Art of Scientific Computing.
|
||||
// * The function returns 1 on success, 0 on failure.
|
||||
// * NOTE: The argument is ALSO the result matrix, meaning the input matrix is REPLACED
|
||||
int MatrixMath::MatrixInvert(float* A, int n)
|
||||
{
|
||||
// A = input matrix AND result matrix
|
||||
// n = number of rows = number of columns in A (n x n)
|
||||
int pivrow; // keeps track of current pivot row
|
||||
int k,i,j; // k: overall index along diagonal; i: row index; j: col index
|
||||
int pivrows[n]; // keeps track of rows swaps to undo at end
|
||||
float tmp; // used for finding max value and making column swaps
|
||||
|
||||
for (k = 0; k < n; k++)
|
||||
{
|
||||
// find pivot row, the row with biggest entry in current column
|
||||
tmp = 0;
|
||||
for (i = k; i < n; i++)
|
||||
{
|
||||
if (abs(A[i*n+k]) >= tmp) // 'Avoid using other functions inside abs()?'
|
||||
{
|
||||
tmp = abs(A[i*n+k]);
|
||||
pivrow = i;
|
||||
}
|
||||
}
|
||||
|
||||
// check for singular matrix
|
||||
if (A[pivrow*n+k] == 0.0f)
|
||||
{
|
||||
SERIAL_ECHOLNPGM("Inversion failed due to singular matrix");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Execute pivot (row swap) if needed
|
||||
if (pivrow != k)
|
||||
{
|
||||
// swap row k with pivrow
|
||||
for (j = 0; j < n; j++)
|
||||
{
|
||||
tmp = A[k*n+j];
|
||||
A[k*n+j] = A[pivrow*n+j];
|
||||
A[pivrow*n+j] = tmp;
|
||||
}
|
||||
}
|
||||
pivrows[k] = pivrow; // record row swap (even if no swap happened)
|
||||
|
||||
tmp = 1.0f/A[k*n+k]; // invert pivot element
|
||||
A[k*n+k] = 1.0f; // This element of input matrix becomes result matrix
|
||||
|
||||
// Perform row reduction (divide every element by pivot)
|
||||
for (j = 0; j < n; j++)
|
||||
{
|
||||
A[k*n+j] = A[k*n+j]*tmp;
|
||||
}
|
||||
|
||||
// Now eliminate all other entries in this column
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
if (i != k)
|
||||
{
|
||||
tmp = A[i*n+k];
|
||||
A[i*n+k] = 0.0f; // The other place where in matrix becomes result mat
|
||||
for (j = 0; j < n; j++)
|
||||
{
|
||||
A[i*n+j] = A[i*n+j] - A[k*n+j]*tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Done, now need to undo pivot row swaps by doing column swaps in reverse order
|
||||
for (k = n-1; k >= 0; k--)
|
||||
{
|
||||
if (pivrows[k] != k)
|
||||
{
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
tmp = A[i*n+k];
|
||||
A[i*n+k] = A[i*n+pivrows[k]];
|
||||
A[i*n+pivrows[k]] = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void MatrixMath::MatrixIdentity(float* A, int m, int n)
|
||||
{
|
||||
int i, j;
|
||||
for (i=0;i<m;i++)
|
||||
for(j=0;j<n;j++)
|
||||
A[n*i+j]=i==j?1:0;
|
||||
}
|
||||
|
||||
MatrixMath matrixMaths; //instance
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* MatrixMath.h Library for Matrix Math
|
||||
*
|
||||
* Created by Charlie Matlack on 12/18/10.
|
||||
* Modified from code by RobH45345 on Arduino Forums, taken from unknown source.
|
||||
*/
|
||||
|
||||
#ifndef MatrixMath_h
|
||||
#define MatrixMath_h
|
||||
|
||||
#include "Marlin.h"
|
||||
|
||||
class MatrixMath
|
||||
{
|
||||
public:
|
||||
MatrixMath();
|
||||
void MatrixPrint(float* A, int m, int n, String label);
|
||||
void MatrixCopy(float* A, int n, int m, float* B);
|
||||
void MatrixMult(float* A, float* B, int m, int p, int n, float* C);
|
||||
void MatrixAdd(float* A, float* B, int m, int n, float* C);
|
||||
void MatrixSubtract(float* A, float* B, int m, int n, float* C);
|
||||
void MatrixTranspose(float* A, int m, int n, float* C);
|
||||
int MatrixInvert(float* A, int n);
|
||||
void MatrixIdentity(float* A, int m, int n);
|
||||
};
|
||||
|
||||
extern MatrixMath matrixMaths;
|
||||
|
||||
#endif
|
||||
Binary file not shown.
@@ -67,28 +67,28 @@
|
||||
const uint8_t PROGMEM port_to_mode_PGM[] =
|
||||
{
|
||||
NOT_A_PORT,
|
||||
&DDRA,
|
||||
&DDRB,
|
||||
&DDRC,
|
||||
&DDRD,
|
||||
(uint8_t) (uint16_t) &DDRA,
|
||||
(uint8_t) (uint16_t) &DDRB,
|
||||
(uint8_t) (uint16_t) &DDRC,
|
||||
(uint8_t) (uint16_t) &DDRD,
|
||||
};
|
||||
|
||||
const uint8_t PROGMEM port_to_output_PGM[] =
|
||||
{
|
||||
NOT_A_PORT,
|
||||
&PORTA,
|
||||
&PORTB,
|
||||
&PORTC,
|
||||
&PORTD,
|
||||
(uint8_t) (uint16_t) &PORTA,
|
||||
(uint8_t) (uint16_t) &PORTB,
|
||||
(uint8_t) (uint16_t) &PORTC,
|
||||
(uint8_t) (uint16_t) &PORTD,
|
||||
};
|
||||
|
||||
const uint8_t PROGMEM port_to_input_PGM[] =
|
||||
{
|
||||
NOT_A_PORT,
|
||||
&PINA,
|
||||
&PINB,
|
||||
&PINC,
|
||||
&PIND,
|
||||
(uint8_t) (uint16_t) &PINA,
|
||||
(uint8_t) (uint16_t) &PINB,
|
||||
(uint8_t) (uint16_t) &PINC,
|
||||
(uint8_t) (uint16_t) &PIND,
|
||||
};
|
||||
|
||||
const uint8_t PROGMEM digital_pin_to_port_PGM[] =
|
||||
|
||||
@@ -58,8 +58,8 @@ extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
|
||||
#define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) )
|
||||
#define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) )
|
||||
#define analogInPinToBit(P) (P)
|
||||
#define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_byte( port_to_output_PGM + (P))) )
|
||||
#define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_byte( port_to_input_PGM + (P))) )
|
||||
#define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_byte( port_to_mode_PGM + (P))) )
|
||||
#define portOutputRegister(P) ( (volatile uint8_t *)( (uint16_t) pgm_read_byte( port_to_output_PGM + (P))) )
|
||||
#define portInputRegister(P) ( (volatile uint8_t *)( (uint16_t) pgm_read_byte( port_to_input_PGM + (P))) )
|
||||
#define portModeRegister(P) ( (volatile uint8_t *)( (uint16_t) pgm_read_byte( port_to_mode_PGM + (P))) )
|
||||
|
||||
#endif
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include <math.h>
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/delay.h>
|
||||
#include <util/delay.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
+1
-3
@@ -369,7 +369,6 @@ bool Sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin) {
|
||||
*
|
||||
* \param[in] blockNumber Logical block to be read.
|
||||
* \param[out] dst Pointer to the location that will receive the data.
|
||||
|
||||
* \return The value one, true, is returned for success and
|
||||
* the value zero, false, is returned for failure.
|
||||
*/
|
||||
@@ -639,5 +638,4 @@ bool Sd2Card::writeStop() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+37
-3
@@ -867,7 +867,7 @@ bool SdBaseFile::openParent(SdBaseFile* dir) {
|
||||
}
|
||||
// search for parent in '../..'
|
||||
do {
|
||||
if (file.readDir(&entry) != 32) goto fail;
|
||||
if (file.readDir(&entry, NULL) != 32) goto fail;
|
||||
c = entry.firstClusterLow;
|
||||
c |= (uint32_t)entry.firstClusterHigh << 16;
|
||||
} while (c != cluster);
|
||||
@@ -1108,10 +1108,16 @@ int16_t SdBaseFile::read(void* buf, uint16_t nbyte) {
|
||||
* readDir() called before a directory has been opened, this is not
|
||||
* a directory file or an I/O error occurred.
|
||||
*/
|
||||
int8_t SdBaseFile::readDir(dir_t* dir) {
|
||||
int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) {
|
||||
int16_t n;
|
||||
// if not a directory file or miss-positioned return an error
|
||||
if (!isDir() || (0X1F & curPosition_)) return -1;
|
||||
|
||||
//If we have a longFilename buffer, mark it as invalid. If we find a long filename it will be filled automaticly.
|
||||
if (longFilename != NULL)
|
||||
{
|
||||
longFilename[0] = '\0';
|
||||
}
|
||||
|
||||
while (1) {
|
||||
n = read(dir, sizeof(dir_t));
|
||||
@@ -1120,6 +1126,34 @@ int8_t SdBaseFile::readDir(dir_t* dir) {
|
||||
if (dir->name[0] == DIR_NAME_FREE) return 0;
|
||||
// skip empty entries and entry for . and ..
|
||||
if (dir->name[0] == DIR_NAME_DELETED || dir->name[0] == '.') continue;
|
||||
//Fill the long filename if we have a long filename entry,
|
||||
// long filename entries are stored before the actual filename.
|
||||
if (DIR_IS_LONG_NAME(dir) && longFilename != NULL)
|
||||
{
|
||||
vfat_t *VFAT = (vfat_t*)dir;
|
||||
//Sanity check the VFAT entry. The first cluster is always set to zero. And th esequence number should be higher then 0
|
||||
if (VFAT->firstClusterLow == 0 && (VFAT->sequenceNumber & 0x1F) > 0 && (VFAT->sequenceNumber & 0x1F) <= MAX_VFAT_ENTRIES)
|
||||
{
|
||||
//TODO: Store the filename checksum to verify if a none-long filename aware system modified the file table.
|
||||
n = ((VFAT->sequenceNumber & 0x1F) - 1) * 13;
|
||||
longFilename[n+0] = VFAT->name1[0];
|
||||
longFilename[n+1] = VFAT->name1[1];
|
||||
longFilename[n+2] = VFAT->name1[2];
|
||||
longFilename[n+3] = VFAT->name1[3];
|
||||
longFilename[n+4] = VFAT->name1[4];
|
||||
longFilename[n+5] = VFAT->name2[0];
|
||||
longFilename[n+6] = VFAT->name2[1];
|
||||
longFilename[n+7] = VFAT->name2[2];
|
||||
longFilename[n+8] = VFAT->name2[3];
|
||||
longFilename[n+9] = VFAT->name2[4];
|
||||
longFilename[n+10] = VFAT->name2[5];
|
||||
longFilename[n+11] = VFAT->name3[0];
|
||||
longFilename[n+12] = VFAT->name3[1];
|
||||
//If this VFAT entry is the last one, add a NUL terminator at the end of the string
|
||||
if (VFAT->sequenceNumber & 0x40)
|
||||
longFilename[n+13] = '\0';
|
||||
}
|
||||
}
|
||||
// return if normal file or subdirectory
|
||||
if (DIR_IS_FILE_OR_SUBDIR(dir)) return n;
|
||||
}
|
||||
@@ -1788,4 +1822,4 @@ void (*SdBaseFile::oldDateTime_)(uint16_t& date, uint16_t& time) = 0; // NOLINT
|
||||
#endif // ALLOW_DEPRECATED_FUNCTIONS
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+3
-3
@@ -283,7 +283,7 @@ class SdBaseFile {
|
||||
bool printName();
|
||||
int16_t read();
|
||||
int16_t read(void* buf, uint16_t nbyte);
|
||||
int8_t readDir(dir_t* dir);
|
||||
int8_t readDir(dir_t* dir, char* longFilename);
|
||||
static bool remove(SdBaseFile* dirFile, const char* path);
|
||||
bool remove();
|
||||
/** Set the file's current position to zero. */
|
||||
@@ -455,7 +455,7 @@ class SdBaseFile {
|
||||
* \param[out] dir The dir_t struct that will receive the data.
|
||||
* \return bytes read for success zero for eof or -1 for failure.
|
||||
*/
|
||||
int8_t readDir(dir_t& dir) {return readDir(&dir);} // NOLINT
|
||||
int8_t readDir(dir_t& dir, char* longFilename) {return readDir(&dir, longFilename);} // NOLINT
|
||||
/** \deprecated Use:
|
||||
* static uint8_t remove(SdBaseFile* dirFile, const char* path);
|
||||
* \param[in] dirFile The directory that contains the file.
|
||||
@@ -480,4 +480,4 @@ class SdBaseFile {
|
||||
};
|
||||
|
||||
#endif // SdBaseFile_h
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -108,7 +108,14 @@ uint8_t const SOFT_SPI_SCK_PIN = 13;
|
||||
* a pure virtual function is called.
|
||||
*/
|
||||
#define USE_CXA_PURE_VIRTUAL 1
|
||||
/**
|
||||
* Defines for long (vfat) filenames
|
||||
*/
|
||||
/** Number of VFAT entries used. Every entry has 13 UTF-16 characters */
|
||||
#define MAX_VFAT_ENTRIES (2)
|
||||
/** Total size of the buffer used to store the long filenames */
|
||||
#define LONG_FILENAME_LENGTH (13*MAX_VFAT_ENTRIES+1)
|
||||
#endif // SdFatConfig_h
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+43
-7
@@ -22,6 +22,8 @@
|
||||
|
||||
#ifndef SdFatStructs_h
|
||||
#define SdFatStructs_h
|
||||
|
||||
#define PACKED __attribute__((__packed__))
|
||||
/**
|
||||
* \file
|
||||
* \brief FAT file structures
|
||||
@@ -95,7 +97,7 @@ struct partitionTable {
|
||||
uint32_t firstSector;
|
||||
/** Length of the partition, in blocks. */
|
||||
uint32_t totalSectors;
|
||||
};
|
||||
} PACKED;
|
||||
/** Type name for partitionTable */
|
||||
typedef struct partitionTable part_t;
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -119,7 +121,7 @@ struct masterBootRecord {
|
||||
uint8_t mbrSig0;
|
||||
/** Second MBR signature byte. Must be 0XAA */
|
||||
uint8_t mbrSig1;
|
||||
};
|
||||
} PACKED;
|
||||
/** Type name for masterBootRecord */
|
||||
typedef struct masterBootRecord mbr_t;
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -247,7 +249,7 @@ struct fat_boot {
|
||||
uint8_t bootSectorSig0;
|
||||
/** must be 0XAA */
|
||||
uint8_t bootSectorSig1;
|
||||
};
|
||||
} PACKED;
|
||||
/** Type name for FAT Boot Sector */
|
||||
typedef struct fat_boot fat_boot_t;
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -401,7 +403,7 @@ struct fat32_boot {
|
||||
uint8_t bootSectorSig0;
|
||||
/** must be 0XAA */
|
||||
uint8_t bootSectorSig1;
|
||||
};
|
||||
} PACKED;
|
||||
/** Type name for FAT32 Boot Sector */
|
||||
typedef struct fat32_boot fat32_boot_t;
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -441,7 +443,7 @@ struct fat32_fsinfo {
|
||||
uint8_t reserved2[12];
|
||||
/** must be 0X00, 0X00, 0X55, 0XAA */
|
||||
uint8_t tailSignature[4];
|
||||
};
|
||||
} PACKED;
|
||||
/** Type name for FAT32 FSINFO Sector */
|
||||
typedef struct fat32_fsinfo fat32_fsinfo_t;
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -539,12 +541,46 @@ struct directoryEntry {
|
||||
uint16_t firstClusterLow;
|
||||
/** 32-bit unsigned holding this file's size in bytes. */
|
||||
uint32_t fileSize;
|
||||
};
|
||||
} PACKED;
|
||||
/**
|
||||
* \struct directoryVFATEntry
|
||||
* \brief VFAT long filename directory entry
|
||||
*
|
||||
* directoryVFATEntries are found in the same list as normal directoryEntry.
|
||||
* But have the attribute field set to DIR_ATT_LONG_NAME.
|
||||
*
|
||||
* Long filenames are saved in multiple directoryVFATEntries.
|
||||
* Each entry containing 13 UTF-16 characters.
|
||||
*/
|
||||
struct directoryVFATEntry {
|
||||
/**
|
||||
* Sequence number. Consists of 2 parts:
|
||||
* bit 6: indicates first long filename block for the next file
|
||||
* bit 0-4: the position of this long filename block (first block is 1)
|
||||
*/
|
||||
uint8_t sequenceNumber;
|
||||
/** First set of UTF-16 characters */
|
||||
uint16_t name1[5];//UTF-16
|
||||
/** attributes (at the same location as in directoryEntry), always 0x0F */
|
||||
uint8_t attributes;
|
||||
/** Reserved for use by Windows NT. Always 0. */
|
||||
uint8_t reservedNT;
|
||||
/** Checksum of the short 8.3 filename, can be used to checked if the file system as modified by a not-long-filename aware implementation. */
|
||||
uint8_t checksum;
|
||||
/** Second set of UTF-16 characters */
|
||||
uint16_t name2[6];//UTF-16
|
||||
/** firstClusterLow is always zero for longFilenames */
|
||||
uint16_t firstClusterLow;
|
||||
/** Third set of UTF-16 characters */
|
||||
uint16_t name3[2];//UTF-16
|
||||
} PACKED;
|
||||
//------------------------------------------------------------------------------
|
||||
// Definitions for directory entries
|
||||
//
|
||||
/** Type name for directoryEntry */
|
||||
typedef struct directoryEntry dir_t;
|
||||
/** Type name for directoryVFATEntry */
|
||||
typedef struct directoryVFATEntry vfat_t;
|
||||
/** escape for name[0] = 0XE5 */
|
||||
uint8_t const DIR_NAME_0XE5 = 0X05;
|
||||
/** name[0] value for entry that is free after being "deleted" */
|
||||
@@ -607,4 +643,4 @@ static inline uint8_t DIR_IS_FILE_OR_SUBDIR(const dir_t* dir) {
|
||||
#endif // SdFatStructs_h
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+9
-6
@@ -55,13 +55,16 @@ int16_t SdFile::write(const void* buf, uint16_t nbyte) {
|
||||
* Use writeError to check for errors.
|
||||
*/
|
||||
#if ARDUINO >= 100
|
||||
size_t SdFile::write(uint8_t b)
|
||||
#else
|
||||
void SdFile::write(uint8_t b)
|
||||
#endif
|
||||
size_t SdFile::write(uint8_t b)
|
||||
{
|
||||
SdBaseFile::write(&b, 1);
|
||||
return SdBaseFile::write(&b, 1);
|
||||
}
|
||||
#else
|
||||
void SdFile::write(uint8_t b)
|
||||
{
|
||||
SdBaseFile::write(&b, 1);
|
||||
}
|
||||
#endif
|
||||
//------------------------------------------------------------------------------
|
||||
/** Write a string to a file. Used by the Arduino Print class.
|
||||
* \param[in] str Pointer to the string.
|
||||
@@ -89,4 +92,4 @@ void SdFile::writeln_P(PGM_P str) {
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+4
-102
@@ -51,7 +51,7 @@ void CardReader::lsDive(const char *prepend,SdFile parent)
|
||||
dir_t p;
|
||||
uint8_t cnt=0;
|
||||
|
||||
while (parent.readDir(p) > 0)
|
||||
while (parent.readDir(p, longFilename) > 0)
|
||||
{
|
||||
if( DIR_IS_SUBDIR(&p) && lsAction!=LS_Count && lsAction!=LS_GetFilename) // hence LS_SerialPrint
|
||||
{
|
||||
@@ -429,16 +429,16 @@ void CardReader::checkautostart(bool force)
|
||||
|
||||
char autoname[30];
|
||||
sprintf(autoname,"auto%i.g",lastnr);
|
||||
for(int8_t i=0;i<(int)strlen(autoname);i++)
|
||||
for(int8_t i=0;i<(int8_t)strlen(autoname);i++)
|
||||
autoname[i]=tolower(autoname[i]);
|
||||
dir_t p;
|
||||
|
||||
root.rewind();
|
||||
|
||||
bool found=false;
|
||||
while (root.readDir(p) > 0)
|
||||
while (root.readDir(p, NULL) > 0)
|
||||
{
|
||||
for(int8_t i=0;i<(int)strlen((char*)p.name);i++)
|
||||
for(int8_t i=0;i<(int8_t)strlen((char*)p.name);i++)
|
||||
p.name[i]=tolower(p.name[i]);
|
||||
//Serial.print((char*)p.name);
|
||||
//Serial.print(" ");
|
||||
@@ -533,102 +533,4 @@ void CardReader::printingHasFinished()
|
||||
}
|
||||
autotempShutdown();
|
||||
}
|
||||
void CardReader::fast_xfer(char* strchr_pointer)
|
||||
{
|
||||
char *pstr;
|
||||
boolean done = false;
|
||||
|
||||
//force heater pins low
|
||||
if(HEATER_0_PIN > -1) WRITE(HEATER_0_PIN,LOW);
|
||||
if(HEATER_BED_PIN > -1) WRITE(HEATER_BED_PIN,LOW);
|
||||
|
||||
lastxferchar = 1;
|
||||
xferbytes = 0;
|
||||
|
||||
pstr = strstr(strchr_pointer, " ");
|
||||
//pstr = strchr_pointer;
|
||||
|
||||
if(pstr == NULL)
|
||||
{
|
||||
SERIAL_ECHOLN("invalid command");
|
||||
return;
|
||||
}
|
||||
|
||||
*pstr = '\0';
|
||||
|
||||
//check mode (currently only RAW is supported
|
||||
if(strcmp(strchr_pointer, "RAW") != 0)
|
||||
{
|
||||
SERIAL_ECHOLN("Invalid transfer codec");
|
||||
return;
|
||||
}else{
|
||||
SERIAL_ECHOPGM("Selected codec: ");
|
||||
SERIAL_ECHOLN(strchr_pointer+4);
|
||||
}
|
||||
|
||||
if (!file.open(&root, pstr+1, O_CREAT | O_APPEND | O_WRITE | O_TRUNC))
|
||||
{
|
||||
SERIAL_ECHOPGM("open failed, File: ");
|
||||
SERIAL_ECHOLN(pstr+1);
|
||||
SERIAL_ECHOPGM(".");
|
||||
}else{
|
||||
SERIAL_ECHOPGM("Writing to file: ");
|
||||
SERIAL_ECHOLN(pstr+1);
|
||||
}
|
||||
|
||||
SERIAL_ECHOLN("ok");
|
||||
|
||||
//RAW transfer codec
|
||||
//Host sends \0 then up to SD_FAST_XFER_CHUNK_SIZE then \0
|
||||
//when host is done, it sends \0\0.
|
||||
//if a non \0 character is recieved at the beginning, host has failed somehow, kill the transfer.
|
||||
|
||||
//read SD_FAST_XFER_CHUNK_SIZE bytes (or until \0 is recieved)
|
||||
while(!done)
|
||||
{
|
||||
while(!MYSERIAL.available())
|
||||
{
|
||||
}
|
||||
if(MYSERIAL.peek() != 0)
|
||||
{
|
||||
//host has failed, this isn't a RAW chunk, it's an actual command
|
||||
file.sync();
|
||||
file.close();
|
||||
SERIAL_ECHOLN("Not RAW data");
|
||||
return;
|
||||
}
|
||||
//clear the initial 0
|
||||
MYSERIAL.read();
|
||||
for(int i=0;i<SD_FAST_XFER_CHUNK_SIZE+1;i++)
|
||||
{
|
||||
while(!MYSERIAL.available())
|
||||
{
|
||||
}
|
||||
lastxferchar = MYSERIAL.read();
|
||||
//buffer the data...
|
||||
fastxferbuffer[i] = lastxferchar;
|
||||
|
||||
xferbytes++;
|
||||
|
||||
if(lastxferchar == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if(fastxferbuffer[0] != 0)
|
||||
{
|
||||
fastxferbuffer[SD_FAST_XFER_CHUNK_SIZE] = 0;
|
||||
file.write(fastxferbuffer);
|
||||
SERIAL_ECHOLN("ok");
|
||||
}else{
|
||||
SERIAL_ECHOPGM("Wrote ");
|
||||
SERIAL_ECHO(xferbytes);
|
||||
SERIAL_ECHOLN(" bytes.");
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
||||
file.sync();
|
||||
file.close();
|
||||
}
|
||||
|
||||
#endif //SDSUPPORT
|
||||
|
||||
+3
-7
@@ -33,8 +33,6 @@ public:
|
||||
void chdir(const char * relpath);
|
||||
void updir();
|
||||
void setroot();
|
||||
|
||||
void fast_xfer(char* strchr_pointer);
|
||||
|
||||
|
||||
FORCE_INLINE bool eof() { return sdpos>=filesize ;};
|
||||
@@ -47,10 +45,10 @@ public:
|
||||
bool saving;
|
||||
bool sdprinting ;
|
||||
bool cardOK ;
|
||||
char filename[12];
|
||||
char filename[13];
|
||||
char longFilename[LONG_FILENAME_LENGTH];
|
||||
bool filenameIsDir;
|
||||
int lastnr; //last number of the autostart;
|
||||
char fastxferbuffer[SD_FAST_XFER_CHUNK_SIZE + 1];
|
||||
private:
|
||||
SdFile root,*curDir,workDir,workDirParent,workDirParentParent;
|
||||
Sd2Card card;
|
||||
@@ -67,8 +65,6 @@ private:
|
||||
int16_t nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory.
|
||||
char* diveDirName;
|
||||
void lsDive(const char *prepend,SdFile parent);
|
||||
int lastxferchar;
|
||||
long xferbytes;
|
||||
};
|
||||
#define IS_SD_PRINTING (card.sdprinting)
|
||||
|
||||
@@ -77,4 +73,4 @@ private:
|
||||
#define IS_SD_PRINTING (false)
|
||||
|
||||
#endif //SDSUPPORT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Regular → Executable
+1
-1
@@ -424,7 +424,7 @@ pins
|
||||
#define PD7_PWM NULL
|
||||
#endif /* _AVR_ATmega{168,328,328P}__ */
|
||||
|
||||
#if defined (__AVR_ATmega644__) || defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644PA__) || defined (__AVR_ATmega1284__) || defined (__AVR_ATmega1284P__)
|
||||
#if defined (__AVR_ATmega644__) || defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644PA__) || defined (__AVR_ATmega1284P__)
|
||||
// UART
|
||||
#define RXD DIO8
|
||||
#define TXD DIO9
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+629
-103
@@ -1,20 +1,40 @@
|
||||
#ifndef LANGUAGE_H
|
||||
#define LANGUAGE_H
|
||||
|
||||
// NOTE: IF YOU CHANGE THIS FILE / MERGE THIS FILE WITH CHANGES
|
||||
//
|
||||
// ==> ALWAYS TRY TO COMPILE MARLIN WITH/WITHOUT "ULTIPANEL" / "ULTRALCD" / "SDSUPPORT" #define IN "Configuration.h"
|
||||
// ==> ALSO TRY ALL AVAILABLE "LANGUAGE_CHOICE" OPTIONS
|
||||
|
||||
// Languages
|
||||
// 1 Custom (For you to add your own messages)
|
||||
// 2 English
|
||||
// 1 English
|
||||
// 2 -
|
||||
// 3 French (Waiting translation)
|
||||
// 4 German (Waiting translation)
|
||||
// 5 Etc
|
||||
// 4 German
|
||||
// 5 Spanish
|
||||
// 6 Russian
|
||||
// 7 Italian
|
||||
// 8 Etc
|
||||
|
||||
#define LANGUAGE_CHOICE 1 // Pick your language from the list above
|
||||
|
||||
#define PROTOCOL_VERSION "1.0"
|
||||
|
||||
#if MOTHERBOARD == 7 || MOTHERBOARD == 71
|
||||
#define MACHINE_NAME "Ultimaker"
|
||||
#define FIRMWARE_URL "http://firmware.ultimaker.com"
|
||||
#else
|
||||
#define MACHINE_NAME "Mendel"
|
||||
#define FIRMWARE_URL "http://www.mendel-parts.com"
|
||||
#endif
|
||||
|
||||
#define STRINGIFY_(n) #n
|
||||
#define STRINGIFY(n) STRINGIFY_(n)
|
||||
|
||||
#if LANGUAGE_CHOICE == 1
|
||||
|
||||
// LCD Menu Messages
|
||||
|
||||
#define WELCOME_MSG "Printer Ready."
|
||||
#define WELCOME_MSG MACHINE_NAME " Ready."
|
||||
#define MSG_SD_INSERTED "Card inserted"
|
||||
#define MSG_SD_REMOVED "Card removed"
|
||||
#define MSG_MAIN " Main \003"
|
||||
@@ -22,13 +42,20 @@
|
||||
#define MSG_DISABLE_STEPPERS " Disable Steppers"
|
||||
#define MSG_AUTO_HOME " Auto Home"
|
||||
#define MSG_SET_ORIGIN " Set Origin"
|
||||
#define MSG_PREHEAT_PLA " Preheat PLA"
|
||||
#define MSG_PREHEAT_PLA_SETTINGS " Preheat PLA Setting"
|
||||
#define MSG_PREHEAT_ABS " Preheat ABS"
|
||||
#define MSG_PREHEAT_ABS_SETTINGS " Preheat ABS Setting"
|
||||
#define MSG_COOLDOWN " Cooldown"
|
||||
#define MSG_EXTRUDE " Extrude"
|
||||
#define MSG_RETRACT " Retract"
|
||||
#define MSG_PREHEAT_PLA " Preheat PLA"
|
||||
#define MSG_PREHEAT_ABS " Preheat ABS"
|
||||
#define MSG_MOVE_AXIS " Move Axis \x7E"
|
||||
#define MSG_SPEED " Speed:"
|
||||
#define MSG_NOZZLE " \002Nozzle:"
|
||||
#define MSG_NOZZLE1 " \002Nozzle2:"
|
||||
#define MSG_NOZZLE2 " \002Nozzle3:"
|
||||
#define MSG_BED " \002Bed:"
|
||||
#define MSG_FAN_SPEED " Fan speed:"
|
||||
#define MSG_FLOW " Flow:"
|
||||
@@ -59,31 +86,39 @@
|
||||
#define MSG_ZSTEPS " Zsteps/mm:"
|
||||
#define MSG_ESTEPS " Esteps/mm:"
|
||||
#define MSG_MAIN_WIDE " Main \003"
|
||||
#define MSG_RECTRACT_WIDE " Rectract \x7E"
|
||||
#define MSG_TEMPERATURE_WIDE " Temperature \x7E"
|
||||
#define MSG_TEMPERATURE_RTN " Temperature \003"
|
||||
#define MSG_MOTION_WIDE " Motion \x7E"
|
||||
#define MSG_STORE_EPROM " Store memory"
|
||||
#define MSG_LOAD_EPROM " Load memory"
|
||||
#define MSG_STORE_EPROM " Store memory"
|
||||
#define MSG_LOAD_EPROM " Load memory"
|
||||
#define MSG_RESTORE_FAILSAFE " Restore Failsafe"
|
||||
#define MSG_REFRESH "\004Refresh"
|
||||
#define MSG_WATCH " Watch \003"
|
||||
#define MSG_PREPARE " Prepare \x7E"
|
||||
#define MSG_PREPARE_ALT " Prepare \003"
|
||||
#define MSG_CONTROL_ARROW " Control \x7E"
|
||||
#define MSG_RETRACT_ARROW " Retract \x7E"
|
||||
#define MSG_TUNE " Tune \x7E"
|
||||
#define MSG_PAUSE_PRINT " Pause Print \x7E"
|
||||
#define MSG_RESUME_PRINT " Resume Print \x7E"
|
||||
#define MSG_STOP_PRINT " Stop Print \x7E"
|
||||
#define MSG_CARD_MENU " Card Menu \x7E"
|
||||
#define MSG_NO_CARD " No Card"
|
||||
#define MSG_SERIAL_ERROR_MENU_STRUCTURE "Something is wrong in the MenuStructure."
|
||||
#define MSG_DWELL "Sleep..."
|
||||
#define MSG_USERWAIT "Wait for user..."
|
||||
#define MSG_DWELL "Sleep..."
|
||||
#define MSG_USERWAIT "Wait for user..."
|
||||
#define MSG_NO_MOVE "No move."
|
||||
#define MSG_PART_RELEASE "Partial Release"
|
||||
#define MSG_KILLED "KILLED. "
|
||||
#define MSG_STOPPED "STOPPED. "
|
||||
#define MSG_PREHEAT_PLA " Preheat PLA"
|
||||
#define MSG_PREHEAT_ABS " Preheat ABS"
|
||||
#define MSG_STOPPED "STOPPED. "
|
||||
#define MSG_STEPPER_RELEASED "Released."
|
||||
|
||||
#define MSG_CONTROL_RETRACT " Retract mm:"
|
||||
#define MSG_CONTROL_RETRACTF " Retract F:"
|
||||
#define MSG_CONTROL_RETRACT_ZLIFT " Hop mm:"
|
||||
#define MSG_CONTROL_RETRACT_RECOVER " UnRet +mm:"
|
||||
#define MSG_CONTROL_RETRACT_RECOVERF " UnRet F:"
|
||||
#define MSG_AUTORETRACT " AutoRetr.:"
|
||||
#define MSG_SERIAL_ERROR_MENU_STRUCTURE "Something is wrong in the MenuStructure."
|
||||
|
||||
// Serial Console Messages
|
||||
|
||||
@@ -93,7 +128,7 @@
|
||||
#define MSG_BROWNOUT_RESET " Brown out Reset"
|
||||
#define MSG_WATCHDOG_RESET " Watchdog Reset"
|
||||
#define MSG_SOFTWARE_RESET " Software Reset"
|
||||
#define MSG_MARLIN "Marlin "
|
||||
#define MSG_MARLIN "Marlin "
|
||||
#define MSG_AUTHOR " | Author: "
|
||||
#define MSG_CONFIGURATION_VER " Last Updated: "
|
||||
#define MSG_FREE_MEMORY " Free Memory: "
|
||||
@@ -115,20 +150,23 @@
|
||||
#define MSG_HEATING_COMPLETE "Heating done."
|
||||
#define MSG_BED_HEATING "Bed Heating."
|
||||
#define MSG_BED_DONE "Bed done."
|
||||
#define MSG_M115_REPORT "FIRMWARE_NAME:Marlin V1; Sprinter/grbl mashup for gen6 FIRMWARE_URL:http://www.mendel-parts.com PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:1\n"
|
||||
#define MSG_M115_REPORT "FIRMWARE_NAME:Marlin V1; Sprinter/grbl mashup for gen6 FIRMWARE_URL:" FIRMWARE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) "\n"
|
||||
#define MSG_COUNT_X " Count X:"
|
||||
#define MSG_ERR_KILLED "Printer halted. kill() called !!"
|
||||
#define MSG_ERR_STOPPED "Printer stopped due to errors. Fix the error and use M999 to restart!. (Temperature is reset. Set it before restarting)"
|
||||
#define MSG_ERR_STOPPED "Printer stopped due to errors. Fix the error and use M999 to restart!. (Temperature is reset. Set it before restarting)"
|
||||
#define MSG_RESEND "Resend:"
|
||||
#define MSG_UNKNOWN_COMMAND "Unknown command:\""
|
||||
#define MSG_ACTIVE_EXTRUDER "Active Extruder: "
|
||||
#define MSG_INVALID_EXTRUDER "Invalid extruder"
|
||||
#define MSG_X_MIN "x_min:"
|
||||
#define MSG_X_MAX "x_max:"
|
||||
#define MSG_Y_MIN "y_min:"
|
||||
#define MSG_Y_MAX "y_max:"
|
||||
#define MSG_Z_MIN "z_min:"
|
||||
#define MSG_Z_MAX "z_max:"
|
||||
#define MSG_X_MIN "x_min: "
|
||||
#define MSG_X_MAX "x_max: "
|
||||
#define MSG_Y_MIN "y_min: "
|
||||
#define MSG_Y_MAX "y_max: "
|
||||
#define MSG_Z_MIN "z_min: "
|
||||
#define MSG_Z_MAX "z_max: "
|
||||
#define MSG_M119_REPORT "Reporting endstop status"
|
||||
#define MSG_ENDSTOP_HIT "TRIGGERED"
|
||||
#define MSG_ENDSTOP_OPEN "open"
|
||||
|
||||
#define MSG_SD_CANT_OPEN_SUBDIR "Cannot open subdir"
|
||||
#define MSG_SD_INIT_FAIL "SD init fail"
|
||||
@@ -156,79 +194,90 @@
|
||||
|
||||
// LCD Menu Messages
|
||||
|
||||
#define WELCOME_MSG "MARLIN Ready."
|
||||
#define WELCOME_MSG MACHINE_NAME " Bereit."
|
||||
|
||||
#define MSG_SD_INSERTED "Card inserted"
|
||||
#define MSG_SD_REMOVED "Card removed"
|
||||
#define MSG_MAIN " Main \003"
|
||||
#define MSG_AUTOSTART " Autostart"
|
||||
#define MSG_SD_INSERTED "SDKarte erkannt"
|
||||
#define MSG_SD_REMOVED "SDKarte entfernt"
|
||||
#define MSG_MAIN " Hauptmneü \003"
|
||||
#define MSG_AUTOSTART " Autostart"
|
||||
#define MSG_DISABLE_STEPPERS " Stepper abschalten"
|
||||
#define MSG_AUTO_HOME " Auto Heim"
|
||||
#define MSG_SET_ORIGIN " Position setzen"
|
||||
#define MSG_PREHEAT_PLA " Aufheizen PLA"
|
||||
#define MSG_PREHEAT_ABS " Aufheizen ABS"
|
||||
#define MSG_COOLDOWN " Abkuehlen"
|
||||
#define MSG_EXTRUDE " Extrude"
|
||||
#define MSG_PREHEAT_PLA " Preheat PLA"
|
||||
#define MSG_PREHEAT_ABS " Preheat ABS"
|
||||
#define MSG_MOVE_AXIS " Move Axis \x7E"
|
||||
#define MSG_MOVE_AXIS " Achsen verfahren \x7E"
|
||||
#define MSG_SPEED " Geschw:"
|
||||
#define MSG_NOZZLE " \002Duese:"
|
||||
#define MSG_BED " \002Bett:"
|
||||
#define MSG_FAN_SPEED " Luefter geschw.:"
|
||||
#define MSG_FLOW " Fluss:"
|
||||
#define MSG_CONTROL " Kontrolle \003"
|
||||
#define MSG_MIN " \002 Min:"
|
||||
#define MSG_MAX " \002 Max:"
|
||||
#define MSG_FACTOR " \002 Faktor:"
|
||||
#define MSG_AUTOTEMP " AutoTemp:"
|
||||
#define MSG_ON "Ein "
|
||||
#define MSG_OFF "Aus "
|
||||
#define MSG_PID_P " PID-P: "
|
||||
#define MSG_PID_I " PID-I: "
|
||||
#define MSG_PID_D " PID-D: "
|
||||
#define MSG_PID_C " PID-C: "
|
||||
#define MSG_ACC " Acc:"
|
||||
#define MSG_VXY_JERK " Vxy-jerk: "
|
||||
#define MSG_VMAX " Vmax "
|
||||
#define MSG_X "x:"
|
||||
#define MSG_Y "y:"
|
||||
#define MSG_Z "z:"
|
||||
#define MSG_E "e:"
|
||||
#define MSG_VMIN " Vmin:"
|
||||
#define MSG_VTRAV_MIN " VTrav min:"
|
||||
#define MSG_AMAX " Amax "
|
||||
#define MSG_A_RETRACT " A-retract:"
|
||||
#define MSG_XSTEPS " Xsteps/mm:"
|
||||
#define MSG_YSTEPS " Ysteps/mm:"
|
||||
#define MSG_ZSTEPS " Zsteps/mm:"
|
||||
#define MSG_ESTEPS " Esteps/mm:"
|
||||
#define MSG_MAIN_WIDE " Main \003"
|
||||
#define MSG_TEMPERATURE_WIDE " Temperatur \x7E"
|
||||
#define MSG_MOTION_WIDE " Motion \x7E"
|
||||
#define MSG_STORE_EPROM " EPROM speichern"
|
||||
#define MSG_LOAD_EPROM " EPROM laden"
|
||||
#define MSG_RESTORE_FAILSAFE " Standard Konfig."
|
||||
#define MSG_REFRESH "\004Refresh"
|
||||
#define MSG_WATCH " Beobachten \003"
|
||||
#define MSG_PREPARE " Prepare \x7E"
|
||||
#define MSG_PREPARE_ALT " Prepare \003"
|
||||
#define MSG_CONTROL_ARROW " Control \x7E"
|
||||
#define MSG_TUNE " Tune \x7E"
|
||||
#define MSG_STOP_PRINT " Druck stoppen \x7E"
|
||||
#define MSG_CARD_MENU " SDKarten Menue \x7E"
|
||||
#define MSG_NO_CARD " Keine SDKarte"
|
||||
#define MSG_SERIAL_ERROR_MENU_STRUCTURE "Fehler in der Menuestruktur."
|
||||
#define MSG_DWELL "DWELL..."
|
||||
#define MSG_NO_MOVE "No move."
|
||||
#define MSG_PART_RELEASE "Partial Release"
|
||||
#define MSG_KILLED "KILLED. "
|
||||
#define MSG_PREHEAT_PLA " Preheat PLA"
|
||||
#define MSG_PREHEAT_ABS " Preheat ABS"
|
||||
#define MSG_STEPPER_RELEASED "Released."
|
||||
|
||||
|
||||
#define MSG_AUTO_HOME " Auto Nullpunkt"
|
||||
#define MSG_SET_ORIGIN " Setze Nullpunkt"
|
||||
#define MSG_PREHEAT_PLA " Vorwärmen PLA"
|
||||
#define MSG_PREHEAT_PLA_SETTINGS " Vorwärmen PLA Einstellungen"
|
||||
#define MSG_PREHEAT_ABS " Vorwärmen ABS"
|
||||
#define MSG_PREHEAT_ABS_SETTINGS " Vorwärmen ABS Einstellungen"
|
||||
#define MSG_COOLDOWN " Abkühlen"
|
||||
#define MSG_EXTRUDE " Extrude"
|
||||
#define MSG_RETRACT " Retract"
|
||||
#define MSG_MOVE_AXIS " Achsen bewegen\x7E"
|
||||
#define MSG_SPEED " Geschw:"
|
||||
#define MSG_NOZZLE " \002Düse:"
|
||||
#define MSG_NOZZLE1 " \002Düse2:"
|
||||
#define MSG_NOZZLE2 " \002Düse3:"
|
||||
#define MSG_BED " \002Bett:"
|
||||
#define MSG_FAN_SPEED " Lüftergeschw.:"
|
||||
#define MSG_FLOW " Fluß:"
|
||||
#define MSG_CONTROL " Einstellungen \003"
|
||||
#define MSG_MIN " \002 Min:"
|
||||
#define MSG_MAX " \002 Max:"
|
||||
#define MSG_FACTOR " \002 Faktor:"
|
||||
#define MSG_AUTOTEMP " AutoTemp:"
|
||||
#define MSG_ON "Ein "
|
||||
#define MSG_OFF "Aus "
|
||||
#define MSG_PID_P " PID-P: "
|
||||
#define MSG_PID_I " PID-I: "
|
||||
#define MSG_PID_D " PID-D: "
|
||||
#define MSG_PID_C " PID-C: "
|
||||
#define MSG_ACC " Acc:"
|
||||
#define MSG_VXY_JERK " Vxy-jerk: "
|
||||
#define MSG_VMAX " Vmax "
|
||||
#define MSG_X "x:"
|
||||
#define MSG_Y "y:"
|
||||
#define MSG_Z "z:"
|
||||
#define MSG_E "e:"
|
||||
#define MSG_VMIN " Vmin:"
|
||||
#define MSG_VTRAV_MIN " VTrav min:"
|
||||
#define MSG_AMAX " Amax "
|
||||
#define MSG_A_RETRACT " A-Retract:"
|
||||
#define MSG_XSTEPS " Xsteps/mm:"
|
||||
#define MSG_YSTEPS " Ysteps/mm:"
|
||||
#define MSG_ZSTEPS " Zsteps/mm:"
|
||||
#define MSG_ESTEPS " Esteps/mm:"
|
||||
#define MSG_MAIN_WIDE " Hauptmenü \003"
|
||||
#define MSG_RECTRACT_WIDE " Rectract \x7E"
|
||||
#define MSG_WATCH " Beobachten \003"
|
||||
#define MSG_TEMPERATURE_WIDE " Temperatur \x7E"
|
||||
#define MSG_TEMPERATURE_RTN " Temperatur \003"
|
||||
#define MSG_MOTION_WIDE " Bewegung \x7E"
|
||||
#define MSG_STORE_EPROM " EPROM speichern"
|
||||
#define MSG_LOAD_EPROM " EPROM laden"
|
||||
#define MSG_RESTORE_FAILSAFE " Standardkonfig."
|
||||
#define MSG_REFRESH "\004Aktualisieren"
|
||||
#define MSG_PREPARE " Vorbereitung \x7E"
|
||||
#define MSG_PREPARE_ALT " Vorbereitung \003"
|
||||
#define MSG_CONTROL_ARROW " Einstellungen \x7E"
|
||||
#define MSG_TUNE " Justierung \x7E"
|
||||
#define MSG_PAUSE_PRINT " Druck anhalten\x7E"
|
||||
#define MSG_RESUME_PRINT " Druck fortsetz\x7E"
|
||||
#define MSG_STOP_PRINT " Druck stoppen \x7E"
|
||||
#define MSG_CARD_MENU " SDKarten Menü \x7E"
|
||||
#define MSG_NO_CARD " Keine SDKarte"
|
||||
#define MSG_DWELL "Warten..."
|
||||
#define MSG_USERWAIT "Warte auf Nutzer..."
|
||||
#define MSG_NO_MOVE "Kein Zug."
|
||||
#define MSG_PART_RELEASE "Stepper tlw frei"
|
||||
#define MSG_KILLED "KILLED"
|
||||
#define MSG_STOPPED "GESTOPPT"
|
||||
#define MSG_STEPPER_RELEASED "Stepper frei"
|
||||
#define MSG_CONTROL_RETRACT " Retract mm:"
|
||||
#define MSG_CONTROL_RETRACTF " Retract F:"
|
||||
#define MSG_CONTROL_RETRACT_ZLIFT " Hop mm:"
|
||||
#define MSG_CONTROL_RETRACT_RECOVER " UnRet +mm:"
|
||||
#define MSG_CONTROL_RETRACT_RECOVERF " UnRet F:"
|
||||
#define MSG_AUTORETRACT " AutoRetr.:"
|
||||
#define MSG_SERIAL_ERROR_MENU_STRUCTURE "Fehler in Menüstruktur."
|
||||
|
||||
// Serial Console Messages
|
||||
|
||||
#define MSG_Enqueing "enqueing \""
|
||||
@@ -259,20 +308,23 @@
|
||||
#define MSG_HEATING_COMPLETE "Heating done."
|
||||
#define MSG_BED_HEATING "Bed Heating."
|
||||
#define MSG_BED_DONE "Bed done."
|
||||
#define MSG_M115_REPORT "FIRMWARE_NAME:Marlin V1; Sprinter/grbl mashup for gen6 FIRMWARE_URL:http://www.mendel-parts.com PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:1\n"
|
||||
#define MSG_M115_REPORT "FIRMWARE_NAME:Marlin V1; Sprinter/grbl mashup for gen6 FIRMWARE_URL:" FIRMWARE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) "\n"
|
||||
#define MSG_COUNT_X " Count X:"
|
||||
#define MSG_ERR_KILLED "Printer halted. kill() called !!"
|
||||
#define MSG_ERR_STOPPED "Printer stopped due to errors. Fix the error and use M999 to restart!"
|
||||
#define MSG_ERR_STOPPED "Printer stopped due to errors. Fix the error and use M999 to restart!"
|
||||
#define MSG_RESEND "Resend:"
|
||||
#define MSG_UNKNOWN_COMMAND "Unknown command:\""
|
||||
#define MSG_ACTIVE_EXTRUDER "Active Extruder: "
|
||||
#define MSG_INVALID_EXTRUDER "Invalid extruder"
|
||||
#define MSG_X_MIN "x_min:"
|
||||
#define MSG_X_MAX "x_max:"
|
||||
#define MSG_Y_MIN "y_min:"
|
||||
#define MSG_Y_MAX "y_max:"
|
||||
#define MSG_Z_MIN "z_min:"
|
||||
#define MSG_Z_MAX "z_max:"
|
||||
#define MSG_X_MIN "x_min: "
|
||||
#define MSG_X_MAX "x_max: "
|
||||
#define MSG_Y_MIN "y_min: "
|
||||
#define MSG_Y_MAX "y_max: "
|
||||
#define MSG_Z_MIN "z_min: "
|
||||
#define MSG_Z_MAX "z_max: "
|
||||
#define MSG_M119_REPORT "Reporting endstop status"
|
||||
#define MSG_ENDSTOP_HIT "TRIGGERED"
|
||||
#define MSG_ENDSTOP_OPEN "open"
|
||||
|
||||
#define MSG_SD_CANT_OPEN_SUBDIR "Cannot open subdir"
|
||||
#define MSG_SD_INIT_FAIL "SD init fail"
|
||||
@@ -296,4 +348,478 @@
|
||||
#define MSG_ERR_LONG_EXTRUDE_STOP " too long extrusion prevented"
|
||||
|
||||
#endif
|
||||
|
||||
#if LANGUAGE_CHOICE == 5
|
||||
|
||||
// LCD Menu Messages
|
||||
#define WELCOME_MSG MACHINE_NAME " Lista."
|
||||
#define MSG_SD_INSERTED "Tarjeta SD Colocada"
|
||||
#define MSG_SD_REMOVED "Tarjeta SD Retirada"
|
||||
#define MSG_MAIN " Menu Principal \003"
|
||||
#define MSG_AUTOSTART " Autostart"
|
||||
#define MSG_DISABLE_STEPPERS " Apagar Motores"
|
||||
#define MSG_AUTO_HOME " Llevar Ejes al Cero"
|
||||
#define MSG_SET_ORIGIN " Establecer Cero"
|
||||
#define MSG_COOLDOWN " Enfriar"
|
||||
#define MSG_EXTRUDE " Extruir"
|
||||
#define MSG_RETRACT " Retraer"
|
||||
#define MSG_PREHEAT_PLA " Precalentar PLA"
|
||||
#define MSG_PREHEAT_PLA_SETTINGS " Ajustar temp. PLA"
|
||||
#define MSG_PREHEAT_ABS " Precalentar ABS"
|
||||
#define MSG_PREHEAT_ABS_SETTINGS " Ajustar temp. ABS"
|
||||
#define MSG_MOVE_AXIS " Mover Ejes \x7E"
|
||||
#define MSG_SPEED " Velocidad:"
|
||||
#define MSG_NOZZLE " \002Nozzle:"
|
||||
#define MSG_NOZZLE1 " \002Nozzle2:"
|
||||
#define MSG_NOZZLE2 " \002Nozzle3:"
|
||||
#define MSG_BED " \002Base:"
|
||||
#define MSG_FAN_SPEED " Ventilador:"
|
||||
#define MSG_FLOW " Flujo:"
|
||||
#define MSG_CONTROL " Control \003"
|
||||
#define MSG_MIN " \002 Min:"
|
||||
#define MSG_MAX " \002 Max:"
|
||||
#define MSG_FACTOR " \002 Fact:"
|
||||
#define MSG_AUTOTEMP " Autotemp:"
|
||||
#define MSG_ON "On "
|
||||
#define MSG_OFF "Off"
|
||||
#define MSG_PID_P " PID-P: "
|
||||
#define MSG_PID_I " PID-I: "
|
||||
#define MSG_PID_D " PID-D: "
|
||||
#define MSG_PID_C " PID-C: "
|
||||
#define MSG_ACC " Acc:"
|
||||
#define MSG_VXY_JERK " Vxy-jerk: "
|
||||
#define MSG_VMAX " Vmax "
|
||||
#define MSG_X "x:"
|
||||
#define MSG_Y "y:"
|
||||
#define MSG_Z "z:"
|
||||
#define MSG_E "e:"
|
||||
#define MSG_VMIN " Vmin:"
|
||||
#define MSG_VTRAV_MIN " VTrav min:"
|
||||
#define MSG_AMAX " Amax "
|
||||
#define MSG_A_RETRACT " A-retrac.:"
|
||||
#define MSG_XSTEPS " Xpasos/mm:"
|
||||
#define MSG_YSTEPS " Ypasos/mm:"
|
||||
#define MSG_ZSTEPS " Zpasos/mm:"
|
||||
#define MSG_ESTEPS " Epasos/mm:"
|
||||
#define MSG_MAIN_WIDE " Menu Principal \003"
|
||||
#define MSG_RECTRACT_WIDE " Retraer \x7E"
|
||||
#define MSG_TEMPERATURE_WIDE " Temperatura \x7E"
|
||||
#define MSG_TEMPERATURE_RTN " Temperatura \003"
|
||||
#define MSG_MOTION_WIDE " Movimiento \x7E"
|
||||
#define MSG_STORE_EPROM " Guardar Memoria"
|
||||
#define MSG_LOAD_EPROM " Cargar Memoria"
|
||||
#define MSG_RESTORE_FAILSAFE " Rest. de emergencia"
|
||||
#define MSG_REFRESH "\004Volver a cargar"
|
||||
#define MSG_WATCH " Monitorizar \003"
|
||||
#define MSG_PREPARE " Preparar \x7E"
|
||||
#define MSG_PREPARE_ALT " Preparar \003"
|
||||
#define MSG_CONTROL_ARROW " Control \x7E"
|
||||
#define MSG_RETRACT_ARROW " Retraer \x7E"
|
||||
#define MSG_TUNE " Ajustar \x7E"
|
||||
#define MSG_PAUSE_PRINT " Pausar Impresion \x7E"
|
||||
#define MSG_RESUME_PRINT " Reanudar Impresion \x7E"
|
||||
#define MSG_STOP_PRINT " Detener Impresion \x7E"
|
||||
#define MSG_CARD_MENU " Menu de SD \x7E"
|
||||
#define MSG_NO_CARD " No hay Tarjeta SD"
|
||||
#define MSG_DWELL "Reposo..."
|
||||
#define MSG_USERWAIT "Esperando Ordenes..."
|
||||
#define MSG_NO_MOVE "Sin movimiento"
|
||||
#define MSG_PART_RELEASE "Desacople Parcial"
|
||||
#define MSG_KILLED "PARADA DE EMERGENCIA. "
|
||||
#define MSG_STOPPED "PARADA. "
|
||||
#define MSG_STEPPER_RELEASED "Desacoplada."
|
||||
#define MSG_CONTROL_RETRACT " Retraer mm:"
|
||||
#define MSG_CONTROL_RETRACTF " Retraer F:"
|
||||
#define MSG_CONTROL_RETRACT_ZLIFT " Levantar mm:"
|
||||
#define MSG_CONTROL_RETRACT_RECOVER " DesRet +mm:"
|
||||
#define MSG_CONTROL_RETRACT_RECOVERF " DesRet F:"
|
||||
#define MSG_AUTORETRACT " AutoRetr.:"
|
||||
#define MSG_SERIAL_ERROR_MENU_STRUCTURE "Hay un error en la estructura del menu"
|
||||
|
||||
// Serial Console Messages
|
||||
|
||||
#define MSG_Enqueing "En cola \""
|
||||
#define MSG_POWERUP "PowerUp"
|
||||
#define MSG_EXTERNAL_RESET " Reset Externo"
|
||||
#define MSG_BROWNOUT_RESET " Reset por Voltaje Incorrecto"
|
||||
#define MSG_WATCHDOG_RESET " Reset por Bloqueo"
|
||||
#define MSG_SOFTWARE_RESET " Reset por Software"
|
||||
#define MSG_MARLIN "Marlin "
|
||||
#define MSG_AUTHOR " | Autor: "
|
||||
#define MSG_CONFIGURATION_VER " Ultima actualizacion: "
|
||||
#define MSG_FREE_MEMORY " Memoria libre: "
|
||||
#define MSG_PLANNER_BUFFER_BYTES " PlannerBufferBytes: "
|
||||
#define MSG_OK "ok"
|
||||
#define MSG_FILE_SAVED "Guardado."
|
||||
#define MSG_ERR_LINE_NO "El Numero de Linea no es igual al Ultimo Numero de Linea+1, Ultima Linea:"
|
||||
#define MSG_ERR_CHECKSUM_MISMATCH "el checksum no coincide, Ultima Linea:"
|
||||
#define MSG_ERR_NO_CHECKSUM "No se pudo hallar el Checksum con el numero de linea, Ultima Linea:"
|
||||
#define MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM "No se hallo el Numero de Linea con el Checksum, Ultima Linea:"
|
||||
#define MSG_FILE_PRINTED "Impresion terminada"
|
||||
#define MSG_BEGIN_FILE_LIST "Comienzo de la lista de archivos"
|
||||
#define MSG_END_FILE_LIST "Fin de la lista de archivos"
|
||||
#define MSG_M104_INVALID_EXTRUDER "M104 Extrusor Invalido "
|
||||
#define MSG_M105_INVALID_EXTRUDER "M105 Extrusor Invalido "
|
||||
#define MSG_ERR_NO_THERMISTORS "No hay termistores - no temp"
|
||||
#define MSG_M109_INVALID_EXTRUDER "M109 Extrusor Invalido "
|
||||
#define MSG_HEATING "Calentando..."
|
||||
#define MSG_HEATING_COMPLETE "Calentamiento Hecho."
|
||||
#define MSG_BED_HEATING "Calentando la base."
|
||||
#define MSG_BED_DONE "Base Caliente."
|
||||
#define MSG_M115_REPORT "FIRMWARE_NAME:Marlin V1; Sprinter/grbl mashup for gen6 FIRMWARE_URL:" FIRMWARE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) "\n"
|
||||
#define MSG_COUNT_X " Cuenta X:"
|
||||
#define MSG_ERR_KILLED "¡¡Impresora Parada con kill()!!"
|
||||
#define MSG_ERR_STOPPED "¡Impresora parada por errores. Arregle el error y use M999 Para reiniciar!. (La temperatura se reestablece. Ajustela antes de continuar)"
|
||||
#define MSG_RESEND "Reenviar:"
|
||||
#define MSG_UNKNOWN_COMMAND "Comando Desconocido:\""
|
||||
#define MSG_ACTIVE_EXTRUDER "Extrusor Activo: "
|
||||
#define MSG_INVALID_EXTRUDER "Extrusor Invalido"
|
||||
#define MSG_X_MIN "x_min: "
|
||||
#define MSG_X_MAX "x_max: "
|
||||
#define MSG_Y_MIN "y_min: "
|
||||
#define MSG_Y_MAX "y_max: "
|
||||
#define MSG_Z_MIN "z_min: "
|
||||
#define MSG_M119_REPORT "Comprobando fines de carrera."
|
||||
#define MSG_ENDSTOP_HIT "PULSADO"
|
||||
#define MSG_ENDSTOP_OPEN "abierto"
|
||||
|
||||
#define MSG_SD_CANT_OPEN_SUBDIR "No se pudo abrir la subcarpeta."
|
||||
#define MSG_SD_INIT_FAIL "Fallo al iniciar la SD"
|
||||
#define MSG_SD_VOL_INIT_FAIL "Fallo al montar el volumen"
|
||||
#define MSG_SD_OPENROOT_FAIL "Fallo al abrir la carpeta raiz"
|
||||
#define MSG_SD_CARD_OK "Tarjeta SD OK"
|
||||
#define MSG_SD_WORKDIR_FAIL "Fallo al abrir la carpeta de trabajo"
|
||||
#define MSG_SD_OPEN_FILE_FAIL "Error al abrir, Archivo: "
|
||||
#define MSG_SD_FILE_OPENED "Archivo abierto:"
|
||||
#define MSG_SD_SIZE " Tamaño:"
|
||||
#define MSG_SD_FILE_SELECTED "Archivo Seleccionado"
|
||||
#define MSG_SD_WRITE_TO_FILE "Escribiendo en el archivo: "
|
||||
#define MSG_SD_PRINTING_BYTE "SD imprimiendo el byte "
|
||||
#define MSG_SD_NOT_PRINTING "No se esta imprimiendo con SD"
|
||||
#define MSG_SD_ERR_WRITE_TO_FILE "Error al escribir en el archivo"
|
||||
#define MSG_SD_CANT_ENTER_SUBDIR "No se puede abrir la carpeta:"
|
||||
|
||||
#define MSG_STEPPER_TO_HIGH "Steprate demasiado alto : "
|
||||
#define MSG_ENDSTOPS_HIT "Se ha tocado el fin de carril: "
|
||||
#define MSG_ERR_COLD_EXTRUDE_STOP " extrusion fria evitada"
|
||||
#define MSG_ERR_LONG_EXTRUDE_STOP " extrusion demasiado larga evitada"
|
||||
|
||||
#endif
|
||||
|
||||
#if LANGUAGE_CHOICE == 6
|
||||
|
||||
// LCD Menu Messages
|
||||
#define WELCOME_MSG MACHINE_NAME " Готов."
|
||||
#define MSG_SD_INSERTED "Карта вставлена"
|
||||
#define MSG_SD_REMOVED "Карта извлечена"
|
||||
#define MSG_MAIN " Меню \003"
|
||||
#define MSG_AUTOSTART " Автостарт "
|
||||
#define MSG_DISABLE_STEPPERS " Выключить двигатели"
|
||||
#define MSG_AUTO_HOME " Парковка "
|
||||
#define MSG_SET_ORIGIN " Запомнить ноль "
|
||||
#define MSG_PREHEAT_PLA " Преднагрев PLA "
|
||||
#define MSG_PREHEAT_PLA_SETTINGS " Настр. преднагр.PLA"
|
||||
#define MSG_PREHEAT_ABS " Преднагрев ABS "
|
||||
#define MSG_PREHEAT_ABS_SETTINGS " Настр. преднагр.ABS"
|
||||
#define MSG_COOLDOWN " Охлаждение "
|
||||
#define MSG_EXTRUDE " Экструзия "
|
||||
#define MSG_RETRACT " Откат"
|
||||
#define MSG_MOVE_AXIS " Движение по осям \x7E"
|
||||
#define MSG_SPEED " Скорость:"
|
||||
#define MSG_NOZZLE " \002 Фильера:"
|
||||
#define MSG_NOZZLE1 " \002 Фильера2:"
|
||||
#define MSG_NOZZLE2 " \002 Фильера3:"
|
||||
#define MSG_BED " \002 Кровать:"
|
||||
#define MSG_FAN_SPEED " Куллер:"
|
||||
#define MSG_FLOW " Поток:"
|
||||
#define MSG_CONTROL " Настройки \003"
|
||||
#define MSG_MIN " \002 Минимум:"
|
||||
#define MSG_MAX " \002 Максимум:"
|
||||
#define MSG_FACTOR " \002 Фактор:"
|
||||
#define MSG_AUTOTEMP " Autotemp:"
|
||||
#define MSG_ON "Вкл. "
|
||||
#define MSG_OFF "Выкл. "
|
||||
#define MSG_PID_P " PID-P: "
|
||||
#define MSG_PID_I " PID-I: "
|
||||
#define MSG_PID_D " PID-D: "
|
||||
#define MSG_PID_C " PID-C: "
|
||||
#define MSG_ACC " Acc:"
|
||||
#define MSG_VXY_JERK " Vxy-jerk: "
|
||||
#define MSG_VMAX " Vmax "
|
||||
#define MSG_X "x:"
|
||||
#define MSG_Y "y:"
|
||||
#define MSG_Z "z:"
|
||||
#define MSG_E "e:"
|
||||
#define MSG_VMIN " Vmin:"
|
||||
#define MSG_VTRAV_MIN " VTrav min:"
|
||||
#define MSG_AMAX " Amax "
|
||||
#define MSG_A_RETRACT " A-retract:"
|
||||
#define MSG_XSTEPS " X шаг/mm:"
|
||||
#define MSG_YSTEPS " Y шаг/mm:"
|
||||
#define MSG_ZSTEPS " Z шаг/mm:"
|
||||
#define MSG_ESTEPS " E шаг/mm:"
|
||||
#define MSG_MAIN_WIDE " Меню \003"
|
||||
#define MSG_RECTRACT_WIDE " Откат подачи \x7E"
|
||||
#define MSG_TEMPERATURE_WIDE " Температура \x7E"
|
||||
#define MSG_TEMPERATURE_RTN " Температура \003"
|
||||
#define MSG_MOTION_WIDE " Скорости \x7E"
|
||||
#define MSG_STORE_EPROM " Сохранить настройки"
|
||||
#define MSG_LOAD_EPROM " Загрузить настройки"
|
||||
#define MSG_RESTORE_FAILSAFE " Сброс настроек "
|
||||
#define MSG_REFRESH "\004Обновить "
|
||||
#define MSG_WATCH " Обзор \003"
|
||||
#define MSG_PREPARE " Действия \x7E"
|
||||
#define MSG_PREPARE_ALT " Действия \003"
|
||||
#define MSG_CONTROL_ARROW " Настройки \x7E"
|
||||
#define MSG_RETRACT_ARROW " Настройки отката \x7E"
|
||||
#define MSG_TUNE " Tune \x7E"
|
||||
#define MSG_PAUSE_PRINT " Пауза печати \x7E"
|
||||
#define MSG_RESUME_PRINT " Продолжить печать \x7E"
|
||||
#define MSG_STOP_PRINT " Остановить печать \x7E"
|
||||
#define MSG_CARD_MENU " Меню карты \x7E"
|
||||
#define MSG_NO_CARD " Нет карты"
|
||||
#define MSG_DWELL "Сон..."
|
||||
#define MSG_USERWAIT "Нажмите для продолж."
|
||||
#define MSG_NO_MOVE "Нет движения. "
|
||||
#define MSG_PART_RELEASE " Извлечение принта "
|
||||
#define MSG_KILLED "УБИТО. "
|
||||
#define MSG_STOPPED "ОСТАНОВЛЕНО. "
|
||||
#define MSG_STEPPER_RELEASED "Двигатели отключены."
|
||||
#define MSG_CONTROL_RETRACT " Откат mm:"
|
||||
#define MSG_CONTROL_RETRACTF " Откат F:"
|
||||
#define MSG_CONTROL_RETRACT_ZLIFT " Прыжок mm:"
|
||||
#define MSG_CONTROL_RETRACT_RECOVER " Возврат +mm:"
|
||||
#define MSG_CONTROL_RETRACT_RECOVERF " Возврат F:"
|
||||
#define MSG_AUTORETRACT " АвтоОткат:"
|
||||
#define MSG_SERIAL_ERROR_MENU_STRUCTURE "Ошибка в структуре меню."
|
||||
|
||||
// Serial Console Messages
|
||||
|
||||
#define MSG_Enqueing "Запланировано \""
|
||||
#define MSG_POWERUP "Включение питания"
|
||||
#define MSG_EXTERNAL_RESET " Внешний сброс"
|
||||
#define MSG_BROWNOUT_RESET " Brown out сброс"
|
||||
#define MSG_WATCHDOG_RESET " Watchdog сброс"
|
||||
#define MSG_SOFTWARE_RESET " программный сброс"
|
||||
#define MSG_MARLIN "Marlin "
|
||||
#define MSG_AUTHOR " | Автор: "
|
||||
#define MSG_CONFIGURATION_VER " Последнее обновление: "
|
||||
#define MSG_FREE_MEMORY " Памяти свободно: "
|
||||
#define MSG_PLANNER_BUFFER_BYTES " Буффер очереди команд Bytes: "
|
||||
#define MSG_OK "ok"
|
||||
#define MSG_FILE_SAVED "Файл записан."
|
||||
#define MSG_ERR_LINE_NO "Номен строки это не последняя строка+1, последняя строка:"
|
||||
#define MSG_ERR_CHECKSUM_MISMATCH "контрольная сумма не совпадает, последняя строка:"
|
||||
#define MSG_ERR_NO_CHECKSUM "нет контрольной суммы для строки, последняя строка:"
|
||||
#define MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM "нет строки для контрольной суммы, последняя строка:"
|
||||
#define MSG_FILE_PRINTED "Печать файла завершена"
|
||||
#define MSG_BEGIN_FILE_LIST "Список файлов"
|
||||
#define MSG_END_FILE_LIST "Конец списка файлов"
|
||||
#define MSG_M104_INVALID_EXTRUDER "M104 ошибка экструдера "
|
||||
#define MSG_M105_INVALID_EXTRUDER "M105 ошибка экструдера "
|
||||
#define MSG_ERR_NO_THERMISTORS "Нет термистра - нет температуры"
|
||||
#define MSG_M109_INVALID_EXTRUDER "M109 ошибка экструдера "
|
||||
#define MSG_HEATING "Нагрев... "
|
||||
#define MSG_HEATING_COMPLETE "Наргето. "
|
||||
#define MSG_BED_HEATING "Нагрев стола... "
|
||||
#define MSG_BED_DONE "Стол нагрет. "
|
||||
#define MSG_M115_REPORT "FIRMWARE_NAME:Marlin V1; Sprinter/grbl mashup for gen6 FIRMWARE_URL:" FIRMWARE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) "\n"
|
||||
#define MSG_COUNT_X " Count X:"
|
||||
#define MSG_ERR_KILLED "Принтер остановлен. вызов kill() !!"
|
||||
#define MSG_ERR_STOPPED "Ошибка принтера, останов. Устраните неисправность и используйте M999 для перезагрузки!. (Температура недоступна. Проверьте датчики)"
|
||||
#define MSG_RESEND "Переотправка:"
|
||||
#define MSG_UNKNOWN_COMMAND "Неизвестная команда:\""
|
||||
#define MSG_ACTIVE_EXTRUDER "Активный экструдер: "
|
||||
#define MSG_INVALID_EXTRUDER "Ошибка экструдера"
|
||||
#define MSG_X_MIN "x_min:"
|
||||
#define MSG_X_MAX "x_max:"
|
||||
#define MSG_Y_MIN "y_min:"
|
||||
#define MSG_Y_MAX "y_max:"
|
||||
#define MSG_Z_MIN "z_min:"
|
||||
#define MSG_Z_MAX "z_max:"
|
||||
|
||||
#define MSG_SD_CANT_OPEN_SUBDIR "Не открыть папку"
|
||||
#define MSG_SD_INIT_FAIL "Ошибка инициализации SD"
|
||||
#define MSG_SD_VOL_INIT_FAIL "Ошибка инициализации раздела"
|
||||
#define MSG_SD_OPENROOT_FAIL "Не прочесть содержимое корня"
|
||||
#define MSG_SD_CARD_OK "SD карта в порядке"
|
||||
#define MSG_SD_WORKDIR_FAIL "не открыть рабочую папку"
|
||||
#define MSG_SD_OPEN_FILE_FAIL "Ошибка чтения, файл: "
|
||||
#define MSG_SD_FILE_OPENED "Файл открыт:"
|
||||
#define MSG_SD_SIZE " Размер:"
|
||||
#define MSG_SD_FILE_SELECTED "Файл выбран"
|
||||
#define MSG_SD_WRITE_TO_FILE "Запись в файл: "
|
||||
#define MSG_SD_PRINTING_BYTE "SD печать byte "
|
||||
#define MSG_SD_NOT_PRINTING "нет SD печати"
|
||||
#define MSG_SD_ERR_WRITE_TO_FILE "ошибка записи в файл"
|
||||
#define MSG_SD_CANT_ENTER_SUBDIR "Не зайти в папку:"
|
||||
|
||||
#define MSG_STEPPER_TO_HIGH "Частота шагов очень высока : "
|
||||
#define MSG_ENDSTOPS_HIT "концевик сработал: "
|
||||
#define MSG_ERR_COLD_EXTRUDE_STOP " защита холодной экструзии"
|
||||
#define MSG_ERR_LONG_EXTRUDE_STOP " защита превышения длинны экструзии"
|
||||
#define MSG_M119_REPORT "Статус концевиков"
|
||||
#define MSG_ENDSTOP_HIT "Срабатывание концевика"
|
||||
#define MSG_ENDSTOP_OPEN "Концевик освобожден"
|
||||
|
||||
#endif
|
||||
|
||||
#if LANGUAGE_CHOICE == 7
|
||||
|
||||
// LCD Menu Messages
|
||||
#define WELCOME_MSG MACHINE_NAME " Pronto."
|
||||
#define MSG_SD_INSERTED "SD Card inserita"
|
||||
#define MSG_SD_REMOVED "SD Card rimossa"
|
||||
#define MSG_MAIN " Menu principale \003"
|
||||
#define MSG_AUTOSTART " Autostart"
|
||||
#define MSG_DISABLE_STEPPERS " Disabilita Motori Passo-Passo"
|
||||
#define MSG_AUTO_HOME " Auto Home"
|
||||
#define MSG_SET_ORIGIN " Imposta Origini Assi"
|
||||
#define MSG_PREHEAT_PLA " Preriscalda PLA"
|
||||
#define MSG_PREHEAT_PLA_SETTINGS " Impostazioni Preriscaldamento PLA"
|
||||
#define MSG_PREHEAT_ABS " Preriscalda ABS"
|
||||
#define MSG_PREHEAT_ABS_SETTINGS " Impostazioni Preriscaldamento ABS"
|
||||
#define MSG_COOLDOWN " Rafredda"
|
||||
#define MSG_EXTRUDE " Estrudi"
|
||||
#define MSG_RETRACT " Ritrai"
|
||||
#define MSG_MOVE_AXIS " Muovi Asse \x7E"
|
||||
#define MSG_SPEED " Velcità:"
|
||||
#define MSG_NOZZLE " \002Ugello:"
|
||||
#define MSG_NOZZLE1 " \002Ugello2:"
|
||||
#define MSG_NOZZLE2 " \002Ugello3:"
|
||||
#define MSG_BED " \002Piatto:"
|
||||
#define MSG_FAN_SPEED " Velocità Ventola:"
|
||||
#define MSG_FLOW " Flusso:"
|
||||
#define MSG_CONTROL " Controllo \003"
|
||||
#define MSG_MIN " \002 Min:"
|
||||
#define MSG_MAX " \002 Max:"
|
||||
#define MSG_FACTOR " \002 Fact:"
|
||||
#define MSG_AUTOTEMP " Autotemp:"
|
||||
#define MSG_ON "On "
|
||||
#define MSG_OFF "Off"
|
||||
#define MSG_PID_P " PID-P: "
|
||||
#define MSG_PID_I " PID-I: "
|
||||
#define MSG_PID_D " PID-D: "
|
||||
#define MSG_PID_C " PID-C: "
|
||||
#define MSG_ACC " Acc:"
|
||||
#define MSG_VXY_JERK " Vxy-jerk: "
|
||||
#define MSG_VMAX " Vmax "
|
||||
#define MSG_X "x:"
|
||||
#define MSG_Y "y:"
|
||||
#define MSG_Z "z:"
|
||||
#define MSG_E "e:"
|
||||
#define MSG_VMIN " Vmin:"
|
||||
#define MSG_VTRAV_MIN " VTrav min:"
|
||||
#define MSG_AMAX " Amax "
|
||||
#define MSG_A_RETRACT " A-ritrai:"
|
||||
#define MSG_XSTEPS " Xpassi/mm:"
|
||||
#define MSG_YSTEPS " Ypassi/mm:"
|
||||
#define MSG_ZSTEPS " Zpassi/mm:"
|
||||
#define MSG_ESTEPS " Epassi/mm:"
|
||||
#define MSG_MAIN_WIDE " Menu Principale \003"
|
||||
#define MSG_RECTRACT_WIDE " Ritrai \x7E"
|
||||
#define MSG_TEMPERATURE_WIDE " Temperatura \x7E"
|
||||
#define MSG_TEMPERATURE_RTN " Temperatura \003"
|
||||
#define MSG_MOTION_WIDE " Movimento \x7E"
|
||||
#define MSG_STORE_EPROM " Salva in memoria"
|
||||
#define MSG_LOAD_EPROM " Carica dalla memoria"
|
||||
#define MSG_RESTORE_FAILSAFE " Configurazioni di default"
|
||||
#define MSG_REFRESH "\004Aggiorna"
|
||||
#define MSG_WATCH " Guarda \003"
|
||||
#define MSG_PREPARE " Prepara \x7E"
|
||||
#define MSG_PREPARE_ALT " Prepara \003"
|
||||
#define MSG_CONTROL_ARROW " Controllo \x7E"
|
||||
#define MSG_RETRACT_ARROW " Ritrai \x7E"
|
||||
#define MSG_TUNE " Tune \x7E"
|
||||
#define MSG_PAUSE_PRINT " Metti in Pausa la Stampa \x7E"
|
||||
#define MSG_RESUME_PRINT " Riprendi Stampa \x7E"
|
||||
#define MSG_STOP_PRINT " Arresta Stampa \x7E"
|
||||
#define MSG_CARD_MENU " Card Menu \x7E"
|
||||
#define MSG_NO_CARD " No Card"
|
||||
#define MSG_DWELL " Sospensione..."
|
||||
#define MSG_USERWAIT "Attendi utente..."
|
||||
#define MSG_NO_MOVE "Nessun movimento."
|
||||
#define MSG_PART_RELEASE "Rilascio Parziale"
|
||||
#define MSG_KILLED "UCCISO. "
|
||||
#define MSG_STOPPED "ARRESTATO. "
|
||||
#define MSG_STEPPER_RELEASED "Rilasciato."
|
||||
#define MSG_CONTROL_RETRACT " Ritrai mm:"
|
||||
#define MSG_CONTROL_RETRACTF " Ritrai F:"
|
||||
#define MSG_CONTROL_RETRACT_ZLIFT " Salta mm:"
|
||||
#define MSG_CONTROL_RETRACT_RECOVER " UnRet +mm:"
|
||||
#define MSG_CONTROL_RETRACT_RECOVERF " UnRet F:"
|
||||
#define MSG_AUTORETRACT " AutoRilascio.:"
|
||||
#define MSG_SERIAL_ERROR_MENU_STRUCTURE "Qualcosa non va in MenuStructure."
|
||||
|
||||
// Serial Console Messages
|
||||
|
||||
#define MSG_Enqueing "accodamento \""
|
||||
#define MSG_POWERUP "Accensione"
|
||||
#define MSG_EXTERNAL_RESET " Reset Esterno"
|
||||
#define MSG_BROWNOUT_RESET " Brown out Reset"
|
||||
#define MSG_WATCHDOG_RESET " Watchdog Reset"
|
||||
#define MSG_SOFTWARE_RESET " Software Reset"
|
||||
#define MSG_MARLIN "Marlin "
|
||||
#define MSG_AUTHOR " | Autore: "
|
||||
#define MSG_CONFIGURATION_VER " Ultimo Aggiornamento: "
|
||||
#define MSG_FREE_MEMORY " Memoria Libera: "
|
||||
#define MSG_PLANNER_BUFFER_BYTES " PlannerBufferBytes: "
|
||||
#define MSG_OK "ok"
|
||||
#define MSG_FILE_SAVED "File Salvato."
|
||||
#define MSG_ERR_LINE_NO "Il Numero della Linea non corrisponde al Numero dell'Ultima Linea+1, Ultima Linea:"
|
||||
#define MSG_ERR_CHECKSUM_MISMATCH "checksum non corrispondente, Ultima Linea:"
|
||||
#define MSG_ERR_NO_CHECKSUM "Nessun Checksum con Numero di Linea, Ultima Linea:"
|
||||
#define MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM "Nessun Numero di Linea con Checksum, Ultima Linea:"
|
||||
#define MSG_FILE_PRINTED "File stampato"
|
||||
#define MSG_BEGIN_FILE_LIST "Inizio Lista File"
|
||||
#define MSG_END_FILE_LIST "Fine Lista File"
|
||||
#define MSG_M104_INVALID_EXTRUDER "M104 Estrusore non valido "
|
||||
#define MSG_M105_INVALID_EXTRUDER "M105 Estrusore non valido "
|
||||
#define MSG_ERR_NO_THERMISTORS "Nessun Termistore - nessuna temperatura"
|
||||
#define MSG_M109_INVALID_EXTRUDER "M109 Estrusore non valido "
|
||||
#define MSG_HEATING "Riscaldamento..."
|
||||
#define MSG_HEATING_COMPLETE "Riscaldamento concluso."
|
||||
#define MSG_BED_HEATING "Riscaldamento Piatto."
|
||||
#define MSG_BED_DONE "Piatto Pronto."
|
||||
#define MSG_M115_REPORT "FIRMWARE_NAME:Marlin V1; Sprinter/grbl mashup for gen6 FIRMWARE_URL:" FIRMWARE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) "\n"
|
||||
#define MSG_COUNT_X " Calcola X:"
|
||||
#define MSG_ERR_KILLED "Stampante Calda. kill() chiamata !!"
|
||||
#define MSG_ERR_STOPPED "Stampante fermata a causa di errori. Risolvi l'errore e usa M999 per ripartire!. (Reset temperatura. Impostala prima di ripartire)"
|
||||
#define MSG_RESEND "Reinviato:"
|
||||
#define MSG_UNKNOWN_COMMAND "Comando sconosciuto:\""
|
||||
#define MSG_ACTIVE_EXTRUDER "Attiva Estrusore: "
|
||||
#define MSG_INVALID_EXTRUDER "Estrusore non valido"
|
||||
#define MSG_X_MIN "x_min: "
|
||||
#define MSG_X_MAX "x_max: "
|
||||
#define MSG_Y_MIN "y_min: "
|
||||
#define MSG_Y_MAX "y_max: "
|
||||
#define MSG_Z_MIN "z_min: "
|
||||
#define MSG_Z_MAX "z_max: "
|
||||
#define MSG_M119_REPORT "Segnalazione stato degli endstop"
|
||||
#define MSG_ENDSTOP_HIT "INNESCATO"
|
||||
#define MSG_ENDSTOP_OPEN "aperto"
|
||||
|
||||
#define MSG_SD_CANT_OPEN_SUBDIR "Impossibile aprire sottocartella"
|
||||
#define MSG_SD_INIT_FAIL "Fallita Inizializzazione SD"
|
||||
#define MSG_SD_VOL_INIT_FAIL "Fallito il montaggio del Volume"
|
||||
#define MSG_SD_OPENROOT_FAIL "Fallita l'apertura Cartella Principale"
|
||||
#define MSG_SD_CARD_OK "SD card ok"
|
||||
#define MSG_SD_WORKDIR_FAIL "Fallita l'apertura Cartella di Lavoro"
|
||||
#define MSG_SD_OPEN_FILE_FAIL "Fallita l'apertura del File: "
|
||||
#define MSG_SD_FILE_OPENED "File aperto:"
|
||||
#define MSG_SD_SIZE " Dimensione:"
|
||||
#define MSG_SD_FILE_SELECTED "File selezionato"
|
||||
#define MSG_SD_WRITE_TO_FILE "Scrittura su file: "
|
||||
#define MSG_SD_PRINTING_BYTE "Si sta scrivendo il byte su SD "
|
||||
#define MSG_SD_NOT_PRINTING "Non si sta scrivendo su SD"
|
||||
#define MSG_SD_ERR_WRITE_TO_FILE "Errore nella scrittura su file"
|
||||
#define MSG_SD_CANT_ENTER_SUBDIR "Impossibile entrare nella sottocartella:"
|
||||
|
||||
#define MSG_STEPPER_TO_HIGH "Steprate troppo alto : "
|
||||
#define MSG_ENDSTOPS_HIT "Raggiunto il fondo carrello: "
|
||||
#define MSG_ERR_COLD_EXTRUDE_STOP " prevenuta estrusione fredda"
|
||||
#define MSG_ERR_LONG_EXTRUDE_STOP " prevenuta estrusione troppo lunga"
|
||||
|
||||
#endif
|
||||
|
||||
#endif // ifndef LANGUAGE_H
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
#include "led.h"
|
||||
#if (LED_PIN > -1)
|
||||
#include "Marlin.h"
|
||||
#include "temperature.h"
|
||||
|
||||
static unsigned long previous_millis_led=0;
|
||||
static unsigned long previous_millis_toggle=0;
|
||||
|
||||
void led_init()
|
||||
{
|
||||
SET_OUTPUT(LED_PIN);
|
||||
}
|
||||
|
||||
void led_status()
|
||||
{
|
||||
if (((millis() - previous_millis_led) < LED_UPDATE_INTERVAL))
|
||||
return;
|
||||
previous_millis_led=millis();
|
||||
if (degTargetHotend(active_extruder) > HEATER_0_MINTEMP)
|
||||
{
|
||||
if (((millis() - previous_millis_toggle) < LED_HOTEND_ACTIVE_FLASH))
|
||||
return;
|
||||
previous_millis_toggle=millis();
|
||||
TOGGLE(LED_PIN);
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITE(LED_PIN, HIGH);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif //LED_PIN > -1
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#ifndef __LEDH
|
||||
|
||||
#define __LEDH
|
||||
#include "Marlin.h"
|
||||
|
||||
#if (LED_PIN > -1)
|
||||
void led_status();
|
||||
void led_init();
|
||||
|
||||
#define LED_UPDATE_INTERVAL 100
|
||||
#define LED_HOTEND_ACTIVE_FLASH 800
|
||||
#define LED_ERROR_FLASH 200
|
||||
#define LED_STATUS led_status()
|
||||
|
||||
#else //no led
|
||||
#define LED_STATUS
|
||||
FORCE_INLINE void led_status() {};
|
||||
#endif //LED_PIN > -1
|
||||
|
||||
#endif
|
||||
@@ -125,17 +125,7 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8
|
||||
arc_target[axis_linear] += linear_per_segment;
|
||||
arc_target[E_AXIS] += extruder_per_segment;
|
||||
|
||||
if (min_software_endstops) {
|
||||
if (arc_target[X_AXIS] < X_HOME_POS) arc_target[X_AXIS] = X_HOME_POS;
|
||||
if (arc_target[Y_AXIS] < Y_HOME_POS) arc_target[Y_AXIS] = Y_HOME_POS;
|
||||
if (arc_target[Z_AXIS] < Z_HOME_POS) arc_target[Z_AXIS] = Z_HOME_POS;
|
||||
}
|
||||
|
||||
if (max_software_endstops) {
|
||||
if (arc_target[X_AXIS] > X_MAX_LENGTH) arc_target[X_AXIS] = X_MAX_LENGTH;
|
||||
if (arc_target[Y_AXIS] > Y_MAX_LENGTH) arc_target[Y_AXIS] = Y_MAX_LENGTH;
|
||||
if (arc_target[Z_AXIS] > Z_MAX_LENGTH) arc_target[Z_AXIS] = Z_MAX_LENGTH;
|
||||
}
|
||||
clamp_to_software_endstops(arc_target);
|
||||
plan_buffer_line(arc_target[X_AXIS], arc_target[Y_AXIS], arc_target[Z_AXIS], arc_target[E_AXIS], feed_rate, extruder);
|
||||
|
||||
}
|
||||
|
||||
+390
-81
@@ -45,16 +45,11 @@
|
||||
#endif /* 99 */
|
||||
|
||||
/****************************************************************************************
|
||||
* Gen7 v1.1, v1.2, v1.3, v1.4 pin assignment
|
||||
* Gen7 v1.1, v1.2, v1.3 pin assignment
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
|
||||
#if MOTHERBOARD == 13
|
||||
#define MOTHERBOARD 11
|
||||
#define GEN7_VERSION 14 // v1.4
|
||||
#endif
|
||||
|
||||
#if MOTHERBOARD == 12
|
||||
#define MOTHERBOARD 11
|
||||
#define GEN7_VERSION 13 // v1.3
|
||||
@@ -108,6 +103,7 @@
|
||||
#define HEATER_2_PIN -1
|
||||
#define HEATER_BED_PIN 3
|
||||
|
||||
#define KILL_PIN -1
|
||||
|
||||
#define SDPOWER -1
|
||||
#define SDSS -1 // SCL pin of I2C header
|
||||
@@ -121,12 +117,86 @@
|
||||
#endif
|
||||
#define PS_ON_PIN 15
|
||||
|
||||
#if (GEN7_VERSION < 14)
|
||||
// Gen 1.3 and earlier supplied thermistor power via PS_ON
|
||||
// Need to ignore the bad thermistor readings on those units
|
||||
//All these generations of Gen7 supply thermistor power
|
||||
//via PS_ON, so ignore bad thermistor readings
|
||||
#define BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
|
||||
|
||||
//our pin for debugging.
|
||||
#define DEBUG_PIN 0
|
||||
|
||||
//our RS485 pins
|
||||
#define TX_ENABLE_PIN 12
|
||||
#define RX_ENABLE_PIN 13
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************************
|
||||
* Gen7 v1.4 pin assignment
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
#if MOTHERBOARD == 13
|
||||
#define GEN7_VERSION 14 // v1.4
|
||||
#endif
|
||||
|
||||
#if MOTHERBOARD == 13
|
||||
#define KNOWN_BOARD
|
||||
|
||||
#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega644__) && !defined(__AVR_ATmega1284P__)
|
||||
#error Oops! Make sure you have 'Gen7' selected from the 'Tools -> Boards' menu.
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef GEN7_VERSION
|
||||
#define GEN7_VERSION 14 // v1.x
|
||||
#endif
|
||||
|
||||
//x axis pins
|
||||
#define X_STEP_PIN 29
|
||||
#define X_DIR_PIN 28
|
||||
#define X_ENABLE_PIN 25
|
||||
#define X_MIN_PIN 0
|
||||
#define X_MAX_PIN -1
|
||||
|
||||
//y axis pins
|
||||
#define Y_STEP_PIN 27
|
||||
#define Y_DIR_PIN 26
|
||||
#define Y_ENABLE_PIN 25
|
||||
#define Y_MIN_PIN 1
|
||||
#define Y_MAX_PIN -1
|
||||
|
||||
//z axis pins
|
||||
#define Z_STEP_PIN 23
|
||||
#define Z_DIR_PIN 22
|
||||
#define Z_ENABLE_PIN 25
|
||||
#define Z_MIN_PIN 2
|
||||
#define Z_MAX_PIN -1
|
||||
|
||||
//extruder pins
|
||||
#define E0_STEP_PIN 19
|
||||
#define E0_DIR_PIN 18
|
||||
#define E0_ENABLE_PIN 25
|
||||
|
||||
#define TEMP_0_PIN 0
|
||||
#define TEMP_1_PIN -1
|
||||
#define TEMP_2_PIN -1
|
||||
#define TEMP_BED_PIN 1
|
||||
|
||||
#define HEATER_0_PIN 4
|
||||
#define HEATER_1_PIN -1
|
||||
#define HEATER_2_PIN -1
|
||||
#define HEATER_BED_PIN 3
|
||||
|
||||
#define KILL_PIN -1
|
||||
|
||||
#define SDPOWER -1
|
||||
#define SDSS -1 // SCL pin of I2C header
|
||||
#define LED_PIN -1
|
||||
|
||||
#define FAN_PIN -1
|
||||
|
||||
#define PS_ON_PIN 15
|
||||
|
||||
//our pin for debugging.
|
||||
#define DEBUG_PIN 0
|
||||
|
||||
@@ -206,6 +276,7 @@
|
||||
#define SDCARDDETECT -1
|
||||
#define SUICIDE_PIN -1 //has to be defined; otherwise Power_off doesn't work
|
||||
|
||||
#define KILL_PIN -1
|
||||
//Pins for 4bit LCD Support
|
||||
#define LCD_PINS_RS 18
|
||||
#define LCD_PINS_ENABLE 17
|
||||
@@ -267,6 +338,10 @@
|
||||
#define Z_MIN_PIN 18
|
||||
#define Z_MAX_PIN 19
|
||||
|
||||
#define Z2_STEP_PIN 36
|
||||
#define Z2_DIR_PIN 34
|
||||
#define Z2_ENABLE_PIN 30
|
||||
|
||||
#define E0_STEP_PIN 26
|
||||
#define E0_DIR_PIN 28
|
||||
#define E0_ENABLE_PIN 24
|
||||
@@ -539,6 +614,7 @@
|
||||
#define LED_PIN -1 //changed @ rkoeppl 20110410
|
||||
#define FAN_PIN -1 //changed @ rkoeppl 20110410
|
||||
#define PS_ON_PIN -1 //changed @ rkoeppl 20110410
|
||||
#define KILL_PIN -1 //changed @ drakelive 20120830
|
||||
//our pin for debugging.
|
||||
|
||||
#define DEBUG_PIN 0
|
||||
@@ -554,7 +630,10 @@
|
||||
* Sanguinololu pin assignment
|
||||
*
|
||||
****************************************************************************************/
|
||||
#if MOTHERBOARD == 62
|
||||
#if MOTHERBOARD == 63
|
||||
#define MELZI
|
||||
#endif
|
||||
#if MOTHERBOARD == 62 || MOTHERBOARD == 63
|
||||
#undef MOTHERBOARD
|
||||
#define MOTHERBOARD 6
|
||||
#define SANGUINOLOLU_V_1_2
|
||||
@@ -569,26 +648,45 @@
|
||||
|
||||
#define X_STEP_PIN 15
|
||||
#define X_DIR_PIN 21
|
||||
#define X_MIN_PIN 18
|
||||
#define X_MAX_PIN -1
|
||||
#if X_HOME_DIR < 0
|
||||
# define X_MIN_PIN 18
|
||||
# define X_MAX_PIN -1
|
||||
#else
|
||||
# define X_MIN_PIN -1
|
||||
# define X_MAX_PIN 18
|
||||
#endif
|
||||
|
||||
#define Y_STEP_PIN 22
|
||||
#define Y_DIR_PIN 23
|
||||
#define Y_MIN_PIN 19
|
||||
#define Y_MAX_PIN -1
|
||||
#if Y_HOME_DIR < 0
|
||||
# define Y_MIN_PIN 19
|
||||
# define Y_MAX_PIN -1
|
||||
#else
|
||||
# define Y_MIN_PIN -1
|
||||
# define Y_MAX_PIN 19
|
||||
#endif
|
||||
|
||||
#define Z_STEP_PIN 3
|
||||
#define Z_DIR_PIN 2
|
||||
#define Z_MIN_PIN 20
|
||||
#define Z_MAX_PIN -1
|
||||
#if Z_HOME_DIR < 0
|
||||
# define Z_MIN_PIN 20
|
||||
# define Z_MAX_PIN -1
|
||||
#else
|
||||
# define Z_MIN_PIN -1
|
||||
# define Z_MAX_PIN 20
|
||||
#endif
|
||||
|
||||
#define E0_STEP_PIN 1
|
||||
#define E0_DIR_PIN 0
|
||||
|
||||
#define PROBE_PIN -1
|
||||
|
||||
#define LED_PIN -1
|
||||
#define FAN_PIN -1
|
||||
|
||||
#define FAN_PIN -1
|
||||
|
||||
#ifdef MELZI
|
||||
#define LED_PIN 28
|
||||
#define FAN_PIN 4
|
||||
#endif
|
||||
|
||||
#define PS_ON_PIN -1
|
||||
#define KILL_PIN -1
|
||||
@@ -599,7 +697,7 @@
|
||||
|
||||
#ifdef SANGUINOLOLU_V_1_2
|
||||
|
||||
#define HEATER_BED_PIN 12 // (bed) - 10 for spare DIO pin and bed MOSFET, 12 for SL MOSFET
|
||||
#define HEATER_BED_PIN 12 // (bed)
|
||||
#define X_ENABLE_PIN 14
|
||||
#define Y_ENABLE_PIN 14
|
||||
#define Z_ENABLE_PIN 26
|
||||
@@ -622,66 +720,11 @@
|
||||
#define SDPOWER -1
|
||||
#define SDSS 31
|
||||
|
||||
#ifdef MELZI
|
||||
#define SDSS 24
|
||||
#endif
|
||||
|
||||
/****************************************************************************************
|
||||
* Melzi pin assignment
|
||||
*
|
||||
****************************************************************************************/
|
||||
#if MOTHERBOARD == 63
|
||||
#define KNOWN_BOARD 1
|
||||
#ifndef __AVR_ATmega644P__
|
||||
#ifndef __AVR_ATmega1284P__
|
||||
#error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu.
|
||||
#endif
|
||||
#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 PROBE_PIN -1 //29 on Melzi1284p A2
|
||||
|
||||
#define LED_PIN 27
|
||||
|
||||
#define FAN_PIN 4
|
||||
|
||||
#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
|
||||
|
||||
#define HEATER_BED_PIN 12 // bed (change to 10 for gate pin of MOSFET on heated bed)
|
||||
#define X_ENABLE_PIN 14
|
||||
#define Y_ENABLE_PIN 14
|
||||
#define Z_ENABLE_PIN 26
|
||||
#define E0_ENABLE_PIN 14
|
||||
|
||||
#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
|
||||
@@ -789,10 +832,18 @@
|
||||
#define LCD_PINS_D7 19
|
||||
|
||||
//encoder rotation values
|
||||
#define encrot0 0
|
||||
#define encrot1 2
|
||||
#define encrot2 3
|
||||
#define encrot3 1
|
||||
#ifndef ULTIMAKERCONTROLLER
|
||||
#define encrot0 0
|
||||
#define encrot1 2
|
||||
#define encrot2 3
|
||||
#define encrot3 1
|
||||
#else
|
||||
#define encrot0 0
|
||||
#define encrot1 1
|
||||
#define encrot2 3
|
||||
#define encrot3 2
|
||||
|
||||
#endif
|
||||
|
||||
#define SDCARDDETECT -1
|
||||
//bits in the shift register that carry the buttons for:
|
||||
@@ -994,6 +1045,264 @@
|
||||
|
||||
|
||||
|
||||
/****************************************************************************************
|
||||
* Open Motion controller with enable based extruders
|
||||
*
|
||||
* ATMega644
|
||||
*
|
||||
* +---\/---+
|
||||
* (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 == 90 //Alpha OMCA board
|
||||
#define KNOWN_BOARD 1
|
||||
|
||||
#ifndef __AVR_ATmega644__
|
||||
#error Oops! Make sure you have 'SanguinoA' selected from the 'Tools -> Boards' menu.
|
||||
#endif
|
||||
|
||||
#define X_STEP_PIN 21
|
||||
#define X_DIR_PIN 20
|
||||
#define X_ENABLE_PIN 24
|
||||
#define X_MIN_PIN 0
|
||||
#define X_MAX_PIN -1
|
||||
|
||||
#define Y_STEP_PIN 23
|
||||
#define Y_DIR_PIN 22
|
||||
#define Y_ENABLE_PIN 24
|
||||
#define Y_MIN_PIN 1
|
||||
#define Y_MAX_PIN -1
|
||||
|
||||
#define Z_STEP_PIN 26
|
||||
#define Z_DIR_PIN 25
|
||||
#define Z_ENABLE_PIN 24
|
||||
#define Z_MIN_PIN 2
|
||||
#define Z_MAX_PIN -1
|
||||
|
||||
#define E0_STEP_PIN 28
|
||||
#define E0_DIR_PIN 27
|
||||
#define E0_ENABLE_PIN 24
|
||||
|
||||
#define E1_STEP_PIN -1 // 19
|
||||
#define E1_DIR_PIN -1 // 18
|
||||
#define E1_ENABLE_PIN 24
|
||||
|
||||
#define E2_STEP_PIN -1 // 17
|
||||
#define E2_DIR_PIN -1 // 16
|
||||
#define E2_ENABLE_PIN 24
|
||||
|
||||
#define SDPOWER -1
|
||||
#define SDSS 11
|
||||
#define SDCARDDETECT -1 // 10 optional also used as mode pin
|
||||
#define LED_PIN -1
|
||||
#define FAN_PIN 3
|
||||
#define PS_ON_PIN -1
|
||||
#define KILL_PIN -1
|
||||
|
||||
#define HEATER_0_PIN 4
|
||||
#define HEATER_1_PIN -1 // 12
|
||||
#define HEATER_2_PIN -1 // 13
|
||||
#define TEMP_0_PIN 0 //D27 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
|
||||
#define TEMP_1_PIN -1 // 1
|
||||
#define TEMP_2_PIN -1 // 2
|
||||
#define HEATER_BED_PIN -1 // 14/15
|
||||
#define TEMP_BED_PIN -1 // 1,2 or I2C
|
||||
/* 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
|
||||
|
||||
#if MOTHERBOARD == 91 // Final OMCA board -- REF http://sanguino.cc/hardware
|
||||
#define KNOWN_BOARD 1
|
||||
|
||||
#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega644__)
|
||||
#error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu. (Final OMCA board)
|
||||
#endif
|
||||
|
||||
#define X_STEP_PIN 26
|
||||
#define X_DIR_PIN 25
|
||||
#define X_ENABLE_PIN 10
|
||||
#define X_MIN_PIN 0
|
||||
#define X_MAX_PIN -1
|
||||
|
||||
#define Y_STEP_PIN 28
|
||||
#define Y_DIR_PIN 27
|
||||
#define Y_ENABLE_PIN 10
|
||||
#define Y_MIN_PIN 1
|
||||
#define Y_MAX_PIN -1
|
||||
|
||||
#define Z_STEP_PIN 23
|
||||
#define Z_DIR_PIN 22
|
||||
#define Z_ENABLE_PIN 10
|
||||
#define Z_MIN_PIN 2
|
||||
#define Z_MAX_PIN -1
|
||||
|
||||
#define E0_STEP_PIN 24
|
||||
#define E0_DIR_PIN 21
|
||||
#define E0_ENABLE_PIN 10
|
||||
|
||||
/* future proofing */
|
||||
#define __FS 20
|
||||
#define __FD 19
|
||||
#define __GS 18
|
||||
#define __GD 13
|
||||
|
||||
#define UNUSED_PWM 14 /* PWM on LEFT connector */
|
||||
|
||||
#define E1_STEP_PIN -1 // 21
|
||||
#define E1_DIR_PIN -1 // 20
|
||||
#define E1_ENABLE_PIN -1 // 19
|
||||
|
||||
#define E2_STEP_PIN -1 // 21
|
||||
#define E2_DIR_PIN -1 // 20
|
||||
#define E2_ENABLE_PIN -1 // 18
|
||||
|
||||
#define SDPOWER -1
|
||||
#define SDSS 11
|
||||
#define SDCARDDETECT -1 // 10 optional also used as mode pin
|
||||
#define LED_PIN -1
|
||||
#define FAN_PIN 14 /* PWM on MIDDLE connector */
|
||||
#define PS_ON_PIN -1
|
||||
#define KILL_PIN -1
|
||||
|
||||
#define HEATER_0_PIN 3 /*DONE PWM on RIGHT connector */
|
||||
#define HEATER_1_PIN -1
|
||||
#define HEATER_2_PIN -1
|
||||
#define HEATER_1_PIN -1
|
||||
#define HEATER_2_PIN -1
|
||||
#define TEMP_0_PIN 0 // ANALOG INPUT NUMBERING
|
||||
#define TEMP_1_PIN 1 // ANALOG
|
||||
#define TEMP_2_PIN -1 // 2
|
||||
#define HEATER_BED_PIN 4
|
||||
#define TEMP_BED_PIN 2 // 1,2 or I2C
|
||||
|
||||
#define I2C_SCL 16
|
||||
#define I2C_SDA 17
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/****************************************************************************************
|
||||
* MegaTronics
|
||||
*
|
||||
****************************************************************************************/
|
||||
#if MOTHERBOARD == 70
|
||||
#define KNOWN_BOARD 1
|
||||
|
||||
//////////////////FIX THIS//////////////
|
||||
|
||||
#ifndef __AVR_ATmega2560__
|
||||
#error Oops! Make sure you have 'Arduino Mega' selected from the 'Tools -> Boards' menu.
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#define X_STEP_PIN 26
|
||||
#define X_DIR_PIN 28
|
||||
#define X_ENABLE_PIN 24
|
||||
#define X_MIN_PIN 41
|
||||
#define X_MAX_PIN 37 //2 //Max endstops default to disabled "-1", set to commented value to enable.
|
||||
|
||||
#define Y_STEP_PIN 60 // A6
|
||||
#define Y_DIR_PIN 61 // A7
|
||||
#define Y_ENABLE_PIN 22
|
||||
#define Y_MIN_PIN 14
|
||||
#define Y_MAX_PIN 15 //15
|
||||
|
||||
#define Z_STEP_PIN 54 // A0
|
||||
#define Z_DIR_PIN 55 // A1
|
||||
#define Z_ENABLE_PIN 56 // A2
|
||||
#define Z_MIN_PIN 18
|
||||
#define Z_MAX_PIN 19
|
||||
|
||||
#define E0_STEP_PIN 31
|
||||
#define E0_DIR_PIN 32
|
||||
#define E0_ENABLE_PIN 38
|
||||
|
||||
#define E1_STEP_PIN 34
|
||||
#define E1_DIR_PIN 36
|
||||
#define E1_ENABLE_PIN 30
|
||||
|
||||
#define SDPOWER -1
|
||||
#define SDSS 53
|
||||
#define LED_PIN 13
|
||||
|
||||
|
||||
#define FAN_PIN 7 // IO pin. Buffer needed
|
||||
#define PS_ON_PIN 12
|
||||
#define KILL_PIN -1
|
||||
|
||||
#define HEATER_0_PIN 9 // EXTRUDER 1
|
||||
#define HEATER_1_PIN 8 // EXTRUDER 2 (FAN On Sprinter)
|
||||
#define HEATER_2_PIN -1
|
||||
|
||||
#if TEMP_SENSOR_0 == -1
|
||||
#define TEMP_0_PIN 8 // ANALOG NUMBERING
|
||||
#else
|
||||
#define TEMP_0_PIN 13 // ANALOG NUMBERING
|
||||
|
||||
#endif
|
||||
|
||||
#define TEMP_1_PIN 15 // ANALOG NUMBERING
|
||||
#define TEMP_2_PIN -1 // ANALOG NUMBERING
|
||||
#define HEATER_BED_PIN 10 // BED
|
||||
#define TEMP_BED_PIN 14 // ANALOG NUMBERING
|
||||
|
||||
#define BEEPER 33 // Beeper on AUX-4
|
||||
|
||||
|
||||
#ifdef ULTRA_LCD
|
||||
|
||||
#ifdef NEWPANEL
|
||||
//arduino pin which triggers an piezzo beeper
|
||||
|
||||
#define LCD_PINS_RS 16
|
||||
#define LCD_PINS_ENABLE 17
|
||||
#define LCD_PINS_D4 23
|
||||
#define LCD_PINS_D5 25
|
||||
#define LCD_PINS_D6 27
|
||||
#define LCD_PINS_D7 29
|
||||
|
||||
//buttons are directly attached using AUX-2
|
||||
#define BTN_EN1 37
|
||||
#define BTN_EN2 35
|
||||
#define BTN_ENC 43 //the click
|
||||
|
||||
#define BLEN_C 2
|
||||
#define BLEN_B 1
|
||||
#define BLEN_A 0
|
||||
|
||||
#define SDCARDDETECT -1 // Ramps does not use this port
|
||||
|
||||
//encoder rotation values
|
||||
#define encrot0 0
|
||||
#define encrot1 2
|
||||
#define encrot2 3
|
||||
#define encrot3 1
|
||||
#endif
|
||||
#endif //ULTRA_LCD
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef KNOWN_BOARD
|
||||
#error Unknown MOTHERBOARD value in configuration.h
|
||||
|
||||
+270
-217
@@ -1,63 +1,62 @@
|
||||
/*
|
||||
planner.c - buffers movement commands and manages the acceleration profile plan
|
||||
Part of Grbl
|
||||
|
||||
Copyright (c) 2009-2011 Simen Svale Skogsrud
|
||||
|
||||
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/>.
|
||||
*/
|
||||
Part of Grbl
|
||||
|
||||
Copyright (c) 2009-2011 Simen Svale Skogsrud
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
/* The ring buffer implementation gleaned from the wiring_serial library by David A. Mellis. */
|
||||
|
||||
/*
|
||||
Reasoning behind the mathematics in this module (in the key of 'Mathematica'):
|
||||
|
||||
s == speed, a == acceleration, t == time, d == distance
|
||||
Reasoning behind the mathematics in this module (in the key of 'Mathematica'):
|
||||
|
||||
s == speed, a == acceleration, t == time, d == distance
|
||||
|
||||
Basic definitions:
|
||||
|
||||
Speed[s_, a_, t_] := s + (a*t)
|
||||
Travel[s_, a_, t_] := Integrate[Speed[s, a, t], t]
|
||||
|
||||
Distance to reach a specific speed with a constant acceleration:
|
||||
|
||||
Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, d, t]
|
||||
d -> (m^2 - s^2)/(2 a) --> estimate_acceleration_distance()
|
||||
|
||||
Speed after a given distance of travel with constant acceleration:
|
||||
|
||||
Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, m, t]
|
||||
m -> Sqrt[2 a d + s^2]
|
||||
|
||||
DestinationSpeed[s_, a_, d_] := Sqrt[2 a d + s^2]
|
||||
|
||||
When to start braking (di) to reach a specified destionation speed (s2) after accelerating
|
||||
from initial speed s1 without ever stopping at a plateau:
|
||||
|
||||
Solve[{DestinationSpeed[s1, a, di] == DestinationSpeed[s2, a, d - di]}, di]
|
||||
di -> (2 a d - s1^2 + s2^2)/(4 a) --> intersection_distance()
|
||||
|
||||
IntersectionDistance[s1_, s2_, a_, d_] := (2 a d - s1^2 + s2^2)/(4 a)
|
||||
*/
|
||||
|
||||
Basic definitions:
|
||||
|
||||
Speed[s_, a_, t_] := s + (a*t)
|
||||
Travel[s_, a_, t_] := Integrate[Speed[s, a, t], t]
|
||||
|
||||
Distance to reach a specific speed with a constant acceleration:
|
||||
|
||||
Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, d, t]
|
||||
d -> (m^2 - s^2)/(2 a) --> estimate_acceleration_distance()
|
||||
|
||||
Speed after a given distance of travel with constant acceleration:
|
||||
|
||||
Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, m, t]
|
||||
m -> Sqrt[2 a d + s^2]
|
||||
|
||||
DestinationSpeed[s_, a_, d_] := Sqrt[2 a d + s^2]
|
||||
|
||||
When to start braking (di) to reach a specified destionation speed (s2) after accelerating
|
||||
from initial speed s1 without ever stopping at a plateau:
|
||||
|
||||
Solve[{DestinationSpeed[s1, a, di] == DestinationSpeed[s2, a, d - di]}, di]
|
||||
di -> (2 a d - s1^2 + s2^2)/(4 a) --> intersection_distance()
|
||||
|
||||
IntersectionDistance[s1_, s2_, a_, d_] := (2 a d - s1^2 + s2^2)/(4 a)
|
||||
*/
|
||||
|
||||
#include "Marlin.h"
|
||||
#include "planner.h"
|
||||
#include "stepper.h"
|
||||
#include "temperature.h"
|
||||
#include "ultralcd.h"
|
||||
#include "language.h"
|
||||
#include "led.h"
|
||||
|
||||
//===========================================================================
|
||||
//=============================public variables ============================
|
||||
@@ -84,10 +83,10 @@ static float previous_nominal_speed; // Nominal speed of previous path line segm
|
||||
extern volatile int extrudemultiply; // Sets extrude multiply factor (in percent)
|
||||
|
||||
#ifdef AUTOTEMP
|
||||
float autotemp_max=250;
|
||||
float autotemp_min=210;
|
||||
float autotemp_factor=0.1;
|
||||
bool autotemp_enabled=false;
|
||||
float autotemp_max=250;
|
||||
float autotemp_min=210;
|
||||
float autotemp_factor=0.1;
|
||||
bool autotemp_enabled=false;
|
||||
#endif
|
||||
|
||||
//===========================================================================
|
||||
@@ -101,27 +100,33 @@ volatile unsigned char block_buffer_tail; // Index of the block to pro
|
||||
//=============================private variables ============================
|
||||
//===========================================================================
|
||||
#ifdef PREVENT_DANGEROUS_EXTRUDE
|
||||
bool allow_cold_extrude=false;
|
||||
bool allow_cold_extrude=false;
|
||||
#endif
|
||||
#ifdef XY_FREQUENCY_LIMIT
|
||||
// Used for the frequency limit
|
||||
static unsigned char old_direction_bits = 0; // Old direction bits. Used for speed calculations
|
||||
static long x_segment_time[3]={0,0,0}; // Segment times (in us). Used for speed calculations
|
||||
static long y_segment_time[3]={0,0,0};
|
||||
// Used for the frequency limit
|
||||
static unsigned char old_direction_bits = 0; // Old direction bits. Used for speed calculations
|
||||
static long x_segment_time[3]={
|
||||
0,0,0}; // Segment times (in us). Used for speed calculations
|
||||
static long y_segment_time[3]={
|
||||
0,0,0};
|
||||
#endif
|
||||
|
||||
// Returns the index of the next block in the ring buffer
|
||||
// NOTE: Removed modulo (%) operator, which uses an expensive divide and multiplication.
|
||||
static int8_t next_block_index(int8_t block_index) {
|
||||
block_index++;
|
||||
if (block_index == BLOCK_BUFFER_SIZE) { block_index = 0; }
|
||||
if (block_index == BLOCK_BUFFER_SIZE) {
|
||||
block_index = 0;
|
||||
}
|
||||
return(block_index);
|
||||
}
|
||||
|
||||
|
||||
// Returns the index of the previous block in the ring buffer
|
||||
static int8_t prev_block_index(int8_t block_index) {
|
||||
if (block_index == 0) { block_index = BLOCK_BUFFER_SIZE; }
|
||||
if (block_index == 0) {
|
||||
block_index = BLOCK_BUFFER_SIZE;
|
||||
}
|
||||
block_index--;
|
||||
return(block_index);
|
||||
}
|
||||
@@ -135,8 +140,8 @@ static int8_t prev_block_index(int8_t block_index) {
|
||||
FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration)
|
||||
{
|
||||
if (acceleration!=0) {
|
||||
return((target_rate*target_rate-initial_rate*initial_rate)/
|
||||
(2.0*acceleration));
|
||||
return((target_rate*target_rate-initial_rate*initial_rate)/
|
||||
(2.0*acceleration));
|
||||
}
|
||||
else {
|
||||
return 0.0; // acceleration was 0, set acceleration distance to 0
|
||||
@@ -150,9 +155,9 @@ FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float targ
|
||||
|
||||
FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance)
|
||||
{
|
||||
if (acceleration!=0) {
|
||||
return((2.0*acceleration*distance-initial_rate*initial_rate+final_rate*final_rate)/
|
||||
(4.0*acceleration) );
|
||||
if (acceleration!=0) {
|
||||
return((2.0*acceleration*distance-initial_rate*initial_rate+final_rate*final_rate)/
|
||||
(4.0*acceleration) );
|
||||
}
|
||||
else {
|
||||
return 0.0; // acceleration was 0, set intersection distance to 0
|
||||
@@ -166,46 +171,49 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi
|
||||
unsigned long final_rate = ceil(block->nominal_rate*exit_factor); // (step/min)
|
||||
|
||||
// Limit minimal step rate (Otherwise the timer will overflow.)
|
||||
if(initial_rate <120) {initial_rate=120; }
|
||||
if(final_rate < 120) {final_rate=120; }
|
||||
|
||||
if(initial_rate <120) {
|
||||
initial_rate=120;
|
||||
}
|
||||
if(final_rate < 120) {
|
||||
final_rate=120;
|
||||
}
|
||||
|
||||
long acceleration = block->acceleration_st;
|
||||
int32_t accelerate_steps =
|
||||
ceil(estimate_acceleration_distance(block->initial_rate, block->nominal_rate, acceleration));
|
||||
int32_t decelerate_steps =
|
||||
floor(estimate_acceleration_distance(block->nominal_rate, block->final_rate, -acceleration));
|
||||
|
||||
|
||||
// Calculate the size of Plateau of Nominal Rate.
|
||||
int32_t plateau_steps = block->step_event_count-accelerate_steps-decelerate_steps;
|
||||
|
||||
|
||||
// Is the Plateau of Nominal Rate smaller than nothing? That means no cruising, and we will
|
||||
// have to use intersection_distance() to calculate when to abort acceleration and start braking
|
||||
// in order to reach the final_rate exactly at the end of this block.
|
||||
if (plateau_steps < 0) {
|
||||
accelerate_steps = ceil(
|
||||
intersection_distance(block->initial_rate, block->final_rate, acceleration, block->step_event_count));
|
||||
accelerate_steps = ceil(intersection_distance(block->initial_rate, block->final_rate, acceleration, block->step_event_count));
|
||||
accelerate_steps = max(accelerate_steps,0); // Check limits due to numerical round-off
|
||||
accelerate_steps = min(accelerate_steps,block->step_event_count);
|
||||
plateau_steps = 0;
|
||||
}
|
||||
|
||||
#ifdef ADVANCE
|
||||
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;
|
||||
// block->decelerate_after = accelerate_steps+plateau_steps;
|
||||
#ifdef ADVANCE
|
||||
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;
|
||||
// block->decelerate_after = accelerate_steps+plateau_steps;
|
||||
CRITICAL_SECTION_START; // Fill variables used by the stepper in a critical section
|
||||
if(block->busy == false) { // Don't update variables if block is busy.
|
||||
block->accelerate_until = accelerate_steps;
|
||||
block->decelerate_after = accelerate_steps+plateau_steps;
|
||||
block->initial_rate = initial_rate;
|
||||
block->final_rate = final_rate;
|
||||
#ifdef ADVANCE
|
||||
block->initial_advance = initial_advance;
|
||||
block->final_advance = final_advance;
|
||||
#endif //ADVANCE
|
||||
#ifdef ADVANCE
|
||||
block->initial_advance = initial_advance;
|
||||
block->final_advance = final_advance;
|
||||
#endif //ADVANCE
|
||||
}
|
||||
CRITICAL_SECTION_END;
|
||||
}
|
||||
@@ -227,24 +235,27 @@ FORCE_INLINE float max_allowable_speed(float acceleration, float target_velocity
|
||||
|
||||
// The kernel called by planner_recalculate() when scanning the plan from last to first entry.
|
||||
void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *next) {
|
||||
if(!current) { return; }
|
||||
|
||||
if (next) {
|
||||
if(!current) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (next) {
|
||||
// If entry speed is already at the maximum entry speed, no need to recheck. Block is cruising.
|
||||
// If not, block in state of acceleration or deceleration. Reset entry speed to maximum and
|
||||
// check for maximum allowable speed reductions to ensure maximum possible planned speed.
|
||||
if (current->entry_speed != current->max_entry_speed) {
|
||||
|
||||
|
||||
// If nominal length true, max junction speed is guaranteed to be reached. Only compute
|
||||
// for max allowable speed if block is decelerating and nominal length is false.
|
||||
if ((!current->nominal_length_flag) && (current->max_entry_speed > next->entry_speed)) {
|
||||
current->entry_speed = min( current->max_entry_speed,
|
||||
max_allowable_speed(-current->acceleration,next->entry_speed,current->millimeters));
|
||||
} else {
|
||||
max_allowable_speed(-current->acceleration,next->entry_speed,current->millimeters));
|
||||
}
|
||||
else {
|
||||
current->entry_speed = current->max_entry_speed;
|
||||
}
|
||||
current->recalculate_flag = true;
|
||||
|
||||
|
||||
}
|
||||
} // Skip last block. Already initialized and set for recalculation.
|
||||
}
|
||||
@@ -253,10 +264,17 @@ void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *n
|
||||
// implements the reverse pass.
|
||||
void planner_reverse_pass() {
|
||||
uint8_t block_index = block_buffer_head;
|
||||
if(((block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1)) > 3) {
|
||||
|
||||
//Make a local copy of block_buffer_tail, because the interrupt can alter it
|
||||
CRITICAL_SECTION_START;
|
||||
unsigned char tail = block_buffer_tail;
|
||||
CRITICAL_SECTION_END
|
||||
|
||||
if(((block_buffer_head-tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1)) > 3) {
|
||||
block_index = (block_buffer_head - 3) & (BLOCK_BUFFER_SIZE - 1);
|
||||
block_t *block[3] = { NULL, NULL, NULL };
|
||||
while(block_index != block_buffer_tail) {
|
||||
block_t *block[3] = {
|
||||
NULL, NULL, NULL };
|
||||
while(block_index != tail) {
|
||||
block_index = prev_block_index(block_index);
|
||||
block[2]= block[1];
|
||||
block[1]= block[0];
|
||||
@@ -268,8 +286,10 @@ void planner_reverse_pass() {
|
||||
|
||||
// The kernel called by planner_recalculate() when scanning the plan from first to last entry.
|
||||
void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *next) {
|
||||
if(!previous) { return; }
|
||||
|
||||
if(!previous) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the previous block is an acceleration block, but it is not long enough to complete the
|
||||
// full speed change within the block, we need to adjust the entry speed accordingly. Entry
|
||||
// speeds have already been reset, maximized, and reverse planned by reverse planner.
|
||||
@@ -277,7 +297,7 @@ void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *n
|
||||
if (!previous->nominal_length_flag) {
|
||||
if (previous->entry_speed < current->entry_speed) {
|
||||
double entry_speed = min( current->entry_speed,
|
||||
max_allowable_speed(-previous->acceleration,previous->entry_speed,previous->millimeters) );
|
||||
max_allowable_speed(-previous->acceleration,previous->entry_speed,previous->millimeters) );
|
||||
|
||||
// Check for junction speed change
|
||||
if (current->entry_speed != entry_speed) {
|
||||
@@ -292,7 +312,8 @@ void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *n
|
||||
// implements the forward pass.
|
||||
void planner_forward_pass() {
|
||||
uint8_t block_index = block_buffer_tail;
|
||||
block_t *block[3] = { NULL, NULL, NULL };
|
||||
block_t *block[3] = {
|
||||
NULL, NULL, NULL };
|
||||
|
||||
while(block_index != block_buffer_head) {
|
||||
block[0] = block[1];
|
||||
@@ -311,7 +332,7 @@ void planner_recalculate_trapezoids() {
|
||||
int8_t block_index = block_buffer_tail;
|
||||
block_t *current;
|
||||
block_t *next = NULL;
|
||||
|
||||
|
||||
while(block_index != block_buffer_head) {
|
||||
current = next;
|
||||
next = &block_buffer[block_index];
|
||||
@@ -320,7 +341,7 @@ void planner_recalculate_trapezoids() {
|
||||
if (current->recalculate_flag || next->recalculate_flag) {
|
||||
// NOTE: Entry and exit factors always > 0 by all previous logic operations.
|
||||
calculate_trapezoid_for_block(current, current->entry_speed/current->nominal_speed,
|
||||
next->entry_speed/current->nominal_speed);
|
||||
next->entry_speed/current->nominal_speed);
|
||||
current->recalculate_flag = false; // Reset current only to ensure next trapezoid is computed
|
||||
}
|
||||
}
|
||||
@@ -329,7 +350,7 @@ void planner_recalculate_trapezoids() {
|
||||
// Last/newest block in buffer. Exit speed is set with MINIMUM_PLANNER_SPEED. Always recalculated.
|
||||
if(next != NULL) {
|
||||
calculate_trapezoid_for_block(next, next->entry_speed/next->nominal_speed,
|
||||
MINIMUM_PLANNER_SPEED/next->nominal_speed);
|
||||
MINIMUM_PLANNER_SPEED/next->nominal_speed);
|
||||
next->recalculate_flag = false;
|
||||
}
|
||||
}
|
||||
@@ -381,14 +402,14 @@ void getHighESpeed()
|
||||
if(degTargetHotend0()+2<autotemp_min) { //probably temperature set to zero.
|
||||
return; //do nothing
|
||||
}
|
||||
|
||||
|
||||
float high=0.0;
|
||||
uint8_t block_index = block_buffer_tail;
|
||||
|
||||
|
||||
while(block_index != block_buffer_head) {
|
||||
if((block_buffer[block_index].steps_x != 0) ||
|
||||
(block_buffer[block_index].steps_y != 0) ||
|
||||
(block_buffer[block_index].steps_z != 0)) {
|
||||
(block_buffer[block_index].steps_y != 0) ||
|
||||
(block_buffer[block_index].steps_z != 0)) {
|
||||
float se=(float(block_buffer[block_index].steps_e)/float(block_buffer[block_index].step_event_count))*block_buffer[block_index].nominal_speed;
|
||||
//se; mm/sec;
|
||||
if(se>high)
|
||||
@@ -398,7 +419,7 @@ void getHighESpeed()
|
||||
}
|
||||
block_index = (block_index+1) & (BLOCK_BUFFER_SIZE - 1);
|
||||
}
|
||||
|
||||
|
||||
float g=autotemp_min+high*autotemp_factor;
|
||||
float t=g;
|
||||
if(t<autotemp_min)
|
||||
@@ -437,20 +458,32 @@ void check_axes_activity() {
|
||||
}
|
||||
}
|
||||
else {
|
||||
#if FAN_PIN > -1
|
||||
if (FanSpeed != 0) analogWrite(FAN_PIN,FanSpeed); // If buffer is empty use current fan speed
|
||||
#endif
|
||||
#if FAN_PIN > -1
|
||||
if (FanSpeed != 0){
|
||||
analogWrite(FAN_PIN,FanSpeed); // If buffer is empty use current fan speed
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if((DISABLE_X) && (x_active == 0)) disable_x();
|
||||
if((DISABLE_Y) && (y_active == 0)) disable_y();
|
||||
if((DISABLE_Z) && (z_active == 0)) disable_z();
|
||||
if((DISABLE_E) && (e_active == 0)) { disable_e0();disable_e1();disable_e2(); }
|
||||
#if FAN_PIN > -1
|
||||
if((FanSpeed == 0) && (fan_speed ==0)) analogWrite(FAN_PIN, 0);
|
||||
#endif
|
||||
if((DISABLE_E) && (e_active == 0)) {
|
||||
disable_e0();
|
||||
disable_e1();
|
||||
disable_e2();
|
||||
}
|
||||
#if FAN_PIN > -1
|
||||
if((FanSpeed == 0) && (fan_speed ==0)) {
|
||||
analogWrite(FAN_PIN, 0);
|
||||
}
|
||||
|
||||
if (FanSpeed != 0 && tail_fan_speed !=0) {
|
||||
analogWrite(FAN_PIN,tail_fan_speed);
|
||||
}
|
||||
#endif
|
||||
#ifdef AUTOTEMP
|
||||
getHighESpeed();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -467,11 +500,10 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||
// Rest here until there is room in the buffer.
|
||||
while(block_buffer_tail == next_buffer_head) {
|
||||
manage_heater();
|
||||
manage_inactivity(1);
|
||||
manage_inactivity();
|
||||
LCD_STATUS;
|
||||
LED_STATUS;
|
||||
}
|
||||
|
||||
|
||||
// The target position of the tool in absolute steps
|
||||
// Calculate target position in absolute steps
|
||||
//this should be done after the wait, because otherwise a M92 code within the gcode disrupts this calculation somehow
|
||||
@@ -480,26 +512,28 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||
target[Y_AXIS] = lround(y*axis_steps_per_unit[Y_AXIS]);
|
||||
target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]);
|
||||
target[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]);
|
||||
|
||||
#ifdef PREVENT_DANGEROUS_EXTRUDE
|
||||
if(target[E_AXIS]!=position[E_AXIS])
|
||||
|
||||
#ifdef PREVENT_DANGEROUS_EXTRUDE
|
||||
if(target[E_AXIS]!=position[E_AXIS])
|
||||
if(degHotend(active_extruder)<EXTRUDE_MINTEMP && !allow_cold_extrude)
|
||||
{
|
||||
position[E_AXIS]=target[E_AXIS]; //behave as if the move really took place, but ignore E part
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
|
||||
}
|
||||
if(labs(target[E_AXIS]-position[E_AXIS])>axis_steps_per_unit[E_AXIS]*EXTRUDE_MAXLENGTH)
|
||||
{
|
||||
position[E_AXIS]=target[E_AXIS]; //behave as if the move really took place, but ignore E part
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PREVENT_LENGTHY_EXTRUDE
|
||||
if(labs(target[E_AXIS]-position[E_AXIS])>axis_steps_per_unit[E_AXIS]*EXTRUDE_MAXLENGTH)
|
||||
{
|
||||
position[E_AXIS]=target[E_AXIS]; //behave as if the move really took place, but ignore E part
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Prepare to set up new block
|
||||
block_t *block = &block_buffer[block_buffer_head];
|
||||
|
||||
|
||||
// Mark block as not busy (Not executed by the stepper interrupt)
|
||||
block->busy = false;
|
||||
|
||||
@@ -513,78 +547,89 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||
block->step_event_count = max(block->steps_x, max(block->steps_y, max(block->steps_z, block->steps_e)));
|
||||
|
||||
// Bail if this is a zero-length block
|
||||
if (block->step_event_count <= dropsegments) { return; };
|
||||
if (block->step_event_count <= dropsegments) {
|
||||
return;
|
||||
};
|
||||
|
||||
block->fan_speed = FanSpeed;
|
||||
|
||||
|
||||
// Compute direction bits for this block
|
||||
block->direction_bits = 0;
|
||||
if (target[X_AXIS] < position[X_AXIS]) { block->direction_bits |= (1<<X_AXIS); }
|
||||
if (target[Y_AXIS] < position[Y_AXIS]) { block->direction_bits |= (1<<Y_AXIS); }
|
||||
if (target[Z_AXIS] < position[Z_AXIS]) { block->direction_bits |= (1<<Z_AXIS); }
|
||||
if (target[E_AXIS] < position[E_AXIS]) { block->direction_bits |= (1<<E_AXIS); }
|
||||
|
||||
if (target[X_AXIS] < position[X_AXIS]) {
|
||||
block->direction_bits |= (1<<X_AXIS);
|
||||
}
|
||||
if (target[Y_AXIS] < position[Y_AXIS]) {
|
||||
block->direction_bits |= (1<<Y_AXIS);
|
||||
}
|
||||
if (target[Z_AXIS] < position[Z_AXIS]) {
|
||||
block->direction_bits |= (1<<Z_AXIS);
|
||||
}
|
||||
if (target[E_AXIS] < position[E_AXIS]) {
|
||||
block->direction_bits |= (1<<E_AXIS);
|
||||
}
|
||||
|
||||
block->active_extruder = extruder;
|
||||
|
||||
|
||||
//enable active axes
|
||||
if(block->steps_x != 0) enable_x();
|
||||
if(block->steps_y != 0) enable_y();
|
||||
#ifndef Z_LATE_ENABLE
|
||||
if(block->steps_z != 0) enable_z();
|
||||
#endif
|
||||
#ifndef Z_LATE_ENABLE
|
||||
if(block->steps_z != 0) enable_z();
|
||||
#endif
|
||||
|
||||
// Enable all
|
||||
if(block->steps_e != 0) { enable_e0();enable_e1();enable_e2(); }
|
||||
if(block->steps_e != 0) {
|
||||
enable_e0();
|
||||
enable_e1();
|
||||
enable_e2();
|
||||
}
|
||||
|
||||
if (block->steps_e == 0) {
|
||||
if(feed_rate<mintravelfeedrate) feed_rate=mintravelfeedrate;
|
||||
if(feed_rate<mintravelfeedrate) feed_rate=mintravelfeedrate;
|
||||
}
|
||||
else {
|
||||
if(feed_rate<minimumfeedrate) feed_rate=minimumfeedrate;
|
||||
if(feed_rate<minimumfeedrate) feed_rate=minimumfeedrate;
|
||||
}
|
||||
|
||||
|
||||
float delta_mm[4];
|
||||
delta_mm[X_AXIS] = (target[X_AXIS]-position[X_AXIS])/axis_steps_per_unit[X_AXIS];
|
||||
delta_mm[Y_AXIS] = (target[Y_AXIS]-position[Y_AXIS])/axis_steps_per_unit[Y_AXIS];
|
||||
delta_mm[Z_AXIS] = (target[Z_AXIS]-position[Z_AXIS])/axis_steps_per_unit[Z_AXIS];
|
||||
delta_mm[E_AXIS] = ((target[E_AXIS]-position[E_AXIS])/axis_steps_per_unit[E_AXIS])*extrudemultiply/100.0;
|
||||
// if ( block->steps_x <=dropsegments && block->steps_y <=dropsegments && block->steps_z <=dropsegments ) {
|
||||
// block->millimeters = abs(delta_mm[E_AXIS]);
|
||||
// } else {
|
||||
// block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS]));
|
||||
// }
|
||||
|
||||
// TODO - JMG - SORT OUT RETRACTS WHEN e IS NOT ALONE
|
||||
block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) +
|
||||
square(delta_mm[Z_AXIS]) + square(delta_mm[E_AXIS]));
|
||||
if ( block->steps_x <=dropsegments && block->steps_y <=dropsegments && block->steps_z <=dropsegments ) {
|
||||
block->millimeters = fabs(delta_mm[E_AXIS]);
|
||||
}
|
||||
else {
|
||||
block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS]));
|
||||
}
|
||||
float inverse_millimeters = 1.0/block->millimeters; // Inverse millimeters to remove multiple divides
|
||||
|
||||
// Calculate speed in mm/second for each axis. No divide by zero due to previous checks.
|
||||
float inverse_second = feed_rate * inverse_millimeters;
|
||||
|
||||
int moves_queued=(block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1);
|
||||
|
||||
// slow down when de buffer starts to empty, rather than wait at the corner for a buffer refill
|
||||
#ifdef OLD_SLOWDOWN
|
||||
if(moves_queued < (BLOCK_BUFFER_SIZE * 0.5) && moves_queued > 1) feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5);
|
||||
#endif
|
||||
|
||||
#ifdef SLOWDOWN
|
||||
// Calculate speed in mm/second for each axis. No divide by zero due to previous checks.
|
||||
float inverse_second = feed_rate * inverse_millimeters;
|
||||
|
||||
int moves_queued=(block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1);
|
||||
|
||||
// slow down when de buffer starts to empty, rather than wait at the corner for a buffer refill
|
||||
#ifdef OLD_SLOWDOWN
|
||||
if(moves_queued < (BLOCK_BUFFER_SIZE * 0.5) && moves_queued > 1) feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5);
|
||||
#endif
|
||||
|
||||
#ifdef SLOWDOWN
|
||||
// segment time im micro seconds
|
||||
unsigned long segment_time = lround(1000000.0/inverse_second);
|
||||
if ((moves_queued > 1) && (moves_queued < (BLOCK_BUFFER_SIZE * 0.5))) {
|
||||
if (segment_time < minsegmenttime) { // buffer is draining, add extra time. The amount of time added increases if the buffer is still emptied more.
|
||||
inverse_second=1000000.0/(segment_time+lround(2*(minsegmenttime-segment_time)/moves_queued));
|
||||
inverse_second=1000000.0/(segment_time+lround(2*(minsegmenttime-segment_time)/moves_queued));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
// END OF SLOW DOWN SECTION
|
||||
|
||||
|
||||
|
||||
block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0
|
||||
block->nominal_rate = ceil(block->step_event_count * inverse_second); // (step/sec) Always > 0
|
||||
|
||||
// Calculate and limit speed in mm/sec for each axis
|
||||
// Calculate and limit speed in mm/sec for each axis
|
||||
float current_speed[4];
|
||||
float speed_factor = 1.0; //factor <=1 do decrease speed
|
||||
for(int i=0; i < 4; i++) {
|
||||
@@ -593,7 +638,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||
speed_factor = min(speed_factor, max_feedrate[i] / fabs(current_speed[i]));
|
||||
}
|
||||
|
||||
// Max segement time in us.
|
||||
// Max segement time in us.
|
||||
#ifdef XY_FREQUENCY_LIMIT
|
||||
#define MAX_FREQ_TIME (1000000.0/XY_FREQUENCY_LIMIT)
|
||||
|
||||
@@ -602,7 +647,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||
old_direction_bits = block->direction_bits;
|
||||
|
||||
if((direction_change & (1<<X_AXIS)) == 0) {
|
||||
x_segment_time[0] += segment_time;
|
||||
x_segment_time[0] += segment_time;
|
||||
}
|
||||
else {
|
||||
x_segment_time[2] = x_segment_time[1];
|
||||
@@ -610,7 +655,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||
x_segment_time[0] = segment_time;
|
||||
}
|
||||
if((direction_change & (1<<Y_AXIS)) == 0) {
|
||||
y_segment_time[0] += segment_time;
|
||||
y_segment_time[0] += segment_time;
|
||||
}
|
||||
else {
|
||||
y_segment_time[2] = y_segment_time[1];
|
||||
@@ -651,7 +696,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||
}
|
||||
block->acceleration = block->acceleration_st / steps_per_mm;
|
||||
block->acceleration_rate = (long)((float)block->acceleration_st * 8.388608);
|
||||
|
||||
|
||||
#if 0 // Use old jerk for now
|
||||
// Compute path unit vector
|
||||
double unit_vec[3];
|
||||
@@ -659,7 +704,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||
unit_vec[X_AXIS] = delta_mm[X_AXIS]*inverse_millimeters;
|
||||
unit_vec[Y_AXIS] = delta_mm[Y_AXIS]*inverse_millimeters;
|
||||
unit_vec[Z_AXIS] = delta_mm[Z_AXIS]*inverse_millimeters;
|
||||
|
||||
|
||||
// Compute maximum allowable entry speed at junction by centripetal acceleration approximation.
|
||||
// Let a circle be tangent to both previous and current path line segments, where the junction
|
||||
// deviation is defined as the distance from the junction to the closest edge of the circle,
|
||||
@@ -676,9 +721,9 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||
// Compute cosine of angle between previous and current path. (prev_unit_vec is negative)
|
||||
// NOTE: Max junction velocity is computed without sin() or acos() by trig half angle identity.
|
||||
double cos_theta = - previous_unit_vec[X_AXIS] * unit_vec[X_AXIS]
|
||||
- previous_unit_vec[Y_AXIS] * unit_vec[Y_AXIS]
|
||||
- previous_unit_vec[Z_AXIS] * unit_vec[Z_AXIS] ;
|
||||
|
||||
- previous_unit_vec[Y_AXIS] * unit_vec[Y_AXIS]
|
||||
- previous_unit_vec[Z_AXIS] * unit_vec[Z_AXIS] ;
|
||||
|
||||
// Skip and use default max junction speed for 0 degree acute junction.
|
||||
if (cos_theta < 0.95) {
|
||||
vmax_junction = min(previous_nominal_speed,block->nominal_speed);
|
||||
@@ -687,36 +732,39 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||
// Compute maximum junction velocity based on maximum acceleration and junction deviation
|
||||
double sin_theta_d2 = sqrt(0.5*(1.0-cos_theta)); // Trig half angle identity. Always positive.
|
||||
vmax_junction = min(vmax_junction,
|
||||
sqrt(block->acceleration * junction_deviation * sin_theta_d2/(1.0-sin_theta_d2)) );
|
||||
sqrt(block->acceleration * junction_deviation * sin_theta_d2/(1.0-sin_theta_d2)) );
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// Start with a safe speed
|
||||
float vmax_junction = max_xy_jerk/2;
|
||||
float vmax_junction = max_xy_jerk/2;
|
||||
float vmax_junction_factor = 1.0;
|
||||
if(fabs(current_speed[Z_AXIS]) > max_z_jerk/2)
|
||||
vmax_junction = max_z_jerk/2;
|
||||
vmax_junction = min(vmax_junction, block->nominal_speed);
|
||||
vmax_junction = min(vmax_junction, max_z_jerk/2);
|
||||
if(fabs(current_speed[E_AXIS]) > max_e_jerk/2)
|
||||
vmax_junction = min(vmax_junction, max_e_jerk/2);
|
||||
|
||||
vmax_junction = min(vmax_junction, block->nominal_speed);
|
||||
float safe_speed = vmax_junction;
|
||||
|
||||
if ((moves_queued > 1) && (previous_nominal_speed > 0.0001)) {
|
||||
float jerk = sqrt(pow((current_speed[X_AXIS]-previous_speed[X_AXIS]), 2)+pow((current_speed[Y_AXIS]-previous_speed[Y_AXIS]), 2));
|
||||
if((fabs(previous_speed[X_AXIS]) > 0.0001) || (fabs(previous_speed[Y_AXIS]) > 0.0001)) {
|
||||
vmax_junction = block->nominal_speed;
|
||||
}
|
||||
// if((fabs(previous_speed[X_AXIS]) > 0.0001) || (fabs(previous_speed[Y_AXIS]) > 0.0001)) {
|
||||
vmax_junction = block->nominal_speed;
|
||||
// }
|
||||
if (jerk > max_xy_jerk) {
|
||||
vmax_junction *= (max_xy_jerk/jerk);
|
||||
vmax_junction_factor = (max_xy_jerk/jerk);
|
||||
}
|
||||
if(fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]) > max_z_jerk) {
|
||||
vmax_junction *= (max_z_jerk/fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]));
|
||||
vmax_junction_factor= min(vmax_junction_factor, (max_z_jerk/fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS])));
|
||||
}
|
||||
if(fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]) > max_e_jerk) {
|
||||
vmax_junction *= (max_e_jerk/fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]));
|
||||
vmax_junction_factor = min(vmax_junction_factor, (max_e_jerk/fabs(current_speed[E_AXIS] - previous_speed[E_AXIS])));
|
||||
}
|
||||
vmax_junction = min(previous_nominal_speed, vmax_junction * vmax_junction_factor); // Limit speed to max previous speed
|
||||
}
|
||||
block->max_entry_speed = vmax_junction;
|
||||
|
||||
|
||||
// Initialize block entry speed. Compute based on deceleration to user-defined MINIMUM_PLANNER_SPEED.
|
||||
double v_allowable = max_allowable_speed(-block->acceleration,MINIMUM_PLANNER_SPEED,block->millimeters);
|
||||
block->entry_speed = min(vmax_junction, v_allowable);
|
||||
@@ -729,48 +777,52 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||
// block nominal speed limits both the current and next maximum junction speeds. Hence, in both
|
||||
// the reverse and forward planners, the corresponding block junction speed will always be at the
|
||||
// the maximum junction speed and may always be ignored for any speed reduction checks.
|
||||
if (block->nominal_speed <= v_allowable) { block->nominal_length_flag = true; }
|
||||
else { block->nominal_length_flag = false; }
|
||||
if (block->nominal_speed <= v_allowable) {
|
||||
block->nominal_length_flag = true;
|
||||
}
|
||||
else {
|
||||
block->nominal_length_flag = false;
|
||||
}
|
||||
block->recalculate_flag = true; // Always calculate trapezoid for new block
|
||||
|
||||
|
||||
// Update previous path unit_vector and nominal speed
|
||||
memcpy(previous_speed, current_speed, sizeof(previous_speed)); // previous_speed[] = current_speed[]
|
||||
previous_nominal_speed = block->nominal_speed;
|
||||
|
||||
|
||||
#ifdef ADVANCE
|
||||
// Calculate advance rate
|
||||
if((block->steps_e == 0) || (block->steps_x == 0 && block->steps_y == 0 && block->steps_z == 0)) {
|
||||
|
||||
#ifdef ADVANCE
|
||||
// Calculate advance rate
|
||||
if((block->steps_e == 0) || (block->steps_x == 0 && block->steps_y == 0 && block->steps_z == 0)) {
|
||||
block->advance_rate = 0;
|
||||
block->advance = 0;
|
||||
}
|
||||
else {
|
||||
long acc_dist = estimate_acceleration_distance(0, block->nominal_rate, block->acceleration_st);
|
||||
float advance = (STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K) *
|
||||
(current_speed[E_AXIS] * current_speed[E_AXIS] * EXTRUTION_AREA * EXTRUTION_AREA)*256;
|
||||
block->advance = advance;
|
||||
if(acc_dist == 0) {
|
||||
block->advance_rate = 0;
|
||||
block->advance = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
long acc_dist = estimate_acceleration_distance(0, block->nominal_rate, block->acceleration_st);
|
||||
float advance = (STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K) *
|
||||
(current_speed[E_AXIS] * current_speed[E_AXIS] * EXTRUTION_AREA * EXTRUTION_AREA)*256;
|
||||
block->advance = advance;
|
||||
if(acc_dist == 0) {
|
||||
block->advance_rate = 0;
|
||||
}
|
||||
else {
|
||||
block->advance_rate = advance / (float)acc_dist;
|
||||
}
|
||||
block->advance_rate = advance / (float)acc_dist;
|
||||
}
|
||||
/*
|
||||
}
|
||||
/*
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPGM("advance :");
|
||||
SERIAL_ECHO(block->advance/256.0);
|
||||
SERIAL_ECHOPGM("advance rate :");
|
||||
SERIAL_ECHOLN(block->advance_rate/256.0);
|
||||
*/
|
||||
#endif // ADVANCE
|
||||
SERIAL_ECHOPGM("advance :");
|
||||
SERIAL_ECHO(block->advance/256.0);
|
||||
SERIAL_ECHOPGM("advance rate :");
|
||||
SERIAL_ECHOLN(block->advance_rate/256.0);
|
||||
*/
|
||||
#endif // ADVANCE
|
||||
|
||||
calculate_trapezoid_for_block(block, block->entry_speed/block->nominal_speed,
|
||||
MINIMUM_PLANNER_SPEED/block->nominal_speed);
|
||||
|
||||
safe_speed/block->nominal_speed);
|
||||
|
||||
// Move buffer head
|
||||
block_buffer_head = next_buffer_head;
|
||||
|
||||
|
||||
// Update position
|
||||
memcpy(position, target, sizeof(target)); // position[] = target[]
|
||||
|
||||
@@ -801,12 +853,13 @@ void plan_set_e_position(const float &e)
|
||||
|
||||
uint8_t movesplanned()
|
||||
{
|
||||
return (block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1);
|
||||
return (block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1);
|
||||
}
|
||||
|
||||
void allow_cold_extrudes(bool allow)
|
||||
{
|
||||
#ifdef PREVENT_DANGEROUS_EXTRUDE
|
||||
allow_cold_extrude=allow;
|
||||
#endif
|
||||
#ifdef PREVENT_DANGEROUS_EXTRUDE
|
||||
allow_cold_extrude=allow;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
+206
-103
@@ -27,7 +27,6 @@
|
||||
#include "temperature.h"
|
||||
#include "ultralcd.h"
|
||||
#include "language.h"
|
||||
#include "led.h"
|
||||
#include "speed_lookuptable.h"
|
||||
|
||||
|
||||
@@ -36,8 +35,6 @@
|
||||
//=============================public variables ============================
|
||||
//===========================================================================
|
||||
block_t *current_block; // A pointer to the block currently being traced
|
||||
volatile bool endstop_z_hit=false;
|
||||
bool old_z_min_endstop=false;
|
||||
|
||||
|
||||
//===========================================================================
|
||||
@@ -67,11 +64,13 @@ volatile long endstops_trigsteps[3]={0,0,0};
|
||||
volatile long endstops_stepsTotal,endstops_stepsDone;
|
||||
static volatile bool endstop_x_hit=false;
|
||||
static volatile bool endstop_y_hit=false;
|
||||
static volatile bool endstop_z_hit=false;
|
||||
|
||||
static bool old_x_min_endstop=false;
|
||||
static bool old_x_max_endstop=false;
|
||||
static bool old_y_min_endstop=false;
|
||||
static bool old_y_max_endstop=false;
|
||||
static bool old_z_min_endstop=false;
|
||||
static bool old_z_max_endstop=false;
|
||||
|
||||
static bool check_endstops = true;
|
||||
@@ -215,6 +214,12 @@ void st_wake_up() {
|
||||
ENABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
}
|
||||
|
||||
void step_wait(){
|
||||
for(int8_t i=0; i < 6; i++){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) {
|
||||
unsigned short timer;
|
||||
if(step_rate > MAX_STEP_FREQUENCY) step_rate = MAX_STEP_FREQUENCY;
|
||||
@@ -262,12 +267,10 @@ FORCE_INLINE void trapezoid_generator_reset() {
|
||||
#endif
|
||||
deceleration_time = 0;
|
||||
// step_rate to timer interval
|
||||
OCR1A_nominal = calc_timer(current_block->nominal_rate);
|
||||
acc_step_rate = current_block->initial_rate;
|
||||
acceleration_time = calc_timer(acc_step_rate);
|
||||
OCR1A = acceleration_time;
|
||||
OCR1A_nominal = calc_timer(current_block->nominal_rate);
|
||||
|
||||
|
||||
|
||||
// SERIAL_ECHO_START;
|
||||
// SERIAL_ECHOPGM("advance :");
|
||||
@@ -320,8 +323,10 @@ ISR(TIMER1_COMPA_vect)
|
||||
out_bits = current_block->direction_bits;
|
||||
|
||||
// Set direction en check limit switches
|
||||
if ((out_bits & (1<<X_AXIS)) != 0) { // -direction
|
||||
WRITE(X_DIR_PIN, INVERT_X_DIR);
|
||||
if ((out_bits & (1<<X_AXIS)) != 0) { // stepping along -X axis
|
||||
#if !defined COREXY //NOT COREXY
|
||||
WRITE(X_DIR_PIN, INVERT_X_DIR);
|
||||
#endif
|
||||
count_direction[X_AXIS]=-1;
|
||||
CHECK_ENDSTOPS
|
||||
{
|
||||
@@ -336,8 +341,11 @@ ISR(TIMER1_COMPA_vect)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else { // +direction
|
||||
WRITE(X_DIR_PIN,!INVERT_X_DIR);
|
||||
else { // +direction
|
||||
#if !defined COREXY //NOT COREXY
|
||||
WRITE(X_DIR_PIN,!INVERT_X_DIR);
|
||||
#endif
|
||||
|
||||
count_direction[X_AXIS]=1;
|
||||
CHECK_ENDSTOPS
|
||||
{
|
||||
@@ -354,7 +362,9 @@ ISR(TIMER1_COMPA_vect)
|
||||
}
|
||||
|
||||
if ((out_bits & (1<<Y_AXIS)) != 0) { // -direction
|
||||
WRITE(Y_DIR_PIN,INVERT_Y_DIR);
|
||||
#if !defined COREXY //NOT COREXY
|
||||
WRITE(Y_DIR_PIN,INVERT_Y_DIR);
|
||||
#endif
|
||||
count_direction[Y_AXIS]=-1;
|
||||
CHECK_ENDSTOPS
|
||||
{
|
||||
@@ -370,7 +380,9 @@ ISR(TIMER1_COMPA_vect)
|
||||
}
|
||||
}
|
||||
else { // +direction
|
||||
WRITE(Y_DIR_PIN,!INVERT_Y_DIR);
|
||||
#if !defined COREXY //NOT COREXY
|
||||
WRITE(Y_DIR_PIN,!INVERT_Y_DIR);
|
||||
#endif
|
||||
count_direction[Y_AXIS]=1;
|
||||
CHECK_ENDSTOPS
|
||||
{
|
||||
@@ -385,9 +397,35 @@ ISR(TIMER1_COMPA_vect)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef COREXY //coreXY kinematics defined
|
||||
if((current_block->steps_x >= current_block->steps_y)&&((out_bits & (1<<X_AXIS)) == 0)){ //+X is major axis
|
||||
WRITE(X_DIR_PIN, !INVERT_X_DIR);
|
||||
WRITE(Y_DIR_PIN, !INVERT_Y_DIR);
|
||||
}
|
||||
if((current_block->steps_x >= current_block->steps_y)&&((out_bits & (1<<X_AXIS)) != 0)){ //-X is major axis
|
||||
WRITE(X_DIR_PIN, INVERT_X_DIR);
|
||||
WRITE(Y_DIR_PIN, INVERT_Y_DIR);
|
||||
}
|
||||
if((current_block->steps_y > current_block->steps_x)&&((out_bits & (1<<Y_AXIS)) == 0)){ //+Y is major axis
|
||||
WRITE(X_DIR_PIN, !INVERT_X_DIR);
|
||||
WRITE(Y_DIR_PIN, INVERT_Y_DIR);
|
||||
}
|
||||
if((current_block->steps_y > current_block->steps_x)&&((out_bits & (1<<Y_AXIS)) != 0)){ //-Y is major axis
|
||||
WRITE(X_DIR_PIN, INVERT_X_DIR);
|
||||
WRITE(Y_DIR_PIN, !INVERT_Y_DIR);
|
||||
}
|
||||
#endif //coreXY
|
||||
|
||||
|
||||
if ((out_bits & (1<<Z_AXIS)) != 0) { // -direction
|
||||
WRITE(Z_DIR_PIN,INVERT_Z_DIR);
|
||||
|
||||
#ifdef Z_DUAL_STEPPER_DRIVERS
|
||||
WRITE(Z2_DIR_PIN,INVERT_Z_DIR);
|
||||
#endif
|
||||
|
||||
count_direction[Z_AXIS]=-1;
|
||||
CHECK_ENDSTOPS
|
||||
{
|
||||
@@ -404,6 +442,11 @@ ISR(TIMER1_COMPA_vect)
|
||||
}
|
||||
else { // +direction
|
||||
WRITE(Z_DIR_PIN,!INVERT_Z_DIR);
|
||||
|
||||
#ifdef Z_DUAL_STEPPER_DRIVERS
|
||||
WRITE(Z2_DIR_PIN,!INVERT_Z_DIR);
|
||||
#endif
|
||||
|
||||
count_direction[Z_AXIS]=1;
|
||||
CHECK_ENDSTOPS
|
||||
{
|
||||
@@ -449,38 +492,97 @@ ISR(TIMER1_COMPA_vect)
|
||||
}
|
||||
}
|
||||
#endif //ADVANCE
|
||||
|
||||
#if !defined COREXY
|
||||
counter_x += current_block->steps_x;
|
||||
if (counter_x > 0) {
|
||||
WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
|
||||
counter_x -= current_block->step_event_count;
|
||||
count_position[X_AXIS]+=count_direction[X_AXIS];
|
||||
WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
|
||||
}
|
||||
|
||||
counter_y += current_block->steps_y;
|
||||
if (counter_y > 0) {
|
||||
WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
|
||||
counter_y -= current_block->step_event_count;
|
||||
count_position[Y_AXIS]+=count_direction[Y_AXIS];
|
||||
WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef COREXY
|
||||
counter_x += current_block->steps_x;
|
||||
counter_y += current_block->steps_y;
|
||||
|
||||
if ((counter_x > 0)&&!(counter_y>0)){ //X step only
|
||||
WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
|
||||
WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
|
||||
counter_x -= current_block->step_event_count;
|
||||
count_position[X_AXIS]+=count_direction[X_AXIS];
|
||||
WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
|
||||
WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
|
||||
}
|
||||
|
||||
if (!(counter_x > 0)&&(counter_y>0)){ //Y step only
|
||||
WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
|
||||
WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
|
||||
counter_y -= current_block->step_event_count;
|
||||
count_position[Y_AXIS]+=count_direction[Y_AXIS];
|
||||
WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
|
||||
WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
|
||||
}
|
||||
|
||||
if ((counter_x > 0)&&(counter_y>0)){ //step in both axes
|
||||
if (((out_bits & (1<<X_AXIS)) == 0)^((out_bits & (1<<Y_AXIS)) == 0)){ //X and Y in different directions
|
||||
WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
|
||||
counter_x -= current_block->step_event_count;
|
||||
WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
|
||||
step_wait();
|
||||
count_position[X_AXIS]+=count_direction[X_AXIS];
|
||||
count_position[Y_AXIS]+=count_direction[Y_AXIS];
|
||||
WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
|
||||
counter_y -= current_block->step_event_count;
|
||||
WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
|
||||
}
|
||||
else{ //X and Y in same direction
|
||||
WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
|
||||
counter_x -= current_block->step_event_count;
|
||||
WRITE(X_STEP_PIN, INVERT_X_STEP_PIN) ;
|
||||
step_wait();
|
||||
count_position[X_AXIS]+=count_direction[X_AXIS];
|
||||
count_position[Y_AXIS]+=count_direction[Y_AXIS];
|
||||
WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
|
||||
counter_y -= current_block->step_event_count;
|
||||
WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
|
||||
}
|
||||
}
|
||||
#endif //corexy
|
||||
|
||||
counter_x += current_block->steps_x;
|
||||
if (counter_x > 0) {
|
||||
WRITE(X_STEP_PIN, HIGH);
|
||||
counter_x -= current_block->step_event_count;
|
||||
WRITE(X_STEP_PIN, LOW);
|
||||
count_position[X_AXIS]+=count_direction[X_AXIS];
|
||||
}
|
||||
|
||||
counter_y += current_block->steps_y;
|
||||
if (counter_y > 0) {
|
||||
WRITE(Y_STEP_PIN, HIGH);
|
||||
counter_y -= current_block->step_event_count;
|
||||
WRITE(Y_STEP_PIN, LOW);
|
||||
count_position[Y_AXIS]+=count_direction[Y_AXIS];
|
||||
}
|
||||
|
||||
counter_z += current_block->steps_z;
|
||||
if (counter_z > 0) {
|
||||
WRITE(Z_STEP_PIN, HIGH);
|
||||
WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN);
|
||||
|
||||
#ifdef Z_DUAL_STEPPER_DRIVERS
|
||||
WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN);
|
||||
#endif
|
||||
|
||||
counter_z -= current_block->step_event_count;
|
||||
WRITE(Z_STEP_PIN, LOW);
|
||||
count_position[Z_AXIS]+=count_direction[Z_AXIS];
|
||||
WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN);
|
||||
|
||||
#ifdef Z_DUAL_STEPPER_DRIVERS
|
||||
WRITE(Z2_STEP_PIN, INVERT_Z_STEP_PIN);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef ADVANCE
|
||||
counter_e += current_block->steps_e;
|
||||
if (counter_e > 0) {
|
||||
WRITE_E_STEP(HIGH);
|
||||
WRITE_E_STEP(!INVERT_E_STEP_PIN);
|
||||
counter_e -= current_block->step_event_count;
|
||||
WRITE_E_STEP(LOW);
|
||||
count_position[E_AXIS]+=count_direction[E_AXIS];
|
||||
WRITE_E_STEP(INVERT_E_STEP_PIN);
|
||||
}
|
||||
#endif //!ADVANCE
|
||||
step_events_completed += 1;
|
||||
@@ -564,45 +666,45 @@ ISR(TIMER1_COMPA_vect)
|
||||
// Set E direction (Depends on E direction + advance)
|
||||
for(unsigned char i=0; i<4;i++) {
|
||||
if (e_steps[0] != 0) {
|
||||
WRITE(E0_STEP_PIN, LOW);
|
||||
WRITE(E0_STEP_PIN, INVERT_E_STEP_PIN);
|
||||
if (e_steps[0] < 0) {
|
||||
WRITE(E0_DIR_PIN, INVERT_E0_DIR);
|
||||
e_steps[0]++;
|
||||
WRITE(E0_STEP_PIN, HIGH);
|
||||
WRITE(E0_STEP_PIN, !INVERT_E_STEP_PIN);
|
||||
}
|
||||
else if (e_steps[0] > 0) {
|
||||
WRITE(E0_DIR_PIN, !INVERT_E0_DIR);
|
||||
e_steps[0]--;
|
||||
WRITE(E0_STEP_PIN, HIGH);
|
||||
WRITE(E0_STEP_PIN, !INVERT_E_STEP_PIN);
|
||||
}
|
||||
}
|
||||
#if EXTRUDERS > 1
|
||||
if (e_steps[1] != 0) {
|
||||
WRITE(E1_STEP_PIN, LOW);
|
||||
WRITE(E1_STEP_PIN, INVERT_E_STEP_PIN);
|
||||
if (e_steps[1] < 0) {
|
||||
WRITE(E1_DIR_PIN, INVERT_E1_DIR);
|
||||
e_steps[1]++;
|
||||
WRITE(E1_STEP_PIN, HIGH);
|
||||
WRITE(E1_STEP_PIN, !INVERT_E_STEP_PIN);
|
||||
}
|
||||
else if (e_steps[1] > 0) {
|
||||
WRITE(E1_DIR_PIN, !INVERT_E1_DIR);
|
||||
e_steps[1]--;
|
||||
WRITE(E1_STEP_PIN, HIGH);
|
||||
WRITE(E1_STEP_PIN, !INVERT_E_STEP_PIN);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if EXTRUDERS > 2
|
||||
if (e_steps[2] != 0) {
|
||||
WRITE(E2_STEP_PIN, LOW);
|
||||
WRITE(E2_STEP_PIN, INVERT_E_STEP_PIN);
|
||||
if (e_steps[2] < 0) {
|
||||
WRITE(E2_DIR_PIN, INVERT_E2_DIR);
|
||||
e_steps[2]++;
|
||||
WRITE(E2_STEP_PIN, HIGH);
|
||||
WRITE(E2_STEP_PIN, !INVERT_E_STEP_PIN);
|
||||
}
|
||||
else if (e_steps[2] > 0) {
|
||||
WRITE(E2_DIR_PIN, !INVERT_E2_DIR);
|
||||
e_steps[2]--;
|
||||
WRITE(E2_STEP_PIN, HIGH);
|
||||
WRITE(E2_STEP_PIN, !INVERT_E_STEP_PIN);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -621,6 +723,10 @@ void st_init()
|
||||
#endif
|
||||
#if Z_DIR_PIN > -1
|
||||
SET_OUTPUT(Z_DIR_PIN);
|
||||
|
||||
#if defined(Z_DUAL_STEPPER_DRIVERS) && (Z2_DIR_PIN > -1)
|
||||
SET_OUTPUT(Z2_DIR_PIN);
|
||||
#endif
|
||||
#endif
|
||||
#if E0_DIR_PIN > -1
|
||||
SET_OUTPUT(E0_DIR_PIN);
|
||||
@@ -645,6 +751,11 @@ void st_init()
|
||||
#if (Z_ENABLE_PIN > -1)
|
||||
SET_OUTPUT(Z_ENABLE_PIN);
|
||||
if(!Z_ENABLE_ON) WRITE(Z_ENABLE_PIN,HIGH);
|
||||
|
||||
#if defined(Z_DUAL_STEPPER_DRIVERS) && (Z2_ENABLE_PIN > -1)
|
||||
SET_OUTPUT(Z2_ENABLE_PIN);
|
||||
if(!Z_ENABLE_ON) WRITE(Z2_ENABLE_PIN,HIGH);
|
||||
#endif
|
||||
#endif
|
||||
#if (E0_ENABLE_PIN > -1)
|
||||
SET_OUTPUT(E0_ENABLE_PIN);
|
||||
@@ -660,89 +771,86 @@ void st_init()
|
||||
#endif
|
||||
|
||||
//endstops and pullups
|
||||
#ifdef ENDSTOPPULLUPS
|
||||
#if X_MIN_PIN > -1
|
||||
SET_INPUT(X_MIN_PIN);
|
||||
|
||||
#if X_MIN_PIN > -1
|
||||
SET_INPUT(X_MIN_PIN);
|
||||
#ifdef ENDSTOPPULLUP_XMIN
|
||||
WRITE(X_MIN_PIN,HIGH);
|
||||
#endif
|
||||
#if X_MAX_PIN > -1
|
||||
SET_INPUT(X_MAX_PIN);
|
||||
WRITE(X_MAX_PIN,HIGH);
|
||||
#endif
|
||||
#if Y_MIN_PIN > -1
|
||||
SET_INPUT(Y_MIN_PIN);
|
||||
#endif
|
||||
|
||||
#if Y_MIN_PIN > -1
|
||||
SET_INPUT(Y_MIN_PIN);
|
||||
#ifdef ENDSTOPPULLUP_YMIN
|
||||
WRITE(Y_MIN_PIN,HIGH);
|
||||
#endif
|
||||
#if Y_MAX_PIN > -1
|
||||
SET_INPUT(Y_MAX_PIN);
|
||||
WRITE(Y_MAX_PIN,HIGH);
|
||||
#endif
|
||||
#if Z_MIN_PIN > -1
|
||||
SET_INPUT(Z_MIN_PIN);
|
||||
#endif
|
||||
|
||||
#if Z_MIN_PIN > -1
|
||||
SET_INPUT(Z_MIN_PIN);
|
||||
#ifdef ENDSTOPPULLUP_ZMIN
|
||||
WRITE(Z_MIN_PIN,HIGH);
|
||||
#endif
|
||||
#if Z_MAX_PIN > -1
|
||||
SET_INPUT(Z_MAX_PIN);
|
||||
#endif
|
||||
|
||||
#if X_MAX_PIN > -1
|
||||
SET_INPUT(X_MAX_PIN);
|
||||
#ifdef ENDSTOPPULLUP_XMAX
|
||||
WRITE(X_MAX_PIN,HIGH);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if Y_MAX_PIN > -1
|
||||
SET_INPUT(Y_MAX_PIN);
|
||||
#ifdef ENDSTOPPULLUP_YMAX
|
||||
WRITE(Y_MAX_PIN,HIGH);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if Z_MAX_PIN > -1
|
||||
SET_INPUT(Z_MAX_PIN);
|
||||
#ifdef ENDSTOPPULLUP_ZMAX
|
||||
WRITE(Z_MAX_PIN,HIGH);
|
||||
#endif
|
||||
#else //ENDSTOPPULLUPS
|
||||
#if X_MIN_PIN > -1
|
||||
SET_INPUT(X_MIN_PIN);
|
||||
#endif
|
||||
#if X_MAX_PIN > -1
|
||||
SET_INPUT(X_MAX_PIN);
|
||||
#endif
|
||||
#if Y_MIN_PIN > -1
|
||||
SET_INPUT(Y_MIN_PIN);
|
||||
#endif
|
||||
#if Y_MAX_PIN > -1
|
||||
SET_INPUT(Y_MAX_PIN);
|
||||
#endif
|
||||
#if Z_MIN_PIN > -1
|
||||
SET_INPUT(Z_MIN_PIN);
|
||||
#endif
|
||||
#if Z_MAX_PIN > -1
|
||||
SET_INPUT(Z_MAX_PIN);
|
||||
#endif
|
||||
#endif //ENDSTOPPULLUPS
|
||||
#endif
|
||||
|
||||
|
||||
//Initialize Step Pins
|
||||
#if (X_STEP_PIN > -1)
|
||||
SET_OUTPUT(X_STEP_PIN);
|
||||
#if X_ENABLE_PIN > -1
|
||||
if(!X_ENABLE_ON) WRITE(X_ENABLE_PIN,HIGH);
|
||||
#endif
|
||||
WRITE(X_STEP_PIN,INVERT_X_STEP_PIN);
|
||||
if(!X_ENABLE_ON) WRITE(X_ENABLE_PIN,HIGH);
|
||||
#endif
|
||||
#if (Y_STEP_PIN > -1)
|
||||
SET_OUTPUT(Y_STEP_PIN);
|
||||
#if Y_ENABLE_PIN > -1
|
||||
if(!Y_ENABLE_ON) WRITE(Y_ENABLE_PIN,HIGH);
|
||||
#endif
|
||||
WRITE(Y_STEP_PIN,INVERT_Y_STEP_PIN);
|
||||
if(!Y_ENABLE_ON) WRITE(Y_ENABLE_PIN,HIGH);
|
||||
#endif
|
||||
#if (Z_STEP_PIN > -1)
|
||||
SET_OUTPUT(Z_STEP_PIN);
|
||||
#if Z_ENABLE_PIN > -1
|
||||
if(!Z_ENABLE_ON) WRITE(Z_ENABLE_PIN,HIGH);
|
||||
WRITE(Z_STEP_PIN,INVERT_Z_STEP_PIN);
|
||||
if(!Z_ENABLE_ON) WRITE(Z_ENABLE_PIN,HIGH);
|
||||
|
||||
#if defined(Z_DUAL_STEPPER_DRIVERS) && (Z2_STEP_PIN > -1)
|
||||
SET_OUTPUT(Z2_STEP_PIN);
|
||||
WRITE(Z2_STEP_PIN,INVERT_Z_STEP_PIN);
|
||||
if(!Z_ENABLE_ON) WRITE(Z2_ENABLE_PIN,HIGH);
|
||||
#endif
|
||||
#endif
|
||||
#if (E0_STEP_PIN > -1)
|
||||
SET_OUTPUT(E0_STEP_PIN);
|
||||
#if E0_ENABLE_PIN > -1
|
||||
if(!E_ENABLE_ON) WRITE(E0_ENABLE_PIN,HIGH);
|
||||
#endif
|
||||
WRITE(E0_STEP_PIN,INVERT_E_STEP_PIN);
|
||||
if(!E_ENABLE_ON) WRITE(E0_ENABLE_PIN,HIGH);
|
||||
#endif
|
||||
#if defined(E1_STEP_PIN) && (E1_STEP_PIN > -1)
|
||||
SET_OUTPUT(E1_STEP_PIN);
|
||||
#if E1_ENABLE_PIN > -1
|
||||
if(!E_ENABLE_ON) WRITE(E1_ENABLE_PIN,HIGH);
|
||||
#endif
|
||||
WRITE(E1_STEP_PIN,INVERT_E_STEP_PIN);
|
||||
if(!E_ENABLE_ON) WRITE(E1_ENABLE_PIN,HIGH);
|
||||
#endif
|
||||
#if defined(E2_STEP_PIN) && (E2_STEP_PIN > -1)
|
||||
SET_OUTPUT(E2_STEP_PIN);
|
||||
#if E2_ENABLE_PIN > -1
|
||||
if(!E_ENABLE_ON) WRITE(E2_ENABLE_PIN,HIGH);
|
||||
#endif
|
||||
WRITE(E2_STEP_PIN,INVERT_E_STEP_PIN);
|
||||
if(!E_ENABLE_ON) WRITE(E2_ENABLE_PIN,HIGH);
|
||||
#endif
|
||||
|
||||
#ifdef CONTROLLERFAN_PIN
|
||||
@@ -781,12 +889,7 @@ void st_init()
|
||||
TIMSK0 |= (1<<OCIE0A);
|
||||
#endif //ADVANCE
|
||||
|
||||
#ifdef ENDSTOPS_ONLY_FOR_HOMING
|
||||
enable_endstops(false);
|
||||
#else
|
||||
enable_endstops(true);
|
||||
#endif
|
||||
|
||||
enable_endstops(true); // Start with endstops active. After homing they can be disabled
|
||||
sei();
|
||||
}
|
||||
|
||||
@@ -796,7 +899,7 @@ void st_synchronize()
|
||||
{
|
||||
while( blocks_queued()) {
|
||||
manage_heater();
|
||||
manage_inactivity(1);
|
||||
manage_inactivity();
|
||||
LCD_STATUS;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-4
@@ -25,7 +25,7 @@
|
||||
|
||||
#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 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); }}
|
||||
@@ -66,9 +66,6 @@ void checkStepperErrors(); //Print errors detected by the stepper
|
||||
void finishAndDisableSteppers();
|
||||
|
||||
extern block_t *current_block; // A pointer to the block currently being traced
|
||||
extern volatile long endstops_trigsteps[];
|
||||
extern volatile bool endstop_z_hit;
|
||||
extern bool old_z_min_endstop;
|
||||
|
||||
void quickStop();
|
||||
#endif
|
||||
|
||||
+158
-71
@@ -51,13 +51,21 @@ int current_raw_bed = 0;
|
||||
float pid_setpoint[EXTRUDERS] = { 0.0 };
|
||||
|
||||
float Kp=DEFAULT_Kp;
|
||||
float Ki=DEFAULT_Ki;
|
||||
int Ki_Max=PID_INTEGRAL_DRIVE_MAX;
|
||||
float Kd=DEFAULT_Kd;
|
||||
float Ki=(DEFAULT_Ki*PID_dT);
|
||||
float Kd=(DEFAULT_Kd/PID_dT);
|
||||
#ifdef PID_ADD_EXTRUSION_RATE
|
||||
float Kc=DEFAULT_Kc;
|
||||
#endif
|
||||
#endif //PIDTEMP
|
||||
|
||||
#ifdef PIDTEMPBED
|
||||
// used external
|
||||
float pid_setpoint_bed = { 0.0 };
|
||||
|
||||
float bedKp=DEFAULT_bedKp;
|
||||
float bedKi=(DEFAULT_bedKi*PID_dT);
|
||||
float bedKd=(DEFAULT_bedKd/PID_dT);
|
||||
#endif //PIDTEMPBED
|
||||
|
||||
|
||||
//===========================================================================
|
||||
@@ -65,9 +73,6 @@ int current_raw_bed = 0;
|
||||
//===========================================================================
|
||||
static volatile bool temp_meas_ready = false;
|
||||
|
||||
static unsigned long previous_millis_bed_heater;
|
||||
//static unsigned long previous_millis_heater;
|
||||
|
||||
#ifdef PIDTEMP
|
||||
//static cannot be external:
|
||||
static float temp_iState[EXTRUDERS] = { 0 };
|
||||
@@ -83,7 +88,22 @@ static unsigned long previous_millis_bed_heater;
|
||||
// static float pid_output[EXTRUDERS];
|
||||
static bool pid_reset[EXTRUDERS];
|
||||
#endif //PIDTEMP
|
||||
#ifdef PIDTEMPBED
|
||||
//static cannot be external:
|
||||
static float temp_iState_bed = { 0 };
|
||||
static float temp_dState_bed = { 0 };
|
||||
static float pTerm_bed;
|
||||
static float iTerm_bed;
|
||||
static float dTerm_bed;
|
||||
//int output;
|
||||
static float pid_error_bed;
|
||||
static float temp_iState_min_bed;
|
||||
static float temp_iState_max_bed;
|
||||
#else //PIDTEMPBED
|
||||
static unsigned long previous_millis_bed_heater;
|
||||
#endif //PIDTEMPBED
|
||||
static unsigned char soft_pwm[EXTRUDERS];
|
||||
static unsigned char soft_pwm_bed;
|
||||
|
||||
#ifdef WATCHPERIOD
|
||||
int watch_raw[EXTRUDERS] = { -1000 }; // the first value used for all
|
||||
@@ -123,44 +143,67 @@ static unsigned long previous_millis_bed_heater;
|
||||
//============================= functions ============================
|
||||
//===========================================================================
|
||||
|
||||
void PID_autotune(float temp)
|
||||
void PID_autotune(float temp, int extruder, int ncycles)
|
||||
{
|
||||
float input;
|
||||
float input = 0.0;
|
||||
int cycles=0;
|
||||
bool heating = true;
|
||||
|
||||
unsigned long temp_millis = millis();
|
||||
unsigned long t1=temp_millis;
|
||||
unsigned long t2=temp_millis;
|
||||
long t_high;
|
||||
long t_low;
|
||||
long t_high = 0;
|
||||
long t_low = 0;
|
||||
|
||||
long bias=PID_MAX/2;
|
||||
long d = PID_MAX/2;
|
||||
long bias, d;
|
||||
float Ku, Tu;
|
||||
float Kp, Ki, Kd;
|
||||
float max, min;
|
||||
|
||||
float max = 0, min = 10000;
|
||||
|
||||
if ((extruder > EXTRUDERS)
|
||||
#if (TEMP_BED_PIN <= -1)
|
||||
||(extruder < 0)
|
||||
#endif
|
||||
){
|
||||
SERIAL_ECHOLN("PID Autotune failed. Bad extruder number.");
|
||||
return;
|
||||
}
|
||||
|
||||
SERIAL_ECHOLN("PID Autotune start");
|
||||
|
||||
disable_heater(); // switch off all heaters.
|
||||
|
||||
soft_pwm[0] = PID_MAX/2;
|
||||
|
||||
for(;;) {
|
||||
|
||||
if (extruder<0)
|
||||
{
|
||||
soft_pwm_bed = (MAX_BED_POWER)/2;
|
||||
bias = d = (MAX_BED_POWER)/2;
|
||||
}
|
||||
else
|
||||
{
|
||||
soft_pwm[extruder] = (PID_MAX)/2;
|
||||
bias = d = (PID_MAX)/2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
for(;;) {
|
||||
|
||||
if(temp_meas_ready == true) { // temp sample ready
|
||||
CRITICAL_SECTION_START;
|
||||
temp_meas_ready = false;
|
||||
CRITICAL_SECTION_END;
|
||||
input = analog2temp(current_raw[0], 0);
|
||||
|
||||
input = (extruder<0)?analog2tempBed(current_raw_bed):analog2temp(current_raw[extruder], extruder);
|
||||
|
||||
max=max(max,input);
|
||||
min=min(min,input);
|
||||
if(heating == true && input > temp) {
|
||||
if(millis() - t2 > 5000) {
|
||||
heating=false;
|
||||
soft_pwm[0] = (bias - d) >> 1;
|
||||
if (extruder<0)
|
||||
soft_pwm_bed = (bias - d) >> 1;
|
||||
else
|
||||
soft_pwm[extruder] = (bias - d) >> 1;
|
||||
t1=millis();
|
||||
t_high=t1 - t2;
|
||||
max=temp;
|
||||
@@ -173,8 +216,8 @@ void PID_autotune(float temp)
|
||||
t_low=t2 - t1;
|
||||
if(cycles > 0) {
|
||||
bias += (d*(t_high - t_low))/(t_low + t_high);
|
||||
bias = constrain(bias, 20 ,PID_MAX-FULL_PID_BAND);
|
||||
if(bias > PID_MAX/2) d = PID_MAX - 1 - bias;
|
||||
bias = constrain(bias, 20 ,(extruder<0?(MAX_BED_POWER):(PID_MAX))-20);
|
||||
if(bias > (extruder<0?(MAX_BED_POWER):(PID_MAX))/2) d = (extruder<0?(MAX_BED_POWER):(PID_MAX)) - 1 - bias;
|
||||
else d = bias;
|
||||
|
||||
SERIAL_PROTOCOLPGM(" bias: "); SERIAL_PROTOCOL(bias);
|
||||
@@ -211,7 +254,10 @@ void PID_autotune(float temp)
|
||||
*/
|
||||
}
|
||||
}
|
||||
soft_pwm[0] = (bias + d) >> 1;
|
||||
if (extruder<0)
|
||||
soft_pwm_bed = (bias + d) >> 1;
|
||||
else
|
||||
soft_pwm[extruder] = (bias + d) >> 1;
|
||||
cycles++;
|
||||
min=temp;
|
||||
}
|
||||
@@ -222,17 +268,26 @@ void PID_autotune(float temp)
|
||||
return;
|
||||
}
|
||||
if(millis() - temp_millis > 2000) {
|
||||
temp_millis = millis();
|
||||
SERIAL_PROTOCOLPGM("ok T:");
|
||||
SERIAL_PROTOCOL(degHotend(0));
|
||||
int p;
|
||||
if (extruder<0){
|
||||
p=soft_pwm_bed;
|
||||
SERIAL_PROTOCOLPGM("ok B:");
|
||||
}else{
|
||||
p=soft_pwm[extruder];
|
||||
SERIAL_PROTOCOLPGM("ok T:");
|
||||
}
|
||||
|
||||
SERIAL_PROTOCOL(input);
|
||||
SERIAL_PROTOCOLPGM(" @:");
|
||||
SERIAL_PROTOCOLLN(getHeaterPower(0));
|
||||
SERIAL_PROTOCOLLN(p);
|
||||
|
||||
temp_millis = millis();
|
||||
}
|
||||
if(((millis() - t1) + (millis() - t2)) > (10L*60L*1000L*2L)) {
|
||||
SERIAL_PROTOCOLLNPGM("PID Autotune failed! timeout");
|
||||
return;
|
||||
}
|
||||
if(cycles > 5) {
|
||||
if(cycles > ncycles) {
|
||||
SERIAL_PROTOCOLLNPGM("PID Autotune finished ! Place the Kp, Ki and Kd constants in the configuration.h");
|
||||
return;
|
||||
}
|
||||
@@ -244,27 +299,31 @@ void updatePID()
|
||||
{
|
||||
#ifdef PIDTEMP
|
||||
for(int e = 0; e < EXTRUDERS; e++) {
|
||||
temp_iState_max[e] = Ki_Max / Ki;
|
||||
temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki;
|
||||
}
|
||||
#endif
|
||||
#ifdef PIDTEMPBED
|
||||
temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / bedKi;
|
||||
#endif
|
||||
}
|
||||
|
||||
int getHeaterPower(int heater) {
|
||||
if (heater<0)
|
||||
return soft_pwm_bed;
|
||||
return soft_pwm[heater];
|
||||
}
|
||||
|
||||
void manage_heater()
|
||||
{
|
||||
#ifdef USE_WATCHDOG
|
||||
wd_reset();
|
||||
#endif
|
||||
|
||||
float pid_input;
|
||||
float pid_output;
|
||||
|
||||
if(temp_meas_ready != true) //better readability
|
||||
return;
|
||||
|
||||
//Reset the watchdog after we know we have a temperature measurement.
|
||||
watchdog_reset();
|
||||
|
||||
CRITICAL_SECTION_START;
|
||||
temp_meas_ready = false;
|
||||
CRITICAL_SECTION_END;
|
||||
@@ -277,11 +336,11 @@ void manage_heater()
|
||||
|
||||
#ifndef PID_OPENLOOP
|
||||
pid_error[e] = pid_setpoint[e] - pid_input;
|
||||
if(pid_error[e] > FULL_PID_BAND) {
|
||||
if(pid_error[e] > 10) {
|
||||
pid_output = PID_MAX;
|
||||
pid_reset[e] = true;
|
||||
}
|
||||
else if(pid_error[e] < -FULL_PID_BAND) {
|
||||
else if(pid_error[e] < -10) {
|
||||
pid_output = 0;
|
||||
pid_reset[e] = true;
|
||||
}
|
||||
@@ -294,12 +353,16 @@ void manage_heater()
|
||||
temp_iState[e] += pid_error[e];
|
||||
temp_iState[e] = constrain(temp_iState[e], temp_iState_min[e], temp_iState_max[e]);
|
||||
iTerm[e] = Ki * temp_iState[e];
|
||||
|
||||
//K1 defined in Configuration.h in the PID settings
|
||||
#define K2 (1.0-K1)
|
||||
dTerm[e] = (Kd * (pid_input - temp_dState[e]))*K2 + (K1 * dTerm[e]);
|
||||
temp_dState[e] = pid_input;
|
||||
|
||||
pid_output = constrain(pTerm[e] + iTerm[e] - dTerm[e], 0, PID_MAX);
|
||||
}
|
||||
#else
|
||||
pid_output = constrain(pid_setpoint[e], 0, PID_MAX);
|
||||
#endif //PID_OPENLOOP
|
||||
#ifdef PID_DEBUG
|
||||
SERIAL_ECHOLN(" PIDDEBUG "<<e<<": Input "<<pid_input<<" Output "<<pid_output" pTerm "<<pTerm[e]<<" iTerm "<<iTerm[e]<<" dTerm "<<dTerm[e]);
|
||||
@@ -334,25 +397,58 @@ void manage_heater()
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef PIDTEMPBED
|
||||
if(millis() - previous_millis_bed_heater < BED_CHECK_INTERVAL)
|
||||
return;
|
||||
previous_millis_bed_heater = millis();
|
||||
|
||||
#endif
|
||||
|
||||
#if TEMP_BED_PIN > -1
|
||||
|
||||
#ifndef BED_LIMIT_SWITCHING
|
||||
#ifdef PIDTEMPBED
|
||||
pid_input = analog2tempBed(current_raw_bed);
|
||||
|
||||
#ifndef PID_OPENLOOP
|
||||
pid_error_bed = pid_setpoint_bed - pid_input;
|
||||
pTerm_bed = bedKp * pid_error_bed;
|
||||
temp_iState_bed += pid_error_bed;
|
||||
temp_iState_bed = constrain(temp_iState_bed, temp_iState_min_bed, temp_iState_max_bed);
|
||||
iTerm_bed = bedKi * temp_iState_bed;
|
||||
|
||||
//K1 defined in Configuration.h in the PID settings
|
||||
#define K2 (1.0-K1)
|
||||
dTerm_bed= (bedKd * (pid_input - temp_dState_bed))*K2 + (K1 * dTerm_bed);
|
||||
temp_dState_bed = pid_input;
|
||||
|
||||
pid_output = constrain(pTerm_bed + iTerm_bed - dTerm_bed, 0, MAX_BED_POWER);
|
||||
|
||||
#else
|
||||
pid_output = constrain(pid_setpoint_bed, 0, MAX_BED_POWER);
|
||||
#endif //PID_OPENLOOP
|
||||
|
||||
if((current_raw_bed > bed_minttemp) && (current_raw_bed < bed_maxttemp))
|
||||
{
|
||||
soft_pwm_bed = (int)pid_output >> 1;
|
||||
}
|
||||
else {
|
||||
soft_pwm_bed = 0;
|
||||
}
|
||||
|
||||
#elif not defined BED_LIMIT_SWITCHING
|
||||
// Check if temperature is within the correct range
|
||||
if((current_raw_bed > bed_minttemp) && (current_raw_bed < bed_maxttemp)) {
|
||||
if(current_raw_bed >= target_raw_bed)
|
||||
{
|
||||
WRITE(HEATER_BED_PIN,LOW);
|
||||
soft_pwm_bed = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITE(HEATER_BED_PIN,HIGH);
|
||||
soft_pwm_bed = MAX_BED_POWER>>1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
soft_pwm_bed = 0;
|
||||
WRITE(HEATER_BED_PIN,LOW);
|
||||
}
|
||||
#else //#ifdef BED_LIMIT_SWITCHING
|
||||
@@ -360,15 +456,16 @@ void manage_heater()
|
||||
if((current_raw_bed > bed_minttemp) && (current_raw_bed < bed_maxttemp)) {
|
||||
if(current_raw_bed > target_bed_high_temp)
|
||||
{
|
||||
WRITE(HEATER_BED_PIN,LOW);
|
||||
soft_pwm_bed = 0;
|
||||
}
|
||||
else
|
||||
if(current_raw_bed <= target_bed_low_temp)
|
||||
{
|
||||
WRITE(HEATER_BED_PIN,HIGH);
|
||||
soft_pwm_bed = MAX_BED_POWER>>1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
soft_pwm_bed = 0;
|
||||
WRITE(HEATER_BED_PIN,LOW);
|
||||
}
|
||||
#endif
|
||||
@@ -376,30 +473,6 @@ void manage_heater()
|
||||
}
|
||||
|
||||
#define PGM_RD_W(x) (short)pgm_read_word(&x)
|
||||
|
||||
#ifdef COMPUTE_THERMISTORS
|
||||
// Use algebra to work out temperatures, not tables
|
||||
// NB - this assumes all extruders use the same thermistor type.
|
||||
int temp2analogi(int celsius, const float& beta, const float& rs, const float& r_inf)
|
||||
{
|
||||
float r = r_inf*exp(beta/(celsius - ABS_ZERO));
|
||||
return AD_RANGE - (int)(0.5 + AD_RANGE*r/(r + rs));
|
||||
}
|
||||
|
||||
float analog2tempi(int raw, const float& beta, const float& rs, const float& r_inf)
|
||||
{
|
||||
float rawf = (float)(AD_RANGE - raw);
|
||||
return ABS_ZERO + beta/log( (rawf*rs/(AD_RANGE - rawf))/r_inf );
|
||||
}
|
||||
|
||||
int temp2analog(int celsius, uint8_t e) { return temp2analogi(celsius, E_BETA, E_RS, E_R_INF); }
|
||||
int temp2analogBed(int celsius) { return temp2analogi(celsius, BED_BETA, BED_RS, BED_R_INF); }
|
||||
float analog2temp(int raw, uint8_t e) { return analog2tempi(raw, E_BETA, E_RS, E_R_INF); }
|
||||
float analog2tempBed(int raw) { return analog2tempi(raw, BED_BETA, BED_RS, BED_R_INF); }
|
||||
|
||||
#else
|
||||
|
||||
|
||||
// Takes hot end temperature value as input and returns corresponding raw value.
|
||||
// For a thermistor, it uses the RepRap thermistor temp table.
|
||||
// This is needed because PID in hydra firmware hovers around a given analog value, not a temp value.
|
||||
@@ -473,7 +546,6 @@ int temp2analogBed(int celsius) {
|
||||
#elif defined BED_USES_AD595
|
||||
return lround(((celsius-TEMP_SENSOR_AD595_OFFSET)/TEMP_SENSOR_AD595_GAIN) * (1024.0 * OVERSAMPLENR/ (5.0 * 100.0) ) );
|
||||
#else
|
||||
#warning No heater-type defined for the bed.
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
@@ -550,13 +622,10 @@ float analog2tempBed(int raw) {
|
||||
#elif defined BED_USES_AD595
|
||||
return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET;
|
||||
#else
|
||||
#warning No heater-type defined for the bed.
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void tp_init()
|
||||
{
|
||||
// Finish init of mult extruder arrays
|
||||
@@ -568,8 +637,12 @@ void tp_init()
|
||||
maxttemp[e] = maxttemp[0];
|
||||
#ifdef PIDTEMP
|
||||
temp_iState_min[e] = 0.0;
|
||||
temp_iState_max[e] = Ki_Max / Ki;
|
||||
temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki;
|
||||
#endif //PIDTEMP
|
||||
#ifdef PIDTEMPBED
|
||||
temp_iState_min_bed = 0.0;
|
||||
temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / bedKi;
|
||||
#endif //PIDTEMPBED
|
||||
}
|
||||
|
||||
#if (HEATER_0_PIN > -1)
|
||||
@@ -586,6 +659,9 @@ void tp_init()
|
||||
#endif
|
||||
#if (FAN_PIN > -1)
|
||||
SET_OUTPUT(FAN_PIN);
|
||||
#ifdef FAST_PWM_FAN
|
||||
setPwmFrequency(FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HEATER_0_USES_MAX6675
|
||||
@@ -727,6 +803,7 @@ void disable_heater()
|
||||
|
||||
#if TEMP_BED_PIN > -1
|
||||
target_raw_bed=0;
|
||||
soft_pwm_bed=0;
|
||||
#if HEATER_BED_PIN > -1
|
||||
WRITE(HEATER_BED_PIN,LOW);
|
||||
#endif
|
||||
@@ -831,6 +908,7 @@ ISR(TIMER0_COMPB_vect)
|
||||
static unsigned char soft_pwm_0;
|
||||
static unsigned char soft_pwm_1;
|
||||
static unsigned char soft_pwm_2;
|
||||
static unsigned char soft_pwm_b;
|
||||
|
||||
if(pwm_count == 0){
|
||||
soft_pwm_0 = soft_pwm[0];
|
||||
@@ -843,6 +921,10 @@ ISR(TIMER0_COMPB_vect)
|
||||
soft_pwm_2 = soft_pwm[2];
|
||||
if(soft_pwm_2 > 0) WRITE(HEATER_2_PIN,1);
|
||||
#endif
|
||||
#if HEATER_BED_PIN > -1
|
||||
soft_pwm_b = soft_pwm_bed;
|
||||
if(soft_pwm_b > 0) WRITE(HEATER_BED_PIN,1);
|
||||
#endif
|
||||
}
|
||||
if(soft_pwm_0 <= pwm_count) WRITE(HEATER_0_PIN,0);
|
||||
#if EXTRUDERS > 1
|
||||
@@ -851,6 +933,9 @@ ISR(TIMER0_COMPB_vect)
|
||||
#if EXTRUDERS > 2
|
||||
if(soft_pwm_2 <= pwm_count) WRITE(HEATER_2_PIN,0);
|
||||
#endif
|
||||
#if HEATER_BED_PIN > -1
|
||||
if(soft_pwm_b <= pwm_count) WRITE(HEATER_BED_PIN,0);
|
||||
#endif
|
||||
|
||||
pwm_count++;
|
||||
pwm_count &= 0x7f;
|
||||
@@ -884,6 +969,8 @@ ISR(TIMER0_COMPB_vect)
|
||||
#if (TEMP_BED_PIN > -1)
|
||||
#if TEMP_BED_PIN > 7
|
||||
ADCSRB = 1<<MUX5;
|
||||
#else
|
||||
ADCSRB = 0;
|
||||
#endif
|
||||
ADMUX = ((1 << REFS0) | (TEMP_BED_PIN & 0x07));
|
||||
ADCSRA |= 1<<ADSC; // Start conversion
|
||||
|
||||
+167
-162
@@ -1,170 +1,175 @@
|
||||
/*
|
||||
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 "planner.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;
|
||||
#ifdef BED_LIMIT_SWITCHING
|
||||
extern int target_bed_low_temp ;
|
||||
extern int target_bed_high_temp ;
|
||||
#endif
|
||||
extern float Kp,Ki,Kd,Kc;
|
||||
extern int Ki_Max;
|
||||
|
||||
#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);
|
||||
#ifdef BED_LIMIT_SWITCHING
|
||||
if(celsius>BED_HYSTERESIS)
|
||||
{
|
||||
target_bed_low_temp= temp2analogBed(celsius-BED_HYSTERESIS);
|
||||
target_bed_high_temp= temp2analogBed(celsius+BED_HYSTERESIS);
|
||||
}
|
||||
else
|
||||
{
|
||||
target_bed_low_temp=0;
|
||||
target_bed_high_temp=0;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
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)
|
||||
/*
|
||||
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 "planner.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;
|
||||
#ifdef BED_LIMIT_SWITCHING
|
||||
extern int target_bed_low_temp ;
|
||||
extern int target_bed_high_temp ;
|
||||
#endif
|
||||
|
||||
#ifdef PIDTEMP
|
||||
extern float Kp,Ki,Kd,Kc;
|
||||
extern float pid_setpoint[EXTRUDERS];
|
||||
#endif
|
||||
#ifdef PIDTEMPBED
|
||||
extern float bedKp,bedKi,bedKd;
|
||||
extern float pid_setpoint_bed;
|
||||
#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);
|
||||
#ifdef PIDTEMPBED
|
||||
pid_setpoint_bed = celsius;
|
||||
#elif defined BED_LIMIT_SWITCHING
|
||||
if(celsius>BED_HYSTERESIS)
|
||||
{
|
||||
target_bed_low_temp= temp2analogBed(celsius-BED_HYSTERESIS);
|
||||
target_bed_high_temp= temp2analogBed(celsius+BED_HYSTERESIS);
|
||||
}
|
||||
else
|
||||
{
|
||||
target_bed_low_temp=0;
|
||||
target_bed_high_temp=0;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
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)
|
||||
#else
|
||||
#define setTargetHotend1(_celsius) do{}while(0)
|
||||
#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 > 2
|
||||
#define degHotend2() degHotend(2)
|
||||
#define degTargetHotend2() degTargetHotend(2)
|
||||
#define setTargetHotend2(_celsius) setTargetHotend((_celsius), 2)
|
||||
#define isHeatingHotend2() isHeatingHotend(2)
|
||||
#define isCoolingHotend2() isCoolingHotend(2)
|
||||
#else
|
||||
#define setTargetHotend2(_celsius) do{}while(0)
|
||||
#endif
|
||||
#if EXTRUDERS > 3
|
||||
#error Invalid number of extruders
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
int getHeaterPower(int heater);
|
||||
void disable_heater();
|
||||
void setWatch();
|
||||
void updatePID();
|
||||
|
||||
FORCE_INLINE void autotempShutdown(){
|
||||
#ifdef AUTOTEMP
|
||||
if(autotemp_enabled)
|
||||
{
|
||||
autotemp_enabled=false;
|
||||
#endif
|
||||
#if EXTRUDERS > 3
|
||||
#error Invalid number of extruders
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
int getHeaterPower(int heater);
|
||||
void disable_heater();
|
||||
void setWatch();
|
||||
void updatePID();
|
||||
|
||||
FORCE_INLINE void autotempShutdown(){
|
||||
#ifdef AUTOTEMP
|
||||
if(autotemp_enabled)
|
||||
{
|
||||
autotemp_enabled=false;
|
||||
if(degTargetHotend(active_extruder)>autotemp_min)
|
||||
setTargetHotend(0,active_extruder);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void PID_autotune(float temp);
|
||||
void PID_autotune(float temp, int extruder, int ncycles);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+136
-255
@@ -310,267 +310,148 @@ const short temptable_7[][2] PROGMEM = {
|
||||
{1005*OVERSAMPLENR, 5}
|
||||
};
|
||||
#endif
|
||||
//
|
||||
#if (THERMISTORHEATER_0 == 100) || (THERMISTORHEATER_1 == 100) || (THERMISTORHEATER_2 == 100) || (THERMISTORBED == 100) // 100k DO-35 NTC
|
||||
const short temptable_100[][2] PROGMEM = {
|
||||
{1*OVERSAMPLENR, 929},
|
||||
{36*OVERSAMPLENR, 299},
|
||||
{71*OVERSAMPLENR, 246},
|
||||
{106*OVERSAMPLENR, 217},
|
||||
{141*OVERSAMPLENR, 198},
|
||||
{176*OVERSAMPLENR, 184},
|
||||
{211*OVERSAMPLENR, 173},
|
||||
{246*OVERSAMPLENR, 163},
|
||||
{281*OVERSAMPLENR, 154},
|
||||
{316*OVERSAMPLENR, 147},
|
||||
{351*OVERSAMPLENR, 140},
|
||||
{386*OVERSAMPLENR, 134},
|
||||
{421*OVERSAMPLENR, 128},
|
||||
{456*OVERSAMPLENR, 122},
|
||||
{491*OVERSAMPLENR, 117},
|
||||
{526*OVERSAMPLENR, 112},
|
||||
{561*OVERSAMPLENR, 107},
|
||||
{596*OVERSAMPLENR, 102},
|
||||
{631*OVERSAMPLENR, 97},
|
||||
{666*OVERSAMPLENR, 91},
|
||||
{701*OVERSAMPLENR, 86},
|
||||
{736*OVERSAMPLENR, 81},
|
||||
{771*OVERSAMPLENR, 76},
|
||||
{806*OVERSAMPLENR, 70},
|
||||
{841*OVERSAMPLENR, 63},
|
||||
{876*OVERSAMPLENR, 56},
|
||||
{911*OVERSAMPLENR, 48},
|
||||
{946*OVERSAMPLENR, 38},
|
||||
{981*OVERSAMPLENR, 23},
|
||||
{1005*OVERSAMPLENR, 5},
|
||||
{1016*OVERSAMPLENR, 0}
|
||||
};
|
||||
#endif
|
||||
#if (THERMISTORHEATER_0 == 101) || (THERMISTORHEATER_1 == 101) || (THERMISTORHEATER_2 == 101) || (THERMISTORBED == 101) // 100k Honeywell 135-104LAG-J01
|
||||
const short temptable_101[][2] PROGMEM = {
|
||||
{1*OVERSAMPLENR, 704},
|
||||
{54*OVERSAMPLENR, 216},
|
||||
{107*OVERSAMPLENR, 175},
|
||||
{160*OVERSAMPLENR, 152},
|
||||
{213*OVERSAMPLENR, 137},
|
||||
{266*OVERSAMPLENR, 125},
|
||||
{319*OVERSAMPLENR, 115},
|
||||
{372*OVERSAMPLENR, 106},
|
||||
{425*OVERSAMPLENR, 99},
|
||||
{478*OVERSAMPLENR, 91},
|
||||
{531*OVERSAMPLENR, 85},
|
||||
{584*OVERSAMPLENR, 78},
|
||||
{637*OVERSAMPLENR, 71},
|
||||
{690*OVERSAMPLENR, 65},
|
||||
{743*OVERSAMPLENR, 58},
|
||||
{796*OVERSAMPLENR, 50},
|
||||
{849*OVERSAMPLENR, 42},
|
||||
{902*OVERSAMPLENR, 31},
|
||||
{955*OVERSAMPLENR, 17},
|
||||
{1008*OVERSAMPLENR, 0}
|
||||
};
|
||||
#endif
|
||||
#if (THERMISTORHEATER_0 == 102) || (THERMISTORHEATER_1 == 102) || (THERMISTORHEATER_2 == 102) || (THERMISTORBED == 102) // EPCOS G57540
|
||||
const short temptable_102[][2] PROGMEM = {
|
||||
{15*OVERSAMPLENR,286},
|
||||
{16*OVERSAMPLENR,282},
|
||||
{17*OVERSAMPLENR,278},
|
||||
{18*OVERSAMPLENR,274},
|
||||
{19*OVERSAMPLENR,270},
|
||||
{20*OVERSAMPLENR,266},
|
||||
{21*OVERSAMPLENR,262},
|
||||
{22*OVERSAMPLENR,258},
|
||||
{23*OVERSAMPLENR,254},
|
||||
{25*OVERSAMPLENR,250},
|
||||
{27*OVERSAMPLENR,246},
|
||||
{28*OVERSAMPLENR,242},
|
||||
{31*OVERSAMPLENR,238},
|
||||
{33*OVERSAMPLENR,234},
|
||||
{35*OVERSAMPLENR,230},
|
||||
{38*OVERSAMPLENR,226},
|
||||
{41*OVERSAMPLENR,222},
|
||||
{44*OVERSAMPLENR,218},
|
||||
{48*OVERSAMPLENR,214},
|
||||
{52*OVERSAMPLENR,210},
|
||||
{56*OVERSAMPLENR,206},
|
||||
{61*OVERSAMPLENR,202},
|
||||
{66*OVERSAMPLENR,198},
|
||||
{71*OVERSAMPLENR,194},
|
||||
{78*OVERSAMPLENR,190},
|
||||
{84*OVERSAMPLENR,186},
|
||||
{92*OVERSAMPLENR,182},
|
||||
{100*OVERSAMPLENR,178},
|
||||
{109*OVERSAMPLENR,174},
|
||||
{120*OVERSAMPLENR,170},
|
||||
{131*OVERSAMPLENR,166},
|
||||
{143*OVERSAMPLENR,162},
|
||||
{156*OVERSAMPLENR,158},
|
||||
{171*OVERSAMPLENR,154},
|
||||
{187*OVERSAMPLENR,150},
|
||||
{205*OVERSAMPLENR,146},
|
||||
{224*OVERSAMPLENR,142},
|
||||
{224*OVERSAMPLENR,160},
|
||||
{245*OVERSAMPLENR,155},
|
||||
{268*OVERSAMPLENR,150},
|
||||
{293*OVERSAMPLENR,145},
|
||||
{320*OVERSAMPLENR,140},
|
||||
{348*OVERSAMPLENR,135},
|
||||
{379*OVERSAMPLENR,130},
|
||||
{411*OVERSAMPLENR,125},
|
||||
{480*OVERSAMPLENR,115},
|
||||
{553*OVERSAMPLENR,105},
|
||||
{628*OVERSAMPLENR,95},
|
||||
{702*OVERSAMPLENR,85},
|
||||
{770*OVERSAMPLENR,75},
|
||||
{830*OVERSAMPLENR,65},
|
||||
{881*OVERSAMPLENR,55},
|
||||
{922*OVERSAMPLENR,45},
|
||||
{954*OVERSAMPLENR,35},
|
||||
{977*OVERSAMPLENR,25},
|
||||
{993*OVERSAMPLENR,15},
|
||||
{999*OVERSAMPLENR,10},
|
||||
{1008*OVERSAMPLENR,0},
|
||||
};
|
||||
#endif
|
||||
#if (THERMISTORHEATER_0 == 103) || (THERMISTORHEATER_1 == 103) || (THERMISTORHEATER_2 == 103) || (THERMISTORBED == 103) // EPCOS G57540
|
||||
const short temptable_103[][2] PROGMEM = {
|
||||
{1*OVERSAMPLENR, 628},
|
||||
{187*OVERSAMPLENR, 156},
|
||||
{218*OVERSAMPLENR, 148},
|
||||
{249*OVERSAMPLENR, 141},
|
||||
{280*OVERSAMPLENR, 135},
|
||||
{311*OVERSAMPLENR, 129},
|
||||
{342*OVERSAMPLENR, 124},
|
||||
{373*OVERSAMPLENR, 120},
|
||||
{404*OVERSAMPLENR, 115},
|
||||
{435*OVERSAMPLENR, 111},
|
||||
{466*OVERSAMPLENR, 107},
|
||||
{497*OVERSAMPLENR, 103},
|
||||
{528*OVERSAMPLENR, 99},
|
||||
{559*OVERSAMPLENR, 96},
|
||||
{590*OVERSAMPLENR, 92},
|
||||
{621*OVERSAMPLENR, 88},
|
||||
{652*OVERSAMPLENR, 84},
|
||||
{683*OVERSAMPLENR, 81},
|
||||
{714*OVERSAMPLENR, 77},
|
||||
{745*OVERSAMPLENR, 73},
|
||||
{776*OVERSAMPLENR, 68},
|
||||
{807*OVERSAMPLENR, 64},
|
||||
{838*OVERSAMPLENR, 59},
|
||||
{869*OVERSAMPLENR, 54},
|
||||
{900*OVERSAMPLENR, 48},
|
||||
{931*OVERSAMPLENR, 40},
|
||||
{962*OVERSAMPLENR, 31},
|
||||
{993*OVERSAMPLENR, 17},
|
||||
{1008*OVERSAMPLENR,0}
|
||||
};
|
||||
#endif
|
||||
#if (THERMISTORHEATER_0 == 104) || (THERMISTORHEATER_1 == 104) || (THERMISTORHEATER_2 == 104) || (THERMISTORBED == 104) // EPCOS G57540G103F - r2=4k7
|
||||
const short temptable_104[][2] PROGMEM = {
|
||||
{1*OVERSAMPLENR, 599},
|
||||
{54*OVERSAMPLENR, 160},
|
||||
{107*OVERSAMPLENR, 123},
|
||||
{160*OVERSAMPLENR, 103},
|
||||
{213*OVERSAMPLENR, 90},
|
||||
{266*OVERSAMPLENR, 79},
|
||||
{319*OVERSAMPLENR, 70},
|
||||
{372*OVERSAMPLENR, 62},
|
||||
{425*OVERSAMPLENR, 55},
|
||||
{478*OVERSAMPLENR, 49},
|
||||
{531*OVERSAMPLENR, 43},
|
||||
{584*OVERSAMPLENR, 37},
|
||||
{637*OVERSAMPLENR, 31},
|
||||
{690*OVERSAMPLENR, 25},
|
||||
{743*OVERSAMPLENR, 19},
|
||||
{796*OVERSAMPLENR, 12},
|
||||
{849*OVERSAMPLENR, 5},
|
||||
{902*OVERSAMPLENR, -3},
|
||||
{955*OVERSAMPLENR, -16},
|
||||
{1008*OVERSAMPLENR, -42}
|
||||
};
|
||||
#endif
|
||||
#if (THERMISTORHEATER_0 == 105) || (THERMISTORHEATER_1 == 105) || (THERMISTORHEATER_2 == 105) || (THERMISTORBED == 105) // EPCOS G57540G103F - r2=10k
|
||||
const short temptable_105[][2] PROGMEM = {
|
||||
{1*OVERSAMPLENR, 460},
|
||||
{54*OVERSAMPLENR, 123},
|
||||
{107*OVERSAMPLENR, 92},
|
||||
{160*OVERSAMPLENR, 75},
|
||||
{213*OVERSAMPLENR, 63},
|
||||
{266*OVERSAMPLENR, 54},
|
||||
{319*OVERSAMPLENR, 46},
|
||||
{372*OVERSAMPLENR, 40},
|
||||
{425*OVERSAMPLENR, 34},
|
||||
{478*OVERSAMPLENR, 28},
|
||||
{531*OVERSAMPLENR, 23},
|
||||
{584*OVERSAMPLENR, 17},
|
||||
{637*OVERSAMPLENR, 12},
|
||||
{690*OVERSAMPLENR, 7},
|
||||
{743*OVERSAMPLENR, 2},
|
||||
{796*OVERSAMPLENR, -3},
|
||||
{849*OVERSAMPLENR, -10},
|
||||
{902*OVERSAMPLENR, -18},
|
||||
{955*OVERSAMPLENR, -29},
|
||||
{1008*OVERSAMPLENR, -53}
|
||||
|
||||
#if (THERMISTORHEATER_0 == 51) || (THERMISTORHEATER_1 == 51) || (THERMISTORHEATER_2 == 51) || (THERMISTORBED == 51)
|
||||
// 100k EPCOS (WITH 1kohm RESISTOR FOR PULLUP, R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!)
|
||||
// Verified by linagee.
|
||||
// Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance
|
||||
// Advantage: Twice the resolution and better linearity from 150C to 200C
|
||||
const short temptable_51[][2] PROGMEM = {
|
||||
{1*OVERSAMPLENR, 350},
|
||||
{190*OVERSAMPLENR, 250}, //top rating 250C
|
||||
{203*OVERSAMPLENR, 245},
|
||||
{217*OVERSAMPLENR, 240},
|
||||
{232*OVERSAMPLENR, 235},
|
||||
{248*OVERSAMPLENR, 230},
|
||||
{265*OVERSAMPLENR, 225},
|
||||
{283*OVERSAMPLENR, 220},
|
||||
{302*OVERSAMPLENR, 215},
|
||||
{322*OVERSAMPLENR, 210},
|
||||
{344*OVERSAMPLENR, 205},
|
||||
{366*OVERSAMPLENR, 200},
|
||||
{390*OVERSAMPLENR, 195},
|
||||
{415*OVERSAMPLENR, 190},
|
||||
{440*OVERSAMPLENR, 185},
|
||||
{467*OVERSAMPLENR, 180},
|
||||
{494*OVERSAMPLENR, 175},
|
||||
{522*OVERSAMPLENR, 170},
|
||||
{551*OVERSAMPLENR, 165},
|
||||
{580*OVERSAMPLENR, 160},
|
||||
{609*OVERSAMPLENR, 155},
|
||||
{638*OVERSAMPLENR, 150},
|
||||
{666*OVERSAMPLENR, 145},
|
||||
{695*OVERSAMPLENR, 140},
|
||||
{722*OVERSAMPLENR, 135},
|
||||
{749*OVERSAMPLENR, 130},
|
||||
{775*OVERSAMPLENR, 125},
|
||||
{800*OVERSAMPLENR, 120},
|
||||
{823*OVERSAMPLENR, 115},
|
||||
{845*OVERSAMPLENR, 110},
|
||||
{865*OVERSAMPLENR, 105},
|
||||
{884*OVERSAMPLENR, 100},
|
||||
{901*OVERSAMPLENR, 95},
|
||||
{917*OVERSAMPLENR, 90},
|
||||
{932*OVERSAMPLENR, 85},
|
||||
{944*OVERSAMPLENR, 80},
|
||||
{956*OVERSAMPLENR, 75},
|
||||
{966*OVERSAMPLENR, 70},
|
||||
{975*OVERSAMPLENR, 65},
|
||||
{982*OVERSAMPLENR, 60},
|
||||
{989*OVERSAMPLENR, 55},
|
||||
{995*OVERSAMPLENR, 50},
|
||||
{1000*OVERSAMPLENR, 45},
|
||||
{1004*OVERSAMPLENR, 40},
|
||||
{1007*OVERSAMPLENR, 35},
|
||||
{1010*OVERSAMPLENR, 30},
|
||||
{1013*OVERSAMPLENR, 25},
|
||||
{1015*OVERSAMPLENR, 20},
|
||||
{1017*OVERSAMPLENR, 15},
|
||||
{1018*OVERSAMPLENR, 10},
|
||||
{1019*OVERSAMPLENR, 5},
|
||||
{1020*OVERSAMPLENR, 0},
|
||||
{1021*OVERSAMPLENR, -5}
|
||||
};
|
||||
#endif
|
||||
|
||||
#if (THERMISTORHEATER_0 == 110) || (THERMISTORHEATER_1 == 110) || (THERMISTORHEATER_2 == 110) || (THERMISTORBED == 110) // RS thermistor 198-961
|
||||
const short temptable_110[][2] PROGMEM = {
|
||||
{1*OVERSAMPLENR, 704},
|
||||
{15*OVERSAMPLENR, 280},
|
||||
{21*OVERSAMPLENR, 266},
|
||||
{41*OVERSAMPLENR, 234},
|
||||
{61*OVERSAMPLENR, 208},
|
||||
{81*OVERSAMPLENR, 191},
|
||||
{101*OVERSAMPLENR, 178},
|
||||
{121*OVERSAMPLENR, 168},
|
||||
{141*OVERSAMPLENR, 159},
|
||||
{161*OVERSAMPLENR, 152},
|
||||
{181*OVERSAMPLENR, 146},
|
||||
{221*OVERSAMPLENR, 135},
|
||||
{261*OVERSAMPLENR, 126},
|
||||
{301*OVERSAMPLENR, 118},
|
||||
{341*OVERSAMPLENR, 111},
|
||||
{381*OVERSAMPLENR, 105},
|
||||
{421*OVERSAMPLENR, 99},
|
||||
{461*OVERSAMPLENR, 94},
|
||||
{501*OVERSAMPLENR, 88},
|
||||
{541*OVERSAMPLENR, 83},
|
||||
{581*OVERSAMPLENR, 78},
|
||||
{621*OVERSAMPLENR, 73},
|
||||
{661*OVERSAMPLENR, 68},
|
||||
{741*OVERSAMPLENR, 58},
|
||||
{781*OVERSAMPLENR, 52},
|
||||
{821*OVERSAMPLENR, 46},
|
||||
{861*OVERSAMPLENR, 40},
|
||||
{901*OVERSAMPLENR, 32},
|
||||
{981*OVERSAMPLENR, 7},
|
||||
{1008*OVERSAMPLENR, 0}
|
||||
#if (THERMISTORHEATER_0 == 52) || (THERMISTORHEATER_1 == 52) || (THERMISTORHEATER_2 == 52) || (THERMISTORBED == 52)
|
||||
// 200k ATC Semitec 204GT-2 (WITH 1kohm RESISTOR FOR PULLUP, R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!)
|
||||
// Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf
|
||||
// Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance
|
||||
// Advantage: More resolution and better linearity from 150C to 200C
|
||||
const short temptable_52[][2] PROGMEM = {
|
||||
{1*OVERSAMPLENR, 500},
|
||||
{125*OVERSAMPLENR, 300}, //top rating 300C
|
||||
{142*OVERSAMPLENR, 290},
|
||||
{162*OVERSAMPLENR, 280},
|
||||
{185*OVERSAMPLENR, 270},
|
||||
{211*OVERSAMPLENR, 260},
|
||||
{240*OVERSAMPLENR, 250},
|
||||
{274*OVERSAMPLENR, 240},
|
||||
{312*OVERSAMPLENR, 230},
|
||||
{355*OVERSAMPLENR, 220},
|
||||
{401*OVERSAMPLENR, 210},
|
||||
{452*OVERSAMPLENR, 200},
|
||||
{506*OVERSAMPLENR, 190},
|
||||
{563*OVERSAMPLENR, 180},
|
||||
{620*OVERSAMPLENR, 170},
|
||||
{677*OVERSAMPLENR, 160},
|
||||
{732*OVERSAMPLENR, 150},
|
||||
{783*OVERSAMPLENR, 140},
|
||||
{830*OVERSAMPLENR, 130},
|
||||
{871*OVERSAMPLENR, 120},
|
||||
{906*OVERSAMPLENR, 110},
|
||||
{935*OVERSAMPLENR, 100},
|
||||
{958*OVERSAMPLENR, 90},
|
||||
{976*OVERSAMPLENR, 80},
|
||||
{990*OVERSAMPLENR, 70},
|
||||
{1000*OVERSAMPLENR, 60},
|
||||
{1008*OVERSAMPLENR, 50},
|
||||
{1013*OVERSAMPLENR, 40},
|
||||
{1017*OVERSAMPLENR, 30},
|
||||
{1019*OVERSAMPLENR, 20},
|
||||
{1021*OVERSAMPLENR, 10},
|
||||
{1022*OVERSAMPLENR, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
#if (THERMISTORHEATER_0 == 111) || (THERMISTORHEATER_1 == 111) || (THERMISTORHEATER_2 == 111) || (THERMISTORBED == 111) //100k EPCOS
|
||||
const short temptable_111[][2] PROGMEM = {
|
||||
{1*OVERSAMPLENR, 704},
|
||||
{54*OVERSAMPLENR, 216},
|
||||
{107*OVERSAMPLENR, 175},
|
||||
{160*OVERSAMPLENR, 152},
|
||||
{213*OVERSAMPLENR, 137},
|
||||
{266*OVERSAMPLENR, 125},
|
||||
{319*OVERSAMPLENR, 115},
|
||||
{372*OVERSAMPLENR, 106},
|
||||
{425*OVERSAMPLENR, 99},
|
||||
{478*OVERSAMPLENR, 91},
|
||||
{531*OVERSAMPLENR, 85},
|
||||
{584*OVERSAMPLENR, 78},
|
||||
{637*OVERSAMPLENR, 71},
|
||||
{690*OVERSAMPLENR, 65},
|
||||
{743*OVERSAMPLENR, 58},
|
||||
{796*OVERSAMPLENR, 50},
|
||||
{849*OVERSAMPLENR, 42},
|
||||
{902*OVERSAMPLENR, 31},
|
||||
{955*OVERSAMPLENR, 17},
|
||||
{1008*OVERSAMPLENR, 0}
|
||||
#if (THERMISTORHEATER_0 == 55) || (THERMISTORHEATER_1 == 55) || (THERMISTORHEATER_2 == 55) || (THERMISTORBED == 55)
|
||||
// 100k ATC Semitec 104GT-2 (Used on ParCan) (WITH 1kohm RESISTOR FOR PULLUP, R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!)
|
||||
// Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf
|
||||
// Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance
|
||||
// Advantage: More resolution and better linearity from 150C to 200C
|
||||
const short temptable_55[][2] PROGMEM = {
|
||||
{1*OVERSAMPLENR, 500},
|
||||
{76*OVERSAMPLENR, 300},
|
||||
{87*OVERSAMPLENR, 290},
|
||||
{100*OVERSAMPLENR, 280},
|
||||
{114*OVERSAMPLENR, 270},
|
||||
{131*OVERSAMPLENR, 260},
|
||||
{152*OVERSAMPLENR, 250},
|
||||
{175*OVERSAMPLENR, 240},
|
||||
{202*OVERSAMPLENR, 230},
|
||||
{234*OVERSAMPLENR, 220},
|
||||
{271*OVERSAMPLENR, 210},
|
||||
{312*OVERSAMPLENR, 200},
|
||||
{359*OVERSAMPLENR, 190},
|
||||
{411*OVERSAMPLENR, 180},
|
||||
{467*OVERSAMPLENR, 170},
|
||||
{527*OVERSAMPLENR, 160},
|
||||
{590*OVERSAMPLENR, 150},
|
||||
{652*OVERSAMPLENR, 140},
|
||||
{713*OVERSAMPLENR, 130},
|
||||
{770*OVERSAMPLENR, 120},
|
||||
{822*OVERSAMPLENR, 110},
|
||||
{867*OVERSAMPLENR, 100},
|
||||
{905*OVERSAMPLENR, 90},
|
||||
{936*OVERSAMPLENR, 80},
|
||||
{961*OVERSAMPLENR, 70},
|
||||
{979*OVERSAMPLENR, 60},
|
||||
{993*OVERSAMPLENR, 50},
|
||||
{1003*OVERSAMPLENR, 40},
|
||||
{1010*OVERSAMPLENR, 30},
|
||||
{1015*OVERSAMPLENR, 20},
|
||||
{1018*OVERSAMPLENR, 10},
|
||||
{1020*OVERSAMPLENR, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+59
-29
@@ -1,37 +1,41 @@
|
||||
#ifndef ULTRALCD_H
|
||||
#define ULTRALCD_H
|
||||
#include "Marlin.h"
|
||||
#ifdef ULTRA_LCD
|
||||
#include <LiquidCrystal.h>
|
||||
void lcd_status();
|
||||
void lcd_init();
|
||||
void lcd_status(const char* message);
|
||||
void beep();
|
||||
void buttons_init();
|
||||
void buttons_check();
|
||||
|
||||
#define LCD_UPDATE_INTERVAL 100
|
||||
#define STATUSTIMEOUT 15000
|
||||
extern LiquidCrystal lcd;
|
||||
extern volatile char buttons; //the last checked buttons in a bit array.
|
||||
#include "Marlin.h"
|
||||
|
||||
#ifdef ULTRA_LCD
|
||||
#include "language.h"
|
||||
|
||||
#if LANGUAGE_CHOICE == 6
|
||||
#include "LiquidCrystalRus.h"
|
||||
#define LCD_CLASS LiquidCrystalRus
|
||||
#else
|
||||
#include <LiquidCrystal.h>
|
||||
#define LCD_CLASS LiquidCrystal
|
||||
#endif
|
||||
|
||||
void lcd_status();
|
||||
void lcd_init();
|
||||
void lcd_status(const char* message);
|
||||
void beep();
|
||||
void buttons_init();
|
||||
void buttons_check();
|
||||
|
||||
#define LCD_UPDATE_INTERVAL 100
|
||||
#define STATUSTIMEOUT 15000
|
||||
|
||||
extern LCD_CLASS lcd;
|
||||
|
||||
extern volatile char buttons; //the last checked buttons in a bit array.
|
||||
|
||||
#ifdef NEWPANEL
|
||||
#ifdef NEWPANEL
|
||||
#define EN_C (1<<BLEN_C)
|
||||
#define EN_B (1<<BLEN_B)
|
||||
#define EN_A (1<<BLEN_A)
|
||||
|
||||
|
||||
#define CLICKED (buttons&EN_C)
|
||||
#define BLOCK {blocking=millis()+blocktime;}
|
||||
#if (SDCARDDETECT > -1)
|
||||
#ifdef SDCARDDETECTINVERTED
|
||||
#define CARDINSERTED (READ(SDCARDDETECT)!=0)
|
||||
#else
|
||||
#define CARDINSERTED (READ(SDCARDDETECT)==0)
|
||||
#endif
|
||||
#endif //SDCARDTETECTINVERTED
|
||||
|
||||
#else
|
||||
|
||||
#else
|
||||
//atomatic, do not change
|
||||
#define B_LE (1<<BL_LE)
|
||||
#define B_UP (1<<BL_UP)
|
||||
@@ -44,14 +48,25 @@
|
||||
|
||||
#define CLICKED ((buttons&B_MI)||(buttons&B_ST))
|
||||
#define BLOCK {blocking[BL_MI]=millis()+blocktime;blocking[BL_ST]=millis()+blocktime;}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (SDCARDDETECT > -1)
|
||||
#ifdef SDCARDDETECTINVERTED
|
||||
#define CARDINSERTED (READ(SDCARDDETECT)!=0)
|
||||
#else
|
||||
#define CARDINSERTED (READ(SDCARDDETECT)==0)
|
||||
#endif //SDCARDTETECTINVERTED
|
||||
#else
|
||||
//If we don't have a card detect line, aways asume the card is inserted
|
||||
#define CARDINSERTED true
|
||||
#endif
|
||||
|
||||
|
||||
// blocking time for recognizing a new keypress of one key, ms
|
||||
#define blocktime 500
|
||||
#define lcdslow 5
|
||||
|
||||
enum MainStatus{Main_Status, Main_Menu, Main_Prepare,Sub_PrepareMove, Main_Control, Main_SD,Sub_TempControl,Sub_MotionControl,Sub_RetractControl};
|
||||
enum MainStatus{Main_Status, Main_Menu, Main_Prepare,Sub_PrepareMove, Main_Control, Main_SD,Sub_TempControl,Sub_MotionControl,Sub_RetractControl, Sub_PreheatPLASettings, Sub_PreheatABSSettings};
|
||||
|
||||
class MainMenu{
|
||||
public:
|
||||
@@ -71,6 +86,8 @@
|
||||
void showControlRetract();
|
||||
void showAxisMove();
|
||||
void showSD();
|
||||
void showPLAsettings();
|
||||
void showABSsettings();
|
||||
bool force_lcd_update;
|
||||
long lastencoderpos;
|
||||
int8_t lineoffset;
|
||||
@@ -139,13 +156,15 @@
|
||||
|
||||
#define LCD_INIT lcd_init();
|
||||
#define LCD_MESSAGE(x) lcd_status(x);
|
||||
#define LCD_MESSAGEPGM(x) lcd_statuspgm(MYPGM(x));
|
||||
#define LCD_MESSAGEPGM(x) lcd_statuspgm(PSTR(x));
|
||||
#define LCD_ALERTMESSAGEPGM(x) lcd_alertstatuspgm(PSTR(x));
|
||||
#define LCD_STATUS lcd_status()
|
||||
#else //no lcd
|
||||
#define LCD_INIT
|
||||
#define LCD_STATUS
|
||||
#define LCD_MESSAGE(x)
|
||||
#define LCD_MESSAGEPGM(x)
|
||||
#define LCD_ALERTMESSAGEPGM(x)
|
||||
FORCE_INLINE void lcd_status() {};
|
||||
|
||||
#define CLICKED false
|
||||
@@ -153,6 +172,7 @@
|
||||
#endif
|
||||
|
||||
void lcd_statuspgm(const char* message);
|
||||
void lcd_alertstatuspgm(const char* message);
|
||||
|
||||
char *ftostr3(const float &x);
|
||||
char *itostr2(const uint8_t &x);
|
||||
@@ -162,4 +182,14 @@ char *itostr31(const int &xx);
|
||||
char *itostr3(const int &xx);
|
||||
char *itostr4(const int &xx);
|
||||
char *ftostr51(const float &x);
|
||||
|
||||
//TODO: These do not belong here.
|
||||
extern int plaPreheatHotendTemp;
|
||||
extern int plaPreheatHPBTemp;
|
||||
extern int plaPreheatFanSpeed;
|
||||
|
||||
extern int absPreheatHotendTemp;
|
||||
extern int absPreheatHPBTemp;
|
||||
extern int absPreheatFanSpeed;
|
||||
|
||||
#endif //ULTRALCD
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
#include "Marlin.h"
|
||||
|
||||
#ifdef USE_WATCHDOG
|
||||
#include <avr/wdt.h>
|
||||
|
||||
#include "watchdog.h"
|
||||
#include "ultralcd.h"
|
||||
|
||||
//===========================================================================
|
||||
//=============================private variables ============================
|
||||
//===========================================================================
|
||||
|
||||
//===========================================================================
|
||||
//=============================functinos ============================
|
||||
//===========================================================================
|
||||
|
||||
|
||||
/// intialise watch dog with a 1 sec interrupt time
|
||||
void watchdog_init()
|
||||
{
|
||||
#ifdef WATCHDOG_RESET_MANUAL
|
||||
//We enable the watchdog timer, but only for the interrupt.
|
||||
//Take care, as this requires the correct order of operation, with interrupts disabled. See the datasheet of any AVR chip for details.
|
||||
wdt_reset();
|
||||
_WD_CONTROL_REG = _BV(_WD_CHANGE_BIT) | _BV(WDE);
|
||||
_WD_CONTROL_REG = _BV(WDIE) | WDTO_1S;
|
||||
#else
|
||||
wdt_enable(WDTO_1S);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// reset watchdog. MUST be called every 1s after init or avr will reset.
|
||||
void watchdog_reset()
|
||||
{
|
||||
wdt_reset();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//=============================ISR ============================
|
||||
//===========================================================================
|
||||
|
||||
//Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled.
|
||||
#ifdef WATCHDOG_RESET_MANUAL
|
||||
ISR(WDT_vect)
|
||||
{
|
||||
//TODO: This message gets overwritten by the kill() call
|
||||
LCD_MESSAGEPGM("ERR:Please Reset");//16 characters so it fits on a 16x2 display
|
||||
LCD_STATUS;
|
||||
SERIAL_ERROR_START;
|
||||
SERIAL_ERRORLNPGM("Something is wrong, please turn off the printer.");
|
||||
kill(); //kill blocks
|
||||
while(1); //wait for user or serial reset
|
||||
}
|
||||
#endif//RESET_MANUAL
|
||||
|
||||
#endif//USE_WATCHDOG
|
||||
+8
-7
@@ -1,16 +1,17 @@
|
||||
#ifndef WATCHDOG_H
|
||||
#define WATCHDOG_H
|
||||
|
||||
#include "Marlin.h"
|
||||
|
||||
#ifdef USE_WATCHDOG
|
||||
|
||||
// intialise watch dog with a 1 sec interrupt time
|
||||
void wd_init();
|
||||
// pad the dog/reset watchdog. MUST be called at least every second after the first wd_init or avr will go into emergency procedures..
|
||||
void wd_reset();
|
||||
|
||||
void watchdog_init();
|
||||
// pad the dog/reset watchdog. MUST be called at least every second after the first watchdog_init or avr will go into emergency procedures..
|
||||
void watchdog_reset();
|
||||
#else
|
||||
FORCE_INLINE void wd_init() {};
|
||||
FORCE_INLINE void wd_reset() {};
|
||||
//If we do not have a watchdog, then we can have empty functions which are optimized away.
|
||||
FORCE_INLINE void watchdog_init() {};
|
||||
FORCE_INLINE void watchdog_reset() {};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
#ifdef USE_WATCHDOG
|
||||
#include "Marlin.h"
|
||||
#include "watchdog.h"
|
||||
|
||||
//===========================================================================
|
||||
//=============================private variables ============================
|
||||
//===========================================================================
|
||||
|
||||
static volatile uint8_t timeout_seconds=0;
|
||||
|
||||
void(* ctrlaltdelete) (void) = 0; //does not work on my atmega2560
|
||||
|
||||
//===========================================================================
|
||||
//=============================functinos ============================
|
||||
//===========================================================================
|
||||
|
||||
|
||||
/// intialise watch dog with a 1 sec interrupt time
|
||||
void wd_init()
|
||||
{
|
||||
WDTCSR |= (1<<WDCE )|(1<<WDE ); //allow changes
|
||||
WDTCSR = (1<<WDCE )|(1<<WDE )|(1<<WDP3 )|(1<<WDP0); // Reset after 8 sec.
|
||||
// WDTCSR = (1<<WDIF)|(1<<WDIE)| (1<<WDCE )|(1<<WDE )| (1<<WDP3) | (1<<WDP0);
|
||||
}
|
||||
|
||||
/// reset watchdog. MUST be called every 1s after init or avr will reset.
|
||||
void wd_reset()
|
||||
{
|
||||
wdt_reset();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//=============================ISR ============================
|
||||
//===========================================================================
|
||||
|
||||
//Watchdog timer interrupt, called if main program blocks >1sec
|
||||
ISR(WDT_vect)
|
||||
{
|
||||
if(timeout_seconds++ >= WATCHDOG_TIMEOUT)
|
||||
{
|
||||
|
||||
#ifdef RESET_MANUAL
|
||||
LCD_MESSAGEPGM("Please Reset!");
|
||||
LCD_STATUS;
|
||||
SERIAL_ERROR_START;
|
||||
SERIAL_ERRORLNPGM("Something is wrong, please turn off the printer.");
|
||||
#else
|
||||
LCD_MESSAGEPGM("Timeout, resetting!");
|
||||
LCD_STATUS;
|
||||
#endif
|
||||
//disable watchdog, it will survife reboot.
|
||||
WDTCSR |= (1<<WDCE) | (1<<WDE);
|
||||
WDTCSR = 0;
|
||||
#ifdef RESET_MANUAL
|
||||
kill(); //kill blocks
|
||||
while(1); //wait for user or serial reset
|
||||
#else
|
||||
ctrlaltdelete();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* USE_WATCHDOG */
|
||||
@@ -1,173 +0,0 @@
|
||||
#include "z_probe.h"
|
||||
#if defined(PROBE_PIN) && (PROBE_PIN > -1)
|
||||
#include "Marlin.h"
|
||||
#include "stepper.h"
|
||||
#include "temperature.h"
|
||||
|
||||
float Probe_Bed(float x_pos, float y_pos, int n)
|
||||
{
|
||||
//returns Probed Z average height
|
||||
float ProbeDepth[n];
|
||||
float ProbeDepthAvg=0;
|
||||
|
||||
//force bed heater off for probing
|
||||
int save_bed_targ = target_raw_bed;
|
||||
target_raw_bed = 0;
|
||||
WRITE(HEATER_BED_PIN,LOW);
|
||||
|
||||
if (Z_HOME_DIR==-1)
|
||||
{
|
||||
//int probe_flag =1;
|
||||
float meas = 0;
|
||||
int fails = 0;
|
||||
saved_feedrate = feedrate;
|
||||
saved_feedmultiply = feedmultiply;
|
||||
feedmultiply = 100;
|
||||
//previous_millis_cmd = millis();
|
||||
|
||||
//Move to probe position
|
||||
if (x_pos >= 0) destination[X_AXIS]=x_pos;
|
||||
if (y_pos >= 0) destination[Y_AXIS]=y_pos;
|
||||
//destination[Z_AXIS]=current_position[Z_AXIS];
|
||||
destination[Z_AXIS]=Z_HOME_RETRACT_MM;
|
||||
feedrate = 9000;
|
||||
prepare_move();
|
||||
|
||||
enable_endstops(true);
|
||||
SERIAL_ECHO("PRE-PROBE current_position[Z_AXIS]=");SERIAL_ECHOLN(current_position[Z_AXIS]);
|
||||
|
||||
SERIAL_ECHOLN("Ready to probe...");
|
||||
|
||||
//Probe bed n times
|
||||
//*******************************************************************************************Bed Loop*************************************
|
||||
for(int8_t i=0; i < n ; i++)
|
||||
{
|
||||
//int z = 0;
|
||||
|
||||
//fast probe
|
||||
//plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
||||
destination[Z_AXIS] = 1.1 * Z_MAX_LENGTH * Z_HOME_DIR;
|
||||
feedrate = homing_feedrate[Z_AXIS];
|
||||
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
||||
st_synchronize();
|
||||
|
||||
//feedrate = 0.0;
|
||||
|
||||
SERIAL_ECHO("current_position[Z_AXIS]=");SERIAL_ECHOLN(current_position[Z_AXIS]);
|
||||
if(endstop_z_hit == true)
|
||||
{
|
||||
SERIAL_ECHO("endstops_trigsteps[Z_AXIS]=");SERIAL_ECHOLN(endstops_trigsteps[Z_AXIS]);
|
||||
ProbeDepth[i]= endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS];
|
||||
meas = ProbeDepth[i];
|
||||
SERIAL_ECHO("ProbeDepth[");SERIAL_ECHO(i);SERIAL_ECHO("]=");SERIAL_ECHOLN(ProbeDepth[i]);
|
||||
//*************************************************************************************************************
|
||||
if (i > 0 ) //Second probe has happened so compare results
|
||||
{
|
||||
if (abs(ProbeDepth[i] - ProbeDepth[i - 1]) > .05)
|
||||
{ //keep going until readings match to avoid sticky bed
|
||||
SERIAL_ECHO("Probing again: ");
|
||||
SERIAL_ECHO(ProbeDepth[i]); SERIAL_ECHO(" - "); SERIAL_ECHO(ProbeDepth[i - 1]);SERIAL_ECHO(" = "); SERIAL_ECHOLN(abs(ProbeDepth[i] - ProbeDepth[i - 1]));
|
||||
meas = ProbeDepth[i];
|
||||
i--; i--; //Throw out both that don't match because we don't know which one is accurate
|
||||
if(fails++ > 4) break;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
SERIAL_ECHOLN("Probe not triggered.");
|
||||
i=n-1;
|
||||
}
|
||||
//**************************************************************************************************************************************************
|
||||
//fast move clear
|
||||
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], meas, current_position[E_AXIS]);
|
||||
destination[Z_AXIS] = Z_HOME_RETRACT_MM;
|
||||
feedrate = fast_home_feedrate[Z_AXIS];
|
||||
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
||||
st_synchronize();
|
||||
|
||||
//check z stop isn't still triggered
|
||||
if ( READ(X_MIN_PIN) != X_ENDSTOPS_INVERTING )
|
||||
{
|
||||
SERIAL_ECHOLN("Poking Stuck Bed:");
|
||||
destination[Z_AXIS] = -1; prepare_move();
|
||||
destination[Z_AXIS] = Z_HOME_RETRACT_MM; prepare_move();
|
||||
st_synchronize();
|
||||
i--; //Throw out this meaningless measurement
|
||||
}
|
||||
feedrate = 0;
|
||||
} //end probe loop
|
||||
#ifdef ENDSTOPS_ONLY_FOR_HOMING
|
||||
enable_endstops(false);
|
||||
#endif
|
||||
|
||||
feedrate = saved_feedrate;
|
||||
feedmultiply = saved_feedmultiply;
|
||||
//previous_millis_cmd = millis();
|
||||
endstops_hit_on_purpose();
|
||||
}
|
||||
for(int8_t i=0;i<n;i++)
|
||||
{
|
||||
ProbeDepthAvg += ProbeDepth[i];
|
||||
}
|
||||
ProbeDepthAvg /= n;
|
||||
SERIAL_ECHO("Probed Z="); SERIAL_ECHOLN(ProbeDepthAvg);
|
||||
SERIAL_ECHO("RAW current_position[Z_AXIS]=");SERIAL_ECHOLN(current_position[Z_AXIS]);
|
||||
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], Z_HOME_RETRACT_MM, current_position[E_AXIS]);
|
||||
current_position[Z_AXIS] = Z_HOME_RETRACT_MM;
|
||||
|
||||
target_raw_bed = save_bed_targ;
|
||||
return ProbeDepthAvg;
|
||||
}
|
||||
|
||||
void probe_init()
|
||||
{
|
||||
SET_INPUT(PROBE_PIN);
|
||||
WRITE(PROBE_PIN,HIGH);
|
||||
}
|
||||
|
||||
/*Crash1 - G29 to Probe and stop on Bed
|
||||
G29 will probe bed at least twice at 3 points and take an average. G30 will probe bed at it's current location.
|
||||
Z stop should be set slightly below bed height. Solder stub wire to each hole in huxley bed and attach a ring terminal under spring.
|
||||
Wire bed probe to A2 on Melzi and duplicate cap/resistor circuit in schematic.
|
||||
|
||||
Use something like this in the start.gcode file:
|
||||
G29 ;Probe bed for Z height
|
||||
G92 Z0 ;Set Z to Probed Depth
|
||||
G1 Z5 F200 ;Lift Z out of way
|
||||
*/
|
||||
void probe_3points()
|
||||
{
|
||||
float Probe_Avg, Point1, Point2, Point3;
|
||||
Point1 = Probe_Bed(15,15,PROBE_N);
|
||||
Point2 = Probe_Bed(X_MAX_LENGTH - 20,15,PROBE_N) ;
|
||||
Point3 = Probe_Bed(X_MAX_LENGTH/2,Y_MAX_LENGTH - 5,PROBE_N);
|
||||
Probe_Avg = (Point1 + Point2 + Point3) / 3;
|
||||
//destination[2] = Probe_Avg;
|
||||
//feedrate = homing_feedrate[Z_AXIS];
|
||||
//prepare_move();
|
||||
SERIAL_ECHOLN("**************************************");
|
||||
SERIAL_ECHO("Point1 ="); SERIAL_ECHOLN(Point1);
|
||||
SERIAL_ECHO("Point2 ="); SERIAL_ECHOLN(Point2);
|
||||
SERIAL_ECHO("Point3 ="); SERIAL_ECHOLN(Point3);
|
||||
SERIAL_ECHO("Probed Average="); SERIAL_ECHOLN(Probe_Avg);
|
||||
SERIAL_ECHOLN("**************************************");
|
||||
}
|
||||
|
||||
void probe_1point()
|
||||
{
|
||||
float Point;
|
||||
Point = Probe_Bed(-1,-1,PROBE_N);
|
||||
//destination[2] = Point +1;
|
||||
//feedrate = homing_feedrate[Z_AXIS];
|
||||
//prepare_move();
|
||||
SERIAL_ECHOLN("**************************************");
|
||||
SERIAL_ECHO("Probed Z="); SERIAL_ECHOLN(Point);
|
||||
}
|
||||
|
||||
void probe_status()
|
||||
{
|
||||
SERIAL_ECHO("Probe Status = "); SERIAL_ECHOLN(READ(PROBE_PIN));
|
||||
}
|
||||
|
||||
#endif //defined(PROBE_PIN) > -1
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
#ifndef __Z_PROBEH
|
||||
|
||||
#define __Z_PROBEH
|
||||
#include "Marlin.h"
|
||||
|
||||
#if defined(PROBE_PIN) && (PROBE_PIN > -1)
|
||||
void probe_init();
|
||||
void probe_3points();
|
||||
void probe_1point();
|
||||
void probe_status();
|
||||
float Probe_Bed(float x_pos, float y_pos,int n);
|
||||
|
||||
#else //no probe pin
|
||||
FORCE_INLINE void probe_init() {};
|
||||
FORCE_INLINE void probe_3points() {};
|
||||
FORCE_INLINE void probe_1point() {};
|
||||
FORCE_INLINE void probe_status() {};
|
||||
FORCE_INLINE float Probe_Bed(float x_pos, float y_pos,int n) {return 0;}
|
||||
#endif //PROBE_PIN
|
||||
|
||||
#endif
|
||||
@@ -1,64 +0,0 @@
|
||||
This RepRap firmware is a mashup between Sprinter, grbl and many original parts.
|
||||
(https://github.com/kliment/Sprinter)
|
||||
(https://github.com/simen/grbl/tree)
|
||||
|
||||
Derived from Sprinter and Grbl by Erik van der Zalm.
|
||||
Sprinters lead developers are Kliment and caru.
|
||||
Grbls lead developer is Simen Svale Skogsrud.
|
||||
It has been adapted to the Ultimaker Printer by:
|
||||
Bernhard Kubicek, Matthijs Keuper, Bradley Feldman, and others...
|
||||
|
||||
|
||||
Features:
|
||||
- Interrupt based movement with real linear acceleration
|
||||
- High steprate
|
||||
- Look ahead (Keep the speed high when possible. High cornering speed)
|
||||
- Interrupt based temperature protection
|
||||
- preliminary support for Matthew Roberts advance algorithm
|
||||
For more info see: http://reprap.org/pipermail/reprap-dev/2011-May/003323.html
|
||||
- Full endstop support
|
||||
- Simple LCD support (16x2)
|
||||
- SD Card support
|
||||
- Provisions for Bernhard Kubicek's new hardware control console and 20x4 lcd
|
||||
|
||||
This firmware is optimized for Ultimaker's gen6 electronics (including the Ultimaker 1.5.x daughterboard and Arduino Mega 2560).
|
||||
|
||||
The default baudrate is 115200.
|
||||
|
||||
|
||||
========================================================================================
|
||||
|
||||
Configuring and compilation
|
||||
|
||||
|
||||
Install the latest arduino software IDE/toolset (currently 0022)
|
||||
http://www.arduino.cc/en/Main/Software
|
||||
|
||||
Install Ultimaker's RepG 25 build
|
||||
http://software.ultimaker.com
|
||||
(or alternatively install Kliment's printrun/pronterface https://github.com/kliment/Printrun_)
|
||||
|
||||
Copy the Ultimaker Marlin firmware
|
||||
https:/github.com/bkubicek/Marlin
|
||||
(Use the download button)
|
||||
|
||||
Start the arduino IDE.
|
||||
Select Tools -> Board -> Arduino Mega 2560
|
||||
Select the correct serial port in Tools ->Serial Port
|
||||
Open Marlin.pde
|
||||
|
||||
Click the Verify/Compile button
|
||||
|
||||
Click the Upload button
|
||||
If all goes well the firmware is uploading
|
||||
|
||||
Start Ultimaker's Custom RepG 25
|
||||
Make sure Show Experimental Profiles is enabled in Preferences
|
||||
Select Sprinter as the Driver
|
||||
|
||||
Press the Connect button.
|
||||
|
||||
KNOWN ISSUES: RepG will display: Unknown: marlin x.y.z
|
||||
|
||||
That's ok. Enjoy Silky Smooth Printing.
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
WARNING:
|
||||
--------
|
||||
THIS IS RELEASE CANDIDATE 1 FOR MARLIN 1.0.0
|
||||
THIS IS RELEASE CANDIDATE 2 FOR MARLIN 1.0.0
|
||||
|
||||
The configuration is now split in two files
|
||||
Configuration.h for the normal settings
|
||||
Configuration_adv.h for the advanced settings
|
||||
|
||||
Gen7T is not supported.
|
||||
|
||||
Quick Information
|
||||
===================
|
||||
This RepRap firmware is a mashup between <a href="https://github.com/kliment/Sprinter">Sprinter</a>, <a href="https://github.com/simen/grbl/tree">grbl</a> and many original parts.
|
||||
@@ -29,6 +31,7 @@ Features:
|
||||
* Full endstop support
|
||||
* SD Card support
|
||||
* SD Card folders (works in pronterface)
|
||||
* SD Card autostart support
|
||||
* LCD support (ideally 20x4)
|
||||
* LCD menu system for autonomous SD card printing, controlled by an click-encoder.
|
||||
* EEPROM storage of e.g. max-velocity, max-acceleration, and similar variables
|
||||
@@ -40,6 +43,8 @@ Features:
|
||||
* Endstop trigger reporting to the host software.
|
||||
* Updated sdcardlib
|
||||
* Heater power reporting. Useful for PID monitoring.
|
||||
* PID tuning
|
||||
* CoreXY kinematics (www.corexy.com/theory.html)
|
||||
|
||||
The default baudrate is 250000. This baudrate has less jitter and hence errors than the usual 115200 baud, but is less supported by drivers and host-environments.
|
||||
|
||||
@@ -97,6 +102,11 @@ If you have an SD card reader attached to your controller, also folders work now
|
||||
You can write to file in a subfolder by specifying a similar text using small letters in the path.
|
||||
Also, backup copies of various operating systems are hidden, as well as files not ending with ".g".
|
||||
|
||||
*SD card folders:*
|
||||
|
||||
If you place a file auto[0-9].g into the root of the sd card, it will be automatically executed if you boot the printer. The same file will be executed by selecting "Autostart" from the menu.
|
||||
First *0 will be performed, than *1 and so on. That way, you can heat up or even print automatically without user interaction.
|
||||
|
||||
*Endstop trigger reporting:*
|
||||
|
||||
If an endstop is hit while moving towards the endstop, the location at which the firmware thinks that the endstop was triggered is outputed on the serial port.
|
||||
@@ -142,21 +152,33 @@ Movement variables:
|
||||
* M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) Unused in Marlin!!
|
||||
* M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec
|
||||
* M204 - Set default acceleration: S normal moves T filament only moves (M204 S3000 T7000) im mm/sec^2 also sets minimum segment time in ms (B20000) to prevent buffer underruns and M20 minimum feedrate
|
||||
* M206 - set home offsets. This sets the X,Y,Z coordinates of the endstops (and is added to the {X,Y,Z}_HOME_POS configuration options (and is also added to the coordinates, if any, provided to G82, as with earlier firmware)
|
||||
* M220 - set build speed mulitplying S:factor in percent ; aka "realtime tuneing in the gcode". So you can slow down if you have islands in one height-range, and speed up otherwise.
|
||||
* M301 - Set PID parameters P I and D
|
||||
* M221 - set the extrude multiplying S:factor in percent
|
||||
* M400 - Finish all buffered moves.
|
||||
|
||||
Temperature variables:
|
||||
* M301 - Set PID parameters P I and D
|
||||
* M302 - Allow cold extrudes
|
||||
* M303 - PID relay autotune S<temperature> sets the target temperature. (default target temperature = 150C)
|
||||
|
||||
Advance:
|
||||
|
||||
* M200 - Set filament diameter for advance
|
||||
* M205 - advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk
|
||||
* M205 - advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk
|
||||
|
||||
EEPROM:
|
||||
|
||||
* M500 - stores paramters in EEPROM
|
||||
* M500 - stores paramters in EEPROM. This parameters are stored: axis_steps_per_unit, max_feedrate, max_acceleration ,acceleration,retract_acceleration,
|
||||
minimumfeedrate,mintravelfeedrate,minsegmenttime, jerk velocities, PID
|
||||
* M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
|
||||
* M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
|
||||
* M503 - print the current settings (from memory not from eeprom)
|
||||
|
||||
MISC:
|
||||
|
||||
* M240 - Trigger a camera to take a photograph
|
||||
* M999 - Restart after being stopped by error
|
||||
|
||||
Configuring and compilation:
|
||||
============================
|
||||
|
||||
Reference in New Issue
Block a user