Compare commits
406 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 769796ed4c | |||
| e8c92e0a95 | |||
| abf0693e8e | |||
| 47319cf64e | |||
| e358a2d7af | |||
| 044a64a1fb | |||
| cd91e0e3e1 | |||
| d728e35658 | |||
| dcd3e8a211 | |||
| ddd9d0cfd4 | |||
| 0e58ef6805 | |||
| 0e89022cc3 | |||
| b86336c3f5 | |||
| b69e75c89a | |||
| 825adbd67b | |||
| 1d224cc031 | |||
| 06c03fe2f0 | |||
| 87ff61a8a6 | |||
| 8c94ad0d26 | |||
| aacbebbebe | |||
| 31873ec707 | |||
| de0448343f | |||
| 69961dbba3 | |||
| f67feea093 | |||
| 6c050b8440 | |||
| b9f9f8f7d3 | |||
| 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 | |||
| fa2e1be0ca | |||
| 7699f250e3 | |||
| 11518a987f | |||
| b447815de5 | |||
| bde30b2b48 | |||
| 13e185d330 | |||
| b58eae7657 | |||
| 3e7fcb813e | |||
| 2a77c84c8f | |||
| d47a3e5950 | |||
| f87c80889f | |||
| 154de69c02 | |||
| 6ef8459494 | |||
| 598eb1d4f1 | |||
| 9173a5713b | |||
| da040fd393 | |||
| bdb70c0509 | |||
| 5113513cb2 | |||
| d8a0c6450f | |||
| 4cc8e37bf1 | |||
| b5fae1104b | |||
| f9c5333f97 | |||
| 292ddd2edb | |||
| 25cd8af536 | |||
| 14702089ee | |||
| b51e8bf7e5 | |||
| 3183a14755 | |||
| 5edef148fe | |||
| 13e2ad2831 | |||
| 59cc5f889e | |||
| a11f3b2d2f | |||
| b0070a244a | |||
| abb7e63906 | |||
| 9f139d6e0e | |||
| e45e5c68bb | |||
| 7c6141ebc4 | |||
| 9c918a497b | |||
| ab01658fd2 | |||
| 42bedb3f60 | |||
| a991bde523 | |||
| 3e575533c5 | |||
| 2ae2ead97b | |||
| 71dc82e0b4 | |||
| 5aadc2f5ca | |||
| 8d0916af13 | |||
| 6cc6029d7a | |||
| 157aa7f2fd | |||
| 7aeb45303d | |||
| cee5f9020a | |||
| 3814bbb529 | |||
| 729cde4475 | |||
| 396270a0de | |||
| 11f2dafc4e | |||
| 8463e39a4a | |||
| 2bc160a978 | |||
| 57f9359a41 | |||
| 3c1a4aac2b | |||
| 212515148e | |||
| 6735025428 | |||
| 415aadf704 | |||
| 4bababf5b0 | |||
| f312216e97 | |||
| 651cde8b98 | |||
| 554cc1718d | |||
| 617968ab76 | |||
| 84d9cf7339 | |||
| e017228569 | |||
| 3320a5b37d | |||
| 06411d5c9e | |||
| 82c99625fa | |||
| 01001b89d2 | |||
| 88ee053af0 | |||
| b1d84d879b | |||
| f6fe7143e4 | |||
| dde4b40fa9 | |||
| 2bc5e7ec9e | |||
| aa4f9a6474 | |||
| 87fd249c43 | |||
| 1ec0c3b68a | |||
| 5b4625f79c | |||
| cc4a9cdb69 | |||
| 61c943b4bf | |||
| bae1e422f6 | |||
| 754d2d69b2 | |||
| 986f0ba76c | |||
| 460b788d78 | |||
| 3664ed6aad | |||
| 43f5c3e82b | |||
| 4fd75dc813 | |||
| 12e8edcac3 | |||
| cf50ba140f | |||
| 89e832c295 | |||
| b99c49ec3b | |||
| 95a0b28acb | |||
| af22e9cd38 | |||
| 7714b98da7 | |||
| dfd240b260 | |||
| 4f909963e4 | |||
| 6b86f15686 | |||
| 0bc9daa4f7 | |||
| b0c3871750 | |||
| 9c57453168 | |||
| 59205ac5fc | |||
| 7a4be21b4f | |||
| 716e89b87c | |||
| d00b7e5587 | |||
| e4ab0e5982 | |||
| 8cb29921a0 | |||
| 044886b4a0 | |||
| b19c8b74b9 | |||
| 6d95644c0d | |||
| 311627141b | |||
| 7216a12856 | |||
| 98805c9228 | |||
| 85da81e673 | |||
| b9ad0bb2ce | |||
| dd5ca68c87 | |||
| dd5296ad4d | |||
| f75f426dfa | |||
| 2d9a715655 | |||
| d2f034ba84 | |||
| 6aecf80278 | |||
| b128d25f27 | |||
| 26a1de1e44 | |||
| f8e170a44b | |||
| aad4b75b94 | |||
| a0dc66f7bf | |||
| 6d6f323535 | |||
| 4d6a5c29df | |||
| 74d0032e25 | |||
| 191f36b493 | |||
| c54a807824 | |||
| a6823a84e1 | |||
| 57e163e989 | |||
| b58787a367 | |||
| 71ca78982b | |||
| 235051253a | |||
| 27654bfe69 | |||
| cdf0bd4e63 | |||
| 6ac9b2e761 | |||
| ac8adabb2b | |||
| 0e0e4945d8 | |||
| c0f8c9fd72 | |||
| 0db97b9c7f | |||
| c9005865ed | |||
| 1022a5eaa7 |
@@ -0,0 +1,5 @@
|
||||
*.o
|
||||
applet/
|
||||
*~
|
||||
*.orig
|
||||
*.rej
|
||||
+180
-224
@@ -1,229 +1,230 @@
|
||||
#ifndef __CONFIGURATION_H
|
||||
#define __CONFIGURATION_H
|
||||
#ifndef CONFIGURATION_H
|
||||
#define CONFIGURATION_H
|
||||
|
||||
// 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
|
||||
|
||||
//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-05-02" //Personal revision number for changes to THIS file.
|
||||
#define STRING_CONFIG_H_AUTHOR "erik" //Who made the changes.
|
||||
|
||||
// This determines the communication speed of the printer
|
||||
#define BAUDRATE 250000
|
||||
//#define BAUDRATE 115200
|
||||
//#define BAUDRATE 230400
|
||||
|
||||
|
||||
// Frequency limit
|
||||
// See nophead's blog for more info
|
||||
// Not working O
|
||||
//#define XY_FREQUENCY_LIMIT 15
|
||||
|
||||
// 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)
|
||||
|
||||
// If defined the movements slow down when the look ahead buffer is only half full
|
||||
#define SLOWDOWN
|
||||
|
||||
// BASIC SETTINGS: select your board type, thermistor type, axis scaling, and endstop configuration
|
||||
|
||||
//// The following define selects which electronics board you have. Please choose the one that matches your setup
|
||||
// MEGA/RAMPS up to 1.2 = 3,
|
||||
// RAMPS 1.3 = 33
|
||||
// Gen6 = 5,
|
||||
// Gen7 custom (Alfons3 Version) = 10 "https://github.com/Alfons3/Generation_7_Electronics"
|
||||
// Gen7 v1.1, v1.2 = 11
|
||||
// Gen7 v1.3 = 12
|
||||
// Gen7 v1.4 = 13
|
||||
// MEGA/RAMPS up to 1.2 = 3
|
||||
// RAMPS 1.3 = 33 (Power outputs: Extruder, Bed, Fan)
|
||||
// RAMPS 1.3 = 34 (Power outputs: Extruder0, Extruder1, Bed)
|
||||
// Gen6 = 5
|
||||
// Gen6 deluxe = 51
|
||||
// Sanguinololu 1.2 and above = 62
|
||||
// Ultimaker = 7,
|
||||
// Melzi = 63
|
||||
// Ultimaker = 7
|
||||
// Teensylu = 8
|
||||
// Gen3+ =9
|
||||
|
||||
#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
|
||||
// 0 is not used
|
||||
// 1 is 100k thermistor - best choice for EPCOS 100k (4.7k pullup)
|
||||
// 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 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)
|
||||
|
||||
//// Thermistor settings:
|
||||
// 1 is 100k thermistor
|
||||
// 2 is 200k thermistor
|
||||
// 3 is mendel-parts thermistor
|
||||
// 4 is 10k thermistor
|
||||
// 5 is ParCan supplied 104GT-2 100K
|
||||
// 6 is EPCOS 100k
|
||||
// 7 is 100k Honeywell thermistor 135-104LAG-J01
|
||||
//#define THERMISTORHEATER_0 3
|
||||
//#define THERMISTORHEATER_1 3
|
||||
//#define THERMISTORBED 3
|
||||
|
||||
//#define HEATER_0_USES_THERMISTOR
|
||||
//#define HEATER_1_USES_THERMISTOR
|
||||
#define HEATER_0_USES_AD595
|
||||
//#define HEATER_1_USES_AD595
|
||||
|
||||
// Select one of these only to define how the bed temp is read.
|
||||
//#define BED_USES_THERMISTOR
|
||||
//#define BED_USES_AD595
|
||||
|
||||
#define BED_CHECK_INTERVAL 5000 //ms
|
||||
|
||||
//// Experimental watchdog and minimal temp
|
||||
// The watchdog waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
|
||||
// If the temperature has not increased at the end of that period, the target temperature is set to zero. It can be reset with another M104/M109
|
||||
/// CURRENTLY NOT IMPLEMENTED AND UNUSEABLE
|
||||
//#define WATCHPERIOD 5000 //5 seconds
|
||||
#define TEMP_SENSOR_0 -1
|
||||
#define TEMP_SENSOR_1 0
|
||||
#define TEMP_SENSOR_2 0
|
||||
#define TEMP_SENSOR_BED 0
|
||||
|
||||
// Actual temperature must be close to target for this long before M109 returns success
|
||||
//#define TEMP_RESIDENCY_TIME 20 // (seconds)
|
||||
//#define TEMP_HYSTERESIS 5 // (C°) range of +/- temperatures considered "close" to the target one
|
||||
#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
|
||||
// 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 5
|
||||
//#define HEATER_1_MINTEMP 5
|
||||
//#define BED_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 275
|
||||
//#define HEATER_1_MAXTEMP 275
|
||||
//#define BED_MAXTEMP 150
|
||||
|
||||
#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:
|
||||
// Uncomment the following line to enable PID support.
|
||||
|
||||
// Comment the following line to disable PID and enable bang-bang.
|
||||
#define PIDTEMP
|
||||
#define PID_MAX 255 // limits current to nozzle; 255=full current
|
||||
#ifdef PIDTEMP
|
||||
#if MOTHERBOARD == 62
|
||||
#error Sanguinololu does not support PID, sorry. Please disable it.
|
||||
#endif
|
||||
//#define PID_DEBUG // Sends debug data to the serial port.
|
||||
//#define PID_OPENLOOP 1 // Puts PID in open loop. M104 sets the output power in %
|
||||
|
||||
#define PID_MAX 255 // limits current to nozzle; 255=full current
|
||||
#define PID_INTEGRAL_DRIVE_MAX 255 //limit for the integral term
|
||||
#define K1 0.95 //smoothing factor withing the PID
|
||||
#define PID_dT 0.1 //sampling period of the PID
|
||||
#define PID_dT ((16.0 * 8.0)/(F_CPU / 64.0 / 256.0)) //sampling period of the
|
||||
|
||||
//To develop some PID settings for your machine, you can initiall follow
|
||||
// the Ziegler-Nichols method.
|
||||
// set Ki and Kd to zero.
|
||||
// heat with a defined Kp and see if the temperature stabilizes
|
||||
// ideally you do this graphically with repg.
|
||||
// the PID_CRITIAL_GAIN should be the Kp at which temperature oscillatins are not dampned out/decreas in amplitutde
|
||||
// PID_SWING_AT_CRITIAL is the time for a full period of the oscillations at the critical Gain
|
||||
// usually further manual tunine is necessary.
|
||||
// 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.08
|
||||
#define DEFAULT_Kd 114
|
||||
|
||||
#define PID_CRITIAL_GAIN 50
|
||||
#define PID_SWING_AT_CRITIAL 47 //seconds
|
||||
|
||||
//#define PID_PI //no differentail term
|
||||
#define PID_PID //normal PID
|
||||
|
||||
#ifdef PID_PID
|
||||
//PID according to Ziegler-Nichols method
|
||||
// #define DEFAULT_Kp (0.6*PID_CRITIAL_GAIN)
|
||||
// #define DEFAULT_Ki (2*Kp/PID_SWING_AT_CRITIAL*PID_dT)
|
||||
// #define DEFAULT_Kd (PID_SWING_AT_CRITIAL/8./PID_dT)
|
||||
|
||||
// Ultitmaker
|
||||
#define DEFAULT_Kp 22.2
|
||||
#define DEFAULT_Ki (1.25*PID_dT)
|
||||
#define DEFAULT_Kd (99/PID_dT)
|
||||
// Makergear
|
||||
// #define DEFAULT_Kp 7.0
|
||||
// #define DEFAULT_Ki 0.1
|
||||
// #define DEFAULT_Kd 12
|
||||
|
||||
// Mendel Parts V9 on 12V
|
||||
// #define DEFAULT_Kp 63.0
|
||||
// #define DEFAULT_Ki (2.25*PID_dT)
|
||||
// #define DEFAULT_Kd (440/PID_dT)
|
||||
#endif
|
||||
|
||||
#ifdef PID_PI
|
||||
//PI according to Ziegler-Nichols method
|
||||
#define DEFAULT_Kp (PID_CRITIAL_GAIN/2.2)
|
||||
#define DEFAULT_Ki (1.2*Kp/PID_SWING_AT_CRITIAL*PID_dT)
|
||||
#define DEFAULT_Kd (0)
|
||||
#endif
|
||||
|
||||
// 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
|
||||
#ifdef PID_ADD_EXTRUSION_RATE
|
||||
#define DEFAULT_Kc (3) //heatingpower=Kc*(e_speed)
|
||||
#endif
|
||||
// #define DEFAULT_Kp 63.0
|
||||
// #define DEFAULT_Ki 2.25
|
||||
// #define DEFAULT_Kd 440
|
||||
#endif // PIDTEMP
|
||||
|
||||
//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.
|
||||
|
||||
//===========================================================================
|
||||
//=============================Mechanical Settings===========================
|
||||
//===========================================================================
|
||||
|
||||
// Uncomment the following line to enable CoreXY kinematics
|
||||
// #define COREXY
|
||||
|
||||
// Endstop Settings
|
||||
// corse Endstop Settings
|
||||
#define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors
|
||||
// The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
|
||||
const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
|
||||
// For optos H21LOB set to true, for Mendel-Parts newer optos TCST2103 set to false
|
||||
|
||||
#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 = 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
|
||||
#define Y_ENABLE_ON 0
|
||||
#define Z_ENABLE_ON 0
|
||||
#define E_ENABLE_ON 0
|
||||
#define E_ENABLE_ON 0 // For all extruders
|
||||
|
||||
// Disables axis when it's not being used.
|
||||
#define DISABLE_X false
|
||||
#define DISABLE_Y false
|
||||
#define DISABLE_Z false
|
||||
#define DISABLE_E false
|
||||
#define DISABLE_E false // For all extruders
|
||||
|
||||
// Inverting axis direction
|
||||
//#define INVERT_X_DIR false // for Mendel set to false, for Orca set to true
|
||||
//#define INVERT_Y_DIR true // 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_E_DIR true // for direct drive extruder v9 set to true, for geared extruder set to false
|
||||
|
||||
#define INVERT_X_DIR true // for Mendel set to false, for Orca set to true
|
||||
#define INVERT_X_DIR true // for Mendel set to false, for Orca set to true
|
||||
#define INVERT_Y_DIR false // for Mendel set to true, for Orca set to false
|
||||
#define INVERT_Z_DIR true // for Mendel set to false, for Orca set to true
|
||||
#define INVERT_E_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false
|
||||
#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:
|
||||
// ENDSTOP SETTINGS:
|
||||
// Sets direction of endstops when homing; 1=MAX, -1=MIN
|
||||
#define X_HOME_DIR -1
|
||||
#define Y_HOME_DIR -1
|
||||
#define Z_HOME_DIR -1
|
||||
|
||||
#define min_software_endstops false //If true, axis won't move to coordinates less than zero.
|
||||
#define max_software_endstops false //If true, axis won't move to coordinates greater than the defined lengths below.
|
||||
#define X_MAX_LENGTH 210
|
||||
#define Y_MAX_LENGTH 210
|
||||
#define Z_MAX_LENGTH 210
|
||||
#define min_software_endstops true //If true, axis won't move to coordinates less than 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
|
||||
|
||||
#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. 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
|
||||
|
||||
//// MOVEMENT SETTINGS
|
||||
#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
|
||||
#define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0} // set the homing speeds (mm/min)
|
||||
|
||||
#define AXIS_RELATIVE_MODES {false, false, false, false}
|
||||
|
||||
#define MAX_STEP_FREQUENCY 40000 // Max step frequency for Ultimaker (5000 pps / half step)
|
||||
|
||||
// default settings
|
||||
|
||||
#define DEFAULT_AXIS_STEPS_PER_UNIT {78.7402,78.7402,200*8/3,760*1.1} // default steps per unit for ultimaker
|
||||
//#define DEFAULT_AXIS_STEPS_PER_UNIT {40, 40, 3333.92, 67} //sells mendel with v9 extruder
|
||||
#define DEFAULT_MAX_FEEDRATE {500, 500, 5, 200000} // (mm/sec)
|
||||
#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 3000 // X, Y, Z and E max acceleration in mm/s^2 for printing moves
|
||||
#define DEFAULT_RETRACT_ACCELERATION 7000 // X, Y, Z and E max acceleration in mm/s^2 for r retracts
|
||||
#define DEFAULT_RETRACT_ACCELERATION 3000 // X, Y, Z and E max acceleration in mm/s^2 for r retracts
|
||||
|
||||
#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
|
||||
#define DEFAULT_XYJERK 30.0 // (mm/sec)
|
||||
//
|
||||
#define DEFAULT_XYJERK 20.0 // (mm/sec)
|
||||
#define DEFAULT_ZJERK 0.4 // (mm/sec)
|
||||
|
||||
|
||||
|
||||
#define DEFAULT_EJERK 5.0 // (mm/sec)
|
||||
|
||||
//===========================================================================
|
||||
//=============================Additional Features===========================
|
||||
@@ -235,104 +236,59 @@ const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the
|
||||
// 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
|
||||
|
||||
|
||||
// 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.
|
||||
//#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
|
||||
|
||||
// extruder advance constant (s2/mm3)
|
||||
//
|
||||
// advance (steps) = STEPS_PER_CUBIC_MM_E * EXTUDER_ADVANCE_K * cubic mm per second ^ 2
|
||||
//
|
||||
// hooke's law says: force = k * distance
|
||||
// bernoulli's priniciple says: v ^ 2 / 2 + g . h + pressure / density = constant
|
||||
// so: v ^ 2 is proportional to number of steps we advance the extruder
|
||||
//#define ADVANCE
|
||||
|
||||
#ifdef ADVANCE
|
||||
#define EXTRUDER_ADVANCE_K .3
|
||||
|
||||
#define D_FILAMENT 1.7
|
||||
#define STEPS_MM_E 65
|
||||
#define EXTRUTION_AREA (0.25 * D_FILAMENT * D_FILAMENT * 3.14159)
|
||||
#define STEPS_PER_CUBIC_MM_E (axis_steps_per_unit[E_AXIS]/ EXTRUTION_AREA)
|
||||
|
||||
#endif // ADVANCE
|
||||
|
||||
//#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 ULTIPANEL
|
||||
//#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
|
||||
|
||||
|
||||
#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
|
||||
#define PLA_PREHEAT_FAN_SPEED 255 // Insert Value between 0 and 255
|
||||
|
||||
#define ABS_PREHEAT_HOTEND_TEMP 240
|
||||
#define ABS_PREHEAT_HPB_TEMP 100
|
||||
#define ABS_PREHEAT_FAN_SPEED 255 // Insert Value between 0 and 255
|
||||
|
||||
#else //no panel but just lcd
|
||||
#ifdef ULTRA_LCD
|
||||
#define LCD_WIDTH 16
|
||||
#define LCD_HEIGHT 2
|
||||
#define LCD_HEIGHT 2
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// A debugging feature to compare calculated vs performed steps, to see if steps are lost by the software.
|
||||
//#define DEBUG_STEPS
|
||||
// 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
|
||||
|
||||
// Arc interpretation settings:
|
||||
#define MM_PER_ARC_SEGMENT 1
|
||||
#define N_ARC_CORRECTION 25
|
||||
|
||||
|
||||
//automatic temperature: The hot end target temperature is calculated by all the buffered lines of gcode.
|
||||
//The maximum buffered steps/sec of the extruder motor are called "se".
|
||||
//You enter the autotemp mode by a M109 S<mintemp> T<maxtemp> F<factor>
|
||||
// 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
|
||||
#ifdef AUTOTEMP
|
||||
#define AUTOTEMP_OLDWEIGHT 0.98
|
||||
#endif
|
||||
|
||||
|
||||
const int dropsegments=5; //everything with less than this number of steps will be ignored as move and joined with the next movement
|
||||
|
||||
//===========================================================================
|
||||
//=============================Buffers ============================
|
||||
//===========================================================================
|
||||
|
||||
|
||||
|
||||
// The number of linear motions that can be in the plan at any give time.
|
||||
// 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
|
||||
#else
|
||||
#define BLOCK_BUFFER_SIZE 16 // maximize block buffer
|
||||
#endif
|
||||
|
||||
|
||||
//The ASCII buffer for recieving from the serial:
|
||||
#define MAX_CMD_SIZE 96
|
||||
#define BUFSIZE 4
|
||||
|
||||
// SF send wrong arc g-codes when using Arc Point as fillet procedure
|
||||
//#define SF_ARC_FIX
|
||||
|
||||
#include "Configuration_adv.h"
|
||||
#include "thermistortables.h"
|
||||
|
||||
#endif //__CONFIGURATION_H
|
||||
|
||||
@@ -0,0 +1,263 @@
|
||||
#ifndef CONFIGURATION_ADV_H
|
||||
#define CONFIGURATION_ADV_H
|
||||
|
||||
//===========================================================================
|
||||
//=============================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
|
||||
|
||||
//// Heating sanity check:
|
||||
// This waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
|
||||
// If the temperature has not increased at the end of that period, the target temperature is set to zero.
|
||||
// It can be reset with another M104/M109
|
||||
//#define WATCHPERIOD 20000 //20 seconds
|
||||
|
||||
// Wait for Cooldown
|
||||
// This defines if the M109 call should not block if it is cooling down.
|
||||
// example: From a current temp of 220, you set M109 S200.
|
||||
// if CooldownNoWait is defined M109 will not wait for the cooldown to finish
|
||||
#define CooldownNoWait true
|
||||
|
||||
#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
|
||||
#ifdef PID_ADD_EXTRUSION_RATE
|
||||
#define DEFAULT_Kc (1) //heatingpower=Kc*(e_speed)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
//automatic temperature: The hot end target temperature is calculated by all the buffered lines of gcode.
|
||||
//The maximum buffered steps/sec of the extruder motor are called "se".
|
||||
//You enter the autotemp mode by a M109 S<mintemp> T<maxtemp> F<factor>
|
||||
// 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 B260 F1 in the start.gcode
|
||||
#define AUTOTEMP
|
||||
#ifdef AUTOTEMP
|
||||
#define AUTOTEMP_OLDWEIGHT 0.98
|
||||
#endif
|
||||
|
||||
// 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 190
|
||||
#define EXTRUDER_RUNOUT_SECONDS 30.
|
||||
#define EXTRUDER_RUNOUT_ESTEPS 14. //mm filament
|
||||
#define EXTRUDER_RUNOUT_SPEED 1500. //extrusion speed
|
||||
#define EXTRUDER_RUNOUT_EXTRUDE 100
|
||||
|
||||
//These defines help to calibrate the AD595 sensor in case you get wrong temperature measurements.
|
||||
//The measured temperature is defined as "actualTemp = (measuredTemp * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET"
|
||||
#define TEMP_SENSOR_AD595_OFFSET 0.0
|
||||
#define TEMP_SENSOR_AD595_GAIN 1.0
|
||||
|
||||
//This is for controlling a fan to cool down the stepper drivers
|
||||
//it will turn on when any driver is enabled
|
||||
//and turn off after the set amount of seconds from last driver being disabled again
|
||||
//#define CONTROLLERFAN_PIN 23 //Pin used for the fan to cool controller, comment out to disable this function
|
||||
#define CONTROLLERFAN_SEC 60 //How many seconds, after all motors were disabled, the fan should run
|
||||
|
||||
//===========================================================================
|
||||
//=============================Mechanical Settings===========================
|
||||
//===========================================================================
|
||||
|
||||
// This defines the number of extruders
|
||||
#define EXTRUDERS 1
|
||||
|
||||
#define ENDSTOPS_ONLY_FOR_HOMING // If defined the endstops will only be used for homing
|
||||
|
||||
//#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 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 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
|
||||
|
||||
#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.
|
||||
#define DEFAULT_MINSEGMENTTIME 20000
|
||||
|
||||
// If defined the movements slow down when the look ahead buffer is only half full
|
||||
#define SLOWDOWN
|
||||
|
||||
// Frequency limit
|
||||
// See nophead's blog for more info
|
||||
// Not working O
|
||||
//#define XY_FREQUENCY_LIMIT 15
|
||||
|
||||
// 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 0.05// (mm/sec)
|
||||
|
||||
//===========================================================================
|
||||
//=============================Additional Features===========================
|
||||
//===========================================================================
|
||||
|
||||
|
||||
#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.
|
||||
|
||||
// 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.
|
||||
//#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
|
||||
|
||||
// extruder advance constant (s2/mm3)
|
||||
//
|
||||
// advance (steps) = STEPS_PER_CUBIC_MM_E * EXTUDER_ADVANCE_K * cubic mm per second ^ 2
|
||||
//
|
||||
// hooke's law says: force = k * distance
|
||||
// bernoulli's priniciple says: v ^ 2 / 2 + g . h + pressure / density = constant
|
||||
// so: v ^ 2 is proportional to number of steps we advance the extruder
|
||||
//#define ADVANCE
|
||||
|
||||
#ifdef ADVANCE
|
||||
#define EXTRUDER_ADVANCE_K .0
|
||||
|
||||
#define D_FILAMENT 2.85
|
||||
#define STEPS_MM_E 836
|
||||
#define EXTRUTION_AREA (0.25 * D_FILAMENT * D_FILAMENT * 3.14159)
|
||||
#define STEPS_PER_CUBIC_MM_E (axis_steps_per_unit[E_AXIS]/ EXTRUTION_AREA)
|
||||
|
||||
#endif // ADVANCE
|
||||
|
||||
// Arc interpretation settings:
|
||||
#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
|
||||
|
||||
// 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
|
||||
|
||||
#ifdef ULTIPANEL
|
||||
#undef SDCARDDETECTINVERTED
|
||||
#endif
|
||||
//===========================================================================
|
||||
//=============================Buffers ============================
|
||||
//===========================================================================
|
||||
|
||||
// The number of linear motions that can be in the plan at any give time.
|
||||
// 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
|
||||
#else
|
||||
#define BLOCK_BUFFER_SIZE 16 // maximize block buffer
|
||||
#endif
|
||||
|
||||
|
||||
//The ASCII buffer for recieving from the serial:
|
||||
#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 ============================
|
||||
//===========================================================================
|
||||
|
||||
#if TEMP_SENSOR_0 > 0
|
||||
#define THERMISTORHEATER_0 TEMP_SENSOR_0
|
||||
#define HEATER_0_USES_THERMISTOR
|
||||
#endif
|
||||
#if TEMP_SENSOR_1 > 0
|
||||
#define THERMISTORHEATER_1 TEMP_SENSOR_1
|
||||
#define HEATER_1_USES_THERMISTOR
|
||||
#endif
|
||||
#if TEMP_SENSOR_2 > 0
|
||||
#define THERMISTORHEATER_2 TEMP_SENSOR_2
|
||||
#define HEATER_2_USES_THERMISTOR
|
||||
#endif
|
||||
#if TEMP_SENSOR_BED > 0
|
||||
#define THERMISTORBED TEMP_SENSOR_BED
|
||||
#define BED_USES_THERMISTOR
|
||||
#endif
|
||||
#if TEMP_SENSOR_0 == -1
|
||||
#define HEATER_0_USES_AD595
|
||||
#endif
|
||||
#if TEMP_SENSOR_1 == -1
|
||||
#define HEATER_1_USES_AD595
|
||||
#endif
|
||||
#if TEMP_SENSOR_2 == -1
|
||||
#define HEATER_2_USES_AD595
|
||||
#endif
|
||||
#if TEMP_SENSOR_BED == -1
|
||||
#define BED_USES_AD595
|
||||
#endif
|
||||
#if TEMP_SENSOR_0 == -2
|
||||
#define HEATER_0_USES_MAX6675
|
||||
#endif
|
||||
#if TEMP_SENSOR_0 == 0
|
||||
#undef HEATER_0_MINTEMP
|
||||
#undef HEATER_0_MAXTEMP
|
||||
#endif
|
||||
#if TEMP_SENSOR_1 == 0
|
||||
#undef HEATER_1_MINTEMP
|
||||
#undef HEATER_1_MAXTEMP
|
||||
#endif
|
||||
#if TEMP_SENSOR_2 == 0
|
||||
#undef HEATER_2_MINTEMP
|
||||
#undef HEATER_2_MAXTEMP
|
||||
#endif
|
||||
#if TEMP_SENSOR_BED == 0
|
||||
#undef BED_MINTEMP
|
||||
#undef BED_MAXTEMP
|
||||
#endif
|
||||
|
||||
|
||||
#endif //__CONFIGURATION_ADV_H
|
||||
+109
-59
@@ -1,17 +1,25 @@
|
||||
#ifndef __EEPROMH
|
||||
#define __EEPROMH
|
||||
#ifndef EEPROM_H
|
||||
#define EEPROM_H
|
||||
|
||||
#include "Marlin.h"
|
||||
#include "planner.h"
|
||||
#include "temperature.h"
|
||||
#include <EEPROM.h>
|
||||
//#include <EEPROM.h>
|
||||
|
||||
int plaPreheatHotendTemp;
|
||||
int plaPreheatHPBTemp;
|
||||
int plaPreheatFanSpeed;
|
||||
|
||||
int absPreheatHotendTemp;
|
||||
int absPreheatHPBTemp;
|
||||
int absPreheatFanSpeed;
|
||||
|
||||
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(ee++, *p++);
|
||||
eeprom_write_byte((unsigned char *)ee++, *p++);
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -20,7 +28,7 @@ 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(ee++);
|
||||
*p++ = eeprom_read_byte((unsigned char *)ee++);
|
||||
return i;
|
||||
}
|
||||
//======================================================================================
|
||||
@@ -36,9 +44,9 @@ template <class T> int EEPROM_readAnything(int &ee, T& value)
|
||||
// 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 "V04"
|
||||
#define EEPROM_VERSION "V07"
|
||||
|
||||
inline void StoreSettings()
|
||||
inline void EEPROM_StoreSettings()
|
||||
{
|
||||
#ifdef EEPROM_SETTINGS
|
||||
char ver[4]= "000";
|
||||
@@ -54,6 +62,14 @@ inline void StoreSettings()
|
||||
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);
|
||||
EEPROM_writeAnything(i,plaPreheatHotendTemp);
|
||||
EEPROM_writeAnything(i,plaPreheatHPBTemp);
|
||||
EEPROM_writeAnything(i,plaPreheatFanSpeed);
|
||||
EEPROM_writeAnything(i,absPreheatHotendTemp);
|
||||
EEPROM_writeAnything(i,absPreheatHPBTemp);
|
||||
EEPROM_writeAnything(i,absPreheatFanSpeed);
|
||||
#ifdef PIDTEMP
|
||||
EEPROM_writeAnything(i,Kp);
|
||||
EEPROM_writeAnything(i,Ki);
|
||||
@@ -71,7 +87,72 @@ inline void StoreSettings()
|
||||
#endif //EEPROM_SETTINGS
|
||||
}
|
||||
|
||||
inline void RetrieveSettings(bool def=false)
|
||||
|
||||
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_ECHOLNPGM("Home offset (mm):");
|
||||
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_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;
|
||||
@@ -91,6 +172,14 @@ inline void RetrieveSettings(bool def=false)
|
||||
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);
|
||||
EEPROM_readAnything(i,plaPreheatHotendTemp);
|
||||
EEPROM_readAnything(i,plaPreheatHPBTemp);
|
||||
EEPROM_readAnything(i,plaPreheatFanSpeed);
|
||||
EEPROM_readAnything(i,absPreheatHotendTemp);
|
||||
EEPROM_readAnything(i,absPreheatHPBTemp);
|
||||
EEPROM_readAnything(i,absPreheatFanSpeed);
|
||||
#ifndef PIDTEMP
|
||||
float Kp,Ki,Kd;
|
||||
#endif
|
||||
@@ -102,6 +191,7 @@ inline void RetrieveSettings(bool def=false)
|
||||
SERIAL_ECHOLNPGM("Stored settings retreived:");
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
float tmp1[]=DEFAULT_AXIS_STEPS_PER_UNIT;
|
||||
float tmp2[]=DEFAULT_MAX_FEEDRATE;
|
||||
@@ -119,62 +209,22 @@ inline void RetrieveSettings(bool def=false)
|
||||
mintravelfeedrate=DEFAULT_MINTRAVELFEEDRATE;
|
||||
max_xy_jerk=DEFAULT_XYJERK;
|
||||
max_z_jerk=DEFAULT_ZJERK;
|
||||
max_e_jerk=DEFAULT_EJERK;
|
||||
add_homeing[0] = add_homeing[1] = add_homeing[2] = 0;
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLN("Using Default settings:");
|
||||
#ifdef ULTIPANEL
|
||||
plaPreheatHotendTemp = PLA_PREHEAT_HOTEND_TEMP;
|
||||
plaPreheatHPBTemp = PLA_PREHEAT_HPB_TEMP;
|
||||
plaPreheatFanSpeed = PLA_PREHEAT_FAN_SPEED;
|
||||
absPreheatHotendTemp = ABS_PREHEAT_HOTEND_TEMP;
|
||||
absPreheatHPBTemp = ABS_PREHEAT_HPB_TEMP;
|
||||
absPreheatFanSpeed = ABS_PREHEAT_FAN_SPEED;
|
||||
#endif
|
||||
}
|
||||
#ifdef EEPROM_CHITCHAT
|
||||
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]/60);
|
||||
SERIAL_ECHOPAIR(" Y",max_feedrate[1]/60 );
|
||||
SERIAL_ECHOPAIR(" Z", max_feedrate[2]/60 );
|
||||
SERIAL_ECHOPAIR(" E", max_feedrate[3]/60);
|
||||
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/60 );
|
||||
SERIAL_ECHOPAIR(" T" ,mintravelfeedrate/60 );
|
||||
SERIAL_ECHOPAIR(" B" ,minsegmenttime );
|
||||
SERIAL_ECHOPAIR(" X" ,max_xy_jerk/60 );
|
||||
SERIAL_ECHOPAIR(" Z" ,max_z_jerk/60);
|
||||
SERIAL_ECHOLN("");
|
||||
#ifdef PIDTEMP
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM("PID settings:");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPAIR(" M301 P",Kp );
|
||||
SERIAL_ECHOPAIR(" I" ,Ki );
|
||||
SERIAL_ECHOPAIR(" D" ,Kd);
|
||||
SERIAL_ECHOLN("");
|
||||
#endif
|
||||
EEPROM_printSettings();
|
||||
#endif
|
||||
|
||||
#endif //EEPROM_SETTINGS
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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.
+205
-228
@@ -1,49 +1,100 @@
|
||||
# Sprinter Arduino Project Makefile
|
||||
#
|
||||
# Makefile Based on:
|
||||
# Arduino 0011 Makefile
|
||||
# Arduino adaptation by mellis, eighthave, oli.keller
|
||||
#
|
||||
# This has been tested with Arduino 0022.
|
||||
#
|
||||
# This makefile allows you to build sketches from the command line
|
||||
# without the Arduino environment (or Java).
|
||||
#
|
||||
# Detailed instructions for using the makefile:
|
||||
#
|
||||
# 1. 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).
|
||||
#
|
||||
# 2. 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*).
|
||||
#
|
||||
# 3. 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. If you are using Gen7 electronics, you
|
||||
# probably need to use 20000000. Either way, you must regenerate
|
||||
# the speed lookup table with create_speed_lookuptable.py.
|
||||
#
|
||||
# 4. Type "make" and press enter to compile/verify your program.
|
||||
#
|
||||
# 5. Type "make upload", reset your Arduino board, and press enter to
|
||||
# upload your program to the Arduino board.
|
||||
#
|
||||
# $Id$
|
||||
|
||||
#For "old" Arduino Mega
|
||||
#MCU = atmega1280
|
||||
#For Arduino Mega2560
|
||||
#MCU = atmega2560
|
||||
#For Sanguinololu
|
||||
MCU = atmega644p
|
||||
|
||||
# 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
|
||||
F_CPU = 16000000
|
||||
|
||||
UPLOAD_RATE = 115200
|
||||
AVRDUDE_PROGRAMMER = arduino
|
||||
PORT = /dev/arduino
|
||||
|
||||
TARGET = $(notdir $(CURDIR))
|
||||
# CHANGE BELOW:
|
||||
#~ INSTALL_DIR = /Applications/Arduino.app/Contents/Resources/Java
|
||||
INSTALL_DIR = /home/bkubicek/software/arduino-0022
|
||||
#~ PORT = /dev/cu.usbserial*
|
||||
PORT = /dev/ttyACM0
|
||||
|
||||
# Get these values from:
|
||||
# $(INSTALL_DIR)/hardware/boards.txt
|
||||
# (arduino-0022/hardware/arduino/boards.txt)
|
||||
# The values below are for the "Arduino Duemilanove or Nano w/ ATmega328"
|
||||
# now for "Arduino Mega 2560"
|
||||
UPLOAD_SPEED = 115200
|
||||
UPLOAD_PROTOCOL = stk500v2
|
||||
BUILD_MCU = atmega2560
|
||||
BUILD_F_CPU = 16000000L
|
||||
TERM=bash
|
||||
# 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
|
||||
|
||||
# getting undefined reference to `__cxa_pure_virtual'
|
||||
#~ [http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1254180518 Arduino Forum - Makefile]
|
||||
#~ http://www.arduino.cc/playground/OpenBSD/CLI
|
||||
#~ [http://arduino.cc/forum/index.php?topic=52041.0 A "simple" makefile for Arduino]
|
||||
#~ [http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1275488191 Arduino Forum - Configuring avr-gcc options in arduino IDE]
|
||||
# found in /usr/lib/gcc/avr/4.3.5/cc1plus; fixed with -Wl,--gc-section
|
||||
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 = $(INSTALL_DIR)/hardware/tools/avr/bin
|
||||
# in Ubuntu, avr-gcc is installed separate;
|
||||
# only avrdude comes with the IDE
|
||||
AVR_TOOLS_PATH = /usr/bin
|
||||
AVR_DUDE_PATH = $(INSTALL_DIR)/hardware/tools
|
||||
#
|
||||
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
|
||||
# added applet/$(TARGET).cpp as in IDE 0022
|
||||
CXXSRC = $(ARDUINO)/HardwareSerial.cpp $(ARDUINO)/WMath.cpp \
|
||||
$(ARDUINO)/Print.cpp \
|
||||
$(ARDUINO)/main.cpp
|
||||
# applet/$(TARGET).cpp # no need, having a rule now for applet/$(TARGET).cpp.o
|
||||
# added main.cpp, as in 0022
|
||||
AVR_TOOLS_PATH =
|
||||
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").
|
||||
@@ -54,189 +105,157 @@ MAKEFILE = Makefile
|
||||
# AVR (extended) COFF requires stabs, plus an avr-objcopy run.
|
||||
DEBUG = stabs
|
||||
|
||||
OPT = 2
|
||||
OPT = s
|
||||
|
||||
# Place -D or -U options here
|
||||
#~ CDEFS = -DBUILD_F_CPU=$(BUILD_F_CPU)
|
||||
#~ CXXDEFS = -DBUILD_F_CPU=$(BUILD_F_CPU)
|
||||
# now called DF_CPU
|
||||
CDEFS = -DF_CPU=$(BUILD_F_CPU) -DARDUINO=22
|
||||
CXXDEFS = -DF_CPU=$(BUILD_F_CPU) -DARDUINO=22
|
||||
CDEFS = -DF_CPU=$(F_CPU)
|
||||
CXXDEFS = -DF_CPU=$(F_CPU)
|
||||
|
||||
# Place -I options here
|
||||
CINCS = -I$(ARDUINO) -I$(INSTALL_DIR)/libraries/LiquidCrystal/ -I$(INSTALL_DIR)/libraries/EEPROM/
|
||||
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
|
||||
# c89 - "ANSI" C
|
||||
# gnu89 - c89 plus GCC extensions
|
||||
# c99 - ISO C99 standard (not yet fully implemented)
|
||||
# c99 - ISO C99 standard (not yet fully implemented)
|
||||
# gnu99 - c99 plus GCC extensions
|
||||
CSTANDARD = -std=gnu99
|
||||
#CSTANDARD = -std=gnu99
|
||||
CDEBUG = -g$(DEBUG)
|
||||
# note that typically, IDE 0022 uses -w to suppress warnings (both in cpp and c)!
|
||||
CWARN = -Wall
|
||||
#~ CWARN = -w
|
||||
# "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++:
|
||||
CCWARN = -Wstrict-prototypes
|
||||
CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
|
||||
CWARN = -Wall -Wstrict-prototypes
|
||||
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)
|
||||
|
||||
# to eliminate pins_ardiuno warnings:
|
||||
# http://arduino.cc/pipermail/developers_arduino.cc/2010-December/004005.html
|
||||
|
||||
# [http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1254180518 Arduino Forum - Makefile]
|
||||
#~ For building the objects files "-ffunction-sections -fdata-sections" was missing
|
||||
#~ and the final avr-gcc call needs "-Wl,--gc-section".
|
||||
CXSECTF = -fno-exceptions -ffunction-sections -fdata-sections
|
||||
CFINALF = -Wl,--gc-section
|
||||
|
||||
CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CCWARN) $(CSTANDARD) $(CEXTRA)
|
||||
# added CWARN also to .cpp
|
||||
CXXFLAGS = $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CXSECTF)
|
||||
#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
|
||||
CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING)
|
||||
CXXFLAGS = $(CDEFS) $(CINCS) -O$(OPT) -Wall $(CEXTRA) $(CTUNING)
|
||||
#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 \
|
||||
-p $(BUILD_MCU) -P $(AVRDUDE_PORT) -c $(UPLOAD_PROTOCOL) \
|
||||
-b $(UPLOAD_SPEED) -C $(INSTALL_DIR)/hardware/tools/avrdude.conf
|
||||
# -b $(UPLOAD_SPEED) -C $(INSTALL_DIR)/hardware/tools/avr/etc/avrdude.conf
|
||||
AVRDUDE_WRITE_FLASH = -U flash:w:applet/$(TARGET).hex:i
|
||||
AVRDUDE_FLAGS = -D -C $(INSTALL_DIR)/hardware/tools/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
|
||||
AVRDUDE = $(AVR_DUDE_PATH)/avrdude
|
||||
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 = avrdude
|
||||
REMOVE = rm -f
|
||||
MV = mv -f
|
||||
|
||||
# Define all object files.
|
||||
# NOTE: obj files will be created in respective src directories (libraries or $(INSTALL_DIR));
|
||||
# make clean deletes them fine
|
||||
# note that srcs are in libraries or other directories;
|
||||
# $(CXXSRC:.cpp=.o) will cause obj files to be in same loc as src files
|
||||
#~ OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o)
|
||||
# to change the output directory for object files;
|
||||
# must change the obj list here!
|
||||
# and then, match to corresponding rule somehow?
|
||||
# or leave this - and parse in rule (auth automatic variable $(@F))?
|
||||
# "Suffix Replacement"
|
||||
OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o)
|
||||
|
||||
# added - OBJ list, transformed into applet/
|
||||
OBJT = $(addprefix applet/,$(notdir $(OBJ)))
|
||||
ALLSRC = $(SRC) $(CXXSRC) $(ASRC)
|
||||
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)
|
||||
|
||||
# Combine all necessary flags and optional flags.
|
||||
# Add target processor to flags.
|
||||
ALL_CFLAGS = -mmcu=$(BUILD_MCU) -I. $(CFLAGS)
|
||||
ALL_CXXFLAGS = -mmcu=$(BUILD_MCU) -I. $(CXXFLAGS)
|
||||
ALL_ASFLAGS = -mmcu=$(BUILD_MCU) -I. -x assembler-with-cpp $(ASFLAGS)
|
||||
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
|
||||
ALL_CXXFLAGS = -mmcu=$(MCU) $(CXXFLAGS)
|
||||
ALL_ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp $(ASFLAGS)
|
||||
|
||||
# depended libraries of .pde need to be added from
|
||||
# $(INSTALL_DIR)/libraries (TODO: and/or ~/sketchbook/libraries)
|
||||
# grep for 'include', test if exists, add...
|
||||
# note: prefix "a real tab character" http://www.delorie.com/djgpp/doc/ug/larger/makefiles.html
|
||||
# $$ to escape $ for shell;
|
||||
# note: must NOT put comments # inside bash execution;
|
||||
# those would get removed by make; making shell see "EOF in backquote substitution"
|
||||
# echo $$ix ; \
|
||||
# 'shell' twice - for each subprocess! Backtick doesn't get expanded?
|
||||
GREPRES:=$(shell for ix in $(shell grep include $(TARGET).pde | sed 's/.*[<"]\(.*\).h[>"].*/\1/'); do \
|
||||
if [ -d $(INSTALL_DIR)/libraries/$$ix ] ; then \
|
||||
LINCS="$$LINCS -I$(INSTALL_DIR)/libraries/$$ix" ;\
|
||||
fi; \
|
||||
done; \
|
||||
echo $$LINCS)
|
||||
# append includes:
|
||||
CINCS += $(GREPRES)
|
||||
CXXINCS += $(GREPRES)
|
||||
# append library source .cpp files too (CXXSRC)
|
||||
GREPRESB:=$(shell for ix in $(shell grep include $(TARGET).pde | sed 's/.*[<"]\(.*\).h[>"].*/\1/'); do \
|
||||
if [ -d $(INSTALL_DIR)/libraries/$$ix ] ; then \
|
||||
CPPSRCS="$$CPPSRCS $(INSTALL_DIR)/libraries/$$ix/*.cpp" ;\
|
||||
fi; \
|
||||
done; \
|
||||
echo $$CPPSRCS)
|
||||
CXXSRC += $(GREPRESB)
|
||||
# added - only CXX obj from libraries:
|
||||
CXXLIBOBJ = $(GREPRESB:.cpp=.o)
|
||||
# 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: applet_files build sizeafter
|
||||
all: sizeafter
|
||||
|
||||
build: elf hex
|
||||
build: applet 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
|
||||
# @ supresses printout of the cmdline itself; so only the out of echo is printed
|
||||
@echo ALL OBJT: $(OBJT)
|
||||
@echo ALL CXXLIBOBJ: $(CXXLIBOBJ)
|
||||
# echo '#include "WProgram.h"' > applet/$(TARGET).cpp
|
||||
@echo "#include \"WProgram.h\"\nvoid setup();\nvoid loop();\n" > applet/$(TARGET).cpp
|
||||
cat $(TARGET).pde >> applet/$(TARGET).cpp
|
||||
# no more need to cat main.cpp (v0022) - now it is compiled in
|
||||
# cat $(ARDUINO)/main.cpp >> applet/$(TARGET).cpp
|
||||
# Creates the object directory
|
||||
applet:
|
||||
$P mkdir -p applet
|
||||
|
||||
# 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.
|
||||
$(Pecho) " WR $@"
|
||||
$P echo '#include "WProgram.h"' > $@
|
||||
$P echo '#include "$<"' >>$@
|
||||
$P echo '#include "$(ARDUINO)/main.cpp"' >> $@
|
||||
|
||||
elf: applet/$(TARGET).elf
|
||||
hex: applet/$(TARGET).hex
|
||||
eep: applet/$(TARGET).eep
|
||||
lss: applet/$(TARGET).lss
|
||||
lss: applet/$(TARGET).lss
|
||||
sym: applet/$(TARGET).sym
|
||||
|
||||
# Program the device.
|
||||
# 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.
|
||||
# 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: build
|
||||
$P if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); 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
|
||||
--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
|
||||
.PRECIOUS: .o
|
||||
|
||||
.elf.hex:
|
||||
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
|
||||
$(Pecho) " COPY $@"
|
||||
$P $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
|
||||
|
||||
.elf.eep:
|
||||
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
||||
--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
|
||||
-$(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:
|
||||
@@ -246,76 +265,34 @@ extcoff: $(TARGET).elf
|
||||
.elf.sym:
|
||||
$(NM) -n $< > $@
|
||||
|
||||
# Link: create ELF output file from library.
|
||||
# NOTE: applet/$(TARGET).cpp.o MUST BE BEFORE applet/core.a
|
||||
# in the dependency list, so its rule runs first!
|
||||
applet/$(TARGET).elf: $(TARGET).pde applet/$(TARGET).cpp.o applet/core.a
|
||||
# $(CC) $(ALL_CFLAGS) -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS)
|
||||
# changed as in IDE v0022: link cpp obj files
|
||||
@echo $$(tput bold)$$(tput setaf 2) $(CC) $$(tput sgr0) $(ALL_CFLAGS) $(CFINALF) -o $@ applet/$(TARGET).cpp.o $(CXXOBJ) -L. applet/core.a $(LDFLAGS)
|
||||
@$(CC) $(ALL_CFLAGS) $(CFINALF) -o $@ applet/$(TARGET).cpp.o $(CXXOBJ) -L. applet/core.a $(LDFLAGS)
|
||||
# Link: create ELF output file from library.
|
||||
applet/$(TARGET).elf: applet/$(TARGET).cpp applet/core.a Configuration.h
|
||||
$(Pecho) " CXX $@"
|
||||
$P $(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS)
|
||||
|
||||
# added: cpp.o depends on cpp (and .pde which generates it)
|
||||
# $< "first item in the dependencies list"; $@ "left side of the :"; $^ "right side of the :"
|
||||
# http://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/
|
||||
applet/$(TARGET).cpp.o: applet/$(TARGET).cpp
|
||||
@echo $$(tput bold) $(CXX) $$(tput sgr0) -c $(ALL_CXXFLAGS) $< -o $@
|
||||
@$(CXX) -c $(ALL_CXXFLAGS) $< -o $@
|
||||
applet/core.a: $(OBJ)
|
||||
$P for i in $(OBJ); do echo " AR $$i"; $(AR) rcs applet/core.a $$i; done
|
||||
|
||||
#~ applet/core.a: $(OBJ)
|
||||
#~ @for i in $(OBJ); do echo $(AR) rcs applet/core.a $$i; $(AR) rcs applet/core.a $$i; done
|
||||
applet/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE)
|
||||
$(Pecho) " CC $@"
|
||||
$P $(CC) -MMD -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
applet/core.a: $(OBJT)
|
||||
@for i in $(OBJT); do echo $(AR) rcs applet/core.a $$i; $(AR) rcs applet/core.a $$i; done
|
||||
applet/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
|
||||
$(Pecho) " CXX $@"
|
||||
$P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@
|
||||
|
||||
# iterate through OBJ to find the original location; then build depending on source extension
|
||||
# TODO: add handling of assembler files
|
||||
applet/%.o:
|
||||
@for iob in $(OBJ); do \
|
||||
if [ "`basename $$iob`" = "`basename $@`" ]; then \
|
||||
for ios in $(ALLSRC); do \
|
||||
if [ "$${iob%%.*}" = "$${ios%%.*}" ]; then \
|
||||
case $${ios##*.} in \
|
||||
"cpp") \
|
||||
echo "$$(tput bold)$$(tput setaf 1) $(CXX) $$(tput sgr0) -c $(ALL_CXXFLAGS) $$ios -o $@"; \
|
||||
$(CXX) -c $(ALL_CXXFLAGS) $$ios -o $@;; \
|
||||
"c") \
|
||||
echo "$$(tput bold)$$(tput setaf 1) $(CC) $$(tput sgr0) -c $(ALL_CFLAGS) $$ios -o $@"; \
|
||||
$(CC) -c $(ALL_CFLAGS) $$ios -o $@;; \
|
||||
esac; \
|
||||
fi; \
|
||||
done; \
|
||||
fi; \
|
||||
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 $@
|
||||
|
||||
#~ # Automatic dependencies
|
||||
#~ %.d: %.c
|
||||
#~ $(CC) -M $(ALL_CFLAGS) $< | sed "s;$(notdir $*).o:;$*.o $*.d:;" > $@
|
||||
|
||||
#~ %.d: %.cpp
|
||||
#~ $(CXX) -M $(ALL_CXXFLAGS) $< | sed "s;$(notdir $*).o:;$*.o $*.d:;" > $@
|
||||
|
||||
# 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 \
|
||||
$(OBJT) applet/$(TARGET).cpp.o \
|
||||
$(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
|
||||
$(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)
|
||||
$(Pecho) " RMDIR applet/"
|
||||
$P rm -rf applet
|
||||
|
||||
.PHONY: all build elf hex eep lss sym program coff extcoff clean applet_files sizebefore sizeafter
|
||||
|
||||
.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}
|
||||
|
||||
+116
-27
@@ -1,26 +1,74 @@
|
||||
#ifndef __MARLINH
|
||||
#define __MARLINH
|
||||
|
||||
// Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
|
||||
// Licence: GPL
|
||||
#include <WProgram.h>
|
||||
#include "fastio.h"
|
||||
|
||||
#ifndef MARLIN_H
|
||||
#define MARLIN_H
|
||||
|
||||
#define HardwareSerial_h // trick to disable the standard HWserial
|
||||
|
||||
#define FORCE_INLINE __attribute__((always_inline)) inline
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <util/delay.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/eeprom.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
|
||||
#include "fastio.h"
|
||||
#include "Configuration.h"
|
||||
#include "pins.h"
|
||||
|
||||
//#define SERIAL_ECHO(x) Serial << "echo: " << x;
|
||||
//#define SERIAL_ECHOLN(x) Serial << "echo: "<<x<<endl;
|
||||
//#define SERIAL_ERROR(x) Serial << "Error: " << x;
|
||||
//#define SERIAL_ERRORLN(x) Serial << "Error: " << x<<endl;
|
||||
//#define SERIAL_PROTOCOL(x) Serial << x;
|
||||
//#define SERIAL_PROTOCOLLN(x) Serial << x<<endl;
|
||||
#if ARDUINO >= 100
|
||||
#if defined(__AVR_ATmega644P__)
|
||||
#include "WProgram.h"
|
||||
#else
|
||||
#include "Arduino.h"
|
||||
#endif
|
||||
#else
|
||||
#include "WProgram.h"
|
||||
#endif
|
||||
|
||||
#include "MarlinSerial.h"
|
||||
|
||||
#ifndef cbi
|
||||
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
|
||||
#endif
|
||||
#ifndef sbi
|
||||
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
|
||||
#endif
|
||||
|
||||
#include "WString.h"
|
||||
|
||||
#if MOTHERBOARD == 8 // Teensylu
|
||||
#define MYSERIAL Serial
|
||||
#else
|
||||
#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_PROTOCOLLN(x) {MYSERIAL.print(x);MYSERIAL.write('\n');}
|
||||
#define SERIAL_PROTOCOLLNPGM(x) {serialprintPGM(MYPGM(x));MYSERIAL.write('\n');}
|
||||
|
||||
#define SERIAL_PROTOCOL(x) Serial.print(x);
|
||||
#define SERIAL_PROTOCOLPGM(x) serialprintPGM(PSTR(x));
|
||||
#define SERIAL_PROTOCOLLN(x) {Serial.print(x);Serial.write('\n');}
|
||||
#define SERIAL_PROTOCOLLNPGM(x) {serialprintPGM(PSTR(x));Serial.write('\n');}
|
||||
|
||||
const char errormagic[] PROGMEM ="Error:";
|
||||
const char echomagic[] PROGMEM ="echo:";
|
||||
@@ -36,17 +84,21 @@ 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(PSTR(x))
|
||||
inline void serialprintPGM(const char *str)
|
||||
#define SerialprintPGM(x) serialprintPGM(MYPGM(x))
|
||||
FORCE_INLINE void serialprintPGM(const char *str)
|
||||
{
|
||||
char ch=pgm_read_byte(str);
|
||||
while(ch)
|
||||
{
|
||||
Serial.write(ch);
|
||||
MYSERIAL.write(ch);
|
||||
ch=pgm_read_byte(++str);
|
||||
}
|
||||
}
|
||||
@@ -55,7 +107,7 @@ inline void serialprintPGM(const char *str)
|
||||
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)
|
||||
@@ -74,21 +126,43 @@ 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() ;
|
||||
#endif
|
||||
|
||||
#if E_ENABLE_PIN > -1
|
||||
#define enable_e() WRITE(E_ENABLE_PIN, E_ENABLE_ON)
|
||||
#define disable_e() WRITE(E_ENABLE_PIN,!E_ENABLE_ON)
|
||||
#if defined(E0_ENABLE_PIN) && (E0_ENABLE_PIN > -1)
|
||||
#define enable_e0() WRITE(E0_ENABLE_PIN, E_ENABLE_ON)
|
||||
#define disable_e0() WRITE(E0_ENABLE_PIN,!E_ENABLE_ON)
|
||||
#else
|
||||
#define enable_e() ;
|
||||
#define disable_e() ;
|
||||
#define enable_e0() /* nothing */
|
||||
#define disable_e0() /* nothing */
|
||||
#endif
|
||||
|
||||
#if (EXTRUDERS > 1) && defined(E1_ENABLE_PIN) && (E1_ENABLE_PIN > -1)
|
||||
#define enable_e1() WRITE(E1_ENABLE_PIN, E_ENABLE_ON)
|
||||
#define disable_e1() WRITE(E1_ENABLE_PIN,!E_ENABLE_ON)
|
||||
#else
|
||||
#define enable_e1() /* nothing */
|
||||
#define disable_e1() /* nothing */
|
||||
#endif
|
||||
|
||||
#if (EXTRUDERS > 2) && defined(E2_ENABLE_PIN) && (E2_ENABLE_PIN > -1)
|
||||
#define enable_e2() WRITE(E2_ENABLE_PIN, E_ENABLE_ON)
|
||||
#define disable_e2() WRITE(E2_ENABLE_PIN,!E_ENABLE_ON)
|
||||
#else
|
||||
#define enable_e2() /* nothing */
|
||||
#define disable_e2() /* nothing */
|
||||
#endif
|
||||
|
||||
|
||||
enum AxisEnum {X_AXIS=0, Y_AXIS=1, Z_AXIS=2, E_AXIS=3};
|
||||
|
||||
|
||||
@@ -98,9 +172,17 @@ void ClearToSend();
|
||||
void get_coordinates();
|
||||
void prepare_move();
|
||||
void kill();
|
||||
void Stop();
|
||||
|
||||
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();
|
||||
@@ -110,5 +192,12 @@ void prepare_arc_move(char isclockwise);
|
||||
extern float homing_feedrate[];
|
||||
extern bool axis_relative_modes[];
|
||||
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;
|
||||
|
||||
// Handling multiple extruders pins
|
||||
extern uint8_t active_extruder;
|
||||
|
||||
#endif
|
||||
|
||||
+1007
-279
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,329 @@
|
||||
/*
|
||||
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
|
||||
Modified 28 September 2010 by Mark Sproul
|
||||
*/
|
||||
|
||||
#include "Marlin.h"
|
||||
#include "MarlinSerial.h"
|
||||
|
||||
#if MOTHERBOARD != 8 // !teensylu
|
||||
// this next line disables the entire HardwareSerial.cpp,
|
||||
// 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)
|
||||
ring_buffer rx_buffer = { { 0 }, 0, 0 };
|
||||
#endif
|
||||
|
||||
FORCE_INLINE void store_char(unsigned char c)
|
||||
{
|
||||
int i = (unsigned int)(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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//#elif defined(SIG_USART_RECV)
|
||||
#if defined(USART0_RX_vect)
|
||||
// fixed by Mark Sproul this is on the 644/644p
|
||||
//SIGNAL(SIG_USART_RECV)
|
||||
SIGNAL(USART0_RX_vect)
|
||||
{
|
||||
#if defined(UDR0)
|
||||
unsigned char c = UDR0;
|
||||
#elif defined(UDR)
|
||||
unsigned char c = UDR; // atmega8, atmega32
|
||||
#else
|
||||
#error UDR not defined
|
||||
#endif
|
||||
store_char(c);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Constructors ////////////////////////////////////////////////////////////////
|
||||
|
||||
MarlinSerial::MarlinSerial()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Public Methods //////////////////////////////////////////////////////////////
|
||||
|
||||
void MarlinSerial::begin(long baud)
|
||||
{
|
||||
uint16_t baud_setting;
|
||||
bool useU2X0 = true;
|
||||
|
||||
#if F_CPU == 16000000UL
|
||||
// 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;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (useU2X0) {
|
||||
UCSR0A = 1 << U2X0;
|
||||
baud_setting = (F_CPU / 4 / baud - 1) / 2;
|
||||
} else {
|
||||
UCSR0A = 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;
|
||||
|
||||
sbi(UCSR0B, RXEN0);
|
||||
sbi(UCSR0B, TXEN0);
|
||||
sbi(UCSR0B, RXCIE0);
|
||||
}
|
||||
|
||||
void MarlinSerial::end()
|
||||
{
|
||||
cbi(UCSR0B, RXEN0);
|
||||
cbi(UCSR0B, TXEN0);
|
||||
cbi(UCSR0B, RXCIE0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int MarlinSerial::peek(void)
|
||||
{
|
||||
if (rx_buffer.head == rx_buffer.tail) {
|
||||
return -1;
|
||||
} else {
|
||||
return rx_buffer.buffer[rx_buffer.tail];
|
||||
}
|
||||
}
|
||||
|
||||
int MarlinSerial::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 = (unsigned int)(rx_buffer.tail + 1) % RX_BUFFER_SIZE;
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
void MarlinSerial::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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// imports from print.h
|
||||
|
||||
|
||||
|
||||
|
||||
void MarlinSerial::print(char c, int base)
|
||||
{
|
||||
print((long) c, base);
|
||||
}
|
||||
|
||||
void MarlinSerial::print(unsigned char b, int base)
|
||||
{
|
||||
print((unsigned long) b, base);
|
||||
}
|
||||
|
||||
void MarlinSerial::print(int n, int base)
|
||||
{
|
||||
print((long) n, base);
|
||||
}
|
||||
|
||||
void MarlinSerial::print(unsigned int n, int base)
|
||||
{
|
||||
print((unsigned long) n, base);
|
||||
}
|
||||
|
||||
void MarlinSerial::print(long n, int base)
|
||||
{
|
||||
if (base == 0) {
|
||||
write(n);
|
||||
} else if (base == 10) {
|
||||
if (n < 0) {
|
||||
print('-');
|
||||
n = -n;
|
||||
}
|
||||
printNumber(n, 10);
|
||||
} else {
|
||||
printNumber(n, base);
|
||||
}
|
||||
}
|
||||
|
||||
void MarlinSerial::print(unsigned long n, int base)
|
||||
{
|
||||
if (base == 0) write(n);
|
||||
else printNumber(n, base);
|
||||
}
|
||||
|
||||
void MarlinSerial::print(double n, int digits)
|
||||
{
|
||||
printFloat(n, digits);
|
||||
}
|
||||
|
||||
void MarlinSerial::println(void)
|
||||
{
|
||||
print('\r');
|
||||
print('\n');
|
||||
}
|
||||
|
||||
void MarlinSerial::println(const String &s)
|
||||
{
|
||||
print(s);
|
||||
println();
|
||||
}
|
||||
|
||||
void MarlinSerial::println(const char c[])
|
||||
{
|
||||
print(c);
|
||||
println();
|
||||
}
|
||||
|
||||
void MarlinSerial::println(char c, int base)
|
||||
{
|
||||
print(c, base);
|
||||
println();
|
||||
}
|
||||
|
||||
void MarlinSerial::println(unsigned char b, int base)
|
||||
{
|
||||
print(b, base);
|
||||
println();
|
||||
}
|
||||
|
||||
void MarlinSerial::println(int n, int base)
|
||||
{
|
||||
print(n, base);
|
||||
println();
|
||||
}
|
||||
|
||||
void MarlinSerial::println(unsigned int n, int base)
|
||||
{
|
||||
print(n, base);
|
||||
println();
|
||||
}
|
||||
|
||||
void MarlinSerial::println(long n, int base)
|
||||
{
|
||||
print(n, base);
|
||||
println();
|
||||
}
|
||||
|
||||
void MarlinSerial::println(unsigned long n, int base)
|
||||
{
|
||||
print(n, base);
|
||||
println();
|
||||
}
|
||||
|
||||
void MarlinSerial::println(double n, int digits)
|
||||
{
|
||||
print(n, digits);
|
||||
println();
|
||||
}
|
||||
|
||||
// Private Methods /////////////////////////////////////////////////////////////
|
||||
|
||||
void MarlinSerial::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 MarlinSerial::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;
|
||||
}
|
||||
}
|
||||
// Preinstantiate Objects //////////////////////////////////////////////////////
|
||||
|
||||
|
||||
MarlinSerial MSerial;
|
||||
|
||||
#endif // whole file
|
||||
#endif //teensylu
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
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
|
||||
|
||||
Modified 28 September 2010 by Mark Sproul
|
||||
*/
|
||||
|
||||
#ifndef MarlinSerial_h
|
||||
#define MarlinSerial_h
|
||||
#include "Marlin.h"
|
||||
|
||||
|
||||
#define DEC 10
|
||||
#define HEX 16
|
||||
#define OCT 8
|
||||
#define BIN 2
|
||||
#define BYTE 0
|
||||
|
||||
|
||||
#if MOTHERBOARD != 8 // ! teensylu
|
||||
// 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;
|
||||
};
|
||||
|
||||
#if defined(UBRRH) || defined(UBRR0H)
|
||||
extern ring_buffer rx_buffer;
|
||||
#endif
|
||||
|
||||
class MarlinSerial //: public Stream
|
||||
{
|
||||
|
||||
public:
|
||||
MarlinSerial();
|
||||
void begin(long);
|
||||
void end();
|
||||
int peek(void);
|
||||
int read(void);
|
||||
void flush(void);
|
||||
|
||||
FORCE_INLINE int available(void)
|
||||
{
|
||||
return (unsigned int)(RX_BUFFER_SIZE + rx_buffer.head - rx_buffer.tail) % RX_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
FORCE_INLINE void write(uint8_t c)
|
||||
{
|
||||
while (!((UCSR0A) & (1 << UDRE0)))
|
||||
;
|
||||
|
||||
UDR0 = c;
|
||||
}
|
||||
|
||||
|
||||
FORCE_INLINE void checkRx(void)
|
||||
{
|
||||
if((UCSR0A & (1<<RXC0)) != 0) {
|
||||
unsigned char c = UDR0;
|
||||
int i = (unsigned int)(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
void printNumber(unsigned long, uint8_t);
|
||||
void printFloat(double, uint8_t);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
FORCE_INLINE void write(const char *str)
|
||||
{
|
||||
while (*str)
|
||||
write(*str++);
|
||||
}
|
||||
|
||||
|
||||
FORCE_INLINE void write(const uint8_t *buffer, size_t size)
|
||||
{
|
||||
while (size--)
|
||||
write(*buffer++);
|
||||
}
|
||||
|
||||
FORCE_INLINE void print(const String &s)
|
||||
{
|
||||
for (int i = 0; i < (int)s.length(); i++) {
|
||||
write(s[i]);
|
||||
}
|
||||
}
|
||||
|
||||
FORCE_INLINE void print(const char *str)
|
||||
{
|
||||
write(str);
|
||||
}
|
||||
void print(char, int = BYTE);
|
||||
void print(unsigned char, int = BYTE);
|
||||
void print(int, int = DEC);
|
||||
void print(unsigned int, int = DEC);
|
||||
void print(long, int = DEC);
|
||||
void print(unsigned long, int = DEC);
|
||||
void print(double, int = 2);
|
||||
|
||||
void println(const String &s);
|
||||
void println(const char[]);
|
||||
void println(char, int = BYTE);
|
||||
void println(unsigned char, int = BYTE);
|
||||
void println(int, int = DEC);
|
||||
void println(unsigned int, int = DEC);
|
||||
void println(long, int = DEC);
|
||||
void println(unsigned long, int = DEC);
|
||||
void println(double, int = 2);
|
||||
void println(void);
|
||||
};
|
||||
|
||||
extern MarlinSerial MSerial;
|
||||
#endif // ! teensylu
|
||||
|
||||
#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
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#ifndef Wiring_h
|
||||
#define Wiring_h
|
||||
|
||||
#include <math.h>
|
||||
#include <avr/io.h>
|
||||
#include <stdlib.h>
|
||||
#include "binary.h"
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
|
||||
#ifndef WiringPrivate_h
|
||||
#define WiringPrivate_h
|
||||
|
||||
#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>
|
||||
|
||||
|
||||
+5
-6
@@ -17,11 +17,9 @@
|
||||
* along with the Arduino Sd2Card Library. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#if ARDUINO < 100
|
||||
#include <WProgram.h>
|
||||
#else // ARDUINO
|
||||
#include <Arduino.h>
|
||||
#endif // ARDUINO
|
||||
#include "Marlin.h"
|
||||
|
||||
#ifdef SDSUPPORT
|
||||
#include "Sd2Card.h"
|
||||
//------------------------------------------------------------------------------
|
||||
#ifndef SOFTWARE_SPI
|
||||
@@ -371,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.
|
||||
*/
|
||||
@@ -640,3 +637,5 @@ bool Sd2Card::writeStop() {
|
||||
chipSelectHigh();
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
* along with the Arduino Sd2Card Library. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "Marlin.h"
|
||||
#ifdef SDSUPPORT
|
||||
|
||||
#ifndef Sd2Card_h
|
||||
#define Sd2Card_h
|
||||
/**
|
||||
@@ -232,3 +236,6 @@ class Sd2Card {
|
||||
bool writeData(uint8_t token, const uint8_t* src);
|
||||
};
|
||||
#endif // Sd2Card_h
|
||||
|
||||
|
||||
#endif
|
||||
@@ -18,6 +18,9 @@
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// Warning this file was generated by a program.
|
||||
#include "Marlin.h"
|
||||
#ifdef SDSUPPORT
|
||||
|
||||
#ifndef Sd2PinMap_h
|
||||
#define Sd2PinMap_h
|
||||
#include <avr/io.h>
|
||||
@@ -38,6 +41,8 @@ struct pin_map_t {
|
||||
uint8_t const SDA_PIN = 20; // D1
|
||||
uint8_t const SCL_PIN = 21; // D0
|
||||
|
||||
#undef MOSI_PIN
|
||||
#undef MISO_PIN
|
||||
// SPI port
|
||||
uint8_t const SS_PIN = 53; // B0
|
||||
uint8_t const MOSI_PIN = 51; // B2
|
||||
@@ -358,3 +363,6 @@ static inline __attribute__((always_inline))
|
||||
}
|
||||
}
|
||||
#endif // Sd2PinMap_h
|
||||
|
||||
|
||||
#endif
|
||||
+84
-77
@@ -17,6 +17,10 @@
|
||||
* along with the Arduino SdFat Library. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "Marlin.h"
|
||||
#ifdef SDSUPPORT
|
||||
|
||||
#include "SdBaseFile.h"
|
||||
//------------------------------------------------------------------------------
|
||||
// pointer to cwd directory
|
||||
@@ -294,20 +298,7 @@ void SdBaseFile::getpos(fpos_t* pos) {
|
||||
pos->position = curPosition_;
|
||||
pos->cluster = curCluster_;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/** List directory contents to Serial.
|
||||
*
|
||||
* \param[in] flags The inclusive OR of
|
||||
*
|
||||
* LS_DATE - %Print file modification date
|
||||
*
|
||||
* LS_SIZE - %Print file size.
|
||||
*
|
||||
* LS_R - Recursive list of subdirectories.
|
||||
*/
|
||||
void SdBaseFile::ls(uint8_t flags) {
|
||||
ls(&Serial, flags, 0);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/** List directory contents.
|
||||
*
|
||||
@@ -324,14 +315,14 @@ void SdBaseFile::ls(uint8_t flags) {
|
||||
* \param[in] indent Amount of space before file name. Used for recursive
|
||||
* list to indicate subdirectory level.
|
||||
*/
|
||||
void SdBaseFile::ls(Print* pr, uint8_t flags, uint8_t indent) {
|
||||
void SdBaseFile::ls(uint8_t flags, uint8_t indent) {
|
||||
rewind();
|
||||
int8_t status;
|
||||
while ((status = lsPrintNext(pr, flags, indent))) {
|
||||
while ((status = lsPrintNext( flags, indent))) {
|
||||
if (status > 1 && (flags & LS_R)) {
|
||||
uint16_t index = curPosition()/32 - 1;
|
||||
SdBaseFile s;
|
||||
if (s.open(this, index, O_READ)) s.ls(pr, flags, indent + 2);
|
||||
if (s.open(this, index, O_READ)) s.ls( flags, indent + 2);
|
||||
seekSet(32 * (index + 1));
|
||||
}
|
||||
}
|
||||
@@ -339,7 +330,7 @@ void SdBaseFile::ls(Print* pr, uint8_t flags, uint8_t indent) {
|
||||
//------------------------------------------------------------------------------
|
||||
// saves 32 bytes on stack for ls recursion
|
||||
// return 0 - EOF, 1 - normal file, or 2 - directory
|
||||
int8_t SdBaseFile::lsPrintNext(Print *pr, uint8_t flags, uint8_t indent) {
|
||||
int8_t SdBaseFile::lsPrintNext( uint8_t flags, uint8_t indent) {
|
||||
dir_t dir;
|
||||
uint8_t w = 0;
|
||||
|
||||
@@ -352,38 +343,38 @@ int8_t SdBaseFile::lsPrintNext(Print *pr, uint8_t flags, uint8_t indent) {
|
||||
&& DIR_IS_FILE_OR_SUBDIR(&dir)) break;
|
||||
}
|
||||
// indent for dir level
|
||||
for (uint8_t i = 0; i < indent; i++) pr->write(' ');
|
||||
for (uint8_t i = 0; i < indent; i++) MYSERIAL.write(' ');
|
||||
|
||||
// print name
|
||||
for (uint8_t i = 0; i < 11; i++) {
|
||||
if (dir.name[i] == ' ')continue;
|
||||
if (i == 8) {
|
||||
pr->write('.');
|
||||
MYSERIAL.write('.');
|
||||
w++;
|
||||
}
|
||||
pr->write(dir.name[i]);
|
||||
MYSERIAL.write(dir.name[i]);
|
||||
w++;
|
||||
}
|
||||
if (DIR_IS_SUBDIR(&dir)) {
|
||||
pr->write('/');
|
||||
MYSERIAL.write('/');
|
||||
w++;
|
||||
}
|
||||
if (flags & (LS_DATE | LS_SIZE)) {
|
||||
while (w++ < 14) pr->write(' ');
|
||||
while (w++ < 14) MYSERIAL.write(' ');
|
||||
}
|
||||
// print modify date/time if requested
|
||||
if (flags & LS_DATE) {
|
||||
pr->write(' ');
|
||||
printFatDate(pr, dir.lastWriteDate);
|
||||
pr->write(' ');
|
||||
printFatTime(pr, dir.lastWriteTime);
|
||||
MYSERIAL.write(' ');
|
||||
printFatDate( dir.lastWriteDate);
|
||||
MYSERIAL.write(' ');
|
||||
printFatTime( dir.lastWriteTime);
|
||||
}
|
||||
// print size if requested
|
||||
if (!DIR_IS_SUBDIR(&dir) && (flags & LS_SIZE)) {
|
||||
pr->write(' ');
|
||||
pr->print(dir.fileSize);
|
||||
MYSERIAL.write(' ');
|
||||
MYSERIAL.print(dir.fileSize);
|
||||
}
|
||||
pr->println();
|
||||
MYSERIAL.println();
|
||||
return DIR_IS_FILE(&dir) ? 1 : 2;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -876,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);
|
||||
@@ -940,17 +931,7 @@ int SdBaseFile::peek() {
|
||||
if (c >= 0) setpos(&pos);
|
||||
return c;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/** %Print the name field of a directory entry in 8.3 format to Serial.
|
||||
*
|
||||
* \param[in] dir The directory structure containing the name.
|
||||
* \param[in] width Blank fill name if length is less than \a width.
|
||||
* \param[in] printSlash Print '/' after directory names if true.
|
||||
*/
|
||||
void SdBaseFile::printDirName(const dir_t& dir,
|
||||
uint8_t width, bool printSlash) {
|
||||
printDirName(&Serial, dir, width, printSlash);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/** %Print the name field of a directory entry in 8.3 format.
|
||||
* \param[in] pr Print stream for output.
|
||||
@@ -958,32 +939,32 @@ void SdBaseFile::printDirName(const dir_t& dir,
|
||||
* \param[in] width Blank fill name if length is less than \a width.
|
||||
* \param[in] printSlash Print '/' after directory names if true.
|
||||
*/
|
||||
void SdBaseFile::printDirName(Print* pr, const dir_t& dir,
|
||||
void SdBaseFile::printDirName(const dir_t& dir,
|
||||
uint8_t width, bool printSlash) {
|
||||
uint8_t w = 0;
|
||||
for (uint8_t i = 0; i < 11; i++) {
|
||||
if (dir.name[i] == ' ')continue;
|
||||
if (i == 8) {
|
||||
pr->write('.');
|
||||
MYSERIAL.write('.');
|
||||
w++;
|
||||
}
|
||||
pr->write(dir.name[i]);
|
||||
MYSERIAL.write(dir.name[i]);
|
||||
w++;
|
||||
}
|
||||
if (DIR_IS_SUBDIR(&dir) && printSlash) {
|
||||
pr->write('/');
|
||||
MYSERIAL.write('/');
|
||||
w++;
|
||||
}
|
||||
while (w < width) {
|
||||
pr->write(' ');
|
||||
MYSERIAL.write(' ');
|
||||
w++;
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
// print uint8_t with width 2
|
||||
static void print2u(Print* pr, uint8_t v) {
|
||||
if (v < 10) pr->write('0');
|
||||
pr->print(v, DEC);
|
||||
static void print2u( uint8_t v) {
|
||||
if (v < 10) MYSERIAL.write('0');
|
||||
MYSERIAL.print(v, DEC);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/** %Print a directory date field to Serial.
|
||||
@@ -992,9 +973,7 @@ static void print2u(Print* pr, uint8_t v) {
|
||||
*
|
||||
* \param[in] fatDate The date field from a directory entry.
|
||||
*/
|
||||
void SdBaseFile::printFatDate(uint16_t fatDate) {
|
||||
printFatDate(&Serial, fatDate);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/** %Print a directory date field.
|
||||
*
|
||||
@@ -1003,23 +982,14 @@ void SdBaseFile::printFatDate(uint16_t fatDate) {
|
||||
* \param[in] pr Print stream for output.
|
||||
* \param[in] fatDate The date field from a directory entry.
|
||||
*/
|
||||
void SdBaseFile::printFatDate(Print* pr, uint16_t fatDate) {
|
||||
pr->print(FAT_YEAR(fatDate));
|
||||
pr->write('-');
|
||||
print2u(pr, FAT_MONTH(fatDate));
|
||||
pr->write('-');
|
||||
print2u(pr, FAT_DAY(fatDate));
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/** %Print a directory time field to Serial.
|
||||
*
|
||||
* Format is hh:mm:ss.
|
||||
*
|
||||
* \param[in] fatTime The time field from a directory entry.
|
||||
*/
|
||||
void SdBaseFile::printFatTime(uint16_t fatTime) {
|
||||
printFatTime(&Serial, fatTime);
|
||||
void SdBaseFile::printFatDate(uint16_t fatDate) {
|
||||
MYSERIAL.print(FAT_YEAR(fatDate));
|
||||
MYSERIAL.write('-');
|
||||
print2u( FAT_MONTH(fatDate));
|
||||
MYSERIAL.write('-');
|
||||
print2u( FAT_DAY(fatDate));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/** %Print a directory time field.
|
||||
*
|
||||
@@ -1028,12 +998,12 @@ void SdBaseFile::printFatTime(uint16_t fatTime) {
|
||||
* \param[in] pr Print stream for output.
|
||||
* \param[in] fatTime The time field from a directory entry.
|
||||
*/
|
||||
void SdBaseFile::printFatTime(Print* pr, uint16_t fatTime) {
|
||||
print2u(pr, FAT_HOUR(fatTime));
|
||||
pr->write(':');
|
||||
print2u(pr, FAT_MINUTE(fatTime));
|
||||
pr->write(':');
|
||||
print2u(pr, FAT_SECOND(fatTime));
|
||||
void SdBaseFile::printFatTime( uint16_t fatTime) {
|
||||
print2u( FAT_HOUR(fatTime));
|
||||
MYSERIAL.write(':');
|
||||
print2u( FAT_MINUTE(fatTime));
|
||||
MYSERIAL.write(':');
|
||||
print2u( FAT_SECOND(fatTime));
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/** Print a file's name to Serial
|
||||
@@ -1044,7 +1014,7 @@ void SdBaseFile::printFatTime(Print* pr, uint16_t fatTime) {
|
||||
bool SdBaseFile::printName() {
|
||||
char name[13];
|
||||
if (!getFilename(name)) return false;
|
||||
Serial.print(name);
|
||||
MYSERIAL.print(name);
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -1138,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));
|
||||
@@ -1150,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;
|
||||
}
|
||||
@@ -1816,3 +1820,6 @@ int16_t SdBaseFile::write(const void* buf, uint16_t nbyte) {
|
||||
#if ALLOW_DEPRECATED_FUNCTIONS && !defined(DOXYGEN)
|
||||
void (*SdBaseFile::oldDateTime_)(uint16_t& date, uint16_t& time) = 0; // NOLINT
|
||||
#endif // ALLOW_DEPRECATED_FUNCTIONS
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+11
-17
@@ -17,18 +17,16 @@
|
||||
* along with the Arduino SdFat Library. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "Marlin.h"
|
||||
#ifdef SDSUPPORT
|
||||
|
||||
#ifndef SdBaseFile_h
|
||||
#define SdBaseFile_h
|
||||
/**
|
||||
* \file
|
||||
* \brief SdBaseFile class
|
||||
*/
|
||||
#include <avr/pgmspace.h>
|
||||
#if ARDUINO < 100
|
||||
#include <WProgram.h>
|
||||
#else // ARDUINO
|
||||
#include <Arduino.h>
|
||||
#endif // ARDUINO
|
||||
#include "Marlin.h"
|
||||
#include "SdFatConfig.h"
|
||||
#include "SdVolume.h"
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -268,8 +266,7 @@ class SdBaseFile {
|
||||
bool isRoot() const {
|
||||
return type_ == FAT_FILE_TYPE_ROOT_FIXED || type_ == FAT_FILE_TYPE_ROOT32;
|
||||
}
|
||||
void ls(Print* pr, uint8_t flags = 0, uint8_t indent = 0);
|
||||
void ls(uint8_t flags = 0);
|
||||
void ls( uint8_t flags = 0, uint8_t indent = 0);
|
||||
bool mkdir(SdBaseFile* dir, const char* path, bool pFlag = true);
|
||||
// alias for backward compactability
|
||||
bool makeDir(SdBaseFile* dir, const char* path) {
|
||||
@@ -282,13 +279,11 @@ class SdBaseFile {
|
||||
bool openRoot(SdVolume* vol);
|
||||
int peek();
|
||||
static void printFatDate(uint16_t fatDate);
|
||||
static void printFatDate(Print* pr, uint16_t fatDate);
|
||||
static void printFatTime(uint16_t fatTime);
|
||||
static void printFatTime(Print* pr, uint16_t fatTime);
|
||||
static void printFatTime( uint16_t fatTime);
|
||||
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. */
|
||||
@@ -357,7 +352,7 @@ class SdBaseFile {
|
||||
bool addCluster();
|
||||
bool addDirCluster();
|
||||
dir_t* cacheDirEntry(uint8_t action);
|
||||
int8_t lsPrintNext(Print *pr, uint8_t flags, uint8_t indent);
|
||||
int8_t lsPrintNext( uint8_t flags, uint8_t indent);
|
||||
static bool make83Name(const char* str, uint8_t* name, const char** ptr);
|
||||
bool mkdir(SdBaseFile* parent, const uint8_t dname[11]);
|
||||
bool open(SdBaseFile* dirFile, const uint8_t dname[11], uint8_t oflag);
|
||||
@@ -365,9 +360,7 @@ class SdBaseFile {
|
||||
dir_t* readDirCache();
|
||||
//------------------------------------------------------------------------------
|
||||
// to be deleted
|
||||
static void printDirName(const dir_t& dir,
|
||||
uint8_t width, bool printSlash);
|
||||
static void printDirName(Print* pr, const dir_t& dir,
|
||||
static void printDirName( const dir_t& dir,
|
||||
uint8_t width, bool printSlash);
|
||||
//------------------------------------------------------------------------------
|
||||
// Deprecated functions - suppress cpplint warnings with NOLINT comment
|
||||
@@ -462,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.
|
||||
@@ -487,3 +480,4 @@ class SdBaseFile {
|
||||
};
|
||||
|
||||
#endif // SdBaseFile_h
|
||||
#endif
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
* \file
|
||||
* \brief configuration definitions
|
||||
*/
|
||||
#include "Marlin.h"
|
||||
#ifdef SDSUPPORT
|
||||
|
||||
#ifndef SdFatConfig_h
|
||||
#define SdFatConfig_h
|
||||
#include <stdint.h>
|
||||
@@ -105,4 +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
|
||||
|
||||
+48
-6
@@ -17,8 +17,13 @@
|
||||
* along with the Arduino SdFat Library. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "Marlin.h"
|
||||
#ifdef SDSUPPORT
|
||||
|
||||
#ifndef SdFatStructs_h
|
||||
#define SdFatStructs_h
|
||||
|
||||
#define PACKED __attribute__((__packed__))
|
||||
/**
|
||||
* \file
|
||||
* \brief FAT file structures
|
||||
@@ -92,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;
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -116,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;
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -244,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;
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -398,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;
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -438,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;
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -536,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" */
|
||||
@@ -602,3 +641,6 @@ static inline uint8_t DIR_IS_FILE_OR_SUBDIR(const dir_t* dir) {
|
||||
return (dir->attributes & DIR_ATT_VOLUME_ID) == 0;
|
||||
}
|
||||
#endif // SdFatStructs_h
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+12
-7
@@ -17,7 +17,11 @@
|
||||
* along with the Arduino SdFat Library. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "Marlin.h"
|
||||
|
||||
#ifdef SDSUPPORT
|
||||
#include "SdFatUtil.h"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/** Amount of free RAM
|
||||
* \return The number of free bytes.
|
||||
@@ -43,8 +47,8 @@ int SdFatUtil::FreeRam() {
|
||||
* \param[in] pr Print object for output.
|
||||
* \param[in] str Pointer to string stored in flash memory.
|
||||
*/
|
||||
void SdFatUtil::print_P(Print* pr, PGM_P str) {
|
||||
for (uint8_t c; (c = pgm_read_byte(str)); str++) pr->write(c);
|
||||
void SdFatUtil::print_P( PGM_P str) {
|
||||
for (uint8_t c; (c = pgm_read_byte(str)); str++) MYSERIAL.write(c);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/** %Print a string in flash memory followed by a CR/LF.
|
||||
@@ -52,9 +56,9 @@ void SdFatUtil::print_P(Print* pr, PGM_P str) {
|
||||
* \param[in] pr Print object for output.
|
||||
* \param[in] str Pointer to string stored in flash memory.
|
||||
*/
|
||||
void SdFatUtil::println_P(Print* pr, PGM_P str) {
|
||||
print_P(pr, str);
|
||||
pr->println();
|
||||
void SdFatUtil::println_P( PGM_P str) {
|
||||
print_P( str);
|
||||
MYSERIAL.println();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/** %Print a string in flash memory to Serial.
|
||||
@@ -62,7 +66,7 @@ void SdFatUtil::println_P(Print* pr, PGM_P str) {
|
||||
* \param[in] str Pointer to string stored in flash memory.
|
||||
*/
|
||||
void SdFatUtil::SerialPrint_P(PGM_P str) {
|
||||
print_P(&Serial, str);
|
||||
print_P(str);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/** %Print a string in flash memory to Serial followed by a CR/LF.
|
||||
@@ -70,5 +74,6 @@ void SdFatUtil::SerialPrint_P(PGM_P str) {
|
||||
* \param[in] str Pointer to string stored in flash memory.
|
||||
*/
|
||||
void SdFatUtil::SerialPrintln_P(PGM_P str) {
|
||||
println_P(&Serial, str);
|
||||
println_P( str);
|
||||
}
|
||||
#endif
|
||||
|
||||
+10
-8
@@ -17,18 +17,17 @@
|
||||
* along with the Arduino SdFat Library. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "Marlin.h"
|
||||
#ifdef SDSUPPORT
|
||||
|
||||
#ifndef SdFatUtil_h
|
||||
#define SdFatUtil_h
|
||||
/**
|
||||
* \file
|
||||
* \brief Useful utility functions.
|
||||
*/
|
||||
#include <avr/pgmspace.h>
|
||||
#if ARDUINO < 100
|
||||
#include <WProgram.h>
|
||||
#else // ARDUINO
|
||||
#include <Arduino.h>
|
||||
#endif // ARDUINO
|
||||
#include "Marlin.h"
|
||||
#include "MarlinSerial.h"
|
||||
/** Store and print a string in flash memory.*/
|
||||
#define PgmPrint(x) SerialPrint_P(PSTR(x))
|
||||
/** Store and print a string in flash memory followed by a CR/LF.*/
|
||||
@@ -36,11 +35,14 @@
|
||||
|
||||
namespace SdFatUtil {
|
||||
int FreeRam();
|
||||
void print_P(Print* pr, PGM_P str);
|
||||
void println_P(Print* pr, PGM_P str);
|
||||
void print_P( PGM_P str);
|
||||
void println_P( PGM_P str);
|
||||
void SerialPrint_P(PGM_P str);
|
||||
void SerialPrintln_P(PGM_P str);
|
||||
}
|
||||
|
||||
using namespace SdFatUtil; // NOLINT
|
||||
#endif // #define SdFatUtil_h
|
||||
|
||||
|
||||
#endif
|
||||
+12
-1
@@ -17,6 +17,9 @@
|
||||
* along with the Arduino SdFat Library. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "Marlin.h"
|
||||
|
||||
#ifdef SDSUPPORT
|
||||
#include "SdFile.h"
|
||||
/** Create a file object and open it in the current working directory.
|
||||
*
|
||||
@@ -51,7 +54,12 @@ int16_t SdFile::write(const void* buf, uint16_t nbyte) {
|
||||
* \param[in] b the byte to be written.
|
||||
* Use writeError to check for errors.
|
||||
*/
|
||||
void SdFile::write(uint8_t b) {
|
||||
#if ARDUINO >= 100
|
||||
size_t SdFile::write(uint8_t b)
|
||||
#else
|
||||
void SdFile::write(uint8_t b)
|
||||
#endif
|
||||
{
|
||||
SdBaseFile::write(&b, 1);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -79,3 +87,6 @@ void SdFile::writeln_P(PGM_P str) {
|
||||
write_P(str);
|
||||
write_P(PSTR("\r\n"));
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
+13
-1
@@ -21,7 +21,11 @@
|
||||
* \file
|
||||
* \brief SdFile class
|
||||
*/
|
||||
#include "Marlin.h"
|
||||
|
||||
#ifdef SDSUPPORT
|
||||
#include "SdBaseFile.h"
|
||||
#include <Print.h>
|
||||
#ifndef SdFile_h
|
||||
#define SdFile_h
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -33,10 +37,18 @@ class SdFile : public SdBaseFile, public Print {
|
||||
public:
|
||||
SdFile() {}
|
||||
SdFile(const char* name, uint8_t oflag);
|
||||
void write(uint8_t b);
|
||||
#if ARDUINO >= 100
|
||||
size_t write(uint8_t b);
|
||||
#else
|
||||
void write(uint8_t b);
|
||||
#endif
|
||||
|
||||
int16_t write(const void* buf, uint16_t nbyte);
|
||||
void write(const char* str);
|
||||
void write_P(PGM_P str);
|
||||
void writeln_P(PGM_P str);
|
||||
};
|
||||
#endif // SdFile_h
|
||||
|
||||
|
||||
#endif
|
||||
@@ -17,6 +17,9 @@
|
||||
* along with the Arduino Sd2Card Library. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "Marlin.h"
|
||||
#ifdef SDSUPPORT
|
||||
|
||||
#ifndef SdInfo_h
|
||||
#define SdInfo_h
|
||||
#include <stdint.h>
|
||||
@@ -273,3 +276,5 @@ union csd_t {
|
||||
csd2_t v2;
|
||||
};
|
||||
#endif // SdInfo_h
|
||||
|
||||
#endif
|
||||
@@ -17,6 +17,9 @@
|
||||
* along with the Arduino SdFat Library. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "Marlin.h"
|
||||
#ifdef SDSUPPORT
|
||||
|
||||
#include "SdVolume.h"
|
||||
//------------------------------------------------------------------------------
|
||||
#if !USE_MULTIPLE_CARDS
|
||||
@@ -399,3 +402,4 @@ bool SdVolume::init(Sd2Card* dev, uint8_t part) {
|
||||
fail:
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@@ -17,6 +17,8 @@
|
||||
* along with the Arduino SdFat Library. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "Marlin.h"
|
||||
#ifdef SDSUPPORT
|
||||
#ifndef SdVolume_h
|
||||
#define SdVolume_h
|
||||
/**
|
||||
@@ -209,3 +211,4 @@ class SdVolume {
|
||||
#endif // ALLOW_DEPRECATED_FUNCTIONS
|
||||
};
|
||||
#endif // SdVolume
|
||||
#endif
|
||||
@@ -1,7 +1,14 @@
|
||||
#include "Marlin.h"
|
||||
#include "cardreader.h"
|
||||
//#include <unistd.h>
|
||||
#include "ultralcd.h"
|
||||
#include "stepper.h"
|
||||
#include "temperature.h"
|
||||
#include "language.h"
|
||||
|
||||
#ifdef SDSUPPORT
|
||||
|
||||
|
||||
|
||||
CardReader::CardReader()
|
||||
{
|
||||
filesize = 0;
|
||||
@@ -12,6 +19,7 @@ CardReader::CardReader()
|
||||
autostart_atmillis=0;
|
||||
|
||||
autostart_stilltocheck=true; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware.
|
||||
lastnr=0;
|
||||
//power to SD reader
|
||||
#if SDPOWER > -1
|
||||
SET_OUTPUT(SDPOWER);
|
||||
@@ -38,14 +46,14 @@ char *createFilename(char *buffer,const dir_t &p) //buffer>12characters
|
||||
}
|
||||
|
||||
|
||||
void CardReader::lsDive(char *prepend,SdFile parent)
|
||||
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)
|
||||
if( DIR_IS_SUBDIR(&p) && lsAction!=LS_Count && lsAction!=LS_GetFilename) // hence LS_SerialPrint
|
||||
{
|
||||
|
||||
char path[13*2];
|
||||
@@ -69,7 +77,7 @@ void CardReader::lsDive(char *prepend,SdFile parent)
|
||||
if(lsAction==LS_SerialPrint)
|
||||
{
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLN("Cannot open subdir");
|
||||
SERIAL_ECHOLN(MSG_SD_CANT_OPEN_SUBDIR);
|
||||
SERIAL_ECHOLN(lfilename);
|
||||
}
|
||||
}
|
||||
@@ -87,9 +95,11 @@ void CardReader::lsDive(char *prepend,SdFile parent)
|
||||
if ( p.name[1] != '.')
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue;
|
||||
filenameIsDir=DIR_IS_SUBDIR(&p);
|
||||
|
||||
|
||||
if(!filenameIsDir)
|
||||
{
|
||||
if(p.name[8]!='G') continue;
|
||||
@@ -137,29 +147,44 @@ void CardReader::initsd()
|
||||
{
|
||||
//if (!card.init(SPI_HALF_SPEED,SDSS))
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM("SD init fail");
|
||||
SERIAL_ECHOLNPGM(MSG_SD_INIT_FAIL);
|
||||
}
|
||||
else if (!volume.init(&card))
|
||||
{
|
||||
SERIAL_ERROR_START;
|
||||
SERIAL_ERRORLNPGM("volume.init failed");
|
||||
SERIAL_ERRORLNPGM(MSG_SD_VOL_INIT_FAIL);
|
||||
}
|
||||
else if (!root.openRoot(&volume))
|
||||
{
|
||||
SERIAL_ERROR_START;
|
||||
SERIAL_ERRORLNPGM("openRoot failed");
|
||||
SERIAL_ERRORLNPGM(MSG_SD_OPENROOT_FAIL);
|
||||
}
|
||||
else
|
||||
{
|
||||
cardOK = true;
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM("SD card ok");
|
||||
SERIAL_ECHOLNPGM(MSG_SD_CARD_OK);
|
||||
}
|
||||
workDir=root;
|
||||
curDir=&root;
|
||||
/*
|
||||
if(!workDir.openRoot(&volume))
|
||||
{
|
||||
SERIAL_ECHOLNPGM("workDir open failed");
|
||||
SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL);
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void CardReader::setroot()
|
||||
{
|
||||
/*if(!workDir.openRoot(&volume))
|
||||
{
|
||||
SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL);
|
||||
}*/
|
||||
workDir=root;
|
||||
|
||||
curDir=&workDir;
|
||||
}
|
||||
void CardReader::release()
|
||||
{
|
||||
@@ -215,7 +240,7 @@ void CardReader::openFile(char* name,bool read)
|
||||
SERIAL_ECHOLN(subdirname);
|
||||
if(!myDir.open(curDir,subdirname,O_READ))
|
||||
{
|
||||
SERIAL_PROTOCOLPGM("open failed, File: ");
|
||||
SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL);
|
||||
SERIAL_PROTOCOL(subdirname);
|
||||
SERIAL_PROTOCOLLNPGM(".");
|
||||
return;
|
||||
@@ -245,18 +270,18 @@ void CardReader::openFile(char* name,bool read)
|
||||
if (file.open(curDir, fname, O_READ))
|
||||
{
|
||||
filesize = file.fileSize();
|
||||
SERIAL_PROTOCOLPGM("File opened:");
|
||||
SERIAL_PROTOCOLPGM(MSG_SD_FILE_OPENED);
|
||||
SERIAL_PROTOCOL(fname);
|
||||
SERIAL_PROTOCOLPGM(" Size:");
|
||||
SERIAL_PROTOCOLPGM(MSG_SD_SIZE);
|
||||
SERIAL_PROTOCOLLN(filesize);
|
||||
sdpos = 0;
|
||||
|
||||
SERIAL_PROTOCOLLNPGM("File selected");
|
||||
SERIAL_PROTOCOLLNPGM(MSG_SD_FILE_SELECTED);
|
||||
LCD_MESSAGE(fname);
|
||||
}
|
||||
else
|
||||
{
|
||||
SERIAL_PROTOCOLPGM("open failed, File: ");
|
||||
SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL);
|
||||
SERIAL_PROTOCOL(fname);
|
||||
SERIAL_PROTOCOLLNPGM(".");
|
||||
}
|
||||
@@ -265,14 +290,14 @@ void CardReader::openFile(char* name,bool read)
|
||||
{ //write
|
||||
if (!file.open(curDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC))
|
||||
{
|
||||
SERIAL_PROTOCOLPGM("open failed, File: ");
|
||||
SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL);
|
||||
SERIAL_PROTOCOL(fname);
|
||||
SERIAL_PROTOCOLLNPGM(".");
|
||||
}
|
||||
else
|
||||
{
|
||||
saving = true;
|
||||
SERIAL_PROTOCOLPGM("Writing to file: ");
|
||||
SERIAL_PROTOCOLPGM(MSG_SD_WRITE_TO_FILE);
|
||||
SERIAL_PROTOCOLLN(name);
|
||||
LCD_MESSAGE(fname);
|
||||
}
|
||||
@@ -280,16 +305,85 @@ void CardReader::openFile(char* name,bool read)
|
||||
|
||||
}
|
||||
|
||||
void CardReader::removeFile(char* name)
|
||||
{
|
||||
if(!cardOK)
|
||||
return;
|
||||
file.close();
|
||||
sdprinting = false;
|
||||
|
||||
|
||||
SdFile myDir;
|
||||
curDir=&root;
|
||||
char *fname=name;
|
||||
|
||||
char *dirname_start,*dirname_end;
|
||||
if(name[0]=='/')
|
||||
{
|
||||
dirname_start=strchr(name,'/')+1;
|
||||
while(dirname_start>0)
|
||||
{
|
||||
dirname_end=strchr(dirname_start,'/');
|
||||
//SERIAL_ECHO("start:");SERIAL_ECHOLN((int)(dirname_start-name));
|
||||
//SERIAL_ECHO("end :");SERIAL_ECHOLN((int)(dirname_end-name));
|
||||
if(dirname_end>0 && dirname_end>dirname_start)
|
||||
{
|
||||
char subdirname[13];
|
||||
strncpy(subdirname, dirname_start, dirname_end-dirname_start);
|
||||
subdirname[dirname_end-dirname_start]=0;
|
||||
SERIAL_ECHOLN(subdirname);
|
||||
if(!myDir.open(curDir,subdirname,O_READ))
|
||||
{
|
||||
SERIAL_PROTOCOLPGM("open failed, File: ");
|
||||
SERIAL_PROTOCOL(subdirname);
|
||||
SERIAL_PROTOCOLLNPGM(".");
|
||||
return;
|
||||
}
|
||||
else
|
||||
;//SERIAL_ECHOLN("dive ok");
|
||||
|
||||
curDir=&myDir;
|
||||
dirname_start=dirname_end+1;
|
||||
}
|
||||
else // the reminder after all /fsa/fdsa/ is the filename
|
||||
{
|
||||
fname=dirname_start;
|
||||
//SERIAL_ECHOLN("remaider");
|
||||
//SERIAL_ECHOLN(fname);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else //relative path
|
||||
{
|
||||
curDir=&workDir;
|
||||
}
|
||||
if (file.remove(curDir, fname))
|
||||
{
|
||||
SERIAL_PROTOCOLPGM("File deleted:");
|
||||
SERIAL_PROTOCOL(fname);
|
||||
sdpos = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
SERIAL_PROTOCOLPGM("Deletion failed, File: ");
|
||||
SERIAL_PROTOCOL(fname);
|
||||
SERIAL_PROTOCOLLNPGM(".");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CardReader::getStatus()
|
||||
{
|
||||
if(cardOK){
|
||||
SERIAL_PROTOCOLPGM("SD printing byte ");
|
||||
SERIAL_PROTOCOLPGM(MSG_SD_PRINTING_BYTE);
|
||||
SERIAL_PROTOCOL(sdpos);
|
||||
SERIAL_PROTOCOLPGM("/");
|
||||
SERIAL_PROTOCOLLN(filesize);
|
||||
}
|
||||
else{
|
||||
SERIAL_PROTOCOLLNPGM("Not SD printing");
|
||||
SERIAL_PROTOCOLLNPGM(MSG_SD_NOT_PRINTING);
|
||||
}
|
||||
}
|
||||
void CardReader::write_command(char *buf)
|
||||
@@ -311,7 +405,7 @@ void CardReader::write_command(char *buf)
|
||||
if (file.writeError)
|
||||
{
|
||||
SERIAL_ERROR_START;
|
||||
SERIAL_ERRORLNPGM("error writing to file");
|
||||
SERIAL_ERRORLNPGM(MSG_SD_ERR_WRITE_TO_FILE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,19 +426,19 @@ void CardReader::checkautostart(bool force)
|
||||
if(!cardOK) //fail
|
||||
return;
|
||||
}
|
||||
static int lastnr=0;
|
||||
|
||||
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(" ");
|
||||
@@ -405,7 +499,7 @@ void CardReader::chdir(const char * relpath)
|
||||
if(!newfile.open(*parent,relpath, O_READ))
|
||||
{
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPGM("Cannot enter subdir:");
|
||||
SERIAL_ECHOPGM(MSG_SD_CANT_ENTER_SUBDIR);
|
||||
SERIAL_ECHOLN(relpath);
|
||||
}
|
||||
else
|
||||
@@ -426,4 +520,17 @@ void CardReader::updir()
|
||||
}
|
||||
}
|
||||
|
||||
#endif //SDSUPPORT
|
||||
|
||||
void CardReader::printingHasFinished()
|
||||
{
|
||||
st_synchronize();
|
||||
quickStop();
|
||||
sdprinting = false;
|
||||
if(SD_FINISHED_STEPPERRELEASE)
|
||||
{
|
||||
//finishAndDisableSteppers();
|
||||
enquecommand(SD_FINISHED_RELEASECOMMAND);
|
||||
}
|
||||
autotempShutdown();
|
||||
}
|
||||
#endif //SDSUPPORT
|
||||
+19
-40
@@ -1,8 +1,8 @@
|
||||
#ifndef __CARDREADERH
|
||||
#define __CARDREADERH
|
||||
#ifndef CARDREADER_H
|
||||
#define CARDREADER_H
|
||||
|
||||
#ifdef SDSUPPORT
|
||||
|
||||
|
||||
#include "SdFile.h"
|
||||
enum LsAction {LS_SerialPrint,LS_Count,LS_GetFilename};
|
||||
class CardReader
|
||||
@@ -17,11 +17,13 @@ public:
|
||||
|
||||
void checkautostart(bool x);
|
||||
void openFile(char* name,bool read);
|
||||
void removeFile(char* name);
|
||||
void closefile();
|
||||
void release();
|
||||
void startFileprint();
|
||||
void pauseSDPrint();
|
||||
void getStatus();
|
||||
void printingHasFinished();
|
||||
|
||||
void getfilename(const uint8_t nr);
|
||||
uint16_t getnrfilenames();
|
||||
@@ -30,18 +32,23 @@ public:
|
||||
void ls();
|
||||
void chdir(const char * relpath);
|
||||
void updir();
|
||||
void setroot();
|
||||
|
||||
inline bool eof() { return sdpos>=filesize ;};
|
||||
inline int16_t get() { sdpos = file.curPosition();return (int16_t)file.read();};
|
||||
inline void setIndex(long index) {sdpos = index;file.seekSet(index);};
|
||||
inline uint8_t percentDone(){if(!sdprinting) return 0; if(filesize) return sdpos*100/filesize; else return 0;};
|
||||
|
||||
FORCE_INLINE bool eof() { return sdpos>=filesize ;};
|
||||
FORCE_INLINE int16_t get() { sdpos = file.curPosition();return (int16_t)file.read();};
|
||||
FORCE_INLINE void setIndex(long index) {sdpos = index;file.seekSet(index);};
|
||||
FORCE_INLINE uint8_t percentDone(){if(!sdprinting) return 0; if(filesize) return sdpos*100/filesize; else return 0;};
|
||||
FORCE_INLINE char* getWorkDirName(){workDir.getFilename(filename);return filename;};
|
||||
|
||||
public:
|
||||
bool saving;
|
||||
bool sdprinting ;
|
||||
bool cardOK ;
|
||||
char filename[11];
|
||||
char filename[13];
|
||||
char longFilename[LONG_FILENAME_LENGTH];
|
||||
bool filenameIsDir;
|
||||
int lastnr; //last number of the autostart;
|
||||
private:
|
||||
SdFile root,*curDir,workDir,workDirParent,workDirParentParent;
|
||||
Sd2Card card;
|
||||
@@ -57,41 +64,13 @@ private:
|
||||
LsAction lsAction; //stored for recursion.
|
||||
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(char *prepend,SdFile parent);
|
||||
void lsDive(const char *prepend,SdFile parent);
|
||||
};
|
||||
|
||||
#define IS_SD_PRINTING (card.sdprinting)
|
||||
|
||||
#else
|
||||
|
||||
#define dir_t bool
|
||||
class CardReader
|
||||
{
|
||||
public:
|
||||
inline CardReader(){};
|
||||
|
||||
inline static void initsd(){};
|
||||
inline static void write_command(char *buf){};
|
||||
|
||||
inline static void checkautostart(bool x) {};
|
||||
|
||||
inline static void openFile(char* name,bool read){};
|
||||
inline static void closefile() {};
|
||||
inline static void release(){};
|
||||
inline static void startFileprint(){};
|
||||
inline static void startFilewrite(char *name){};
|
||||
inline static void pauseSDPrint(){};
|
||||
inline static void getStatus(){};
|
||||
|
||||
inline static void selectFile(char* name){};
|
||||
inline static void getfilename(const uint8_t nr){};
|
||||
inline static uint8_t getnrfilenames(){return 0;};
|
||||
|
||||
#define IS_SD_PRINTING (false)
|
||||
|
||||
inline static void ls() {};
|
||||
inline static bool eof() {return true;};
|
||||
inline static char get() {return 0;};
|
||||
inline static void setIndex(){};
|
||||
inline uint8_t percentDone(){return 0;};
|
||||
};
|
||||
#endif //SDSUPPORT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Executable
+50
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
""" Generate the stepper delay lookup table for Marlin firmware. """
|
||||
|
||||
import argparse
|
||||
|
||||
__author__ = "Ben Gamari <bgamari@gmail.com>"
|
||||
__copyright__ = "Copyright 2012, Ben Gamari"
|
||||
__license__ = "GPL"
|
||||
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('-f', '--cpu-freq', type=int, default=16, help='CPU clockrate in MHz (default=16)')
|
||||
parser.add_argument('-d', '--divider', type=int, default=8, help='Timer/counter pre-scale divider (default=8)')
|
||||
args = parser.parse_args()
|
||||
|
||||
cpu_freq = args.cpu_freq * 1000000
|
||||
timer_freq = cpu_freq / args.divider
|
||||
|
||||
print "#ifndef SPEED_LOOKUPTABLE_H"
|
||||
print "#define SPEED_LOOKUPTABLE_H"
|
||||
print
|
||||
print '#include "Marlin.h"'
|
||||
print
|
||||
|
||||
print "const uint16_t speed_lookuptable_fast[256][2] PROGMEM = {"
|
||||
a = [ timer_freq / ((i*256)+(args.cpu_freq*2)) for i in range(256) ]
|
||||
b = [ a[i] - a[i+1] for i in range(255) ]
|
||||
b.append(b[-1])
|
||||
for i in range(32):
|
||||
print " ",
|
||||
for j in range(8):
|
||||
print "{%d, %d}," % (a[8*i+j], b[8*i+j]),
|
||||
print
|
||||
print "};"
|
||||
print
|
||||
|
||||
print "const uint16_t speed_lookuptable_slow[256][2] PROGMEM = {"
|
||||
a = [ timer_freq / ((i*8)+(args.cpu_freq*2)) for i in range(256) ]
|
||||
b = [ a[i] - a[i+1] for i in range(255) ]
|
||||
b.append(b[-1])
|
||||
for i in range(32):
|
||||
print " ",
|
||||
for j in range(8):
|
||||
print "{%d, %d}," % (a[8*i+j], b[8*i+j]),
|
||||
print
|
||||
print "};"
|
||||
print
|
||||
|
||||
print "#endif"
|
||||
|
||||
+2581
-2558
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,498 @@
|
||||
#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 English
|
||||
// 2 -
|
||||
// 3 French (Waiting translation)
|
||||
// 4 German
|
||||
// 5 Spanish
|
||||
// 6 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 MACHINE_NAME " Ready."
|
||||
#define MSG_SD_INSERTED "Card inserted"
|
||||
#define MSG_SD_REMOVED "Card removed"
|
||||
#define MSG_MAIN " Main \003"
|
||||
#define MSG_AUTOSTART " Autostart"
|
||||
#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:"
|
||||
#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-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_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_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_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_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
|
||||
|
||||
#define MSG_Enqueing "enqueing \""
|
||||
#define MSG_POWERUP "PowerUp"
|
||||
#define MSG_EXTERNAL_RESET " External Reset"
|
||||
#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 " | Author: "
|
||||
#define MSG_CONFIGURATION_VER " Last Updated: "
|
||||
#define MSG_FREE_MEMORY " Free Memory: "
|
||||
#define MSG_PLANNER_BUFFER_BYTES " PlannerBufferBytes: "
|
||||
#define MSG_OK "ok"
|
||||
#define MSG_FILE_SAVED "Done saving file."
|
||||
#define MSG_ERR_LINE_NO "Line Number is not Last Line Number+1, Last Line:"
|
||||
#define MSG_ERR_CHECKSUM_MISMATCH "checksum mismatch, Last Line:"
|
||||
#define MSG_ERR_NO_CHECKSUM "No Checksum with line number, Last Line:"
|
||||
#define MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM "No Line Number with checksum, Last Line:"
|
||||
#define MSG_FILE_PRINTED "Done printing file"
|
||||
#define MSG_BEGIN_FILE_LIST "Begin file list"
|
||||
#define MSG_END_FILE_LIST "End file list"
|
||||
#define MSG_M104_INVALID_EXTRUDER "M104 Invalid extruder "
|
||||
#define MSG_M105_INVALID_EXTRUDER "M105 Invalid extruder "
|
||||
#define MSG_ERR_NO_THERMISTORS "No thermistors - no temp"
|
||||
#define MSG_M109_INVALID_EXTRUDER "M109 Invalid extruder "
|
||||
#define MSG_HEATING "Heating..."
|
||||
#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:" 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 deu 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_SD_CANT_OPEN_SUBDIR "Cannot open subdir"
|
||||
#define MSG_SD_INIT_FAIL "SD init fail"
|
||||
#define MSG_SD_VOL_INIT_FAIL "volume.init failed"
|
||||
#define MSG_SD_OPENROOT_FAIL "openRoot failed"
|
||||
#define MSG_SD_CARD_OK "SD card ok"
|
||||
#define MSG_SD_WORKDIR_FAIL "workDir open failed"
|
||||
#define MSG_SD_OPEN_FILE_FAIL "open failed, File: "
|
||||
#define MSG_SD_FILE_OPENED "File opened:"
|
||||
#define MSG_SD_SIZE " Size:"
|
||||
#define MSG_SD_FILE_SELECTED "File selected"
|
||||
#define MSG_SD_WRITE_TO_FILE "Writing to file: "
|
||||
#define MSG_SD_PRINTING_BYTE "SD printing byte "
|
||||
#define MSG_SD_NOT_PRINTING "Not SD printing"
|
||||
#define MSG_SD_ERR_WRITE_TO_FILE "error writing to file"
|
||||
#define MSG_SD_CANT_ENTER_SUBDIR "Cannot enter subdir:"
|
||||
|
||||
#define MSG_STEPPER_TO_HIGH "Steprate to high : "
|
||||
#define MSG_ENDSTOPS_HIT "endstops hit: "
|
||||
#define MSG_ERR_COLD_EXTRUDE_STOP " cold extrusion prevented"
|
||||
#define MSG_ERR_LONG_EXTRUDE_STOP " too long extrusion prevented"
|
||||
|
||||
#endif
|
||||
#if LANGUAGE_CHOICE == 4
|
||||
|
||||
// LCD Menu Messages
|
||||
|
||||
#define WELCOME_MSG MACHINE_NAME " Bereit."
|
||||
|
||||
#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 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 \""
|
||||
#define MSG_POWERUP "PowerUp"
|
||||
#define MSG_EXTERNAL_RESET " External Reset"
|
||||
#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 " | Author: "
|
||||
#define MSG_CONFIGURATION_VER " Last Updated: "
|
||||
#define MSG_FREE_MEMORY " Free Memory: "
|
||||
#define MSG_PLANNER_BUFFER_BYTES " PlannerBufferBytes: "
|
||||
#define MSG_OK "ok"
|
||||
#define MSG_FILE_SAVED "Done saving file."
|
||||
#define MSG_ERR_LINE_NO "Line Number is not Last Line Number+1, Last Line:"
|
||||
#define MSG_ERR_CHECKSUM_MISMATCH "checksum mismatch, Last Line:"
|
||||
#define MSG_ERR_NO_CHECKSUM "No Checksum with line number, Last Line:"
|
||||
#define MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM "No Line Number with checksum, Last Line:"
|
||||
#define MSG_FILE_PRINTED "Done printing file"
|
||||
#define MSG_BEGIN_FILE_LIST "Begin file list"
|
||||
#define MSG_END_FILE_LIST "End file list"
|
||||
#define MSG_M104_INVALID_EXTRUDER "M104 Invalid extruder "
|
||||
#define MSG_M105_INVALID_EXTRUDER "M105 Invalid extruder "
|
||||
#define MSG_ERR_NO_THERMISTORS "No thermistors - no temp"
|
||||
#define MSG_M109_INVALID_EXTRUDER "M109 Invalid extruder "
|
||||
#define MSG_HEATING "Heating..."
|
||||
#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:" 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_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_SD_CANT_OPEN_SUBDIR "Cannot open subdir"
|
||||
#define MSG_SD_INIT_FAIL "SD init fail"
|
||||
#define MSG_SD_VOL_INIT_FAIL "volume.init failed"
|
||||
#define MSG_SD_OPENROOT_FAIL "openRoot failed"
|
||||
#define MSG_SD_CARD_OK "SD card ok"
|
||||
#define MSG_SD_WORKDIR_FAIL "workDir open failed"
|
||||
#define MSG_SD_OPEN_FILE_FAIL "open failed, File: "
|
||||
#define MSG_SD_FILE_OPENED "File opened:"
|
||||
#define MSG_SD_SIZE " Size:"
|
||||
#define MSG_SD_FILE_SELECTED "File selected"
|
||||
#define MSG_SD_WRITE_TO_FILE "Writing to file: "
|
||||
#define MSG_SD_PRINTING_BYTE "SD printing byte "
|
||||
#define MSG_SD_NOT_PRINTING "Not SD printing"
|
||||
#define MSG_SD_ERR_WRITE_TO_FILE "error writing to file"
|
||||
#define MSG_SD_CANT_ENTER_SUBDIR "Cannot enter subdir:"
|
||||
|
||||
#define MSG_STEPPER_TO_HIGH "Steprate to high : "
|
||||
#define MSG_ENDSTOPS_HIT "endstops hit: "
|
||||
#define MSG_ERR_COLD_EXTRUDE_STOP " cold extrusion prevented"
|
||||
#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 " Retract"
|
||||
#define MSG_PREHEAT_PLA " Precalentar PLA"
|
||||
#define MSG_PREHEAT_PLA_SETTINGS " Precalentar PLA Setting"
|
||||
#define MSG_PREHEAT_ABS " Precalentar ABS"
|
||||
#define MSG_PREHEAT_ABS_SETTINGS " Precalentar ABS Setting"
|
||||
#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 " Control \x7E"
|
||||
#define MSG_TUNE " Ajustar \x7E"
|
||||
#define MSG_PAUSE_PRINT " Pause Print \x7E"
|
||||
#define MSG_RESUME_PRINT " Resume Print \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_Z_MAX "z_max:"
|
||||
|
||||
#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 entrar en 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
|
||||
#endif // ifndef LANGUAGE_H
|
||||
@@ -19,7 +19,6 @@
|
||||
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "Configuration.h"
|
||||
#include "Marlin.h"
|
||||
#include "stepper.h"
|
||||
#include "planner.h"
|
||||
@@ -27,7 +26,7 @@
|
||||
// The arc is approximated by generating a huge number of tiny, linear segments. The length of each
|
||||
// segment is configured in settings.mm_per_arc_segment.
|
||||
void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8_t axis_1,
|
||||
uint8_t axis_linear, float feed_rate, float radius, uint8_t isclockwise)
|
||||
uint8_t axis_linear, float feed_rate, float radius, uint8_t isclockwise, uint8_t extruder)
|
||||
{
|
||||
// int acceleration_manager_was_enabled = plan_is_acceleration_manager_enabled();
|
||||
// plan_set_acceleration_manager_enabled(false); // disable acceleration management for the duration of the arc
|
||||
@@ -46,8 +45,10 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8
|
||||
if (isclockwise) { angular_travel -= 2*M_PI; }
|
||||
|
||||
float millimeters_of_travel = hypot(angular_travel*radius, fabs(linear_travel));
|
||||
if (millimeters_of_travel == 0.0) { return; }
|
||||
if (millimeters_of_travel < 0.001) { return; }
|
||||
uint16_t segments = floor(millimeters_of_travel/MM_PER_ARC_SEGMENT);
|
||||
if(segments == 0) segments = 1;
|
||||
|
||||
/*
|
||||
// Multiply inverse feed_rate to compensate for the fact that this movement is approximated
|
||||
// by a number of discrete segments. The inverse feed_rate should be correct for the sum of
|
||||
@@ -123,11 +124,13 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8
|
||||
arc_target[axis_1] = center_axis1 + r_axis1;
|
||||
arc_target[axis_linear] += linear_per_segment;
|
||||
arc_target[E_AXIS] += extruder_per_segment;
|
||||
plan_buffer_line(arc_target[X_AXIS], arc_target[Y_AXIS], arc_target[Z_AXIS], arc_target[E_AXIS], feed_rate);
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
// Ensure last segment arrives at target location.
|
||||
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feed_rate);
|
||||
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feed_rate, extruder);
|
||||
|
||||
// plan_set_acceleration_manager_enabled(acceleration_manager_was_enabled);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,6 @@
|
||||
// the direction of helical travel, radius == circle radius, isclockwise boolean. Used
|
||||
// for vector transformation direction.
|
||||
void mc_arc(float *position, float *target, float *offset, unsigned char axis_0, unsigned char axis_1,
|
||||
unsigned char axis_linear, float feed_rate, float radius, unsigned char isclockwise);
|
||||
unsigned char axis_linear, float feed_rate, float radius, unsigned char isclockwise, uint8_t extruder);
|
||||
|
||||
#endif
|
||||
|
||||
+1162
-694
File diff suppressed because it is too large
Load Diff
+359
-261
@@ -1,69 +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
|
||||
|
||||
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 <inttypes.h>
|
||||
//#include <math.h>
|
||||
//#include <stdlib.h>
|
||||
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)
|
||||
*/
|
||||
|
||||
#include "Marlin.h"
|
||||
#include "Configuration.h"
|
||||
#include "pins.h"
|
||||
#include "fastio.h"
|
||||
#include "planner.h"
|
||||
#include "stepper.h"
|
||||
#include "temperature.h"
|
||||
#include "ultralcd.h"
|
||||
#include "language.h"
|
||||
|
||||
//===========================================================================
|
||||
//=============================public variables ============================
|
||||
@@ -78,6 +71,7 @@ float acceleration; // Normal acceleration mm/s^2 THIS IS THE DEFAULT A
|
||||
float retract_acceleration; // mm/s^2 filament pull-pack and push-forward while standing still in the other axis M204 TXXXX
|
||||
float max_xy_jerk; //speed than can be stopped at once, if i understand correctly.
|
||||
float max_z_jerk;
|
||||
float max_e_jerk;
|
||||
float mintravelfeedrate;
|
||||
unsigned long axis_steps_per_sqr_second[NUM_AXIS];
|
||||
|
||||
@@ -86,38 +80,53 @@ long position[4]; //rescaled from extern when axis_steps_per_unit are changed
|
||||
static float previous_speed[4]; // Speed of previous path line segment
|
||||
static float previous_nominal_speed; // Nominal speed of previous path line segment
|
||||
|
||||
extern volatile int extrudemultiply; // Sets extrude multiply factor (in percent)
|
||||
|
||||
#ifdef AUTOTEMP
|
||||
float autotemp_max=250;
|
||||
float autotemp_min=210;
|
||||
float autotemp_factor=1;
|
||||
bool autotemp_enabled=false;
|
||||
float autotemp_max=250;
|
||||
float autotemp_min=210;
|
||||
float autotemp_factor=0.1;
|
||||
bool autotemp_enabled=false;
|
||||
#endif
|
||||
|
||||
//===========================================================================
|
||||
//=================semi-private variables, used in inline functions =====
|
||||
//===========================================================================
|
||||
block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instfructions
|
||||
volatile unsigned char block_buffer_head; // Index of the next block to be pushed
|
||||
volatile unsigned char block_buffer_tail; // Index of the block to process now
|
||||
|
||||
//===========================================================================
|
||||
//=============================private variables ============================
|
||||
//===========================================================================
|
||||
static block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instfructions
|
||||
static volatile unsigned char block_buffer_head; // Index of the next block to be pushed
|
||||
static volatile unsigned char block_buffer_tail; // Index of the block to process now
|
||||
|
||||
#ifdef PREVENT_DANGEROUS_EXTRUDE
|
||||
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};
|
||||
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);
|
||||
}
|
||||
@@ -128,10 +137,11 @@ static int8_t prev_block_index(int8_t block_index) {
|
||||
|
||||
// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the
|
||||
// given acceleration:
|
||||
inline float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration) {
|
||||
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
|
||||
@@ -143,10 +153,11 @@ inline float estimate_acceleration_distance(float initial_rate, float target_rat
|
||||
// a total travel of distance. This can be used to compute the intersection point between acceleration and
|
||||
// deceleration in the cases where the trapezoid has no plateau (i.e. never reaches maximum speed)
|
||||
|
||||
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) );
|
||||
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) );
|
||||
}
|
||||
else {
|
||||
return 0.0; // acceleration was 0, set intersection distance to 0
|
||||
@@ -160,54 +171,57 @@ 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));
|
||||
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
|
||||
long initial_advance = block->advance*entry_factor*entry_factor;
|
||||
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;
|
||||
}
|
||||
|
||||
// Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the
|
||||
// acceleration within the allotted distance.
|
||||
inline float max_allowable_speed(float acceleration, float target_velocity, float distance) {
|
||||
FORCE_INLINE float max_allowable_speed(float acceleration, float target_velocity, float distance) {
|
||||
return sqrt(target_velocity*target_velocity-2*acceleration*distance);
|
||||
}
|
||||
|
||||
@@ -222,24 +236,27 @@ inline float max_allowable_speed(float acceleration, float target_velocity, floa
|
||||
|
||||
// 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.
|
||||
}
|
||||
@@ -247,11 +264,18 @@ void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *n
|
||||
// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This
|
||||
// implements the reverse pass.
|
||||
void planner_reverse_pass() {
|
||||
char block_index = block_buffer_head;
|
||||
if(((block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1)) > 3) {
|
||||
uint8_t block_index = block_buffer_head;
|
||||
|
||||
//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];
|
||||
@@ -263,8 +287,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.
|
||||
@@ -272,7 +298,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) {
|
||||
@@ -286,8 +312,9 @@ void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *n
|
||||
// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This
|
||||
// implements the forward pass.
|
||||
void planner_forward_pass() {
|
||||
char block_index = block_buffer_tail;
|
||||
block_t *block[3] = { NULL, NULL, NULL };
|
||||
uint8_t block_index = block_buffer_tail;
|
||||
block_t *block[3] = {
|
||||
NULL, NULL, NULL };
|
||||
|
||||
while(block_index != block_buffer_head) {
|
||||
block[0] = block[1];
|
||||
@@ -306,7 +333,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];
|
||||
@@ -315,7 +342,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
|
||||
}
|
||||
}
|
||||
@@ -324,7 +351,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;
|
||||
}
|
||||
}
|
||||
@@ -364,43 +391,36 @@ void plan_init() {
|
||||
}
|
||||
|
||||
|
||||
void plan_discard_current_block() {
|
||||
if (block_buffer_head != block_buffer_tail) {
|
||||
block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1);
|
||||
}
|
||||
}
|
||||
|
||||
block_t *plan_get_current_block() {
|
||||
if (block_buffer_head == block_buffer_tail) {
|
||||
return(NULL);
|
||||
}
|
||||
block_t *block = &block_buffer[block_buffer_tail];
|
||||
block->busy = true;
|
||||
return(block);
|
||||
}
|
||||
|
||||
#ifdef AUTOTEMP
|
||||
void getHighESpeed()
|
||||
{
|
||||
static float oldt=0;
|
||||
if(!autotemp_enabled)
|
||||
if(!autotemp_enabled){
|
||||
return;
|
||||
if(degTargetHotend0()+2<autotemp_min) //probably temperature set to zero.
|
||||
}
|
||||
if(degTargetHotend0()+2<autotemp_min) { //probably temperature set to zero.
|
||||
return; //do nothing
|
||||
|
||||
float high=0;
|
||||
char block_index = block_buffer_tail;
|
||||
|
||||
}
|
||||
|
||||
float high=0.0;
|
||||
uint8_t block_index = block_buffer_tail;
|
||||
|
||||
while(block_index != block_buffer_head) {
|
||||
float se=block_buffer[block_index].steps_e/float(block_buffer[block_index].step_event_count)*block_buffer[block_index].nominal_rate;
|
||||
//se; units steps/sec;
|
||||
if(se>high)
|
||||
{
|
||||
high=se;
|
||||
if((block_buffer[block_index].steps_x != 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)
|
||||
{
|
||||
high=se;
|
||||
}
|
||||
}
|
||||
block_index = (block_index+1) & (BLOCK_BUFFER_SIZE - 1);
|
||||
}
|
||||
|
||||
|
||||
float g=autotemp_min+high*autotemp_factor;
|
||||
float t=g;
|
||||
if(t<autotemp_min)
|
||||
@@ -413,10 +433,6 @@ void getHighESpeed()
|
||||
}
|
||||
oldt=t;
|
||||
setTargetHotend0(t);
|
||||
// SERIAL_ECHO_START;
|
||||
// SERIAL_ECHOPAIR("highe",high);
|
||||
// SERIAL_ECHOPAIR(" t",t);
|
||||
// SERIAL_ECHOLN("");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -425,23 +441,50 @@ void check_axes_activity() {
|
||||
unsigned char y_active = 0;
|
||||
unsigned char z_active = 0;
|
||||
unsigned char e_active = 0;
|
||||
unsigned char fan_speed = 0;
|
||||
unsigned char tail_fan_speed = 0;
|
||||
block_t *block;
|
||||
|
||||
if(block_buffer_tail != block_buffer_head) {
|
||||
char block_index = block_buffer_tail;
|
||||
uint8_t block_index = block_buffer_tail;
|
||||
tail_fan_speed = block_buffer[block_index].fan_speed;
|
||||
while(block_index != block_buffer_head) {
|
||||
block = &block_buffer[block_index];
|
||||
if(block->steps_x != 0) x_active++;
|
||||
if(block->steps_y != 0) y_active++;
|
||||
if(block->steps_z != 0) z_active++;
|
||||
if(block->steps_e != 0) e_active++;
|
||||
if(block->fan_speed != 0) fan_speed++;
|
||||
block_index = (block_index+1) & (BLOCK_BUFFER_SIZE - 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
#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_e();
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -449,7 +492,7 @@ float junction_deviation = 0.1;
|
||||
// Add a new linear movement to the buffer. steps_x, _y and _z is the absolute position in
|
||||
// mm. Microseconds specify how many microseconds the move should take to perform. To aid acceleration
|
||||
// calculation the caller must also provide the physical length of the line in millimeters.
|
||||
void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate)
|
||||
void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder)
|
||||
{
|
||||
// Calculate the buffer head after we push this byte
|
||||
int next_buffer_head = next_block_index(block_buffer_head);
|
||||
@@ -458,7 +501,7 @@ 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;
|
||||
}
|
||||
|
||||
@@ -469,11 +512,29 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||
target[X_AXIS] = lround(x*axis_steps_per_unit[X_AXIS]);
|
||||
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]);
|
||||
|
||||
target[E_AXIS] = lround(e*axis_steps_per_unit[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);
|
||||
}
|
||||
#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;
|
||||
|
||||
@@ -482,84 +543,103 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||
block->steps_y = labs(target[Y_AXIS]-position[Y_AXIS]);
|
||||
block->steps_z = labs(target[Z_AXIS]-position[Z_AXIS]);
|
||||
block->steps_e = labs(target[E_AXIS]-position[E_AXIS]);
|
||||
block->steps_e *= extrudemultiply;
|
||||
block->steps_e /= 100;
|
||||
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;
|
||||
};
|
||||
|
||||
// Compute direction bits for this block
|
||||
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();
|
||||
if(block->steps_e != 0) enable_e();
|
||||
#endif
|
||||
|
||||
// Enable all
|
||||
if(block->steps_e != 0) {
|
||||
enable_e0();
|
||||
enable_e1();
|
||||
enable_e2();
|
||||
}
|
||||
|
||||
if (block->steps_e == 0) {
|
||||
if(feed_rate<mintravelfeedrate) feed_rate=mintravelfeedrate;
|
||||
}
|
||||
else {
|
||||
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];
|
||||
block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) +
|
||||
square(delta_mm[Z_AXIS]) + square(delta_mm[E_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 = 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.
|
||||
|
||||
// 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));
|
||||
}
|
||||
}
|
||||
#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
|
||||
|
||||
// segment time im micro seconds
|
||||
long segment_time = lround(1000000.0/inverse_second);
|
||||
|
||||
|
||||
if (block->steps_e == 0) {
|
||||
if(feed_rate<mintravelfeedrate) feed_rate=mintravelfeedrate;
|
||||
}
|
||||
else {
|
||||
if(feed_rate<minimumfeedrate) feed_rate=minimumfeedrate;
|
||||
}
|
||||
|
||||
#ifdef SLOWDOWN
|
||||
// slow down when de buffer starts to empty, rather than wait at the corner for a buffer refill
|
||||
int moves_queued=(block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1);
|
||||
|
||||
if(moves_queued < (BLOCK_BUFFER_SIZE * 0.5)) feed_rate = feed_rate / ((BLOCK_BUFFER_SIZE * 0.5)/moves_queued);
|
||||
#endif
|
||||
|
||||
/*
|
||||
if ((blockcount>0) && (blockcount < (BLOCK_BUFFER_SIZE - 4))) {
|
||||
if (segment_time<minsegmenttime) { // buffer is draining, add extra time. The amount of time added increases if the buffer is still emptied more.
|
||||
segment_time=segment_time+lround(2*(minsegmenttime-segment_time)/blockcount);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (segment_time<minsegmenttime) segment_time=minsegmenttime;
|
||||
}
|
||||
// END OF SLOW DOWN SECTION
|
||||
*/
|
||||
|
||||
|
||||
// Calculate speed in mm/sec for each axis
|
||||
// Calculate and limit speed in mm/sec for each axis
|
||||
float current_speed[4];
|
||||
for(int i=0; i < 4; i++) {
|
||||
current_speed[i] = delta_mm[i] * inverse_second;
|
||||
}
|
||||
|
||||
// Limit speed per axis
|
||||
float speed_factor = 1.0; //factor <=1 do decrease speed
|
||||
for(int i=0; i < 4; i++) {
|
||||
if(abs(current_speed[i]) > max_feedrate[i])
|
||||
speed_factor = min(speed_factor, max_feedrate[i] / abs(current_speed[i]));
|
||||
current_speed[i] = delta_mm[i] * inverse_second;
|
||||
if(fabs(current_speed[i]) > max_feedrate[i])
|
||||
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)
|
||||
|
||||
@@ -568,7 +648,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];
|
||||
@@ -576,7 +656,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];
|
||||
@@ -591,17 +671,6 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||
|
||||
// Correct the speed
|
||||
if( speed_factor < 1.0) {
|
||||
// Serial.print("speed factor : "); Serial.println(speed_factor);
|
||||
for(int i=0; i < 4; i++) {
|
||||
if(abs(current_speed[i]) > max_feedrate[i])
|
||||
speed_factor = min(speed_factor, max_feedrate[i] / abs(current_speed[i]));
|
||||
/*
|
||||
if(speed_factor < 0.1) {
|
||||
Serial.print("speed factor : "); Serial.println(speed_factor);
|
||||
Serial.print("current_speed"); Serial.print(i); Serial.print(" : "); Serial.println(current_speed[i]);
|
||||
}
|
||||
*/
|
||||
}
|
||||
for(unsigned char i=0; i < 4; i++) {
|
||||
current_speed[i] *= speed_factor;
|
||||
}
|
||||
@@ -628,7 +697,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];
|
||||
@@ -636,7 +705,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,
|
||||
@@ -653,9 +722,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);
|
||||
@@ -664,31 +733,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;
|
||||
if(abs(current_speed[Z_AXIS]) > max_z_jerk/2)
|
||||
vmax_junction = max_z_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 = 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 ((block_buffer_head != block_buffer_tail) && (previous_nominal_speed > 0.0)) {
|
||||
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((previous_speed[X_AXIS] != 0.0) || (previous_speed[Y_AXIS] != 0.0)) {
|
||||
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(abs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]) > max_z_jerk) {
|
||||
vmax_junction *= (max_z_jerk/abs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]));
|
||||
if(fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]) > max_z_jerk) {
|
||||
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_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);
|
||||
@@ -701,50 +778,57 @@ 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) *
|
||||
(block->speed_e * block->speed_e * EXTRUTION_AREA * EXTRUTION_AREA / 3600.0)*65536;
|
||||
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;
|
||||
}
|
||||
#endif // ADVANCE
|
||||
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
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
|
||||
|
||||
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[]
|
||||
|
||||
planner_recalculate();
|
||||
#ifdef AUTOTEMP
|
||||
getHighESpeed();
|
||||
#endif
|
||||
|
||||
st_wake_up();
|
||||
}
|
||||
|
||||
@@ -762,7 +846,21 @@ void plan_set_position(const float &x, const float &y, const float &z, const flo
|
||||
previous_speed[3] = 0.0;
|
||||
}
|
||||
|
||||
void plan_set_e_position(const float &e)
|
||||
{
|
||||
position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]);
|
||||
st_set_e_position(position[E_AXIS]);
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
+51
-17
@@ -24,7 +24,7 @@
|
||||
#ifndef planner_h
|
||||
#define planner_h
|
||||
|
||||
#include "Configuration.h"
|
||||
#include "Marlin.h"
|
||||
|
||||
// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in
|
||||
// the source g-code and may never actually be reached if acceleration management is active.
|
||||
@@ -36,18 +36,19 @@ typedef struct {
|
||||
long decelerate_after; // The index of the step event on which to start decelerating
|
||||
long acceleration_rate; // The acceleration rate used for acceleration calculation
|
||||
unsigned char direction_bits; // The direction bit set for this block (refers to *_DIRECTION_BIT in config.h)
|
||||
unsigned char active_extruder; // Selects the active extruder
|
||||
#ifdef ADVANCE
|
||||
// long advance_rate;
|
||||
// volatile long initial_advance;
|
||||
// volatile long final_advance;
|
||||
// float advance;
|
||||
long advance_rate;
|
||||
volatile long initial_advance;
|
||||
volatile long final_advance;
|
||||
float advance;
|
||||
#endif
|
||||
|
||||
// Fields used by the motion planner to manage acceleration
|
||||
// float speed_x, speed_y, speed_z, speed_e; // Nominal mm/minute for each axis
|
||||
float nominal_speed; // The nominal speed for this block in mm/min
|
||||
float entry_speed; // Entry speed at previous-current junction in mm/min
|
||||
float max_entry_speed; // Maximum allowable junction entry speed in mm/min
|
||||
// float speed_x, speed_y, speed_z, speed_e; // Nominal mm/sec for each axis
|
||||
float nominal_speed; // The nominal speed for this block in mm/sec
|
||||
float entry_speed; // Entry speed at previous-current junction in mm/sec
|
||||
float max_entry_speed; // Maximum allowable junction entry speed in mm/sec
|
||||
float millimeters; // The total travel of this block in mm
|
||||
float acceleration; // acceleration mm/sec^2
|
||||
unsigned char recalculate_flag; // Planner flag to recalculate trapezoids on entry junction
|
||||
@@ -58,6 +59,7 @@ typedef struct {
|
||||
unsigned long initial_rate; // The jerk-adjusted step rate at start of block
|
||||
unsigned long final_rate; // The minimal rate at exit
|
||||
unsigned long acceleration_st; // acceleration steps/sec^2
|
||||
unsigned long fan_speed;
|
||||
volatile char busy;
|
||||
} block_t;
|
||||
|
||||
@@ -66,18 +68,13 @@ void plan_init();
|
||||
|
||||
// Add a new linear movement to the buffer. x, y and z is the signed, absolute target position in
|
||||
// millimaters. Feed rate specifies the speed of the motion.
|
||||
void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate);
|
||||
void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder);
|
||||
|
||||
// Set position. Used for G92 instructions.
|
||||
void plan_set_position(const float &x, const float &y, const float &z, const float &e);
|
||||
void plan_set_e_position(const float &e);
|
||||
|
||||
|
||||
// Called when the current block is no longer needed. Discards the block and makes the memory
|
||||
// availible for new blocks.
|
||||
void plan_discard_current_block();
|
||||
|
||||
// Gets the current block. Returns NULL if buffer empty
|
||||
block_t *plan_get_current_block();
|
||||
|
||||
void check_axes_activity();
|
||||
uint8_t movesplanned(); //return the nr of buffered moves
|
||||
@@ -91,10 +88,10 @@ extern float acceleration; // Normal acceleration mm/s^2 THIS IS THE DE
|
||||
extern float retract_acceleration; // mm/s^2 filament pull-pack and push-forward while standing still in the other axis M204 TXXXX
|
||||
extern float max_xy_jerk; //speed than can be stopped at once, if i understand correctly.
|
||||
extern float max_z_jerk;
|
||||
extern float max_e_jerk;
|
||||
extern float mintravelfeedrate;
|
||||
extern unsigned long axis_steps_per_sqr_second[NUM_AXIS];
|
||||
|
||||
|
||||
#ifdef AUTOTEMP
|
||||
extern bool autotemp_enabled;
|
||||
extern float autotemp_max;
|
||||
@@ -102,4 +99,41 @@ extern unsigned long axis_steps_per_sqr_second[NUM_AXIS];
|
||||
extern float autotemp_factor;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
extern block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instfructions
|
||||
extern volatile unsigned char block_buffer_head; // Index of the next block to be pushed
|
||||
extern volatile unsigned char block_buffer_tail;
|
||||
// Called when the current block is no longer needed. Discards the block and makes the memory
|
||||
// availible for new blocks.
|
||||
FORCE_INLINE void plan_discard_current_block()
|
||||
{
|
||||
if (block_buffer_head != block_buffer_tail) {
|
||||
block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Gets the current block. Returns NULL if buffer empty
|
||||
FORCE_INLINE block_t *plan_get_current_block()
|
||||
{
|
||||
if (block_buffer_head == block_buffer_tail) {
|
||||
return(NULL);
|
||||
}
|
||||
block_t *block = &block_buffer[block_buffer_tail];
|
||||
block->busy = true;
|
||||
return(block);
|
||||
}
|
||||
|
||||
// Gets the current block. Returns NULL if buffer empty
|
||||
FORCE_INLINE bool blocks_queued()
|
||||
{
|
||||
if (block_buffer_head == block_buffer_tail) {
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
void allow_cold_extrudes(bool allow);
|
||||
#endif
|
||||
|
||||
+152
-76
@@ -1,76 +1,152 @@
|
||||
#ifndef SPEED_LOOKUPTABLE_H
|
||||
#define SPEED_LOOKUPTABLE_H
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
uint16_t speed_lookuptable_fast[256][2] PROGMEM = {\
|
||||
{ 62500, 55556}, { 6944, 3268}, { 3676, 1176}, { 2500, 607}, { 1893, 369}, { 1524, 249}, { 1275, 179}, { 1096, 135},
|
||||
{ 961, 105}, { 856, 85}, { 771, 69}, { 702, 58}, { 644, 49}, { 595, 42}, { 553, 37}, { 516, 32},
|
||||
{ 484, 28}, { 456, 25}, { 431, 23}, { 408, 20}, { 388, 19}, { 369, 16}, { 353, 16}, { 337, 14},
|
||||
{ 323, 13}, { 310, 11}, { 299, 11}, { 288, 11}, { 277, 9}, { 268, 9}, { 259, 8}, { 251, 8},
|
||||
{ 243, 8}, { 235, 7}, { 228, 6}, { 222, 6}, { 216, 6}, { 210, 6}, { 204, 5}, { 199, 5},
|
||||
{ 194, 5}, { 189, 4}, { 185, 4}, { 181, 4}, { 177, 4}, { 173, 4}, { 169, 4}, { 165, 3},
|
||||
{ 162, 3}, { 159, 4}, { 155, 3}, { 152, 3}, { 149, 2}, { 147, 3}, { 144, 3}, { 141, 2},
|
||||
{ 139, 3}, { 136, 2}, { 134, 2}, { 132, 3}, { 129, 2}, { 127, 2}, { 125, 2}, { 123, 2},
|
||||
{ 121, 2}, { 119, 1}, { 118, 2}, { 116, 2}, { 114, 1}, { 113, 2}, { 111, 2}, { 109, 1},
|
||||
{ 108, 2}, { 106, 1}, { 105, 2}, { 103, 1}, { 102, 1}, { 101, 1}, { 100, 2}, { 98, 1},
|
||||
{ 97, 1}, { 96, 1}, { 95, 2}, { 93, 1}, { 92, 1}, { 91, 1}, { 90, 1}, { 89, 1},
|
||||
{ 88, 1}, { 87, 1}, { 86, 1}, { 85, 1}, { 84, 1}, { 83, 0}, { 83, 1}, { 82, 1},
|
||||
{ 81, 1}, { 80, 1}, { 79, 1}, { 78, 0}, { 78, 1}, { 77, 1}, { 76, 1}, { 75, 0},
|
||||
{ 75, 1}, { 74, 1}, { 73, 1}, { 72, 0}, { 72, 1}, { 71, 1}, { 70, 0}, { 70, 1},
|
||||
{ 69, 0}, { 69, 1}, { 68, 1}, { 67, 0}, { 67, 1}, { 66, 0}, { 66, 1}, { 65, 0},
|
||||
{ 65, 1}, { 64, 1}, { 63, 0}, { 63, 1}, { 62, 0}, { 62, 1}, { 61, 0}, { 61, 1},
|
||||
{ 60, 0}, { 60, 0}, { 60, 1}, { 59, 0}, { 59, 1}, { 58, 0}, { 58, 1}, { 57, 0},
|
||||
{ 57, 1}, { 56, 0}, { 56, 0}, { 56, 1}, { 55, 0}, { 55, 1}, { 54, 0}, { 54, 0},
|
||||
{ 54, 1}, { 53, 0}, { 53, 0}, { 53, 1}, { 52, 0}, { 52, 0}, { 52, 1}, { 51, 0},
|
||||
{ 51, 0}, { 51, 1}, { 50, 0}, { 50, 0}, { 50, 1}, { 49, 0}, { 49, 0}, { 49, 1},
|
||||
{ 48, 0}, { 48, 0}, { 48, 1}, { 47, 0}, { 47, 0}, { 47, 0}, { 47, 1}, { 46, 0},
|
||||
{ 46, 0}, { 46, 1}, { 45, 0}, { 45, 0}, { 45, 0}, { 45, 1}, { 44, 0}, { 44, 0},
|
||||
{ 44, 0}, { 44, 1}, { 43, 0}, { 43, 0}, { 43, 0}, { 43, 1}, { 42, 0}, { 42, 0},
|
||||
{ 42, 0}, { 42, 1}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 1}, { 40, 0},
|
||||
{ 40, 0}, { 40, 0}, { 40, 0}, { 40, 1}, { 39, 0}, { 39, 0}, { 39, 0}, { 39, 0},
|
||||
{ 39, 1}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 1}, { 37, 0}, { 37, 0},
|
||||
{ 37, 0}, { 37, 0}, { 37, 0}, { 37, 1}, { 36, 0}, { 36, 0}, { 36, 0}, { 36, 0},
|
||||
{ 36, 1}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 1},
|
||||
{ 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 1}, { 33, 0}, { 33, 0},
|
||||
{ 33, 0}, { 33, 0}, { 33, 0}, { 33, 0}, { 33, 1}, { 32, 0}, { 32, 0}, { 32, 0},
|
||||
{ 32, 0}, { 32, 0}, { 32, 0}, { 32, 0}, { 32, 1}, { 31, 0}, { 31, 0}, { 31, 0},
|
||||
{ 31, 0}, { 31, 0}, { 31, 0}, { 31, 1}, { 30, 0}, { 30, 0}, { 30, 0}, { 30, 0}
|
||||
};
|
||||
|
||||
uint16_t speed_lookuptable_slow[256][2] PROGMEM = {\
|
||||
{ 62500, 12500}, { 50000, 8334}, { 41666, 5952}, { 35714, 4464}, { 31250, 3473}, { 27777, 2777}, { 25000, 2273}, { 22727, 1894},
|
||||
{ 20833, 1603}, { 19230, 1373}, { 17857, 1191}, { 16666, 1041}, { 15625, 920}, { 14705, 817}, { 13888, 731}, { 13157, 657},
|
||||
{ 12500, 596}, { 11904, 541}, { 11363, 494}, { 10869, 453}, { 10416, 416}, { 10000, 385}, { 9615, 356}, { 9259, 331},
|
||||
{ 8928, 308}, { 8620, 287}, { 8333, 269}, { 8064, 252}, { 7812, 237}, { 7575, 223}, { 7352, 210}, { 7142, 198},
|
||||
{ 6944, 188}, { 6756, 178}, { 6578, 168}, { 6410, 160}, { 6250, 153}, { 6097, 145}, { 5952, 139}, { 5813, 132},
|
||||
{ 5681, 126}, { 5555, 121}, { 5434, 115}, { 5319, 111}, { 5208, 106}, { 5102, 102}, { 5000, 99}, { 4901, 94},
|
||||
{ 4807, 91}, { 4716, 87}, { 4629, 84}, { 4545, 81}, { 4464, 79}, { 4385, 75}, { 4310, 73}, { 4237, 71},
|
||||
{ 4166, 68}, { 4098, 66}, { 4032, 64}, { 3968, 62}, { 3906, 60}, { 3846, 59}, { 3787, 56}, { 3731, 55},
|
||||
{ 3676, 53}, { 3623, 52}, { 3571, 50}, { 3521, 49}, { 3472, 48}, { 3424, 46}, { 3378, 45}, { 3333, 44},
|
||||
{ 3289, 43}, { 3246, 41}, { 3205, 41}, { 3164, 39}, { 3125, 39}, { 3086, 38}, { 3048, 36}, { 3012, 36},
|
||||
{ 2976, 35}, { 2941, 35}, { 2906, 33}, { 2873, 33}, { 2840, 32}, { 2808, 31}, { 2777, 30}, { 2747, 30},
|
||||
{ 2717, 29}, { 2688, 29}, { 2659, 28}, { 2631, 27}, { 2604, 27}, { 2577, 26}, { 2551, 26}, { 2525, 25},
|
||||
{ 2500, 25}, { 2475, 25}, { 2450, 23}, { 2427, 24}, { 2403, 23}, { 2380, 22}, { 2358, 22}, { 2336, 22},
|
||||
{ 2314, 21}, { 2293, 21}, { 2272, 20}, { 2252, 20}, { 2232, 20}, { 2212, 20}, { 2192, 19}, { 2173, 18},
|
||||
{ 2155, 19}, { 2136, 18}, { 2118, 18}, { 2100, 17}, { 2083, 17}, { 2066, 17}, { 2049, 17}, { 2032, 16},
|
||||
{ 2016, 16}, { 2000, 16}, { 1984, 16}, { 1968, 15}, { 1953, 16}, { 1937, 14}, { 1923, 15}, { 1908, 15},
|
||||
{ 1893, 14}, { 1879, 14}, { 1865, 14}, { 1851, 13}, { 1838, 14}, { 1824, 13}, { 1811, 13}, { 1798, 13},
|
||||
{ 1785, 12}, { 1773, 13}, { 1760, 12}, { 1748, 12}, { 1736, 12}, { 1724, 12}, { 1712, 12}, { 1700, 11},
|
||||
{ 1689, 12}, { 1677, 11}, { 1666, 11}, { 1655, 11}, { 1644, 11}, { 1633, 10}, { 1623, 11}, { 1612, 10},
|
||||
{ 1602, 10}, { 1592, 10}, { 1582, 10}, { 1572, 10}, { 1562, 10}, { 1552, 9}, { 1543, 10}, { 1533, 9},
|
||||
{ 1524, 9}, { 1515, 9}, { 1506, 9}, { 1497, 9}, { 1488, 9}, { 1479, 9}, { 1470, 9}, { 1461, 8},
|
||||
{ 1453, 8}, { 1445, 9}, { 1436, 8}, { 1428, 8}, { 1420, 8}, { 1412, 8}, { 1404, 8}, { 1396, 8},
|
||||
{ 1388, 7}, { 1381, 8}, { 1373, 7}, { 1366, 8}, { 1358, 7}, { 1351, 7}, { 1344, 8}, { 1336, 7},
|
||||
{ 1329, 7}, { 1322, 7}, { 1315, 7}, { 1308, 6}, { 1302, 7}, { 1295, 7}, { 1288, 6}, { 1282, 7},
|
||||
{ 1275, 6}, { 1269, 7}, { 1262, 6}, { 1256, 6}, { 1250, 7}, { 1243, 6}, { 1237, 6}, { 1231, 6},
|
||||
{ 1225, 6}, { 1219, 6}, { 1213, 6}, { 1207, 6}, { 1201, 5}, { 1196, 6}, { 1190, 6}, { 1184, 5},
|
||||
{ 1179, 6}, { 1173, 5}, { 1168, 6}, { 1162, 5}, { 1157, 5}, { 1152, 6}, { 1146, 5}, { 1141, 5},
|
||||
{ 1136, 5}, { 1131, 5}, { 1126, 5}, { 1121, 5}, { 1116, 5}, { 1111, 5}, { 1106, 5}, { 1101, 5},
|
||||
{ 1096, 5}, { 1091, 5}, { 1086, 4}, { 1082, 5}, { 1077, 5}, { 1072, 4}, { 1068, 5}, { 1063, 4},
|
||||
{ 1059, 5}, { 1054, 4}, { 1050, 4}, { 1046, 5}, { 1041, 4}, { 1037, 4}, { 1033, 5}, { 1028, 4},
|
||||
{ 1024, 4}, { 1020, 4}, { 1016, 4}, { 1012, 4}, { 1008, 4}, { 1004, 4}, { 1000, 4}, { 996, 4},
|
||||
{ 992, 4}, { 988, 4}, { 984, 4}, { 980, 4}, { 976, 4}, { 972, 4}, { 968, 3}, { 965, 3}
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef SPEED_LOOKUPTABLE_H
|
||||
#define SPEED_LOOKUPTABLE_H
|
||||
|
||||
#include "Marlin.h"
|
||||
|
||||
#if F_CPU == 16000000
|
||||
|
||||
const uint16_t speed_lookuptable_fast[256][2] PROGMEM = {\
|
||||
{ 62500, 55556}, { 6944, 3268}, { 3676, 1176}, { 2500, 607}, { 1893, 369}, { 1524, 249}, { 1275, 179}, { 1096, 135},
|
||||
{ 961, 105}, { 856, 85}, { 771, 69}, { 702, 58}, { 644, 49}, { 595, 42}, { 553, 37}, { 516, 32},
|
||||
{ 484, 28}, { 456, 25}, { 431, 23}, { 408, 20}, { 388, 19}, { 369, 16}, { 353, 16}, { 337, 14},
|
||||
{ 323, 13}, { 310, 11}, { 299, 11}, { 288, 11}, { 277, 9}, { 268, 9}, { 259, 8}, { 251, 8},
|
||||
{ 243, 8}, { 235, 7}, { 228, 6}, { 222, 6}, { 216, 6}, { 210, 6}, { 204, 5}, { 199, 5},
|
||||
{ 194, 5}, { 189, 4}, { 185, 4}, { 181, 4}, { 177, 4}, { 173, 4}, { 169, 4}, { 165, 3},
|
||||
{ 162, 3}, { 159, 4}, { 155, 3}, { 152, 3}, { 149, 2}, { 147, 3}, { 144, 3}, { 141, 2},
|
||||
{ 139, 3}, { 136, 2}, { 134, 2}, { 132, 3}, { 129, 2}, { 127, 2}, { 125, 2}, { 123, 2},
|
||||
{ 121, 2}, { 119, 1}, { 118, 2}, { 116, 2}, { 114, 1}, { 113, 2}, { 111, 2}, { 109, 1},
|
||||
{ 108, 2}, { 106, 1}, { 105, 2}, { 103, 1}, { 102, 1}, { 101, 1}, { 100, 2}, { 98, 1},
|
||||
{ 97, 1}, { 96, 1}, { 95, 2}, { 93, 1}, { 92, 1}, { 91, 1}, { 90, 1}, { 89, 1},
|
||||
{ 88, 1}, { 87, 1}, { 86, 1}, { 85, 1}, { 84, 1}, { 83, 0}, { 83, 1}, { 82, 1},
|
||||
{ 81, 1}, { 80, 1}, { 79, 1}, { 78, 0}, { 78, 1}, { 77, 1}, { 76, 1}, { 75, 0},
|
||||
{ 75, 1}, { 74, 1}, { 73, 1}, { 72, 0}, { 72, 1}, { 71, 1}, { 70, 0}, { 70, 1},
|
||||
{ 69, 0}, { 69, 1}, { 68, 1}, { 67, 0}, { 67, 1}, { 66, 0}, { 66, 1}, { 65, 0},
|
||||
{ 65, 1}, { 64, 1}, { 63, 0}, { 63, 1}, { 62, 0}, { 62, 1}, { 61, 0}, { 61, 1},
|
||||
{ 60, 0}, { 60, 0}, { 60, 1}, { 59, 0}, { 59, 1}, { 58, 0}, { 58, 1}, { 57, 0},
|
||||
{ 57, 1}, { 56, 0}, { 56, 0}, { 56, 1}, { 55, 0}, { 55, 1}, { 54, 0}, { 54, 0},
|
||||
{ 54, 1}, { 53, 0}, { 53, 0}, { 53, 1}, { 52, 0}, { 52, 0}, { 52, 1}, { 51, 0},
|
||||
{ 51, 0}, { 51, 1}, { 50, 0}, { 50, 0}, { 50, 1}, { 49, 0}, { 49, 0}, { 49, 1},
|
||||
{ 48, 0}, { 48, 0}, { 48, 1}, { 47, 0}, { 47, 0}, { 47, 0}, { 47, 1}, { 46, 0},
|
||||
{ 46, 0}, { 46, 1}, { 45, 0}, { 45, 0}, { 45, 0}, { 45, 1}, { 44, 0}, { 44, 0},
|
||||
{ 44, 0}, { 44, 1}, { 43, 0}, { 43, 0}, { 43, 0}, { 43, 1}, { 42, 0}, { 42, 0},
|
||||
{ 42, 0}, { 42, 1}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 1}, { 40, 0},
|
||||
{ 40, 0}, { 40, 0}, { 40, 0}, { 40, 1}, { 39, 0}, { 39, 0}, { 39, 0}, { 39, 0},
|
||||
{ 39, 1}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 1}, { 37, 0}, { 37, 0},
|
||||
{ 37, 0}, { 37, 0}, { 37, 0}, { 37, 1}, { 36, 0}, { 36, 0}, { 36, 0}, { 36, 0},
|
||||
{ 36, 1}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 1},
|
||||
{ 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 1}, { 33, 0}, { 33, 0},
|
||||
{ 33, 0}, { 33, 0}, { 33, 0}, { 33, 0}, { 33, 1}, { 32, 0}, { 32, 0}, { 32, 0},
|
||||
{ 32, 0}, { 32, 0}, { 32, 0}, { 32, 0}, { 32, 1}, { 31, 0}, { 31, 0}, { 31, 0},
|
||||
{ 31, 0}, { 31, 0}, { 31, 0}, { 31, 1}, { 30, 0}, { 30, 0}, { 30, 0}, { 30, 0}
|
||||
};
|
||||
|
||||
const uint16_t speed_lookuptable_slow[256][2] PROGMEM = {\
|
||||
{ 62500, 12500}, { 50000, 8334}, { 41666, 5952}, { 35714, 4464}, { 31250, 3473}, { 27777, 2777}, { 25000, 2273}, { 22727, 1894},
|
||||
{ 20833, 1603}, { 19230, 1373}, { 17857, 1191}, { 16666, 1041}, { 15625, 920}, { 14705, 817}, { 13888, 731}, { 13157, 657},
|
||||
{ 12500, 596}, { 11904, 541}, { 11363, 494}, { 10869, 453}, { 10416, 416}, { 10000, 385}, { 9615, 356}, { 9259, 331},
|
||||
{ 8928, 308}, { 8620, 287}, { 8333, 269}, { 8064, 252}, { 7812, 237}, { 7575, 223}, { 7352, 210}, { 7142, 198},
|
||||
{ 6944, 188}, { 6756, 178}, { 6578, 168}, { 6410, 160}, { 6250, 153}, { 6097, 145}, { 5952, 139}, { 5813, 132},
|
||||
{ 5681, 126}, { 5555, 121}, { 5434, 115}, { 5319, 111}, { 5208, 106}, { 5102, 102}, { 5000, 99}, { 4901, 94},
|
||||
{ 4807, 91}, { 4716, 87}, { 4629, 84}, { 4545, 81}, { 4464, 79}, { 4385, 75}, { 4310, 73}, { 4237, 71},
|
||||
{ 4166, 68}, { 4098, 66}, { 4032, 64}, { 3968, 62}, { 3906, 60}, { 3846, 59}, { 3787, 56}, { 3731, 55},
|
||||
{ 3676, 53}, { 3623, 52}, { 3571, 50}, { 3521, 49}, { 3472, 48}, { 3424, 46}, { 3378, 45}, { 3333, 44},
|
||||
{ 3289, 43}, { 3246, 41}, { 3205, 41}, { 3164, 39}, { 3125, 39}, { 3086, 38}, { 3048, 36}, { 3012, 36},
|
||||
{ 2976, 35}, { 2941, 35}, { 2906, 33}, { 2873, 33}, { 2840, 32}, { 2808, 31}, { 2777, 30}, { 2747, 30},
|
||||
{ 2717, 29}, { 2688, 29}, { 2659, 28}, { 2631, 27}, { 2604, 27}, { 2577, 26}, { 2551, 26}, { 2525, 25},
|
||||
{ 2500, 25}, { 2475, 25}, { 2450, 23}, { 2427, 24}, { 2403, 23}, { 2380, 22}, { 2358, 22}, { 2336, 22},
|
||||
{ 2314, 21}, { 2293, 21}, { 2272, 20}, { 2252, 20}, { 2232, 20}, { 2212, 20}, { 2192, 19}, { 2173, 18},
|
||||
{ 2155, 19}, { 2136, 18}, { 2118, 18}, { 2100, 17}, { 2083, 17}, { 2066, 17}, { 2049, 17}, { 2032, 16},
|
||||
{ 2016, 16}, { 2000, 16}, { 1984, 16}, { 1968, 15}, { 1953, 16}, { 1937, 14}, { 1923, 15}, { 1908, 15},
|
||||
{ 1893, 14}, { 1879, 14}, { 1865, 14}, { 1851, 13}, { 1838, 14}, { 1824, 13}, { 1811, 13}, { 1798, 13},
|
||||
{ 1785, 12}, { 1773, 13}, { 1760, 12}, { 1748, 12}, { 1736, 12}, { 1724, 12}, { 1712, 12}, { 1700, 11},
|
||||
{ 1689, 12}, { 1677, 11}, { 1666, 11}, { 1655, 11}, { 1644, 11}, { 1633, 10}, { 1623, 11}, { 1612, 10},
|
||||
{ 1602, 10}, { 1592, 10}, { 1582, 10}, { 1572, 10}, { 1562, 10}, { 1552, 9}, { 1543, 10}, { 1533, 9},
|
||||
{ 1524, 9}, { 1515, 9}, { 1506, 9}, { 1497, 9}, { 1488, 9}, { 1479, 9}, { 1470, 9}, { 1461, 8},
|
||||
{ 1453, 8}, { 1445, 9}, { 1436, 8}, { 1428, 8}, { 1420, 8}, { 1412, 8}, { 1404, 8}, { 1396, 8},
|
||||
{ 1388, 7}, { 1381, 8}, { 1373, 7}, { 1366, 8}, { 1358, 7}, { 1351, 7}, { 1344, 8}, { 1336, 7},
|
||||
{ 1329, 7}, { 1322, 7}, { 1315, 7}, { 1308, 6}, { 1302, 7}, { 1295, 7}, { 1288, 6}, { 1282, 7},
|
||||
{ 1275, 6}, { 1269, 7}, { 1262, 6}, { 1256, 6}, { 1250, 7}, { 1243, 6}, { 1237, 6}, { 1231, 6},
|
||||
{ 1225, 6}, { 1219, 6}, { 1213, 6}, { 1207, 6}, { 1201, 5}, { 1196, 6}, { 1190, 6}, { 1184, 5},
|
||||
{ 1179, 6}, { 1173, 5}, { 1168, 6}, { 1162, 5}, { 1157, 5}, { 1152, 6}, { 1146, 5}, { 1141, 5},
|
||||
{ 1136, 5}, { 1131, 5}, { 1126, 5}, { 1121, 5}, { 1116, 5}, { 1111, 5}, { 1106, 5}, { 1101, 5},
|
||||
{ 1096, 5}, { 1091, 5}, { 1086, 4}, { 1082, 5}, { 1077, 5}, { 1072, 4}, { 1068, 5}, { 1063, 4},
|
||||
{ 1059, 5}, { 1054, 4}, { 1050, 4}, { 1046, 5}, { 1041, 4}, { 1037, 4}, { 1033, 5}, { 1028, 4},
|
||||
{ 1024, 4}, { 1020, 4}, { 1016, 4}, { 1012, 4}, { 1008, 4}, { 1004, 4}, { 1000, 4}, { 996, 4},
|
||||
{ 992, 4}, { 988, 4}, { 984, 4}, { 980, 4}, { 976, 4}, { 972, 4}, { 968, 3}, { 965, 3}
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
const uint16_t speed_lookuptable_fast[256][2] PROGMEM = {
|
||||
{62500, 54055}, {8445, 3917}, {4528, 1434}, {3094, 745}, {2349, 456}, {1893, 307}, {1586, 222}, {1364, 167},
|
||||
{1197, 131}, {1066, 105}, {961, 86}, {875, 72}, {803, 61}, {742, 53}, {689, 45}, {644, 40},
|
||||
{604, 35}, {569, 32}, {537, 28}, {509, 25}, {484, 23}, {461, 21}, {440, 19}, {421, 17},
|
||||
{404, 16}, {388, 15}, {373, 14}, {359, 13}, {346, 12}, {334, 11}, {323, 10}, {313, 10},
|
||||
{303, 9}, {294, 9}, {285, 8}, {277, 7}, {270, 8}, {262, 7}, {255, 6}, {249, 6},
|
||||
{243, 6}, {237, 6}, {231, 5}, {226, 5}, {221, 5}, {216, 5}, {211, 4}, {207, 5},
|
||||
{202, 4}, {198, 4}, {194, 4}, {190, 3}, {187, 4}, {183, 3}, {180, 3}, {177, 4},
|
||||
{173, 3}, {170, 3}, {167, 2}, {165, 3}, {162, 3}, {159, 2}, {157, 3}, {154, 2},
|
||||
{152, 3}, {149, 2}, {147, 2}, {145, 2}, {143, 2}, {141, 2}, {139, 2}, {137, 2},
|
||||
{135, 2}, {133, 2}, {131, 2}, {129, 1}, {128, 2}, {126, 2}, {124, 1}, {123, 2},
|
||||
{121, 1}, {120, 2}, {118, 1}, {117, 1}, {116, 2}, {114, 1}, {113, 1}, {112, 2},
|
||||
{110, 1}, {109, 1}, {108, 1}, {107, 2}, {105, 1}, {104, 1}, {103, 1}, {102, 1},
|
||||
{101, 1}, {100, 1}, {99, 1}, {98, 1}, {97, 1}, {96, 1}, {95, 1}, {94, 1},
|
||||
{93, 1}, {92, 1}, {91, 0}, {91, 1}, {90, 1}, {89, 1}, {88, 1}, {87, 0},
|
||||
{87, 1}, {86, 1}, {85, 1}, {84, 0}, {84, 1}, {83, 1}, {82, 1}, {81, 0},
|
||||
{81, 1}, {80, 1}, {79, 0}, {79, 1}, {78, 0}, {78, 1}, {77, 1}, {76, 0},
|
||||
{76, 1}, {75, 0}, {75, 1}, {74, 1}, {73, 0}, {73, 1}, {72, 0}, {72, 1},
|
||||
{71, 0}, {71, 1}, {70, 0}, {70, 1}, {69, 0}, {69, 1}, {68, 0}, {68, 1},
|
||||
{67, 0}, {67, 1}, {66, 0}, {66, 1}, {65, 0}, {65, 0}, {65, 1}, {64, 0},
|
||||
{64, 1}, {63, 0}, {63, 1}, {62, 0}, {62, 0}, {62, 1}, {61, 0}, {61, 1},
|
||||
{60, 0}, {60, 0}, {60, 1}, {59, 0}, {59, 0}, {59, 1}, {58, 0}, {58, 0},
|
||||
{58, 1}, {57, 0}, {57, 0}, {57, 1}, {56, 0}, {56, 0}, {56, 1}, {55, 0},
|
||||
{55, 0}, {55, 1}, {54, 0}, {54, 0}, {54, 1}, {53, 0}, {53, 0}, {53, 0},
|
||||
{53, 1}, {52, 0}, {52, 0}, {52, 1}, {51, 0}, {51, 0}, {51, 0}, {51, 1},
|
||||
{50, 0}, {50, 0}, {50, 0}, {50, 1}, {49, 0}, {49, 0}, {49, 0}, {49, 1},
|
||||
{48, 0}, {48, 0}, {48, 0}, {48, 1}, {47, 0}, {47, 0}, {47, 0}, {47, 1},
|
||||
{46, 0}, {46, 0}, {46, 0}, {46, 0}, {46, 1}, {45, 0}, {45, 0}, {45, 0},
|
||||
{45, 1}, {44, 0}, {44, 0}, {44, 0}, {44, 0}, {44, 1}, {43, 0}, {43, 0},
|
||||
{43, 0}, {43, 0}, {43, 1}, {42, 0}, {42, 0}, {42, 0}, {42, 0}, {42, 0},
|
||||
{42, 1}, {41, 0}, {41, 0}, {41, 0}, {41, 0}, {41, 0}, {41, 1}, {40, 0},
|
||||
{40, 0}, {40, 0}, {40, 0}, {40, 1}, {39, 0}, {39, 0}, {39, 0}, {39, 0},
|
||||
{39, 0}, {39, 0}, {39, 1}, {38, 0}, {38, 0}, {38, 0}, {38, 0}, {38, 0},
|
||||
};
|
||||
|
||||
const uint16_t speed_lookuptable_slow[256][2] PROGMEM = {
|
||||
{62500, 10417}, {52083, 7441}, {44642, 5580}, {39062, 4340}, {34722, 3472}, {31250, 2841}, {28409, 2368}, {26041, 2003},
|
||||
{24038, 1717}, {22321, 1488}, {20833, 1302}, {19531, 1149}, {18382, 1021}, {17361, 914}, {16447, 822}, {15625, 745},
|
||||
{14880, 676}, {14204, 618}, {13586, 566}, {13020, 520}, {12500, 481}, {12019, 445}, {11574, 414}, {11160, 385},
|
||||
{10775, 359}, {10416, 336}, {10080, 315}, {9765, 296}, {9469, 278}, {9191, 263}, {8928, 248}, {8680, 235},
|
||||
{8445, 222}, {8223, 211}, {8012, 200}, {7812, 191}, {7621, 181}, {7440, 173}, {7267, 165}, {7102, 158},
|
||||
{6944, 151}, {6793, 145}, {6648, 138}, {6510, 133}, {6377, 127}, {6250, 123}, {6127, 118}, {6009, 113},
|
||||
{5896, 109}, {5787, 106}, {5681, 101}, {5580, 98}, {5482, 95}, {5387, 91}, {5296, 88}, {5208, 86},
|
||||
{5122, 82}, {5040, 80}, {4960, 78}, {4882, 75}, {4807, 73}, {4734, 70}, {4664, 69}, {4595, 67},
|
||||
{4528, 64}, {4464, 63}, {4401, 61}, {4340, 60}, {4280, 58}, {4222, 56}, {4166, 55}, {4111, 53},
|
||||
{4058, 52}, {4006, 51}, {3955, 49}, {3906, 48}, {3858, 48}, {3810, 45}, {3765, 45}, {3720, 44},
|
||||
{3676, 43}, {3633, 42}, {3591, 40}, {3551, 40}, {3511, 39}, {3472, 38}, {3434, 38}, {3396, 36},
|
||||
{3360, 36}, {3324, 35}, {3289, 34}, {3255, 34}, {3221, 33}, {3188, 32}, {3156, 31}, {3125, 31},
|
||||
{3094, 31}, {3063, 30}, {3033, 29}, {3004, 28}, {2976, 28}, {2948, 28}, {2920, 27}, {2893, 27},
|
||||
{2866, 26}, {2840, 25}, {2815, 25}, {2790, 25}, {2765, 24}, {2741, 24}, {2717, 24}, {2693, 23},
|
||||
{2670, 22}, {2648, 22}, {2626, 22}, {2604, 22}, {2582, 21}, {2561, 21}, {2540, 20}, {2520, 20},
|
||||
{2500, 20}, {2480, 20}, {2460, 19}, {2441, 19}, {2422, 19}, {2403, 18}, {2385, 18}, {2367, 18},
|
||||
{2349, 17}, {2332, 18}, {2314, 17}, {2297, 16}, {2281, 17}, {2264, 16}, {2248, 16}, {2232, 16},
|
||||
{2216, 16}, {2200, 15}, {2185, 15}, {2170, 15}, {2155, 15}, {2140, 15}, {2125, 14}, {2111, 14},
|
||||
{2097, 14}, {2083, 14}, {2069, 14}, {2055, 13}, {2042, 13}, {2029, 13}, {2016, 13}, {2003, 13},
|
||||
{1990, 13}, {1977, 12}, {1965, 12}, {1953, 13}, {1940, 11}, {1929, 12}, {1917, 12}, {1905, 12},
|
||||
{1893, 11}, {1882, 11}, {1871, 11}, {1860, 11}, {1849, 11}, {1838, 11}, {1827, 11}, {1816, 10},
|
||||
{1806, 11}, {1795, 10}, {1785, 10}, {1775, 10}, {1765, 10}, {1755, 10}, {1745, 9}, {1736, 10},
|
||||
{1726, 9}, {1717, 10}, {1707, 9}, {1698, 9}, {1689, 9}, {1680, 9}, {1671, 9}, {1662, 9},
|
||||
{1653, 9}, {1644, 8}, {1636, 9}, {1627, 8}, {1619, 9}, {1610, 8}, {1602, 8}, {1594, 8},
|
||||
{1586, 8}, {1578, 8}, {1570, 8}, {1562, 8}, {1554, 7}, {1547, 8}, {1539, 8}, {1531, 7},
|
||||
{1524, 8}, {1516, 7}, {1509, 7}, {1502, 7}, {1495, 7}, {1488, 7}, {1481, 7}, {1474, 7},
|
||||
{1467, 7}, {1460, 7}, {1453, 7}, {1446, 6}, {1440, 7}, {1433, 7}, {1426, 6}, {1420, 6},
|
||||
{1414, 7}, {1407, 6}, {1401, 6}, {1395, 7}, {1388, 6}, {1382, 6}, {1376, 6}, {1370, 6},
|
||||
{1364, 6}, {1358, 6}, {1352, 6}, {1346, 5}, {1341, 6}, {1335, 6}, {1329, 5}, {1324, 6},
|
||||
{1318, 5}, {1313, 6}, {1307, 5}, {1302, 6}, {1296, 5}, {1291, 5}, {1286, 6}, {1280, 5},
|
||||
{1275, 5}, {1270, 5}, {1265, 5}, {1260, 5}, {1255, 5}, {1250, 5}, {1245, 5}, {1240, 5},
|
||||
{1235, 5}, {1230, 5}, {1225, 5}, {1220, 5}, {1215, 4}, {1211, 5}, {1206, 5}, {1201, 5},
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
+492
-203
@@ -21,15 +21,12 @@
|
||||
/* The timer calculations of this module informed by the 'RepRap cartesian firmware' by Zack Smith
|
||||
and Philipp Tiefenbacher. */
|
||||
|
||||
#include "stepper.h"
|
||||
#include "Configuration.h"
|
||||
#include "Marlin.h"
|
||||
#include "stepper.h"
|
||||
#include "planner.h"
|
||||
#include "pins.h"
|
||||
#include "fastio.h"
|
||||
#include "temperature.h"
|
||||
#include "ultralcd.h"
|
||||
|
||||
#include "language.h"
|
||||
#include "speed_lookuptable.h"
|
||||
|
||||
|
||||
@@ -40,7 +37,6 @@
|
||||
block_t *current_block; // A pointer to the block currently being traced
|
||||
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//=============================private variables ============================
|
||||
//===========================================================================
|
||||
@@ -52,17 +48,17 @@ static long counter_x, // Counter variables for the bresenham line tracer
|
||||
counter_y,
|
||||
counter_z,
|
||||
counter_e;
|
||||
static unsigned long step_events_completed; // The number of step events executed in the current block
|
||||
volatile static unsigned long step_events_completed; // The number of step events executed in the current block
|
||||
#ifdef ADVANCE
|
||||
static long advance_rate, advance, final_advance = 0;
|
||||
static short old_advance = 0;
|
||||
static long old_advance = 0;
|
||||
#endif
|
||||
static short e_steps;
|
||||
static unsigned char busy = false; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler.
|
||||
static long e_steps[3];
|
||||
static long acceleration_time, deceleration_time;
|
||||
//static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;
|
||||
static unsigned short acc_step_rate; // needed for deccelaration start point
|
||||
static char step_loops;
|
||||
static unsigned short OCR1A_nominal;
|
||||
|
||||
volatile long endstops_trigsteps[3]={0,0,0};
|
||||
volatile long endstops_stepsTotal,endstops_stepsDone;
|
||||
@@ -70,13 +66,23 @@ 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;
|
||||
|
||||
volatile long count_position[NUM_AXIS] = { 0, 0, 0, 0};
|
||||
volatile char count_direction[NUM_AXIS] = { 1, 1, 1, 1};
|
||||
|
||||
//===========================================================================
|
||||
//=============================functions ============================
|
||||
//===========================================================================
|
||||
|
||||
|
||||
#define CHECK_ENDSTOPS if(check_endstops)
|
||||
|
||||
// intRes = intIn1 * intIn2 >> 16
|
||||
// uses:
|
||||
@@ -153,11 +159,12 @@ asm volatile ( \
|
||||
#define ENABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 |= (1<<OCIE1A)
|
||||
#define DISABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 &= ~(1<<OCIE1A)
|
||||
|
||||
|
||||
void checkHitEndstops()
|
||||
{
|
||||
if( endstop_x_hit || endstop_y_hit || endstop_z_hit) {
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPGM("endstops hit: ");
|
||||
SERIAL_ECHOPGM(MSG_ENDSTOPS_HIT);
|
||||
if(endstop_x_hit) {
|
||||
SERIAL_ECHOPAIR(" X:",(float)endstops_trigsteps[X_AXIS]/axis_steps_per_unit[X_AXIS]);
|
||||
}
|
||||
@@ -181,6 +188,11 @@ void endstops_hit_on_purpose()
|
||||
endstop_z_hit=false;
|
||||
}
|
||||
|
||||
void enable_endstops(bool check)
|
||||
{
|
||||
check_endstops = check;
|
||||
}
|
||||
|
||||
// __________________________
|
||||
// /| |\ _________________ ^
|
||||
// / | | \ /| |\ |
|
||||
@@ -199,11 +211,16 @@ void endstops_hit_on_purpose()
|
||||
|
||||
void st_wake_up() {
|
||||
// TCNT1 = 0;
|
||||
if(busy == false)
|
||||
ENABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
}
|
||||
|
||||
inline unsigned short calc_timer(unsigned short step_rate) {
|
||||
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;
|
||||
|
||||
@@ -219,8 +236,8 @@ inline unsigned short calc_timer(unsigned short step_rate) {
|
||||
step_loops = 1;
|
||||
}
|
||||
|
||||
if(step_rate < 32) step_rate = 32;
|
||||
step_rate -= 32; // Correct for minimal speed
|
||||
if(step_rate < (F_CPU/500000)) step_rate = (F_CPU/500000);
|
||||
step_rate -= (F_CPU/500000); // Correct for minimal speed
|
||||
if(step_rate >= (8*256)){ // higher step rate
|
||||
unsigned short table_address = (unsigned short)&speed_lookuptable_fast[(unsigned char)(step_rate>>8)][0];
|
||||
unsigned char tmp_step_rate = (step_rate & 0x00ff);
|
||||
@@ -234,55 +251,70 @@ inline unsigned short calc_timer(unsigned short step_rate) {
|
||||
timer = (unsigned short)pgm_read_word_near(table_address);
|
||||
timer -= (((unsigned short)pgm_read_word_near(table_address+2) * (unsigned char)(step_rate & 0x0007))>>3);
|
||||
}
|
||||
if(timer < 100) { timer = 100; Serial.print("Steprate to high : "); Serial.println(step_rate); }//(20kHz this should never happen)
|
||||
if(timer < 100) { timer = 100; MYSERIAL.print(MSG_STEPPER_TO_HIGH); MYSERIAL.println(step_rate); }//(20kHz this should never happen)
|
||||
return timer;
|
||||
}
|
||||
|
||||
// Initializes the trapezoid generator from the current block. Called whenever a new
|
||||
// block begins.
|
||||
inline void trapezoid_generator_reset() {
|
||||
FORCE_INLINE void trapezoid_generator_reset() {
|
||||
#ifdef ADVANCE
|
||||
advance = current_block->initial_advance;
|
||||
final_advance = current_block->final_advance;
|
||||
// Do E steps + advance steps
|
||||
e_steps[current_block->active_extruder] += ((advance >>8) - old_advance);
|
||||
old_advance = advance >>8;
|
||||
#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;
|
||||
|
||||
// SERIAL_ECHO_START;
|
||||
// SERIAL_ECHOPGM("advance :");
|
||||
// SERIAL_ECHO(current_block->advance/256.0);
|
||||
// SERIAL_ECHOPGM("advance rate :");
|
||||
// SERIAL_ECHO(current_block->advance_rate/256.0);
|
||||
// SERIAL_ECHOPGM("initial advance :");
|
||||
// SERIAL_ECHO(current_block->initial_advance/256.0);
|
||||
// SERIAL_ECHOPGM("final advance :");
|
||||
// SERIAL_ECHOLN(current_block->final_advance/256.0);
|
||||
|
||||
}
|
||||
|
||||
// "The Stepper Driver Interrupt" - This timer interrupt is the workhorse.
|
||||
// It pops blocks from the block_buffer and executes them by pulsing the stepper pins appropriately.
|
||||
ISR(TIMER1_COMPA_vect)
|
||||
{
|
||||
if(busy){
|
||||
SERIAL_ERROR_START
|
||||
SERIAL_ERROR(*(unsigned short *)OCR1A);
|
||||
SERIAL_ERRORLNPGM(" ISR overtaking itself.");
|
||||
return;
|
||||
} // The busy-flag is used to avoid reentering this interrupt
|
||||
|
||||
busy = true;
|
||||
sei(); // Re enable interrupts (normally disabled while inside an interrupt handler)
|
||||
|
||||
{
|
||||
// If there is no current block, attempt to pop one from the buffer
|
||||
if (current_block == NULL) {
|
||||
// Anything in the buffer?
|
||||
current_block = plan_get_current_block();
|
||||
if (current_block != NULL) {
|
||||
current_block->busy = true;
|
||||
trapezoid_generator_reset();
|
||||
counter_x = -(current_block->step_event_count >> 1);
|
||||
counter_y = counter_x;
|
||||
counter_z = counter_x;
|
||||
counter_e = counter_x;
|
||||
step_events_completed = 0;
|
||||
// #ifdef ADVANCE
|
||||
e_steps = 0;
|
||||
step_events_completed = 0;
|
||||
|
||||
#ifdef Z_LATE_ENABLE
|
||||
if(current_block->steps_z > 0) {
|
||||
enable_z();
|
||||
OCR1A = 2000; //1ms wait
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// #ifdef ADVANCE
|
||||
// e_steps[current_block->active_extruder] = 0;
|
||||
// #endif
|
||||
}
|
||||
else {
|
||||
// DISABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
OCR1A=2000; // 1kHz.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,142 +323,266 @@ 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;
|
||||
#if X_MIN_PIN > -1
|
||||
if((READ(X_MIN_PIN) != ENDSTOPS_INVERTING) && (current_block->steps_x > 0)) {
|
||||
endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
|
||||
endstop_x_hit=true;
|
||||
step_events_completed = current_block->step_event_count;
|
||||
}
|
||||
#endif
|
||||
CHECK_ENDSTOPS
|
||||
{
|
||||
#if X_MIN_PIN > -1
|
||||
bool x_min_endstop=(READ(X_MIN_PIN) != X_ENDSTOPS_INVERTING);
|
||||
if(x_min_endstop && old_x_min_endstop && (current_block->steps_x > 0)) {
|
||||
endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
|
||||
endstop_x_hit=true;
|
||||
step_events_completed = current_block->step_event_count;
|
||||
}
|
||||
old_x_min_endstop = x_min_endstop;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else { // +direction
|
||||
WRITE(X_DIR_PIN,!INVERT_X_DIR);
|
||||
count_direction[X_AXIS]=1;
|
||||
#if X_MAX_PIN > -1
|
||||
if((READ(X_MAX_PIN) != ENDSTOPS_INVERTING) && (current_block->steps_x > 0)){
|
||||
endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
|
||||
endstop_x_hit=true;
|
||||
step_events_completed = current_block->step_event_count;
|
||||
}
|
||||
else { // +direction
|
||||
#if !defined COREXY //NOT COREXY
|
||||
WRITE(X_DIR_PIN,!INVERT_X_DIR);
|
||||
#endif
|
||||
|
||||
count_direction[X_AXIS]=1;
|
||||
CHECK_ENDSTOPS
|
||||
{
|
||||
#if X_MAX_PIN > -1
|
||||
bool x_max_endstop=(READ(X_MAX_PIN) != X_ENDSTOPS_INVERTING);
|
||||
if(x_max_endstop && old_x_max_endstop && (current_block->steps_x > 0)){
|
||||
endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
|
||||
endstop_x_hit=true;
|
||||
step_events_completed = current_block->step_event_count;
|
||||
}
|
||||
old_x_max_endstop = x_max_endstop;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if ((out_bits & (1<<Y_AXIS)) != 0) { // -direction
|
||||
WRITE(Y_DIR_PIN,INVERT_Y_DIR);
|
||||
count_direction[Y_AXIS]=-1;
|
||||
#if Y_MIN_PIN > -1
|
||||
if((READ(Y_MIN_PIN) != ENDSTOPS_INVERTING) && (current_block->steps_y > 0)) {
|
||||
endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
|
||||
endstop_y_hit=true;
|
||||
step_events_completed = current_block->step_event_count;
|
||||
}
|
||||
#if !defined COREXY //NOT COREXY
|
||||
WRITE(Y_DIR_PIN,INVERT_Y_DIR);
|
||||
#endif
|
||||
count_direction[Y_AXIS]=-1;
|
||||
CHECK_ENDSTOPS
|
||||
{
|
||||
#if Y_MIN_PIN > -1
|
||||
bool y_min_endstop=(READ(Y_MIN_PIN) != Y_ENDSTOPS_INVERTING);
|
||||
if(y_min_endstop && old_y_min_endstop && (current_block->steps_y > 0)) {
|
||||
endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
|
||||
endstop_y_hit=true;
|
||||
step_events_completed = current_block->step_event_count;
|
||||
}
|
||||
old_y_min_endstop = y_min_endstop;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else { // +direction
|
||||
WRITE(Y_DIR_PIN,!INVERT_Y_DIR);
|
||||
count_direction[Y_AXIS]=1;
|
||||
#if Y_MAX_PIN > -1
|
||||
if((READ(Y_MAX_PIN) != ENDSTOPS_INVERTING) && (current_block->steps_y > 0)){
|
||||
endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
|
||||
endstop_y_hit=true;
|
||||
step_events_completed = current_block->step_event_count;
|
||||
}
|
||||
#if !defined COREXY //NOT COREXY
|
||||
WRITE(Y_DIR_PIN,!INVERT_Y_DIR);
|
||||
#endif
|
||||
count_direction[Y_AXIS]=1;
|
||||
CHECK_ENDSTOPS
|
||||
{
|
||||
#if Y_MAX_PIN > -1
|
||||
bool y_max_endstop=(READ(Y_MAX_PIN) != Y_ENDSTOPS_INVERTING);
|
||||
if(y_max_endstop && old_y_max_endstop && (current_block->steps_y > 0)){
|
||||
endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
|
||||
endstop_y_hit=true;
|
||||
step_events_completed = current_block->step_event_count;
|
||||
}
|
||||
old_y_max_endstop = y_max_endstop;
|
||||
#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);
|
||||
count_direction[Z_AXIS]=-1;
|
||||
#if Z_MIN_PIN > -1
|
||||
if((READ(Z_MIN_PIN) != ENDSTOPS_INVERTING) && (current_block->steps_z > 0)) {
|
||||
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
|
||||
endstop_z_hit=true;
|
||||
step_events_completed = current_block->step_event_count;
|
||||
}
|
||||
|
||||
#ifdef Z_DUAL_STEPPER_DRIVERS
|
||||
WRITE(Z2_DIR_PIN,INVERT_Z_DIR);
|
||||
#endif
|
||||
|
||||
count_direction[Z_AXIS]=-1;
|
||||
CHECK_ENDSTOPS
|
||||
{
|
||||
#if Z_MIN_PIN > -1
|
||||
bool z_min_endstop=(READ(Z_MIN_PIN) != Z_ENDSTOPS_INVERTING);
|
||||
if(z_min_endstop && old_z_min_endstop && (current_block->steps_z > 0)) {
|
||||
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
|
||||
endstop_z_hit=true;
|
||||
step_events_completed = current_block->step_event_count;
|
||||
}
|
||||
old_z_min_endstop = z_min_endstop;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else { // +direction
|
||||
WRITE(Z_DIR_PIN,!INVERT_Z_DIR);
|
||||
count_direction[Z_AXIS]=1;
|
||||
#if Z_MAX_PIN > -1
|
||||
if((READ(Z_MAX_PIN) != ENDSTOPS_INVERTING) && (current_block->steps_z > 0)){
|
||||
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
|
||||
endstop_z_hit=true;
|
||||
step_events_completed = current_block->step_event_count;
|
||||
}
|
||||
|
||||
#ifdef Z_DUAL_STEPPER_DRIVERS
|
||||
WRITE(Z2_DIR_PIN,!INVERT_Z_DIR);
|
||||
#endif
|
||||
|
||||
count_direction[Z_AXIS]=1;
|
||||
CHECK_ENDSTOPS
|
||||
{
|
||||
#if Z_MAX_PIN > -1
|
||||
bool z_max_endstop=(READ(Z_MAX_PIN) != Z_ENDSTOPS_INVERTING);
|
||||
if(z_max_endstop && old_z_max_endstop && (current_block->steps_z > 0)) {
|
||||
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
|
||||
endstop_z_hit=true;
|
||||
step_events_completed = current_block->step_event_count;
|
||||
}
|
||||
old_z_max_endstop = z_max_endstop;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef ADVANCE
|
||||
if ((out_bits & (1<<E_AXIS)) != 0) { // -direction
|
||||
WRITE(E_DIR_PIN,INVERT_E_DIR);
|
||||
REV_E_DIR();
|
||||
count_direction[E_AXIS]=-1;
|
||||
}
|
||||
else { // +direction
|
||||
WRITE(E_DIR_PIN,!INVERT_E_DIR);
|
||||
count_direction[E_AXIS]=-1;
|
||||
NORM_E_DIR();
|
||||
count_direction[E_AXIS]=1;
|
||||
}
|
||||
#endif //!ADVANCE
|
||||
|
||||
|
||||
|
||||
for(int8_t i=0; i < step_loops; i++) { // Take multiple steps per interrupt (For high speed moves)
|
||||
/*
|
||||
#if MOTHERBOARD != 8 // !teensylu
|
||||
MSerial.checkRx(); // Check for serial chars.
|
||||
#endif
|
||||
|
||||
#ifdef ADVANCE
|
||||
counter_e += current_block->steps_e;
|
||||
if (counter_e > 0) {
|
||||
counter_e -= current_block->step_event_count;
|
||||
if ((out_bits & (1<<E_AXIS)) != 0) { // - direction
|
||||
CRITICAL_SECTION_START;
|
||||
e_steps--;
|
||||
CRITICAL_SECTION_END;
|
||||
e_steps[current_block->active_extruder]--;
|
||||
}
|
||||
else {
|
||||
CRITICAL_SECTION_START;
|
||||
e_steps++;
|
||||
CRITICAL_SECTION_END;
|
||||
e_steps[current_block->active_extruder]++;
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
// Do E steps + advance steps
|
||||
CRITICAL_SECTION_START;
|
||||
e_steps += ((advance >> 16) - old_advance);
|
||||
CRITICAL_SECTION_END;
|
||||
old_advance = advance >> 16;
|
||||
*/
|
||||
#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;
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
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_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_PIN, HIGH);
|
||||
WRITE_E_STEP(!INVERT_E_STEP_PIN);
|
||||
counter_e -= current_block->step_event_count;
|
||||
WRITE(E_STEP_PIN, LOW);
|
||||
count_position[E_AXIS]+=count_direction[E_AXIS];
|
||||
WRITE_E_STEP(INVERT_E_STEP_PIN);
|
||||
}
|
||||
#endif //!ADVANCE
|
||||
step_events_completed += 1;
|
||||
@@ -435,7 +591,8 @@ ISR(TIMER1_COMPA_vect)
|
||||
// Calculare new timer value
|
||||
unsigned short timer;
|
||||
unsigned short step_rate;
|
||||
if (step_events_completed <= current_block->accelerate_until) {
|
||||
if (step_events_completed <= (unsigned long int)current_block->accelerate_until) {
|
||||
|
||||
MultiU24X24toH16(acc_step_rate, acceleration_time, current_block->acceleration_rate);
|
||||
acc_step_rate += current_block->initial_rate;
|
||||
|
||||
@@ -445,13 +602,20 @@ ISR(TIMER1_COMPA_vect)
|
||||
|
||||
// step_rate to timer interval
|
||||
timer = calc_timer(acc_step_rate);
|
||||
#ifdef ADVANCE
|
||||
advance += advance_rate;
|
||||
#endif
|
||||
acceleration_time += timer;
|
||||
OCR1A = timer;
|
||||
acceleration_time += timer;
|
||||
#ifdef ADVANCE
|
||||
for(int8_t i=0; i < step_loops; i++) {
|
||||
advance += advance_rate;
|
||||
}
|
||||
//if(advance > current_block->advance) advance = current_block->advance;
|
||||
// Do E steps + advance steps
|
||||
e_steps[current_block->active_extruder] += ((advance >>8) - old_advance);
|
||||
old_advance = advance >>8;
|
||||
|
||||
#endif
|
||||
}
|
||||
else if (step_events_completed > current_block->decelerate_after) {
|
||||
else if (step_events_completed > (unsigned long int)current_block->decelerate_after) {
|
||||
MultiU24X24toH16(step_rate, deceleration_time, current_block->acceleration_rate);
|
||||
|
||||
if(step_rate > acc_step_rate) { // Check step_rate stays positive
|
||||
@@ -467,27 +631,28 @@ ISR(TIMER1_COMPA_vect)
|
||||
|
||||
// step_rate to timer interval
|
||||
timer = calc_timer(step_rate);
|
||||
#ifdef ADVANCE
|
||||
advance -= advance_rate;
|
||||
if(advance < final_advance)
|
||||
advance = final_advance;
|
||||
#endif //ADVANCE
|
||||
deceleration_time += timer;
|
||||
OCR1A = timer;
|
||||
deceleration_time += timer;
|
||||
#ifdef ADVANCE
|
||||
for(int8_t i=0; i < step_loops; i++) {
|
||||
advance -= advance_rate;
|
||||
}
|
||||
if(advance < final_advance) advance = final_advance;
|
||||
// Do E steps + advance steps
|
||||
e_steps[current_block->active_extruder] += ((advance >>8) - old_advance);
|
||||
old_advance = advance >>8;
|
||||
#endif //ADVANCE
|
||||
}
|
||||
else {
|
||||
timer = calc_timer(current_block->nominal_rate);
|
||||
OCR1A = timer;
|
||||
OCR1A = OCR1A_nominal;
|
||||
}
|
||||
|
||||
|
||||
// If current block is finished, reset pointer
|
||||
if (step_events_completed >= current_block->step_event_count) {
|
||||
current_block = NULL;
|
||||
plan_discard_current_block();
|
||||
}
|
||||
}
|
||||
cli(); // disable interrupts
|
||||
busy=false;
|
||||
}
|
||||
|
||||
#ifdef ADVANCE
|
||||
@@ -496,28 +661,60 @@ ISR(TIMER1_COMPA_vect)
|
||||
// Timer 0 is shared with millies
|
||||
ISR(TIMER0_COMPA_vect)
|
||||
{
|
||||
// Critical section needed because Timer 1 interrupt has higher priority.
|
||||
// The pin set functions are placed on trategic position to comply with the stepper driver timing.
|
||||
WRITE(E_STEP_PIN, LOW);
|
||||
// Set E direction (Depends on E direction + advance)
|
||||
if (e_steps < 0) {
|
||||
WRITE(E_DIR_PIN,INVERT_E_DIR);
|
||||
e_steps++;
|
||||
WRITE(E_STEP_PIN, HIGH);
|
||||
}
|
||||
if (e_steps > 0) {
|
||||
WRITE(E_DIR_PIN,!INVERT_E_DIR);
|
||||
e_steps--;
|
||||
WRITE(E_STEP_PIN, HIGH);
|
||||
}
|
||||
old_OCR0A += 25; // 10kHz interrupt
|
||||
old_OCR0A += 52; // ~10kHz interrupt (250000 / 26 = 9615kHz)
|
||||
OCR0A = old_OCR0A;
|
||||
// Set E direction (Depends on E direction + advance)
|
||||
for(unsigned char i=0; i<4;i++) {
|
||||
if (e_steps[0] != 0) {
|
||||
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, !INVERT_E_STEP_PIN);
|
||||
}
|
||||
else if (e_steps[0] > 0) {
|
||||
WRITE(E0_DIR_PIN, !INVERT_E0_DIR);
|
||||
e_steps[0]--;
|
||||
WRITE(E0_STEP_PIN, !INVERT_E_STEP_PIN);
|
||||
}
|
||||
}
|
||||
#if EXTRUDERS > 1
|
||||
if (e_steps[1] != 0) {
|
||||
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, !INVERT_E_STEP_PIN);
|
||||
}
|
||||
else if (e_steps[1] > 0) {
|
||||
WRITE(E1_DIR_PIN, !INVERT_E1_DIR);
|
||||
e_steps[1]--;
|
||||
WRITE(E1_STEP_PIN, !INVERT_E_STEP_PIN);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if EXTRUDERS > 2
|
||||
if (e_steps[2] != 0) {
|
||||
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, !INVERT_E_STEP_PIN);
|
||||
}
|
||||
else if (e_steps[2] > 0) {
|
||||
WRITE(E2_DIR_PIN, !INVERT_E2_DIR);
|
||||
e_steps[2]--;
|
||||
WRITE(E2_STEP_PIN, !INVERT_E_STEP_PIN);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif // ADVANCE
|
||||
|
||||
void st_init()
|
||||
{
|
||||
//Initialize Dir Pins
|
||||
//Initialize Dir Pins
|
||||
#if X_DIR_PIN > -1
|
||||
SET_OUTPUT(X_DIR_PIN);
|
||||
#endif
|
||||
@@ -526,9 +723,19 @@ 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 E_DIR_PIN > -1
|
||||
SET_OUTPUT(E_DIR_PIN);
|
||||
#if E0_DIR_PIN > -1
|
||||
SET_OUTPUT(E0_DIR_PIN);
|
||||
#endif
|
||||
#if defined(E1_DIR_PIN) && (E1_DIR_PIN > -1)
|
||||
SET_OUTPUT(E1_DIR_PIN);
|
||||
#endif
|
||||
#if defined(E2_DIR_PIN) && (E2_DIR_PIN > -1)
|
||||
SET_OUTPUT(E2_DIR_PIN);
|
||||
#endif
|
||||
|
||||
//Initialize Enable Pins - steppers default to disabled.
|
||||
@@ -544,74 +751,112 @@ 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 (E_ENABLE_PIN > -1)
|
||||
SET_OUTPUT(E_ENABLE_PIN);
|
||||
if(!E_ENABLE_ON) WRITE(E_ENABLE_PIN,HIGH);
|
||||
#if (E0_ENABLE_PIN > -1)
|
||||
SET_OUTPUT(E0_ENABLE_PIN);
|
||||
if(!E_ENABLE_ON) WRITE(E0_ENABLE_PIN,HIGH);
|
||||
#endif
|
||||
#if defined(E1_ENABLE_PIN) && (E1_ENABLE_PIN > -1)
|
||||
SET_OUTPUT(E1_ENABLE_PIN);
|
||||
if(!E_ENABLE_ON) WRITE(E1_ENABLE_PIN,HIGH);
|
||||
#endif
|
||||
#if defined(E2_ENABLE_PIN) && (E2_ENABLE_PIN > -1)
|
||||
SET_OUTPUT(E2_ENABLE_PIN);
|
||||
if(!E_ENABLE_ON) WRITE(E2_ENABLE_PIN,HIGH);
|
||||
#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);
|
||||
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);
|
||||
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);
|
||||
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 (E_STEP_PIN > -1)
|
||||
SET_OUTPUT(E_STEP_PIN);
|
||||
#if (E0_STEP_PIN > -1)
|
||||
SET_OUTPUT(E0_STEP_PIN);
|
||||
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);
|
||||
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);
|
||||
WRITE(E2_STEP_PIN,INVERT_E_STEP_PIN);
|
||||
if(!E_ENABLE_ON) WRITE(E2_ENABLE_PIN,HIGH);
|
||||
#endif
|
||||
|
||||
#ifdef CONTROLLERFAN_PIN
|
||||
SET_OUTPUT(CONTROLLERFAN_PIN); //Set pin used for driver cooling fan
|
||||
#endif
|
||||
|
||||
// waveform generation = 0100 = CTC
|
||||
TCCR1B &= ~(1<<WGM13);
|
||||
TCCR1B |= (1<<WGM12);
|
||||
@@ -621,27 +866,42 @@ void st_init()
|
||||
// output mode = 00 (disconnected)
|
||||
TCCR1A &= ~(3<<COM1A0);
|
||||
TCCR1A &= ~(3<<COM1B0);
|
||||
TCCR1B = (TCCR1B & ~(0x07<<CS10)) | (2<<CS10); // 2MHz timer
|
||||
|
||||
// Set the timer pre-scaler
|
||||
// Generally we use a divider of 8, resulting in a 2MHz timer
|
||||
// frequency on a 16MHz MCU. If you are going to change this, be
|
||||
// sure to regenerate speed_lookuptable.h with
|
||||
// create_speed_lookuptable.py
|
||||
TCCR1B = (TCCR1B & ~(0x07<<CS10)) | (2<<CS10);
|
||||
|
||||
OCR1A = 0x4000;
|
||||
TCNT1 = 0;
|
||||
ENABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
|
||||
#ifdef ADVANCE
|
||||
e_steps = 0;
|
||||
#if defined(TCCR0A) && defined(WGM01)
|
||||
TCCR0A &= ~(1<<WGM01);
|
||||
TCCR0A &= ~(1<<WGM00);
|
||||
#endif
|
||||
e_steps[0] = 0;
|
||||
e_steps[1] = 0;
|
||||
e_steps[2] = 0;
|
||||
TIMSK0 |= (1<<OCIE0A);
|
||||
#endif //ADVANCE
|
||||
|
||||
enable_endstops(true); // Start with endstops active. After homing they can be disabled
|
||||
sei();
|
||||
}
|
||||
|
||||
|
||||
// Block until all buffered steps are executed
|
||||
void st_synchronize()
|
||||
{
|
||||
while(plan_get_current_block()) {
|
||||
while( blocks_queued()) {
|
||||
manage_heater();
|
||||
manage_inactivity(1);
|
||||
manage_inactivity();
|
||||
LCD_STATUS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void st_set_position(const long &x, const long &y, const long &z, const long &e)
|
||||
@@ -654,7 +914,14 @@ void st_set_position(const long &x, const long &y, const long &z, const long &e)
|
||||
CRITICAL_SECTION_END;
|
||||
}
|
||||
|
||||
long st_get_position(char axis)
|
||||
void st_set_e_position(const long &e)
|
||||
{
|
||||
CRITICAL_SECTION_START;
|
||||
count_position[E_AXIS] = e;
|
||||
CRITICAL_SECTION_END;
|
||||
}
|
||||
|
||||
long st_get_position(uint8_t axis)
|
||||
{
|
||||
long count_pos;
|
||||
CRITICAL_SECTION_START;
|
||||
@@ -662,3 +929,25 @@ long st_get_position(char axis)
|
||||
CRITICAL_SECTION_END;
|
||||
return count_pos;
|
||||
}
|
||||
|
||||
void finishAndDisableSteppers()
|
||||
{
|
||||
st_synchronize();
|
||||
LCD_MESSAGEPGM(MSG_STEPPER_RELEASED);
|
||||
disable_x();
|
||||
disable_y();
|
||||
disable_z();
|
||||
disable_e0();
|
||||
disable_e1();
|
||||
disable_e2();
|
||||
}
|
||||
|
||||
void quickStop()
|
||||
{
|
||||
DISABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
while(blocks_queued())
|
||||
plan_discard_current_block();
|
||||
current_block = NULL;
|
||||
ENABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
}
|
||||
|
||||
|
||||
+23
-3
@@ -23,6 +23,21 @@
|
||||
|
||||
#include "planner.h"
|
||||
|
||||
#if EXTRUDERS > 2
|
||||
#define WRITE_E_STEP(v) { if(current_block->active_extruder == 2) { WRITE(E2_STEP_PIN, v); } else { if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }}}
|
||||
#define NORM_E_DIR() { if(current_block->active_extruder == 2) { WRITE(!E2_DIR_PIN, INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { WRITE(!E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }}}
|
||||
#define REV_E_DIR() { if(current_block->active_extruder == 2) { WRITE(E2_DIR_PIN, INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }}}
|
||||
#elif EXTRUDERS > 1
|
||||
#define WRITE_E_STEP(v) { if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }}
|
||||
#define NORM_E_DIR() { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }}
|
||||
#define REV_E_DIR() { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }}
|
||||
#else
|
||||
#define WRITE_E_STEP(v) WRITE(E0_STEP_PIN, v)
|
||||
#define NORM_E_DIR() WRITE(E0_DIR_PIN, !INVERT_E0_DIR)
|
||||
#define REV_E_DIR() WRITE(E0_DIR_PIN, INVERT_E0_DIR)
|
||||
#endif
|
||||
|
||||
|
||||
// Initialize and start the stepper motor subsystem
|
||||
void st_init();
|
||||
|
||||
@@ -31,9 +46,10 @@ void st_synchronize();
|
||||
|
||||
// Set current position in steps
|
||||
void st_set_position(const long &x, const long &y, const long &z, const long &e);
|
||||
void st_set_e_position(const long &e);
|
||||
|
||||
// Get current position in steps
|
||||
long st_get_position(char axis);
|
||||
long st_get_position(uint8_t axis);
|
||||
|
||||
// The stepper subsystem goes to sleep when it runs out of things to execute. Call this
|
||||
// to notify the subsystem that it is time to go to work.
|
||||
@@ -43,9 +59,13 @@ void st_wake_up();
|
||||
void checkHitEndstops(); //call from somwhere to create an serial error message with the locations the endstops where hit, in case they were triggered
|
||||
void endstops_hit_on_purpose(); //avoid creation of the message, i.e. after homeing and before a routine call of checkHitEndstops();
|
||||
|
||||
void enable_endstops(bool check); // Enable/disable endstop checking
|
||||
|
||||
void checkStepperErrors(); //Print errors detected by the stepper
|
||||
|
||||
void finishAndDisableSteppers();
|
||||
|
||||
extern block_t *current_block; // A pointer to the block currently being traced
|
||||
|
||||
|
||||
#endif
|
||||
void quickStop();
|
||||
#endif
|
||||
|
||||
+648
-252
File diff suppressed because it is too large
Load Diff
+168
-92
@@ -1,93 +1,169 @@
|
||||
/*
|
||||
temperature.h - temperature controller
|
||||
Part of Marlin
|
||||
|
||||
Copyright (c) 2011 Erik van der Zalm
|
||||
|
||||
Grbl is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Grbl is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef temperature_h
|
||||
#define temperature_h
|
||||
|
||||
#include "Marlin.h"
|
||||
#include "fastio.h"
|
||||
#ifdef PID_ADD_EXTRUSION_RATE
|
||||
#include "stepper.h"
|
||||
#endif
|
||||
|
||||
// public functions
|
||||
void tp_init(); //initialise the heating
|
||||
void manage_heater(); //it is critical that this is called periodically.
|
||||
|
||||
|
||||
enum TempSensor {TEMPSENSOR_HOTEND_0=0,TEMPSENSOR_BED=1, TEMPSENSOR_HOTEND_1=2};
|
||||
|
||||
//low leven conversion routines
|
||||
// do not use this routines and variables outsie of temperature.cpp
|
||||
int temp2analog(int celsius);
|
||||
int temp2analogBed(int celsius);
|
||||
float analog2temp(int raw);
|
||||
float analog2tempBed(int raw);
|
||||
extern int target_raw[3];
|
||||
extern int current_raw[3];
|
||||
extern float Kp,Ki,Kd,Kc;
|
||||
|
||||
#ifdef PIDTEMP
|
||||
extern float pid_setpoint ;
|
||||
#endif
|
||||
|
||||
#ifdef WATCHPERIOD
|
||||
extern int watch_raw[3] ;
|
||||
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
|
||||
|
||||
inline float degHotend0(){ return analog2temp(current_raw[TEMPSENSOR_HOTEND_0]);};
|
||||
inline float degHotend1(){ return analog2temp(current_raw[TEMPSENSOR_HOTEND_1]);};
|
||||
inline float degBed() { return analog2tempBed(current_raw[TEMPSENSOR_BED]);};
|
||||
|
||||
inline float degTargetHotend0() { return analog2temp(target_raw[TEMPSENSOR_HOTEND_0]);};
|
||||
inline float degTargetHotend1() { return analog2temp(target_raw[TEMPSENSOR_HOTEND_1]);};
|
||||
inline float degTargetBed() { return analog2tempBed(target_raw[TEMPSENSOR_BED]);};
|
||||
|
||||
inline void setTargetHotend0(const float &celsius)
|
||||
{
|
||||
target_raw[TEMPSENSOR_HOTEND_0]=temp2analog(celsius);
|
||||
#ifdef PIDTEMP
|
||||
pid_setpoint = celsius;
|
||||
#endif //PIDTEMP
|
||||
};
|
||||
inline void setTargetHotend1(const float &celsius) { target_raw[TEMPSENSOR_HOTEND_1]=temp2analog(celsius);};
|
||||
inline void setTargetBed(const float &celsius) { target_raw[TEMPSENSOR_BED ]=temp2analogBed(celsius);};
|
||||
|
||||
inline bool isHeatingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] > current_raw[TEMPSENSOR_HOTEND_0];};
|
||||
inline bool isHeatingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] > current_raw[TEMPSENSOR_HOTEND_1];};
|
||||
inline bool isHeatingBed() {return target_raw[TEMPSENSOR_BED] > current_raw[TEMPSENSOR_BED];};
|
||||
|
||||
inline bool isCoolingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] < current_raw[TEMPSENSOR_HOTEND_0];};
|
||||
inline bool isCoolingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] < current_raw[TEMPSENSOR_HOTEND_1];};
|
||||
inline bool isCoolingBed() {return target_raw[TEMPSENSOR_BED] < current_raw[TEMPSENSOR_BED];};
|
||||
|
||||
void disable_heater();
|
||||
void setWatch();
|
||||
void updatePID();
|
||||
|
||||
#endif
|
||||
/*
|
||||
temperature.h - temperature controller
|
||||
Part of Marlin
|
||||
|
||||
Copyright (c) 2011 Erik van der Zalm
|
||||
|
||||
Grbl is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Grbl is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef temperature_h
|
||||
#define temperature_h
|
||||
|
||||
#include "Marlin.h"
|
||||
#include "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;
|
||||
|
||||
#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)
|
||||
#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)
|
||||
#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;
|
||||
if(degTargetHotend(active_extruder)>autotemp_min)
|
||||
setTargetHotend(0,active_extruder);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void PID_autotune(float temp);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+275
-180
@@ -1,14 +1,13 @@
|
||||
#ifndef THERMISTORTABLES_H_
|
||||
#define THERMISTORTABLES_H_
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
#include "Marlin.h"
|
||||
|
||||
#define OVERSAMPLENR 16
|
||||
|
||||
#if (THERMISTORHEATER_0 == 1) || (THERMISTORHEATER_1 == 1) || (THERMISTORBED == 1) //100k bed thermistor
|
||||
#if (THERMISTORHEATER_0 == 1) || (THERMISTORHEATER_1 == 1) || (THERMISTORHEATER_2 == 1) || (THERMISTORBED == 1) //100k bed thermistor
|
||||
|
||||
#define NUMTEMPS_1 61
|
||||
const short temptable_1[NUMTEMPS_1][2] PROGMEM = {
|
||||
const short temptable_1[][2] PROGMEM = {
|
||||
{ 23*OVERSAMPLENR , 300 },
|
||||
{ 25*OVERSAMPLENR , 295 },
|
||||
{ 27*OVERSAMPLENR , 290 },
|
||||
@@ -72,36 +71,48 @@ const short temptable_1[NUMTEMPS_1][2] PROGMEM = {
|
||||
{ 1008*OVERSAMPLENR , 0 } //safety
|
||||
};
|
||||
#endif
|
||||
#if (THERMISTORHEATER_0 == 2) || (THERMISTORHEATER_1 == 2) || (THERMISTORBED == 2) //200k bed thermistor
|
||||
#define NUMTEMPS_2 21
|
||||
const short temptable_2[NUMTEMPS_2][2] PROGMEM = {
|
||||
#if (THERMISTORHEATER_0 == 2) || (THERMISTORHEATER_1 == 2) || (THERMISTORHEATER_2 == 2) || (THERMISTORBED == 2) //200k bed thermistor
|
||||
const short temptable_2[][2] PROGMEM = {
|
||||
//200k ATC Semitec 204GT-2
|
||||
//Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf
|
||||
// Calculated using 4.7kohm pullup, voltage divider math, and manufacturer provided temp/resistance
|
||||
{1*OVERSAMPLENR, 848},
|
||||
{54*OVERSAMPLENR, 275},
|
||||
{107*OVERSAMPLENR, 228},
|
||||
{160*OVERSAMPLENR, 202},
|
||||
{213*OVERSAMPLENR, 185},
|
||||
{266*OVERSAMPLENR, 171},
|
||||
{319*OVERSAMPLENR, 160},
|
||||
{372*OVERSAMPLENR, 150},
|
||||
{425*OVERSAMPLENR, 141},
|
||||
{478*OVERSAMPLENR, 133},
|
||||
{531*OVERSAMPLENR, 125},
|
||||
{584*OVERSAMPLENR, 118},
|
||||
{637*OVERSAMPLENR, 110},
|
||||
{690*OVERSAMPLENR, 103},
|
||||
{743*OVERSAMPLENR, 95},
|
||||
{796*OVERSAMPLENR, 86},
|
||||
{849*OVERSAMPLENR, 77},
|
||||
{902*OVERSAMPLENR, 65},
|
||||
{955*OVERSAMPLENR, 49},
|
||||
{1008*OVERSAMPLENR, 17},
|
||||
{1020*OVERSAMPLENR, 0} //safety
|
||||
{30*OVERSAMPLENR, 300}, //top rating 300C
|
||||
{34*OVERSAMPLENR, 290},
|
||||
{39*OVERSAMPLENR, 280},
|
||||
{46*OVERSAMPLENR, 270},
|
||||
{53*OVERSAMPLENR, 260},
|
||||
{63*OVERSAMPLENR, 250},
|
||||
{74*OVERSAMPLENR, 240},
|
||||
{87*OVERSAMPLENR, 230},
|
||||
{104*OVERSAMPLENR, 220},
|
||||
{124*OVERSAMPLENR, 210},
|
||||
{148*OVERSAMPLENR, 200},
|
||||
{176*OVERSAMPLENR, 190},
|
||||
{211*OVERSAMPLENR, 180},
|
||||
{252*OVERSAMPLENR, 170},
|
||||
{301*OVERSAMPLENR, 160},
|
||||
{357*OVERSAMPLENR, 150},
|
||||
{420*OVERSAMPLENR, 140},
|
||||
{489*OVERSAMPLENR, 130},
|
||||
{562*OVERSAMPLENR, 120},
|
||||
{636*OVERSAMPLENR, 110},
|
||||
{708*OVERSAMPLENR, 100},
|
||||
{775*OVERSAMPLENR, 90},
|
||||
{835*OVERSAMPLENR, 80},
|
||||
{884*OVERSAMPLENR, 70},
|
||||
{924*OVERSAMPLENR, 60},
|
||||
{955*OVERSAMPLENR, 50},
|
||||
{977*OVERSAMPLENR, 40},
|
||||
{993*OVERSAMPLENR, 30},
|
||||
{1004*OVERSAMPLENR, 20},
|
||||
{1012*OVERSAMPLENR, 10},
|
||||
{1016*OVERSAMPLENR, 0},
|
||||
};
|
||||
|
||||
#endif
|
||||
#if (THERMISTORHEATER_0 == 3) || (THERMISTORHEATER_1 == 3) || (THERMISTORBED == 3) //mendel-parts
|
||||
#define NUMTEMPS_3 28
|
||||
const short temptable_3[NUMTEMPS_3][2] PROGMEM = {
|
||||
#if (THERMISTORHEATER_0 == 3) || (THERMISTORHEATER_1 == 3) || (THERMISTORHEATER_2 == 3) || (THERMISTORBED == 3) //mendel-parts
|
||||
const short temptable_3[][2] PROGMEM = {
|
||||
{1*OVERSAMPLENR,864},
|
||||
{21*OVERSAMPLENR,300},
|
||||
{25*OVERSAMPLENR,290},
|
||||
@@ -133,10 +144,8 @@ const short temptable_3[NUMTEMPS_3][2] PROGMEM = {
|
||||
};
|
||||
|
||||
#endif
|
||||
#if (THERMISTORHEATER_0 == 4) || (THERMISTORHEATER_1 == 4) || (THERMISTORBED == 4) //10k thermistor
|
||||
|
||||
#define NUMTEMPS_4 20
|
||||
const short temptable_4[NUMTEMPS_4][2] PROGMEM = {
|
||||
#if (THERMISTORHEATER_0 == 4) || (THERMISTORHEATER_1 == 4) || (THERMISTORHEATER_2 == 4) || (THERMISTORBED == 4) //10k thermistor
|
||||
const short temptable_4[][2] PROGMEM = {
|
||||
{1*OVERSAMPLENR, 430},
|
||||
{54*OVERSAMPLENR, 137},
|
||||
{107*OVERSAMPLENR, 107},
|
||||
@@ -160,78 +169,50 @@ const short temptable_4[NUMTEMPS_4][2] PROGMEM = {
|
||||
};
|
||||
#endif
|
||||
|
||||
#if (THERMISTORHEATER_0 == 5) || (THERMISTORHEATER_1 == 5) || (THERMISTORBED == 5) //100k ParCan thermistor (104GT-2)
|
||||
|
||||
#define NUMTEMPS_5 61
|
||||
const short temptable_5[NUMTEMPS_5][2] PROGMEM = {
|
||||
{1*OVERSAMPLENR, 713},
|
||||
{18*OVERSAMPLENR, 316},
|
||||
{35*OVERSAMPLENR, 266},
|
||||
{52*OVERSAMPLENR, 239},
|
||||
{69*OVERSAMPLENR, 221},
|
||||
{86*OVERSAMPLENR, 208},
|
||||
{103*OVERSAMPLENR, 197},
|
||||
{120*OVERSAMPLENR, 188},
|
||||
{137*OVERSAMPLENR, 181},
|
||||
{154*OVERSAMPLENR, 174},
|
||||
{171*OVERSAMPLENR, 169},
|
||||
{188*OVERSAMPLENR, 163},
|
||||
{205*OVERSAMPLENR, 159},
|
||||
{222*OVERSAMPLENR, 154},
|
||||
{239*OVERSAMPLENR, 150},
|
||||
{256*OVERSAMPLENR, 147},
|
||||
{273*OVERSAMPLENR, 143},
|
||||
{290*OVERSAMPLENR, 140},
|
||||
{307*OVERSAMPLENR, 136},
|
||||
{324*OVERSAMPLENR, 133},
|
||||
{341*OVERSAMPLENR, 130},
|
||||
{358*OVERSAMPLENR, 128},
|
||||
{375*OVERSAMPLENR, 125},
|
||||
{392*OVERSAMPLENR, 122},
|
||||
{409*OVERSAMPLENR, 120},
|
||||
{426*OVERSAMPLENR, 117},
|
||||
{443*OVERSAMPLENR, 115},
|
||||
{460*OVERSAMPLENR, 112},
|
||||
{477*OVERSAMPLENR, 110},
|
||||
{494*OVERSAMPLENR, 108},
|
||||
{511*OVERSAMPLENR, 106},
|
||||
{528*OVERSAMPLENR, 103},
|
||||
{545*OVERSAMPLENR, 101},
|
||||
{562*OVERSAMPLENR, 99},
|
||||
{579*OVERSAMPLENR, 97},
|
||||
{596*OVERSAMPLENR, 95},
|
||||
{613*OVERSAMPLENR, 92},
|
||||
{630*OVERSAMPLENR, 90},
|
||||
{647*OVERSAMPLENR, 88},
|
||||
{664*OVERSAMPLENR, 86},
|
||||
{681*OVERSAMPLENR, 84},
|
||||
{698*OVERSAMPLENR, 81},
|
||||
{715*OVERSAMPLENR, 79},
|
||||
{732*OVERSAMPLENR, 77},
|
||||
{749*OVERSAMPLENR, 75},
|
||||
{766*OVERSAMPLENR, 72},
|
||||
{783*OVERSAMPLENR, 70},
|
||||
{800*OVERSAMPLENR, 67},
|
||||
{817*OVERSAMPLENR, 64},
|
||||
{834*OVERSAMPLENR, 61},
|
||||
{851*OVERSAMPLENR, 58},
|
||||
{868*OVERSAMPLENR, 55},
|
||||
{885*OVERSAMPLENR, 52},
|
||||
{902*OVERSAMPLENR, 48},
|
||||
{919*OVERSAMPLENR, 44},
|
||||
{936*OVERSAMPLENR, 40},
|
||||
{953*OVERSAMPLENR, 34},
|
||||
{970*OVERSAMPLENR, 28},
|
||||
{987*OVERSAMPLENR, 20},
|
||||
{1004*OVERSAMPLENR, 8},
|
||||
{1021*OVERSAMPLENR, 0}
|
||||
#if (THERMISTORHEATER_0 == 5) || (THERMISTORHEATER_1 == 5) || (THERMISTORHEATER_2 == 5) || (THERMISTORBED == 5) //100k ParCan thermistor (104GT-2)
|
||||
const short temptable_5[][2] PROGMEM = {
|
||||
// ATC Semitec 104GT-2 (Used in ParCan)
|
||||
// Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf
|
||||
// Calculated using 4.7kohm pullup, voltage divider math, and manufacturer provided temp/resistance
|
||||
{1*OVERSAMPLENR, 713},
|
||||
{17*OVERSAMPLENR, 300}, //top rating 300C
|
||||
{20*OVERSAMPLENR, 290},
|
||||
{23*OVERSAMPLENR, 280},
|
||||
{27*OVERSAMPLENR, 270},
|
||||
{31*OVERSAMPLENR, 260},
|
||||
{37*OVERSAMPLENR, 250},
|
||||
{43*OVERSAMPLENR, 240},
|
||||
{51*OVERSAMPLENR, 230},
|
||||
{61*OVERSAMPLENR, 220},
|
||||
{73*OVERSAMPLENR, 210},
|
||||
{87*OVERSAMPLENR, 200},
|
||||
{106*OVERSAMPLENR, 190},
|
||||
{128*OVERSAMPLENR, 180},
|
||||
{155*OVERSAMPLENR, 170},
|
||||
{189*OVERSAMPLENR, 160},
|
||||
{230*OVERSAMPLENR, 150},
|
||||
{278*OVERSAMPLENR, 140},
|
||||
{336*OVERSAMPLENR, 130},
|
||||
{402*OVERSAMPLENR, 120},
|
||||
{476*OVERSAMPLENR, 110},
|
||||
{554*OVERSAMPLENR, 100},
|
||||
{635*OVERSAMPLENR, 90},
|
||||
{713*OVERSAMPLENR, 80},
|
||||
{784*OVERSAMPLENR, 70},
|
||||
{846*OVERSAMPLENR, 60},
|
||||
{897*OVERSAMPLENR, 50},
|
||||
{937*OVERSAMPLENR, 40},
|
||||
{966*OVERSAMPLENR, 30},
|
||||
{986*OVERSAMPLENR, 20},
|
||||
{1000*OVERSAMPLENR, 10},
|
||||
{1010*OVERSAMPLENR, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
#if (THERMISTORHEATER_0 == 6) || (THERMISTORHEATER_1 == 6) || (THERMISTORBED == 6) // 100k Epcos thermistor
|
||||
#define NUMTEMPS_6 36
|
||||
const short temptable_6[NUMTEMPS_6][2] PROGMEM = {
|
||||
{28*OVERSAMPLENR, 250},
|
||||
#if (THERMISTORHEATER_0 == 6) || (THERMISTORHEATER_1 == 6) || (THERMISTORHEATER_2 == 6) || (THERMISTORBED == 6) // 100k Epcos thermistor
|
||||
const short temptable_6[][2] PROGMEM = {
|
||||
{1*OVERSAMPLENR, 350},
|
||||
{28*OVERSAMPLENR, 250}, //top rating 250C
|
||||
{31*OVERSAMPLENR, 245},
|
||||
{35*OVERSAMPLENR, 240},
|
||||
{39*OVERSAMPLENR, 235},
|
||||
@@ -240,8 +221,8 @@ const short temptable_6[NUMTEMPS_6][2] PROGMEM = {
|
||||
{49*OVERSAMPLENR, 220},
|
||||
{53*OVERSAMPLENR, 215},
|
||||
{62*OVERSAMPLENR, 210},
|
||||
{73*OVERSAMPLENR, 205},
|
||||
{72*OVERSAMPLENR, 200},
|
||||
{71*OVERSAMPLENR, 205}, //fitted graphically
|
||||
{78*OVERSAMPLENR, 200}, //fitted graphically
|
||||
{94*OVERSAMPLENR, 190},
|
||||
{102*OVERSAMPLENR, 185},
|
||||
{116*OVERSAMPLENR, 170},
|
||||
@@ -270,10 +251,10 @@ const short temptable_6[NUMTEMPS_6][2] PROGMEM = {
|
||||
};
|
||||
#endif
|
||||
|
||||
#if (THERMISTORHEATER_0 == 7) || (THERMISTORHEATER_1 == 7) || (THERMISTORBED == 7) // 100k Honeywell 135-104LAG-J01
|
||||
#define NUMTEMPS_7 54
|
||||
const short temptable_7[NUMTEMPS_7][2] PROGMEM = {
|
||||
{46*OVERSAMPLENR, 270},
|
||||
#if (THERMISTORHEATER_0 == 7) || (THERMISTORHEATER_1 == 7) || (THERMISTORHEATER_2 == 7) || (THERMISTORBED == 7) // 100k Honeywell 135-104LAG-J01
|
||||
const short temptable_7[][2] PROGMEM = {
|
||||
{1*OVERSAMPLENR, 500},
|
||||
{46*OVERSAMPLENR, 270}, //top rating 300C
|
||||
{50*OVERSAMPLENR, 265},
|
||||
{54*OVERSAMPLENR, 260},
|
||||
{58*OVERSAMPLENR, 255},
|
||||
@@ -330,82 +311,196 @@ const short temptable_7[NUMTEMPS_7][2] PROGMEM = {
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if THERMISTORHEATER_0 == 1
|
||||
#define NUMTEMPS_HEATER_0 NUMTEMPS_1
|
||||
#define heater_0_temptable temptable_1
|
||||
#elif THERMISTORHEATER_0 == 2
|
||||
#define NUMTEMPS_HEATER_0 NUMTEMPS_2
|
||||
#define heater_0_temptable temptable_2
|
||||
#elif THERMISTORHEATER_0 == 3
|
||||
#define NUMTEMPS_HEATER_0 NUMTEMPS_3
|
||||
#define heater_0_temptable temptable_3
|
||||
#elif THERMISTORHEATER_0 == 4
|
||||
#define NUMTEMPS_HEATER_0 NUMTEMPS_4
|
||||
#define heater_0_temptable temptable_4
|
||||
#elif THERMISTORHEATER_0 == 5
|
||||
#define NUMTEMPS_HEATER_0 NUMTEMPS_5
|
||||
#define heater_0_temptable temptable_5
|
||||
#elif THERMISTORHEATER_0 == 6
|
||||
#define NUMTEMPS_HEATER_0 NUMTEMPS_6
|
||||
#define heater_0_temptable temptable_6
|
||||
#elif THERMISTORHEATER_0 == 7
|
||||
#define NUMTEMPS_HEATER_0 NUMTEMPS_7
|
||||
#define heater_0_temptable temptable_7
|
||||
#elif defined HEATER_0_USES_THERMISTOR
|
||||
#error No heater 0 thermistor table specified
|
||||
#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_1 == 1
|
||||
#define NUMTEMPS_HEATER_1 NUMTEMPS_1
|
||||
#define heater_1_temptable temptable_1
|
||||
#elif THERMISTORHEATER_1 == 2
|
||||
#define NUMTEMPS_HEATER_1 NUMTEMPS_2
|
||||
#define heater_1_temptable temptable_2
|
||||
#elif THERMISTORHEATER_1 == 3
|
||||
#define NUMTEMPS_HEATER_1 NUMTEMPS_3
|
||||
#define heater_1_temptable temptable_3
|
||||
#elif THERMISTORHEATER_1 == 4
|
||||
#define NUMTEMPS_HEATER_1 NUMTEMPS_4
|
||||
#define heater_1_temptable temptable_4
|
||||
#elif THERMISTORHEATER_1 == 5
|
||||
#define NUMTEMPS_HEATER_1 NUMTEMPS_5
|
||||
#define heater_1_temptable temptable_5
|
||||
#elif THERMISTORHEATER_1 == 6
|
||||
#define NUMTEMPS_HEATER_1 NUMTEMPS_6
|
||||
#define heater_1_temptable temptable_6
|
||||
#elif THERMISTORHEATER_1 == 7
|
||||
#define NUMTEMPS_HEATER_1 NUMTEMPS_7
|
||||
#define heater_1_temptable temptable_7
|
||||
#elif defined HEATER_1_USES_THERMISTOR
|
||||
#error No heater 1 thermistor table specified
|
||||
#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 == 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
|
||||
|
||||
#if THERMISTORBED == 1
|
||||
#define BNUMTEMPS NUMTEMPS_1
|
||||
#define bedtemptable temptable_1
|
||||
#elif THERMISTORBED == 2
|
||||
#define BNUMTEMPS NUMTEMPS_2
|
||||
#define bedtemptable temptable_2
|
||||
#elif THERMISTORBED == 3
|
||||
#define BNUMTEMPS NUMTEMPS_3
|
||||
#define bedtemptable temptable_3
|
||||
#elif THERMISTORBED == 4
|
||||
#define BNUMTEMPS NUMTEMPS_4
|
||||
#define bedtemptable temptable_4
|
||||
#elif THERMISTORBED == 5
|
||||
#define BNUMTEMPS NUMTEMPS_5
|
||||
#define bedtemptable temptable_5
|
||||
#elif THERMISTORBED == 6
|
||||
#define BNUMTEMPS NUMTEMPS_6
|
||||
#define bedtemptable temptable_6
|
||||
#elif THERMISTORBED == 7
|
||||
#define BNUMTEMPS NUMTEMPS_7
|
||||
#define bedtemptable temptable_7
|
||||
#elif defined BED_USES_THERMISTOR
|
||||
#error No bed thermistor table specified
|
||||
#define _TT_NAME(_N) temptable_ ## _N
|
||||
#define TT_NAME(_N) _TT_NAME(_N)
|
||||
|
||||
#ifdef THERMISTORHEATER_0
|
||||
#define heater_0_temptable TT_NAME(THERMISTORHEATER_0)
|
||||
#define heater_0_temptable_len (sizeof(heater_0_temptable)/sizeof(*heater_0_temptable))
|
||||
#else
|
||||
#ifdef HEATER_0_USES_THERMISTOR
|
||||
#error No heater 0 thermistor table specified
|
||||
#else // HEATER_0_USES_THERMISTOR
|
||||
#define heater_0_temptable 0
|
||||
#define heater_0_temptable_len 0
|
||||
#endif // HEATER_0_USES_THERMISTOR
|
||||
#endif
|
||||
|
||||
#ifdef THERMISTORHEATER_1
|
||||
#define heater_1_temptable TT_NAME(THERMISTORHEATER_1)
|
||||
#define heater_1_temptable_len (sizeof(heater_1_temptable)/sizeof(*heater_1_temptable))
|
||||
#else
|
||||
#ifdef HEATER_1_USES_THERMISTOR
|
||||
#error No heater 1 thermistor table specified
|
||||
#else // HEATER_1_USES_THERMISTOR
|
||||
#define heater_1_temptable 0
|
||||
#define heater_1_temptable_len 0
|
||||
#endif // HEATER_1_USES_THERMISTOR
|
||||
#endif
|
||||
|
||||
#ifdef THERMISTORHEATER_2
|
||||
#define heater_2_temptable TT_NAME(THERMISTORHEATER_2)
|
||||
#define heater_2_temptable_len (sizeof(heater_2_temptable)/sizeof(*heater_2_temptable))
|
||||
#else
|
||||
#ifdef HEATER_2_USES_THERMISTOR
|
||||
#error No heater 2 thermistor table specified
|
||||
#else // HEATER_2_USES_THERMISTOR
|
||||
#define heater_2_temptable 0
|
||||
#define heater_2_temptable_len 0
|
||||
#endif // HEATER_2_USES_THERMISTOR
|
||||
#endif
|
||||
|
||||
#ifdef THERMISTORBED
|
||||
#define bedtemptable TT_NAME(THERMISTORBED)
|
||||
#define bedtemptable_len (sizeof(bedtemptable)/sizeof(*bedtemptable))
|
||||
#else
|
||||
#ifdef BED_USES_THERMISTOR
|
||||
#error No bed thermistor table specified
|
||||
#endif // BED_USES_THERMISTOR
|
||||
#endif
|
||||
|
||||
#endif //THERMISTORTABLES_H_
|
||||
|
||||
+44
-29
@@ -1,35 +1,35 @@
|
||||
#ifndef __ULTRALCDH
|
||||
#define __ULTRALCDH
|
||||
#include "Configuration.h"
|
||||
|
||||
#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
|
||||
|
||||
|
||||
#include <LiquidCrystal.h>
|
||||
extern LiquidCrystal lcd;
|
||||
|
||||
|
||||
extern volatile char buttons; //the last checked buttons in a bit array.
|
||||
|
||||
#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;}
|
||||
#define CARDINSERTED (READ(SDCARDDETECT)==0)
|
||||
|
||||
#if (SDCARDDETECT > -1)
|
||||
#ifdef SDCARDDETECTINVERTED
|
||||
#define CARDINSERTED (READ(SDCARDDETECT)!=0)
|
||||
#else
|
||||
#define CARDINSERTED (READ(SDCARDDETECT)==0)
|
||||
#endif
|
||||
#endif //SDCARDTETECTINVERTED
|
||||
|
||||
#else
|
||||
|
||||
//atomatic, do not change
|
||||
@@ -46,12 +46,14 @@
|
||||
#define BLOCK {blocking[BL_MI]=millis()+blocktime;blocking[BL_ST]=millis()+blocktime;}
|
||||
|
||||
#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, Main_Control, Main_SD,Sub_TempControl,Sub_MotionControl};
|
||||
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:
|
||||
@@ -68,9 +70,13 @@
|
||||
void showControl();
|
||||
void showControlMotion();
|
||||
void showControlTemp();
|
||||
void showControlRetract();
|
||||
void showAxisMove();
|
||||
void showSD();
|
||||
void showPLAsettings();
|
||||
void showABSsettings();
|
||||
bool force_lcd_update;
|
||||
int lastencoderpos;
|
||||
long lastencoderpos;
|
||||
int8_t lineoffset;
|
||||
int8_t lastlineoffset;
|
||||
|
||||
@@ -79,11 +85,11 @@
|
||||
bool tune;
|
||||
|
||||
private:
|
||||
inline void updateActiveLines(const uint8_t &maxlines,volatile int &encoderpos)
|
||||
FORCE_INLINE void updateActiveLines(const uint8_t &maxlines,volatile long &encoderpos)
|
||||
{
|
||||
if(linechanging) return; // an item is changint its value, do not switch lines hence
|
||||
lastlineoffset=lineoffset;
|
||||
int curencoderpos=encoderpos;
|
||||
long curencoderpos=encoderpos;
|
||||
force_lcd_update=false;
|
||||
if( (abs(curencoderpos-lastencoderpos)<lcdslow) )
|
||||
{
|
||||
@@ -104,7 +110,6 @@
|
||||
curencoderpos=maxlines*lcdslow;
|
||||
}
|
||||
lastencoderpos=encoderpos=curencoderpos;
|
||||
int lastactiveline=activeline;
|
||||
activeline=curencoderpos/lcdslow;
|
||||
if(activeline<0) activeline=0;
|
||||
if(activeline>LCD_HEIGHT-1) activeline=LCD_HEIGHT-1;
|
||||
@@ -119,7 +124,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
inline void clearIfNecessary()
|
||||
FORCE_INLINE void clearIfNecessary()
|
||||
{
|
||||
if(lastlineoffset!=lineoffset ||force_lcd_update)
|
||||
{
|
||||
@@ -131,27 +136,37 @@
|
||||
|
||||
//conversion routines, could need some overworking
|
||||
char *ftostr51(const float &x);
|
||||
char *ftostr52(const float &x);
|
||||
char *ftostr31(const float &x);
|
||||
char *ftostr3(const float &x);
|
||||
|
||||
|
||||
|
||||
#define LCD_INIT lcd_init();
|
||||
#define LCD_MESSAGE(x) lcd_status(x);
|
||||
#define LCD_MESSAGEPGM(x) lcd_statuspgm(PSTR(x));
|
||||
#define LCD_MESSAGEPGM(x) lcd_statuspgm(MYPGM(x));
|
||||
#define LCD_ALERTMESSAGEPGM(x) lcd_alertstatuspgm(MYPGM(x));
|
||||
#define LCD_STATUS lcd_status()
|
||||
#else //no lcd
|
||||
#define LCD_INIT
|
||||
#define LCD_STATUS
|
||||
#define LCD_MESSAGE(x)
|
||||
#define LCD_MESSAGEPGM(x)
|
||||
inline void lcd_status() {};
|
||||
#endif
|
||||
|
||||
#ifndef ULTIPANEL
|
||||
#define CLICKED false
|
||||
#define LCD_ALERTMESSAGEPGM(x)
|
||||
FORCE_INLINE void lcd_status() {};
|
||||
|
||||
#define CLICKED false
|
||||
#define BLOCK ;
|
||||
#endif
|
||||
|
||||
void lcd_statuspgm(const char* message);
|
||||
void lcd_alertstatuspgm(const char* message);
|
||||
|
||||
char *ftostr3(const float &x);
|
||||
char *itostr2(const uint8_t &x);
|
||||
char *ftostr31(const float &x);
|
||||
char *ftostr32(const float &x);
|
||||
char *itostr31(const int &xx);
|
||||
char *itostr3(const int &xx);
|
||||
char *itostr4(const int &xx);
|
||||
char *ftostr51(const float &x);
|
||||
#endif //ULTRALCD
|
||||
|
||||
|
||||
+3023
-1673
File diff suppressed because it is too large
Load Diff
+5
-5
@@ -1,6 +1,6 @@
|
||||
#ifndef __WATCHDOGH
|
||||
#define __WATCHDOGH
|
||||
#include "Configuration.h"
|
||||
#ifndef WATCHDOG_H
|
||||
#define WATCHDOG_H
|
||||
#include "Marlin.h"
|
||||
#ifdef USE_WATCHDOG
|
||||
|
||||
// intialise watch dog with a 1 sec interrupt time
|
||||
@@ -9,8 +9,8 @@
|
||||
void wd_reset();
|
||||
|
||||
#else
|
||||
inline void wd_init() {};
|
||||
inline void wd_reset() {};
|
||||
FORCE_INLINE void wd_init() {};
|
||||
FORCE_INLINE void wd_reset() {};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
#ifdef USE_WATCHDOG
|
||||
#include "Marlin.h"
|
||||
#include "watchdog.h"
|
||||
#include <avr/wdt.h>
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
//===========================================================================
|
||||
//=============================private variables ============================
|
||||
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* fixed by this patch:
|
||||
* http://code.google.com/p/arduino/issues/detail?id=604
|
||||
* */
|
||||
/*
|
||||
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$
|
||||
*/
|
||||
|
||||
#ifndef Wiring_h
|
||||
#define Wiring_h
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <stdlib.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.1415926535897932384626433832795
|
||||
#define HALF_PI 1.5707963267948966192313216916398
|
||||
#define TWO_PI 6.283185307179586476925286766559
|
||||
#define DEG_TO_RAD 0.017453292519943295769236907684886
|
||||
#define RAD_TO_DEG 57.295779513082320876798154814105
|
||||
|
||||
#define SERIAL 0x0
|
||||
#define DISPLAY 0x1
|
||||
|
||||
#define LSBFIRST 0
|
||||
#define MSBFIRST 1
|
||||
|
||||
#define CHANGE 1
|
||||
#define FALLING 2
|
||||
#define RISING 3
|
||||
|
||||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||
#define INTERNAL1V1 2
|
||||
#define INTERNAL2V56 3
|
||||
#else
|
||||
#define INTERNAL 3
|
||||
#endif
|
||||
#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)))
|
||||
#if __AVR_LIBC_VERSION__ < 10701UL
|
||||
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
|
||||
#endif
|
||||
#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) * 1000L) / (F_CPU / 1000L) )
|
||||
#define microsecondsToClockCycles(a) ( ((a) * (F_CPU / 1000L)) / 1000L )
|
||||
|
||||
#define lowByte(w) ((uint8_t) ((w) & 0xff))
|
||||
#define highByte(w) ((uint8_t) ((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) (1UL << (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);
|
||||
|
||||
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, uint8_t val);
|
||||
uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);
|
||||
|
||||
void attachInterrupt(uint8_t, void (*)(void), int mode);
|
||||
void detachInterrupt(uint8_t);
|
||||
|
||||
void setup(void);
|
||||
void loop(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#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,7 +1,12 @@
|
||||
|
||||
WARNING:
|
||||
--------
|
||||
THIS IS THE BETA 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
|
||||
===================
|
||||
@@ -26,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
|
||||
@@ -37,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.
|
||||
|
||||
@@ -54,7 +62,7 @@ It leads to less over-deposition at corners, especially at flat angles.
|
||||
|
||||
*Arc support:*
|
||||
|
||||
Splic3r can find curves that, although broken into segments, were ment to describe an arc.
|
||||
Slic3r can find curves that, although broken into segments, were ment to describe an arc.
|
||||
Marlin is able to print those arcs. The advantage is the firmware can choose the resolution,
|
||||
and can perform the arc with nearly constant velocity, resulting in a nice finish.
|
||||
Also, less serial communication is needed.
|
||||
@@ -94,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.
|
||||
@@ -139,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