Commit Graph

1697 Commits

Author SHA1 Message Date
Markus Hitter fdf9534ed9 check_configtool.sh: comment on comment stripping. 2016-06-06 14:18:08 +02:00
Markus Hitter b3f77a89b2 check_configtool.sh: remove test files on success. 2016-06-06 14:18:02 +02:00
Markus Hitter e35fe22f74 check_configtool.sh: allow spaces in paths.
To the best of my bash script knowledge, this also means we have
to break on the first error, because pipe terms run in a subshell,
so they can't pass variables to the parent.
2016-06-06 14:15:14 +02:00
Phil Hord 21ac717d6d Configtool: add integrity tests for Configtool output.
Add a test that puts the stock config files through the
Configtool input/output parsers and verifies the output matches
the input.  If Configtool breaks down in the future and produces
different output, this should catch it.

If this fails because of some intentional change in the tool or
in the stock config files, then the tool or stock config files
should be updated to be compatible again before merging the result.
2016-06-06 12:36:53 +02:00
Phil Hord 2a6f00454f Configtool: add --quit and --save commandline switches.
Teach configtool to save ini, board and printer files with the
--save commandline switch.  Add a feature to Printer and Board
to let us pass None for the "values" to save; this causes the
class to save the previously loaded settings instead of taking
new settings in the argument.

Also add --quit switch to tell commandline not to continue to run the
GUI.  There's not much point in running the gui after many of these
switches, but that will change in the future.  Add this --quit option
to quit early so we can begin to use this new mode for test validation.
2016-06-06 12:36:17 +02:00
Phil Hord ba5447b409 Configtool: add --show-all switch.
Show all the loaded (defined) variables. Leave out the commented
variables for now.
2016-06-05 21:09:25 +02:00
Phil Hord 0c8ae903e9 Configtool: add --load switch to load printer, board or ini.
Teach configtool command line functions to load the printer, board
or ini file settings into internal classes. For now this only
exercises the "load" functionality of the classes, but with -vv
you can also see the results of the load dumped to the console.
2016-06-05 21:09:18 +02:00
Phil Hord 2c5a36b14e Configtool: make Settings the "global" container.
Instead of passing myriad variables around in arguments to
classes and functions, put the global settings like "verbose" and
"cmdFolder" in the Settings object and pass that in to the top.
2016-06-05 21:09:11 +02:00
Phil Hord eafb8e0bfb Configtool: begin command line automation.
Add a command line handler mode to Configtool to permit automation
for scripts.

Traumflug's review note: restored Python 3 checks.
2016-06-05 21:09:04 +02:00
Phil Hord 11bb6bb1cf Configtool: refactor printerpanel for MVC.
Move model functionality out of printerpanel.py into a new class,
Printer, so we can more easily add commandline driven tests in
the future and to help identify code reuse opportunities.
2016-06-05 21:08:55 +02:00
Phil Hord d3062ca1dd Configtool: refactor boardpanel for MVC.
Move model functionality out of boardpanel.py into a new class,
Board, so we can more easily add commandline driven tests in the
future.
2016-06-05 21:08:41 +02:00
Markus Hitter c80b4d4d28 Revert "Configtool: attempt to fix broken pin definitions."
This worked only when the GUI came up, so a better fix was found
with commit

  "Configtool: deal with missing #defines requiring a value."
2016-06-05 21:07:54 +02:00
Markus Hitter 5a28a62717 Configtool: default new config options to disabled.
New boolean options were all enabled, which was a problem
especially with the boolean choices DISPLAY_BUS_xxx and
DISPLAY_TYPE_xxx: all choice entries were set to True, so display
code was not only enabled behind the users back, but also set to
an arbitrary value (depending on the Python implementation).
2016-06-05 15:03:13 +02:00
Markus Hitter 776b3dec94 Configtool: try to repair broken value-#defines.
Previously, #defines requiring a value, but configured as boolean,
broke GUI code. While Configtool its self should never write such
broken #defines, they can happen with manual config file edits.

IMHO it's fine to do such repair attempts as long as it doesn't
hobble other functionality. Whatever was broken at read time will
end up disabled at write time, unless the user changes that value
in the GUI.
2016-06-05 15:03:13 +02:00
Markus Hitter 490e58a43c Configtool: simplify board config parsing (a little bit).
There should be no functional change. Mostly done for consistency
with other, similar code sections.
2016-06-05 15:03:13 +02:00
Markus Hitter d49520c36d Configtool: deal with missing #defines requiring a value.
This is done by parsing values from the generic config before
parsing those in the user config. Values existing in the user
config overwrite those in the generic config; values not
existing there stay at the value in the generic config.

Previously, only boolean #defines were handled properly (and
by code somewhere else). Missing #defines with value were
written as boolean #define, making the file unparseable on
the next read.
2016-06-05 15:03:13 +02:00
Markus Hitter 9d3a064f40 Configtool: remove redundant code.
There is no point in parsing candidates, just to throw away them
a moment later.
2016-06-05 15:03:13 +02:00
Markus Hitter 09bcb0cf42 Configtool: attempt to fix broken pin definitions.
We can't magically find out what the right pin is, but we can at
least make sure it gets written with valid syntax next time. This
also ensures pins can be handled in the GUI, avoiding failures
like the one reported by inline comments here:

b9fe0a5dd0
2016-06-01 13:20:14 +02:00
Phil Hord d9cf035687 simulator: suppress position display unless something changed
Also coalesce multiple pin-steps occurring at the same clock-time into
a single step.  This allows us to treat X+Y movements at the same moment
into a single step on corexy.
2016-05-31 15:21:49 -04:00
Phil Hord aebaa3bf40 simulator: add --pinouts to show pin activity on console
We show pin output on the console when --verbose is 2.  But this gets in
the way of other verbose output we may want to monitor.  Move the pinouts
option to an explicit switch instead of relying on the --verbose flag.
2016-05-31 15:21:49 -04:00
Phil Hord 65b176e2f6 simulator: Add --no-color option to turn off ANSI controls 2016-05-31 15:21:49 -04:00
Phil Hord e5715e433b simulator: Wait for DDA to complete before exiting
When the simulator finishes processing the last gcode, it exits.  This
leaves causes us to exit without completing the last commanded move.

Rework how we handle end-of-file parsing and wait for the dda queue to
empty before exiting at the end of file processing.
2016-05-31 15:21:49 -04:00
Phil Hord b317ba086c corexy: Fix new_dda_startpoint for corexy
Add a function axes_um_to_steps to convert from um to steps on all axes
respecting current kinematics setting.

Extend code_stepper_axescode_axes_to_stepper_axes to convert all axes,
including E-axis for consistency.

It seems like axes_um_to_steps could be simplified to something like
"apply_kinematics_axes()" which would just do the transformation math
in-place on some axes[] to move from 'Cartesian' to 'target-kinematics'.
Then the original um_to_steps and delta_um code could remain untouched
since 2014.  But I'm not sure how this will work with scara or delta
configurations. I'm fairly certain they only work from absolute positions
anyway.

Fixes #216.
2016-05-31 15:19:50 -04:00
Ruslan Popov 2c48b9b188 Formatting source code.
No functional change.
2016-05-30 16:13:11 +02:00
Markus Hitter eb8d918836 Configtool: implement tooltips for boolChoices.
Now these display bus type and display type choices have their
help text, too.
2016-05-30 14:31:40 +02:00
Markus Hitter 813bdf4452 Display: add regression test for 4-bit bus and HD44780 display.
(Ab)use the old Gen7 v1.3 configuration for this, as this is
rarely in use and because this board also happens to be the board
where the tested code was developed on.
2016-05-30 14:10:25 +02:00
Markus Hitter 0545a5bb2c Configtool: show display bus pins only if needed. 2016-05-30 13:41:27 +02:00
Markus Hitter b9fe0a5dd0 Configtool: learn about 4-bit bus pins. 2016-05-30 13:41:13 +02:00
Markus Hitter ad021f7df7 Configtool: move handling of unused pins to parent class.
This shouldn't change behaviour.
2016-05-30 11:12:37 +02:00
Markus Hitter 7a18217dee Configtool: move choices value insertion to the parent class.
This shouldn't change behaviour.
2016-05-30 11:10:08 +02:00
Markus Hitter ca69343a04 Configtool: allow ATmega pin names, too. 2016-05-30 11:08:00 +02:00
Markus Hitter 0947c5ba50 Configtool: learn about DISPLAY_TYPE_HD44780.
This replaces DISPLAY_TYPE_LCD1302, because LCD1302 has no
actual implementation, yet.
2016-05-30 11:05:50 +02:00
Markus Hitter 692fab68b9 display_hd44780.c: replace silly demo with temperatures.
Now we have something useful. And it works nicely :-)
2016-05-30 11:03:41 +02:00
Markus Hitter c2c9753f80 Display: implement cursor positioning for the HD44780. 2016-05-30 11:01:24 +02:00
Markus Hitter 1d4ebbd7fa Display: queue up display_set_cursor(), too. 2016-05-30 10:59:12 +02:00
Markus Hitter 8d7471d3a4 Display: display_clear() is a common command now.
Before control commands were queued up, this was different for
each display.
2016-05-30 10:50:41 +02:00
Markus Hitter 5b9e123e0e Display: queue up display clear commands. 2016-05-30 10:32:33 +02:00
Markus Hitter da0d5aec2c Display: add support for the HD44780 display.
All in one chunk because the infrastructure is already there.
This also implements the parallel 4-bit bus used by quite some
displays.

For now you have to add quite a number of #defines to your
config.h. First, there are all the pins required, pin names
changed to your actual board/display connection, of course:

  #define DISPLAY_RS_PIN       PC1
  #define DISPLAY_RW_PIN       PC0
  #define DISPLAY_E_PIN        PD2
  #define DISPLAY_D4_PIN       PD3
  #define DISPLAY_D5_PIN       PD4
  #define DISPLAY_D6_PIN       PD5
  #define DISPLAY_D7_PIN       PD6

And then the information about the display actually existing:

  #define DISPLAY_BUS_4BIT
  #define DISPLAY_TYPE_HD44780

Allowing to do all this in Configtool is forthcoming, of course.
2016-05-30 10:31:39 +02:00
Markus Hitter 12dc74fe62 Display: finally get rid of i2c_test.c.
Not without dubbing its remaining functionality in form of a
display_greeting(), of course.
2016-05-28 21:14:37 +02:00
Phil Hord 92a303c607 Add testcase for corexy homing bug 2016-05-26 11:22:12 +02:00
Phil Hord 750acb41bc Simulator: calculate position for corexy correctly
CoreXY turns the X and Y motors to render a target position differently
than straight cartesian printer does.  From the theory page on corexy.com,
where the motors are called A and B instead of X and Y:

    dx = 1/2(dA + dB), dY = 1/2(dA - dB)
    dA = dX + dY
    dB = dX - dY

Accordingly, each step of a single motor results in half of a step in the
X or Y axis.  To simplify this and not lose steps, make the pos[] array
hold 2*steps instead of single steps.  Adjust back to single steps with
/2 where needed.  Store 2*steps whenever writing to pos[] variables
which are not coreXY driven.

Since each step of X or Y (A or B) affects both X and Y position, send
updates to record_pin for all axes instead of only the "affected" axis.
The function record_pin will ignore reports for pins which did not change
from the previous call.  This also helps us keep from reporting duplicate
positions for half-steps in coreXY mode, too.
2016-05-26 11:16:11 +02:00
Phil Hord 59610750dd Simulator: support endstop simulation
Provide a simulated, simplified representation of the action of
mechanical endstop switches which turn on and off at slightly
different amounts of pressure. When any axis moves past -10,
simulate endstop "on" condition. When the axis moves to 0,
simulate the endstop "off" condition.

This support allows the simulation of G28 (home) commands.
2016-05-26 11:09:54 +02:00
Phil Hord 887a4eedd9 Simulator: fix pin numbering consistency
The simulator code is compiled with different definitions than the
rest of the code even when compiling the simulator.  This was done
originally to satisfy the compiler, but it was the wrong way to go.
The result is that the main Teacup code may decide to do things one
way (X_INVERT_DIR, for example) but the simulator code will do
things a different way (no X_INVERT_DIR).

Fix this by including the board and printer definitions also in the
simulator code, and use a simple enum trick to give consistent
definitions to the needed PIN definitions, safely ignoring the ones
the config does not use.

This requires that we include simulator.h after 'config.h' in all cases.
Manage that by moving simulator.h from its previous home in arduino.h
into config_wrapper.h.

After this change we will be able to reliably communicate the expected
state of the endstop pins from the simulator.
2016-05-26 11:04:30 +02:00
Markus Hitter 6e4cd69345 board.ramps-1.3.h: add all four pins from the Servos connector.
Previously there were only two of them, the others missing for
no apparent reason. This should help connecting an external
relay, like described here:
http://www.reprap-diy.com/connect_sevenswitch_to_ramps
2016-05-25 20:29:54 +02:00
Phil Hord 90d519af5f dda_clock(): guard against *dda changes in interrupts
dda_clock() might be interrupted by dda_step(), and dda_step might
use or modify variables also being used in dda_clock().  It is
possible for dda to be modified when a new dda becomes live during
our dda_clock().  Check the dda->id to ensure it has not changed on
us before we actually write new calculated values into the dda.

Note by Traumflug: copied some of the explanation in the commit
message directly into the code.
2016-05-21 15:46:10 +02:00
Phil Hord 1eefb28a19 dda_clock(): modify dda->n only in atomic code
dda_clock() might be interrupted by dda_step(), and dda_step might
use or modify variables also being used in dda_clock. In particular
dda->c is modified in both functions but it is done atomically in
dda_clock() to prevent dda_step() from interrupting during the
write.  But dda->n is also modified in both places and it is not
protected in dda_clock().

Move updates to dda->n to the atomic section along with dda->c.

Note by Traumflug: good catch! It even makes the binary 14 bytes
smaller, so likely faster.
2016-05-21 15:45:49 +02:00
Markus Hitter fe398d84ce displaybus.h: note the different #include strategies.
Yes, these strategies feel a lot like heading into uncharted
territory, because I can't find notable textbook examples on how
to select between various "classes" at compile time. Nevertheless,
it works fine, binaries are small and fast and as such it can't
be _that_ wrong.
2016-05-18 18:03:36 +02:00
Phil Hord 90fbdd314a configtool: Add avrdude flags option to settings
Some target devices need extra avrdude command line switches to
get them to upload successfully.  There are dozens of options which
may be useful to different people. Instead of breaking all the possible
options out into separate fields, provide a generic "Program Flags" text
field which the user can fill in similar to the CFLAGS and LDFLAGS
settings.

The Arduino Mega2560 bootloader was changed[1] to report an error when
asked to erase flash because it has never actually implemented erasing
flash. To program this bootloader with avrdude requires the -D switch
to avoid flash erase. But it seems that every arduino will work fine
with -D, as evidenced by the fact that the Arduino IDE always [2]
includes -D in the avrdude commandline. Presumably the flash is erased
during/before programming anyway and the separate erase step is unneeded.

Perhaps the -D should be always added to avrdude command line in
configtool and in Makefile-AVR.  But I haven't tested any other boards
yet, and I'm being more cautious even though the Arduino IDE does
otherwise.

[1] arduino/Arduino#543
[2] d8e5997328/app/src/processing/app/debug/AvrdudeUploader.java (L168)
2016-05-17 12:57:16 -04:00
Markus Hitter bb56874088 Regressiontests: add a test for ATmega328, I2C, SSD1306. 2016-05-06 20:34:18 +02:00
Markus Hitter 535fa0c171 check_integrity.sh: remove the -c option from awk invocations.
Ubuntu now (16.04) comes with 'mawk', which doesn't recognize the -c
option, so simply remove it. Its meaning was to switch into 'traditional'
mode.
2016-05-06 19:37:56 +02:00