farmbot-serial 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/farmbot-serial.gemspec +2 -2
- data/lib/hardware_interface_arduino.rb +62 -163
- data/lib/hardware_interface_arduino_values_received.rb +8 -1
- data/lib/hardware_interface_write_status.rb +35 -0
- metadata +3 -13
- data/lib/arduino_default_params.rb +0 -148
- data/lib/hardware_interface.rb +0 -210
- data/lib/hardware_interface_arduino_write_status.rb +0 -30
- data/lib/hardware_interface_param.rb +0 -218
- data/lib/status.rb +0 -52
- data/spec/lib/ramps_arduino_write_status_spec.rb +0 -27
- data/spec/lib/ramps_param_spec.rb +0 -555
- data/spec/lib/ramps_spec.rb +0 -289
@@ -1,148 +0,0 @@
|
|
1
|
-
# Put this in a module.
|
2
|
-
$arduino_default_params = [
|
3
|
-
{
|
4
|
-
:name => 'PARAM_VERSION',
|
5
|
-
:id => 0,
|
6
|
-
:value => 0
|
7
|
-
},
|
8
|
-
{
|
9
|
-
:name => 'MOVEMENT_TIMEOUT_X',
|
10
|
-
:id => 11,
|
11
|
-
:value => 15
|
12
|
-
},
|
13
|
-
{
|
14
|
-
:name => 'MOVEMENT_TIMEOUT_Y',
|
15
|
-
:id => 12,
|
16
|
-
:value => 15
|
17
|
-
},
|
18
|
-
{
|
19
|
-
:name => 'MOVEMENT_TIMEOUT_Z',
|
20
|
-
:id => 13,
|
21
|
-
:value => 15
|
22
|
-
},
|
23
|
-
{
|
24
|
-
:name => 'MOVEMENT_INVERT_ENDPOINTS_X',
|
25
|
-
:id => 21,
|
26
|
-
:value => 0
|
27
|
-
},
|
28
|
-
{
|
29
|
-
:name => 'MOVEMENT_INVERT_ENDPOINTS_Y',
|
30
|
-
:id => 22,
|
31
|
-
:value => 0
|
32
|
-
},
|
33
|
-
{
|
34
|
-
:name => 'MOVEMENT_INVERT_ENDPOINTS_Z',
|
35
|
-
:id => 23,
|
36
|
-
:value => 0
|
37
|
-
},
|
38
|
-
{
|
39
|
-
:name => 'MOVEMENT_INVERT_MOTOR_X',
|
40
|
-
:id => 31,
|
41
|
-
:value => 0
|
42
|
-
},
|
43
|
-
{
|
44
|
-
:name => 'MOVEMENT_INVERT_MOTOR_Y',
|
45
|
-
:id => 32,
|
46
|
-
:value => 0
|
47
|
-
},
|
48
|
-
{
|
49
|
-
:name => 'MOVEMENT_INVERT_MOTOR_Z',
|
50
|
-
:id => 33,
|
51
|
-
:value => 0
|
52
|
-
},
|
53
|
-
{
|
54
|
-
:name => 'MOVEMENT_STEPS_ACC_DEC_X',
|
55
|
-
:id => 41,
|
56
|
-
:value => 100
|
57
|
-
},
|
58
|
-
{
|
59
|
-
:name => 'MOVEMENT_STEPS_ACC_DEC_Y',
|
60
|
-
:id => 42,
|
61
|
-
:value => 100
|
62
|
-
},
|
63
|
-
{
|
64
|
-
:name => 'MOVEMENT_STEPS_ACC_DEC_Z',
|
65
|
-
:id => 43,
|
66
|
-
:value => 100
|
67
|
-
},
|
68
|
-
{
|
69
|
-
:name => 'MOVEMENT_HOME_UP_X',
|
70
|
-
:id => 51,
|
71
|
-
:value => 0
|
72
|
-
},
|
73
|
-
{
|
74
|
-
:name => 'MOVEMENT_HOME_UP_Y',
|
75
|
-
:id => 52,
|
76
|
-
:value => 0
|
77
|
-
},
|
78
|
-
{
|
79
|
-
:name => 'MOVEMENT_HOME_UP_Z',
|
80
|
-
:id => 53,
|
81
|
-
:value => 0
|
82
|
-
},
|
83
|
-
{
|
84
|
-
:name => 'MOVEMENT_MIN_SPD_X',
|
85
|
-
:id => 61,
|
86
|
-
:value => 200
|
87
|
-
},
|
88
|
-
{
|
89
|
-
:name => 'MOVEMENT_MIN_SPD_Y',
|
90
|
-
:id => 62,
|
91
|
-
:value => 200
|
92
|
-
},
|
93
|
-
{
|
94
|
-
:name => 'MOVEMENT_MIN_SPD_Z',
|
95
|
-
:id => 63,
|
96
|
-
:value => 200
|
97
|
-
},
|
98
|
-
{
|
99
|
-
:name => 'MOVEMENT_MAX_SPD_X',
|
100
|
-
:id => 71,
|
101
|
-
:value => 1000
|
102
|
-
},
|
103
|
-
{
|
104
|
-
:name => 'MOVEMENT_MAX_SPD_Y',
|
105
|
-
:id => 72,
|
106
|
-
:value => 1000
|
107
|
-
},
|
108
|
-
{
|
109
|
-
:name => 'MOVEMENT_MAX_SPD_Z',
|
110
|
-
:id => 73,
|
111
|
-
:value => 1000
|
112
|
-
},
|
113
|
-
{
|
114
|
-
:name => 'MOVEMENT_LENGTH_X',
|
115
|
-
:id => 101,
|
116
|
-
:value => 1000
|
117
|
-
},
|
118
|
-
{
|
119
|
-
:name => 'MOVEMENT_LENGTH_Y',
|
120
|
-
:id => 102,
|
121
|
-
:value => 1000
|
122
|
-
},
|
123
|
-
{
|
124
|
-
:name => 'MOVEMENT_LENGTH_Z',
|
125
|
-
:id => 103,
|
126
|
-
:value => 1000
|
127
|
-
},
|
128
|
-
{
|
129
|
-
:name => 'MOVEMENT_STEPS_PER_UNIT_X',
|
130
|
-
:id => 111,
|
131
|
-
:value => 5
|
132
|
-
},
|
133
|
-
{
|
134
|
-
:name => 'MOVEMENT_STEPS_PER_UNIT_Y',
|
135
|
-
:id => 112,
|
136
|
-
:value => 5
|
137
|
-
},
|
138
|
-
{
|
139
|
-
:name => 'MOVEMENT_STEPS_PER_UNIT_Z',
|
140
|
-
:id => 113,
|
141
|
-
:value => 5
|
142
|
-
},
|
143
|
-
{
|
144
|
-
:name => 'TESTING',
|
145
|
-
:id => 1,
|
146
|
-
:value => 0
|
147
|
-
}
|
148
|
-
]
|
data/lib/hardware_interface.rb
DELETED
@@ -1,210 +0,0 @@
|
|
1
|
-
## HARDWARE INTERFACE
|
2
|
-
## ******************
|
3
|
-
|
4
|
-
# Communicate with the arduino using a serial interface
|
5
|
-
# All information is exchanged using a variation of g-code
|
6
|
-
# Parameters are stored in the database
|
7
|
-
module Fb
|
8
|
-
class HardwareInterface
|
9
|
-
class << self
|
10
|
-
attr_accessor :current
|
11
|
-
|
12
|
-
def current
|
13
|
-
@current ||= self.new(true)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
attr_reader :ramps_param, :ramps_main, :ramps_arduino
|
18
|
-
attr_accessor :status
|
19
|
-
|
20
|
-
# initialize the interface
|
21
|
-
#
|
22
|
-
def initialize(test_mode)
|
23
|
-
@status = Fb::Status.new
|
24
|
-
@test_mode = test_mode
|
25
|
-
|
26
|
-
# create the sub processing objects
|
27
|
-
@ramps_param = Fb::HardwareInterfaceParam.new
|
28
|
-
@ramps_arduino = Fb::HardwareInterfaceArduino.new(test_mode)
|
29
|
-
|
30
|
-
@ramps_arduino.ramps_param = @ramps_param
|
31
|
-
@ramps_arduino.ramps_main = self
|
32
|
-
@ramps_param.ramps_arduino = @ramps_arduino
|
33
|
-
@ramps_param.ramps_main = self
|
34
|
-
|
35
|
-
@external_info = ""
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
## INTERFACE FUNCTIONS
|
40
|
-
## *******************
|
41
|
-
|
42
|
-
## control additional I/O (servo, pins, water)
|
43
|
-
|
44
|
-
# move a servo
|
45
|
-
#
|
46
|
-
def servo_std_move(pin, value)
|
47
|
-
@ramps_arduino.execute_command("F61 P#{pin} V#{value}", false, @status_debug_msg)
|
48
|
-
end
|
49
|
-
|
50
|
-
# set standard pin value
|
51
|
-
#
|
52
|
-
def pin_std_set_value(pin, value, mode)
|
53
|
-
@ramps_arduino.execute_command("F41 P#{pin} V#{value} M#{mode}", false, @status_debug_msg)
|
54
|
-
end
|
55
|
-
|
56
|
-
# read standard pin
|
57
|
-
#
|
58
|
-
def pin_std_read_value(pin, mode, external_info)
|
59
|
-
@ramps_arduino.external_info = external_info
|
60
|
-
@ramps_arduino.execute_command("F42 P#{pin} M#{mode}", false, @status_debug_msg)
|
61
|
-
@external_info = ''
|
62
|
-
end
|
63
|
-
|
64
|
-
# set standard pin mode
|
65
|
-
#
|
66
|
-
def pin_std_set_mode(pin, mode)
|
67
|
-
@ramps_arduino.execute_command("F43 P#{pin} M#{mode}", false, @status_debug_msg)
|
68
|
-
end
|
69
|
-
|
70
|
-
# set pulse on standard pin
|
71
|
-
#
|
72
|
-
def pin_std_pulse(pin, value1, value2, time, mode)
|
73
|
-
@ramps_arduino.execute_command("F44 P#{pin} V#{value1} W#{value2} T#{time} M#{mode}", false, @status_debug_msg)
|
74
|
-
end
|
75
|
-
|
76
|
-
# dose an amount of water (in ml)
|
77
|
-
#
|
78
|
-
def dose_water(amount)
|
79
|
-
@ramps_arduino.execute_command("F01 Q#{amount.to_i}", false, @status_debug_msg)
|
80
|
-
end
|
81
|
-
|
82
|
-
## arduino status
|
83
|
-
|
84
|
-
# read end stop status from the device
|
85
|
-
#
|
86
|
-
def read_end_stops()
|
87
|
-
@ramps_arduino.execute_command('F81', false, @status_debug_msg)
|
88
|
-
end
|
89
|
-
|
90
|
-
# read current coordinates from the device
|
91
|
-
#
|
92
|
-
def read_postition()
|
93
|
-
@ramps_arduino.execute_command('F82', false, @status_debug_msg)
|
94
|
-
end
|
95
|
-
# read current software version
|
96
|
-
#
|
97
|
-
def read_device_version()
|
98
|
-
@ramps_arduino.execute_command('F83', false, @status_debug_msg)
|
99
|
-
end
|
100
|
-
|
101
|
-
## basic movements
|
102
|
-
|
103
|
-
# move all axis home
|
104
|
-
#
|
105
|
-
def move_home_all
|
106
|
-
status.info_target_x = 0
|
107
|
-
status.info_target_y = 0
|
108
|
-
status.info_target_z = 0
|
109
|
-
@ramps_arduino.execute_command('G28', true, false)
|
110
|
-
end
|
111
|
-
|
112
|
-
# move the bot to the home position
|
113
|
-
#
|
114
|
-
def move_home_x
|
115
|
-
status.info_target_x = 0
|
116
|
-
@ramps_arduino.execute_command('F11', true, false)
|
117
|
-
end
|
118
|
-
|
119
|
-
# move the bot to the home position
|
120
|
-
#
|
121
|
-
def move_home_y
|
122
|
-
status.info_target_y = 0
|
123
|
-
@ramps_arduino.execute_command('F12', true, false)
|
124
|
-
end
|
125
|
-
|
126
|
-
# move the bot to the home position
|
127
|
-
#
|
128
|
-
def move_home_z
|
129
|
-
status.info_target_z = 0
|
130
|
-
@ramps_arduino.execute_command('F13', true, false)
|
131
|
-
end
|
132
|
-
|
133
|
-
# calibrate x axis
|
134
|
-
#
|
135
|
-
def calibrate_x
|
136
|
-
status.info_target_x = 0
|
137
|
-
@ramps_arduino.execute_command('F14', true, false)
|
138
|
-
end
|
139
|
-
|
140
|
-
# calibrate y axis
|
141
|
-
#
|
142
|
-
def calibrate_y
|
143
|
-
status.info_target_y = 0
|
144
|
-
@ramps_arduino.execute_command('F15', true, false)
|
145
|
-
end
|
146
|
-
|
147
|
-
# calibrate z axis
|
148
|
-
#
|
149
|
-
def calibrate_z
|
150
|
-
status.info_target_z = 0
|
151
|
-
@ramps_arduino.execute_command('F16', true, false)
|
152
|
-
end
|
153
|
-
|
154
|
-
# move the bot to the give coordinates
|
155
|
-
#
|
156
|
-
def move_absolute( coord_x, coord_y, coord_z)
|
157
|
-
|
158
|
-
status.info_target_x = coord_x
|
159
|
-
status.info_target_y = coord_y
|
160
|
-
status.info_target_z = coord_z
|
161
|
-
|
162
|
-
# calculate the number of steps for the motors to do
|
163
|
-
|
164
|
-
steps_x = coord_x * @ramps_param.axis_x_steps_per_unit
|
165
|
-
steps_y = coord_y * @ramps_param.axis_y_steps_per_unit
|
166
|
-
steps_z = coord_z * @ramps_param.axis_z_steps_per_unit
|
167
|
-
|
168
|
-
move_to_coord(steps_x, steps_y, steps_z )
|
169
|
-
|
170
|
-
end
|
171
|
-
|
172
|
-
# move the bot a number of units starting from the current position
|
173
|
-
#
|
174
|
-
def move_relative( amount_x, amount_y, amount_z)
|
175
|
-
|
176
|
-
# calculate the number of steps for the motors to do
|
177
|
-
|
178
|
-
status.info_target_x = status.info_current_x + amount_x
|
179
|
-
status.info_target_y = status.info_current_y + amount_y
|
180
|
-
status.info_target_z = status.info_current_z + amount_z
|
181
|
-
|
182
|
-
steps_x = amount_x * @ramps_param.axis_x_steps_per_unit + status.info_current_x_steps
|
183
|
-
steps_y = amount_y * @ramps_param.axis_y_steps_per_unit + status.info_current_y_steps
|
184
|
-
steps_z = amount_z * @ramps_param.axis_z_steps_per_unit + status.info_current_z_steps
|
185
|
-
|
186
|
-
move_to_coord( steps_x, steps_y, steps_z )
|
187
|
-
|
188
|
-
end
|
189
|
-
|
190
|
-
# drive the motors so the bot is moved a number of steps
|
191
|
-
#
|
192
|
-
def move_steps(steps_x, steps_y, steps_z)
|
193
|
-
@ramps_arduino.execute_command("G01 X#{steps_x.to_i} Y#{steps_y.to_i} Z#{steps_z.to_i}", true, false)
|
194
|
-
end
|
195
|
-
|
196
|
-
# drive the motors so the bot is moved to a set location
|
197
|
-
#
|
198
|
-
def move_to_coord(steps_x, steps_y, steps_z)
|
199
|
-
@ramps_arduino.execute_command("G00 X#{steps_x.to_i} Y#{steps_y.to_i} Z#{steps_z.to_i}", true, false)
|
200
|
-
end
|
201
|
-
|
202
|
-
## parameter hanlding
|
203
|
-
|
204
|
-
def check_parameters
|
205
|
-
@ramps_param.check_parameters()
|
206
|
-
end
|
207
|
-
|
208
|
-
end
|
209
|
-
|
210
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module Fb
|
2
|
-
class HardwareInterfaceArduinoWriteStatus
|
3
|
-
|
4
|
-
attr_accessor :done, :code, :received, :start, :log, :onscreen, :text,
|
5
|
-
:params, :timeout
|
6
|
-
|
7
|
-
def initialize
|
8
|
-
@done = 0
|
9
|
-
@code = ''
|
10
|
-
@received = ''
|
11
|
-
@text = ''
|
12
|
-
@params = ''
|
13
|
-
@log = false
|
14
|
-
@onscreen = false
|
15
|
-
@start = Time.now
|
16
|
-
@timeout = 5
|
17
|
-
end
|
18
|
-
|
19
|
-
def is_busy
|
20
|
-
Time.now - @start < @timeout and @done == 0
|
21
|
-
end
|
22
|
-
|
23
|
-
def split_received
|
24
|
-
# get the parameter and data part
|
25
|
-
@code = received[0..2].upcase
|
26
|
-
@params = received[3..-1].to_s.upcase.strip
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
@@ -1,218 +0,0 @@
|
|
1
|
-
## HARDWARE INTERFACE
|
2
|
-
## ******************
|
3
|
-
|
4
|
-
# Communicate with the arduino using a serial interface
|
5
|
-
# All information is exchanged using a variation of g-code
|
6
|
-
# Parameters are stored in the database
|
7
|
-
module Fb
|
8
|
-
class HardwareInterfaceParam
|
9
|
-
|
10
|
-
attr_accessor :params, :param_version_db, :param_version_ar, :params_in_sync,
|
11
|
-
:axis_x_steps_per_unit, :axis_y_steps_per_unit, :axis_z_steps_per_unit,
|
12
|
-
:ramps_arduino, :ramps_main
|
13
|
-
|
14
|
-
|
15
|
-
# initialize the interface
|
16
|
-
#
|
17
|
-
def initialize
|
18
|
-
@params = []
|
19
|
-
@external_info = ""
|
20
|
-
@param_version_db = 0
|
21
|
-
@param_version_ar = 0
|
22
|
-
@params_in_sync = false
|
23
|
-
|
24
|
-
@axis_x_steps_per_unit = 1
|
25
|
-
@axis_y_steps_per_unit = 1
|
26
|
-
@axis_z_steps_per_unit = 1
|
27
|
-
|
28
|
-
load_param_names()
|
29
|
-
|
30
|
-
|
31
|
-
load_param_values_non_arduino()
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
## DATABASE AND SETTINGS HANDLING
|
36
|
-
## ******************************
|
37
|
-
|
38
|
-
# load non-arduino parameters
|
39
|
-
#
|
40
|
-
def load_param_values_non_arduino
|
41
|
-
|
42
|
-
p = get_param_by_name('MOVEMENT_STEPS_PER_UNIT_X')
|
43
|
-
@axis_x_steps_per_unit = p['value_db']
|
44
|
-
|
45
|
-
p = get_param_by_name('MOVEMENT_STEPS_PER_UNIT_Y')
|
46
|
-
@axis_y_steps_per_unit = p['value_db']
|
47
|
-
|
48
|
-
p = get_param_by_name('MOVEMENT_STEPS_PER_UNIT_Z')
|
49
|
-
@axis_z_steps_per_unit = p['value_db']
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
# load the id's of the arduino parameters
|
54
|
-
#
|
55
|
-
def load_param_names
|
56
|
-
$arduino_default_params.each do |p|
|
57
|
-
param_name_add(p[:name], p[:id], p[:value])
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
# add a parameter to the param list
|
62
|
-
#
|
63
|
-
def param_name_add(name, id, default)
|
64
|
-
found = false
|
65
|
-
@params.each do |p|
|
66
|
-
if p['name'] == name
|
67
|
-
found = true
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
if found == false
|
72
|
-
param = Hash.new
|
73
|
-
param['name'] = name
|
74
|
-
param['id'] = id
|
75
|
-
param['value_db'] = 0
|
76
|
-
param['value_ar'] = 0
|
77
|
-
param['default'] = default
|
78
|
-
@params << param
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
# get the parameter object by name
|
83
|
-
#
|
84
|
-
def get_param_by_name(name)
|
85
|
-
param = nil
|
86
|
-
@params.each do |p|
|
87
|
-
if p['name'] == name
|
88
|
-
param = p
|
89
|
-
end
|
90
|
-
end
|
91
|
-
return param
|
92
|
-
end
|
93
|
-
|
94
|
-
# get the parameter object by id
|
95
|
-
#
|
96
|
-
def get_param_by_id(id)
|
97
|
-
param = nil
|
98
|
-
@params.each do |p|
|
99
|
-
if p['id'] == id
|
100
|
-
param = p
|
101
|
-
end
|
102
|
-
end
|
103
|
-
return param
|
104
|
-
end
|
105
|
-
|
106
|
-
# get parameter object by name or id
|
107
|
-
#
|
108
|
-
def get_param(name_or_id, by_name_or_id)
|
109
|
-
param = nil
|
110
|
-
@params.each do |p|
|
111
|
-
if (by_name_or_id == :by_id and p['id'] == name_or_id)
|
112
|
-
param = p
|
113
|
-
end
|
114
|
-
if (by_name_or_id == :by_name and p['name'] == name_or_id)
|
115
|
-
param = p
|
116
|
-
end
|
117
|
-
end
|
118
|
-
return param
|
119
|
-
end
|
120
|
-
|
121
|
-
# save parameter value to the database
|
122
|
-
#
|
123
|
-
def save_param_value(name_or_id, by_name_or_id, from_device_or_db, value)
|
124
|
-
|
125
|
-
param = get_param(name_or_id, by_name_or_id)
|
126
|
-
|
127
|
-
if param != nil and from_device_or_db == :from_device
|
128
|
-
param['value_ar'] = value
|
129
|
-
end
|
130
|
-
if param != nil and from_device_or_db == :from_db
|
131
|
-
param['value_db'] = value
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
# check to see of parameters in arduino are up to date
|
136
|
-
#
|
137
|
-
def check_parameters
|
138
|
-
update_param_version_ar()
|
139
|
-
compare_and_write_parameters()
|
140
|
-
end
|
141
|
-
|
142
|
-
def update_param_version_ar
|
143
|
-
# read the parameter version in the database and in the device
|
144
|
-
read_parameter_from_device(0)
|
145
|
-
|
146
|
-
params.each do |p|
|
147
|
-
if p['id'] == 0
|
148
|
-
@param_version_ar = p['value_ar']
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
def compare_and_write_parameters
|
154
|
-
# if the parameters in the device is different from the database parameter version
|
155
|
-
# read and compare each parameter and write to device is different
|
156
|
-
|
157
|
-
if @param_version_db != @param_version_ar
|
158
|
-
|
159
|
-
load_param_values_non_arduino()
|
160
|
-
|
161
|
-
if !parameters_different()
|
162
|
-
@params_in_sync = true
|
163
|
-
write_parameter_to_device(0, @param_version_db)
|
164
|
-
else
|
165
|
-
@params_in_sync = false
|
166
|
-
end
|
167
|
-
else
|
168
|
-
@params_in_sync = true
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
def parameters_different
|
173
|
-
differences_found_total = false
|
174
|
-
params.each do |p|
|
175
|
-
if p['id'] != 0
|
176
|
-
difference = check_and_write_parameter(p)
|
177
|
-
if difference then
|
178
|
-
@params_in_sync = false
|
179
|
-
differences_found_total = true
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|
183
|
-
differences_found_total
|
184
|
-
end
|
185
|
-
|
186
|
-
# synchronise a parameter value
|
187
|
-
#
|
188
|
-
def check_and_write_parameter(param)
|
189
|
-
|
190
|
-
# read value from device and database
|
191
|
-
read_parameter_from_device(param['id'])
|
192
|
-
|
193
|
-
differences_found = false
|
194
|
-
|
195
|
-
# if the parameter value between device and database is different, write value to device
|
196
|
-
if param['value_db'] != param ['value_ar']
|
197
|
-
differences_found = true
|
198
|
-
write_parameter_to_device(param['id'],param['value_db'])
|
199
|
-
end
|
200
|
-
|
201
|
-
return differences_found
|
202
|
-
|
203
|
-
end
|
204
|
-
|
205
|
-
# read a parameter from arduino
|
206
|
-
#
|
207
|
-
def read_parameter_from_device(id)
|
208
|
-
@ramps_arduino.execute_command("F21 P#{id}", false, false)
|
209
|
-
end
|
210
|
-
|
211
|
-
# write a parameter value to arduino
|
212
|
-
#
|
213
|
-
def write_parameter_to_device(id, value)
|
214
|
-
@ramps_arduino.execute_command("F22 P#{id} V#{value}", false, false)
|
215
|
-
end
|
216
|
-
|
217
|
-
end
|
218
|
-
end
|