Commit Graph

1437 Commits

Author SHA1 Message Date
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
Markus Hitter 3dd430de59 display_ssd1306.c: note current state and missing pieces.
A few days before being done with this display hardware decided
say good bye. Accordingly I can't continue with writing related
code. Writing down what already works and what's still missing is
probably a good idea, to make sure the next fellow doesn't have
to investigate from scratch.
2016-04-28 23:11:39 +02:00
Markus Hitter f091b1e316 display_ssd1306.c: note a possible error recovery strategy.
Currently not implemented because this costs additional binary
size and, well, with I2C being reliable now, it's difficult to
test it. And also because I'm lazy :-)
2016-04-27 23:54:15 +02:00
Markus Hitter d803883cdb i2c.c: review error handling yet again.
- Flag I2C_MODE_FREE was misleading, because one couldn't test
   for it the same way as for I2C_MODE_BUSY. At an error
   condition, 'i2c_mode & I2C_MODE_FREE' would still evaluate
   to true.

 - On error, drop not only the buffer, but the entire
   transmission.

All of a sudden, the display works reliably, even at the
previously shaky speed of 100'000 bits/s!

TBH, probably I didn't understand some parts of Ruslan's code
earlier but tweaked it anyways. Shame on me!
2016-04-27 23:54:15 +02:00
Markus Hitter 6e8067208e i2c.c: simplify error handling.
If all error conditions are handled the same, there's not much
point to use distinct code for each of them.

Also, handle collisions like the other error conditions.

This saves a nice 52 bytes of program memory.

  Program:  24404 bytes
     Data:   1543 bytes
   EEPROM:     32 bytes
2016-04-27 23:54:14 +02:00
Markus Hitter a13312d9a9 Display: introduce display queue.
Now we shouldn't experience wait cycles in i2c_write() during
typical display writes any longer. It should also distribute CPU
load of display writes a lot better.

Previously writing a line of text to the display would take
almost as long as it took to actually send it to the display,
because the I2C queue could hold only one transmission, which
effectively meant only one character. This could hold the main
loop for several milliseconds.

Now we queue characters, send them one by one, and return to the
main loop in between.

This costs 160 bytes program memory. Only 18 bytes RAM, because
the I2C queue was reduced accordingly. Now:

  Program:  24456 bytes
     Data:   1543 bytes
   EEPROM:     32 bytes
2016-04-27 23:54:14 +02:00
Markus Hitter aabce8ed15 usb_serial.h: refine the note.
Thanks for the hint, @phord.
2016-04-27 23:53:42 +02:00
Markus Hitter 9b2c5e61c6 dda_lookahead.c: replace Windows EOL by the usual Unix EOL.
No functional change.
2016-04-26 17:41:21 +02:00
Markus Hitter 0d91b44436 dda_lookahead.c: remove redundant macro.
No functional change.
2016-04-26 17:41:07 +02:00
Markus Hitter c9056e376d dda_lookahead.c: remove two obsolete #includes.
No functional change.
2016-04-26 17:40:57 +02:00
Markus Hitter ea2a10fa76 i2c.c: recover from error conditions.
This is
- clearing 'i2c_should_end', so i2c_write() doesn't hang and
- draining the buffer on errors.

This way we loose the remaining transmission, which is typically
half a character, but we no longer stall the entire firmware main
loop.

Actually, such error conditions are surprisingly frequent, at
least on the test hardware. Now they result in some flickering
of the displayed numbers.
2016-04-26 15:36:11 +02:00