Login| Sign Up| Help| Contact|

Patent Searching and Data


Title:
APPARATUS AND METHODS FOR COMPUTERIZED END EFFECTOR MANIPULATION
Document Type and Number:
WIPO Patent Application WO/2019/094867
Kind Code:
A2
Abstract:
Apparatus and method for a painting machine are provided. The painting machine may include an end effector controlled by custom software. The custom control software may be capable of coordinated n-axis manipulation of an end. Illustrative end effectors may include an inkjet head, brush, air brush or any suitable tool for applying ink, paint, color and/or texture to a surface. For example an end effector may utilize oil-based ink or ultraviolet- cured ink. Illustrative surfaces may include canvas, paper, brick, glass etc. The custom control software may control manipulation of the end effector based on a variety of electronic inputs. The custom software may manipulate different end effectors in different ways depending on the input data, type of ink/paint being used, type of surface receiving the ink/paint or any other variable.

Inventors:
TRITT, Ben (LLC30 W. 24th Street, Floor, New York NY, 10010, US)
LEONARD, Jeff (LLC30 W 24th Street, Floor, New York NY, 10010, US)
ACHITUV, Tal (LLC30 W 24th Street, Floor, New York NY, 10010, US)
TRUEBLOOD, Owen, Elias (LLC30 W 24th Street, Floor, New York NY, 10010, US)
PETERSON, Bryce (LLC30 W 24th Street, Floor, New York NY, 10010, US)
MARKOVICH, Yaakov (LLC30 W 24th Street, Floor, New York NY, 10010, US)
LEIGH, Sang-won (LLC30 W 24th Street, Floor, New York NY, 10010, US)
Application Number:
US2018/060574
Publication Date:
May 16, 2019
Filing Date:
November 12, 2018
Export Citation:
Click for automatic bibliography generation   Help
Assignee:
TRITT, Ben (LLC30 W. 24th Street, Floor, New York NY, 10010, US)
LEONARD, Jeff (LLC30 W 24th Street, Floor, New York NY, 10010, US)
ACHITUV, Tal (LLC30 W 24th Street, Floor, New York NY, 10010, US)
TRUEBLOOD, Owen, Elias (LLC30 W 24th Street, Floor, New York NY, 10010, US)
PETERSON, Bryce (LLC30 W 24th Street, Floor, New York NY, 10010, US)
MARKOVICH, Yaakov (LLC30 W 24th Street, Floor, New York NY, 10010, US)
LEIGH, Sang-won (LLC30 W 24th Street, Floor, New York NY, 10010, US)
International Classes:
B05C11/10
Attorney, Agent or Firm:
BALDINGER, Jacob (Weiss & Arons LLP, 63 South Main StreetSpring Valley, NY, 10977, US)
Download PDF:
Claims:
WHAT IS CLAIMED IS:

1. A system for painting a mark along a non-linear pathway, the system comprising:

an end effector for printing onto a surface; and

software that, when run on a processor:

captures electronic data comprising the mark and the non-linear pathway; configures the end effector to paint the mark by following the non-linear pathway;

wherein the mark comprises a creator designed repeating pattern that provides a visual effect of a brush stroke.

2. The system of claim 1, wherein the end effector comprises an inkjet head.

3. The system of claim 2, further comprising ink that is comprised of particles that are:

small enough to pass through one or more nozzles in the inkjet head onto the surface when the one or more nozzles are in an open state; and

large enough to be retained within the inkjet head when the one or more nozzles are in a closed state;

wherein the end effector is configured to print by depositing the ink onto the surface.

4. The system of claim 3, wherein the ink comprises a white ink.

5. The system of claim 1, wherein:

the non-linear pathway crosses itself and the mark is a multi-layered mark; and the software configures the end effector to print the multi-layered mark on a stationary surface.

6. The system of claim 1, wherein:

the non-linear pathway passes through a multi-dimensional space; and

the software configures the end effector to move along the non-linear pathway through the multi-dimensional space.

7. The system of claim 1, further comprising one or more collision sensors, wherein the software receives topographical data of a surface from the collision sensors and configures the end effector to:

print the mark on the surface; and

avoid a collision with the surface.

8. The system of claim 1, further comprising a robotic arm, wherein:

the end effector is affixed to the robotic arm; and

the software controls movement of the robotic arm.

9. A system for painting a multi-layer mark on a surface, the system comprising:

an end effector; and

software that, when run on a processor:

transforms a creator input into computer executable painting instructions; based on the painting instructions configures the end effector to paint a multi-layer mark on a surface;

wherein:

the creator input comprises a plurality of sub-inputs; and

the system transforms the creator input into computer executable painting instructions by recording each sub-input as a layer of the multi-layer mark.

10. The system of claim 9, wherein the end effector is an output end effector, the system further comprising an input end effector that is manipulatable in a multi-dimensional space by a creator to generate the artistic input.

11. The system of claim 9:

the end effector comprising one or more sensors that track a position and/or movement of the end effector relative to the surface; and

the software configures the end effector to paint the multi-layered mark onto the surface independent of the position and/or movement of the end effector relative to the surface.

12. The system of claim 9, wherein the software adds a tunable level of noise to the artistic input before painting the multi-layered mark on the surface.

13. The system of claim 9, wherein the computer executable painting instructions comprise:

a property of the surface;

a property of paint applied by the end effector to the surface; and a non-linear path of the end effector over the surface, the non-linear path determined based on the property of the surface and the property of the paint.

14. The system of claim 9, further comprising an XYZ gantry that moves the end effector over the surface;

wherein, movement of the XYZ gantry is controlled by the software.

15. A method for painting a mark along a non-linear pathway, the method comprising:

receiving electronic input data comprising the mark and the non-linear pathway; and

based on the electronic input data, generating:

paint properties associated with a medium deposited by an end effector on a surface;

motion properties for moving the end effector along the non-linear pathway over the surface

based on the paint and motion properties, electronically controlling the end effector and painting the mark along the non-linear pathway on the surface;

wherein;

the electronic input data comprises a repeating pattern; and

painting the mark comprises painting the repeating pattern along the nonlinear path.

16. The method of claim 15 wherein electronically controlling by the end effector comprises electronically controlling:

movement of the end effector along the non-linear pathway; and the medium deposited by the end effector on the surface during the movement.

17. The method of claim 15, wherein the electronic input data comprises a flat image, the method further comprises:

segmenting the flat image into layers;

for each layer, generating:

paint properties associated with the medium deposited by the end effector to paint the layer; and

motion properties for moving the end effector over the surface to paint the layer; and

based on the paint and motion properties associated with the layer, electronically controlling the end effector and painting the layers on the surface,

wherein, painting the layers on the surface generates a visual effect that is different from the painting the flat image on the surface.

18. The method of claim 15, further comprising:

detecting a change to the mark after the mark is painted by the end effector on the surface;

based on the change, generating properties for reproducing the change; and based on the properties associated with the change, electronically controlling the end effector and painting the change on the surface.

19. The method of claim 18 wherein the electronic input data is first electronic input data, the method further comprising:

using the one or more sensors, capturing second electronic input data corresponding to the change; and

generating the properties of the change based on computing differences between the first electronic data and second electronic data.

20. The method of claim 15 further comprising adding a tunable level of noise to the electronic input data before painting the mark along the non-linear pathway on the surface; wherein, the tunable level of noise generates a visual effect that is different from the painting of the mark without adding the tunable level of noise.

21. A painting machine comprising:

a moveable mounting system;

an end effector coupled to the mounting system; and

software configured to:

receive electronic input data defining a target color and transparency; and control movement of the mounting system such that the end effector paints overlapping marks on a surface to provide the target color and transparency.

22. The painting machine of claim 21 wherein the end effector is coupled to:

a receptacle for receiving paint and/or ink; and

a conduit for delivering the paint and/or ink from the receptacle to the end effector.

23. The painting machine of claim 21 wherein the end effector comprises one or more of the following tools:

a paint brush;

an air brush;

a paint roller;

a scraper;

a cutting tool; and

an applicator configured to apply a liquified substance, the liquified substance comprising a polymer, a resin, a plastic, a rubber, a composite, and/or a metal.

24. The painting machine of claim 21 wherein:

the end effector comprises an inkjet head having two or more nozzles; and the software is configured to control each nozzle to paint the overlapping markings on the surface.

25. The painting machine of claim 21, wherein the software is further configured to control movement of the mounting system such that the end effector paints the overlapping markings on the surface at a speed that is faster and/or slower than a speed defined by the electronic input data.

26. The painting machine of claim 21, wherein the mounting system is moveable over the surface such that the end effector is configured to paint the overlapping marks on the surface while the surface remains stationary.

27. The painting machine of claim 21, wherein the mounting system is configured to maneuver the end effector at speeds and/or with motions outside a range of humanly capable speed and/or motion.

28. The painting machine of claim 21, wherein the software is configured to:

register a position of the end effector relative to a first mark painted on the surface; and

based on the position, align the end effector to paint a second mark on the surface.

29. The painting machine of claim 21, the painting machine further comprising:

an input tool moveable by a human creator; and

a tracking controller configured to track movement of the input tool; wherein the software is configured to paint the overlapping marks on the surface by controlling movement of the end effector in accordance with the tracked movement of the input tool.

30. The painting machine of claim 21, wherein:

the end effector is releasably coupled to the moveable mounting system; and the software is configured to control a release of paint from the end effector such that the end effector paints the overlapping marks on a surface based on the electronic input data:

when the end effector is coupled to the mounting system; and

when the end effector is decoupled from the mounting system.

31. A painting machine for painting marks on a surface, the painting machine comprising: electronic input data defining a target visual effect based on layering two or more colors on a surface;

a housing;

an end effector affixed to the housing and configured to paint on the surface; a mounting system configured to:

mate with the housing; and

maneuver the end effector to paint the surface along the non-linear path to produce the target visual effect.

32. The painting machine of claim 31 wherein the mounting system is configured to:

move the end effector along any one of three orthogonal axes; and rotate the end effector about a rotational axis.

33. The painting machine of claim 31 wherein the housing is designed to be hand-held by a human.

34. The painting machine of claim 31 wherein the housing is capable of mating with two or more end effectors.

35. The painting machine of claim 31 wherein the mounting system comprises a robotic arm; wherein, the robotic arm is configured to orient the end effector at a position relative to the surface and move the end effector along the non-linear path.

36. The painting machine of claim 31 wherein the mounting system comprises:

at least one electric motor; and

at least one axle rotationally coupled to the electric motor.

37. The painting machine of claim 31, wherein the mounting system comprises a plurality of electric motors, each electric motor that are configured to operate in concert to maneuver the end effector.

38. The painting machine of claim 31, the mounting system further comprising: a first track aligned along a first longitudinal axis; and

a second track aligned along a second longitudinal axis that is oblique or perpendicular to the first longitudinal axis;

wherein the mounting system operates according to a Computer Numerical Control protocol.

39. The painting machine of claim 31, comprising:

one or more sensors that detect a position and/or motion of the end effector relative to a surface;

the end effector is configured to paint marks on the surface that are responsive to the position and/or motion.

40. A painting machine for painting overlapping marks on a surface, the painting machine comprising:

first electronic input data defining:

a first mark, the first mark comprising a first pattern; and

a pathway;

an end effector configured to paint the first pattern on the surface and along the pathway at a first time;

a sensor configured to capture a second electronic input defining a second mark present at a target location along the pathway at a second time;

software code that, when run on a processor:

calculates how to duplicate the second mark; and

configures the end effector to paint the second mark.

41. The painting machine of claim 40, wherein the sensor is embedded in the surface.

42. The painting machine of claim 40, wherein the sensor is embedded in the end effector.

43. The painting machine of claim 40, wherein the sensor is within a medium extruded by the end effector.

44. A system for painting a medium along a vector path, the system comprising:

an end effector configured to apply the medium to a surface;

an circulation subsystem that controls medium pressure and medium circulation using a single pump; and

software and hardware that control movement of the end effector and applying the medium, along the vector path and relative to the surface.

45. The system of claim 44, wherein the ink circulation subsystem comprises a

microcontroller that dynamically controls a meniscus pressure.

46. The system of claim 45 wherein the ink circulation subsystem comprises:

a receptacle; and

a conduit that is configured to carry the further comprising a pump that is configured to transfer the medium from the second receptacle to the first receptacle.

47. The system of claim 45 further wherein the microcontroller adjusts the meniscus pressure in response movement of the end effector.

48. The system of claim 47 further comprising a pressure sensor for monitoring the pressure generated by the pump.

49. The system of claim 44, wherein the software regulates a quantity of the medium applied by the end effector to the surface.

50. The system of claim 44, wherein the end effector comprises one or more of:

an inkjet head;

an airbrush;

a paintbrush; and a paint roller.

51. The system of claim 44 wherein the end effector comprises:

a first inkjet head; and

a second inkjet head;

wherein the first and second inkjet heads are moveable with respect to each other.

52. The system of claim 51, wherein the end effector applies the medium based on pressure applied to the medium and a control signal generated by the software that triggers a change in the pressure.

53. A system for painting a medium along a non-linear path, the system comprising:

an end effector configured to apply the medium to a surface;

a receptacle that holds the medium applied by the end effector; and a conduit comprising:

a first segment that transfers the medium from the receptacle to the end effector; and

a second segment that transfers the medium from the end effector to the receptacle;

a pump that moves the medium through the conduit and maintains a pressure in the conduit;

software that controls movement of the end effector and deposit of the medium, along the non-linear path relative to the surface.

54. The system of claim 53 wherein the pump comprises an Archimedes screw.

55. The system of claim 53 further comprising a valve that regulates a flow of the medium from the receptacle into the conduit.

56. The system of claim 53 further comprising a pressure sensor that detects changes in the pressure in the conduit; wherein the pump is responsive to the changes in the pressure.

57. The system of claim 53 further comprising a filter that allows air to enter the receptacle.

58. The system of claim 53, wherein the receptacle is a first receptacle holding a first medium and the first receptacle is removable from the system and replaceable with a second receptacle holding a second medium.

59. The system of claim 53 wherein the medium comprises a white colored ink.

60. The system of claim 53 further comprising a mixing chamber that mixes a plurality of foundational ingredients to form the medium.

61. The system of claim 53 wherein the pump maintains the pressure during rotation of the receptacle, conduit or end effector.

62. The system of claim 53, wherein the end effector comprises:

an ingress port that allows the medium to enter the end effector; and an egress port that allows the medium to exit the end effector.

63. A system for depositing a medium along an arbitrary vector path, the system comprising:

an end effector configured to apply the medium to a surface;

a housing configured to rotate the end effector;

a receptacle that holds the medium applied by the end effector;

a conduit that transfers the medium from the receptacle to the end effector;

a pump that moves the medium through the conduit and maintains a meniscus pressure in the conduit;

software that controls movement of the end effector and deposit of the medium, along the arbitrary vector path and relative to the surface.

The system of claim 63 the end effector mounted to the housing using an embedded bearing that defines a rotational axis; and

the housing comprising a planetary gear system configured to rotate the end effector about the rotational axis.

65. The system of claim 63 wherein the housing defines a rotational axis and is configured to rotate the end effector 360° about the rotational axis.

Description:
APPARATUS AND METHODS FOR COMPUTERIZED END EFFECTOR MANIPULATION

CROSS REFERENCE TO RELATED APPLICATION

[0001] This application is a nonprovisional of U.S. Provisional Application No. 62/584,909, filed on November 12, 2017, which is hereby incorporated by reference herein in its entirety.

COMPUTER PROGRAM LISTING APPENDIX

[0002] This application includes a computer program listing as an appendix. The appendix includes thirteen (13) ASCII text files.

FIELD OF TECHNOLOGY

[0001] Aspects of this disclosure relate to painting machines for producing layered and textured marks.

BACKGROUND

[0002] Typically, a printer or other output device prints a "flat" image of an electronic file holding a creators input. For example, a creator may utilize a user interface to input creative marks or designs. Such input may include pressure applied by the creator to a tool used by the creator. Other illustrative inputs may include color, path, rotation and/or tilt of the tool handled by the creator. The user interface may create one or more electronic files corresponding to the input of the creator. However, typical output tools are not suitable for reproducing the richness and layering effects of the input. [0003] For example, traditional (e.g., by a human being) painting with a brush may generate irregular and chaotic movements, colors, texture and marks. The brush may be moved (e.g., tilted) by the creator generating changes in viscosity of the color or texture being applied. Such irregularity is compounded when brush strokes cross or overlap each other. Such irregularity may be further compounded when brush strokes of different colors cross each other. Other tools may be associated with other irregularities and chaotic movements/marks, specific to properties of the tool and properties of a surface being worked on by the tool.

[0004] However, when attempting to produce computer generated output based on the creator input, such irregularity is difficult to reproduce. For example, typical printing software/hardware is configured and designed to move in regiments and orderly patterns (e.g., line by line or row by row) and cannot follow irregular or non-linear pathways. Nor can typical printing software/hardware reproduce the irregularities and chaotic elements input by the creator.

[0005] Typical printing software/hardware cannot reproduce sequential marks as recorded by a creator during a painting (digital or traditional) process or an ability to pause during printing to allow for creator supervisory control. Nor can typical printing software/hardware print on non- horizontal or irregularly shaped/contoured surfaces. Typical printing software/hardware cannot print using oil-based or acrylic paints.

[0006] Accordingly, it would be desirable to provide apparatus and methods for computerized end effector manipulation that overcome the technical challenges of layering, reproducing irregularities and chaotic elements input by a creator.

BRIEF DESCRIPTION OF THE DRAWINGS

[0007] The objects and advantages of the disclosure will be apparent upon consideration of the following detailed description, taken in conjunction with the accompanying drawings, in which like reference characters refer to like parts throughout, and in which:

[0008] FIG. 1 shows illustrative apparatus in accordance with principles of the disclosure;

[0009] FIG. 2 shows illustrative apparatus in accordance with principles of the disclosure;

[0010] FIG. 3 A shows illustrative apparatus in accordance with principles of the disclosure;

[0011] FIG. 3B shows illustrative apparatus in accordance with principles of the disclosure;

[0012] FIG. 4 shows an illustrative apparatus and painting scenario in accordance with principles of the disclosure; [0013] FIG. 5 shows illustrative apparatus in accordance with principles of the disclosure;

[0014] FIG. 6 shows illustrative apparatus in accordance with principles of the disclosure;

[0015] FIG. 7 shows illustrative apparatus in accordance with principles of the disclosure;

[0016] FIG. 8 shows illustrative apparatus in accordance with principles of the disclosure;

[0017] FIG. 9 shows illustrative apparatus in accordance with principles of the disclosure;

[0018] FIG. 10 shows illustrative apparatus in accordance with principles of the disclosure;

[0019] FIG. 11 shows illustrative apparatus in accordance with principles of the disclosure;

[0020] FIG. 12 shows illustrative apparatus in accordance with principles of the disclosure;

[0021] FIG. 13 shows illustrative apparatus in accordance with principles of the disclosure;

[0022] FIG. 14 shows illustrative apparatus in accordance with principles of the disclosure;

[0023] FIG. 15 shows illustrative apparatus in accordance with principles of the disclosure;

[0024] FIG. 16 shows illustrative apparatus in accordance with principles of the disclosure;

[0025] FIG. 17 shows illustrative apparatus in accordance with principles of the disclosure;

[0026] FIG. 18A shows illustrative apparatus in accordance with principles of the disclosure;

[0027] FIG. 18B shows illustrative apparatus in accordance with principles of the disclosure;

[0028] FIG. 18C shows illustrative apparatus in accordance with principles of the disclosure;

[0029] FIG. 18D shows illustrative apparatus in accordance with principles of the disclosure;

[0030] FIG. 19 shows an illustrative painting scenario in accordance with principles of the disclosure;

[0031] FIG. 20 shows an illustrative painting scenario in accordance with principles of the disclosure;

[0032] FIG. 21 shows an illustrative painting scenario in accordance with principles of the disclosure;

[0033] FIG. 22 shows illustrative apparatus in accordance with principles of the disclosure;

[0034] FIG. 23 shows illustrative apparatus in accordance with principles of the disclosure;

[0035] FIG. 24 shows illustrative apparatus in accordance with principles of the disclosure;

[0036] FIG. 25 shows illustrative apparatus in accordance with principles of the disclosure;

[0037] FIG. 26 shows illustrative apparatus in accordance with principles of the disclosure;

[0038] FIG. 27 shows an illustrative process in accordance with principles of the disclosure;

[0039] FIG. 28 shows an illustrative process in accordance with principles of the disclosure; and

[0040] FIG. 29 shows illustrative apparatus in accordance with principles of the disclosure. DETAILED DESCRIPTION

[0041] Apparatus and methods for a painting machine and associated painting systems are provided. The painting machine, as described herein, may provide larger degrees of freedom and creative control over the introduction of irregular, chaotic, or simply less predictable, mark making, when producing output based on creator input.

[0042] The painting machine may provide flexible tools for creators, including human creators, to create works dictated by their own vision, motor habits and experimental processes. The painting machine described herein may free creators, including human creators, from constraints imposed by "stylistic" components of other automated painting tools.

[0043] For example, the painting machine may not be constrained by specific algorithmic process for translating digital files into painted form. Such algorithmic processes may include processes for deconstructing a digital image based on algorithmic patterns and/or predetermined brush types/strokes. Such algorithmic processes typically do not provide a machine generated output that embodies stylistic components of the creator. The painting machine is not constrained by end effector limitations that may force a specific "stylistic" output. The painting machine may produce output that reflects a stylistic input of a creator.

[0044] To produce output that reflects a stylistic input of a creator, the painting machine may use custom ink and grounds (coatings on substrate) to control drying time and visual effects

(blurring, dissolving, spreading, dripping, etc.) of marks produced by the painting machine. The painting machine may provide an ability to mix (wet or dry) desired materials.

[0045] The painting machine may incorporate human feedback into the machine output process.

The painting machine may record a creator input process, whether executed digitally or physically, including creator changes applied to a machine output. The painting machine may recreate the creator input, including creator changes applied to a prior machine output.

[0046] The painting machine may paint raster images in non-linear fashion, as dictated by creator input. The painting machine may produce marks that equivalent to a brush type. A brush type may include a traditional brush type. A brush type may include a virtual brush, such a brush created using Adobe Photoshop available from Adobe Inc. of San Jose, California.

[0047] The painting machine may allow for a dynamic process using raster and vector processes to adjust, correct, and paint digital images or other creator input. For example, the painting machine may provide for printing an image (or other mark) in raster form and then choosing a digital paint brush and virtually painting over a digital image of the printed mark (or choose other items to overlay on the printed image) and then paint, in reality, the painting (as input using the digital brush) over the previously printed image.

[0048] For example, the painting machine may produce a pattern that produces a mark by emulating an effect of a specific brush type on a specific surface. The painting machine may paint a desired section of an image using a desired brush type and associated strokes (as defined by a creator). The painting machine may produce output may overlaying marks on raster images, randomly selecting areas to reprint in linear or non-linear fashion, selecting discreet elements to layer in any order (e.g., masked items, colors, shapes) - all as defined by a creator.

[0049] A painting machine may utilize a combination of process and spot color. For example, process color may be used for underneath layers or areas of great detail. Spot colors may be used for recreating the effects of traditional painting (layering colors) and offset or screen printing (individual color separation layered for final effect). The painting machine may control opacity/transparency of each color by including white mixed with any other color and determining an impact of mixing white with other colors.

[0001] Output of the painting machine may be controlled by a creator's desired aesthetic criteria even when the desired aesthetic criteria are defined by complex multi-sensory movements or handling of traditional tools (brushes, markers).

[0002] Output of the painting machine may include painting with curable inks to achieve layered effects associated with traditional painting. For example, the painting machine may produce an output that provides a desired visual effect (e.g., relative transparency) due to a build-up of colors on a specific surface topology. The paint machine may utilize using high volume ink delivery (e.g., 150-5000 microns or above) and curable (e.g., by ultraviolet light) inks. The painting machine may provide translation of, or parsing of, digital input to paint all or some of the digital input as discrete marks, as raster images or as recreated as tool paths with the corresponding printed pattern or brush style.

[0003] The painting machine may include custom software. The custom software may be configured to receive electronic input data. The electronic input data may be generated by a creator. The creator may be any living being. The creator may be a human. The creator may be a machine. The creator may generate the electronic input data by making irregular and chaotic movements using a variety of colors, texture and marks.

[0004] The electronic input data store one or more properties that define the creator input. The creator input may include one or more marks generated by the creator. Two or more marks may overlap each other. Illustrative properties may include color, tool used to generate a mark, path/curve data, layer and mask information, patterns, gradient, brightness, contrast and filters applied. Color may include CMYKW (cyan, magenta, yellow, black and white) settings, hue/saturation or any custom color palette. The path/curve data associated with a mark may be defined by pixels and/or vectors.

[0005] Illustrative properties of a tool used by a creator may include thickness of brush bristles, number of bristles, size of brush, line thickness, path/motion of the tool as the mark was being generated and orientation of tool as the mark was being generated.

[0006] Custom software may control an end effector to produce output based on properties of the electronic input data. For example, illustrative output may include ink or color applied by the end effector that adheres to a surface with specific properties. The custom software may control the end effector such that ink is dispersed on the surface and/or builds-up on the surface. The custom software may control different end effectors in different ways depending on the properties of the electronic input data, type of ink/paint being used, type of surface receiving the ink/paint or any other variable.

[0007] The custom software may control the end effector such that marks are painted on a first side of a surface and the marks produce a desired visual effect on a second side of the surface. The first and second sides may be opposing sides of the surface.

[0008] The painting machine may receive electronic input data that includes vector and/or raster based images, commands and/or files. Illustrative electronic input data may include files generated using raster graphics editors such as Adobe Photoshop, available from Adobe Inc. of San Jose, California.

[0009] Illustrative electronic input data may include files generated using vector graphics editors such as CorelDRAW, available from Corel Corporation of Ottawa, Canada. Vector based approaches may simulate motion of a human hand and create output effects that simulate the "look and feel" of marks produced by a human hand. [0010] Mechanically, and through the custom software, the painting machine may produce output having varying degrees of "controlled chaos" within prescribed mark making. For example, the custom software may interrupt a tight confinement of marks along a highly defined set of parameters.

[0011] Other examples of controlled chaos that may be produced by the painting machine and its associated custom software include producing output that includes a desired effect such as watercolor effects (e.g., dispersion) using a print head, blur effects, tightening or loosening edges and adding noise.

[0012] These effects may be visual to the human eye. These effects may not be visual to the human eye. These effects may be visible to the human when applied to the surface in a threshold number of marks. These effects may be produced based on digital manipulation from within custom software, or by introducing mechanical anomalies to movement of an end effector along its projected path. These effects may be produced by (dynamically) moving the end effector longitudinally along the z axis, (dynamically) rotating the end effector about the z axis, misfiring nozzles of a print head, adding air current to a print head, applying custom coatings to disturb the ink after it has been applied to a surface, applying vibrations as ink is being applied to a surface and/or after it has been applied to the surface. These impacts may be produced by utilizing any signal (e.g., noise function, sensor data, such as pre-defined file, feedback, etc.) to alter one or more properties of electronic input data and corresponding movement of an end effector.

[0013] The painting machine may include an end effector. An end effector may be affixed or otherwise coupled to a robotic device that moves the end effector relative to the surface.

Generally, an end effector may include a terminal end of a device designed to interact with the environment.

[0014] Illustrative end effectors may include an inkjet head, brush, air brush or any suitable tool for applying ink, paint, color and/or texture to a surface. Illustrative print heads include Toshiba CFIB and the Toshiba CFIBXL. Illustrative airbrush end effectors include Iwata-Medea Eclipse HP BCS Dual Action Bottle Feed Air Brush ECL 2000.

[0015] An end effector may be configured to apply oil-based ink or ultraviolet-cured ink to a surface. An end effector may spray/diffuse a medium. An end effector may apply a medium that is neither paint nor ink. For example, an end effector may apply a chemical for priming a surface or thinning paint (e.g., an alcohol). [0016] A surface may include any desired surface for receiving color and/or textures generated by a creator. Illustrative surfaces may include canvas, paper, brick and glass.

[0017] The custom software may include a user interface. The user interface may receive and/or generate electronic input data. For example, the user interface may provide tools for generating creator input. Such tools may include digital masking tools and fill commands for prescribed areas of a surface. The user interface may allow a creator to instruct the end effector to produce: repeatable patterns, image fragments, algorithmic mark making and/or output that mimics human movement.

[0018] The user interface may allow a creator to reprogram electronic input data (e.g., Photoshop or similar files) to output sequential marks as recorded during a digital painting process. The user interface may allow a creator to switch between real-time control over the painting machine for producing the output or using the painting machine to record creator input for later output. The user interface may allow a creator to pause production of painting machine output and allow for human supervisory control. Human supervisory control may include changing or otherwise manipulating marks produced by the painting machine. Such changes may be recorded by the painting machine as electronic input data.

[0019] Multiple changes may occur simultaneous or in sequential order. For example, two or more humans or machines may change or otherwise manipulating marks produced by the painting machine. The two or more humans or machines may be collaborating or merely working at the same time but not in collaboration.

[0020] The painting machine may include a mounting system. The mounting system may be designed to move the end effector. The mounting system may be designed to move multiple end effectors. The mounting system may be designed to move an end effector over different types of surfaces. The end effector may be affixed to the mounting system.

[0021] The mounting system may move the end effector across any suitable surface in any orientation. For example, the mounting system may include wall mounted tracks. Other embodiments of the mounting system may include flying apparatus, such as drones and other mechanisms (or combinations thereof) for effecting movement of an end effector, such as tracks, treads, legs, etc.

[0022] A mounting system may be designed for moving multiple end effectors. A mounting system may be designed for a specific use case. Different use cases may include different surfaces, different mediums, different digital simulation tools (on the user interface), different translation software between the interface used to create the electronic input data and properties of the end effector. Such properties may include thickness of bristles, number of bristles, size of brush, aperture size of a nozzle or any suitable requirement or capability of the end effector.

[0023] Embodiments may include mechanisms (hardware and associated control software) for moving an end effector relative to a target surface in any suitable direction. Such a mechanism may allow the end effector(s) to move in any suitable direction relative to the target surface. Exemplary movements may include pan, tilt, truck, dolly, follow, pedestal or orienting the end effector in any suitable position with respect to the surface.

[0024] Embodiments may include mechanisms (hardware and associated control software) for moving the surface relative to the end effector. Embodiments may include mechanisms (hardware and associated control software) for moving both the end effector and the surface.

[0025] The custom software may control operation of the mounting system. The custom software may control operation of the mounting system such that the end effector outputs or paints a mark on the surface in the way the mark was generated by the creator. A mark output by an end effector may include any suitable effect on a surface. A mark may be visible to a human eye. A mark may not be visible to the human eye. A mark may include a point, a line, a brush stroke or an entire painting. The painting machine may generate marks are different from "flat" images printed by conventional devices.

[0026] The custom software may provide the painting machine with specific functionality and design elements for painting, tracing, coating and/or plotting. For example, based on the electronic input file, the custom software may control movement of the end effector to generate a mark that replicates motions of the creator when the creator generated the mark. Motions of the creator may be defined as one or more properties of a mark in the electronic input data.

[0027] The end effector may include a brush. The mounting system may be configured to move the brush in any suitable manner. For example, a brush may include a number of bristles, each bristle have a specific thickness. The mounting system (as controlled by the custom software) may be configured to move the brush to leverage any suitable characteristic of the brush when painting on the surface. The mounting system may be configured to tilt the brush or alter a speed/acceleration at which the brush moves across the surface. [0028] The mounting system may dip the brush into paint to obtain a target amount of paint. The target amount of paint may be specified in the electronic input data. The target amount of paint may be determined by the custom software based on one or more properties of the mark, as defined in the electronic input data.

[0029] The end effector may include an airbrush. The custom software may be configured to control movement of the mounting system and end effector based on specific property of the end effector. The custom software may control movement of the mounting system and end effector to paint marks as defined by non-linear pathways defined within the electronic input data. The custom software may be configured to control movement of the mounting system and end effector to paint an overlapping mark as defined by non-linear pathways defined within the electronic input data. A non-linear pathway may include a linear segment, single and multidimensional pathways.

[0001] The electronic input data may define marks based on properties of a specific artist tool used to create the mark. For example, the electronic input data may include properties such as orientation of an airbrush with respect to a surface, a viscosity of paint applied by the tool and/or a color of the paint applied by the tool. The custom software may configure the mounting system and/or end effector to produce a mark based on properties of the specific artist tool. Based on the one or more properties stored in the electronic input data, the custom software may configure end effector to produce a mark that visually appears to have been traditionally (e.g., by hand) painted by an artistic tool.

[0002] For example, output generated by the painting machine may be textured. Output generated by the painting machine may include marks produced by moving the end effector along a non-linear pathway over a surface.

[0003] A non-linear pathway may cross itself and the painting machine may follow the nonlinear pathway to generate a mark that included two or more layers (e.g., an "overlapping mark").

[0004] The painting machine may generate output that includes irregular and/or chaotic markings. The irregular and chaotic markings may provide an output that is different from marks produced using conventional printer software/hardware. For example, a marks produced by the painting machine may be indistinguishable, to a human eye, from marks produced by creators using traditional painting techniques. In some embodiments, marks produced by the painting machine may appear different, to a human eye, from marks produced by creators using traditional painting techniques and different from marks produced using conventional printer software/hardware .

[0005] For example, the custom software may be configured to add random noise to the electronic input data. The custom software may configure the end effector to deposit marks on a surface based on merging the electronic input data (or properties included in the electronic input data) and the random noise. Marks generated by the painting machine may appear (when observed by a human eye or analyzed by a computer algorithm) to include a known style of a creator. The random noise may be configured to retain the known creator style and provide a noticeable visual change (when observed by a human eye or analyzed by a computer algorithm) to one or more marks generated by the creator and stored in the electronic input data.

[0006] The known creator style may include a signature painting style associated with a human artist. For example, a creator style may include signature movements or visual effects of a known human artist. The known creator style may include colors associated with a human artist. The creator style may include a visual effect on a surface recognized as being associated with the human artist. The creator style may include any suitable recognizable characteristic of works produced by a creator. The electronic input data may store one or more properties that define the creator style.

[0007] The end effector may include a print head. A print head may be an inkjet head. Generally, a print head refers to devices that deposit droplets of ink (or any other medium) from one or more embedded nozzles to produce a mark on a surface. An exemplary print head may include a digital controller which determines how and when to fire each nozzle of the print head.

[0008] A print head nozzle may direct ink, paint or any other medium onto a surface. Release of the medium by the nozzle may be controlled by the custom software. For example, the custom software may intentional misfire a nozzle to create a desired visual effect on the surface. For a given set of properties in the electronic input data, the custom software may generate a paint plan for producing output based on the set of properties. The paint plan may also account for a particular surface and a particular medium that will deposited on the surface by the end effector.

[0009] Generating a paint plan may include "slicing" a mark defined by the electronic input data into bands. Each band may be the width of the end effector (e.g., an inkjet head) or thinner. Such a slicing process may be referred to as raster image processing ("RIP"). Paint planning may include plotting motion of the end effector based on limits of the painting machine. Paint planning may include plotting motion of the end effector such that a target region on the surface to be painted will be traversed by the end effector.

[0010] Paint planning may include plotting motion of the end effector such that the medium deposited by the end effector onto the surface will be deposited on target locations on the surface to form the intended mark.

[0011] Paint planning may include plotting motion of the end effector such that the medium deposited by the end effector is arranged on the surface in a pattern that best approximates target properties for the mark in the electronic input data. In the context of inkjet or other printer heads, this process may be generally known as "dithering."

[0012] However, unlike conventional dithering, the custom software may calculate an arrangement of end effector output needed generate a multi-layered mark along a non-linear pathway. A multi-layer mark may produce a desired visual effect (e.g., to a human eye) that includes color, texture, shape or any other suitable property that may be generated by traditional, free-hand painting.

[0013] The custom software may generate a paint plan such that output of the end effector produces a visual effect defined based on properties of the electronic input data. Paint planning may also include plotting motion of the end effector such that a target density of the medium deposited by the end effector (e.g., dots per inch) is achieved.

[0014] Paint planning may include a generating color plan for the mark. The color plan may include using spot color to produce a desired output. The color plan may include using process color to produce a desired output.

[0015] Paint planning may include utilizing a combination of process and spot color. For example, process color may be used for underneath layers or areas of great detail. Spot colors may be used for recreating the effects of traditional painting (layering colors) and offset or screen printing (individual color separation layered for final effect).

[0016] The custom software may perform motion planning. Motion planning may include generating a motion plan and motion control instructions to implement the motion plan. Motion planning may include generating motion control instructions for moving the end effector and painting a mark on the surface. The motion control instructions may implement the paint plan. Motion control instructions may be transmitted to a motion controller. The custom software may include the motion controller.

[0017] The motion controller may be implemented in firmware. The motion controller may interpret motion commands from motion plans generated by the custom software. Based on the motion commands, the motion controller may execute the commands and drive one or more motors. The firmware may run on an embedded device in the painting system. The motion controller may be included in a mounting system, end effector or any other suitable component of the painting system or machine.

[0018] Motion control instructions may be generated by a motion controller. The motion controller may generate signals necessary to physically move the end effector across a target region of the surface. The signals may include low-level signals. Low level signals may include signals that are directly understandable by hardware of the end effector and/or mounting system.

[0019] The motion controller may monitor real-time movement of the end effector. The motion controller may adjust real time movement of the end effector based on the motion control instructions. For example, the motion controller may trigger synchronization signals transmitted to the end effector. The motion controller may generate synchronization signals at appropriate times so that the end effector deposits medium on the surface on a timeline that matches movement of the end effector over a surface.

[0020] For example, the end effector may include an inkjet printer head. The inkjet head may include one or more nozzles that control release of a medium stored within the inkjet head. Each nozzle may be moveable. A nozzle may release medium in response to receiving an electrical signal.

[0021] The custom software may trigger an electrical signal that causes a nozzle to release a target amount of the medium. The custom software may trigger an electrical signal that causes a nozzle to release a target amount of the medium at a target time. The target time may be any time along a timeline associated with movement of the end effector over the surface. Each nozzle in a print head may be independently controllable to release medium. Each nozzle may be independently moveable.

[0022] Apparatus may include a painting subsystem. The custom software may include one or more aspects of the painting subsystem. The painting subsystem may convert paint planning output into instructions that are understandable by the end effector hardware. When the end effector is a print head, the painting subsystem may generate a "firing pattern" for nozzles of the print head to release medium as the end effector moves across the surface (in accordance with the motion control instructions).

[0023] The painting subsystem may account for specific features of a print head such as nozzle size, number of nozzles and chemical properties of the medium. The painting subsystem may monitor and receive status information from end effector hardware. The painting subsystem may provide an interface for accessing low-level configuration settings of end effector hardware. The painting subsystem may provide an interface for accessing low-level configuration setting of mounting system hardware.

[0024] The painting subsystem may manage transfer/buffering of data through each level of end effector control hardware. End effector control hardware may include mechanical components needed to move an end effector or release medium from the end effector. Exemplary end effector control hardware for a print head may include a print controller card ("PCC"). A PCC may be described as a "printer's motherboard." An example of an illustrative PCC is model number PCC-E 2941-5210 Rev J.

[0025] An exemplary PCC may include hardware that accepts print data received over a network. The PCC may include hardware for passing the paint plan data to a head driver card ("HDC"). The HDC includes hardware that manages one or more print heads. The HDC supplies specific power requirements of a print head and implements low level digital control protocols needed to drive operation (e.g., firing of nozzles to release medium) of a print head. An example of an illustrative HDC is model number HDC-4CF 2941-5300 Rev B.

[0026] End effector control hardware may include a microcontroller. The microcontroller may receive data from one or more pressure sensors. A pressure sensor may monitor pressure in a conduit that carries ink or any other medium from a reservoir to a print head. The pressure sensor may monitor positive pressure (relative to atmospheric pressure). The pressure sensor may monitor negative pressure (relative to atmospheric pressure).

[0027] A pressure sensor may monitor pressure in a conduit that carries ink or any other medium from a print head to a reservoir. The pressure sensor may monitor positive pressure (relative to atmospheric pressure). The pressure sensor may monitor negative pressure (relative to atmospheric pressure). [0028] The microcontroller may receive pressure data from two or more pressure sensors. Based on the pressure data received from pressure sensors, the microcontroller may trigger an appropriate voltage to be applied to a pump that maintains a target pressure in an ink circulation system. The target pressure may be a target meniscus pressure. Meniscus pressure may be determined, based on pressure at an ink inlet port of the print head (relative to the atmospheric pressure), and pressure at an ink outlet port of the print head relative to the atmospheric pressure.

[0029] The microcontroller may include a button that initiates a purging process of the print head. The microcontroller may include a button that powers on the print head. The microcontroller may include a button that powers off the print head. Powering off the print head may include shutting down the pump. Powering off the print head may include closing a valve that prevents ink from leaking out of the print head when the pump is shut down.

[0030] The PCC or HDC may include the microcontroller.

[0031] Methods for robotic painting are provided. Methods may include painting a mark by depositing color on a surface. The mark may be deposited on the surface by a machine, without - i.e., independent of— human intervention. Methods may include receiving electronic input data. The electronic input data may include input generated by a creator. The electronic input data may include one or more digital files.

[0032] The electronic input data may include one or more properties of one or more marks. The properties may include color data, pressure applied data, brush type data and path data. The properties may include relationships between one or more marks. For example, a mark may be defined by layering two or more marks at a target location on a surface.

[0033] Methods may include transmitting electronic control commands to an end effector. The end effector may be controlled by custom software running on a computer system. The electronic commands may direct the end effector to reproduce a mark based on the properties of the creator input file. Methods may include, in response to receiving the electronic control commands, moving the end effector in a fashion that traces path data stored in the electronic input data. Methods may include, using the end effector, depositing marks onto a surface such that the deposited marks produce a mark defined by properties in electronic input data.

[0034] For example, the end effector may produce a mark having color as defined in the electronic input data. The end effector may produce a mark by applying pressure to a surface as defined in the electronic input data. The end effector may produce a mark that looks like it was produced by a brush type defined in the electronic input data. Methods may include producing a mark by extracting one or more properties from the electronic input data and generating a set of control instructions that direct the end effector to produce a mark based on mimicking steps taken by a creator to generate the electronic input data.

[0035] Methods may include moving the end effector and depositing medium on a surface such that the deposited medium builds up on the surface. Methods may include moving the end effector and depositing medium on the surface to generate a three dimensional ("3D") mark on the surface.

[0036] Methods may include moving the end effector and depositing medium on a surface such that the deposited medium provides a visual effect of the mark defined by the properties in the electronic input data. For example, methods may include depositing medium on the surface that provides a perception of a three dimensional mark.

[0037] Methods may include generated and painting 2.5 dimensional ("2.5D") marks. 2.5D marks (which may include images or other visual scenes) refers to marks that are composed of layers. Such 2.5D marks may appear "flat" but are actually composed by minutely layered elements that may be difficult to detect with the human eye or even with diagnostic tools.

[0038] The 3D appearance may be generated by a shape of a mark, shading or other graphical simulations that the software calculates and are deposited by the end effector on the surface. The custom software may account for a texture or other features of the surface. For example, the surface may be a specific color, include protrusions and/or depressions. Methods may include producing 2.5D and 3D marks on a surface.

[0039] The custom software may account for a vantage point of a target viewer. For example, the surface may include a billboard that is viewed by highway drivers. The custom software may calculate how to deposit medium on the surface such that marks deposited by the end effector on the surface, collectively, provide a target visual impression to the target viewer.

[0040] The custom software may change/manipulate resolution, layering effects and mark thickness based on a marks expected distance from a viewer (e.g., in large public spaces) and lighting effects, surface variability and viewing the mark through (or on) a glass surface. The custom software may configure the end effector to produce a tangible output that provides a target visual impression to a viewer from a target vantage point. [0041] Methods for depositing liquid paint on a surface are provided. Methods may include receiving, at a computing device, a user-input command. The user-input command may include a color. The user-input command may include a three-dimensional shape. The user-input command may include a brush type.

[0042] A brush type may include any traditional brush type. Such brush types include: fan, oval wash, sword, angle, flat, bright, filbert, rigger, and/or round. A brush type may include a custom or virtual brush type. For example, a customized brush type may be designed using Adobe Photoshop software. Customized brushes may include adjustable characteristics. Exemplary characteristics include hardness, diameter, roundness, spacing, angle, flip axis, jitter, scattering, pressure, texture, opacity and many others. A brush type may be created to produce a desired visual effect.

[0043] The user-input command may include a mark type. The user input command may include electronic input data. The color, three-dimensional shape, brush type and mark type may be properties of the electronic input data.

[0044] Methods may include transmitting, to a painting machine, the user-input command. In response to receiving the user-input command, methods may include moving a painting module. The painting module may be moved "free hand" by a human artist. The paint module may be moved along a support. The painting module may include a receptacle. The painting module may include an end effector. The painting module may include a mounting system for moving the end effector. The painting module may include custom software for controlling movement of and output of the end effector.

[0045] The receptacle may be configured to hold liquid paint. The receptacle may be configured to release targeted amounts of the liquid paint. The targeted amounts of liquid paint may be applied, by an end effector, to a surface. The painting module may include a pump that moves the liquid paint out of the receptacle. In some embodiments, the end effector may be moved along the support and the receptacle may remain stationary. The receptacle may be fluidly linked to the end effector via a conduit.

[0046] Methods may include ejecting or otherwise transferring liquid paint from the receptacle and onto a brush or other suitable end effector. The brush may be associated with the bush type. [0047] The moving of the end effector and ejecting of the liquid paint as the end effector moves may form a mark on the surface. The mark may be a three-dimensional shape. The three- dimensional shape may be formed, at least in part, based on the mark type.

[0048] Apparatus for a system that paints a mark are provided. "Painting" may include any method or apparatus for making a mark on a surface. For example, painting may include printing a mark using a print head. Painting may include etching a mark into a surface.

[0049] The system may paint a mark along a non-linear pathway. The non-linear pathway may include a curved pathway. The non-linear pathway may include straight line segments. The non-linear pathway may overlap itself.

[0050] The system may include an end effector for painting onto a surface. The system may include software. The software may be run on a processor. The software, when run on the processor, may capture electronic data. The electronic data may include one or more properties of the mark. Illustrative mark properties may include color, pressure, type of artistic tool, orientation of the artistic tool (e.g., with respect to a surface), properties of the artistic tool (e.g., number of bristles) and speed at which the artistic tool moves along the non-linear pathway.

[0051] Properties within the electronic input data may define the non-linear pathway. For example, the electronic input data may include linked data structures that define the non-linear pathway. The linked data structures may include a graphical data structure that includes nodes, and edges linking the nodes. The electronic input data may include vectors that define the nonlinear pathway.

[0052] The system may configure the end effector to produce a mark by following the non-linear pathway. The end effector may produce the mark by depositing ink or any other medium onto a surface while following the non-linear pathway.

[0053] The end effector may include an inkjet head. The system may include ink or any other medium suitable for producing marks on a surface. The ink may be a white ink. The ink may be comprised of particles that are small enough to pass through one or more nozzles in the inkjet head. A nozzle may have an open state and a closed state. The particles may be small enough to pass though the nozzle (and onto the surface) when a nozzle is in the open state. The particles may be large enough to be retained within the inkjet head when a nozzle is in the closed state.

[0054] Apparatus and methods may include custom inks/paints. Such custom inks may include white colored ink. White ink may be mixed with other colors and applied at any level of opacity/transparency. Conventional printers typically work transparently, using the white of the surface as the white color instead of white ink. Using conventional printers, colors, when layered, can only get progressively darker. Conventional printers that do use white ink use process color (CMYK) and introduce white ink via a separate channel. Such use does not allow the white ink to be combined/layered with other colors to build light colors over darker colors.

[0055] Custom ink/paint may be created using oil. A medium may include custom inks/paints that are UV curable. A medium may be created to have a target drying time. For example, the target drying time may allow a creator to manipulate the ink after being deposited on a surface by an end effector. The target drying time may range from minutes to months after ink is deposited on the surface.

[0056] The custom software may control an opening/closing of nozzles in the inkjet head. The custom software may control an opening/closing of nozzles in the inkjet head as the inkjet head follows a non-linear pathway. The non-linear pathway may cross itself.

[0057] The end effector may be configured to paint by depositing the ink onto a surface. The software may configure the end effector to generate a multi-layered mark. The end effector may generate the multi-layered mark by depositing ink along the non-linear pathway.

[0058] The custom software may configure the end effector to paint a mark (multi layered or single layered) on a stationary surface. The software may configure the end effector to paint a mark (multi layered or single layered) on a moving surface. The custom software may control movement of the surface. A mounting system may move the surface.

[0059] The non-linear pathway may pass through a multi-dimensional space. The multidimensional space may include 2, 3, 6 or more dimensions. The software may configure the end effector to move along the non-linear pathway and through the multi-dimensional space.

[0060] Dimensions may include an orientation and/or position of the end effector with respect to the surface. For example, the end effector may include a paint brush. The paint brush may define a longitudinal axis (e.g., defined by a ferrule, handle or belly of the brush). Different orientations of the longitudinal axis with respect to the surface may produce different marks on the surface. For example, different orientations of the brush with respect to the surface may produce marks having different textures, paths, appearance (e.g., transparency/opacity) or color.

[0061] The system may include one or more sensors. The sensors may detect when an end effector is approaching a change in surface contour. The custom software may receive topographical data of a surface from the sensors. Based on the topographical data, the custom software may configure the end effector to paint a mark at a target location on the surface and avoid a collision with the surface.

Illustrative sensors may include a depth/di stance sensor. Such a sensor may be an infrared or ultrasonic distance sensor that provides a one-dimensional measurement of distance from the end effector to the surface. The system may include LIDAR sensor. LIDAR sensors operate using the principles of radar and use light from a laser. LIDAR sensors may generate a 2D depth-map of a surface, capturing textural data for reintegration into the painting/control system.

[0062] The system may include a robotic arm. The end effector may be affixed to the robotic arm. The custom software may control movement of the robotic arm. An illustrative robotic arm may include a KR 16 robotic arm manufactured by KUKA Aktiengesellschaft of Augsburg, Germany. Low-level control of the KR 16 robotic arm may be accomplished using control software provided by Haploid LLC of Brooklyn, New York. The custom software may communicate control signals to the KR 16 via the low-level control software provided by Haploid LLC. The custom software may generate control signals based on paint and motion plans associated with a mark.

[0063] An illustrative robotic arm may include a UR5 robotic arm manufactured by Universal Robots A/S of Odense, Denmark. Custom software may control an end effector affixed to the UR5 for painting applications.

[0064] Custom software may interface with V-REP robot simulation applications provided by Coppelia Robotics GmbH of Zurich, Switzerland. For example, the custom software may synchronize a UR5 robotic arm with simulated motion of the UR5 robotic arm that occurs within a V-REP robot simulation application. The custom software may utilize inverse kinematics, motion planning, and physics simulation capabilities provided by the V-REP robot simulation application to drive painting motion of an end effector affixed to the UR5 robotic arm.

[0065] Custom software may include a real time control system for controlling movement of a robotic arm. Such control software may be based on open source work available in the Robot Operating System (ROS) project.

[0066] For example, custom software may configure a UR5 robotic arm by loading code into the UR5's controller. The custom software may include a messaging system that runs on top of the V-REP robot simulation application. The messaging system may use V-REP's built-in scripting functionality. The messaging system may drive the UR5 robotic arm based on a simulated motion that occurs within the V-REP robot simulation application.

[0067] The messaging system may also be used to drive a simulation within the V-REP application based on control instructions provided to the UR5's controller.

[0068] Illustrative custom software applications may configure a robotic arm to paint interactively based on a pen digitizer input. The pen digitizer may be received from a creator. Custom software may include painting applications for robotic arms developed using open source Processing environment and the Java programming language.

[0069] The custom software may include computer code that runs in the V-REP robot simulation application. Such code may be developed using the Lua programming language. The custom software may include applications that are run external to the V-REP robot simulation application. Such code may be developed using the Python programming language.

[0070] Additional open source libraries that may be used to develop applications for painting with a robotic arm such as the UR5 robotic arm are available at https://github.com/artmatr- engineering.

[0071] Apparatus may include a system for painting a multi-layer mark on a surface. The system may include an end effector. The end effector may be coupled to a mounting system. The system may include custom software. The custom software, when run on a processor may transform creator input into painting instructions. The painting instructions may be readable by software and/or hardware components of the painting system. The painting instructions may be executable by software and/or hardware components of the painting system.

[0072] The creator input may include electronic input data. The electronic input data may include a mark defined by non-linear pathways. The electronic input data may include a multi- layered or overlapping mark. Based on the computer readable painting instructions, the custom software may configure the end effector to paint a multi-layered mark on the surface.

[0073] The end effector may be an output end effector. The system may include an input end effector. The input end effector may be manipulatable in a multi-dimensional space. The input end effector may be manipulatable by a creator to generate creator input. The creator may be a machine. The creator may be a living being. For example, the creator may be a human artist.

[0074] The end effector may include one or more sensors. The sensors may track a position of the end effector relative to the surface. The end effector may include one or more sensors. The sensors may track movement of the end effector relative to the surface. The custom software may configure the end effector to paint a multi-layered mark onto the surface independent of position and/or movement of the end effector relative to the surface.

[0075] For example, the system may include a modular inkjet end effector. The modular inkjet end effector may include a self-contained ink circulation system. The self-contained ink circulation system may control ink pressure and ink circulation using a single actuator/pump. The modular inkjet end effector may be operated in any orientation. The self-contained ink circulation system may regulate pressure within the modular inkjet end effector independent of fluid pressure (of the ink) due to gravitational forces.

[0076] The modular end effector may be moved relative to a surface by a human painter. Sensors may monitor a location and orientation of the modular end effector relative to the surface. Regardless of the location and orientation of the modular end effector, the custom software may configure the modular end effector to paint a desired mark on the surface. The custom software may configure the modular end effector to paint the desired mark based on electronic input data associated with the desired mark and determining how to paint the desired mark given the real-time position, orientation and/or movement of the modular end effector.

[0077] As a further example, sensors may ascertain position, orientation and/or movement of the end effector with respect to the surface. Based on the position, orientation and/or movement, the custom software may determine an appropriate mark that should be produced by the end effector to produce a mark having a target visual impression on target location on the surface.

[0078] The target visual impression may be determined based on the electronic input data. The target visual impression may be determined by adding a tunable level of noise to the creator input before painting a mark on the surface. The custom software may merge the tunable level of noise to one or more properties of the electronic input data. The noise may be randomly generated.

[0079] The noise may be designed to achieve a specific visual effect or impression. The effects of noise may be similar to effects created traditionally by interaction between a surface used for painting (such as canvas, linen, specialty papers, etc.) the medium being applied to the surface and the application used to apply the medium. A surface may impact the visual effect/impression of a mark due to its texture, absorbability, stretchability and coatings. Marks produced using painting machines described herein may include an underlying pattern or "noise" typically generated by interaction between the surface, medium and applicator. Other visual effects/impressions that may be output include grids, spots, transparencies, bumps, or algorithmic patterns.

[0080] The painting instructions generated by the custom software may include a property of the surface. The property of the surface may include a width, length, texture, contour and/or thickness of the surface. The property of the surface may include a coating applied to the surface. For example, a gesso may be applied to a surface before paint is applied to the surface. The property of the surface may include a texture of contour of the surface.

[0081] Texture/contour may include areas of the surface that are not to be painted. For example, the system may be configured to paint on the side of a building. Windows or other areas of the building may remain unpainted. The software may generate executable painting instructions that account for the unpainted areas. The software may account for the unpainted areas by determining where to deposit marks such that a desired visual effect is achieved despite the unpainted areas. The software may account for the unpainted areas by controlling the end effector such that paint is not deposited on the areas expected to remain unpainted.

[0082] The painting instructions generated by the software may include a property of paint applied by the end effector to the surface. The paint property may include a viscosity of the paint. The paint property may include an expected visual effect after the paint is deposited on the surface. The visual effect may depend on a chemical composition of the paint. For example, oil-based paints may provide a different visual effect than water-based or acrylic paints. The visual effect may depend on a texture of the surface. The paint property may be a color of the paint.

[0083] The painting instructions may include a non-linear path that the end effector follows as it deposits paint on the surface. The non-linear path may be determined based on a property of the surface and/or a property of the paint. For example, based on the paint being applied and the surface to which the paint is being applied, the end effector may need to make multiple passes (e.g., multiple coatings) along the non-linear path to provide a desired visual effect.

[0084] The system may include an XYZ gantry. An XYZ gantry may move the end effector along X, Y and Z axes. The XYZ gantry may move the end effector to any target location on the surface. The XYZ gantry may move the end effector to any target location relative to the surface. For example, the XYZ gantry may move the end effector to a target height above an area on the surface. Movement of the XYZ gantry may be controlled by the custom software.

[0085] Methods for painting a mark are provided. Methods may include painting the mark by depositing paint on a surface along a non-linear pathway. Methods may include painting the mark by depositing paint on a surface along a linear pathway. Methods may include painting the mark by depositing paint on a surface along a non-linear pathway. A non-linear pathway may include one or more linear segments. Methods may include painting the mark by depositing multiple layers of paint on a surface along the non-linear pathway. The multiple layers of paint may be deposited while the surface remains stationary.

[0086] Methods may include receiving electronic input data. The electronic input data may include one or more properties that define the mark. The electronic input data may include one or more properties that define the non-linear pathway.

[0087] Methods may include generating paint properties associated with a medium deposited by an end effector on a surface. Custom software may compute the paint properties based on achieving a desired visual effect by depositing the medium on a particular surface.

[0088] Methods may include generating a motion plan for moving the end effector along the non-linear pathway over the surface. The motion plan may include control instructions for moving the end effector relative to the surface. The motion plan may include speed of the end effector. The speed of the end effector may be measured relative to the surface. In some embodiments, the surface may move concurrently with the end effector. Custom software may compute the motion plan and associated motion control instructions based on achieving a desired visual effect on a particular surface by depositing the medium along the non-linear path.

[0089] Based on the paint properties and motion plan, methods may include electronically controlling of the end effector and painting the mark along the non-linear pathway on the surface. Custom software may electronically control of the end effector. Electronic control of the end effector may include controlling when and where the end effector deposits the medium on the surface. Electronic control of the end effector may include controlling motion of the end effector.

[0090] Electronically controlling the end effector may include controlling movement of the end effector such that the end effector follows the non-linear pathway. Electronically controlling the end effector may include how the end effector deposits medium on the surface during the movement. For example, the end effector may be a print head that includes 100s of nozzles. Which nozzle(s) fire (to deposit paint) and which do not, and when each nozzle fires, as the end effector moves, may all be electronically controlled by the custom software.

[0091] The custom software may include software tools provided by Meteor Inkjet Ltd. ("Meteor") of Cambridge, United Kingdom. Meteor provides software for managing print hardware and a runtime library for controlling printing operations. However, Meteor software alone is unable to provide painting functionality.

[0092] Painting produces a target visual effect that is different from conventional flat printing techniques. To achieve the target visual effect, marks may be layered on top of each other. Layering marks provides texture and color that cannot be produced using conventional printing technology. For example, layering marks provides for interaction between the layers that yields unique color impressions and other visual effects. Furthermore, to achieve the target visual effect, marks may be layered along one or more non-linear paths.

[0093] Conventional printing software and hardware are also unable to provide motion and paint planning necessary to paint layered marks. Furthermore, conventional printing hardware does not provide a range of motion for moving an end effector along non-linear pathways or in accordance with other properties of an electronic input data generated by a creator. Conventional printing software and hardware are also unable to dynamically rotate, or otherwise move a print head up, down or around 3D surfaces (e.g., follow a non-linear path) to produce a mark having a desired visual effect.

[0094] To achieve a visual effect associated with traditional (e.g., by hand) painting, custom software and hardware tools may be built. The custom software/hardware tools may allow for robotic painting in a way that is not technically achievable using conventional software/hardware printing tools.

[0095] For example, the custom software and hardware tools described herein may control movement of an end effector such that the end effector layers a medium on a surface along a non-linear pathway. The custom software and hardware tools described herein may control movement of an end effector such that the end effector deposits medium onto a surface in an orientation not technically achievable using conventional software/hardware printing tools.

[0096] The custom software may provide paint planning. The custom software may provide motion planning. Motion planning may include providing motion control functionality. The custom software may utilize a HTTP server for processing motion control. The custom software may generate HTTP requests to control motion of the end effector and control release of medium from the end effector (e.g., an inkjet head). Custom software tools described herein may utilize aspects of conventional software tools.

[0097] For example, custom software for painting using a printer head affixed to an XYZ gantry may provide paint planning functionality and motion control. The custom software may utilize Meteor runtime libraries to manage a painting subsystem. The custom software may communicate with hardware components of an XYZ gantry using Grbl motion control software (available at https://github.com/grbl).

[0098] The custom software may generate a motion plan and associated control instructions for controlling movement of the end effector. The custom software may generate control instructions in G-Code format. G-code format refers to a numerical control programming language used to control automated machine tools.

[0099] Hardware for controlling motion of the XYZ gantry may be built using the open source Arduino microcontroller development platform (available at www.arduino.ee). The Arduino open-source electronic prototyping platform is hereby incorporated by reference herein in its entirety.

[00100] The custom software may provide a graphical user interface ("GUI"). The custom software may include a GUI that allows a creator to load images for painting and plan how the images will be painted on a surface. The custom software may not be specific to any particular printing hardware and can control any suitable mounting system. Illustrative mounting systems include XYZ gantries and robotic arms. Based on the mounting system in use, the custom software may generate an appropriate configuration file that controls motion of the end effector. The configuration file may also include instruction for controlling the mounting system.

[00101] Using the GUI a creator may load an image (or other electronic input data) into the painting system. The GUI may provide functionality for selecting and arranging the desired output and desired visual effect. The creator may then click a button within the GUI to initiate the painting process. Behind the GUI, the custom software handles paint planning, motion planning and the high-level motion control. In some embodiments, the custom software may not communicate directly with the end effector. Instead, the custom software may generate HTTP requests that are translated into instructions that control movement of the mounting system and painting by the end effector.

[00102] The custom software may include custom firmware that manages motion control of a mounting system. For example the custom firmware may manage motion control of XYZ gantry hardware instead of Grbl. The custom software may include a custom protocol designed to communicate motion plans to firmware running the Arduino microcontroller platform.

[00103] The custom protocol may obtain live feedback of the painting process for display in the GUI and implement real-time modification of the painting/motion plans. Real-time modification of the painting/motion plans may be initiated by a creator through the GUI. The custom protocol may replace use of G-Code to communicate motion plans and associated motion control instructions to the motion controller.

[00104] Custom software may be written in any suitable programming environment or language. For example, illustrative custom software may be written in the C# programming language using Windows Forms. Illustrative custom software may be written in the Java programming library using the open source Processing environment for cross-platform support and prototyping.

[00105] Illustrative custom software may be written as an Electron application. Electron (www.electronj s.org) is a technology that allows rapid implementation of cross-platform applications using standard Web technologies. It includes many portions of the Chrome Web browser and V8 JavaScript runtime (developed by The Chromium Project for Google Chrome and Chromium web browsers and available at https://v8.dev/).

[00106] Custom software may be written in JavaScript and may leverage open source libraries to implement its functionality. For example, custom motion control firmware may be implemented in C++ on top of an open source Arduino environment.

[00107] The custom software may include one or more components that are run on one or more computer systems. For example, a GUI may be run on a creator' s own computer and generate commands that are transmitted to a server running Meteor libraries.

[00108] The electronic input data may include a "flat" image. Methods may include segmenting the flat image into layers. Methods may include, for each layer, generating paint properties associated with the medium deposited by the end effector to paint the layer. Methods may include, for each layer, generating motion properties for moving the end effector over a surface to paint the layer on the surface. Motion properties may include motion planning and/or motion control instructions.

[00109] Based on the paint and motion properties associated with the layer, methods may include, electronically controlling the end effector and painting the layers on the surface. Painting the layers on the surface may generate a desired visual effect that is different from painting the flat image on the surface using conventional printing software/hardware.

[00110] Conventional printing software/hardware may take sequential marks as defined in electronic input data and compress them into one flat layer. Such flattening typically eviscerates visual effects that result from layering marks. Conventional printing technologies are unable to produce color and textural visual effects associated with layering marks.

[00111] On the other hand, custom software, hardware and chemistry described herein may generate an output that maintains effects of layering marks associated traditional (e.g., by hand) painting techniques. The generated output may be 2.5D. Such layered painting has applicability in the fields of painting, architectural facades, interior design, industrial design and advertising.

[00112] Methods may include detecting a change to a mark. The mark may be a layered or overlapping mark. The change may be detected after the mark is painted by the end effector on the surface. The change may not be made by the end effector. The change may be made by manipulating paint deposited by the end effector.

[00113] For example, a creator may blow on wet paint deposited by the end effector. A creator may brush wet paint deposited by the end effector. A creator may add additional marks to the surface after paint is deposited by the end effector. A creator may layer additional marks after paint is deposited by the end effector.

[00114] Methods may include generating properties for reproducing the change. Such properties may include capturing one or more digital images of the change. Photogrammetric sensing techniques may be applied to generate the properties for reproducing the change based on the images. One or more cameras may capture the change. Cameras for capturing the change may be external to the painting machine.

[00115] Cameras for capturing the change may be embedded in any suitable component of a painting machine or system. For example, cameras may be embedded in axes, belts, rails or any other components of an XYZ gantry. Cameras may be embedded in a robotic arm. The end effector may include one or more embedded cameras for capturing the change. Cameras may be embedded in the surface. Sensors for capturing properties for reproducing the change may be embedded in the medium deposited on surface.

[00116] Properties for reproducing the change may include paint properties for painting the change on a surface. Properties for reproducing the change may include motion properties for moving the end effector over the surface to paint the change. Based on the properties for reproducing the change methods may include electronically controlling the end effector and painting the change on the surface.

[00117] Electronic input data may be first electronic input data. Methods may include using the one or more sensors, capturing second electronic input data corresponding to the change. Methods may include generating the properties of the change based on computing differences between the first electronic data and second electronic data.

[00118] Methods may include adding a tunable level of noise to electronic input data. The noise may be randomly generated noise. The noise may be any suitable distortion or change to the electronic input data. The noise may be added before instructing the end effector to paint the mark on the surface. When added to the electronic input data, the tunable level of noise may generate marks having a visual effect that is different from marks painted without adding the tunable level of noise.

[00119] Methods may automatically recognize, analyze, and transfer painting style. For example, based on electronic input data, methods may include generating paint and motion plans for an end effector to produce marks (e.g., brush strokes) using a painting style extracted from the electronic input data. A painting style may be extracted based on properties associated with a plurality of electronic input data. A painting style may be extracted based on property patterns within the plurality of electronic input data.

[00120] A plurality of electronic input data may be input into the custom software. The custom software may extract a painting style from the plurality of electronic input data. In some embodiments, electronic input data may be provided that defines a painting style.

[00121] Using a painting style, a painting system may create a work having the painting style. Using a painting style, a painting system may complete an incomplete work by continuing where a human painter has left off. The painting system may complete the incomplete work by replicating the style of the human painter and filling in gaps in accordance with the painting style of the human painter. The painting style of the human painter may be determined based on the incomplete work.

[00122] Apparatus for a painting machine is provided. The painting machine may include a moveable mounting system. The moveable mounting system may include an XYZ gantry. The moveable mounting system may include a robotic arm. The painting machine may include an end effector. The end effector may be coupled to the mounting system. The end effector may be releasably coupled to the mounting system.

[00123] The painting machine may include custom software. The custom software may be configured to receive electronic input data. The electronic input data may define an overlapping mark. The electronic input data may include properties that define the overlapping marks. The electronic input data may include properties that define a plurality of overlapping marks.

[00124] The custom software may control movement of the mounting system such that the end effector paints the overlapping marks on a surface. The custom software may control movement of the mounting system such that the end effector paints the overlapping marks on a surface based on the properties stored in the electronic input data.

[00125] The end effector may be coupled to a receptacle. The receptacle may hold a medium. The medium may be a liquid. The medium may be a paint and/or ink. The medium may include a liquefied substance such as a polymer, a resin, a plastic, a rubber, a composite a metal and/or a combination of the foregoing.

[00126] A conduit may link the receptacle and the end effector. The conduit may fluidly link the medium in the receptacle to the end effector. The end effector may include an applicator that applies the medium to the surface. The applicator may include any suitable tool for making a mark on a surface. Illustrative end effectors may include one or more of the following tools: a paint brush, an air brush, a paint roller, a scraper or a cutting tool.

[00127] The end effector may include an inkjet head. The inkjet head may include a nozzle. The inkjet head may include two or more nozzles. For example, an inkjet head may include 320, 700, 1280 or more nozzles. The inkjet head may include a receptacle for holding a medium such as ink or paint. A nozzle may controllably release the medium from the inkjet head. The software may control release of the medium from each nozzle. The custom software may control release of the medium from each nozzle and concurrent movement of the inkjet head to paint overlapping markings on the surface. The custom software may intentionally misfire a nozzle or desynchronize firing of nozzles to achieve a mark having a desired visual effect.

[00128] The software may control movement of an end effector by controlling movement of the mounting system. The software may control movement of the mounting system such that the end effector paints the overlapping markings on the surface at a speed that is faster and/or slower than a speed defined in the electronic input data.

[00129] The mounting system may be moveable over the surface such that the end effector is configured to paint the overlapping marks on the surface while the surface remains stationary. The mounting system may be configured to maneuver the end effector at speeds and/or with motions outside a range of humanly capable speed and/or motion.

[00130] The software may be configured to register a position of the end effector relative to a first mark painted on the surface. Based on the position, the software may align the end effector to paint a second mark on the surface. Registering an end effector to any target position on a surface is a challenge for conventional printing systems. This challenge is exacerbated when it comes to real-time improvisational painting, such as when a creator does not have a clear idea where a new mark is going to be made on a surface.

[00131] To address this challenge, the custom software may automatically position the end effector with-respect-to current work. Such positioning may allow a creator to start/stop the painting process as desired and continue from any desired location on the surface, mark deposited on the surface or time stamp during the painting process.

[00132] The painting machine may include an input tool. The input tool may be moveable by a creator. The input tool may include any device that may function as an end effector. The painting machine may include a tracking controller. The tracking controller may be configured to track movement of the input tool. The custom software may be configured to paint overlapping marks on a surface by controlling movement of the end effector in accordance with the tracked movement of the input tool.

[00133] Illustrative tracking control may be implemented using Lighthouse Tracking technology provided by the HTC Vive VR system. A tracking device may be affixed to an input tool. For example, a tracking device may be affixed to a paintbrush handle. The tracking device may monitor a position and orientation of the input tool. As the input tool moves (e.g., is used by a creator to paint on a surface) the 6D pose (3D rotation + 3D translation or position + orientation) of the input tool may be recorded. A 6D pose may be defined by three translational axes (typically denoted X, Y, Z axes) and three rotational axes (A, B, C).

[00134] Illustrative tracking may include tracking eye movement of a creator as the creator moves the input tool. Eye-movement may be tracked using eye-tracking sensors.

[00135] The position and rotation of the input tool may be mapped to a position and orientation of an end effector. Based on the position and orientation of the input tool, the end effector may paint on a surface. The custom software may configure the end effector to mimic tracked motion of the input tool.

[00136] For example, the painting machine may track brush strokes of a creator while the creator produces a work using traditional painting techniques. The custom software may configure the end effector to produce marks that appear to have been painted by a brush type. Illustrative brush types include: fan, oval wash, sword, angle, flat, bright, filbert, rigger, and/or round. The custom software may configure the end effector to produce marks may share one or more features of two or more brush types.

[00137] The painting machine may mimic the tracked brush strokes but apply different colors, using a different output tool to a different surface to create a new work of art.

[00138] Custom software may configure the end effector to follow the tracked motion of the input tool and add deviation to the tracked motion. The deviation may provide a visual effect that includes a signature or core stylistic character associated with the tracked motion and includes unique stylistic effects of the deviation. For example, the deviation may include mimicking a path (linear and/or non-linear) of tracked brush strokes of a human creator but at a speed faster or slower than the tracked brush strokes. Deviations may include any suitable mark, paint or surface property. Deviations may include changes to any property in electronic input data.

[00139] The end effector may be releasably coupled to the mounting system. When the end effector is coupled to the mounting system, the custom software may be configured to control release of paint from the end effector such that the end effector paints an overlapping mark on a surface based on the electronic input data.

[00140] When the end effector is decoupled from the mounting system, a creator may use the end effector to apply marks on a surface by moving the end effector free-hand across the surface. The creator may use a modular end effector. The custom software may be configured to control release of paint from the end effector such that the end effector paints overlapping marks on a surface based on the electronic input data. The custom software may control release of the medium from an end effector based on a position/orientation of the end effector with respect to a surface.

[00141] Apparatus for a painting machine is provided. The painting machine may paint marks on a surface. The painting machine may receive electronic input data defining a nonlinear path. The painting machine may include a housing. The painting machine may include an end effector. The end effector may be configured to be affixed to the housing. The end effector may be configured to paint on the surface.

[00142] The housing may be designed to be hand-held by a creator. The housing may be designed to be hand-held by a human creator. The housing may be designed to be affixed and moved by any suitable way. For example, the housing may be attached to a plant and the end effector may be moved by motion of plant as the plant is blown by wind.

[00143] A painting machine may include two or more end effectors. The two or more end effectors may move relative to one another. Movement of the end effectors, relative to each other, may be controlled by the custom software. The housing may be capable of mating with two or more end effectors.

[00144] The painting system may include a mounting system. The mounting system may be configured to mate with the housing. When mated to the housing and end effector, the mounting system may maneuver the end effector to paint on the surface along the non-linear path.

[00145] The mounting system may be configured to move the end effector along any one of three orthogonal axes. The mounting system may be configured to rotate the end effector about a rotational axis. The rotational axis may be any suitable axis defined by one or more of the three orthogonal axes. The rotational axis may be any suitable axis within a multidimensional space. The rotational axis may be aligned with a longitudinal axis of the end effector. The rotational axis may be misaligned with a longitudinal axis of the end effector.

[00146] The mounting system may orient the end effector at a target position relative to the surface and move the end effector along the non-linear path.

[00147] The mounting system may include a robotic arm. The mounting system may include at least one electric motor. The mounting system may include at least one axle rotationally coupled to the electric motor. The mounting system may include a plurality of electric motors. Each electric motor may be configured to operate in concert to maneuver the end effector in accordance with a paint/motion plan.

[00148] For example, the mounting system may include an XYZ gantry. XYZ gantries described herein may provide longitudinal movement of an end effector along one or more of x, y and z axes. XYZ gantries described herein may provide rotational movement of the end effector about any suitable rotational axis. For example, an XYZ gantry may provide rotational movement of the end effector about one or more of x, y and z axes. An XYZ gantry may provide rotational movement of the end effector about an axis defined by the end effector (e.g., a central longitudinal axis).

[00149] Movement along one axis of the XYZ gantry may be implemented using wheels instead of rails, tracks or belts. Using wheels instead of rails/tracks/belts does not limit movement of the end effector along that axis.

[00150] A painting machine may include "smart" servomechanisms for the wheel-based axis and stepper motors for other axes. Motion control may be accomplished using an Arduino microcontroller platform running custom firmware developed in the Arduino programming environment. A cable bundle may be routed from the painting machine to power supplies. A computer system may provide control of the motors and end effector of the painting machine.

[00151] For general operation, three DC power supplies may be used, 9V for the Arduino microcontroller, 24V for the stepper motors, and 75V for the smart servomechanisms. When an inkjet head is coupled to the painting machine as the end effector, an additional 48V power supply may be added to the painting machine.

[00152] End effectors may be mounted to a standardized tool plate on the last motion stage of a painting machine. End effectors mounted on a painting machine may be moved vertically, horizontally, or forward/back by driving each independent motion axis. Illustrative end effectors have included an inkjet printing system, paintbrushes, airbrushes and pens.

[00153] The mounting system may include a first track aligned along a first longitudinal axis. The mounting system may include a second track aligned along a second longitudinal axis. The second longitudinal axis may be oblique or perpendicular to the first longitudinal axis. The mounting system may operate according to a Computer Numerical Control (CNC) protocol. A CNC protocols may include standard CNC protocols known to those skilled in the art. For example, a standard CNC protocol may include a computer-aided design (CAD) protocol that converts spatial designs into a series of numbers.

[00154] The painting machine may include one or more sensors. The sensors may detect a position and/or motion of the end effector relative to a surface. The painting machine may configure the end effector to paint marks on the surface in response to detected position and/or motion of the end effector.

[00155] Apparatus for a painting machine are provided. The painting machine may be configured to paint an overlapping mark on a surface. The painting machine may receive a first electronic input data. The first electronic input data may define a first mark. The painting machine may include an end effector. The end effector may be configured to paint the first mark, as defined by properties in the electronic input, at a target location on the surface at a first time.

[00156] The painting machine may include custom software. The custom software may extract one or more properties from the first electronic input data and control movement of the end effector based on the extracted properties.

[00157] The painting machine may include a sensor. The sensor may capture second electronic input data. The second electronic input data may define a second mark. The second mark may be present at the target location on the surface at a second time. The custom software may calculate how to change the first mark into the second mark. Based on the calculated change to the first mark, the custom software may configure the end effector to duplicate the second mark.

[00158] The sensor may be embedded in the surface. The sensor may be embedded in the end effector. The sensor may be included within a medium deposited on the surface.

[00159] A system for painting a medium is provided. The system may paint the medium along a path. The path may be a vector path. The path may be non-linear and overlapping. The system may include an end effector. The end effector may be configured to apply the medium to a surface. The system may include a receptacle. The receptacle may hold the medium applied by the end effector.

[00160] The system may include a single reservoir self-contained circulation system. A self-contained circulation system may control pressure and ink circulation in the system using the same actuator/pump. [00161] The end effector may include an ingress port. The ingress port may allow the medium to enter the end effector. The end effector may include an egress port. The egress port may allow the medium to exit the end effector. The medium may flow through the end effector. The system may include a conduit. The conduit may transfer the medium from the receptacle to the end effector. The medium may be pressurized within the end effector. The medium may be pressurized within the conduit.

[00162] The system may include custom software and custom hardware. The custom software and custom hardware may control movement of the end effector. The custom software and custom hardware may control how the medium is applied by the end effector to the surface. The custom software and custom hardware may control movement of the end effector relative to the surface.

[00163] The receptacle may be a first receptacle. The system may include a second receptacle. The second receptacle may hold the medium extracted from the end effector. The system may include a pump. The pump may be configured to transfer the medium from the second receptacle to the first receptacle. The pump may be configured to push the medium out of the first receptacle, through the end effector, into the second receptacle and back into the first receptacle.

[00164] The system may include a vacuum pump. The vacuum pump may be configured to generate negative pressure. The vacuum pump may generate negative pressure by extracting air from a receptacle. The vacuum pump may extract air from the second receptacle. In some embodiments, the vacuum pump may extract air from the first receptacle. The system may include a pressure sensor. The pressure sensor may monitor changes in pressure generated by the vacuum pump. The vacuum pump may adjust the negative pressure in response to pressure readings received from the pressure sensor.

[00165] The custom software may regulate a quantity of the medium applied by the end effector to the surface. The end effector may be any suitable end effector. For example, the end effector may be an inkjet head, an airbrush, a paintbrush or a paint roller.

[00166] The custom software may regulate how ink is applied to the surface by the end effector based on pressure applied to the tablet or physical media used by a creator when creating electronic input data. For example, pressure applied by the creator when drawing on a tablet may be translated by the custom software to configure a threshold number of nozzles of the end effector fire thereby producing a mark having a target width. Pressure applied by the creator when drawing on a tablet may be translated by the custom software to configure the end effector to release more ink at a target location thereby producing a mark having a target darkness.

[00167] The medium may include particles small enough to pass through a nozzle in an inkjet head without clogging the nozzle.

[00168] The end effector may apply the medium based on pressure applied to the medium and control signals generated by the custom software. The control signal may trigger a change in the pressure within the inkjet head. The control signal may trigger a firing of an inkjet head nozzle and release of the medium from the nozzle.

[00169] A system for painting a medium along a non-linear path is provided. The system may include an end effector. The end effector may apply the medium to a surface. The system may include a receptacle. The receptacle may hold the medium applied by the end effector. The system may include a conduit. The conduit may transfer the medium from the receptacle to the end effector. The conduit may transfer the medium from the end effector to the receptacle.

[00170] The system may include a pump. The pump may move the medium through the conduit. The pump may maintain a target pressure in the conduit. The pump may include an Archimedes screw. An Archimedes screw may include a screw within a hollow pipe. Turning the screw moves liquid though the pipe.

[00171] The Archimedes screw may provide a fluid pump which induces a constant pressure in the conduit. Conventional pumps rely on mechanisms which move fluid in oscillating bursts, leading to pressure waves in the fluid/conduit carrying the fluid. In the context of an inkjet system in which a pump is forcing a flow of medium through nozzle channels, pressure waves may create a turbulent flow which may reduce quality and consistency of painting output. The Archimedes screw may be positioned in the conduit. The Archimedes screw may be rotated as the armature in an electric motor.

[00172] The system may include custom software. The custom software may control movement of the end effector. The custom software may control depositing of the medium (by the end effector) along a non-linear path.

[00173] The system may include a valve. The valve may regulate a flow of the medium within the conduit. The value may regulate a flow of the medium from the receptacle into the conduit. [00174] The system may include a pressure sensor. The pressure sensor may detect changes in the pressure within the conduit. The pump may be responsive to the changes in the pressure detected by the pressure sensor. For example, in response to a detected loss of pressure, the pump may increase the pressure to achieve a target pressure. In response to a detected increase in pressure, the pump may stop pumping or release pressure, to achieve the target pressure. Collectively, the pressure sensors and pump may form a feedback loop that maintains a target pressure in the conduit and/or an ink circulation system.

[00175] The pump may maintain a target pressure during movement of the receptacle, conduit or end effector. Movement may include rotation of the receptacle, conduit or end effector.

[00176] The system may include a filter. The filter may allow air to enter the receptacle. The filter may prevent unwanted particles from entering the receptacle.

[00177] The receptacle may be a first receptacle. The first receptacle may hold a first medium. The first receptacle may be removable from the system. The first receptacle may be replaced with a second receptacle. Removable receptacles may allow ink colors to be easily changed. The second receptacle may hold a second medium. The first medium may be a first color paint. The second medium may be a second color paint. The first or the second medium may be a white colored paint. The first or second medium may be any medium that when applied produce a visual effect of white ink.

[00178] A medium may be opaque or translucent variations of colors. The custom software (and associated creator interface) may provide digital simulation of effects produced by use of such mediums. The custom software (and associated creator interface) may provide digital simulation of volumetric components of one or more layers to achieve a desired visual result. Each layer, and digital simulation (and digital effects) associated with layer may be saved by the custom software. Each layer, and digital simulation (and digital effects) associated with layer may be saved as one or more properties of electronic input data. The system may configure an end effector to produce tangible output that embodies the visual effect digitally simulated by the creator interface.

[00179] A medium may include custom inks/paints created using oil. A medium may include custom inks/paints that are UV curable. A medium may be created to have a target drying time. For example, the target drying time may allow a creator to manipulate the ink after being deposited on a surface by an end effector. The target drying time may range from minutes to months after the ink is deposited on the surface.

[00180] The system may include a mixing chamber. A plurality of foundational ingredients may be mixed in the mixing chamber to form the medium.

[00181] A system for a modular inkjet end effector may be provided. A modular inkjet end effector differs from a conventional inkjet system in a few ways. The modular inkjet end effector may include a self-contained circulation system. The self-contained circulation system may control pressure and paint circulation using the same actuator/pump.

[00182] The modular inkjet end effector may be operated in any orientation. The self- contained circulation system may control pressure independent of fluid pressure. Fluid pressure may be caused by gravity or movement of the medium due to gravity.

[00183] A system for depositing medium along an arbitrary vector path is provided. The system may include an end effector. The end effector may be configured to apply the medium to a surface. The system may include a housing. The housing may be configured to rotate the end effector.

[00184] The system may include a receptacle. The receptacle may hold the medium applied by the end effector. The system may include a conduit. The conduit may transfer the medium from the receptacle to the end effector. The system may include a pump. The pump may move the medium through the conduit. The pump may maintain a target pressure in the conduit.

[00185] The system may include custom software. The custom software may control movement of the end effector. The custom software may control depositing (timing and location) of the medium on the surface, along the arbitrary vector path.

[00186] The end effector may be mounted to the housing using an embedded bearing. The embedded bearing may define a rotational axis. The housing may include a planetary gear system. The embedded bearing may be enclosed within the planetary gear. The planetary gear system may be configured to rotate the end effector about the rotational axis.

[00187] The housing may define a rotational axis. The housing may be configured to rotate the end effector 360° about the rotational axis.

[00188] Apparatus and methods described herein are illustrative. Apparatus and methods in accordance with this disclosure will now be described in connection with the figures, which form a part hereof. The figures show illustrative features of apparatus and method steps in accordance with the principles of this disclosure. It is to be understood that other embodiments may be utilized and that structural, functional and procedural modifications may be made without departing from the scope and spirit of the present disclosure.

[00189] The steps of methods may be performed in an order other than the order shown and/or described herein. Method embodiments may omit steps shown and/or described in connection with illustrative methods. Method embodiments may include steps that are neither shown nor described in connection with illustrative methods. Illustrative method steps may be combined. For example, an illustrative method may include steps shown in connection with another illustrative method.

[00190] Apparatus may omit features shown and/or described in connection with illustrative apparatus. Apparatus embodiments may include features that are neither shown nor described in connection with illustrative apparatus. Features of illustrative apparatus may be combined. For example, an illustrative apparatus embodiment may include features shown or described in connection with another illustrative apparatus and/or method embodiment.

[00191] FIG. 1 shows illustrative components of painting system 100. A painting system

100 includes input instrument 101. Input instrument 101 may be any suitable tool for making marks on a surface. Input instrument 101 may include a virtual reality ("VR") tool. A creator may move the VR tool and motion of the VR tool may be tracked. The tracked motion may be saved as electronic input data.

[00192] Painting system 100 may capture direct user manipulation 103. Direct user manipulation 103 may include a creator producing an artistic work in digital or traditional form.

[00193] Painting system 100 includes file input 105. File input 105 may include files created using vector or raster graphics editors. File input 105 may be or include electronic input data.

[00194] Painting system 100 includes stream input 107. Stream input 107 may include real-time input. Stream input 107 may include simulated input, such as motion simulated using the V-REP robot simulation application discussed above. Stream input 107 may include realtime tracked motions of a creator and/or input instrument 101.

[00195] A GUI may allow a creator to provide inputs 101, 103, 105 and 107. Behind the

GUI, inputs 101, 103, 105 and 107 may be processed by input processors 109. Input processors 109 may include one or more computer systems. Input processors 109 may include custom software running on the one or more compute systems.

[00196] Based on inputs 101, 103, 105 and 107, input processors 109 execute motion planner 111. Motion planner 111 may include generating motion control instructions for producing output based on the inputs. Motion planner 111 may be a component of the custom software. The motion control instructions generated by motion planner 111 may implement motor control 113.

[00197] Motor control 113 may include controlling operation of one or more motors.

Motor control 113 may actuate mechanical systems 115. Mechanical systems 115 may include an XYZ gantry. Mechanical systems 115 may include a robotic arm. Mechanical systems 115 may include an end effector. Mechanical systems 115 may include an inkjet print head. Mechanical systems 115 may include an ink circulation system for an inkjet print head. Mechanical systems 115 may include a pressure regulation system for an inkjet print head.

[00198] Actuation of mechanical systems 115 may produce output 117. Output 117 may include one or more marks on a surface. Output 117 may include layered or overlapping marks or marks that follow a non-linear pathway. Output 117 may have a visual effect commensurate with the visual effect associated with traditional (e.g., by hand) painting.

[00199] Painting system 100 includes observing/sensing 119 components that capture changes or manipulation to output 117. Observing/sensing 119 components may include cameras or motion sensors, tracking technology or any other suitable devices for detecting changes or manipulation to output 117.

[00200] Changes or manipulation captured by observing/sensing 119 components may generate electronic input data. Changes or manipulation captured by observing/sensing 119 components may be input into motion planner 111 for producing a revised output 117 based on the changes or manipulations.

[00201] FIG. 2 shows illustrative components of painting system 200. Painting system

200 includes GUI 201. GUI 201 may provide an interface for remixing and iterating certain painting processes that may be implemented by painting system 200. Such processes may include serializing multiple layers of an image, repeating a desired mark and patterned repeat of a desired mark. A mark may be composed of two or more marks. A mark may include an entire layer or two or more layers. A mark may be an image. [00202] GUI 201 may display an expected output that will produced by painting system

200. GUI 201 may highlight operations or steps a creator instructed painting system 200 to perform to produce the output.

[00203] GUI 201 may load digital images (or other electronic input data) to be painted into the painting system. GUI 201 may adjust properties of the image (or other electronic input data) based on a surface (e.g., paper versus canvas) that will be used to produce the output. GUI 201 may configure painting by allowed a creator to adjust settings (e.g., paint properties) such as physical width and height, droplet size, resolution, paint rate, etc.

[00204] GUI 201 may submit the image (or other electronic input data) to paint planner

203. In some embodiments, GUI 201 may submit the image (or other electronic input data) to inkjet (or other end effector) paint subsystem 213.

[00205] Painting system 200 includes paint planner 203. Paint planner 203 may include custom software for slicing the image (or other electronic input data) into bands which are the width of a toe of an end effector or thinner. When the end effector is a print head, slicing the image includes raster image processing 207.

[00206] Paint planner 203 includes motion planner 205. Motion planner 205 may plan motion of the end effector such that motion is constrained to limits of painting system 200 (including an associated mounting system for actuating the end effector). Motion planner 205 may plan motion of the end effector such that a desired region of the surface identified using GUI 201 receives the output.

[00207] Motion planner 205 may plan motion of the end effector such that a medium deposited by the end effector lands in desired locations on the surface. When the end effector is a print head, motion planner 205 may plan motion of the print head such that medium (e.g., ink droplets) deposited by the print head land in target locations on the surface to form the intended mark.

[00208] When the end effector is a print head, motion planner 205 may plan motion of the print head such that ink droplets are arranged in a pattern on the surface that approximates desired properties for the image (or other electronic input data). Desired properties may be identified using GUI 201. Desired properties may include color reproduction or presence/quality of visible repeating patterns. [00209] Motion planner 205 may execute a dithering process. Motion planner 205 may plan motion of a print head such that a target ink droplet density (e.g., dots per inch) is achieved on the surface.

[00210] Painting system 200 includes motion controller 209. Motion controller 209 receives the planned motion from motion planner 205. Motion controller 209 executes the planned motion. For example, motion controller 209 may include hardware for emitting synchronization signals to inkjet painting subsystem 213. The synchronization signals may be generated and emitted at appropriate times so that a painting timeline matches movement of the end effector.

[00211] Motion controller 209 may generate low-level motor control signals necessary to physically move a print head across a desired paintable region of the surface. The low-level motor control signals generated by motion controller 209 may control movement of motion hardware 211.

[00212] Inkjet painting subsystem 213 may receive image (or mark) data from paint planner 203. Painting subsystem 213 may convert image data into droplet firing patterns specific to an inkjet head. Painting subsystem 213 may establish a communication link to the print hardware to transmit images and configuration settings. A communication link may utilize any suitable transmission medium or protocol (e.g., wired, wireless, fiber optic, infrared, radio). The configuration setting may include the firing patterns. The communication link may also be used to receive status information from the print head hardware.

[00213] Painting subsystem 213 may expose low-level configuration of the inkjet head and support systems. Painting subsystem 213 may access low-level configuration of the inkjet head and support systems using print runtime libraries 215. Illustrative runtime libraries for print heads may be provided by Meteor Inkjet Ltd.

[00214] Painting subsystem 213 includes print management service 217. Print management service 217 may manage transfer/buffering of image data through each level of the inkjet control hardware. Inkjet control hardware may include print controller card 219, head driver card 221 and inkjet head 223.

[00215] Print controller card 219 may be a hardware device that accepts print data over a network and passes it on to head driver card 221 for painting. Print controller card 219 may including a central processing unit, memory and connectors for other input and output devices. [00216] Head driver card 221 may be a hardware device that manages one or several inkjet heads, such as inkjet head 223. Head driver card 221 may provide specific power requirements of inkjet head 223. Head driver card 221 may implement low-level digital control protocols for driving inkjet head 223. Driving inkjet head 223 may include controlling a firing (e.g., releasing ink or other medium) of nozzles within inkjet head 223. Driving inkjet head 223 may include controlling pressure applied by a medium that cycles through inkjet head 223. Driving inkjet head 223 may include controlling pressure applied by a medium on nozzles of inkjet head 223.

[00217] Inkjet head 223 may be a device which fires ink droplets from embedded nozzles to produce an output, such as an image. Inkjet head 223 may include a digital controller that determines how and when to fire each nozzle.

[00218] FIG. 3 A shows illustrative painting machine 300. Painting machine 300 includes a mechanical mounting system for moving end effector 321 along X, Y, and/or Z axes. Painting machine 300 may be considered an XYZ gantry. Painting machine 300 may be designed to operate according to a Computer Numerical Control (CNC) protocols. Such CNC protocols may include standard CNC protocols known to those skilled in the art. A standard CNC protocol may include a computer-aided design (CAD) protocol that converts spatial designs into a series of numbers.

[00219] Painting machine 300 includes wheels 317 and 315. Wheel 315 is mechanically coupled to motor 313 and is a drive wheel. Painting machine 300 includes wheels 307 and 323. Wheel 307 is mechanically coupled to motor 311 and is a drive wheel. Motors 313 and 311 may be electric motors.

[00220] Motors 313 and 311 may be servomechanisms. Servomechanisms may include error-sensing feedback to ensure that desired movement is being achieved. Motors 313 and 311 may include built-in encoders or other position feedback mechanisms. Each servomechanism may be connected to a 75V DC power supply.

[00221] Motors 313 and 311 may be synchronized to move end effector 321 along axis y.

Electrics motors 313 and 311 may be configured to move end effector within a plane defined by (or parallel to) axes x and y. [00222] Painting machine 300 includes belt 303. Belt 303 may move end effector 321 along rail 301. Belt 303 may move end effector 321 along axis x. Belt 303 may be driven by a stepper motor. The stepper motor may be coupled to a 24V DC power supply.

[00223] Painting machine 300 may be constructed in a modular fashion such that rail 301 connecting wheels 315/317 to wheels 307/323 may be as short or as long as desired. For example, Rail 301 may be 1-12 feet in length.

[00224] Embodiments (not shown) of painting machine 300 may include a single motor and drive axle to synchronize movement of end effector 321 along the y axis.

[00225] End effector 321 may be mechanically coupled to two motors. Illustrative motor may include a stepper motor coupled to a 24V DC power supply. One motor may drive rotational movement of end effector 321 about an axis perpendicular to the x and y axes (the "z axis"). Another motor may drive longitudinal movement of end effector 321 along the z axis. Embodiments of painting machine 300 may include one, three or more motors for manipulating end effector 321. For example, motor 319 may move end effector 321 along a z axis.

[00226] Motion control of end effector 321 may be implemented using an Arduino microcontroller platform running custom firmware developed in the Arduino programming environment. The Arduino microcontroller platform may be coupled to a 9V power supply. When end effector 321 includes an inkjet head, a 48V power supply may be added to painting machine 300. Item 309 may represent an illustrative Arduino microcontroller platform. Item 305 may represent a portable power source and computer system for controlling of painting machine 300.

[00227] FIG. 3B shows illustrative painting machine 302. Painting machine 302 may include one or more features of painting machine 300 (shown in FIG. 3A).

[00228] Painting machine 302 includes end effector 314. End effector 314 is moveable along the z axis. End effector 314 may be rotatable about the z axis. Bracket 310 may move end effector 314 along rails 304 and along the x axis. Wheels 306 and 308 may move end effector 314 along the y axis. Wheels 306 and 308 may move end effector 314 in a plane parallel to the x and y axes.

[00229] End effector 314 may be mounted to a standardized tool plate (not shown). End effector 314 be moved vertically (along z axis), horizontally (along x axis), or forward ack (along y axis). End effector 314 may be moved by driving each independent motion axis. End effector 314 may be an inkjet system, paintbrushes, airbrushes and/or pens.

[00230] Painting machine 302 includes mounting bracket 312. Motors or microcontrollers may be mounted on mounting bracket 312.

[00231] FIG. 4 shows illustrative painting scenario 400. Scenario 400 shows a painting machine producing output 419 on surface 401 based on an input of creator 417.

[00232] The painting machine shown in FIG. 4 includes rail 403. The painting machine includes "drillbot" 411. Drillbot 411 may be configured to move along rail 403. Drillbot 411 may include a motor, drive axle, wheels, frame and other components shown and described herein.

[00233] The painting machine includes rail 405. The painting machine includes drillbot

413. Drillbot 413 may be configured to move along rail 405. Drillbot 413 may include a motor, drive axle, wheels, frame and other components shown and described herein.

[00234] The painting machine includes rail 407. The painting machine includes drillbot

409. Drillbot 409 may be configured to move along rail 407. Drillbot 409 may include a motor, drive axle, wheels, frame and other components shown and described herein.

[00235] The painting machine includes end effector 415. End effector may be a pail of paint. Drillbots 409, 411 and 413 may be configured to move end effector to any target location on surface 401. Drillbots 409, 411 and 413 may be controlled by custom software.

[00236] The custom software may coordinate movement of drillbots 409, 411 and 413.

The custom software may coordinate movement of end effector 415 coupled to drillbot 413. Drillbots 409, 411 and 413 may execute paint and motion plans generated by the custom software. For example, the custom software may configure drillbot 413 to dump paint at target location above surface 401. The target locations may be specified by creator 417 using a GUI.

[00237] The target locations may be specified by the custom software using a machine learning algorithm. The machine learning algorithm may "learn" a painting style associated with creator 417 and the custom software may produce output 419 on surface 401 in accordance with the painting style. The machine learning algorithm may learn a painting style based on analysis of electronic input data associated with works produced by creator 417.

[00238] A painting machine may include any number of drillbots. For example, two or more drillbots may operate on rail 403. A painting machine may include more rails than rails 403, 405 and 407. For example, a painting machine may include a rail (and associated drillbot) that is oriented perpendicular or oblique, to surface 401. A painting machine may also include two or more end effectors. Each drillbot may be coupled to one or more end effectors.

[00239] A painting machine as shown in FIG. 4 may be used for painting large surfaces.

The painting machine may position an end effector over portions of surface 401 (e.g., a middle of the surface) that are not easily accessible by creator 417.

[00240] FIG. 5 shows illustrative drillbot 500. Drillbot 500 may include one or more features of drillbots 409, 411 and 413 (shown in FIG. 4). Drillbot 500 is shown on rail 405. Drillbot 500 is powered by drill 505. Drill 505 may be powered by battery pack 507.

[00241] A drill bit affixed to drill 505 may be coupled to drive axle 508. Using dill 505 to drive axle 508 may provide operational advantages. For example, using dill 505 to drive axle 508 may provide relatively high torque, ease of portability, battery compatibility (with other drillbots), ergonomics and a dual speed clutch. Drill 505 may drive axle 508 even when a drillbot is carrying a heavy payload, such as a full 1 or 5 gallon can of paint.

[00242] Drive axle 508 is mounted onto frame 509 by bracket 511. Rotational movement provided by drill 505 may turn drive axle which may, in turn, drive wheel 501. Wheel 501 may include a coefficient of friction that allows drill 505 to drive wheel 501 along rail 405 without losing traction. Wheel 501 and drive axle 508 may be secured to frame 509 by opposing frame 501.

[00243] Drillbot 500 may include a microcontroller (not shown). The microcontroller may control torque applied by drill 505 to drive axle 508. For example, the microcontroller may determine a direction of the torque. A direction of the torque may determine which direction drillbot 500 moves along rail 405.

[00244] The microcontroller may control a magnitude of torque applied by drill 505 to drive axle 508. The magnitude of the torque may determine how fast drillbot 500 moves along rail 405. The microcontroller may receive motion control instructions from custom software. The custom software may coordinate motion of control of two or more drillbots. The microcontroller may communicate with drill 505 via wired or wireless communication links. The microcontroller may communicate with the custom software via any suitable communication link. [00245] As disclosed herein, illustrative communication links may utilize any suitable protocol over any suitable transmission medium. For example, illustrative communication links may include radio transmission, wired, auditory, light/infra-red etc.

[00246] Drillbot 500 includes adjustability mechanism 513. Adjustability mechanism 513 may adjust how snugly drillbot 500 is secured to rail 405. In some embodiments, adjustability mechanism 513 may be dynamically controlled by the microcontroller or custom software.

[00247] Dynamic adjustment of adjustability mechanism 513 may inject a tunable level of noise or "controlled chaos" into marks produced by a painting machine that includes drillbot 500. Likewise, dynamic adjustment of torque supplied by drill 505 may inject a tunable level of noise or "controlled chaos" into marks produced by a painting machine that includes drillbot 500.

[00248] FIG. 6 shows illustrative drillbot components 600. Components 600 include frame 601. Frame 601 includes adjustability channel 609. Components 600 include frame 603. Frame 603 includes adjustability channel 613. A position of wheel 615 may be adjusted by moving bracket 611, and an associated axle running though wheel 615, along posts 619 and 621. The axle running though wheel 615 may be moveable within channels 613 and 609. Frames 601 and 603 may provide support for wheel axles such as wheel axle 623.

[00249] Components 600 include spacers 617. Spacers 617 may position a drill (such as drill 505, shown in FIG. 5) on frame 601 with respect to drill bit 627. Drill bit 627 may be rotational coupled to drive axle 625 via coupling 607. Coupling 607 may transfer rotation of drill bit 627 (provided by drill 505) into rotation of drive axle 625. Drivel axle 625 may drive wheel 605.

[00250] FIG. 7 shows illustrative view 700 of drillbot components 600 (shown in FIG. 6).

View 700 shows that frame 603 includes holes 703. Spacers, such as spacers 617 (shown in FIG. 6) may by attached to frame 603 via holes 703. The spacers may position a drill, such as drill 505, on frame 603.

[00251] View 700 also shows bracket 701. A position of wheel 615 may be adjusted by moving bracket 707, and an associated axle running though wheel 615, within channels 613/609 and along posts 619/621. [00252] FIG. 8 shows illustrative view 800 of drillbot components 600 (shown in FIG. 6).

View 800 shows wheel 801. Frames 601 and 603 may support axle 623 that runs through wheel 801.

[00253] FIG. 9 shows illustrative view 900 of drillbot components 600 (shown in FIG. 6).

View 900 shows wheels 605, 801 and 615. Wheel 605 may be drive wheel and is coupled to drive axle 625. Drive axle 625 may be driven by drill 505 (shown in FIG. 5). Drive axle 625 may turn wheel 605 and move a drillbot along a rail. Wheels 605 and 801 may be positioned on a first side of a rail. Wheel 615 may be positioned on an opposing side of the rail.

[00254] A triangular shape of frames 601 and 603 may allow a particular wheel to be positioned on any desired side of a rail. For example, drive wheel 605 may be positioned on a first side of a rail and wheels 801 and 615 may be positioned on an opposing side of the rail.

[00255] FIG. 10 shows illustrative system components 1000 of a painting machine that includes drillbots. System components 1000 include drillbot components. Drillbot components include a drill motor. Drillbot components include a battery. The battery may be used to power the drill motor. The battery may be used to power movement of an end effector coupled to a drillbot.

[00256] Drillbot components include a motion encoder. The motion encoder can be used for velocity of positional feedback. Drillbot components may include miscellaneous peripheral devices.

[00257] A drillbot may include a microcontroller unit (MCU). The MCU may control operation of the drill and/or drillbot. For example, the MCU may adjust torque generated by the drill motor. The MCU may change a direction of torque generated by the drill motor. The MCU may change a magnitude of torque generated by the drill motor. The MCU may control the drill motor such that a wheel driven by the drill motor moves the drillbot along a rail without losing traction. The MCU may alter a speed/acceleration of a drillbot based on motion commands generated by the custom software.

[00258] Such motion commands may accounts to a variable payload carried by a drillbot. For example, scenario 400 (shown in FIG. 4) shows a drillbot carrying a paint can and applying paint from the can to surface 401. The MCU may alter a speed/acceleration of a drillbot based on paint remaining in the can. [00259] FIG. 10 shows that the MCU may receive control signals or other instructions using a wireless radio interface. The MCU may include a communication circuit. The communication circuit may include the network interface, adapter or other hardware for receiving and transmitting communication signals. FIG. 10 shows that a MCU may wireless communicate using a 915 mHz signal.

[00260] FIG. 10 shows that the MCU on the drillbot may receive wireless signals from a radio transmitter. The radio transmitter may be controlled by another MCU of a computer server.

[00261] A computer server may include hardware, such as one or more integrated circuits that form a chipset. The hardware may include digital or analog logic circuitry configured to perform any suitable (e.g., logical) operation. A computer server may include one or more of the following components: I/O circuitry, which may include a transmitter device and a receiver device and may interface with fiber optic cable, coaxial cable, telephone lines, wireless devices, PHY layer hardware, a keypad/display control device or any other suitable encoded media or devices; peripheral devices, which may include counter timers, real-time timers, power-on reset generators or any other suitable peripheral devices; a logical processing device, which may compute data structural information, structural parameters of the data, quantify indices; and machine-readable memory.

[00262] Machine-readable memory may be configured to store, in machine-readable data structures: electronic input data, paint plan data, motion plan data or any other suitable information or data structures. Components of a computer server may be linked by a system bus, wirelessly or by other interconnections. Server components may be present on one or more circuit boards. In some embodiments, the components may be integrated into a single chip. The chip may be silicon-based.

[00263] The server may include RAM, ROM, an input/output ("I/O") module and a non- transitory or non-volatile memory. The I/O module may include a microphone, button and/or touch screen which may accept user-provided input. The I/O module may include one or more of a speaker for providing audio output and a video display for providing textual, audiovisual and/or graphical output.

[00264] Custom software applications may be stored within the non-transitory memory and/or other storage medium. The custom software applications may provide instructions to the processor for executing paint and motion planning. Alternatively, some or all of computer executable instructions of the custom software may be embodied in hardware or firmware components of a drillbot, mounting system or other painting machine components.

[00265] As shown in FIG. 10, a computer server may operate in a networked environment.

The server may be part of two or more networks. The server may support establishing network connections to one or more remote servers. Network connections may include a local area network ("LAN") and a wide area network ("WAN"), and may also include other networks. When used in a LAN networking environment, a node may be connected to the LAN through a network interface or adapter.

[00266] When used in a WAN networking environment, a server may include a modem, antenna or other circuitry for establishing communications over a WAN, such as the Internet. The communication circuit may include the modem.

[00267] The existence of any of various well-known protocols such as TCP/IP, Ethernet,

FTP, HTTP and the like is presumed, and a server can be operated in a client-server configuration to permit a user to retrieve web pages from a web-based server. Web browsers can be used to display and manipulate data on web pages.

[00268] FIG. 10 also shows the computer server may be linked to a controller. The controller may a mobile device such as a tablet, laptop or other personal computing devices. The controller may also be a smartphone, other "smart" devices (e.g., watches, eyeglasses, clothing having embedded electronic circuitry) or any other suitable device for receiving, storing, transmitting and/or displaying electronic information.

[00269] The controller may provide access to a control interface. The control interface may include a GUI.

[00270] FIG. 11 shows illustrative end effector 1100 that includes an air brush tool. End effector 1100 may be mounted to tool plate 1101. Tool plate 1101 may be affixed to a mounting system of a painting machine. End effector 1100 may include paint stored in a reservoir. Paint from the reservoir may be mixed with compressed air carried via conduit 1115.

[00271] The compressed air may atomize the paint spraying fine "mist" of paint onto a surface. Marks made by an airbrush may be controlled by regulating a proportion of air and paint mixed within airbrush body 1103. End effector 1100 includes actuator 1105. Actuator 1105 may regulate an amount of compressed air that enters airbrush body 1103. End effector 1100 includes actuator 1107. Actuator 1107 may regulate an amount of paint that enters airbrush body 1103. Actuator 1105 may also control an amount of paint that enters airbrush body 1103.

[00272] Actuator 1 105 may be mechanically linked to actuator 1107 via member 1109.

Member 1109 may allow a movement of actuator 1107 to trigger movement of actuator 1105. Member 1109 may allow a movement of actuator 1105 to trigger movement of actuator 1107.

[00273] Actuators 1105 and 1107 may be moved by member 1117. End effector 1100 may combine two actuators into a single actuator. An airbrush may include a button that controls flow on/off, and this button can be angled to control flow rate. Member 1117 is a cylinder positioned around the button and allows the button to be angled by coupling member 1117 to a servomechanism (e.g., 1113 or 1111). Member 1117 is crossed by actuatorl 105, which may be depressed to actuate the button using another servomechanism (e.g., either 1113 or 1111).

[00274] End effector 1100 includes motor 1111. Motor 1111 may be a servomechanism.

Motor 1111 may control movement of actuator 1107. End effector 1100 includes motor 1113. Motor 1113 may be a servomechanism. Motor 1113 may control movement of actuator 1105.

[00275] End effector 1100 may include a single-action mechanism that regulates air flow into airbrush body 1103. End effector 1100 may include a dual or double-action mechanism that allows for simultaneous adjustment of both air and paint/color.

[00276] End effector 1100 may include two or more reservoirs of paint. Paint stored in a first reservoir may be mixed with paint stored in a second reservoir to create a desired color or consistency. In some embodiments, paint stored in a reservoir may not be regulated by actuator 1105.

[00277] Movement of actuators 1105 and 1107 may be controlled by custom software and paint/motion plans generated by the custom software. For example, the proportion of air and paint mixed within airbrush body 1103 may be controlled by the custom software. The custom software may control the proportion of air and paint mixed within airbrush body 1103 based on electronic input data. The custom software may control the proportion of air and paint mixed within airbrush body 1103 based on a location of end effector 1100 relative to a surface.

[00278] Custom software may coordinate actuation of actuators 1107 and 1105 by motors

1111 and 1113. Coordinated control of actuators 1105 and 1107 may regulate a proportion of paint/air that enters airbrush body 1 103. Coordinated control of actuators 1 105 and 1 107 may regulate mixing of paint from two or more reservoirs.

[00279] The custom software may control a degree of atomization of paint stored in a reservoir. The custom software may control any suitable aspect of airbrush end effector 1 100 to produce a desired mark on a surface.

[00280] FIG. 12 shows an illustrative view 1200 of end effector 1 100 (shown in FIG. 1 1).

[00281] FIG. 13 shows illustrative end effector 1300 that includes a paint brush tool. End effector 1300 includes applicator 1301. Applicator 1301 may include bristles. Applicator 1301 may include a foam applicator. End effector 1300 may be configured to rotate about axis LB. End effector 1300 may be configured to rotate during movement over a surface. End effector 1300 may be rotated or moved based on paint/motion plans generated by the custom software.

[00282] End effector 1300 includes housing 1307. Housing 1307 may store a paint reservoir. Paint from the reservoir may be transferred to toe 1301 via conduit 1305. An amount of paint transferred to applicator 1301 may be controlled by the custom software.

[00283] End effector 1300 may be affixed to a mounting system via member 1309. The mounting system may move end effector 1300 rotationally or longitudinal, based on paint/motion plans generated by the custom software.

[00284] End effector 1300 includes actuator 13 1 1. Actuator 13 1 1 may allow a creator to dynamically change a behavior of end effector 1300 while end effector is operating under control of the custom software. For example, using actuator 13 1 1 , a creator may add more paint to applicator 1301. Using actuator 13 1 1 , a creator may suspend application of paint by applicator 1301. While application of paint is suspended, end effector 13 1 1 may continue to follow a motion plan computed by the custom software. Using actuator 13 1 1 , a creator may change a color of paint applied by applicator 1301. .

[00285] FIG. 14 shows illustrative end effector 1400 that includes inkjet head 1407. Inkjet head 1407 includes nozzle array 143 1. Nozzle array 143 1 may include any suitable number or arrangement of nozzles that release paint/ink from inkjet head 1407 onto a surface. End effector 1400 may include paint reservoirs 1419 and 1417. Each paint reservoir may store paint. [00286] End effector 1400 may include a multiplexing mechanism for selecting a source of paint (or other chemical) from one of many reservoirs. The multiple reservoirs may be multiplexed via a mechanical mechanism controlled by a computer or human creator.

[00287] Pump 1421 may regulate pressure within reservoir 1419. Pump 1423 may regulate pressure within reservoir 1417. In some embodiments, pressure may be manually adjusted. For example, pressure may be manually adjusted by providing an inlet/outlet port for blowing air or sucking air out of an ink/paint circulation system of end effector 1400. Pressure may be manually adjusted using a syringe inserted into an air inlet/outlet port. Manual adjusting pressure may provide noise that produces a mark having a desired visual effect.

[00288] End effector 1400 includes circuit boards 1415, 1413, 1411 and 1409. These circuit boards may include one or more microcontroller units that control operation of inkjet head 1407 and associated nozzle array 1431. For example, circuit boards 1415, 1413, 1411 and 1409 may include one or more of a Print Controller Card and Head Driver Card. One or more of circuit boards 1415, 1413, 1411 and 1409 may receive signals from a motion controller or paint planner. Circuit boards 1415, 1413, 1411 and 1409 may receive wireless signals. Circuit boards 1415, 1413, 1411 and 1409 may be affixed to substrate 1427.

[00289] End effector 1400 includes motor 1433. Motor 1433 may rotate inkjet head 1407 about axis AR. End effector 1400 includes a planetary gear 1405. Motor 1433 may turn planetary gear 1405. Planetary gear 1405 includes teeth that engage internal gear 1403 and rotate inkjet head 1407 about axis AR. Inkjet head 1407 may be rotated 360° about axis AR.

[00290] Inkjet head 1407 may be rotated using the planetary gear 1405, allowing inkjet head 1407 to be oriented along a changing vector path, similar to a brush stroke made by a human creator.

[00291] Inkjet head 1407 may be linked to reservoir 1429. Reservoir 1429 may be in fluid communication with reservoirs 1419 and 1423. Pumps 1421 and 1423 may pressurize paint within reservoir 1429.

[00292] End effector 1400 may be affixed to a mounting system via tool plate 1401 and bracket 1425.

[00293] FIG. 15 shows illustrative view 1500 of end effector 1400 (shown in FIG. 14).

Components 1505, 1503 and 1501 show illustrative adapters that allow an end effector/mounting system to be compatible with interchangeable tools. [00294] FIG. 16 shows another illustrative view 1600 of end effector 1400 (shown in FIG.

14).

[00295] FIG. 17 shows yet another illustrative view 1700 of end effector 1400 (shown in

FIG. 14).

[00296] FIG. 18A shows illustrative ink circulation systems 1801 and 1803.

[00297] System 1803 shows a two reservoir ink circulation system. System 1803 includes reservoir 1802. System 1803 includes reservoir 1804. Ink pump 1814 may move ink from reservoir 1802 to inkjet housing 1806 via conduit 1810. Ink pump 1814 may be configured to move ink through inkjet housing 1806 through conduit 1808 and into reservoir 1804. Ink pump 1814 may be configured to move ink from reservoir 1804 back into reservoir 1802.

[00298] System 1803 includes vacuum pump 1818. Vacuum pump 1818 may be configured to generate pressure within system 1803. Vacuum pump 1818 may generate pressure by extracting air from reservoir 1804. System 1803 includes pressure sensor 1816. Pressure sensor 1816 may monitor pressure generated by vacuum pump 1818. Vacuum pump 1818 may regulate the amount of pressure within system 1803 based on feedback received from pressure sensor 1816.

[00299] Inkjet housing 1806 may include an inkjet head (not shown). System 1803 includes filter 1812. Filter 1812 may ensure that ink circulated through inkjet housing 1806 does not contain particles that may clog a nozzle of the inkjet head. Filter 1812 may prevent particles larger than a threshold size from entering reservoir 1802.

[00300] FIG. 18A also shows system 1801. System 1801 is an exemplary self-contained ink circulation system. System 1801 may control pressure and ink circulation using pump 1815. Pump 1815 may move ink through conduit 1809.

[00301] System 1801 includes reservoir 1805. Ink or other medium may be stored in swap-able reservoirs. Swap-able reservoirs may be added or removed from system 1801.

[00302] System 1801 includes valve 1807. Valve 1807 may regulate a flow of ink from reservoir 1805 into conduit 1809. Valve 1807 may regulate the flow of ink from reservoir 1805 into conduit 1809 in response to pressure generated by pump 1815. Pump 1815 may maintain a target pressure in the conduit 1809 and inkjet housing 1811.

[00303] System 1801 includes pressure sensor 1813. Pressure sensor 1813 may detect changes in pressure within conduit 1809. Pump 1815 may be responsive to the changes in the pressure detected by pressure sensor 1813. For example, in response to a detected loss of pressure, pump 1815 may increase pressure within conduit 1809 to maintain a target pressure. In response to a detected increase in pressure, pump 1815 may stop pumping or release pressure, to maintain the target pressure.

[00304] Pump 1815 may include an Archimedes screw. An Archimedes screw may include a screw within a hollow pipe. Turning the screw moves liquid though the pipe. Conventional pumps rely on mechanisms which move fluid in oscillating bursts. Such bursts may cause pressure waves in an ink circulation system. Such pressure waves may create a turbulent flow which may reduce quality and consistency of painting output using an inkjet head.

[00305] An Archimedes screw may provide a fluid pump which induces a constant pressure in conduit 1809 and inkjet housing 1811 and improve a consistency of painting output using an inkjet head included in inkjet housing 1811. The Archimedes screw may be rotated as the armature in an electric motor.

[00306] The pump may maintain a target pressure during movement of the receptacle, conduit or end effector. Movement may include rotation of the receptacle, conduit or end effector.

[00307] Inkjet housing 1811 may include an inkjet head (not shown). System 1801 includes filter 1803. Filter 1803 may ensure that ink circulated through inkjet housing 1811 does not contain particles that may clog a nozzle of the inkjet head. Filter 1803 may prevent particles larger than a threshold size from entering reservoir 1805.

[00308] FIG. 18B shows system 1850. System 1850 is an exemplary self-contained ink circulation system. Ink cartridge (or reservoir) 16 stores a medium such as ink 6. Ink cartridge (or reservoir) 16 may include a quantity of air 1. Ink cartridge (or reservoir) 16 may be installed above print head 10. Print head 10 may include an arrangement of nozzles. Connections 2 and 3 may mate with ink cartridge 16. Connections 2 and 3 may allow ink cartridge 16 to be swap- able, in or out, of system 1850.

[00309] Ink cartridge 16 may include a transparent portion that allows viewing a quantity of ink 6 remaining in ink cartridge 16. For example, view A shows that ink cartridge 16 includes transparent portion 4. Transparent portion 4 also includes marks that correspond to an amount of ink 6 remaining in ink cartridge 16. Transparent portion 4 may also include marks that correspond to an amount of air 1 in ink cartridge 16.

[00310] After installing ink cartridge 16 above print head 10, plug 5 may be removed from ink cartridge 16. Removing plug 5 allows ink 6 (inside ink cartridge 16) to be exposed to atmospheric pressure.

[00311] In operation, when valve 7 is open, ink 6 flows through damper 8 and positive pressure sensor 9 to print head 10. Ink 6 flows through print head 10 and may fill print head 10.

[00312] Suction pump 11 may be activated. Suction pump 11 feed ink through negative pressure sensor 12 back to ink cartridge 16. Suction pump 11 may build a target negative pressure within system 1850. Pressure data received from sensors 9 and 12 are processed and calculated in microcontroller 13. Based on the pressure data, microcontroller may drive appropriate voltages that control operation of pump 11 and maintain a target meniscus pressure.

[00313] Preferably, a constant meniscus pressure is maintained. Meniscus pressure is determined, based on pressure at inlet port 10a (measured relative to atmospheric pressure) of print head 10 and pressure at outlet port 10b (measured relative to atmospheric pressure) of print head 10. An illustrative meniscus pressure may be about, or equal to, -10 kPa. However, a target meniscus pressure may be any suitable value for a given print head.

[00314] Based positive pressure at inlet port 10a, microcontroller 13 may determine a target negative pressure at outlet port 10b to maintain a target meniscus pressure. A volume of ink 6 inside ink cartridge 16 is a contributor of positive pressure at inlet port 10a and accordingly, influences the meniscus pressure. A volume of ink 6 within ink cartridge 10 may change during operation of a paint machine. Microcontroller 13 may coordinate control of pump 11 to build/maintain the target meniscus pressure.

[00315] Using system 1850, ink flow through print head 10 may vary without effecting painting quality as long as a target meniscus pressure is maintained. For example, ink flow may vary from 30 to 100 mL/min.

[00316] System 1850 may provide an ink circulation/pressure system that allows a print head to be rotated, twisted, turned (including turning print head 10 upside down) or otherwise moved in any fashion a mounting system is capable of providing, to produce a mark defined in an electronic input data. [00317] System 1850 may allow print head 10 to predictably, consistently and reliably produce a mark on surface, regardless of an orientation of print head 10. An end effector that includes system 1850 may predictably, consistently and reliably produce the mark, as defined by the electronic input data.

[00318] For example, if a mark is defined by a non-linear pathway that includes 360° rotation (about any axis), twisting, turning, or any other movement a mounting system is capable of providing, an end effector that includes system 1850 may predictably, consistently and reliably produce the mark, as defined by the electronic input data.

[00319] Ink cartridge 16 may include a volume of ink 6 that is in acceleration and causes pressure blows. A design of ink cartridge 16 may reduce pressure blows. Preferably, ink cartridge may have a narrow base in relation to an acceleration axis.

[00320] Microcontroller 13 may include push button 14. Button 14 may trigger a purging of print head 10. Microcontroller 13 may include button 15. Button 15 may trigger a shutdown of system 1850. Button 15 may stop operation of pump 11 and close valve 7.

[00321] Suction pump 11 may be peristaltic. Suction pump 11 may be an Archimedes screw. When suction pump 11 is non- peristaltic, a valve 17 may be added to system 1850. Valve 17 may be a non-return valve that prevents ink 6 from leaking out of print head 10 when system 1850 is powered off or in the event of a power failure. Actuation of button 15 may trigger closing of valve 17.

[00322] FIG. 18C shows illustrative criteria 1860 for determining a meniscus pressure. A meniscus pressure may be determined based on assuming that a flow channel resistance is similar at both Pin and Pout. A meniscus pressure may be determined at time the print head is not printing/painting.

[00323] Criteria 1860 include:

[00324] Pn - nozzle pressure in kPa;

[00325] Sp - ink specific gravity in kg/m3;

[00326] g - Earth gravity 9.8 m/s2;

[00327] hi - positive-pressure ink height (in mm);

[00328] h2 - negative-pressure ink height (in mm); and

[00329] Pp - pump pressure in kPa. [00330] Based on criteria 1860, microcontroller 13 may determine a meniscus pressure based on the following: Pp =2*Pn - Sg*g(hl+h2)* 10E-6.

[00331] FIG. 18D shows illustrative views 1870 of ink cartridge 1871. Ink cartridge 1871 may include one or more features of ink cartridge 16 (shown in FIG. 18B). A volume of ink (or other medium) 6 contained within ink cartridge 1870 may be defined by H * W * D. To reduce pressure blows, it is preferable to decrease W. To maintain a target volume of ink H may be increased. Furthermore, ink cartridge 1870 includes internal walls 1873. Internal walls 1873 may reduce an impact of dynamic wave pressure due to movement of ink 6 within ink cartridge 1871. Holes 1875 in a bottom of internal walls 1873 may provide for static pressure balance between volumes of ink 6 separated by internal walls 1873.

[00332] FIG. 19 shows illustrative mark 1900. Mark 1900 may be defined by electronic input data. Mark 1900 follows a non -linear pathway. Mark 1900 includes overlaps 1901 and 1903. Apparatus and methods described herein may configure an end effector to deposit a medium on a surface by following the non-linear pathway and overlaps associated with mark 1900.

[00333] FIG. 20 shows illustrative mark 2000. Mark 2000 includes marks 2001, 2005 and

2003. Mark 2001 may be generated based on altering properties associated with mark 1900 (shown in FIG. 19). For example, mark 2001 may be generated by rotating the non-linear pathway of mark 1900.

[00334] Marks 2005 and 2003 may be added to mark 2001 after mark 2001 is output by an end effector. In a first example, a creator may use traditional painting techniques to add marks 2003 and 2005. A paint machine may include sensors that capture input of the creator and system -generate electronic input data based on the captured input.

[00335] In a second example, a creator may generate electronic input data associated with mark 2000 that defines a sequential layering of marks 2001, 2003 and 2005. The electronic input data may include properties that require mark 2001 to be produced on a surface before outputting marks 2003 and 2005. A sequential layering of marks 2001, 2003 and 2005 may preserve a visual effect of traditional mark layering techniques. A painting machine, as described herein, may configure an end effector to produce mark 2000 by sequentially layering medium on a surface, as defined in the electronic input data. [00336] FIG. 21 shows illustrative mark 2100. Mark 2100 includes marks 2101, 2103 and

2105. Mark 2100 may be generated based on altering properties associated with mark 1900 (shown in FIG. 19). For example, mark 2100 may be generated by duplicating mark 1900 at different locations on a surface.

[00337] Electronic input data may define a sequential layering order of marks 2101, 2103 and 2105 to produce composite mark 2100. For example, the sequentially layering order may require mark 2103 be produced first, then mark 2105 and then mark 2101. Each of marks 2101, 2103 and 2105 may be associated with unique properties. For example, marks 2101, 2103 and 2105 may have different widths. Marks 2101, 2103 and 2105 may be associated with different colors or paints of differing viscosities.

[00338] To produce a desired visual effect, marks 2101, 2103 and 2105 must be produced by following the sequential layering order. Altering the order may produce a composite mark that does not have the desired visual effect. A painting machine, as described herein, may configure an end effector to produce mark 2100 (and its desired visual effect) by following the sequentially layering order, as defined in the electronic input data for mark 2100.

[00339] FIG. 22 shows illustrative functionality 2200 of a creator interface for a painting machine. The creator interface may include one or more features of GUI 200 shown in FIG. 2. A painting machine, as described herein, may include custom software that receives the electronic input data and controls an end effector to produce output that includes irregularities and chaotic elements defined in the electronic input data.

[00340] The painting machine may include a creator interface that calibrates input tools and associated end effector control to generate an output that more accurately depicts a creator's intent and design. Such a creator interface may receive creator input with awareness that an output produced by the end effector includes irregular and chaotic markings.

[00341] Functionality 2200 includes menu panel 2201. Menu panel 2201 shows image

2203. The creator interface may segment image 2203 into layers 2205, 2207, 2209 and 2211. A creator may drag one or more of layers 2205, 2207, 2209 and 2211 onto virtual canvas 2213.

[00342] The creator may drag and drop one or more of layers 2205, 2207, 2209 and 2211 onto virtual canvas 2213. The creator may assign a sequential layering order for outputting one or more of layers 2205, 2207, 2209 and 2211. The creator may alter one or more of 2205, 2207, 2209 and 2211. For example, using color palette 2215, the creator may change or add color of a layer. On virtual canvas 2213, a creator may create new layers.

[00343] The creator interface may digitally simulate visual effects of opaque or translucent variations of colors. The creator interface may digitally simulate visual effects of associated with volumetric components of the layers. The digital simulations may be saved along with associated creator input. The digital simulations may be saved as properties of electronic input data. The painting machine may configure an end effector to produce tangible output that embodies the visual effect digitally simulated by the creator interface.

[00344] FIG. 23 shows illustrative functionality 2300 of the creator interface for the painting machine. Functionality 2300 shows that the creator has created composite mark 2307. Composite mark 2307 has been created by a creator by adding layers 2209 and 2303.

[00345] FIG. 24 shows illustrative functionality 2400 of the creator interface for the painting machine. Functionality 2400 shows that the creator has modified composite mark 2307 by adding free-hand brush strokes. Composite mark 2307 has been created by a creator by adding layers 2209 and 2303.

[00346] Functionality 2400 shows that color panel 2405 may show an active color and a size of an active mark that will be made if the color is applied to virtual canvas 2213.

[00347] FIG. 25 shows illustrative functionality 2500 of the creator interface for the painting machine. Functionality 2500 shows that the creator has added mark 2501 to the virtual canvas. The creator interface may record each mark added (or deleted) by a creator as separate action objects. By sequencing actions performed by the creator, the creator interface may provide functionality for the order, repeat, and selective removal of marks. Each action taken by a creator while working on virtual canvas 2213 may be stored as a separate layer.

[00348] FIG. 26 shows illustrative functionality 2600 of the creator interface for the painting machine. Functionality 2600 shows that that a creator has added mark 2603 on top of mark 2501. Functionality 2600 shows that mark 2603 has been added as layer 2605.

[00349] Functionality 2600 also shows that actions executed by the creator on virtual canvas 2213 (e.g., layers added and brushstrokes) may be represented as HTML elements 2601.

Paint and motion plans may be generated based on HTML elements 2601.

[00350] FIG. 27 shows illustrative workflow 2700. Workflow 2700 shows illustrative steps that may be taken by a creator. At step 2701, the creator adds an image to workflow 2700. Adding the image may add image assets 271 1 associated with the image. Such assets may include properties stored in electronic input data.

[00351] At step 2703, the creator adds strokes (using an artistic tool) to the image. The strokes may be associated with stroke configurations 2713. Illustrative stroke configurations may include a brush type, bristle density, color applied and orientation of the tool as the strokes are applied. Stroke configurations 2713 may include properties stored in electronic input data.

[00352] At step 2705, the creator may add another image. At step 2707, the creator adds additional strokes (using an artistic tool) to the images and prior strokes. Steps 2701, 2703, 2705 and 2707 may be stored as electronic input data.

[00353] At step 2709 the creator may trigger production of an output based on one or more steps in workflow 2700. The output may be produced by an end effector of the painting machine based on motion control corresponding to the sequential steps of workflow 2700. The output may be produced by an end effector using a 2.5D painting process that maintains a visual effect of layering defined by the sequential steps of workflow 2700.

[00354] FIG. 28 modification 2800 to illustrative workflow 2700. Modifications 2800 show that a creator has removed the image of step 2701. Removing the image of step 2701 may also remove image assets associated with that image.

[00355] Modifications 2800 shows that the creator has added additional strokes at step 2801. Modifications 2800 show that the creator may alter the strokes of step 2703. A creator may alter any suitable property of steps in a workflow created using the creator interface.

[00356] Modifications 2800 may form a new electronic input data. The new electronic input data may be produced (in a desired sequential order) by an end effector of the painting machine.

[00357] FIG. 29 shows illustrative functionality 2900 of the creator interface for the painting machine. Functionality 2900 shows that the individual actions and progress states may be accessed by directly clicking on them on the virtual canvas 2213 or through the action bar 2901 and progress bar 2903.

[00358] Action bar 2901 may provide a visual depiction of individual marks added to a work in progress. Progress bar 2903 may provide a visual depiction of a cumulative effect of adding marks to the work in progress. [00359] The computer code included the appendix and custom software referenced herein may be executed by a computer system. The computer system may include a processor circuit. The processor circuit may include a processor for controlling overall operation of the computer system and its associated components. The computer system may include RAM, ROM, an input/output ("I/O") module and a non-transitory or non-volatile memory.

[00360] The I/O module may include a microphone, button and/or touch screen which may accept user provided input. The I/O module may include one or more of a speaker for providing audio output and a video display for providing textual, audiovisual and/or graphical output. The video display may include one or more OLEDs.

[00361] Software may be stored within the non-transitory memory and/or other storage medium. The software may provide instructions to the processor for enabling the computer system to perform various functions. For example, the non-transitory memory may store software used by the computer system, such as an operating system, application programs, and an associated database. Alternatively, some or all of computer executable instructions of the computer system may be embodied in hardware or firmware components of the computer system.

[00362] Application programs, which may be used by the computer system, may include computer executable instructions for invoking user functionality related to communication, such as email, short message service ("SMS"), and voice input and speech recognition applications. Application programs may utilize one or more algorithms that request alerts, process received executable instructions, perform power management routines or other suitable tasks.

[00363] The computer system and associated software may operate in a networked environment. The computer system and associated software may support establishing network connections to one or more remote computer systems. Such remote computers may be personal computers or servers. The network connections may include a local area network ("LAN") and a wide area network ("WAN"), and may also include other networks. When used in a LAN networking environment, the computer system may be connected to the LAN through a network interface or adapter. The communication circuit may include the network interface or adapter.

[00364] When used in a WAN networking environment, the computer system may include a modem or other means for establishing communications over a WAN, such as the Internet. The communication circuit may include the modem. [00365] It will be appreciated that the network connections shown are illustrative and other means of establishing a communications link between devices may be used. The existence of any of various well-known protocols such as TCP/IP, Ethernet, FTP, HTTP and the like is presumed, and the computer system can be operated in a client-server configuration to permit a user to retrieve web pages from a web-based server. Web browsers can be used to display and manipulate data on web pages.

[00366] The computer system may include various other components, such as a battery, speaker, and antennas (not shown). For example, computer system may include portable devices such as a laptop, tablet, smartphone or any other suitable device for receiving, storing, processing, transmitting and/or displaying relevant information.

[00367] The computer system may be operational with numerous other general purpose or special purpose computing system environments or configurations. Examples of well-known computing systems, environments, and/or configurations that may be suitable for use with the invention include, but are not limited to, personal computers, server computers, hand-held or laptop devices, tablets, mobile phones and/or other personal digital assistants ("PDAs"), multiprocessor systems, microprocessor-based systems, set top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like.

[00368] The computer system may utilize computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The computer system may be operational with distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.

[00369] Thus, apparatus and methods for COMPUTERIZED END EFFECTOR

MANIPULATION have been provided. Persons skilled in the art will appreciate that the present disclosure can be practiced by other than the described embodiments, which are presented for purposes of illustration rather than of limitation. The present disclosure is limited only by the claims that follow. Appendix

(computer program listing)

using System; 66

¾sing System. Collections . Concurrent ;

Ώ.s ng Sys tern.10. Ports ;

us g Sys tem . Re f1ect i o ;

using System. Text . RegularExpressions

using' b\ eadinq . Tasks ,

namespace Oil Spill {

public class GRBL {

private static readonly ILog log =

LogManager . GetLogger (MethodBase . GetCurrentMethod C) . DeclaringType) ; private ΓATUS_WAIT_TIME

p iva e j LINE ENDING =

p ivate ConcurrentQueue<s t.ring> transmitQueue ;

private BlockingCollection<string> transmitQueue ;

private ConcurrentQueue<CommandHa dler> replyHandl ers ;

private strina buffer — "" ;

public Version CurrentVersion { get; protected set.; } private Machines ate state;

private Machines ate lastState;

private Vector3 position;

private bool homed = false;

private enurrt MachineState {

UNKNOWN ,

IDLE,

RUN ,

H0LD_C0MPLETE f

HOLD IN PROGRESS,

JOG ,

ALARM ,

DOOR CLOSED,

D00R ~ AJAR STOPPED ,

DOOR AJAR HOLDING,

DOOR CLOSED RESUMING,

CHECK,

HOME,

SLEEP,

} ;

publ c GRBL { ) {

ResetState {) ;

}

private void ResetState () {

i£ (replyHandl ers ?— null && replyHandlers . Count >— 0) {

for (int i = 0 ; i < replyHandlers . Count ; i++) {

Comma ndHandler handler ;

replyHandlers . TryDequeue (out handler) ;

handle . Fail (new Exception ( " e.¾¾ " ' ) ) ;

}

}

transmitQueue = new ConcurrentQueue<s t ring>{) ;

transmitQueue = new BlockingCollection<s ring> ( transmitQueue) ; replyHandlers = new ConcurrentOueue<CommandHandler> { ) ;

CurrentVersion = mail; 67 state = achineState . UNKNOW¾7

68 lastState = MachineState . UNKNOWN ;

60

70 position = new Vector3(0, 0, 0) ;

71 homed — false ;

72 }

74 public float; GetPositionXO {

75 return positio , x ;

77 }

77 public float GetPositionY ( ) {

77 return position. y;

70 }

1

72 public static string GetNextLine (string str) {

73 int lineEndinglndex = str . IndexOf <LINE_ENDING) ;

71

11 if (lineEndinglndex ===== -1) {

36 return null;

37 }

33

39 return st . Substring (0, lineEndinglndex); // Get rid of \ r \n

90 }

91

91; public static string RemoveNextLine {string str) {

3 int lineEndinglndex ~ str . IndexOf (LINE_ENDING) ;

if (lineEndinglndex ~~ -1) {

return null ;

}

eturn str , Substring (lineEndinglndex + LINE_ENDING. Length) ;

100 3

10 i

102 private void UpdateVersion (s ring line) {

103 Version version = new Version (line) ;

10 i

105 if (version == null) {

103 throw new Exception ( :' Oxt cted. ν»:.::;7.;;:; message");

107 }

108

103-} CurrentVersion ~ version;

i 10 }

i 11

112 public event EventHandler Connected;

113 public event EventHandler StateUpdated ;

1 1 public event EventHandler Reset;

1 5

116 // Removes the next line from the buffer, parses it,

117 // and ' u date intern .3. state based on the consent.?.

113 private void ProcessNextLine () {

119 string line = GetNextLine (this , buffer) ;

120

121 / ' / Tf not yet a complete line there s nothing to do

121; if (line == null) {

123 return;

121 }

121

120 this. buffer — RemoveNextLine (this. buffer) ;

127

126 / / Igno.::e eripty .1,1 nes

1.10 if (line = " !< ) {

111 return;

111 } 132

133 //Console .TkriteLone ; Stirring. Form;.;: ί "Processing Lias: \"{0;\"" r Line! ; ;

333

132 // After res t: GRBL will irs introduce itself, with its e sion roassage

133 if (CurrentVersion =- null) {

L¾? if ( "Version. IsVersionString (line) 5 {

132 // Ignore anything at the beqirr i no than isn't the version string 1 c3 t

1 0 }

141

142 UpdateVersion (line) ;

143 Connected (this , new EventArgs () ) ;

144 Reset (this, new EventArgs ( ) )

145 eturn ;

143 }

143

.143 if (line . Equals ("ok") ) {

149 if (replyHandlers . Count ===== 0) {

IroG throw new Exception ("Re oe.lved ;: -reply v/it.hout: pr: eoe-3 log ;: eques■: "> ;

133 }

132

133 // TOBO check against sending record

3/ CoinmanclHa ndler handler;

133 tool peekWorked ~ replyHandlers . TryPeek (out handler);

136

ί ¾7 if ( ! eekWorked) {

loo throw new Exception ( " Coord trot peek a f reply handlers");

333 1

160

161 if ( ! handler . causedMotion) {

3313 boo! haveTask ::: replyHandlers . TryDequeue (out handler);

333

333 if (!haveTask) {

333 throw new Exception i"1.3R?.ble ;:o dequeue far::;; Dsiod.e o") ;

333 }

1337

133 // Don't need to w it for -notion to finish before calling handier

133 handler. Task. Start. () ;

133 }

171 5 else if (line , Equals < " 82-148 r ; 33 $X ' ;:o orJ.cok ' ; " ) ) {

172 // TODO set: locked state

173 } else if (line . StartsWi th ( " ." ) && line . EndsWith ( " " ) ) {

.174 string contents = line . Substring ( i. , line. Length - .3);

173

173 string [] parts ■■ contents . Split ( : ') ;

177 string stateString — parts [3-];

173

173 // FIXME cirsck that there are enough values in the arrays

130 for (int i = 1 ; i < parts . Length ; i++) {

131 string part = parts [i];

132

133 striiigH typeAndValues » part. Split (' : ' )

183 string type = typeAndValues ['.;] ;

133 string [] values = typeAndValues [1] . Split (',')

136

13 4 if (type. Equals C'. t-cs " ) ) {

88 position. x = iloa t . Parse (values

183 position. «· floa t . Parse (values [ 1 ]) ;

180 position. z = flea t . Parse (values [2 ]) ;

/ /Icq hDeimq S "Cur rent position is ( {position .xrd , (position.

( osi ion., z } }

else if (type . Equals ("ttRos ") ) {

throw new Exception ( °¾ not kno how to oodate rjtate based wort: position " ;

else if (type . Equals ( "FS K ) ) {

// Ignore feed, and speed ' ί.ν'ί- } else if (type . Equals Γ :' 2" ) ) {

10 ' 1 ./ / I core Etac

00c ; } else if (type. Equals ("ΐ-ο") ) {

LOO // Ignore pin states

DO } else if (type. Equals ("Ov") ) {

13i // Ignore o erride values

202 } else if (type. Equals ("A") > ί

202 // Ignore a;;ce;i;i : y values

0 :' --i } else if (type. Equals ("La") ) {

202 / Ignore lioe :";i.i"2 i: ;?

020 } e i if (type . Equals ( :: 31 "> ) {

200 / l " gno.::c: b iler: soste

000 } else if (type. Equals ("ViCO") ) {

27 / ' / i ' qn rs vfo k ccidir:¾te offset

000 }

0 1 }

012

010 string substate —

1 :: if (stateString. Contains <" ; M ) ) {

101 string[] stateParts = stateString. Split ( ' : ' ) ;

0:0 stateString = stateParts [0] ;

00- substate — stateParts [i] ;

0.:0 }

000

002.' switch (stateString) {

221. case "Idle":

220 state = Machines ate . IDLE ;

2 0 break ;

220 case "Ron";

220 state = MachineState . RUN ;

200 break;

201 c se "HcO.o":

23 if (substate . Equals ("·. } ") ) {

2 ^ state = MachineState . HOLD COMPLETE ;

12- ; - ) else if (substate. Equals ("!">) ί

Old. state = MachineState. HOLD_ IN PROGRESS;

233 ) else {

220 th o new Exception ($ "10:; r. eoooordo'eO hold s oooto ;:e ;

\ " ; sooo: ;:a to; 0 " "> ;

234 }

200 break;

30 case " log " :

'ά Λ ' ' : state - Mach i neState . JOG ;

000 break;

22? case 001sriOO

210 state = MachineState .ALARM;

04 i break ;

242 case "Door";

040 if (substate . Equals ("0") ) {

244 state = MachineState . DOOR_CLOSED ;

243 } else if (substate . Equals ( "1 " ) ) {

246 state = Mach i n estate . DOOR_AJAR_ STOPPED ;

240 3 else if (subs t:a t e . Equals ( "2") ) { "

040 state = Machi eState . DOOR_AJAR_ HOLDING ;

04 } else if (subs t:a te . Equa Is ( " V < ) ) { "

200 state « M chi neState . DOOR_ CLOSED RESUMING;

230 3 sis® {

230 throw new Exception ($ ' ' dnreoog;o oed boor .-substate:

\ " i iOJOstote \"") ;

20 j 3

21:0 break ;

200 case "Check":

206 state = MachineState . CHECK ;

207 break;

dlcrne " :

state = MachineState. HOME; ' :.Ci: break;

2 J. case " Sl ep" :

232 state = MachineState . SLEEP ;

223 break;

3 default:

233 throw new Exception (S "driknov?:; 3R3L :s3; : J.;:; statu;: r¾ss;> :J ¾■ !<;- ;

isii. St ;:!.:;;; \'" ( ) ;

233 }

337

2 3 boo I coraraandTimeout = false;

223 if (replyHandlers . Count != 0) {

270 CoimsandHandler currentCommand ;

2?i bool gotCommand ~ replyHandlers . TryPeek (oat currentCommand) ;

273 if (!gotCommand) {

2 " 2 throw new Exception ( "ial led to peeh renl hand 2 Ϊ gueue") ;

2 5 J

0

27? long currentTime ~ DateTime . Now. Ticks / TimeSpan . Ticks PerMillisecond ;

7 7 s ; i£ {(currentTime - currentCommand. Time) > (STATUS_WAIT_ TIME * 7)5 {

373 commandTimeout = rue;

230 }

221 5

232

233 bool stateTransitioned - lastState !- state;

222. bool camrtiandTimeout ithoutRun = commandTimeout && state ~—

MachineState . IDLE ;

263 bool acti eToIdleTransition - (lastState «« MachineState . RUN | |

lastState == MachineState . HOME) && state MachineState . IDLE;

233

227 / If ;3 state changed then maybe- a cc:::::;iand completed

233 if (commandTimeoutWithoutRun I I activeToIdleTransition) I

731- // Wo were doing so:;:';thing but now we are not

233

231 if (replyHandlers . Count ∞ 3) {

232 throw new Exception ( " 33333· was ;: u! oLeg *::.t2(;;;" o.::e cedi n ; : : !io:;") ; 273 }

237

223 CommandHandler handler;

233 bool haveTask - replyHandlers . TryDequeue {out handler) ;

227

233 log. Debug i$"Ca2;.:.ng rtp;.y hand 3. si to.?: " ■ handle ;: . :,:;;;·^; :;:i ) 7 " " ) ;

233

300 if (!haveTask) {

301 throw new Exception { "e abl to deq eue task handle;:") ;

302 }

303

30¾ handler. ask. Start () ;

305 }

302

307 if (stateTransitioned) {

303 lastState = state;

309 log. Debug ($"i;tai := 2 ?: ;;.o:;3:.Lo:n : ilas; 227ata; f etnte } " } Γ

310 }

311

312 if (StateUpdated !« null) {

373 StateUpdated (this, naif EventArgs () ) ;

322 )

323 ) else if (li ne . StartsWith ( "A;.- PM ; ") ) {

373 string desc = Alamt escription (line) ;

327 log . Error {$ '772a ;n¾ ¾nc;x;:3;¾.rid: 3io .c; !: ;

322 ; else {

323 if (Version, IsVersionString (line) 5 {

32:; log .Warn ( "3R3L nee t. unex cted 7 . 2e;:;-vs?;: :: ng . , , ") ;

323 ResetState () ;

322 UpdateVersion (line) ; Reset ί this, new EventArgs O } ;

J else {

hrow new Exception (S " u:a ?:ecog;

} public void Receive (e ring data) {

this. buffer += data;

hile (this. uffer. Contains (LINE ENDING) }

ProcessNextLine () ;

5

3

public string NextToTransmit { ) {

retam transmitQueue . Take { ) ;

3

public event Even Handler ReadyToTransmi ;

private void Transmit ( st r i message) {

transmitQueue .Add (message + ;

ReadyToTransmit (this , new EventArgs ()) ; public async Task ExecuteCommand (string command, booi causedMotion) {

CommandHandler handler = new CommandHandler (command , causedMotion) replyHandlers . Enqueue (handler) ;

log . Debug ($ : 'i:x<::c:u :: i n-j coxt'iiii sa : { c.o:c::;ia; ' :d ; ") ;

Transmit (command) ;

await handler . Task ; ublic aayno Task Home() {

awai aitUntilldleO ;

await ExecuteCoitimand ( " ' 5ϊ-i " , t ue) ;

homed = t ue ; public async Task SetFeedRate (flo t feedRate) {

await. ExecuteCommand (String. Format ( "F{ 0 } " , feedRate) , false) ;

3

public async Task SetAbsolute ( ) {

await ExecuteCommand ( "S30 " , false) ;

3

public async Task. MoveTo (float x, float y) {

await ExecuteCommand (String . Format ( "Gl X { J Yil}", x, y) , true) ;

3

public async Task MoveTo (float x, float y, float z) (

await ExecuteCommand (String . Format ( "Gl X{ 0] Y Z {?.)'', x, y, z) , true) ;

3

public async Task WaitUntilldleO ί

await Task.Run(() => { do {

waitingToHome = (state ~~ MachineState . ALARM) &£ ( t homed)

Thread. Sleep (STATUS__WAIT_TIME) ; ¾δ¾ ) while { ί !waitingToHome) SS (this. state != MachineState . IDLE) > ;

143; }) ;

ιοι i

332

VsZ private static string AiarmDescription (string line) {

324 string [] parts = line. Split ( ! : >) ;

331

s'i if (parts . Length !« .·:) {

323 th ow new Exception (S 'tidsiii olor;a 4 r;:;e: \ " { 1 aoe : \ " ") ;

aOO )

1? 03

400 switch (parts [1]) {

401 case

402 re urn "Hard iroai tr.rcyyareah Ma hi e? aeaation a a likely lost Gao to saidce;;. arid iaiiincdlai 7a hai.t , ,: ;

403 case ' 71":

404 retu n :' G -cede aotlea; .;5:rq¾: e;oaoed;-; liia .;.:?!¾? i.;:av<:;. , Kac .iEi?

p" :?!. i: i e?a i¾i:i?ly ro G?; i a c; . Λ1<?;:;ιι ?>aay be aoalock.;:???; . " ;

400 case ".V " :

406 r-sfcurn "P.-osie;: whiis: in t re;; . G.;?l-1 a;;roaa.-t n;;; ra;a 7ee pa.-a.a i: 1;;;;.. Los;;?

:s toys a?;-; i r kel y . " ;

407 case "■¾":

400 return "Pro-be faaak. Tae p?:obe ±:·: ο?: :; a. the eayac;?ed iriiti.al state

!-ei:ore ato ;?:?;. ay probe cycle, whore G30G! aad 441b , 3 ?ia not: a.r :; -aero■: eG a;ad GOO.4. end. GOO, 5 :? a triggered , " ;

404? case "5 " :

410 return "Probe fail, 3;:o?:-o bad not coatact ?;;;?; κ ;: kpa eco aG. a.a:;;a the p- aaraed c?avai for G32.2 ara; G30.4.";

441 case "6";

413 return "bon! ay fail. Rosa a. eaoakng a-sta.a'o oaaaaag eyaiadG

413 case " "; G

-5.14 return "boor; ay Soil. Oorea.y doo-r !·;;;;; oo-eaed da; -?i a?:?; act;. ' -re ho;;?ioe c yaal -a . " ;

ill case "3":

ail etu n "bona ay bail. Cycle ia.alec! a.-a clear 1 :?.;;Ί ;: saaatco ;-a;ae;a

pallaaag off, 4G:y i :aaa;?eoe;. :;.y pa; 11 - add: eettb.ag or -:;heea ?>a ring, :I ;

417 case "0":

443 u n "bear ?ag real. Coo; id ;aot r;a;.:4 l.Gaia switch acathia ?iea.rch

distance. Defined, a.:?; 1... a ' ;;;¾:;; ;:;:av-i:l or; ;> ■■■ ::¾ ::ci?; ana; a '" pao?.io0:4 aea 1 oa:at o ebe sea , " ;

413 default:

410 throw new Exception ($ "bo!; aaoaa oie:::a: \ " : yaaet r 1 ] } 4 " ") ;

lei }

422 }

23

424 private class CoramandHandler {

42a public Task Task;

420 public long Time { get; private set; }

427

428 publ c readonly string command;

429 u lic readonly bool causedMotion ;

43

401 private Exception exception;

402

401 public CommandHandler (string command, bool causedMotion = false) }

404. this. Time = DateTiroe .Now. Ticks / TimeSpan . TicksPerMillisecond;

433

416 this. Task « new Task( () -> {

407 // 3ΪΧ Ε doesn't sees to wo?:k., ..

413 if (exception ?= null) {

413 throw exception;

44. ϋ }

44.1 55 ;

433

433 this . command = command;

4.33 this . causedMotion = causedMotion ; }

8

7 pxs.bl.ic void Fail (Exception e) {

8 exce tion =- e ;

5 }

5 }

i

2 public class Version {

;-:. private static Regex versionRegex = new Regex(@"Grbl ( [ 0-9] ) \ . ( [ 0-9] [a-z ] ) for help\]", RegexOptions . Compiled) ;

readonly string major;

5 readonly string minor;

2

2 public Version (string major, string minor) {

2 this. ma or = major;

2 this. minor = minor;

0 }

1

2 public Version (string str) {

3 MatchCollection matches = versionRegex. Matches (str) ;

4

2 if (matches . Count ?~ 1 j | matches [2] . Groups . Count ?~ 3) {

6 throw new Exception ($ ".ί:Ίν¾ϊ id. e.::. ;: ici! st ing : \ " i 2 ?: ; V ") ;

7 5

o

2 Match versionMatch = matches [0] ;

0 this. major = versionMatch . Groups [1 J .Value ;

1 this. minor = versionMatch . Groups [5 ]. Value ;

2 }

4

4 public static bool IsVersionString (string str) {

1 MatchCollection matches = versionRegex. Matches (str) ;

2 rstain ? (matches . Count. ?— 1 | | matches [0] , Groups . Count. ?— * ) ;

7 }

b

3 p blic st ing Vers i.o Mes s age 0 {

2 return String . Format ( "72: bl {0} i : 5 ! So;: heLp]", ToString ()) ;

1 }

2 override public bool Equa 1 s (object other) {

4 Version othe Version — other as Version;

2 i£ (otherVersion == null) {

2 return false;

8 }

2

8 eturn this . maj or . Equals (otherVersion . maj or) &&

this . minor , Equals (otherVersion . minor) ;

1 }

2

.4 override public int GetHashCode {) {

3 resturn ToString () . GetHashCode () ;

2 }

6

7 override publ c string ToString () {

3 eturn major + i: . " + minor;

3 }

0 }

1

2 public class Vectors {

3 public float x, y, z;

4

5 public Vectors {float x, float y, float z) {

8 this.x = x;

7 this . y — y;

8 this . z = z ; }

10

i ι pxs.fol.ic override strin ToStringO

J.2 return $" .; ; ,;: ; , y · , j ;d p ' ;

13 }

14

15

16

12

18 public void c !ine-c':. iis rinq gr lPo κ ::.N;sEn&■ {

port ::: new S r.laiFort igrblPor oNaffie. 115200. Fa r. i ty . None ) ;

21 // Aiioiv the :;:>?r to set trie a ρρ:: ορ· r: la 8 e rope ;: t:l .es ,

port . ScopBits : = StopBl re . Oris

5 4

525 port » Risad i;¾eo;.d:. - » READ TIMEOUT;

525 port , writeiirieoot ViRITE ΪΙΜΕ05Τ;

524

528 ρθ Γ !: .. Op-::! " : ( ) .!

525

550 grblConriected ---- t ue ;

554.

552 // I n.i tiai 1 the s;: iiiiection arid oo.en srbrrOd:. lines of d ta for processing 455 (new Thread ; i ) -> {

554 tesitAi i:;:: no ipor5:5 ;

455

555 string better - 452

556 while (port 5Ia0p¾r2 {

535 try {

545 butter · pc r 0. R¾adKr.i ¾ting ί '■ ■ ·:

544

544 if ( iJ.f f ¾r. CoQ':.air:£> ί j {

545 buffer ~ processLi no (bu f 1 or } ;

544

545 i catch i3yste;nrri;;:eoueKxceptr:n: c} i

445 cor:. : 1 :r ce ;

545

5

545

5 · ;

554

52 public void updateSstt j.nqs ( )

55 setSet ing (ϋ, 10 ) ;

554 setSet ing ; 1 r 25; ;

555 setSet ting (2 f o; ;

556 setSe t ing ( 3 f 0} ;

554 setS Otrng (4 f 0} ;

558 setS Cteng (5, 0} ;

559 set:3e Ptrng ( 6 , 0) ;

588 set Setti g (10 4 ; ;

c6i setSer tcng (ii 0.01 r ; ;

582 se-tSer 84 g ( 12 0.0521 ; ;

568 setSer t:i.nq ; 13 0; ;

864. set Se tin a (20 0;

383 se Se ting (21 5;

356 set Set ting (22 i;

36 ' 7 set: Set ting (23 0; ;

383 seOSetting (24 4- 00} ;

355 setSetting (25 1000}

¾7 ; sec.Setting (26 250) ;

¾71 seoSetting (25 J. , Of : i

setSetting (20 1000! ;

se Sat tiny ( 3i 3 ; ;

seiSett i ag ' ( 32 0 ; ; s e ?:. S e 11: 1 r; g ί 100 40,0 8;:; ;

5 s e a S e 1 t 1 :a g ( 101 ,- 40,048;:) ;

7 set.Sett.ing (102.- 188.9 7;:;

5 e tS a t t i a. g ( 110 , 5000.0 ;: ;

e tS o 11 i a g ( 111 , 3000.0 ;: } ;

5 setScttiag [112, 500! ;

i setSattiag ;ΐ2ίρ 500! ;

8 t .8 t 6 i a. g { 521 , 500 ! .;

5 £ :.Satkiag6;22, 500! ;

4 i iSatUiagplSO, 700!

5 setaetaiagpiSl, 500! .;

5 setSettiag ( 532, 200; ;

7 j

8

5 private static void resetArd irio i SerialPor 5 port; ί

0 port , DtrSnable true;

5 port.btrEnabie raise;

2 J

2

4 private class Settings: {

0 public int saeppuise ; // iiicrostcondii

6 public in stepIdleDel ay ; // Mill.;, seconds

7 public int stepPortl avert ; // Mask

3 public int di rectioaPortlrrvert; // Mask

5 publ c bool s tepEnabl elaiver 5 ;

0 public bool 1 i.:nitpia.sl:rve rt;

1 public bool robePialnvert ;

2 public ir;C status; eport // Mask

8 public float, unccioiiDevia t.io! ' 7 // M8;

4 public float. arcToleraiice ; // MM

5 public bool reportln hes;

6 ublic ool a o 5 ;: L i n a. t s ;

7 public bool ha rdLirai.ts ;

6 public boot hoMiugCycie ;

8' public .tat h minqDi rlnve r t ;: // Mask

-5 public flo t horai agr ' eed ; // MM/:oiiri

1 public float horai agSee k ; // ΜΜ/:¾ι:ι

5 public iat hoiaioqDebourice ; // Mi 1 lissrcoads

8 public float horai agPuiiCdf; // MM

4 public float laaxSpindieSoeed; // PPM

5 public float ;t.in.Spindie8peed; // RP

6 public bool iassiW'ide;

5 public float xStepsPe rMK;

8 public float yStepsPerMK;

8 public float zStepsPerbiM;

0 public float zMaxPate; // MM/riari

5 public float pMaxRate; // M/r;an

2 public float zMaxPate; // MM/sii.n

2 public float ^Acceleration; // MM/sec' 2

4 public float yAcceierati.on; // MM/sec'2

5 public float aAcceierati.on; // MM/sec'2

6 public tloar xMaxT ravel; // MM

7 public ilea;: yMax r vel .: // MM

0 public floa;: zMaxT ravel; // MM

0

0 public void. setFro;i;8 tring ( s ring lias! ;

1 if ; biine . Startsbdth ( "$") i {

2 .re Paa a;

0 }

4

5 string: " ; parts - line , Sabs t ri ag ( 1 ! .5pi it j ! ! ) ί 0] . Spl i t ( ' ^ ! · ;6 string variable -~ parts iOj ;

7 string vaiStriag parts ilj ;

6

2' switch, (variable; {

0 case "0"; 641 stepPukise - i at . P¾ cse { valS r i ng) ;

642 bre k;

6 case "I";

644 stepIdleDeia y ixs !; . Par;: e ( va i Strlr g ) ;

646 break;

646 case "2";

646 stepPortlr : ver t ----- ita , Parse ί v-alStritg; ;

646 b eak;

646 2¾e "3":

660 di Ee tionPox tlnve ::. ::! irrt , Parse (va iStri a; )

6 1 break;

662 case " 4 " :

666 s fcepEriablelnveri: ----- int , Fa r ;s ( a i S bring ; ' -~ 0;

664 b eak;

666 case "5":

666 Ii:idb:Pir;sinvert = in .. Parse ( valString) ' = 0;

466 break;

666 ase "6":

463 probePir Invert ~ rat . P r se ; ara tr rag ! ! - ~ 0;

460 break;

661 case "10";

662 s .atris eport --- i at: . Pa r se ( al3;:r i ag! ;

664 break;

604 case "11":

604 -j erect oaDeviation ::: f loat . Pa >:se j vaJ.3 Pr i ng■

606 break;

007 case "12":

066 arcToierance float . Parse (valPtrinq ; ;

006 break;

S70 case "13":

071 repc r blacbees ----- a nt bPa se ( va 1 Sbring ; 0;

674 break

677 case "26":

674 sofbliffiits int■ Parse (va 1st ring; 0;

676 breal-:;

674 case "21";

677 hardLriiilta ------ arrt , Parse (vaiOtring j 0;

676 reak ;

676 case "22";

666 hcrar ngCycle ::: in ί; , Parse (va i String ; ■ ::: 0;

661 break

662 case "26":

662 horsi agD.i. r. I a vert : = i nt . Pa ;:se ·; vai.3 r. i ng ! ;

664 break;

666 case "24" ;

666 horarngFeed ~ f lea b . Parse ( vaiSt t: i ag) ;

667 break;

444 case "25":

663 hrvaingoeek - » f lost . Pa rse ( alS r i ag) ;

460 break;

631 case "26":

032 boarkngDeborince int , Par se ( valotriraj ) ;

034 break;

034 case "27":

030 h rtiiri j FnilOfi: ^ fioa t . Parse ( i String ; ;

036 break;

037 case "40":

036 LiiaxS adleSpeed irloa e. , Parse ( valSt■ : r ag ) :-

033 break;

766 case "31":

701 minSpiadieSpeed f ioat . Pa rse ; vaiSt r i ag ! ;

762 break;

700 case "32":

764 leiserMode : = i at . Par se ( ai3 Cr i ng i 1 -- 0;

766 break;

766 case "160": 707 x3;:ep:>Pe k¾5i float: . Parse Ova i String )

7 Oh break;

70 case " 101 " :

710 ySnepsPerfliO. float . Parse ; val3tri::;g) ;

7 J. I bre k;

717 case "102":

713 z 3 ;: e p a P e rMM f I c a t . P a r s e I a I S t r 1 g ) :

17 break

715 ast "110":

710 zMsxRate :: fir>at , Parse (valStrirq j ί

717 break

" if! case "ill"

i 0 y Ma Rate f i o a : . P s e ( va 1 S t i r; g i ;

"20 break;

" 21 case "112":

22 r Ma x Ρ a t e --= f 1 o a t: . P a r s e ί va 101 r: 1 r g 0 ;

723 break;

24 case "120":

725 ^Acceleration float ., Parse ivalStrsng) ;

726 break;

727 case "121":

72$ yAcceieration ■-- floa t . Parse ( va 1 Strinq ) ;

720 break;

770 case "122":

773 ^Acceleration - f loa 0 , Parrse PvalStrirq ; ;

732 break;

773 case "130":

733 xMaxTravei ^ f ioat 3Pa r ,¾¾ ( a 1 Stri g ; ;

733 breaO;

733 case "131":

730 y axTravel == f l at , Pa r ae (va 1 Strang ; ;

733 break;

735 caae "132":

740 zPlapTravei ~ float:„ Parse (vaistring) ;

731 eal-:;

742 default:

743 throw as« Erc.eptio;; ί "OOfknowa aett.tng ft" + variable) ;

744 j

745 }

740 j

747 }

745 /

743 }

7 50

import processing . core , * ;

public class ImageOperations {

rivate PAppiet sketch;

public ImageOperations {PAppiet sketch) {

this. sketch — sketch;

}

private int index (Plinage image, int x, in y) {

retu n x + y * image. width;

}

public void dither (PImage image) {

image . loadPixels { ) ;

for (int. y = 0; y < image . height-1. ; y++) {

for (int x « . ' ! ; x < image , width-! ; x++) {

int pix = image . pixels [index (image , x, y) ]

float oldR — sketch. red (pix) ;

float oldG = sketch. green (pix) ;

float oldB ~ sketch . blue (pix) ;

int. factor t ;

int newR sketch . round (factor oldR / 213) (253/factor) ; i t ewG sketch . round (factor oldG / 213) (251/factor) ; int nevjB sketch . round (factor oldB / 253) (253/factor) ; image . pixels [index (image , x, y) ] — sketch . colo (newR, newG, newB) float e rR = oldR - newR;

float errG = oldG - newG;

float errB = oldB - newB;

int index = index (image, x+1. , )

int c = image . ixels [index] ;

float: r = sketch, red (c> ?

floa g = sketch . green (c) ;

float b - sketch .blue (c) ;

image. ixels [index] - sketch . color (i

index — inde (image , x-1, y+1 ) ;

c. = image . pixels [index] ;

r = sketch. red (c) ;

g = sketch. green (c) ;

b = sketch . blue (c.) ;

r = r + errR * 3/11.01;

g » g + errG * 3/11.01

b = b + errB * 3/11.01 ;

image . pixels [index] ~ sketch . color (r b>

index ~ inde (image , x, y+1 ) ;

c = image . pixels [index] ;

r s ketch. , red {c) ;

g sketch. green (c) ;

b sketch . blue (c) ;

r r + errR * 5/13.0::;

g + errG * 5/16.0::;

b + errB * 5/13.0 :: ;

image . pixels [index] = sketch . color { , b) index = index (image, x+1 y+1.) ;

· c = image . pixels [index] ;

r = sketch . red (c) ; g = s «:etch . green { c) ;

b = s cetch . blue (c) ;

r = r + errR * 1/16,

g = g + errG * /lfl.

b — b + errB * 1/11..

Image . pixels [index] = sketch . color (r , g, b)

}

}

image . updatePixe

using log4net: ;

using System;

us ng System. Collections . Generic

osing Sys em. Dra in ;

us ng System. 10. Ports ;

using System. Linq ;

using System. Reflection;

us ng System. Text ;

using Sys em. Threading ;

using System. Threading . Tasks;

using Ttp .Met: :eor ;

using static OilSpill . Printer ; namespace OilSpill {

class Machine {

private stati readonly ILog log «

LogManager. GetLogger (MethodBase . GetCurrentMethod ( } . DeclaringType) ;

private static in". MIN X = .10; / ' ϊίϋϋ

public bool Is Connected { get; private set; }

public bool GantryCormected { get; private set; }

private bool me eorHardwa reconnected;

private GRBL grbl ;

private SerialPort grblPort;

private Thread statusThread;

private bool askingForStatus ;

private int printHeight ;

public Machine () {

Is Connected - false;

printHeight. = {> ;

meteorHardwareConnected — true;

3

private void SetupPrinter (in t priritClock, irst bitsPerPixel) {

if (printClock < 0 i I printClock > 4000) {

th ow new Exception ( * I av¾.Lid priivC clock") ;

}

if (bitsPerPixel < 1 | | bitsPerPixel > 4} {

throw new Exception ( * Sits ps;: pixel :;;cv;.t be bet ee 1 axd 4");

}

PrinterlnterfaceCLS , PiSetAndValidateParam( {irit.) eCFGPARAM. CCP PRINT CLOCK HZ printClock) ;

if (clockRet \~ eRET . RVAL_OK) {

throw new Exception (String, Format ("Faiiec

clockRet) } ;

}

Printerlnte faceCLS . PiSetA.ndVal.i.datePa.ram( (irit) eCFGPARAM . CCP _BITS_PER PIXEL bitsPerPixel) ;

it (bppRet - eRE . RVAL_OK> {

throw new Exception (String . Format ( "Fai loo; to set bits; per i xei \ c\;;. ; 0 } " , bppRet ) ) ;

}

5

private async Task LoadPrintJob (MeteoxBitmapImage image) { 60 int. yTop = 0;

CI int. copies — 1;

t¾ PreLoadPrintJob printJob =

PreLoadPri ntJob (Properties . Settings . Default . Inkjet.Bi.ts PerPixel , image , yTop, copies, REPEAT MODE . SEAMLESS , 0) ;

63 await printJob. Start <) ;

54 3

6:6 private void ForceProductDetect () {

65 // Force a product detect signal

66 var rVal = PrinterlnterfaceCLS , PiSetSignal ( (int) SigTvpes . SIG FORCEPD, ) ; 65

70 if (rVal ?= eRET . RVAL_OK) {

76 throw riew Exception (String . Format ( " Forcing c product deieot

5iiie¾6r;\;: ; [ 0} ' , rVal} ) ;

72 5

73 3

74

7 5 public int. GetHeight 0 {

7 ' 6 letarn printHeight ;

77 3

78

6 public async Task SetHeight (irtt newHeight) (

80 printHeight - newHeight;

81 await grbl ,ΜονβΤο (grbl . GetPos i tionX () , grbl , GetPositionY ( ) , printHeight) ;

65 3

88

66 public async Task Home (> {

65 awa grbl. Home () ;

86 ]

67

66 public async Task Printlmage (Printerlmage image) {

66 MeteorBitmapImage meteorlmage = image . GetCurrentSlice {) ;

0

96 / *

65 Eitr;;ap ;:est n;¾ge new B tm ( 4096, 51 " * 2) ;

64 Graphics g - : Gia hi s , Froiiariaqc i featlmage} ;

95

56 q , 0iea r. ί Coior , Whi te ! ;

55

56 Pen per; ~ new Fen ( Color . FroiiiArgb ( 2 ¾5 , 0, 0. 0) 5 ;

55

156 int lineWrdth tes linage . Sid t / tes timage . her ght ;

151 for iicit - 0? y < testlmage .Height ; y++! {

162 //int x y * iineWrdth;

155 / / q . DraviLi ;ie (pen, x, y f y. ÷ lineVJidth f v ) f

.654 if (y 5 2 --=--= 0; g . DrawLins {pen, 0, y, tes 11mage Width / 2, y) ;

155 if iy 5 2 ---- 1; g , DrawLine (pen, tsstli age . Wroth / 2, y,- testl.nage . Width.- y) ;

106 !

107

108 Metsov Bi.t;;i.ap lina e ;aeteox:I;;i.aqe ---= new Netec. rEi t:;;apImage { tes cliiage; ;

1 5

110

111 if (meteorlmage == null) {

1155 throw new Exception ( '555; ;ra i id bosge elioo to pzinJ:.") ;

118 }

115 if ( !Meteorlnkj et . MeteorPath . LocatePrinterlnterface ( 5 ) {

11.6 throw ne Exception (" 65; i 1 od to locate ohe 6;eteo; Printer I nte ;: 1 ace ") ;

117 3

116

16; try {

lid; Printer. Connect () ;

151 log . Debug { "CI;;; oecteo c pri:o : er " ) ; } catch (Exception) f

// No pr:i.nter connected

log . Info ( ''Fo nd Einti connec d " ) ;

aeteorHardwareConnected = falsa ; if (meteorHardwareConnected) }

Setu Printer (Properties . Settings . Defa lt . Inkj etPrintCl ock , Properties , Settings . Defaul . Ink;) etBitsPerPixel ) ;

loq . Debug ( "App!i i-~d erint-.r nettings; " } ;

await LoadPrintJob (meteorlmage)

Rectangle sliceRect = image. GetCurrentSliceRectO ;

float printY = Properties . Settings . Default . Ink etHead idt * { (image . Forraattedlmage . Height - sliceRect . Y) /

(float.) Printerlmage . SliceHeiglit ;

log . Debug ($ i: ? ;: i nting slice e ;: ; ; --Mil; X), · pri atY . l . · ") ;

await grbl . MoveTo ( -MIN_ X , -printY); // Move to the right- Y posit! await Task.Run(i) => Printe .WaitNotBusy ()) ;

// Print! Move while spraying- ink

awai t Task. henAl1 (new Task [] {

grbl . ExecuteCommand ($ "Gi

X ; ' -P.topeJ: ti s , Setti gs . Defaui t.. Yant.t y P in s to cb, ; Y{ -- rintY; vn XY-MI?; X Y{ -priiitY; " , tras) ,

Task. Run ( { ) => {

if " ( !meteorHardwareConnected) {

/' / Caret prin , if the Meteor gear is not connected return;

}

// Tell the hardware to start fin iig ink droplets

ForceProdiictDetect. () ;

log. Debug ( "Trigger. ¾d Ptcdt.ot detect") ;

// Poll the PCC s a u until is: reports printing is done Printer status ~ new Printer () ;

log . Debug ( "s¾rt.i ;;.g lot printer to become idle");

do {

System. Threading. Thread. Slee (100) ;

} while (Printer. GetStatus {) ·= PRINTER STATUS , IDLE) ; log. Debu ( "Ft i ntor ηο;·ί idle");

5) ; public eaum Ports tate {

CONNECTED ,

NO PORT,

PORT_IN USE , iiblic PortState ConnectGantry () {

if (grblPort != null && grblPort . IsOpen) {

return PortState . CONNECTED ;

}

string.] portNames ~ SerialPort . GetPortNames ( ) ; 133

184 if (portNames . Length ~= 0) {

IBS eturn PortState . NO_PORT ;

L B 6 }

LB7

LBS s ring grblPortName — portNames [0] ;

LB3

ISO grblPort » new SerialPortO ;

131 grblPort . PortName = grblPortName

132 grblPort .NewLine = " \ r\: " ;

L 7 grblPort . BaudP.ate = 1L0300;

134

133 try {

i 77 grblPort . Open ) ;

177

177 log , Debug £ "R¾ t :: i ng ga:t y " 3 ;

.177 grblPort . DtrEnable =- true;

200 grblPort . DtrEnable - false;

771

202 grbl = new GRBL ( ) ;

700

204 grblPort . DataReceived +~ (object sender2, SerialDataRecei vedEventArgs e2)

200 ~> grbl. Receive (grblPort. ReadExisting (> ) ;

20s

207 grbl . ReadyToTransmit +— (o ject sender2 , EventArgs e2) —> {

208 string message = grbl . NextToTransmit U »"

207 lo . Debug ($ "OenOrng to g l; :0nes ;; qe , 7 : ri;t; ; ; " ) ;

210 grblPort .Write (message) ;

211 };

213

213 grbl . Connected +— (object sender2 , EventArgs e2) => {

224 log. Debug ( :t 77BL οοΜ·=ί:ί:&ο") ;

217

2X6 statusThread = new Thread ( () => {

227 while (askingForStatus) I

2:28 Thread. Sleep (277;) ;

2: 1

777 if ( !grblPort . IsOpen) {

72 i continues;

777 5

224 // Write the GRS1 status request comma d dl.recti

772 /,/ Ail the r: ai--ti :e comiiiarids are stripped iirorci the

buffer on the GRBL side

227 // so this should ot interfere with other cexoKiu i cation operat ions

227 grblPort. Write( R ?"> }

220 }

223 });

4 ' - ;4

237 ski gFo Status — t e ;

202 statusThread. Start {) ;

200

204 grbl. Reset += (object sender3, EventArgs e3) —> {

200 grbl. Home {)

206 . ContinueWith (prev ~> grbl . SetFeedRate (2000) )

237 . ContinueWith (prev ~> grbl , SetAbsolute ( ) )

233 . ContinueWith (prev »> grbl , Mo eTo ( -MIN_ X , 0, printHeight) ) ;

200 };

24.0 5 ;

24.1

24.2 log . Debug (String . Format ( " Port [0; is ops;;. Oor GRBL oo ; ;ri::.n;:.car ion" ,

grblPortName) ) ;

243

244 return. PortState . CONNECTED ;

243 } catch (UnauthorizedAccessException) { .· '" eturn PortState . PORT IN USE;

:;-: 3 }

0 }

I -include Accel Stepper , h>

0 t.ypede£ en m MotionMode f

4 MODE_ POSITION,

5 MODE_ VELOCITY,

ft } MotionMode;

6 typedef struct MotionModeState {

9 Mo ionMode x;

10 MotionMode y;

11 } MotionModeState;

12

10 typedef en xti Command {

1 CMD_STOP,

10 CMD_SET_TARGET ,

.16 CMD_GET_POSITION,

.17 CMD_SET_HOME ,

0 CMD_HOME_X ,

.10 CMD_HOME_Y ,

20 CMD_HOME ,

2:L CMD ' JSET X_ SPEED,

22 CMD ' _SET "" Y_ ~ SPEED,

20 CMD_ SET X_ CCEL,

20 CMD ' _ SET "" Y_ ~ ACCEL ,

10:.- I Command ;

26

27 typedef eaum Response {

20 RESPONSE_OK, // Good coiiiinand

20 RESPONSE_OK_DONE, // Good coremand arid effect achieved

00 RESPONSE_EP.ROR, // Invalid corciiiiand

01 RES PO SE_DONE , // EfOOeot of ca:;; ; ;iiand achieved

00 } Response ;

00

00 const int PIN_X_STEP = 2;

00 const int PIN_Y_STEP = 7;

Oft

07 const:, int PIN X DIR. - 0;

00 const:, int PIN Y DIR. - 0;

00 //const int PIN Y ENABLE ^ 6;

10

11 const int PIN STEPPER. ENftBLE = 0;

02

40 const int PIN X HOME = 0;

40 const int PIN ~ Y ~ HOME = 10;

0

40 AccelStepper stepperX (AccelStepper :: DRIVER, PIN_X_STEP, PIN_X_DIR) ;

47 AccelStepper stepperY (AccelStepper DRIVER, PIN_Y_STEP, PIN_Y_DIR) ;

40

43 MotionModeState motionModeState = {

00 ,x = MODE_POSITION,

51 .V - MODE_POSITION,

02 } ;

00

00 bool. runningToTarget — false;

00 bool homing = false;

¾6 int activeCommandID = NULL;

60 const .Lot inessaqeLength — i + .0 + 2 + ; // and : u.:i nt:8 t: 1- ;1η£ 7 y:iiii: f "\.::\n" ¾ unite t butf [messageLength] ;

£0

61 void setu O {

60 Serial .begin (11.02:00) ;

60 Serial . rintln { "vaOde:. 11 ) ;

64

60 pinMode {PIN_X_HOME, INPUT_PULLUP) ;

6ft pinMode {PIN_Y_HOME , INPUT_PULLUP) ; 00

00 configureSteppers () ;

to }

70

?i void configureSteppers () }

7 0 pinMode(PIN Y DIR, OUTPUT) ;

pinModefPIN Y STEP, OUTPUT) ;

74

70 pinMode (PIN X DIR , OUTPUT) ;

7-i pinModeiPIM X STEP OUTPUT) ;

7* > pinMode ( PIN_STEPPER_ENABLE , OUTPUT) ;

73

B stepperX. setMaxSpeed (2000) ;

81 stepperY. setMaxSpeed (2000) ;

0.7

03 stepper , setAcceleration ( 4000) ;

7 stepperY . setAcceleration ( 000) ;

00

06 stepper . setSpeed (200ό) ;

00 stepper Y . setSpeed (11: 00ό) ;

0 C: digitalvfrite (PTN_ STEPPER_ ENABLE, LOW) ;

9 5

01 .

02 voi oop () {

93 Co ¾;j.: i.c¾i: ion hand!. :; nq

00

00 static int messagelndex « 0;

of

9 0 while { Serial . available 0 ) {

00 buff [messagelndex] = Serial . read () ;

LOO messagelndex + = I ;

0 o 7

0 ό·0 if (messagelndex >= messageLengtb ) {

l.O ' O processMessaqe (buff) ;

1.04 messagelndex ~ 0;

1 .01 }

1-00 }

1 . 00

1.00 // Motion h.a.M.!.,i.Ki

I.00

XiO if (runningToTarge ) {

777 if (motionModeState . x ~ MODE_POSITIO ) (

772 stepper . run < ) ;

770 }

1; 7

i X ~> if (motionModeState . y == MODE_POS ITION) (

1; stepperY . run <) ;

1; 0 )

770

II.3 if (stepperX. distanceToGo O 0 &s stepperY. distanceToGo 0 0) { .1 0 runningToTarget = f lse ;

X 21 alertDone () ;

722 }

120 } else f

121: if (motionModeState . κ ===== MODE VELOCITY) {

1101 stepperX. runSpeed () ;

120

12~? if (switchXPressed 0 ) (

111:3 stepper . setSpeed (0) ;

120 stepper . setCurrentPosition (0) ;

1.00 }

17107 }

1 . 00 l¾¾ if (motionModeState.y ~ MODE_VEL0CITY) {

1¾4 stepperY , runSpeed {) ;

135

132 if (switchYPressed O ) {

132 stepperY . setSpeed ( ) ;

L¾8 stepperY. setCurrentPosition (0) ;

133 }

1 0 }

1 I

142 if (homing £& t β tepperX . iβ unning ( ) && ? stepperY . i sRunning {} ) {

143 homing — false;

144 alertDone () ;

243 }

i 40 }

147 }

no

142 void setTarget (int. x, in y) {

150 stepperX . itioveTo <x> ;

151 stepperY . moveTo (y) ;

152 runningToTarget — true;

122 5

122

22 void stop(> ί

I¾6 runningToTarget = f lse;

2527 motionModeState.x = MODE_ POSITION;

152 motionModeState.y = MODE_ POSITION;

1 ¾¾ stepperX . moveTo (stepperX. currentPositioti () ) ;

1.20 stepperY . moveTo (stepperY. currentPosition ( ) ;

1.61 }

1.22

1.22 boolean switchXPressed (} {

124 eturn ! digitalRead (PIN_X__HOME) ;

121 3

112

117 boolean switchYPressed (} {

Lib return « digitalRead (PIN Y HOME) ;

L!! }

170

171 void okiint id) {

172 Serial .write (id) ;

172 Serial, .write (RESPONSE OK) ;

174 }

172

172 void okDoneiint id) {

177 Serial .write (id) ;

177 Serial .write (RESPONSE_OK_DONE) ;

172 }

170

ill void error (int id) {

122 Serial. write (id) ;

173 Serial . rite (RESPONSE_ERROR) ;

ill }

121

116 void alertDone () {

ili Serial .write (activeCoramandlD) ;

188 Serial -write (RESPONSE DONE) ;

180 activeCoinmandID = BULL;

100 }

101

sage (uint8 t* buff) {

101 uincS t id = buff[0];

1.01 uintS t cmd = buff [2];

102 uint.16 t x = (buff [2] « 8) | buff [3];

101 uintl6 ~ t y = (buff [4] « 8) | buff [3];

108 switch (rand) {

case CMD_STOP:

okDone (id) ;

stop ;

break ;

ca SET TARGET:

motionModeState . x ■» MODE_POSITION ;

motionModeState . y a MODE POSITION;

setTarget (x, y) ;

activeCommandlD ~ id;

break ;

case CMD_GET__POSITIO :

Serial .print (id) ;

Serial .print (stepperX. currentPosition () ) ; Serial .print CS ") ;

Seri l . rintIn ( s tep erY . currentPos tion () ) ; b ea ;

case: CMD SET HOME:

okDone (id) ;

stepperX . setCurrerjfcPosition (0) ;

stepperY. setCurrentPosition (0) ;

break ;

case CMD HOME X:

ok ( d) ;

motionModeState. x ~ MODE VELOCITY;

stepperX . setSpeed (-stepper . maxSpeed () ) ; homing - true;

activeCommandlD = id;

b eak ;

case CMD_HOME_Y :

ok (id) ;

motionModeState. y = MODE_VELOCITY;

stepperY , setSpeed (-s tepperY " . ma s Speed { ) ) ; homing = true;

acti eCommaridID — id;

break. ;

motionModeState. = MODE_VELOCITY;

stepperX .setSpeed ( ' -stepperX .maxSpeed () ) ; motionModeState . y = MODE_VELOCIT ;

stepperY . setSpeed (-stepperY - maxSpeed ( ) ) ; homing ~ true;

acti veCoiranandlD ~ id

b eak ;

case CMD SET_X_ SPEED :

okDone (id) ;

stepperX, setSpeed (x) ;

break ;

case CMD SET _Y_ SPEED:

okDone (id) ;

stepperY , setSpeed (x) ;

eak ;

case CMD_SET_X_ACCEL:

okDone (id) ;

stepperX. setAcceleration (x) ;

b eak ;

case CMD SET Y ACCEL: okDone (id) ;

stepperY , setAcceleration (x) ; break ;

def ult:

error (id)

I const os = require Cos') ;

4 const { spec, valid, explain } ~ require (' 4 ;: , s pec ') ;

¾ const SerialPort = require { ; ee;: i aipo ;:;:') ;

4 const Readline = require (' i aL o r: :/ ars: ί: κ-·-;: ;.:;e '> ;

5 const async ~ require (' , ¾;: ytsc s } ;

ft const { makeEnum } = require ( ' , /u i I ' ) ;

5 // Tb.e order: he e must ni-i ch the ordering of ommands i.r: Ch.e Co::"a nd enuri in the Sii r:nw re

9 // This is an ohlect. 'fla pi g ' corrmiand names to the eqaivalenk οοηιηηϊΐι atios protocol al e

15 const commands = makeEnum ( [

11 ' s op ' ,

12. ' setTare;si" 1 ,

15 ' etPosiCion ' ,

1 ' sat.¾-?e ' ,

15

16 s h ::-::Y ! ,

. " ; 3 5 h :n«= ; ,

10 ' aethapeed : ,

13 s setYSpeea 1 ,

20 t ;:tXA;;csia;'¾i:ic:t ,

21 5;etYAoceie.i:a s: ion 1 ,

52 ] ) ;

23

24 / rder here :nust: mat the ordering ' of: response types it the Response ei iis :Ln cn.e i rsii re

2:5 const replyTypes = makeEnum( [

25 ' k' ,

27 ! doae 1 ,

26 f ox5cos ' ,

25 ! data 1 ,

30 ' a r ;:or' ,

51 3);

34

33 // 5e oarris serial ports tha;: are likely "real" devices

34 asyne function listRealSerialPorts {) {

35 const unlikelyPortsByPlatforrn = {

3ft darwin: [

35 ' /--i<;-.v/ ;: a y . B4a;e ;: oat h- 3oco;:a r-.q- For t : ,

35 hrPhoae-- sTnreiessiPP ' ,

35 < 3PKa ,

45 ] ,

41 } ;

45

45 const ports = await SerialPort . list O ;

44 const portMames » ports. map (p => ■ comName) ;

45

45 const unlikelyports = unlikelyPortsByPlatform[os . latform{) ] ;

45

45 if (unlikelyPorts ===== undefined) {

45 Mbaa ports;

50 }

l

32 coast; isBadPort ~ portNarae => unlikelyPorts . some (badPort => portName . indexOf (badPort) ?== -1) ;

a 3

¾4 return portNames . filter (portName « ·> t sBadPort (portName) ) ;

65 5

36

57 // How Long to wait lor data to appear oa a port

33 const TIMEOUT = 5000;

35 async function findMotionControllerPortName () {

60 const. portNames « await listRealSerialPorts () ;

61

64 // Tries to find the first port connected to a device that

65 // respo ds with a compatible version string

64 return async . find (portNames , (portName —> { 6 const port. — new SerialPort (portName , { baudRate : 1.15200 }) ;

66 const lineParser = new Headline () ;

60 port. ipe (lineParser) ;

66

60 return new Promise ( (fulfill) -> {

00 1st timedOut = false;

71 let timeoutlD;

76 const testData - (data) ~> {

74 if (timedOut) {

76 // This should never happen, because »e reaove the listener or; t rmeout 70 // FIX S if " this does M: get hrown then re-move the timeciO t flag

77 throw new Error (' Tr seout rrred bur da event listener called ≤sr«iv : ) 70 // return;

70 }

00

01 if (data . startsWith ( ! v¾i< ; «?2 ' ) ) {

02 clearTimeout (timeoutlD)

03 port . close ( ) ;

07 fulfill (true) ;

00 3

06 };

0 ' /

03 lineParser . on ( via r.a ' , testData);

00

00 tiiaeout!D = setTimeou (asyno (} => {

01 timedOut - true;

07: lineParser. removeListener ( ! d¾ta ' , testData) ;

00 port. close () ;

00 fulfill (false) ;

06 } , TIMEOUT) ;

06 });

00 });

06 3

0 : ο·

L60 const motionConfigSpec = spec . map dro r.i r. c dhi ori.ra 7 ;. ord , {

L6i stepsPerMM: spec . map ( d; taps per ™rd , {

162 x. : spec. number,

1.03 y: spec, number,

1 7 }),

106 maxSpeed; spec. map ( 'K-ax speerld , {

'.36 x : spec, number ,

107 y: spec. number,

160 }),

106 maxAcceleration : spec .map ( daax aeoei era;: rend , {

110 : spec. number,

111 y : s ec. number ,

112 }{,

113 3 )

1 0

1.1.0 class MotionController {

116 constructor (config , { portName )) {

117 // Val date ;:.b.e cord: 1 gurat ion

110 if ( f valid (motionConfigSpec , config) ) {

t why — explain (motionConfigSpec , config) ;

120 throw new Error ( "MotionConfroller configuration invalid because ${why );

121 }

120;

101 this . steps PerMM = config . stepsPerMM;

120 this .maxSpeed « config . maxSpeed ;

1.26 this .maxAccelerati n — config .maxAcceleration ;

1.26

127 this . nextPacketID = 0;

6.26 this . acknowledgements = {};

6.20 this . effectAchievedHandlers ~ {};

Hi; 131 this . portName = portName ;

11 }

1 1

IM ' isConnectedO {

135 return this. port !=~ undefined && this , port . isOpen ;

LI! }

in

111 / Returns a Promise which i.-s iiilf ii.Ied onc the m ion coiit oiler is ready to ac:¾pt: commands

111 asyno connect 0 {

140 if (this. IsConnectedO > ΐ

111 // Nothing more to do

ill return;

ill }

144

ill if (this .portName ===== undefined) {

146 const. portName — await, findMotionControllerPortName ί > ;

.141

141 if (portName == undefined) {

111 throw new Error (' 1;; :i led ;:o ind a valid moti on contr l,

110 }

114.

111 hi* . ortName — portName ;

111 }

111

ill this. ort = new Seria 1 Port (this . ortName , { baudRate; il!ilO }) ;

l 16

111 this. initialized = false;

lib

111 let commBuffer;

111

111. const portlnitializedPromise = ew Promise ( (fulfill) => {

162 this . port.. on { ; da oa : , (data) ==> {

111 let sanitizedData ;

111

i.li / ' / Wait until at least one ne l.i.ne is received to mark the end of the ersion liiej; ge

ill // before e iii.ng =:o parse replies

ill if ("this. initialized) {

ill; coas encllndex - data . indexOf ( : \:;h . charCodeAt (0) ) ;

ill

170 if (endlndex ===== -i) {

j.7 Ϊ xetisrn ;

172 }

i I

174 sanitizedData = data . lice (endlndex + 1, dat . length) ;

17,1 this, initialized - true;

,1?6 fulfill ();

177 } else {

111 sanitizedData = data ;

A 79 }

110

ill if (commBuffer ===== undefined) {

ill commBuffer = sanitizedData ;

ill 3 else {

ill commBuffer = Buffer . concat f [commBuffe , sanitizedData]);

111 3

i 86

ill // Process all buffered. me¾i.¾C:es

188 let notWaitingForData = true;

181 while (commBuffer . length 2 && notWaitingForData) {

111 const reply!D ~ commBuffer [0] ;

1.11 const reply ype = commBuffer [1] ;

ill

ill const. handlerOrError ~ (handlers ) => {

111 if (! (reply!D in handlers)) ! 195 throw new Error ( ' Received reply for unknown reply ID 3 { eply!D ] ' ) ;

155 }

157

155 return handlers [replylD] ;

295 };

555

55i const ack — (} —> {

255 const handler = handlerOrError ( thxs . acknowledgements ) ;

555 J . delete this. acknowledgements (replylDJ ;

554 return handler;

555 } ;

555

207 const effectAchieved = () «> {

555 const handler — handlerOrError (this . effectAchievedHandlers) ;

555 delete this. effectAchievedHandlers [reply!DJ ;

510 return handler;

5:;l };

5;

2.13 if (reply-Type ===== replyTypes . data) {

522 // P ta replies need to be treated separately because they vary in length

555 const endlndex = data . indexOf ( 4 \n ' . charCodeA ( 0) ) ;

21.6

217 if (endlndex '== - ) {

51.3 // 5.a:vlle data .reply

31.5

320 const headerLen = 5;

2252 const enclMa rkerLen - 2;

222 if (endlndex - (headerLen + endMarkerLen) - I < 5} {

2253 const bufferP.ep ~ coramBuffer . toBuffer ('ssx');

222 throw new Error { "' Invalid message in communications buffer:

$ ibufferRepi " ) ;

225 }

225

227 // Extract, rn&saags vtl.thout. header or end rsaricer ;5r\n)

225 const, message = commBuffer . slice ( , endlndex - 2);

235 // Fulfill remise to obtain this dat

232 effectAchieved () . fulfill (message) ;

235

535 // e;tcve the data reply fror the coraraunica tiona buffer

334 commBuffer = coramBuffer . slice (endlndex + 1, commBuffer . length) ;

235 } else {

235 ,// Need to wain, for raore data before the data reply is com ters and. we can process it

557 notWaitingForData = rue;

555 }

555 } else {

540 switch (replyType) {

541 case replyTypes . ok :

342 ack {} . fulfill () ;

343 break;

544 case replyTypes . done :

245 effectAchieved () . fulfill () ;

246 break ;

242· ' cas replyTypes . okDone :

243 ackO . fulfill O ;

245 effectAchieved () .fulfill*) ;

230 break;

2151 case replyTypes . error :

232 ack () . reject () ;

233 effectAchieved ( } . reject {) ;

254 break ;

255 default:

255 throw new Error ( ' Unknown reply type ${ replyType} " ) ;

257 } ί: ': ' ' '■ / ' Remot the reply leers, the coi unurii a io ns bu f f er

.tit; commBuffer =- coitimBuffer . slice (.· : , commBuffer . length) ;

201 }

222 }

2:02 }};

: t: });

2:02

.299 wait, new Promise (fulfill —> thia . port . once ( ! peo ' , 0 "·> fulfill ())) ;

202 await portInitializedProml.se;

.290 }

.229

270 sendCommand { commandName , x, y) {

271 if (this. ort mtm undefined) {

272 hrow new Error {' ;: tt:.ar ot conne c ted, ¾ns::- eexd c mma d ' ) ;

272 }

214

275 -if (I (commandName in commands) > (

270 throw new Error ( " Unrecognized command: $ { commandNiame } " ) ;

277 )

2 8

279 if {? this. ort. isOpen) {

270 throw new Error('I"ri:it~.i: ort is: not open, careroO: ceres ccxeearc:; 1 ) ;

202L }

202

200 if ( Wxie . nextPacketID in this . acknowledgements) {

202 throw new Error Already waiting for packet with ID $ { thi s . nextPacketID } to be acknowledged " ) ;

200 }

2:06

287 if (this . nextPacketID in this . effectAchievedHandlers) {

203 throw new Error ( " Already waiting for effect of packet with ID

$ [this .nextPacketID) to be achieved * ) ;

722 }

2 0

291 const cmdCode = commands [commandName] ;

293 const xCode — x j | 0;

294 const yCode — y | | 0;

29c

929 const commandBuf fer = Buffer . from (new UintSAr ay ( [

927 this , nextPacketID,

.229 cmdCode,

299 (xCode » 6) & Os ,

290 xCode & 0x22,

291 {yCode » c») & 0x92,

292 yCode & 0x22,

292 ' 7.r. : . charCodeAt (0) ,

20¾ ! x; < , charCodeAt (0) ,

292 ]));

200

207 ' this. ort. write (commandBuffer) ;

000

3 OS const commandAcknowledged = new Promise ( (fulfill , reject) —> {

970 this . acknowledgements [this . nextPacketID] — { fulfill, reject. ) ;

2 el });

012

979 const motionCompleted = new Promise ( (fulfill , reject) => {

019 this . effectAchievedHandlers [this , nextPacketID] » { fulfill , reject } ;

let });

079

027 // Increment but toll ove r a t 225

010 this . extPacketID -H= 1;

029 this .nextPacketID &= 0x22;

lei;

2722 tur {

1.22 commandAcknowledged , motionCompleted ,

}

}

home O }

return this . sendCoirinand ( ' h si¾ ' 5

}

/ Move to a Dositi ": ; e::if: :d fros the >ιο>η& po ition i.n ;; ; >n

aayno raoveTo (realX , rea!Y) {

coast stepsX = realX * this . stepsPerMM. x ;

const stepsY = realY * this . stepsPerMM. y ;

return this . sendCommand { ' ¾ΐ:τ·: ; :;et ; , stepsX, stepsY) .motionCompleted;

}

module . exports = MotionCont.roller

1 using System;

2 using System. Collections . Generic ;

¾ using System. ext;

4 using System. Drawing ;

5 us ng Tt . Meteor ;

ft using System. Threading. Tasks ;

' V using System. Threading;

6 using log4net ;

3 using System. Reflection;

10 using static OilSpill . Printer ;

11

12. namespace OilSpill {

13 public enurn REPEATJ ODE {

14 // Multiple copies of the iaaat will be ioined with a zero pixel gap.

15 / ' / One product detect signal will initiate the printing of ail copies o

16 // the image within the print jab,

11 SEAMLESS = 0,

10 // Each copy f: the image will require it:.;? own product detect signal.

13 // The miummn gap between product, detects must: leave sufficient: margin

20 // for the image plus: head X--drrectior: span.

21 DISCRETE = 1

22 }

20

20 class PreLoadPrintJob {

10:.- private static re donly ILog loq —

LogManager . GetLogge (MethodBase , GetCurrentMethod ( ) . Decla ingType) ;

20

20 private int bpp ;

26 private iMeteorlraageData image;

20 private int ytop;

00 private int copies ;

" Si private REPEAT MODE repeatmode;

01 private int obid;

00

00 pxsbiie PreLoadPrintJob (int bpp, IMeteorlmageData image, int ytop, int: copies,

REPEAT_MODE repeatMode, int jobID) {

05 this. bpp ~ bpp;

Oft th s. image ~ image;

00 this . ytop - ytop;

30 this. copies ~ copies;

3 this . epeatmode - repeatMode ;

00 this. obid ~ jobID;

41 }

02

43 // Send the print job to Meteor. Completes when data is; fully leaded or; hard are,

44 public asyne. Task Start 0 ί

45 // Meteo command to start ¾ print ob

40 int[] StartJobC d = new int [J {

40 (int.) CtrlCmdlds . PCMD_STARTJOB ,

48 4, // rOuribe of DWORD pa amete s;

49 jobid,

00 (int) eJOBTYPE. JT _PRELOAD ,

01 (int) eRES . RES_HIGH, // Print, at fall resolution

02 image. GetDocWidth + 0 // Needed for Lei t-To- ight printing only

00 };

03

00 Printer. abortJobs O ·

06

00 // A start: job comma :;.d car; fail i there is an ex listing p::int job

03 // ready or printing in Seteor, or if a previous print job is still

00 // aborting. The sequencing of the main form's control enables should

00 // guarantee that this never happens in this application,

01 eRET startJobRet;

00 do {

05 log . Debug { "00: yi ng to senc cterO j b coeiCiand") ;

64 start JobRet » PrinterlnterfaceCLS . PiSendCommand (Start JobCmd) ; 00 Thread, Sleep (.100) ;

EC } while (startJobRet ~= eRET . RVAL_BUSY) ;

68 if (startJobRet ! = eRE . RVAL OK) {

CO throw new Exception ($ "20 art lob ccomia u.d -ad. ledOnOr { s t.artl ' obKet : ") ;

-0 5

7 J

72 // The i tart document comm nd specifies the number of discrete copies

70 / of the image which are rsqiiirsd

7 iat[] StartDocCmd = new in.t[] {

70 (ir:t) CtrlCmdlds . PCMD _3TARTPDOC ,

70 1, // DWORD parameter court

77 repeatmode -~ {REPEAT_MODE . DISCRETE) ? copies : 1

0 5;

70

00 var startDocRet = PrinterlnterfaceCLS . PiSendCommand (StartDocCmd) ;

01 if (startDocRet !~ eRET , RVAL_OK) {

02 throw new Exception (String. Format ("Sta t: doc. ^a ad to i I eoOrOn < 0 ί " , startDocRet) ) ;

03 }

0

00 // For aea-iiess image repeans using the prelod data path, PCMD PEPSAT

06 // --.list be seat after PCMD oTARTPDOC and efor¾ the iifiage data.

87 if (copies > J && repeatmode -= REPEAT_ MODE . SEAMLESS) {

80 int[] RepeatCmd - new int. [J (

00 (inb) CtrlCmdlds . PCMD _REPEAT ,

00 I, / ' / DWORD pa.rarneter court

01 copies

00 } ;

00

00 var repeatRet = PrinterlnterfaceCLS . PiSendCommand (RepeatCmd) ;

00 if (repeatRet != eRE . RVAL_OK) {

00 hrow new Exception (String . Format ( is R¾ <:¾ v. cohered :c led \ αθ,η ; 0; " , repeatRet) ) ;

0 ' !

08 }

00

100 // PCMD EJSTMAGE mast be used Or the appl i at t n needs to pass images i.Oi // which exceed 60MB in size to Meteor as one bu fer, (An alternative

100 // is tor the appl icat ion. to split up the data into smaller images,

100 / each; of which car: used PCMD IMAGE; ,

104 //

100 // Tlie image data is seat, through the Printer Interface to the Meteor

100 // Print Engine in chunks. The application must cor; ;:i nuaiiv call

100 // Pi3eiidCo:™iard with the same buffer: while t.iie Print. Engine

100 // returns RVAL FULL .·

100 //

1.0 Note that it. i.s necessary to fix the location of the image command

111 / in issiory while carrying oat. this sequence, to prevent the garbage

112 // collector from relocating the buffer (theoretically possible, but 1.3 // highly un.l i h.ei ! between successive ?r 3endCornm¾nd. calls,

110 //

110 int [] ImageCmd = image . GetBiqlmageCommand (yto , bpp) ;

116 eRET imageRet;

117 unsaf {

13 fixed (int* plmageCmd ~ ImageCmd) {

110 do {

120 imageRet ~ PrinterlnterfaceCLS. PiSendCommand (ImageCmd) ;

121 } while (imageRet eRET . RVAL_ FULL) ;

123 if (imageRet !- eRET . RVAL_OK) {

11:0 throw new Exception (String. Format ( "In¾q8 comma ad

iariedtaOni 0; imageRet) 5 ;

100 }

100 }

107 } 13

3.33 int[] EndDocCmd ~ new . ·.· [] { (int) CtrlCmdlds . PCMD_ENDDOC , 0};

1¾0 var endDocRet = PrinterlnterfaceCLS . PiSendCommand (EndDocCmd) ;

131 if (endDocRet ?= eRET . RVAL_ OK) {

L32 throw new Exception (String , Format { "Stsd d c raea c mroe rxd L lectXrAn i δ r " , endDocRet) ) ;

133 }

13

133 iatU EndJobCmd ~ new inttl { (int.) CtrlCmdlds . PCMD ENDJOB, 0 } ;

133 var endJobRet = Printerlnte f ceCLS . PiSendCoramand (EndJobCmd) ;

133 if (endJobRet *« eRET . RVAL_ OK) {

13" throw new Exception (String . Format ( " Ea« o o;;;:;i¾nd 1 ai.itd \ ;3\n ί ΰ j " , endJobRet) ) ;

133 5

140

141 Console, riteLine { "P?:i t jot started")

142

143 // Poll the hardw re until the print j b is ready ;:o go

144 await Task. Run ({) => {

Ϊ43 whiles {Printe . GetStatus () ?- PRI TER_ STATUS . IDLE) {

146 Thread. Sleep (100) ;

1 7 }

143 } ) ;

143 3

130 }

131 }

1 using System;

2 using System. Collections . Generic ;

¾ using System. Text ;

4 using System. hreading;

5 using Tt . Meteor ;

2

7 namespace OilSpill {

6 public, class Printer {

9 public ernmi. PRINTER STATUS {

10 /// Meteor is no onnec d. This iii happen if the Meteor Pr i nt Enq i n¾ h.as not

11 /// yet eer; started i .q. Men i tor . ei:e needs to be tun), or: if ancc!:si

appiica 1 or;

12 / is; Kiirra'iiiy connected to Meteor,

la DISCONNECTED ,

4 /// Meteor is; connects?;! rid waiting for hardware

.15 WAITING_FO _PCC ,

16 /// Me ;-: i;> i m.tia i i sing the PCC ha rd a ::e

17 INITIALISING,

10 /// Mseteor is; ina ti e

19 IDLE,

20 /// The print data for- the next print "job is; beirq loaded nto the hardvja re bi;■: Eeis

21 LOADING,

22 /// The entreat print fob is; abort i no;

20 ABORTING,

27 /// The print date. for the next rint lob is loadesi ant; Meteor is; waiting fos an ex ernal

22 /// product detect signal to start printing

1: 0 READY ,

27 /// Meteor is printing

22 PRINTING,

1:2 /// Meteor is in an error condition

30 ERROR

01 }

02

Or public static bool IsConnected { get; private set; }

07

02 static public void Connect <) {

22 eRET retOpenPrinter « PrinterlnterfaceCLS . PiOpenPrinter {} ;

22 // p. AL OS iteans; the Met a r Printer In er ace was succes s full y opened..

22 / /

40 // p.VAL EXISTS isearis that the Printer Interface is already open in etas

41 // process.

42 //

42 // Ail other re urn values mean we have faired to open the printer

44 // interface - the rost likely' reason;? are either the Meteor Print Engine in // ' is not running, or the Meteor Printer ' interface is already open in another

40 // print application.

47 //

40 if (retOpenPrinter != eRE . RVAL_OK £& retOpenPrinter ! = eRET . RVAL_ EXISTS) {

40 throw new Exception {$ 'OOrsuil e to oger; ccrinecolon to trie ;:e; . ehST;

{ etOpensr i r;te } " );

Printer . IsConnected ~ true;

3

)e

02 public static void Disconnect (5 {

00 if (Printer . IsConnected) {

07 // Abort any open print, fobs

06 Abort Jobs ( ) ;

'0

00 PrinterlnterfaceCLS . PiClosePrinter <) ;

01 Printer . I sConnected = false; 55 }

5r ]

53

55 public static Printerlnfo Getlnfof) {

66 TAppStatus appStatus;

€Ί eRET retGetPrnSta tus = Pri nterlnterfaceCLS . PiGetPrnStatus (out appStatus);

55

63 if (retGetPrnStatus ·» eRE . P.VAL _OK) {

70 Gtt 2r nStatrs; ; r;;;i'i:d. Ptsybe .i r.isred os!h?

o i }

75 e u n new Printerlnfo (appStatus) ;

75

1<> public static PRINTER_STATUS GetStatus {) {

77 if disconnected) {

70 e urn PRINTER_STATUS . DISCONNECTED ;

73 5

70

71 TAppStatus appStatus ;

72 eRET retGetPrnStatus ~ PrinterlnterfaceCLS . PiGetPrnStatus (out appStatus); 77

77 if (retGetPrnStatus 5= eRET . RVAL OK) {

77 throw new Except ion {$ "7 iGetPrirS rates ( , , . } hailed, liivbe ii out? e53;5 : { ret.eetp ::;;5 r.stt;;; } ") ;

77 }

:

73 The Meteor PnLrd:. E gine state goes into IDLE; after all oorLnecten PCCs have firiished

37 // inrtiaiissing.

73: /

35. // Hare we trap the case of the Meteor configuration tile list its;? more PCCs than are

33 // currei!i:.iv attached.

r., .■'

34 if (appStatus . PccsRequired »=- appStatus . PccsAttached) {

35. etu PRINTER_STATU5. WAITING FCR_PCC;

·-:. 5

5- switch (appStatus . PrinterState) ΐ

55 // There is; no h dware cciins tid .

100 case ePRI TERSTATE , MPS_ DI SCOMNECTED :

101 return PRINTERJSTATUS . WAITING_FOR_PCC ;

102 // The PCC hardware has connected to the Print Engine but has net yet bee;;

103 // initialised

X 4 case ePRINTERSTATE , MPS_CONNECTED :

105 re urn PRINTER_STATUS . INITIALISING;

107 // The Prrtb:. Engine is initialised a id vraitinq for a print gob to start

107 case ePRINTERSTATE , MPS_IDLE :

105 r¾tem PRINTER_ STATUS . IDLE ;

.all // The near print job is; ready to start

i O case ePRINTERSTATE. MPS READY:

1 si return PRINTER_ STATUS . READY ;

172 // Meteor is actively printing

173 ease ePRINTERSTATE . MPS PRINTING:

73. return PP.INTER_ STATUS . PRINTING;

175 // The Print Engine is; download! eg FPGA code to the PCCs

IIS esse ePRINTERSTATE. MPS_INITIALIZING:

117 return PP.INTER_STATUS . INITIALISING;

376 // The PCC P ' PGA has completed or og rarrrri nq ar;d is starting up

1.15 case ePRINTERSTATE . MPS_STARTUP ;

lid; return PRINTER_3TATUS . INITIALISING;

131 / Faalr mndrt.ior; - more in for ;; , ¾+: re;; can be found by loos:;.;;;; at the

13:: // valoes ir: the statas regi.s~.er:;. F'or the pur oses of this; ρ ΐ ice t.i on 1.11 // v;e just eport the generic error:; the register values car; be viewed

1.14 // in Monitor

111 case ePRINTERSTATE . MPS_FAULT :

L26 return PRINTER STATUS . ERROR ;

111 // Traage data is being loaded

111 case ePRINTERSTATE. MPS_ LOADING:

I S return PRINTER STATUS . LOADING;

ISO // Should never get: b.ere

111 default:

112 throw new Exception ("Ux; kciown ΐ.· :: i o ".¾:;' s care") ;

ill 5

ill }

ill

ill / ' / Abort open i t iobs

137 / ' / Clears rint sr;gine memory

111 public static void AbortJobs O {

XZ9 Printerlnterf ceCLS . PiAbort () ;

140 Printer , WaitNotBusy (> ;

141 }

Ϊ 42

141 ' Returns false if arn ng timed out (still busy)

1 4. / Commurds that: cause busy state; PiAbor t, PiSetSiqna I , PiSe SPa ram.

Pi SetHeadPower, Pi 5¾tHorae, PiSendhiortiCor oiiruu u PiSetwa ve:i:o.n-

141 public static bcol WaitNotBusy (int timeoutMs = 10000) {

146 if ( f IsConnected) {

147 turn tru ;

1 3 }

14.1

11-0 long startTiiae = DateTime . Mow. Ticks / TimeSpan . TicksPerMillisecond;

111

112 while (Printerlnte faceCLS , Pil sBus () ) {

111 Thread, Sleep(iOO) ;

114

IIS Console, WriteLine 5. tM tS;;s;y still sees busy") ;

111

LSI // FIXME

LSI /Ml iDateT.ime.Now, Ticks / TrseS ¾:s . rli cks PerMi!LLisecond - start? ime > timeont!Ms; {

LIS return raise;

100

ill 5

;

165 return true;

100 }

107

i O public static void Spit (int count = 1) {

109 PrinterlnterfaceCLS . PiSetSignal { (int) SigTypes . SIG_SPTT, count) ;

170 }

1 ' ? 1

172 // Return head teriperatu r e In fiegrees Celsius

173 public static HeadTemperatureState GetHeadTemperatur (int pccKum, int headNum) { 'M if disconnected) {

170 return null;

176 }

Ί 77

17 ¾ TAp HeadSta us HeadS atus ;

ISO if (PrinterlnterfaceCLS . PiGetHeadStatus (pccNum, headNum, out HeadStatus) == eRET . RVAL_OK) {

161 // Convert from 0,1 degrees to degrees and ronng

162 int temperaturel = (int) {{ (double) HeadStatus . Temperaturel / 11") + Cut) ; ISO int temperature2 = (int) { ί (double) HeadStatus . Temperature2 / 10,0) + 0 , S) ; 164

16S eturn new HeadTemperatureState (temperaturel , temperature2) ; 133 }

130

123 throw new Exception { ! ' PiGe : HeadOta : as ; . , , ; failed");

133 }

1

121 J If Check whet er n of the PCCs in the system re in the process of turning head

02 /// power or; or' o ;: i: , S o ld oiilv be called ¾;her: all requ ed PCCs are connected,

132 private bool KeadPowerChanging () {

13 Printerlnfo info = GetInfo{);

105

100 for {int. pccNum ~ 1; pccNum <- info. PccsRequired; pccNum++) {

137 TAppPccStatus pccStatus;

133 eRET retGetPccStatus = PrinterlnterfaceCLS . PiGetPccStatus (pccNum, out pccStatus ) ;

139

200 if (retGetPccStatus ! = eRET , RVAL_OK) {

301 retu n trsa ;

232 }

203

204 if ( (pccStatus . bmStatusBi ts2 & Bmps.BMPS2 HEAD POWER IN PROGRESS) ?= 0) {

200 retara true;

206 }

20 ' 7 }

2 OS

209 return i ' alse;

210 }

211

211: public class Printerlnfo {

213 public bool HeadPowerEnabled { get; private set; }

214 publxc int SupportedBppBitmas k { get.; private set; }

213 public int PccsRequired { get; private set; }

lit public int PccsAttached { get; rivate set; }

217

1312 public Printerlnfo (TAppStatus appStatus) {

1:13 // Store the bit:::a«k indicating which bit«--per--pi:cei are 'valid for the current hi: d t pe

1:23 SupportedBppBi tmas k — appStatus . SupportedBppBi tmas k ;

1: i

123 HeadPowerEnabled — (appStatus . HeadPowerState —=

eHEADPOWEF.3TATE.HPS HEAD} ;

124 PccsRequired «· appStatus . PccsRequired;

225 PccsAttached = appStatus . PccsAttached;

223 5

227 }

223

223 public class HeadTemperatureState {

230 public int temperaturel { get; private set; }

231 u lic int temperature2 f get; rivate s * at; 3

o o

200 public HeadTemperatureState (i at tl, I at tZ) {

204 temperaturel = tl;

203 tempe atu e2 = t;2 ;

206 }

20 3

203 }

200 }

240 1 using System;

2 using System. Collections . Generic ;

3 using System. Drawing ;

4 using System. Drawinq . Imaging ;

5 us ng System. untime . InteropServices ;

ft using System. Text;

' V using System. hreading;

3 us g System. Threading . Tas ks ;

3 using Ttp. Me eor;

10

11 namespace Pipeline {

12 public class Printer {

13 public enum PRINTER_STATUS {

14 /// Meteor is not connected. his voill happen if the Meteor Prime E gine ha not

13 /// ye':. been started (e.g. Msait r, e;:e needs to be ran) , or: it ano her app.r i ca i n

13 /// is c rreniiy connected to Meteor:.

13 DISCONNECTED,

13 /// Meteor is connected and wasting for hardsars:

1.3 WAITING FOR PCC,

30 /// Meteor .is initialising the PCC hardware

21. INITIALISING,

22 /// Meteor: is inactive

23 IDLE,

23 /// The print data for the next nt job is being loaded icto the h rdware bu f i!ers

23 LOADING,

26 /// The current print job is aborting

23 ABORTING,

23 /// The print data for the next print job is loaded and Meteor is waiting for an eesernai

22 /// product detect signal to start printing

30 READY,

31 /// Meteor is psictinq

33 PRINTING,

33 /// Meteor :i.s .ire an error s:ondisian

3 ERROR

33 }

3ft

33 public static String StatusDescription (PRINTER_ STATUS printerStatus) {

33 switch (printerStatus) {

33 cas PRINTER _STATUS . DISCONNECTED I

40 return "Meteor cot connected" ;

41 case PRINTER_STATUS . WAITING_FOR_PCC :

42 return, " easting for ha rdisaro " ;

43 case PRINTER_STATUS . INITIALISING:

44 return "Intra 1 i sang the PCC 3a ;:a¾¾ re " ;

5 case PRINTER_STATUS . IDLE :

43 x«tara "sole"

43 case PRINTER_STATUS . LOADING:

40 return "Load rag p.tirn: job";

49 cases PRINTER STATUS . ABORTING :

oO return 'Oionar;";

31. case PRINTER STATUS . READY :

62 re u n "Peady to gcd.slO';

33 ease PRINTER STATUS . PRINTING I

lid retura "P.six; si nq" ;

OO case PRINTER STATUS . ERROR :

so retu n "Snccante.ted error:";

¾7 defaulfc5

sb return ''unknown sterna'';

oft }

60 }

61

62 /'/ unber of nozzles in one row public static int ROW_NOZZLE_COUNT 317;

60

public static bool IsConnected { g t; private set; }

67 static public void Connect O {

68 eRET retOpenPrinter - PrinterinterfaceCLS. PiOpenPrinter O

70 // P.VA.L OK means the Meteor; F:L:; e:;; Interface sas successfully operied.

71 / /

72 // P.vAL EXISTS means that the- Printer Ϊ nfer face is already open in this

73 // process,

70 //

73 // Ail othe return values mean e have failed to open the printer

73 // interface -- the "lost likely reasons are either the Meteor Print Snqi.ne

77 // is cot running, or the Meteor Printer Interface is already open in another

73 // print application.

50 //

30 if (retOpenPrinter »- eRET . RVAL_O S& retOpenPrinter !- eRET . RVAL_EXI STS } {

31 throw new Exception {$ "On-Obl a to open connection ;:o prime:;. cfST;

{ :: etOpen? ;: i rite ;:; " );

32 }

33

33 Printer . IsConnected — true;

33 3

86

37 public static void Disconnect () {

83 if (Printer . IsConnected) {

83 // Abort any open print fobs

90 Abort Jobs 0 ;

91

93: PrinterinterfaceCLS . PiClosePrinter () ;

93 Printer . I sConnected = false;

}

95 }

96

97 private static void SetAndValidateParam(int paramld, int value , String

errorMsg) {

93 var ret — PrinterinterfaceCLS . Pi5etAndValidateParam(paramId, value) ;

93

60 if (ret != eRET , RVAL OK) {

51 // FIXKiE

52 Console. WriteLine (errorMsg) ;

03 //throw new Except ion (e roiKsa! ;

53 }

35 3

00

57 public static void Setu (int printClock, int bitsPerPixel) {

50 if (printClock < 0 j j printClock > 4 65) {

53 throw new Exception (" I;c A: i ci prfn;: clock");

I 0 }

11

12 if (bitsPerPixel < 1 I I bitsPerPixel > 3) {

13 throw new Exception ( "Bits; er pirel irsst be between 1 and. ¾");

13 )

16 SetAndValidatePararai (int) eCFGPARSM. CCP_ PRINT _CLOCK HZ, printClock, "tailed to set prin t ol ock i: ) ;

17 SetAndValidatePararai (mt) eCFGPARAM. CCP_ BITS PER_ PIXEL, bitsPerPixel ,

"Failed to set bit;; per pice!");

13 //SetAndValidatePera;;; ; (in!:; eCFGPARiO . CCP HEAD XADluST, 0, "Failed to set head X ad jest" i ;

19 //SetAnd aliciateParaiii; (inn; eCFGPARAp;. CCP READ XOFFSET, 0, "Failed to sec head X offset"? ;

11: / / SetAndVa IidatePa ram ( (in t ; sCFGPARAM. CCP HEAD XSEPAP.ATION , 0, "Failed Co set head X ;;epa ra Ci on" ! ;

II / / SetAndVa IidatePa rain ( (in 35 sCFGPARAM. CCP HEAD YAD00ST,- 0, "Failed to zero head 1 ' ad 1 ast j ;

L2 public static void WaitUntilldle () {

111 do {

119 System. Threading. Thread. Sleep (.100) ;

111 5 while (Printer. GetStatus (> != PRINTER STATUS . IDLE} ;

2 '}

100 public static void ForceProductDetect () {

130 var rVal = PrinterlnterfaceCLS , PiSetSignal ( (int.) SigTvpes . SIG FORCEPD, ) ; 102

100 if (rVal «« eRET . RVAL_OK) {

100 throw riew Exception (String . Format ( " Forcing a produc dete t

foiies rAr [ 0} " , rVal) ) ;

1 0 5

.100 3

1 0

ill public static void SetHeadPower (bool powerOn) {

13$ PrinterlnterfaceCLS . Pi SetHeadPowe (powerOn ? 1 : 0) ;

10 3

101

102 public s atic asyac Task Loadlmage (Bitmap image) {

100 // Meteor coriiiarid tc start a rin job

144 int[] StartJobCmd - new :Lnt[] {

141 (int) CtrlCmdlds . PCMD STARTJOB,

106 .'; , // clu ber of DWORD parasstets

1.007 0 ,

1.46 (irit) eJOBTYPE. JT_PRELOAD,

149 (irtj eRES . RES_HIGH, // i'sir.t at full resolution.

1.00 image. Width + 2 // Needed for Left--To--Right printing oo.lv

111 };

1100 Printer .AbortJobs 0 ;

104

lot // A st.;:;: * :. job co mand can tali if there :i.s an existing print ob

119 // ready or printing in Meteor, or it a previoos print job is still aborting.

117 eRET startJobRet;

111 do {

ill Console. riteLine (" i yi! j to se d s i: 3 rt lob oorroi d " } ;

190 startJobRet - PrinterlnterfaceCLS. PiSendCommand (Sta tJobCmd) ;

ill Thread. Sleep (100) ;

192 } while (startJobRet — eRET. RVAL BUSY) ;

192

190 if (startJobRet != eRET . RVAL__OK) {

190 throw new Exception ($" ilta t. ob comma mi la 1 iedlnVo [ s tart JobRet ; " ;

199 3

190

190 / The start doca::?en C. cornmiind specifies the Li sbc :: of discrete copies lOS // of the image which are required

lOO ir.t[] StartDocCmd = new ir.t[] {

171 (let) CtrlCmdlds . PCMD STARTPDOC,

102 1, // DWORD parameter count

171 1 // # co ies

174 };

17 c

176 var startDocRet = PrinterlnterfaceCLS . PlSendCommand (StartDocCmd) ;

177 if (startDocRet 5= eRET . RVAL OK) {

76 throw new Except ion (String . Forma t £ hit a ?:;: doc ccm/siacd fa edlo \.;; 91 ; 11 , startDocRet) ) ;

I.79 }

1.80

1.61 // PCMD BlGIllAGo mast be used if cte application needs to pass images

111 // which exceed 60KB in size to Meteor as one buffer. (As alternative

161 // is lor the application to split up the data into smaller images,

161 // each of which can used PCMD IMAGE) . 16 /

ill // The image data is sen i: through the Printer ii!terface to the Meteor

110 // Print Engine in chunks. The application musi continually call

123 // P:LSe:od oi;:ri! r:d with the sarie buffer v/hile the Pririt Engine:

111 // reti;:::os RvTOL FULL.

Ill //

L!i // ' Iote that, it: is necessary to fix the location of the ii;;aqe ;:on;r«ar:d ill // in memory while cicryiiw ou this ceqaeoice, to prevent the garbage

233 / collector iro;i rtiocstiaq the b fer ί thee reti cat L y ssible, hut ill // highly unlikely? between successive i SerdComniano calls.

ill //

ill int[] ImageCmd - Printer . GetlmageCommand (image)

ill eRET imageRet ;

110 unsafe {

11 fixed (int* plmageCmd = ImageCmd {

100 do {

201 imageRet = PrinterlnterfaceCLS . PiSendCommand { ImageCmd) ;

202 } while {imageRet eRET . RVAL_FULL) ;

203

202 if (imageRet · = eRET . RVAL_OK) {

201 throw new Exception (String. Format ('M-nage ooneMnd

is i led On \n. ' 0 ; " , imageRet) ) ;

206 }

20 ' 7 5

201 }

201

210 ir;t[] EndDocCmd = new int U { (int ) CtrlCmdlds . PCMD ENDDOC, 1 };

221 va endDocRet = Printerlnte faceCLS . PiSendCommand (EndDocCmd) ;

212 if (endDocRet »■ eRET . RVAL_OK) {

212 throw new Exception (String. Format (''End docat'cu t ooisrasd aiied\n\r; 0 ; " , endDocRet) ) ;

224 }

Oil

1 ib int [] EndJobCmd = new int [] { (in;:) CtrlCmdlds . PCMD_ENDJOB, 0 };

2220 var endJobRet = PrinterlnterfaceCLS . PiSendCommand (EndJobCmd) ;

2:11 if (endJobRet ?= eRET . RVAL_ OK) {

2:10 throw new Exception (String . Format ( "End. job comma d ia i ledin \n ; 0 : " , endJobRet) ) ;

2:20 5

221

111 Console .WriteLine ( "Prim: job .leaded 1 ');

224 // Po l the hi!idware until the print ~ ) ob is teady to qo

221 await Task. Run (() => {

220 while (Printer . GetStatus 0 !~ PRINTER_STATUS . IDLE) {

221 Thread, Sleep ( 100) ;

221 }

223 3 ) ;

230 }

231

232 public static Printerlnfo Getlnfo () ί

211 TAppStatus appStatus;

234 eRET retGetPrnStatus = Printerlnte faceCLS . iGetPrnStatus (out appStatus); 233

236 if (retGetPrnStatus 8= eRET . RVAL OK) {

231 throw new Except ion ($ "P j.Get?.::;·: 3 tatas ·,, . } :la.iled. !Oaybe :; t timed out! eSOOc I tetOeth roStstut; 1 ") ;

21c }

230

240 return ne Printerlnfo (appStatus) ;

24.1 }

242

242 public static PRI TEP._STATUS GetStatus (> {

244 if disconnected) {

245 return PRINTER_STATUS . DISCONNECTED;

241 } ο5 ';

5<5 TAppStatus appStatus;

1:4; ; eRET retGetPrnStatus = PrintsrlnterfaceCLS , PiGetPrnStatus (out appStatus); :55

'.Z-x if (retGetPrnStatus !- eRET . P.VAL _OK) {

:55 throw rxsa Exception (S "5: : 5·:0:5 r rhtatus ;■ taileo. ha yoe it: tiiied c;; ·:. ;

eOET: ; retGetrhnStatrs :· "} ;

-53 }

:55 // The Me:¾ .c Print Engine .;.ti;:s g ~s into IL5..5 after ell connected 5C5s

S3ve tin is ired

initialising,

Ηέίί; we trap the case of the Meteor ooniiiq sr ation file listing more PCCs than are

59 // currently attached.

50 / /

! h: if (appStatus . PccsRequired ·» appStatus , PccsAttachecl) {

53 return PRINTER_STATUS . WAITING FOR PCC ;

h i

6 " ·· switch (appStatus . PrinterState) {

"55 // There is no hardware ooiir;ec ted .

Γ6? case ePRINTERSTATE . MPS DISCONNECTED:

555 refcuxa PRINTER_ STATUS . WAITING FOR_PCC;

'' 55 / The FCC hardware has ooririected to the; Prr.i.r; ;:. thieine but has not yet been

570 // initialised

5Π case ePRINTERSTATE . MPS__CONNECTED :

171 return PP.INTER_STATUS . INITIALISING;

:53 // The Print Engine is : nitia i i sad and waiting for a print iob to start ePRINTERSTATE . MPS_IDLE :

return PRINTER_STATUS . IDLE ;

The next r nt ei; i:; ready to ·:. tart.

ePRINTERSTATE . MPS_READY :

"¾ return PRINTER STATUS . READY;

5 " 5- // ?!ε ;:.8 r n actively printing

555 case ePRINTERSTATE . MPS_ PRINTING :

55 i return PRINTER STATUS . PRINTING;

552 // The Print; Engine downloading FTPGA code to the PCCs

353 case ePRINTERSTATE, MPS_ INITIALIZING;

35t return PRINTER STATUS . INITIALISING;

335 / Tte PCC I?PGA has cots;le ted p.toq rariitLrq an is s t. rtinq up

555 case ePRINTERSTATE, MPS_STARTUP :

t55/ return PRINTER_STATUS . INITIALISING;

55 // P oit condition - ito e 1πίο;™:ά'5οη can found by looting at the

5^3 // vaines in the stains teqteters. For t:;e purposes of thee ap lication

555 // e ust report the genetic error; the regis: i:er values can he viewed

55: // in Moni or

555 case ePRINTERSTATE , MPS_FAULT :

553 return PRINTER_STATU3. ERROR;

29 // Image data is being loaded

533 case ePRINTERSTATE . MPS LOADING:

596 re urn PRINTER_ STATUS . LOADING;

535 // Should never get here

553 default :

35 - threw new Exception ( :; q thrown printer stita " )

500 }

505 }

501

505 Abort airy open print, jobs

505 / Clears print engine iierrory

505 u lic static void AbortJobs () {

335 PrinterlnterfaceCLS . PiAbor () ;

3D " ? Printer .WaitNotBusyO ; Ida; // Ssisirns raise i r vjaitinq tirsd out: (still busy!

331 // Commands that c¾;se b sy state; PiAoort, Pi Sets Lgaai , PiSet?ar«m f

?i3e!;r;saa ;r f Pi 3et orr;e ,, F SeridMcni rComman , FiSet ave orsi

312 ublic static bool Wa tNotBusy(±nt timeoutMs = 10033) I

¾3.3 if disconnected) |

¾ 3. return true

v:a 5

31 ¾

ii'i long startTinie = DateTime . Now . Ticks / TimeSpan , TicksPerMi 1 lisecond;

o

313 while (PrinterInterfaceCLS . Pil sBusy () ) {

320 Thread. Sleep (100) ;

323

322 Console. WriteLine ( 'OOa i tdot Easy still sets ;?;J;; Y" ) ;

323

323 // FI ME

323 /*if (D¾teTi;ii¾, Now, Ticks / T meSpa :i , Ticks erMi L i i s cond - sta tTis > i0_£5 :t¾S ; [

326 ret false:

327 }V

320 5

320

000 Console .WriteLine ( "i :ι thotOa y se s; printer :; s no longer b sy");

001

032; return true ;

000 }

00

003 public static void Spit (int count = 1) {

006 PrinterlnterfaceCLS . PiSet Signal ( {int) SigTypes . SIG_SPIT, count) ;

00O }

333

330 // Pecarn head temperature in degrees Celsius

¾2i; public static HeadTemperatureState GetHeadTemperature (int pccNum, int headNum) {

303 if disconnected) {

342 return null

343 }

344

343 TAppHeadStatus HeadStatus

a 40

a40 if (PrinterlnterfaceCLS. PiGetHeadStatus (pccNum, headNum, out HeadStatus) -= eRET . RVAL_ OK) {

a43 / Convert fro:;; 0,1 decrees to decrees and. round

343 int temperaturel (int) (( (double) HeadStatus . Temperature 1 / 30.0) + O. );

330 int temperature2 = (int) (( (double) HeadStatus . Temperature2 / 30.0) + 0,6);

333

320-; return new HeadTemperatureState (temperaturel , temperature2 ) ;

333 1

334

333 th ow new Exception ( "Pi GetdaadOOatus ;' , .,) raileo' 1 ) ;

336 }

30 ' ?

300 /// Check whether any oil the PCCs in the system are in ;h.e process of earning head

300 /// ' pcejer on or off:, Should only · ≡: called ¾he;; all recurred PCCs are connecoed ,

060 private etatic bool HeadPowerChanging ( ) {

061 PrinterTnfo info = GetInfo{);

063;

363 for (int pccNum = 1; pccNum <— info . PccsF.equi red ; pccN " um++) {

060 TAppPccStatus pccStatus;

063 eRET retGetPccStatus - PrinterlnterfaceCLS . PiGetPccStatus {pccNum, out

pccStatus ) ;

066

060 if (retGetPccStatus != eRET . RVAL_OK) {

063 tur txae ;

363 3 ¾70

371 if ( (pccStatus , bmStatusBits2 & Bmps . BMPS2_HEAD_POWER_IN_PROGRESS) ? = 0) {

372 return true;

373 }

374 }

¾ 75

¾76 return false ;

7 o

oil u lic class Printerlnfo {

is80 public bool HeadPowerEnabl ed { get; priv e set; }

381 public, int SupportedBppBitmas k { get; private set; }

882 public int PccsRequired { get; private set; }

383 public int PccsAttached { get; private set; 3

688

883 public Printerlnfo (TAppStatus appStatus) {

388 // Store tre foitmask indicating winch i t:.s-p¾r-pi xei are valid for the cu rent head type

88 " ? SupportedBppBitmas k ~ appStatus . SupportedBppBitmas k;

388

38 § HeadPowerEnabled = (aρpS tatus . HeadPowerS ate =

eHEADPOWERSTATE . HPS HEAD) ;

380

381 PccsRequired = appStatus . PccsRequired;

382 PccsAttached »» appStatus . PccsAttached ;

383 }

388 }

333

396 public class HeadTemperatureState {

397 public int temperaturel { get; private set; ]

393 public int temperature2 { get; private set; 3

3 9

430 public HeadTemperatureState (int tl, int t2) I

431 temperaturel = tl;

$.bi temperature2 = t,2 ;

403 3

404 J

409;

408; ./// Allocates and rills an image command buffer: to be sent to ttear via

408 /// Pr SendCommanoi . The .image data in. the buffer coroes trorn the previously

808 /// loaded bitmap.

803 ///

418 / ' // The standard comma:v:i ror sending ' linage data to Meteor is PCMD IMAGE,

411 ' // If a large image {> 60MB; needs to be sent 1:;; one command then

412 /// PCMD BIGIMAGS coifiinand au,¾t be ased.

413 /// </su? ; ;¾;;y>

418 // <par¾s ;)a:iie--"v op" Y position in pixels o 8 the in ; nge< " /parnrn>

413 /// cpara na:n¾ ; -- " " c.r neBpp">3its per pixe 1 < ' / oaram>

418 /// par:am naiiifc-h; ssBJ.gImage ">dse the ε 3a nriard PCMD IMAGO " ! or

PCMD 31GIMAGE</pa r aie>

41 " ; /// retu r nsolitage conroaod to send to Meteor:, soli 1 i: ei;;or:y allocation,

i " a i lac/ ?:ea;rrrit 3

418 private static int[] GetlmageCommand (Bitmap bitmap) {

413 cons!; int bitsPerPixel = 4;

480

421 // header size is different for: PCM.D IMAGE and PGM!) BIGIMAGE

422 const mt headerSlze — 9;

423

428 // The widt:b of the rinage data butfer sent to Meteor itust be a multiple of.

DliGRDs

42% int imageDataBufferWidth - {( {bitmap. Width * bitsPerPixel) + 31 ) » 8) ;

426 // Meteor image buffer size o DWORDs

421 int imageBufferSize - imageDataBufferWidth * bitmap . Height ;

4.33

4.33 // Allocate senio r ; / for image + header. iiote that this buffer will be

430 // initialised to zero by the trame^iork. 431 int. [] buff = new itrt [imageBufferSize + ' 3 ;

432

43 // Fill in the comiiiand header

43 buff [0] - (int) CtrlCmdlds . PCMD BIGIMAGE ;

432 buffi ' i.] - imageBufferSise + headerSize; // Dword count:

43 buff [8] - 4; // Plane

433 buff [3] = 4 ; // X left

433 buff [4] - 0; // Y top

433 buff [:.■] - bitmap. Width; // Kidth

440 buff[3] = bitmap. Height; // Height (PCM.D BIGIMAGS only)

44

442 // Start at the iirst data word beyond the header

443 int datalndex = 2 + headerSize; // I.ridex of first data DWORD

444

443 / Copy the image data line by line f ront the bitmap and write it. into the

Meteor

443 // cGKKVi nd buffe ¾ ; : < -; le requested resolution.

44? BitmapData bmpData — bitma . LockBits {nevr Rectangle (2 , 0, bitmap . Width ,

bitmap . Height } , ImageLockMode . Readonly, PixelFormat . Format.32bppArgb) ;

443 int sourceStrideBytes — bmpDa ta . Stride ;

443 bytet] lineData = new byte [4 * imageDataBufferWidth * (32 / bitsPerPixel) ] ;

// 32 bits: per pixel for the :i;iax:i. .n;xi Meteor, buffer: line length

430

431 for (int y - 0; y < bitmap. Height ; y++) {

4¾2 Marshal , Cop (new IntPtr (bmpData . ScanO . Tol nt6 ( } + y *

sourceStrideBytes), lineData, 0 , sourceStrideBytes) ;

433

433 byte bppMask = (byte) ((i « bitsPerPixel) - 1);

433

433 for (int x = ; x < bitma . Width ; x += i) {

432 n shift = 4 * (7 - (x & 7)); // Bit count to shift 1ε; ft

432

433- // Get first oou rc.e pixel

430 byte pixelBrightness ~ Printer. ArgbToGrey (lineData, x * 3);

422 pixelBrightness = OxFF; // Invert f or printer

432 pixelBrightness »= 3; // Only interested, in 4 rasbs

423 pixelBrightness &~ bppMask; // Mask u er nibble

424

432 // Write both pi.reie

433 buff [datalndex] \~ ( (in t) ixelBrightness) « shift;

423

422 if ( (X >~ bitma .Width - I) | | ((x £ 7) ~- 7)) {

datalndex++;

474 }

472 }

473

474 bitmap, UnlockBits (bmpData) ;

473

470 xetnm buff;

4 7 }

4 H

470 /// <su;rsiiary.>

400 // Cyi:vert:; a ARGS alue to yreyacaie

404. /// ' / suromary>

427 /// -yparam : 2: ii;age' : >Byte array o r pixel da ta /o¾ ran>

483 /// tpara "ofi : se!7 : >3yte ofiaet o f ARCS va 1 ue2/pa r 3 tit*

483 /.//' <re tar ne> 3--bi t reys':al¾ va 1 ae</re tar nsJ-

483 private static b te ArgbToGrey (byte Π image, int offset) {

432 retu n (byte) ( (float) image [offset + 2] * 3.3 + ( float) image [offset + 4] *

8v53 + (float) image [offset + 0] * 0.44);

487 }

488 }

432 }

432: using log4net ;

■using System;

using System. Collections . Generic ;

using System. ComponentModel ;

using System. Drawing ;

using System. Drawing . Imaging ;

using System. Linq;

using System. Reflection;

using System. Text ;

using System. Threading . Tas ks ;

{

ss Printerlmage {

private static readonly ILog log =

LogManager . GetLogge (MethodBase . GetCurrentMethod ( ) . DeclaringType) ; public Image Sourcelmage;

public Bitmap Formattedlmage ;

private int. currentSllcelndex;

public static readonly int SliceHeight = 31?;

public Printerlmage (Image sourcelmage) {

this . Sourcelmage = sourcelmage;

int ad ' justedWidth «· (mt) (sourcelmage . idth *

Properties , Settings . Def ult .AspectRatio) ;

this . Formattedlmage — Adj ustThreshold (new Bitmap (Sourcelmage , new Size (adjustedWidth , sourcelmage . Height) ) , 0.5f> ;

s . currentSllcelndex = GetSllceCount {) private float GetSliceSeparation 0 {

return (int) (SliceHeight * (1 -

Properties . Settings . Default.. SliceOverlapRati ublic void SelectSlice (int slicelndex) ί

if (slicelndex < j | slicelndex >— GetSl i ceCount ί > 5 { throw new IndexOutOfRangeExceptio {) ;

5

this . currentSllcelndex — slicelndex;

3

public void PreviousSlice ( {

if (this . currentSllcelndex mm GetSllceCount () - 1) { return ;

!

this; . currentSllcelndex +— ;. ;

3

public v id NextSliceO {

if ( this . currentSllcelndex -~ 0) {

eturn

3

this . currentSllcelndex -= 1; public int GetSllceCount {) {

retu n (int) Math . Ceiling (this . Formattedlmage . Height / (float) GetSliceSeparation () > ;

so }

SO

65 public MetecrBitmapImage GetCurrentSli ce { ) {

66 .// Create the slice li ge

60

IS lock (Formattedlmage) { // FI70 S; Object is cu ;: ?:ent.ly 1:t? eisewiere - wher 6

06 Graph! csUnit unit = GraphlcsUnlt . Pixel ;

70 Rectangle imageRect = Rectangle . Round (Formattedlmage . GetBounds (ref unit) ) ;

71 Rectangle sliceRect ~ GetCurrentSliceRect 0 ;

70 Image slicelmage ;

75 if (imageRect . Contains {sliceRect) ) {

70 log . Debug ( " 3 i. i oe treox i rite ;:!;>;: :i: l¾g3") ;

77 slicelmage — Formattedlmage , Clone (sliceRect ,

System, Drawing , Imaging , PixelFormat . Don Care) ;

78 } olss {

79 log . Debug ( "Si. i oe ¾xt:s:ad;s beyonO ¾ :;«« of: image " ) ;

01 // Bottom slice extends yond Im g so we need to slice vO>af we car; and extend :i.t

8.7 sliceRect . Intersect (imageRect) ;

60

00 Image slicePortion - Formattedlmage . CI one ( sliceRect ,

System. Drawing . Imaging . PixelFormat . DontCare) ;

60

06 // Create a new image and draw the image portion on top

37 slicelmage - new Bitmap (sliceRect . Width , SliceHeight)

SS Graphics sliceGraphics = Graphics . Fromlmage (slicelmage) ;

0;; sliceGraphics . Clear (Color .White) ;

90 sliceGraphics . Drawlmage (slicePortion , 0, 0) ;

61 !

66 slicelmage . RotateFli (RotateFlipType . RotatelSOFlipNcne) ;

94

66 // FIXKE this; is a hack to use a specific region of working nozzles 60

60 // Make blank, linage the size of the head

60 Bitmap fullSli cel age = ew Bitmap (sliceRect: .Width, SliceHeight * 2) ;

60 Graphics fullSlicelmageGraphics = Graphics . romlmage (fullSlicelmage) ;00 fullSlicelmageGraphics. Clear {Color, White) ;

01

02 // Draw the slice portion into the good region of the head

00 fullSlicelmageGraphics . InterpolationMode =

System. Drawing . Drawing2D . InterpolationMode , MearestNeighbor

07 // fLOOLSII eelmageGjiaphics Drawlmage ; slicelmage, new Rectangl ί 0, 250 *

7, fniiO.i.icelmage .Width, 43 * 2) ) ;

0 fullSlicelmageGraphics. Drawlmage (slicelmage, new Rectangle (0, 0 , fullSlicelmage . Width, SliceHeight * 2))

06

07 return new MeteorBitmapImage (fullSlicelmage) ;

00 1

00 3

70

11 lie Rectangle GetCurrentSliceRect () {

11; int. sliceY - ( int) (this . currentSlicelndex * GetSliceSeparatio O ) ;

76 Rectangle sliceRect ~ new Rectangle (0, sliceY, Formattedlmage . Width ,

SliceHeight) ;

10 return sliceRect;

16 }

16

i.S private Bitmap Adj ustThreshold (Image image, float threshold) {

IS Bitmap bm ~ new Bitmap {image .Width , image . Height) ; 120 ImageAttributes attributes ss new ImageAtt ributes () ;

121 attributes , SetThreshold (threshold) ;

122

122 Point. [] points ~ {

124 nffiw Point (0, 0) ,

L2S new Point (image . Width , 0) ,

126 new Point ( 0 , image. Height) ,

in 5;

12 o

.129 Rectangle rect «· new Rectangle { 2 , Q, image. Width, image .Height) ;

130

131 using (Graphics gr = Graphics . Fromlmage (bm) ) {

132 gr . Drawlmage (image , points, rect, GraphicsUni . Pixel , attributes) ;

133 }

34

0 is ari! bm;

130 3

130 }

no }

130

1 using System;

2 using System. Collections . Generic ;

ft using System. Drawing ;

4 using System. Drawing . Imaging ;

5 using System.10;

ft using System. Linq;

7 using System. Net;

6 using System. Threading;

3 using Sys em. Threading . Tas ks ;

10 using System. eb .Script. Serialization ;

11 using System. indows . Forms ;

12

1ft namespace Pipeline {

ram {

16 /// The "lain ¾rft:r\" point for the a lication.

17 /// </ sujrsrusr v

.1 0 (STAThread]

13 static void Main 0 {

20 bool uiEnabled = tnic;

21 bool serviceDi scoveryEnabled = true;

21 // process: ccriiiiiarid line arguments

2ft

2ft stcingfj arqs «· Environment . GetCommandLineArgs O .Skip(l) .ToArray <) ;

26

27 if (args. Length > ft) {

2ft foreach (String arg in args) {

2ft switch (arg) {

ftft ease " !io--.ii":

ftft uiEnabled - false;

ftft break;

ftft case :! :ii..;:c«

ftft // ' Will respond to messages broadcast via ftftDP Looking for tft s .¾¾r e ;:

ftft. serviceDiscoveryEnabled = fcru«;

ftft break ;

ft. ' default:

ftft Console , Error . Wri teLine ($ "ftnr cog .i :sed coxwiio d 1 i te

a " :-;:"*::;] ·: ; ' a.tx; i 'ft) ;

ftft System. Environment . Exit ( 1 ) ;

ft ft- break ;

41 }

42 }

4ft 5

44

ftft if (uiEnabled) {

46 Application. EnableVisualStyles {) ;

47 Application. SetCompatibleTextRenderingDefault (false) ;

48

49 I foForm infoForm = ne InfoForm() ;

20 Pipeline pipeline = new Pipeline (infoForm) ;

01

02 if (servi ceDis coveryEnabl ed) {

01 pipel i ne . RunServiceDi s cover ( ) ;

04. 5

06 pipeline. Run 0 <

03 Application. Run (infoForm) ;

ftft } else {

ftft Pipeline pipeline « new Pipeline {) ;

61

61: .if (serviceDiscoveryEnabled) {

ftft pipeline . RunServiceDis covery { ) ; 22 pipeline . Run ( ) ;

' ~ ?

68 while (true) {

33 Thread. Sleep (1.00) ;

}

1 5

7 }

74 class Pipeline {

72 private static int HTTP PORT = B320 ;

76

77 private InfoForm infoForm;

7 s ! private Webserver app ;

73 private Bitmap imageToPrint ;

20

21 private b ol HeadlsOn = false;

22

23 public Pipeline {) { >

22

23 public Pipeline (InfoForm infoForm) {

26 this . infoForm — infoForm;

22 }

23

32 private bool UIEnabledO }

90 turn infoForm != null ;

31 }

31

33 private void Log (string msg) {

33 if (UIEnabledO} ί

33 infoForm. DebugWriteLine (msg) ;

32 } else {

33 Console . WriteLine (msg) ;

3 3

13: }

Ϊ. 0

121

100: p-oblie class PrintArgs {

i33 // Nozzle "ire p¾r sec

124 public float: printRate { get; set; }

102

103 public float: bitsPerPixel { get; set; }

103 }

102

100 private void init ebApp 0 {

110 String serverl PAddres s = Webserver .GetlPAddress () ;

111 String url - $ '3: ; ;;;;;p^2l3.:;.i:ij::>;avl^

1 2

113 if (UIEnabledO) {

.2 3 infoForm. SetURL (url) ;

i l } else {

116 Console. WriteLine ($"Li 32¾\1;:: ; at ; ?:l : v ") ;

117 }

123

113 app = new Webserver (serverlPAddress , HTTP PORT) ?

20

1111 app . Get ( " I " , (HttpListenerRequest request,

Webserver . SimpleHTTPListenerResponse response) —> {

21; Log (" 311; /") ;

123

123 // TODO se::;d a sim le ¾?sb a p that: uses the HTTP API to sh w the printer st riis

11:3 response . Send { "Pipe! n p;:is2¾r serve::''") ;

122 }) ;

Head powe state 700: app . Get { " /head" , (HttpListenerRequest request,

Webserver . SimpleHTTPListenerResponse response) => {

131 // TODO sk the rinter: b.ardv;a r:e whethe the head is: a otaally on

; turning it on might: have failed)

130 Log ("GET /nead") ;

L33 response . JSON (HeadlsOn)

i.34 5 ) ;

13a

133 app , ost ( " bests n " , (Htt Lis ene Request request ,

Webserver . SimpleHTTPLi stenerResponse response) => {

137 Log("PG3T /he^d/on' 1 ) ;

333 Log ( "71a ;: ra:: o:a hasad p:;:a;r") ;

133

140 Printe . SetHeadPower (true) ;

14. response . Send ( ) ;

142 });

.143

144 app . Post ( " / h¾ad/off", (HttpListenerRequest request,

Webserver. SimpleHTTPListenerResponse response) —> {

143 Log( " ?OS /head/a i: ::") ;

146 Log ( Tarnirn; off head, p wt::") ;

147

143 Printer . SetHeadPower (false) ;

149 response . Send ( > ;

laO });

131

131: app . Get ("/aaaye " , (HttpListenerRequest request,

Webserver . SimpleHTTPListenerResponse response) -> {

133 Log( !1 03/r / iraaaa;/') ;

134

733 if (imageToPrint == null) {

733 response . Status (404) . Send {) ;

737 } else {

733 response . Image (imageToPrint) ;

L33 }

133 )) ;

i.31

130 app , Post ( "/aeaap" , (HttpListenerRequest request,

Webserver . SimpleHTTPLi stenerResponse response) => {

133 Log ("POST /a tu " ) ;

134

10a if (request . ContentType ?— " ¾ p 1 :. cation/ Ί son" ) {

iOa Log($'3:raa:!ii:i content type \ " i reqa aal- . Con ent ype 1 \" "5 ;

133 LogCdlot se'a::av3 up print syatem") ;

133 throw new Exception ($ "Kx eoaeo; content type to la:

¾ppli-:atio:3a; r: bat not i Etaaa:! alantentTyao ] „ ") ;

103 }

1 ' ? 0

171 PrintArgs printArqs;

172 using (var reader = new StreamReade ( request . InputStream) ) {

173 var deserializer = new JavaScriptSerlalizer () ;

174 printArqs *=

deserializer . Deserialize<Print:Arcjs>(reader , ReadToSnd {) ) ;

170 }

176

177 // Defaults

Γ?6 int bitsPerPixel = 4;

70 iria printRate = 000;

150

101 if (printArqs .bitsPerPixel > 0) {

100 bitsPerPixel = (int) printArqs . bitsPerPixel ;

100 }

704

703 if (printArgs .printRate > 0) {

703 printRate = ( int) rintArgs . rintRate ; }

Log ($"3e;: ring p r: i ao rate oo ; p r: i a ".Rati: j ") ;

Log (S "3e■: r.:i rig hirs oe.r pixel to ; ::.tsft;::P:ix»:i; " ) ;

Printer, Setup (printRate, ) ;

1 ) ;

app , Post ( "/ image" , (HttpListenerRequest request ,

Webserver . SimpleHTTFListenerResponse response) => {

Log { " r'Oc ' /frr-ege " ) ;

if ( ! (request . ContentType == "ix¾3 %/png" I I request . ContentType

:' is;¾ge/]?¾g") ) {

Log ($ "1 rival id content type \ " ί a eat . Con Oeiii ype } \ " ") ; Log ("S t s e o rai rio image");

throw new Exception ("Kxpecoeg cor;;; errt type to be a s er. oea imago ty e pake.- JPSG; , ") ;

}

imageToPrint = Bitma . FromStream (request . InputStream) as Bitmap; int targetlmageHeight = Printer. ROW NOZZLE COUNT * 2 ;

if ( im geToPrint . Height !- targe11mageHeight ) {

Log ($ "image as | vaiaqeTo rit . Height ; pizeia t<iii. Pes; i :■·: i rig t b:.a:ageti:;;iage}ie ig i5 r. ; piaeia tail.") ;

// Make a now blank image with the correct size

float ratioToCorrect = target ImageHeight /

( float) imageToPrint . Height ;

int correctedWidth = (int) (imageToPrint. idth * ratioToCorre Bitmap slicelmage = new Bitmap (correctedWidt ,

targetlmageHeight) ;

Graphics sliceGraphics ~ Graphics . Fromlmage (slicelmage) ; sliceGraphics . Clear (Color. White) ; // White me as no ink sliceGraphics . Interpol ationMode =

System, Draviing , Drawing2D . InterpolationMode . eares tNeighbor ; sliceGraphics . Dra lmage (imageToPrint , new Rectangle (0 , 0 , slicelmage. Width, slicelmage . Height) ) ;

imageTo r1nt — s11eelmage ;

}

// Threshold the image

imageToPrint = Thresholdlmage (imageToPrint , 0,5f ) ;

// Remo e every other line

imageToPrint = Stripelmage (imageToPrint) ;

// otate IbO decrees so that the ie f h-mosS: column of the image inted first, and right-side-up

imageToPrint . RotateFlip (RotateFlipType . Rotatel BOFlipNone) ;

Log ( " Loaoiing one image onto oho priaoirio s yaoeo") ;

Printer . Loadlmage (imageToPrint) ;

response . Send ( ) ;

)) ;

app . Post ( " /o.rl t " , (H tpListene Request request ,

Webserver . SimpleHTTPListenerResponse response) —> {

Log( !1 ?03T / rint") ;

if (imageToPrint = null) {

th ow new Exception ( "bo aaaoqe loaded ;: o p.z.in ;: " ) ;

} 243

244 Log { Oo cdiici 5i4:^c0'')

245 Printer . ForceProductDetect (} ;

244

response . Send {) ;

244 });

244

250 app , Post ( "7 ;>p 0" , (HttpListenerRequest request ,

Webserver . SirapleHTTFListenerResponse response) => {

251 Log ("0G2T //spit: " ) ;

252

250 Log ('' Spitting") ;

254 Printer . Spit {) ;

255

256 response. Send 0 ;

054 });

050 3

050

050 public async Task Run () {

261 if { !Meteorlnkj et .MeteorPath . LocatePrinterlnterface () ) {

062 if (UI Enabled O ) {

053 infoForm. SetMeteorStatus ("Pailed ~. loci-s 04::teor, 2;;: ;;h 004:

installed "} ;

054 } else {

060 r . ri teLine ( " OallL d to l c^ ':e the Metto 2 >: ntt.t:

066 }

267

266 letura;

262 5

270

271 infoForm. SetMeteorStatus ( ? 5L c«tid ?< ) ;

274 bool connectedToMeteor = false ;

274

275 try {

274 Printe . Connect () ;

277 connectedToMeteor = true;

270 if (UI Enabled () ) {

200 InfoForm. SetMeteorStatus ("Cooiie t d"} ;

222 } else {

202 Console .WriteLine ( 'HOonn ct d to print i sttKir) ;

200 }

204 } catch (Exception) |

005 if (UIEnabledO > {

005 infoForm. SetMeteorStatus ("Uosble to onntet " } ;

200 } else {

000 Console . Error . riteLine ( "Uasblfe ;:o οηη¾ : ;-;: to Mt;;:eor int.

s; v';st¾r-") ;

000 )

000 }

03:L

292 if (connectedToMeteor) {

093 Printer. PRINTER STATUS status = Printe . GetStatus () ;

094 infoForm. SetPrinterStatus (Printer. StatusDescription (status) ) ; 094

096 if (status — Printer . PRINTER STATUS . WAITING _FOR PCC) {

097 await Task. Run ((> => {

203 Thread. CurrentThread. IsBackground = true;

200

300 while {status == Printe . PRINTER_STATUS . WAITING_FOR_PCC) {

301 status = Printer . GetStatus 0 ;

342 Thread. Sleep(iOO) ;

303 }

304 }); 303 }

306

30 " ? infoForm. Set,Print erStatus (Printer . StatusDescription (status) } ;

ooo

3 0 initWebApp (} ;

33.0 app . Listen (5 ;

311 3

v:2 5

313

sj ' .4 p^i lic void unServiceDis covery () {

30 ; // Let clients find, us via UDP broadcast on. the local network

316 var discovery = new ServiceDis covery () ;

317 discovery . Listen { ) ;

313 }

313

330 private Bitmap Thresholdlmage (Image image, float threshold) {

323 Bitmap bra = new Bitma {image .Width, image . Height) ;

777

320 TmageAttributes tributes ~ new ImageA t ibutes ( ) ;

323 attributes . SetThreshold (threshold) ;

26 Point [] points ~ {

new Point ( 0 , 0) ,

323 new Point (image .Widt , 0) ,

329 new Point ( , image. Height) ,

300 };

301

333: Rectangle rect — new Rectangle (0, 0, image. Width, image. Height) ;

330

330 using (Graphics gr = Graphics . Fromlmage (bm) ) {

003 gr . Drawlmage (image , points, rect, GraphicsUnit . ixel , attributes) ;

330 }

333

330 return bm;

333 }

340

341 // .Adapted from.

iaL;;;n.ik i2i:i:itiaKark^A ^ 2; ^ .2

i 2 private Bitmap Stripelmage (Bitmap srclmaqe) {

1>43 Bitmap image — new Bitma {srclmage. Width, srclmage. Height,

Pixel Format. Format24bppRgb) ;

is Graphics imaqeGraphics · » Graphics . Fromlmage (image) ;

340

340 imageGraphics . Clear (Color . White) ;

347 imageGraphics . rawlmage (srclmage , 0, 0) ;

340

043 // Lock the bitmap's bits,

0.00 Rectangle rect = new Rectangle (0, 0, image, Width, image . Height) ;

00. System. Drawing . Imaging. BitmapData bmpData =

002 image . LockBit s (rect , System, Drawi g . Imaging , ImageLocKMode . Read rite , 303 image . PlxelFormat) ;

000

000 if (bmpData. Pixel Format · = PixelFor at . Format.24bppRgb) {

006 th ow new Exception (S -"Ov^x e -ce pixel to :":;a o

; . b": 0s ta OOixei 6o.;::"ac .I'oOt : i o0 ; j , Carro ;o:.;: :; oe . ") ;

007 5

300

366 // Get: che. address cO: che. firsc line.

000 IntPtr ptr = bmpData . ScanO ;

300

060 // Declare a array to hold the bytes of the bitmap,

363 int bytes = ath.Abs (bmpData. Stride) * image . Height ;

300 byte [] rgbValues = new byte [bytes ] ;

300

300 // Copy the RGB values into the array. ¾67 System. Runtime . InteropServices . Marshal . Cop (ptr , rgbValues , (; , bytes) ;

322

¾6 // Set every othar rov of xels to whit¾

370 for (iat V = 0; y < image . Height ; y += . " ;.) {

¾ ' i for (int x = 0; x < image. idth; x +- 5.) {

372 int: i = y * bmpData . Stride + x * 3 ;

373

is 7 bool inDisabledRow - y % «— 0;

775

½76 float brightness = (rgbValues [i] + rgbValues [i + .1] +

rgbValues [i + 21) / 3. Of;

377 bool darkPixel = brightness < 128 ;

3?¾ int thresholdValue « darkPixel ? 0 : 233;

373

330 byte pixelValue = (byte) (InDisabledRow ? 232 : thresholdValue) ;

301

302 rgbValues [i] = pixelValue;

303 rgbValues [i + 1] - pixelValue;

302 rgbValues [i + 2] = pixelValue;

303 }

006 }

007

000 // Copy ; b.e RGB values; back to i:b.e bitraap

203 System. Runtime . InteropServices . Marshal . Cop (rgbValues , 0, ptr, bytes) ;

030

001 // rjnioch the bits.

302 image . UnlockBits (bmpData) ;

333

032 return image;

303 }

003 }

337 }

333 3

337'

const { ipcRenderer } = require ( ! ¾i¾cc xon ' ) ;

const fs ~ require (' fa') ;

const path = require ( ' path * ) ;

const { promisify } — require ( ' ut.1.1 ! ) ;

const DropZone = require <;.r:)pZ X:e ' ) ;

const canvas = require ( 1 . /o-::i! va;; -- t i 1 ') ;

const Printer — requi re { : . /p ?: i :ite.;: ! ) :

const Stage — requireC ./s :;;;;') ;

const readFile = promisify (fs . eadFile) ;

cons drop - new DropZone (doenstient. , getElementByld ( ! dr sone 1 }) ;

let printer;

function arrayBufferToImg (data) {

const blob ~ new Blob ( [data] , { type: ! ixc^s· }<¾/ * ! }};

const img — document. createElement ( ' iroq ' ) ;

img. src = window. URL. createObj ectURL (blob) ;

e u n img;

}

const getStage ~ (() => {

let stage;

return as () => {

if (stage !—~ undefined) ί

return stage ;

}

const rawPrinterConfig = awai readFile (path . oin ( dirname, ' coxif iq ' ,

const printerConfig - JSON, arse (rawPrinterConfig) ;

stage = new Stage (document. getElementByld ( ' vi¾vpo∑ t 1 ) , printerConfig . canvas . width , printerConfig . canvas .height) ;

document . onkaydown ~ saverst => stage. onKeyDown (event) ;

document . onkeyup = ©vent => stage . onKeyUp (event) ;

return stage;

}

}) 0 ;

const printQueue = [] ;

class Printltem {

oonsfcnictor (img) {

this . image = img ;

this. printed = false;

this. staged = false ;

this, scale — j x: ). , y: 1 } ;

thi . position ~ { x; 0, yi 0 };

}

width () {

return this . imag . width * this . scale. x;

}

height ( ) {

return th s . mage . height * this . scale . ; setWidthPreserveAspectRatio (newWidth) f

const s = newWidth this . image .width ; this. scale = { x: s, y: s } ;

}

setHeightPreserveAspectRatio(newHeight) { const s ~ ne Height / this , image . height ; thie. scale = { x; s, y: s };

}

bounds () {

ista si {

left ; this . position . x ,

top: this . osition . y,

width: this . widt () ,

height: this, height () ,

} ;

}

asyrtc stage {

if (this . staged) {

eto n ;

}

(await getStageO ) .add (this) ;

this. staged — true;

}

render ( ) {

const imgEl ~ document. createElement | ; j.;-q imgEl.src = this . mage . src ;

imgEl . setAttribute ( 1 i a;.s ' , ' i a^qe- o-pri imgEl . onclick {) —> this . stage () ;

return imgEl ;

}

!

function renderPrintQueue () {

const imageTable ~ document . getElementByld ( imageTable . innerHTML = · * ;

printQueue . forEach ( (printlteiti) => {

const row document . crea teElement ( 1 1 1 ) ; const col — document . createElement ( ' td ! ) ; col . appendChild ( rint I tern, rende () ) ; row. appendChild (col) ;

imageTable . appendChild (row) ;

}) ; class Printedlmage {

const uc o iaiag , realWidth, realHeiqh this . image — canvas . copy (image) ;

this . realWidth = realWidth;

this . realHeight = realHeight;

this . dots PerMM = {

x; image. width / realWidth,

V*: image . height / realHeight,

}; "

this . sliceCache = [] ;

this . realRowLength —

} 131

132 invalidateCache {) {

this . sliceCache = [] ;

5- }

Ϊ.35

133 // Returns t:.he real worl length of a line sped ί i ed in triage pixel coordinates

132 / line looks like [ ata;:;:; ί x f v } .· nd; ί x, y } j

133 realLength (line) {

133 const dist = ath. abs {line. end. - line . star , ) / this . do sPerMM. ;

140· const distY = Ma b.. abs (line . end , y - line . start , y) / this . dots PerMM. γ ;

141 retu n M th. sqrt ( (distX ** 2) + (distY ** 2) )

1 2 }

1 3

144 pixelPosition (realX , realY) {

145 retu n {

146 x: realX * this . do s PerMM, x ,

141 y. realY * this . do s PerMM . y ,

142 } ;

143 }

Ϊ 30

131 getPrinterSlice (slicelndex) {

122 const sliceCount — this . realHeight / this . realRowLength;

1 3

132 if (slicelndex < 3 | | slicelndex >= sliceCount) {

133 th ow n-ev? Error ( ! lis valid ;2i i ·::-= .i.;';dex ' ) ;

136 }

133

133 if (! {slicelndex in this . sliceCache) ) {

133 const { x, y | = this . pixelPosition { 0 , this . realRowLength * slicelndex);

120 const { width } = this. image;

133 const { y: height } = this . pixelPosition (0 , this. ealRowLength) ;

132

133 const slice = canvas . sliceRectangle (this . inutge , { x, y, width, height });

133

133 this. sliceCache [slicelndex] = {

i.33 rect: { x, y, width, height },

123 image : s1ice ,

113 };

L33 }

173

171 return thxe. sliceCache [sl celndex] ;

172 }

173

174 // bounds should look lih.e i left, top, tight, bottom }

111 : 1 getPrinterSlices (bounds) {

173 cons startlndex = Math . floor (bounds . top / this . dotsPerMM . y / this . ealRowLength} ; 177 const endlndex — Math . ceil {bounds . bottom / thi . dotsPerMM . y / this . ealRowLength} ; 170 const width = bounds . right - bounds . left, ;

173

120 console , log (bounds ) ;

131

122 const sllcelnfo — [3;

133 for (let i = startlndex; i < endlndex; i += i) {

124. const fullSlice = this. getPrinterSlice (i) .ixnage;

133 const image — canvas . sliceRectangle (fullSlice, {

136 x: bounds. left,

27 yi 0,

133 width,

133 height: fullSlice . height ,

132 }};

131

132 slicelnfo . push ( {

133 image,

133 x: bounds. left / this . dotsPerMM. ,

133 y: i * this . realRowLength ,

133 width: width / this . dots PerMM. κ , height. : this . realRowLength,

}} ;

}

201 console , log (slicelnfo) ;

202 retMM slicelnfo;

203 }

204 5

2 2

202 drop . on { : d too ' ' , asyno (data) => {

202 console . log t ' 1 iiPice dropped') ;

20"

203 const img ~ arrayBufferToImg (data) ;

2 i 0

222 // Wait un il linage is loaded

2.12 await new Promise ( (fulfill) => {

2.13 img. ©nload = () ~> fulfill {) ;

2 2 }) ;

2

216 const: printltem — new Printltem(img) /

222 printQueue .push (printltem) ;

228 renderPrintQueue O ;

21.2 cons ole . l og ( ' lira go 1.copied 1 ) ;

220 5);

2 1

222 document . getElementByld ( ' i?¾tt rs-px ant') . onclick = async. 0 => {

2.123 const stage = await. getStagei);

222

222 const {

226 x: stageRenderX ,

227 y: stageRenderY ,

222 width : stageRenderWidth,

220 height: stageRenderHeight ,

232; } = stage . getRenderBounds {) ;

231

232 / FTXME: l;i;>tead of properly s ra 1 i ng the linages at the highest rss iy'ion

ph ysi rally tea/sidle

233 // we iiist re!ider them into a canvas- that is "big enough" that the printed output 1 GO his okay.

234 // Doing i properly would ifiean taking into account machine configura ion and print se tings ,

232 const dotsPerMM = 10;

233 const printCanvas ~ document, createEleriient ( ' ::¾; ;'.';:;■ ' ) ;

237 printCanvas . width = stage . realWidth * dotsPerMM;

233 printCanvas .height - stage . realHeight * dotsPerMM;

233

230 const scaleX = printCanvas . width stageRenderWidth;

24.1 const scaleY = printCanvas . height / stageRenderHeight;

242

243 const printCtx = printCanvas . get.Context ( 'i?o; ! ) ;

244 printCtx. fillStyle = ; 3iif : ;

242 printCtx. flllRect (0 , ( , printCanvas . idth , printCanvas . height) ;

246

247· ' const printBounds — { } ;

240

240 stage. items . forEach ( (stagedlmage) => {

200 // Coordinates i the p.tint canvas

231 const x = (s agedlmage . positio . x - stageRenderX) * scaleX;

232 const y = (s agedlmage . position . y - stageRenderY) * scaleY;

233 const width ~ stagedlmage . width ( ) * scaleX;

233 cons height — stagedlmage. height () * scaleY;

206 if ( rintBounds .left === undefined. M x < printBounds . left) !

237 printBounds . left = x;

232 } if ( rintBounds . right == undefined | | x + width > printBounds . right) { printBounds . right — x + width;

}

if (printBounds , op ——— undefined M y < printBounds . op) {

printBounds . op = y;

}

if (printBounds .bottom ~~~ unde 1: i ne | | y + height > printBounds . bottom) { printBounds .bottom = y + height;

}

printCtx . drawlxoage (stagedlmage . image , x, y, width, height) ;

}f; printBounds . left. ~ printBounds . left < 0 ? 0 : printBounds . left ;

printBounds . top ~ printBounds , top < 0 ? 0 : printBounds . op ;

printBounds . right. ~ printBounds . right > printCanvas . width

? pri nt.Can as . width

: p i ntBounds . ight ;

printBounds . bottom — pri tBounds . bottom > printCanvas . height

? i ntCanvas . height

: printBounds . bottom;

const printlmage = new Printedlmage (printCanvas , printe . canvas . width , printer . canvas . height) ;

console . log ( ' P;:ir;t beeivi:;. : , printBounds) ;

if ( !printer . motionController . isConnected () ) {

await printer . connect () ;

console . log ( ' c rrect -=d ! ) ;

await printer . home () ;

console . log ( ' ed' ) ;

}

const slices =- printlmage . getPrinterSlices (printBounds) ;

console . log (slices) ;

await slices . reduce ( (printPromise , slicelnfo) => printPromise

. then{() => printe .print (slicelnfo . image , slicelnfo. x, slicelnfo . y, slicelnfo . idth) ) , Promise . esolve () ) ;

} ;

ipcRenderer . on { ! reload ! , () ~ window. location. eload O ) ;

cons viewport = document . getElementByld ( ' iew r * ) ;

async function render {) {

requestAnimationFrame (render) ;

(await getStage () ) . rende () ;

}

function ha.ndleResize () {

viewport.. width = window . inn rWidth ;

viewport . height « window. nnexHeight ;

5

window. onreslze ~ () -> handleResize {) ;

dooiiHieiit . body . onload = async () —> {

const printerConfig «· JSO .parse (await readFile (path. join ( dirname , " fxc. ;i ;:v«, j eou') , ! B < )) ; ~~

printer = new Printer (printerConfig) ; ¾ ¾ window . rinter = printer;

323

323 handleResize (} ;

322 render ( ) ;

320 } ;

322

¾23 function uploadlmaqeForPrinting (imaqeFile) {

is30 const img — documen .. createElement (' u ' ) ;

333 img.src = window , URL . createOb;) ectURL (imageFi le) ;

$33 return new Promise ί (fulfill) => {

333 img. onload = () ~> {

335 window .URL. revokeObj ectURL (this . sic) ;

333

333 const printltem = n w Printltem(inig) ;

333 printQueue . push (printltem) ;

332 console . log ( ' ] ' i:iaq¾ lo;5 cd : )

340 fulfill (printltem) ;

341 };

342 }) ;

342 }

344.

342 const uploadButton ~ document . getElementByld { ' input -im&ge ' ) ;

342 uploadButton . oninput = () => {

240 ooHEt selectedlmageFile « · document . getEl ementByld ( ! inpu t-im-uqe ' ) . files [0] ;

242 uploadlmageForPrinting (selectedlmageFile) . then ( () => readerPrintQ eue () ) ;

343 };

330

231 / /document.. ge 03ie:;;er; 03ylci ; ' cu t r ols : · .onclick ----- eveuc ----> event . stoppKopagaCioni () ,- 322

ass Stage {

constructor (canvas , realwidth, realHeight) {

this . canvas — canvas;

this . canvas . onmousedown ~ e ent —> this , onMouseDown (event)

his . canvas . onmousemove — ve t ~> this . onMouseMove (event)

this . canvas . onamseup = () => this . onMouseUp () ;

this . canvas . onmouseenter = () => this . onMouseEnter {) ;

this . canvas . onmouseleave — () ~> this . onMouseLeave () ;

this . realWidth ~ realWidth;

this . realHeight — realHeight;

this.margin = 6 ; // px

this . items — [] ; this . s caling — false

}

onMouseDow (event) }

this .mouselsDown = trus;

this . updateMousePosition (event) ; if (this . s caling) {

this. scaling = false;

rstani ;

}

[th s . selectedltem] = this , itemsAt Point (this . mo seX, thi . mouseY) . reverse ( ) if (this . selectedltem — undefined) }

return ;

} this . setGrabPoint 0 ; this . originalPosition = Obj ect . ssign ( { ϊ , this , selectedltem, position) this . translating — true;

}

onMouseMove (event) {

this . updateMousePosition (event) ;

if (this . selectedltem {-∞ undefined) {

i (this. scaling) (

const. grabToOrigin = distance (

this . selectedltem. posi ion . x , this . selectedltem. positio . γ , this . cli ckPoin . x , this . clickPoint . y ,

) ;

const, mouseToOrigin = distance (

th s . selectedltem. positio . , this . selectedl em. position. y,

th s . mouseX , th s.mouseY, const relScale - mouseToOrigin / grabToOrigin ;

this . selectedltem. scale . x = this . originalScale . x * relScale; thiss . selecteciltem . seal e . v = this . originalScale . γ * relScale; } else if (this . translating) {

if (this .mouselsDown) I

this , selectedltem. osition ~ {

x : this.mouseX - this . grabPoint . x ,

y : this . mouseY - this . qrabPoin . y ,

}

ί

}

}

}

onMouseUp (event) {

if (this . scaling) {

this , scaling ~ false;

this , deselec All () ;

} else if (this . trans 1 atinq) {

this , trans lating = false;

}

this .mouselsDown = false ;

}

onMouseEnter (event) {

this .mouseOnStage - txrse ;

}

onMouseLeave (event) {

this .mouseOnStage = false;

}

sdateMousePosition (avent) {

this .mouseX = e ent . ageX - this . canvas . offsetLeft ,

this. ouseY — event.cageY - this . canvas . offsetTo ; delete (iterriToDelete) {

i temToDelete . staged = false;

this. items = this . items . filte (item => item !== itemToDelete) ;

}

setGrabPoint {) {

if (? this . mouseOnStage) {

return ;

}

this . grabPoint = {

x ; this . mouseX - this . selectedltem. osition

y : this. mouseY - this . selectedltem. osition this . c1ickPo int.

x: this. mouseX

ys th s. mou seY

} ;

}

onKeyDo n (event) {

if (even . code ===== ' E;;c¾pe 1 ) {

this . escapeCurrentOperation O ,- } else if (event, code ===== ' R¾y8 ! ) {

if (this . selectedltem t~~ undefined ££ this.mouseOnStage) I

this . originalScale = Obj ect . ssign ( { } , this . selectedltem. scale) ; l¾¾ this . setGrabPoint { ) ;

1 this. scaling = true;

31 }

LI! } else if (event, code === ' Dtifc Ce ' ) {

137 if (this , selectedltem !—— undefined) {

133 // Remove he sel cted item

L¾3 this .delete (t is . selectedltem)

140 this . selectedltem = undefined;

14 I }

142 )

143 }

144

343 onKeyU (event) {}

i 43

147 deselectAll {

143 this . selectedltem = undefined;

.143 }

.130

1.31 escapeCurrentOperation ( ) {

Ϊ32 if (this. scaling} {

ΐ 33 this. selectedltem. scale = this . originalScale;

33 fchis . scaling ~ false;

l3¾ } else if (this . translating) {

I ¾S this. selectedltem. osition - this . original-Position ;

1 ¾7 fch s . translating — false ;

36 }

i oo

130 this .deselectAll 0

161 }

161

163 itemsAtPoint (x, y) {

164 return this . items . filte ( (item) => {

163 const {

166 left,

163 top,

163 width,

163 height,

170 } = item. bounds () ;

171

173 e u n i sPointl tiBox (x , y, left, top, width, height);

173 });

174 }

173

170 add(printltem) {

177 if (printltem. in this. items) {

173 // T terri already added, nothing to do

173 return;

130 }

131

102 if (printltem. width () > this . canvas .width) {

133 printltem, set.WidthPreserveAspectP.at.io (this . canvas .width) ;

Ϊ04 }

183

106 if (printltem. height O > this . canvas . height) {

167 printltem., set.HeightPreserveAspectRiit.io (this . canvas . height) ;

188 }

163

190 this . items , push (printltem) ;

lOl }

132

133 getRenderBounds () {

194 const stageAspectRatio = this . realWidth / this . realHeight ;

193 const canvasAspectRatio = this . canvas . idth / this . canvas . height ;

196

197 const marginless idth = tills . canvas . width - this. margin * 3 ;

193 const marginlessHeight = this . canvas . eight. - fchis . margin * 2; 1

999; let width;

991 let. height;

03 if (stageAspectRatio > canvasAspectRatio) {

2: i 4 // Stage is ;la;:.;:.er than canvas

922; // so we should limi the stage's drawn width

229 width — marginlessWidth ;

221 height — marqinl essWidth / stageAspectRatio;

299 ) els¾s {

229 / Stage is aiisr than, canvas

219 // so we should limit, the stage's drawn height

211 width = marginlessHeight * stageAspectRatio;

212 height — marginlessHeight;

212 }

2 9

213 const x ~ (thie . canvas . width - width) / 2;

212 cons y ∞ (this , canvas , height - height) / 1;

211

2 9 retam { x, y, width, height };

21.3 }

221. render O {

222 const {

2191 x: stageDrawX,

229 y; stageDrawY,

221 width: stageDrawWidth,

21:6 height: stageDrawHeight ,

227 } « · tkis.getRenderBoundsO ;

21; 6

229 const ctx = this . canvas . getContext ( ' 2; ! ) ;

929

221 // Draw the stage bou s

221 ctx.fillStyle = 'ίίίί ' ί';

.229 ctx . fillRect, { 0 , 0, this . canvas . width , this , canvas . height) ;

294

221 ctx.strokeStyle - ' 9000 ! ;

229 ct.x . beginPath ( ) ;

299 ctx. moveTo (stageDrawX , stageDrawY) ;

239 ctx. lineTo (staqeDrawX + stageDrawWidth, stageDrawY);

239 ctx. lineTo (stageDrawX + stageDrawWidth, stageDrawY + stageDrawHeight) ;

240 ctx. lineTo (stageDrawX, stageDrawY + stageDrawHeight);

241 ctx. lineTo (staqeDrawX , stageDrawY) ;

242 ctx. stroke (> ;

943

244 ctx. save () ;

243

242 this . items . forEach ( (i em) => {

24? const. ( x, y ) » item. position;

249

249 ctx . drawlmage (item. image , x, y, item. idth () , item. height () 5 ;

290

291. // Highlight the selected i age

292 i.£ (item ===== this , selectedltem) {

293 ctx. strckeStyle - \rgb;995 ; 239. 0; ';

211 ctx.beginPath O

293 ct . moveTo (x , y) ;

216 ctx. lineTo (x + item, width. () , y) ;

2¾7 ctx.llneTo (x + item. idth O , y + item. height {) ) ;

233 ctx. lineTo { , y + item. height () ) ;

239 ctx. lineTo (x, y) ;

299 ctx. stroke {) ;

261 }

222 });

263

263 ctx . restore () ; module . exports = Stage;

jHSt int PIN PRESSURE SENSE = AO; .// M X¾0¾ DP or ssiire

PIN INK_PUMP_IN =

PIN INK_PUMP_OUT

PIN VACUUM _PUMP =

PIN INK_PU P_HEAE

PIN FLOAT IN = 7 ;

PIN ~ FLOAT ~ OUT = f

PIN PURGE BUTTON

-oat targetPressure = Ί 0 '>· ;

>id setu O {

Serial .begin ( ;

while ( 5 Serial) ;

pumpInkReturn (false) ;

pumpInkFeed (false) ;

pumpInkCircula or (false) ;

pinMode ί PIN_ PRESSURE SENSE,

INPUT) ,:

pinMode { IN_VACUUM__PUMP , OUTPUT) ;

pinMode { PIN_PURGE_BUTTO , INPUT_PULLUP)

pinMode (PIN_FLOAT_IN, INPUT_PULLUP) ;

pinMode SPIN FLOAT OUT, INPUT PULLUP) ;

inMode (PIN INK_ PUMP_ IN , OUTPUT);

pinMode(PIN INK_ PUMP_ OUT , OUTPUT);

Pi¬nModefPIN INK PUMP HEAD , OUTPUT);

t rnOffVacu um ( )

>id loop () { if (tinputlsFulK) && ? outputlsFull ( ) ) {

pumpTr, kFeed (true) ;

} e se {

pumpInkFeed (falsa) ;

}

i {outputlsFull () ) ί

pumpInkCirculator (true) ;

} else {

pumpInkCirculator (false) ;

}

if (purgeButtonFressedii ) ί

pumpInkReturn t ue) ;

puirpInkFeed (f lse) ;

pumpInkCirculator (false) ;

} el se {

pumpI kRe urn (faIee) ;

} 66 if (readPressure () > targetPressure) {

6 ' ? turnOnVac um < ) ;

68 } else {

66 turnOffVacuum { ) ;

7 0 }

71

72 priatStatus ;

76 delayCi.0) ;

}

76

76 void printStatus {) {

77 Serial . print ( "OOi ;: ei &re :> s r : " ) ;

76 Serial .print (targetPressure) ;

76 Serial . print ( "c" , Ourrs!:;!:. pi~ii:;;;:s6') ;

60 Serial .print (readPressure () ) ;

66 Serial. print (" . I ij ;: l.;5r0< ; " ) ·

62 Serial .print (inputIs Full () ? t: i>;il'' ; -e:s ; pty") ; 3

66 Serial. print O^t i: :ik : ") ;

66 Serial .println (outputls Full O ? ! 6i:u.i..;6 : ; "~ν. ϊ:ν") ;

66 }

63 void pumpInkRetur (bocl pump) {

66 if (pump) {

60 digital rite (PI INK _PUMP_ IN ,. HIGH)

91 } else {

66: digitalWrite (PIN_INK_PUMP_IN, LOW) ;

66 }

6 5

q ' : .

66 void pumpInkFeed {bool pump) {

66 if (pump) {

66 digitalWrite (PlN_INK_PUMP_OUT , HIGH) ;

6-; } else {

LOO digitalWrite (PIN_INK PUMP OUT, LOW) ;

=6; I }

i.0 1

103

164 void pumpInkCi rculato (bool pump) {

106 if (pump) {

166 digitalWrite (PI _INK PUMP HEAD, HIGH) ;

106 } else {

100 digitalWrite (PIN_INK__PUMP__HEAD , LOW) ;

100 }

110 }

11 i

112 bool inputlsFull () {

1 3 return digitalRead ( PIN_FLOAT_IN) ;

116 }

1 3

116 bool outputlsFull () {

166 etu n digitalRead ( PIN _FLOAT OUT) ;

166 }

119

120 void turnOnVacuum ( > {

126 digitalWrite (PIN_ VACUUM PUMP, HIGH)

122 }

ΐ 26

126 void turnOffVacuumO {

1.26 digitalWrite (PIN_VACUUM_PUMP , LOW) ;

12€ }

12b bool purgeBut onPressed () {

1.26 retuen ! digitalRead (PIN_PURGE_BUTTON) ;

130 ! 131

Vsi float readPres sure {) {

111 // Offset: ¾nd gair: c rrtctioa

11 float pressure = (analogRead (PIN PRESSURE SENSE) - 10) *

111

i. l // Convert to cm

Li! return pressure * 0.<·>37¾;

in 5

i l

140

jHSt int PIN PRESSURE SENSE = AO; .// M X¾0¾ DP or ssiire

PIN INK_PUMP_IN =

PIN INK_PUMP_OUT

PIN VACUUM _PUMP =

PIN INK_PU P_HEAE

PIN FLOAT IN = 7 ;

PIN ~ FLOAT ~ OUT = f

PIN PURGE BUTTON

-oat targetPressure = Ί 0 '>· ;

>id setu O {

Serial .begin ( ;

while ( 5 Serial) ;

pumpInkReturn (false) ;

pumpInkFeed (false) ;

pumpInkCircula or (false) ;

pinMode ί PIN_ PRESSURE SENSE,

INPUT) ,:

pinMode { IN_VACUUM__PUMP , OUTPUT) ;

pinMode { PIN_PURGE_BUTTO , INPUT_PULLUP)

pinMode (PIN_FLOAT_IN, INPUT_PULLUP) ;

pinMode SPIN FLOAT OUT, INPUT PULLUP) ;

inMode (PIN INK_ PUMP_ IN , OUTPUT);

pinMode(PIN INK_ PUMP_ OUT , OUTPUT);

Pi¬nModefPIN INK PUMP HEAD , OUTPUT);

t rnOffVacu um ( )

>id loop () { if (tinputlsFulK) && ? outputlsFull ( ) ) {

pumpTr, kFeed (true) ;

} e se {

pumpInkFeed (falsa) ;

}

i {outputlsFull () ) ί

pumpInkCirculator (true) ;

} else {

pumpInkCirculator (false) ;

}

if (purgeButtonFressedii ) ί

pumpInkReturn t ue) ;

puirpInkFeed (f lse) ;

pumpInkCirculator (false) ;

} el se {

pumpI kRe urn (faIee) ;

} 66 if (readPressure () > targetPressure) {

6 ' ? turnOnVac um < ) ;

68 } else {

66 turnOffVacuum { ) ;

7 0 }

71

72 priatStatus ;

76 delayCi.0) ;

}

76

76 void printStatus {) {

77 Serial . print ( "OOi ;: ei &re :> s r : " ) ;

76 Serial .print (targetPressure) ;

76 Serial . print ( "c" , Ourrs!:;!:. pi~ii:;;;:s6') ;

60 Serial .print (readPressure () ) ;

66 Serial. print (" . I ij ;: l.;5r0< ; " ) ·

62 Serial .print (inputIs Full () ? t: i>;il'' ; -e:s ; pty") ; 3

66 Serial. print O^t i: :ik : ") ;

66 Serial .println (outputls Full O ? ! 6i:u.i..;6 : ; "~ν. ϊ:ν") ;

66 }

63 void pumpInkRetur (bocl pump) {

66 if (pump) {

60 digital rite (PI INK _PUMP_ IN ,. HIGH)

91 } else {

66: digitalWrite (PIN_INK_PUMP_IN, LOW) ;

66 }

6 5

q ' : .

66 void pumpInkFeed {bool pump) {

66 if (pump) {

66 digitalWrite (PlN_INK_PUMP_OUT , HIGH) ;

6-; } else {

LOO digitalWrite (PIN_INK PUMP OUT, LOW) ;

=6; I }

i.0 1

103

164 void pumpInkCi rculato (bool pump) {

106 if (pump) {

166 digitalWrite (PI _INK PUMP HEAD, HIGH) ;

106 } else {

100 digitalWrite (PIN_INK__PUMP__HEAD , LOW) ;

100 }

110 }

11 i

112 bool inputlsFull () {

1 3 return digitalRead ( PIN_FLOAT_IN) ;

116 }

1 3

116 bool outputlsFull () {

166 etu n digitalRead ( PIN _FLOAT OUT) ;

166 }

119

120 void turnOnVacuum ( > {

126 digitalWrite (PIN_ VACUUM PUMP, HIGH)

122 }

ΐ 26

126 void turnOffVacuumO {

1.26 digitalWrite (PIN_VACUUM_PUMP , LOW) ;

12€ }

12b bool purgeBut onPressed () {

1.26 retuen ! digitalRead (PIN_PURGE_BUTTON) ;

130 ! 131

Vsi float readPres sure {) {

111 // Offset: ¾nd gair: c rrtctioa

11 float pressure = (analogRead (PIN PRESSURE SENSE) - 10) *

111

i. l // Convert to cm

Li! return pressure * 0.<·>37¾;

in 5

i l

140