Commit Graph

120 Commits

Author SHA1 Message Date
Markus Hitter 5a8d51cb19 ARM: get dda_maths.c, dda_kinematics.c and dda.c in.
All in one chunk, because it's all hardware-independent and doing
them one by one would end up on not more than some typing
exercises.

Compiles fine. For testing, remove if (DEBUG... for M114 in
gcode_process.c. Then one can see how the queue fills up when
sending movements and M114 repeatedly. This time with actual
coordinates.

No stepper movements, yet, because set_timer() is still empty.
2015-08-12 14:26:37 +02:00
Markus Hitter 692a6daeb2 ARM: get dda_queue.c in.
Compiles fine. For testing, remove if (DEBUG... for M114 in
gcode_process.c. Then one can see how the queue fills up when
sending movements and M114 repeatedly.

queue_step() isn't called, yet, the stepper timer is still missing.
2015-08-12 14:26:37 +02:00
Markus Hitter 4faa3cbf8f ARM: bring in pinio.c.
This enables pinio_init(), power_on() and power_off(). Now one
can turn on the power supply with M119 and turn it off with M2.

Code changes were neccessary. Setting a pin first, then making
it an output doesn't work on ARM. A pin has to be an output
before it permanently accepts a given state. As I was never
sure the former strategy actually worked on AVR, the order of
these two steps was changed for both, AVR and ARM.
2015-08-12 14:26:36 +02:00
Markus Hitter 96f7dbd2b1 ARM: bring in gcode_process.c.
Again, the whole file compiled flawlessly without change. Still,
to get it linked as well, most of the functionality had to
be #ifdef'd out.

Nevertheless, the firmware shows first signs of life, e.g. M115
works.
2015-08-12 14:26:36 +02:00
Markus Hitter 7be5212f06 ARM: introduce sei() and cli().
No test, because it's tricky to test, but it compiles and the
firmware still works as before.
2015-08-12 14:26:36 +02:00
Markus Hitter 4353403695 gcode_process.c: replace some sersendf() with serial_writestr().
sersendf_P() is only needed for formatted strings, plain strings
can be sent simpler.

Saves 48 bytes binary size on AVR.
2015-08-07 16:16:05 +02:00
Markus Hitter 9c194b42f6 Messages: more newlines needed.
The recent switch to send 'ok' postponed requires also sending a
newline in a few places, because this 'ok' is no longer at the
start of the line. Now it appears in its own line.

Some whitespace at line end was removed in heater.c.

Costs 14 bytes binary size on AVR.
2015-08-07 16:15:17 +02:00
Markus Hitter 2af689a4db gcode_process.c: remove a redundant #ifdef DEBUG and similar. 2015-08-01 18:27:39 +02:00
Phil Hord 22b640697b Replace SIMULATOR with __AVR__ in several places.
Previously some features were excluded based on whether SIMULATOR
was defined. But in fact these should have been included when __AVR__
was defined. These used to be the same thing, but now with ARM coming
into the picture, they are not. Fix the situation so AVR includes are
truly only used when __AVR__ is defined.

The _crc16_update function appears to be specific to AVR; I've kept the
alternate implementation limited to AVR in that case in crc.c. I think
this is the right thing to do, but I am not sure. Maybe ARM has some
equivalent function in their libraries.
2015-07-29 21:05:38 +02:00
Markus Hitter 277de42b00 G-code parser: move gcode_source stuff ...
... from gcode_process.c/.h to gcode_parse.c/.h.
2015-07-17 13:31:10 +02:00
Markus Hitter 23be2d1449 SD card: finally(!) implement printing from SD card.
Turned out to be pretty easy with all the more complex bits
already in place.

Strategy is to always parse a full line from one of the sources.
Accordingly, simply sending a character on the serial line stops
reading from SD until the line coming in over serial is completed.
2015-07-07 19:07:35 +02:00
Markus Hitter d3f548a895 SD card: actually read the characters from the file.
Next to the implementation of sd_read_byte() as well as M24 and
M25, yet another demo: read the file and write it to the serial
line, to show correctness of the implementation.
2015-07-07 14:36:44 +02:00
Michael Moon 983bcfdd46 SD card: initial shoehorning of SD code, part 2.
Part 2 is to implement M23: select file. That's more than just a
few lines, as we also have to teach the gcode-parser to collect
strings.

For now the file is simply tested for successful opening, no
actual printing, yet.

About build size: during development there was another
implementation, which didn't abstract SD card functions into
sd.c/.h, but put them into gcode_process.c directly. At the
feature completeness of this commit, the other implementation
used 70 bytes flash less, but also 23 bytes more RAM. So I decided
for the more abstracted/encapsulated version. --Traumflug

Also, this adds 14 bytes binary size even without SD card support.
A lot more #ifdefs around each use of next_target.read_string
would remove this, but after all we do care a bit about
readability of the source code, so let's sacrify these 14 bytes
to it. --Traumflug
2015-07-05 23:32:48 +02:00
Michael Moon 8f2e1e59ac SD card: initial shoehorning of SD code, part 1.
Part 1 is, implement

 - M20: List SD card.
 - M21: Initialize SD card (has to be done before listing).
 - M22: Release SD card.

Do all this in one chunk, splitting this up wouldn't allow to test
the result.
2015-07-05 23:32:48 +02:00
Markus Hitter 9ea3941ffe gcode_process.c: be more explicit about X_MIN,... type.
Big surprise, this makes the binary a whopping 286 bytes smaller
with software endstops enabled. Looking at the produced assembly,
the former code caused gcc to do the float -> integer conversion
at runtime, using a __floatsisf(). Now the X_MIN, X_MAX... values
are compiled in as integers directly.

This is work related to issue #157.
2015-06-10 13:56:39 +02:00
Markus Hitter 3b02ba5376 gcode_process.c: refine description for G28. 2015-06-06 20:09:19 +02:00
Markus Hitter 9aa1d2337f gcode_process.c: we can't rely on next_target.P being zero.
... simply because P is used for many commands and none of them
cares to clean it after usage.

This fixes a bug where setting the default heater without temp
sensor (M106) worked only after a G4 Pxxx command.
2015-04-21 02:51:32 +02:00
Markus Hitter 55c0be5f41 gcode_process.c: same homing order for all axes.
This is, first towards MIN, then towards MAX. Now also matches order
for homing all, which is defined in home() in home.c. Partially
fixes issue #107.
2014-12-26 19:41:38 +01:00
Markus Hitter b66ba4629a gcode_process.c: sort M112.
Counting to numbers up to 300 is apparently not everyone's
business, he he. :-)
2014-12-26 19:41:38 +01:00
Erik Jonsson fa0e0d37e7 gcode_process.c: added stop message when M2 is recieved.
This shall help stopping a simulator when G-code is done.
2014-08-31 19:12:36 +02:00
Markus Hitter 642948acb2 gcode_process.c: review G28 comment. 2014-08-31 19:12:11 +02:00
David Forrest b12157cb6f gcode_process.c: Add comment on units of P, I, and D parameters. 2014-08-31 19:06:52 +02:00
Phil Hord d3f49b3e95 DDA: Convert TARGET axis vars to array.
In preparation for more efficient and scalable code using axis-loops
for common operations, add two new array-types for signed and unsigned
32-bit values per axis. Make the TARGET type use this array instead of
its current X, Y, Z, and E variables.

Traumflug notes:

- Did the usual conversion to spaces for changed lines.

- Added X = 0 to the enum. Just for peace of mind.

- Excellent patch!

Initially I wanted to make the new array an anonymous union with the
old variables to allow accessing values both ways. This way it would
have been possible to do the transition in smaller pieces. But as
the patch worked so flawlessly and binary size is precisely the
same, I abandoned this idea. Maybe it's a good idea in other areas.
2014-08-31 19:03:17 +02:00
Markus Hitter e76bfa0d05 gcode_process.c: more preprocessor conditions for homing movements.
Well, optimizer isn't _that_ smart. It apparently removes
empty functions in the same compilation unit ( = source code file),
but not ones across units.

This saves 10 bytes binary size per endstop not used, so 30 bytes
in a standard configuration. All without any drawbacks.
2014-07-11 01:38:34 +02:00
Markus Hitter 7611872baa Get rid of E_STARTSTOP_STEPS.
This meant to be a firmware-provided retract feature but was
never really supported by G-code generators. Without their support
(by issueing M101/M103), it's pretty hard to detect extrusion
pauses, so this feature simply has no future.

As this was on by default, it saves over 200 bytes binary size
in a default configuration.
2014-07-11 01:37:48 +02:00
Phil Hord 96b7b8e6c9 Update URLs for new github location 2014-03-04 19:57:08 +01:00
Phil Hord 21e5343552 Add config.h wrapper to simplify test automation
Test code which wants to customize config.h can do so without
touching config.h itself by wrapping config.h in a macro variable
which is passed in to the compiler.  It defaults to "config.h" if
no override is provided.

This change would break makefile dependency checking since the selection
of a different header file on the command line is not noticed by make
as a build-trigger.  To solve this, we add a layer to the BUILDDIR path
so build products are now specific to the USER_CONFIG choice if it is
not "config.h".
2014-03-04 19:56:23 +01:00
Markus Hitter c5871d0303 gcode_process.c: show endstop status in clear text.
This costs 40 bytes, but should be a significant enhancement on
usability.
2013-12-06 19:24:58 +01:00
Phil Hord 452e2e5cd9 Restore simulation build target.
This code was accidentally removed long ago in a botched merge. This
patch recovers it and makes it build again. I've done minimal testing
and some necessary cleanup. It compiles and runs, but it probably still
has a few dust bunnies here and there.

I added registers and pin definitions to simulator.h and
simulator/simulator.c which I needed to match my Gen7-based config.
Other configs or non-AVR ports will need to define more or different
registers. Some registers are 16-bits, some are 8-bit, and some are just
constant values (enums). A more clever solution would read in the
chip-specific header and produce saner definitions which covered all
GPIOs. But this commit just takes the quick and easy path to support my
own hardware.

Most of this code originated in these commits:

	commit cbf41dd4ad
	Author: Stephan Walter <stephan@walter.name>
	Date:   Mon Oct 18 20:28:08 2010 +0200

	    document simulation

	commit 3028b297f3
	Author: Stephan Walter <stephan@walter.name>
	Date:   Mon Oct 18 20:15:59 2010 +0200

	    Add simulation code: use "make sim"

Additional tweaks:

Revert va_args processing for AVR, but keep 'int' generalization
for simulation. gcc wasn't lying. The sim really aborts without this.

Remove delay(us) from simulator (obsolete).

Improve the README.sim to demonstrate working pronterface connection
to sim. Also fix the build instructions.

Appease all stock configs.

Stub out intercom and shush usb_serial when building simulator.

Pretend to be all chip-types for config appeasement.

Replace sim_timer with AVR-simulator timer:

The original sim_timer and sim_clock provided direct replacements
for timer/clock.c in the main code. But when the main code changed,
simcode did not. The main clock.c was dropped and merged into timer.c.
Also, the timer.c now has movement calculation code in it in some
cases (ACCELERATION_TEMPORAL) and it would be wrong to teach the
simulator to do the same thing. Instead, teach the simulator to
emulate the AVR Timer1 functionality, reacting to values written to
OCR1A and OCR1B timer comparison registers.

Whenever OCR1A/B are changed, the sim_setTimer function needs to be
called. It is called automatically after a timer event, so changes
within the timer ISRs do not need to bother with this.

A C++ class could make this requirement go away by noticing the
assignment. On the other hand, a chip-agnostic timer.c would help
make the main code more portable. The latter cleanup is probably
better for us in the long run.
2013-12-06 19:24:58 +01:00
Phil Hord 498779d7ab gcode-process.c: fix HEATER_EXTRUDER reference.
A rare combination of factors makes this code assume HEATER_EXTRUDER
always exists, when that is not necessarily so.  Add the normal
guard around it.
2013-11-11 19:02:52 +01:00
Markus Hitter fc4bfca06a Rename M200 to M119 to meet Sprinter & Marlin.
No functional change.
2013-07-11 22:04:03 +02:00
Markus Hitter 23679bbd49 Remove M84.
Teacup handles motor on/off automatically and if your
intention is to stop the printer, M0 is appropriate (and
conforming with the NIST G-code standard).

That said, M84 is kept as a synonym for M2 to enhance compatibility
with slic3rs default end-G-code.
2013-07-11 22:03:51 +02:00
Markus Hitter b10b3db4f8 Wrap EEPROM storage related stuff in #ifdef EECONFIG.
Saves a whopping 600 bytes. Let's cross fingers stuff still works.
It should, using the hardcoded default values.
2013-02-05 14:10:31 +01:00
Markus Hitter faf737bbf5 gcode_process.c: remove commented M113. 2013-01-03 15:34:56 +01:00
Markus Hitter 49b76d6e25 gcode_process.c: make the extruder optional and ...
... default to the first available device if the intended
device isn't available.
2013-01-03 15:34:50 +01:00
Markus Hitter a0997fcee1 gcode_process.c: remove M190 and M191.
These were pointless anyways, the power supply is handled fully
automatic in Teacup.
2013-01-03 15:34:49 +01:00
Markus Hitter 7f903fe0e2 gcode_process.c: remove the now obsolete M135.
The replacement is the now generalised M106.
2013-01-03 15:34:48 +01:00
Markus Hitter 28a366fc48 Handle power_on() for heaters in heater.c.
This removes some instances in gcode_process.c and saves 26 bytes.
2013-01-03 15:34:45 +01:00
Markus Hitter 6f2ec09837 Make temperature sensor type TT_NONE obsolete.
The requirement was simply neither obvious nor intuitive. Drawback
is, the indices of temperature sensors can now differ from these
of the heaters. That's easier to recognize for newbies, though.
2013-01-03 15:34:41 +01:00
Markus Hitter 5d6de1761b Enable internal pullups for endstops on demand, only.
The binary size impact is moderate, like 18 bytes plus
4 bytes per endstop defined.

The story is a follows:

The endstop logic can be used to use a touch probe with PCB
milling. Connect the (conductive) PCB surface to GND, the
spindle/mill bit to the signal line, turn the internal pullups
on and there you go.

However, doing so with pullups always enabled and while milling
under (conductive) water showed polished mill and drill bits to
become matte after a few hours of usage. Obviously, this small
0.5 mA current from the pullup resistors going through the
rotating mill bit is sufficient to get some spark erosion going.
That's bad, as spark erosion happening also means tools become
dull faster than neccessary.

With this patch, pullups are turned on while being used, only,
so this sparc erosion should go away.
2012-12-03 19:48:13 +01:00
Markus Hitter a054d4c6cd Remove all remaining evidence of M109.
M109 went away a few commits ago in favour of only M116.
2012-10-14 22:57:22 +02:00
Markus Hitter b83027def2 gcode_process.c: fix a comment. 2012-10-14 22:56:26 +02:00
Markus Hitter b4d202367c gcode_process.c: fix URL sent on M115. 2012-10-14 22:56:17 +02:00
Markus Hitter 47337f1213 gcode_process.c: join M250 and a stray message into M114.
Also, F is unsigned.
2012-09-29 23:01:42 +02:00
Markus Hitter d169a1fa3e gcode_process.c: remove M253: read arbitrary memory location, too.
Also pretty esoteric.
2012-09-29 23:01:17 +02:00
Markus Hitter 8e3cf55723 gcode_process.c: remove M254: write arbitrary memory location.
Pretty esoteric and I can't imagine how to make meaningful use
of this. And well, we have to make room for eeconfig commands.
2012-09-29 23:01:02 +02:00
Markus Hitter f06b013179 clock.c: introduce clock().
This simplifies calls to clock_10ms() a bit and saves 18 bytes
binary size.
2012-09-29 23:00:24 +02:00
Markus Hitter c75693af38 gcode_process.c: remove support for M109.
This was deprecated in the wiki quite a while ago. Use M104,
followed by a M116, instead.

This saves a whopping 250 bytes binary size.
2012-09-29 22:59:33 +02:00
Markus Hitter 94ac2b11b8 gcode_process.c: remove M107 (fan off).
To turn the fan off, use M106 S0. This aligns with RepRap's
G-code wiki page.
2012-09-29 22:59:08 +02:00
Markus Hitter 06c546959c gcode_process.c: allow controlled fan speed. 2012-09-29 22:58:39 +02:00