@@ -97,32 +97,29 @@ defmodule FarmbotOS.Lua do
9797
9898 def builtins ( ) do
9999 % {
100- base64: [
101- { :decode , & DataManipulation . b64_decode / 2 } ,
102- { :encode , & DataManipulation . b64_encode / 2 }
103- ] ,
104- json: [
105- { :decode , & DataManipulation . json_decode / 2 } ,
106- { :encode , & DataManipulation . json_encode / 2 }
107- ] ,
108- uart: [
109- { :open , & FarmbotOS.Firmware.LuaUART . open / 2 } ,
110- { :list , & FarmbotOS.Firmware.LuaUART . list / 2 }
111- ] ,
112100 # This flag can be compared agaist the last e-stop timestamp
113101 # to abort script execution (if E-Stop was called at any
114102 # point during Lua execution).
115103 __LUA_START_TIME: FarmbotOS.Time . system_time_ms ( ) ,
104+ __SERVER_PATH:
105+ FarmbotOS.Config . get_config_value ( :string , "authorization" , "server" ) ,
116106 auth_token: & Info . auth_token / 2 ,
107+ api: & DataManipulation . api / 2 ,
108+ base64: [
109+ { :decode , & DataManipulation . b64_decode / 2 } ,
110+ { :encode , & DataManipulation . b64_encode / 2 }
111+ ] ,
112+ calibrate_camera: execute_script ( "camera-calibration" ) ,
117113 check_position: & Firmware . check_position / 2 ,
118114 coordinate: & Firmware . coordinate / 2 ,
115+ cs_eval: & FarmbotOS.Celery . execute_from_lua / 2 ,
119116 current_hour: & Info . current_hour / 2 ,
120117 current_minute: & Info . current_minute / 2 ,
121118 current_month: & Info . current_month / 2 ,
122119 current_second: & Info . current_second / 2 ,
120+ detect_weeds: execute_script ( "plant-detection" ) ,
123121 emergency_lock: & Firmware . emergency_lock / 2 ,
124122 emergency_unlock: & Firmware . emergency_unlock / 2 ,
125- soft_stop: & Firmware . soft_stop / 2 ,
126123 env: & DataManipulation . env / 2 ,
127124 fbos_version: & Info . fbos_version / 2 ,
128125 find_axis_length: & Firmware . calibrate / 2 ,
@@ -132,45 +129,38 @@ defmodule FarmbotOS.Lua do
132129 get_device: & DataManipulation . get_device / 2 ,
133130 get_fbos_config: & DataManipulation . get_fbos_config / 2 ,
134131 get_firmware_config: & DataManipulation . get_firmware_config / 2 ,
132+ get_job_progress: & Info . get_job_progress / 2 ,
135133 get_position: & Firmware . get_position / 2 ,
136134 go_to_home: & Firmware . go_to_home / 2 ,
137135 http: & DataManipulation . http / 2 ,
138136 inspect: & DataManipulation . json_encode / 2 ,
137+ json: [
138+ { :decode , & DataManipulation . json_decode / 2 } ,
139+ { :encode , & DataManipulation . json_encode / 2 }
140+ ] ,
141+ measure_soil_height: execute_script ( "Measure Soil Height" ) ,
139142 move_absolute: & Firmware . move_absolute / 2 ,
140143 new_sensor_reading: & DataManipulation . new_sensor_reading / 2 ,
141144 photo_grid: & DataManipulation . photo_grid / 2 ,
142145 read_pin: & Firmware . read_pin / 2 ,
143146 read_status: & Info . read_status / 2 ,
144147 send_message: & Info . send_message / 2 ,
148+ set_job_progress: & Info . set_job_progress / 2 ,
145149 set_pin_io_mode: & Firmware . set_pin_io_mode / 2 ,
150+ soft_stop: & Firmware . soft_stop / 2 ,
146151 soil_height: & DataManipulation . soil_height / 2 ,
147152 take_photo_raw: & DataManipulation . take_photo_raw / 2 ,
148153 take_photo: execute_script ( "take-photo" ) ,
149- calibrate_camera: execute_script ( "camera-calibration" ) ,
150- detect_weeds: execute_script ( "plant-detection" ) ,
151- measure_soil_height: execute_script ( "Measure Soil Height" ) ,
154+ uart: [
155+ { :open , & FarmbotOS.Firmware.LuaUART . open / 2 } ,
156+ { :list , & FarmbotOS.Firmware.LuaUART . list / 2 }
157+ ] ,
152158 update_device: & DataManipulation . update_device / 2 ,
153159 update_fbos_config: & DataManipulation . update_fbos_config / 2 ,
154160 update_firmware_config: & DataManipulation . update_firmware_config / 2 ,
155161 wait: & Wait . wait / 2 ,
156162 watch_pin: & PinWatcher . new / 2 ,
157- write_pin: & Firmware . write_pin / 2 ,
158- get_job_progress: fn [ name ] , lua ->
159- job = Map . get ( FarmbotOS.BotState . fetch ( ) . jobs , name )
160- { [ job ] , lua }
161- end ,
162- set_job_progress: fn [ name , args ] , lua ->
163- map = FarmbotOS.Lua.Util . lua_to_elixir ( args )
164-
165- job = % FarmbotOS.BotState.JobProgress.Percent {
166- type: Map . get ( map , "type" ) || "unknown" ,
167- status: Map . get ( map , "status" ) || "working" ,
168- percent: Map . get ( map , "percent" ) || 0
169- }
170-
171- FarmbotOS.BotState . set_job_progress ( name , job )
172- { [ ] , lua }
173- end
163+ write_pin: & Firmware . write_pin / 2
174164 }
175165 end
176166end
0 commit comments