mirror of
https://github.com/Doodle3D/doodle3d-firmware.git
synced 2024-12-22 11:03:48 +01:00
Merge branch 'feature/printerprofiles' into develop
This commit is contained in:
commit
69d9d2add8
@ -11,7 +11,7 @@
|
|||||||
-- - _description_: A descriptive text usable by API clients
|
-- - _description_: A descriptive text usable by API clients
|
||||||
-- - _min_, _max_, _regex_: optional constraints (min and max constrain value for numbers, or length for strings)
|
-- - _min_, _max_, _regex_: optional constraints (min and max constrain value for numbers, or length for strings)
|
||||||
-- - _isValid_: an optional function which should return true for valid values and false for invalid ones
|
-- - _isValid_: an optional function which should return true for valid values and false for invalid ones
|
||||||
--
|
-- - _subSection: optional: setting name of which current value is used as the uci section where this setting should be loaded from. Otherwise it's retrieved from the generic section. Setting subsection also means it will first try to get a default from subconf_defaults, if that doesn't exsist it will use the regular default
|
||||||
-- The configuration keys themselves document themselves rather well, hence they are not included in the generated documentation.
|
-- The configuration keys themselves document themselves rather well, hence they are not included in the generated documentation.
|
||||||
--
|
--
|
||||||
-- NOTE: the all-caps definitions should be changed into configuration keys, or moved to a better location.
|
-- NOTE: the all-caps definitions should be changed into configuration keys, or moved to a better location.
|
||||||
@ -92,19 +92,44 @@ M.printer_type = {
|
|||||||
return printers[value] ~= nil
|
return printers[value] ~= nil
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
M.printer_bed_width = {
|
M.printer_bed_width = {
|
||||||
default = 220,
|
default = 220,
|
||||||
|
subSection = 'printer_type',
|
||||||
type = 'int',
|
type = 'int',
|
||||||
description = '',
|
description = '',
|
||||||
min = 0
|
min = 0
|
||||||
}
|
}
|
||||||
M.printer_bed_height = {
|
M.printer_bed_height = {
|
||||||
default = 220,
|
default = 220,
|
||||||
|
subSection = 'printer_type',
|
||||||
type = 'int',
|
type = 'int',
|
||||||
description = '',
|
description = '',
|
||||||
min = 0
|
min = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local default_makerbot_startcode = '(**** CONFIGURATION MACROS ****)\n;@printer {printerType}\n;@enable progress\n(** This GCode was generated by ReplicatorG 0040 **)\n(* using Skeinforge (50) *)\n(* for a Dual headed Replicator 2 *)\n(* on 2013/10/27 15:07:27 (+0100) *)\n(**** start.gcode for Replicator 2X, single head ****)\nM103 (disable RPM)\nM73 P0 (enable build progress)\nG21 (set units to mm)\nG90 (set positioning to absolute)\nM104 S240 T0 (set extruder temperature) (temp updated by printOMatic)\nM140 S110 T0 (set HBP temperature)\n(**** begin homing ****)\nG162 X Y F2500 (home XY axes maximum)\nG161 Z F1100 (home Z axis minimum)\nG92 Z-5 (set Z to -5)\nG1 Z0.0 (move Z to "0")\nG161 Z F100 (home Z axis minimum)\nM132 X Y Z A B (Recall stored home offsets for XYZAB axis)\n(**** end homing ****)\nG1 X-141 Y-74 Z10 F3300.0 (move to waiting position)\nG130 X20 Y20 Z20 A20 B20 (Lower stepper Vrefs while heating)\nM6 T0 (wait for toolhead, and HBP to reach temperature)\nG130 X127 Y127 Z40 A127 B127 (Set Stepper motor Vref to defaults)\nM108 R3.0 T0\nG0 X-141 Y-74 (Position Nozzle)\nG0 Z0.6 (Position Height)\nM108 R5.0 (Set Extruder Speed)\nM101 (Start Extruder)\nG4 P2000 (Create Anchor)\nG92 X0 Y0\nM106\n(**** end of start.gcode ****)'
|
||||||
|
M.printer_startcode = {
|
||||||
|
default = ';Generated with Doodle3D (default)\nM109 S{printingTemp} ;set target temperature \n;M190 S{printingBedTemp} ;set target bed temperature\nG21 ;metric values\nG91 ;relative positioning\nM107 ;start with the fan off\nG28 X0 Y0 ;move X/Y to min endstops\nG28 Z0 ;move Z to min endstops\nG1 Z15 F9000 ;move the platform down 15mm\nG92 E0 ;zero the extruded length\nG1 F200 E10 ;extrude 10mm of feed stock\nG92 E0 ;zero the extruded length again\nG92 E0 ;zero the extruded length again\nG1 F9000\nG90 ;absolute positioning\nM117 Printing Doodle... ;display message (20 characters to clear whole screen)',
|
||||||
|
default_makerbot_generic = default_makerbot_startcode,
|
||||||
|
default_makerbot_replicator2 = default_makerbot_startcode,
|
||||||
|
default_makerbot_thingomatic = default_makerbot_startcode,
|
||||||
|
type = 'string',
|
||||||
|
subSection = 'printer_type',
|
||||||
|
description = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
local default_makerbot_endcode = '(******* End.gcode*******)\nM73 P100 ( End build progress )\nG0 Z150 ( Send Z axis to bottom of machine )\nM18 ( Disable steppers )\nM104 S0 T0 ( Cool down the Right Extruder )\nG162 X Y F2500 ( Home XY endstops )\nM18 ( Disable stepper motors )\nM70 P5 ( We <3 Making Things!)\nM72 P1 ( Play Ta-Da song )\n(*********end End.gcode*******)'
|
||||||
|
M.printer_endcode = {
|
||||||
|
default = 'M107 ;fan off\nG91 ;relative positioning\nG1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure\nG1 Z+0.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more\nG28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way\nM84 ;disable axes / steppers\nG90 ;absolute positioning\nM104 S{preheatTemp}\n;M140 S{preheatBedTemp}\nM117 Done ;display message (20 characters to clear whole screen)',
|
||||||
|
default_makerbot_generic = default_makerbot_endcode,
|
||||||
|
default_makerbot_replicator2 = default_makerbot_endcode,
|
||||||
|
default_makerbot_thingomatic = default_makerbot_endcode,
|
||||||
|
type = 'string',
|
||||||
|
subSection = 'printer_type',
|
||||||
|
description = ''
|
||||||
|
}
|
||||||
|
|
||||||
M.printer_baudrate = {
|
M.printer_baudrate = {
|
||||||
default = '115200',
|
default = '115200',
|
||||||
type = 'int',
|
type = 'int',
|
||||||
@ -227,30 +252,6 @@ M.printer_enableTraveling = {
|
|||||||
description = ''
|
description = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
M.printer_startcode_marlin = {
|
|
||||||
default = ';Generated with Doodle3D\nM109 S{printingTemp} ;set target temperature \n;M190 S{printingBedTemp} ;set target bed temperature\nG21 ;metric values\nG91 ;relative positioning\nM107 ;start with the fan off\nG28 X0 Y0 ;move X/Y to min endstops\nG28 Z0 ;move Z to min endstops\nG1 Z15 F9000 ;move the platform down 15mm\nG92 E0 ;zero the extruded length\nG1 F200 E10 ;extrude 10mm of feed stock\nG92 E0 ;zero the extruded length again\nG92 E0 ;zero the extruded length again\nG1 F9000\nG90 ;absolute positioning\nM117 Printing Doodle... ;display message (20 characters to clear whole screen)',
|
|
||||||
type = 'string',
|
|
||||||
description = ''
|
|
||||||
}
|
|
||||||
|
|
||||||
M.printer_endcode_marlin = {
|
|
||||||
default = 'M107 ;fan off\nG91 ;relative positioning\nG1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure\nG1 Z+0.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more\nG28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way\nM84 ;disable axes / steppers\nG90 ;absolute positioning\nM104 S{preheatTemp}\n;M140 S{preheatBedTemp}\nM117 Done ;display message (20 characters to clear whole screen)',
|
|
||||||
type = 'string',
|
|
||||||
description = ''
|
|
||||||
}
|
|
||||||
|
|
||||||
M.printer_startcode_x3g = {
|
|
||||||
default = '(**** CONFIGURATION MACROS ****)\n;@printer r2x\n;@enable progress\n(** This GCode was generated by ReplicatorG 0040 **)\n(* using Skeinforge (50) *)\n(* for a Dual headed Replicator 2 *)\n(* on 2013/10/27 15:07:27 (+0100) *)\n(**** start.gcode for Replicator 2X, single head ****)\nM103 (disable RPM)\nM73 P0 (enable build progress)\nG21 (set units to mm)\nG90 (set positioning to absolute)\nM104 S240 T0 (set extruder temperature) (temp updated by printOMatic)\nM140 S110 T0 (set HBP temperature)\n(**** begin homing ****)\nG162 X Y F2500 (home XY axes maximum)\nG161 Z F1100 (home Z axis minimum)\nG92 Z-5 (set Z to -5)\nG1 Z0.0 (move Z to "0")\nG161 Z F100 (home Z axis minimum)\nM132 X Y Z A B (Recall stored home offsets for XYZAB axis)\n(**** end homing ****)\nG1 X-141 Y-74 Z10 F3300.0 (move to waiting position)\nG130 X20 Y20 Z20 A20 B20 (Lower stepper Vrefs while heating)\nM6 T0 (wait for toolhead, and HBP to reach temperature)\nG130 X127 Y127 Z40 A127 B127 (Set Stepper motor Vref to defaults)\nM108 R3.0 T0\nG0 X-141 Y-74 (Position Nozzle)\nG0 Z0.6 (Position Height)\nM108 R5.0 (Set Extruder Speed)\nM101 (Start Extruder)\nG4 P2000 (Create Anchor)\nG92 X0 Y0\nM106\n(**** end of start.gcode ****)',
|
|
||||||
type = 'string',
|
|
||||||
description = ''
|
|
||||||
}
|
|
||||||
|
|
||||||
M.printer_endcode_x3g = {
|
|
||||||
default = '(******* End.gcode*******)\nM73 P100 ( End build progress )\nG0 Z150 ( Send Z axis to bottom of machine )\nM18 ( Disable steppers )\nM104 S0 T0 ( Cool down the Right Extruder )\nG162 X Y F2500 ( Home XY endstops )\nM18 ( Disable stepper motors )\nM70 P5 ( We <3 Making Things!)\nM72 P1 ( Play Ta-Da song )\n(*********end End.gcode*******)',
|
|
||||||
type = 'string',
|
|
||||||
description = ''
|
|
||||||
}
|
|
||||||
|
|
||||||
M.printer_maxObjectHeight = {
|
M.printer_maxObjectHeight = {
|
||||||
default = 150,
|
default = 150,
|
||||||
type = 'int',
|
type = 'int',
|
||||||
|
@ -88,7 +88,28 @@ function M.all_GET(request, response)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Reset specific setting to default value
|
||||||
|
-- When an setting has a subSection only the setting in it's current subSection is reset.
|
||||||
|
-- For example you want to reset setting _printer.startcode_
|
||||||
|
-- and it has it's _subSection_ set to 'printer_type'
|
||||||
|
-- and printer.type is set to 'ultimaker' then
|
||||||
|
-- only the printer.startcode under the ultimaker subsection is removed.
|
||||||
|
function M.reset_POST(request, response)
|
||||||
|
--log:info("API:reset");
|
||||||
|
if not operationsAccessOrFail(request, response) then return end
|
||||||
|
response:setSuccess()
|
||||||
|
|
||||||
|
for k,v in pairs(request:getAll()) do
|
||||||
|
--log:info(" "..k..": "..v);
|
||||||
|
local r,m = settings.reset(k);
|
||||||
|
if r ~= nil then response:addData(k, "ok")
|
||||||
|
else response:addData(k, "could not reset key ('" .. m .. "')") end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Reset all settings to default value
|
||||||
function M.resetall_POST(request, response)
|
function M.resetall_POST(request, response)
|
||||||
|
if not operationsAccessOrFail(request, response) then return end
|
||||||
response:setSuccess()
|
response:setSuccess()
|
||||||
settings.resetAll()
|
settings.resetAll()
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ function M:setError(msg)
|
|||||||
self.body.status = 'error'
|
self.body.status = 'error'
|
||||||
if msg ~= '' then self.body.msg = msg end
|
if msg ~= '' then self.body.msg = msg end
|
||||||
|
|
||||||
self:addData('more_info', 'http://' .. defaults.API_BASE_URL_PATH .. '/wiki/wiki/communication-api')
|
self:addData('more_info', 'http://' .. defaults.API_BASE_URL_PATH .. '/api')
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Adds a data item to the response, this will be included under the `data` item of the json text.
|
--- Adds a data item to the response, this will be included under the `data` item of the json text.
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
-- if no value is stored in the UCI config. The UCI config file is `/etc/config/wifibox`.
|
-- if no value is stored in the UCI config. The UCI config file is `/etc/config/wifibox`.
|
||||||
-- The default values guarantee there will always be a set of reasonable settings
|
-- The default values guarantee there will always be a set of reasonable settings
|
||||||
-- to use and provide a clear overview of all existing configuration keys as well.
|
-- to use and provide a clear overview of all existing configuration keys as well.
|
||||||
|
-- uci api: http://wiki.openwrt.org/doc/techref/uci, http://luci.subsignal.org/api/luci/modules/luci.model.uci.html
|
||||||
local uci = require('uci').cursor()
|
local uci = require('uci').cursor()
|
||||||
local utils = require('util.utils')
|
local utils = require('util.utils')
|
||||||
local baseconfig = require('conf_defaults')
|
local baseconfig = require('conf_defaults')
|
||||||
|
local subconfig = require('subconf_defaults')
|
||||||
local utils = require('util.utils')
|
local utils = require('util.utils')
|
||||||
local log = require('util.logger')
|
local log = require('util.logger')
|
||||||
|
|
||||||
@ -136,23 +138,51 @@ local function getBaseKeyTable(key)
|
|||||||
return type(base) == 'table' and base.default ~= nil and base or nil
|
return type(base) == 'table' and base.default ~= nil and base or nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Looks up the table in @{subconf_defaults}.lua corresponding to a key.
|
||||||
|
-- @string key The key for which to return the base table.
|
||||||
|
-- @treturn table The base table for key, or nil if it does not exist.
|
||||||
|
--[[local function getSubBaseKeyTable(key)
|
||||||
|
local base = subconfig[key]
|
||||||
|
return type(base) == 'table' and base.default ~= nil and base or nil
|
||||||
|
end]]--
|
||||||
|
|
||||||
|
|
||||||
--- Returns the value of the requested key if it exists.
|
--- Returns the value of the requested key if it exists.
|
||||||
-- @p key The key to return the associated value for.
|
-- @p key The key to return the associated value for.
|
||||||
-- @return The associated value, beware (!) that this may be boolean false for keys of 'bool' type.
|
-- @return The associated value, beware (!) that this may be boolean false for keys of 'bool' type.
|
||||||
function M.get(key)
|
function M.get(key)
|
||||||
|
log:info("settings:get: "..utils.dump(key))
|
||||||
key = replaceDots(key)
|
key = replaceDots(key)
|
||||||
local base = getBaseKeyTable(key)
|
local base = getBaseKeyTable(key)
|
||||||
|
|
||||||
if not base then return nil,ERR_NO_SUCH_KEY end
|
if not base then return nil,ERR_NO_SUCH_KEY end
|
||||||
|
|
||||||
local v = base.default
|
local section = UCI_CONFIG_SECTION;
|
||||||
local uciV = fromUciValue(uci:get(UCI_CONFIG_NAME, UCI_CONFIG_SECTION, key), base.type)
|
if base.subSection ~= nil then
|
||||||
|
log:info(" base.subSection: "..utils.dump(base.subSection))
|
||||||
local actualV = v
|
section = M.get(base.subSection)
|
||||||
if uciV ~= nil then actualV = uciV end
|
end
|
||||||
|
log:info(" section: "..utils.dump(section))
|
||||||
return actualV
|
|
||||||
|
local uciV = fromUciValue(uci:get(UCI_CONFIG_NAME, section, key), base.type)
|
||||||
|
log:info(" uciV: "..utils.dump(uciV))
|
||||||
|
|
||||||
|
if uciV ~= nil then
|
||||||
|
log:info(" returning uciV: "..utils.dump(uciV))
|
||||||
|
return uciV
|
||||||
|
elseif base.subSection ~= nil then
|
||||||
|
log:info(" base.subSection: "..utils.dump(base.subSection))
|
||||||
|
log:info(" section: "..utils.dump(section))
|
||||||
|
log:info(" key: "..utils.dump(key))
|
||||||
|
log:info(" subDefault key: "..utils.dump("default_"..section))
|
||||||
|
local subDefault = base["default_"..section]
|
||||||
|
if subDefault ~= nil then
|
||||||
|
log:info(" returning subsection default: "..utils.dump(subDefault))
|
||||||
|
return subDefault
|
||||||
|
end
|
||||||
|
end
|
||||||
|
log:info(" returning default: "..utils.dump(base.default))
|
||||||
|
return base.default
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns all configuration keys with their current values.
|
--- Returns all configuration keys with their current values.
|
||||||
@ -206,7 +236,7 @@ function M.set(key, value)
|
|||||||
|
|
||||||
if M.isDefault(key) and value == nil then return true end -- key is default already
|
if M.isDefault(key) and value == nil then return true end -- key is default already
|
||||||
--log:info(" not default")
|
--log:info(" not default")
|
||||||
local current = uci:get(UCI_CONFIG_NAME, UCI_CONFIG_SECTION, key)
|
|
||||||
--log:info(" base.type: "..utils.dump(base.type))
|
--log:info(" base.type: "..utils.dump(base.type))
|
||||||
if base.type == 'bool' then
|
if base.type == 'bool' then
|
||||||
if value ~= "" then
|
if value ~= "" then
|
||||||
@ -227,12 +257,23 @@ function M.set(key, value)
|
|||||||
return nil,m
|
return nil,m
|
||||||
end
|
end
|
||||||
|
|
||||||
if fromUciValue(current, base.type) == value then return true end
|
--local current = uci:get(UCI_CONFIG_NAME, UCI_CONFIG_SECTION, key)
|
||||||
|
local current = M.get(key)
|
||||||
|
--if fromUciValue(current, base.type) == value then return true end
|
||||||
|
if current == value then return true end
|
||||||
|
|
||||||
|
local section = UCI_CONFIG_SECTION;
|
||||||
|
if base.subSection ~= nil then
|
||||||
|
log:info(" base.subSection: "..utils.dump(base.subSection))
|
||||||
|
section = M.get(base.subSection)
|
||||||
|
uci:set(UCI_CONFIG_NAME, section, UCI_CONFIG_TYPE)
|
||||||
|
end
|
||||||
|
log:info(" section: "..utils.dump(section))
|
||||||
|
|
||||||
if value ~= nil then
|
if value ~= nil then
|
||||||
uci:set(UCI_CONFIG_NAME, UCI_CONFIG_SECTION, key, toUciValue(value, base.type))
|
uci:set(UCI_CONFIG_NAME, section, key, toUciValue(value, base.type))
|
||||||
else
|
else
|
||||||
uci:delete(UCI_CONFIG_NAME, UCI_CONFIG_SECTION, key)
|
uci:delete(UCI_CONFIG_NAME, section, key)
|
||||||
end
|
end
|
||||||
|
|
||||||
uci:commit(UCI_CONFIG_NAME)
|
uci:commit(UCI_CONFIG_NAME)
|
||||||
@ -244,11 +285,21 @@ end
|
|||||||
-- @treturn bool|nil True if everything went well, nil in case of error.
|
-- @treturn bool|nil True if everything went well, nil in case of error.
|
||||||
function M.resetAll()
|
function M.resetAll()
|
||||||
log:info("settings:resetAll")
|
log:info("settings:resetAll")
|
||||||
for k,_ in pairs(baseconfig) do
|
|
||||||
if not k:match('^[A-Z_]*$') then --TEMP: skip 'constants', which should be moved anyway
|
local allSections = uci:get_all(UCI_CONFIG_NAME)
|
||||||
M.reset(k)
|
log:info(" allSections: "..utils.dump(allSections))
|
||||||
end
|
|
||||||
|
for key,value in pairs(allSections) do
|
||||||
|
if key ~= "system" and not key:match('^[A-Z_]*$') then --TEMP: skip 'constants', which should be moved anyway
|
||||||
|
log:info(" section: "..utils.dump(key))
|
||||||
|
uci:delete(UCI_CONFIG_NAME,key)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
uci:commit(UCI_CONFIG_NAME)
|
||||||
|
|
||||||
|
local allSections = uci:get_all(UCI_CONFIG_NAME)
|
||||||
|
log:info(" >allSections: "..utils.dump(allSections))
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -256,10 +307,30 @@ end
|
|||||||
-- @string key The key to reset.
|
-- @string key The key to reset.
|
||||||
-- @treturn bool|nil True if everything went well, nil in case of error.
|
-- @treturn bool|nil True if everything went well, nil in case of error.
|
||||||
function M.reset(key)
|
function M.reset(key)
|
||||||
log:info("settings:reset")
|
log:info("settings:reset: "..utils.dump(key))
|
||||||
|
|
||||||
|
--uci:foreach(UCI_CONFIG_NAME,UCI_CONFIG_TYPE)
|
||||||
|
--uci:delete(UCI_CONFIG_NAME, UCI_CONFIG_SECTION, key)
|
||||||
|
|
||||||
|
key = replaceDots(key)
|
||||||
|
local base = getBaseKeyTable(key)
|
||||||
|
if not base then return nil,ERR_NO_SUCH_KEY end
|
||||||
|
|
||||||
|
local section = UCI_CONFIG_SECTION;
|
||||||
|
if base.subSection ~= nil then
|
||||||
|
log:info(" base.subSection: "..utils.dump(base.subSection))
|
||||||
|
section = M.get(base.subSection)
|
||||||
|
end
|
||||||
|
log:info(" section: "..utils.dump(section))
|
||||||
|
|
||||||
|
local uciV = fromUciValue(uci:get(UCI_CONFIG_NAME, section, key), base.type)
|
||||||
|
log:info(" uciV: "..utils.dump(uciV))
|
||||||
|
|
||||||
|
uci:delete(UCI_CONFIG_NAME, section, key)
|
||||||
|
|
||||||
|
local uciV = fromUciValue(uci:get(UCI_CONFIG_NAME, section, key), base.type)
|
||||||
|
log:info(" >uciV: "..utils.dump(uciV))
|
||||||
|
|
||||||
--log:info(" key: "..utils.dump(key))
|
|
||||||
uci:delete(UCI_CONFIG_NAME, UCI_CONFIG_SECTION, key)
|
|
||||||
uci:commit(UCI_CONFIG_NAME)
|
uci:commit(UCI_CONFIG_NAME)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user