Skip to content

Commit

Permalink
Merge pull request #1514 from FarmBot/staging
Browse files Browse the repository at this point in the history
v15.4.7
  • Loading branch information
gabrielburnworth authored May 9, 2024
2 parents abd8dbe + ee18737 commit eade856
Show file tree
Hide file tree
Showing 31 changed files with 7,017 additions and 6,642 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ version: 2.0
defaults: &defaults
working_directory: /nerves/build
docker:
- image: ghcr.io/nerves-project/nerves_system_br:1.24.1
- image: ghcr.io/nerves-project/nerves_system_br:1.23.2

install_elixir: &install_elixir
run:
name: Install Elixir
command: |
wget https://repo.hex.pm/builds/elixir/v1.15.4-otp-26.zip
unzip -d /usr/local/elixir v1.15.4-otp-26.zip
wget https://repo.hex.pm/builds/elixir/v1.16.2-otp-26.zip
unzip -d /usr/local/elixir v1.16.2-otp-26.zip
echo 'export PATH=/usr/local/elixir/bin:$PATH' >> $BASH_ENV
install_hex_archives: &install_hex_archives
Expand Down
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
erlang 26.0.2
elixir 1.15.4-otp-26
erlang 26.2.5
elixir 1.16.2-otp-26
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

# 15.4.7

* Firmware update to fix calibration deadzone settings.
* Add optional arguments to `take_photo` and `take_photo_raw` lua helpers.
* Add point group `planted_at`/`created_at` conditional.
* Add `utc` and `local_time` lua helpers.
* Dependency updates.

# 15.4.6

* Dependency updates (includes `RingLogger.viewer`).
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing

**NOTE:** These instructions are for **software developers only.** If you just want to run FarmBot OS on a FarmBot kit you have purchased, please [see these instructions instead](https://software.farm.bot/v14/FarmBot-OS/farmbot-os.html).
**NOTE:** These instructions are for **software developers only.** If you just want to run FarmBot OS on a FarmBot kit you have purchased, please [see these instructions instead](https://software.farm.bot/docs/farmbot-os).

1. Install the [ASDF Package Manager](https://asdf-vm.com/)
2. Install Elixir and Erlang via ASDF. The correct version can be found in the [.tool-versions file](https://github.com/FarmBot/farmbot_os/blob/staging/.tool-versions).
Expand Down
2 changes: 1 addition & 1 deletion ELIXIR_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
~> 1.15.4
~> 1.16.2
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Old versions of FarmBot OS can be found [here](https://github.com/FarmBot/farmbo

## Installing FBOS on a Device

[END USERS: See the official documentation](https://software.farm.bot/v14/FarmBot-OS/farmbot-os.html)
[END USERS: See the official documentation](https://software.farm.bot/docs/farmbot-os)

## Problems?

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
15.4.6
15.4.7
10 changes: 8 additions & 2 deletions lib/core/asset/criteria_retriever.ex
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ defmodule FarmbotOS.Asset.CriteriaRetriever do
String.starts_with?(k, meta)
end)
|> Enum.map(fn {k, value} ->
clean_key = String.slice(k, meta_len..-1)
clean_key = String.slice(k, meta_len..-1//1)
{clean_key, value}
end)
|> Enum.reduce(%{}, fn {key, value}, all ->
Expand Down Expand Up @@ -152,7 +152,13 @@ defmodule FarmbotOS.Asset.CriteriaRetriever do
">"
end

{pg, accum ++ [{"created_at", inverted_op, time}]}
field =
"CASE
WHEN pointer_type = 'Plant' THEN planted_at
ELSE created_at
END"

{pg, accum ++ [{field, inverted_op, time}]}
end
end

Expand Down
1 change: 1 addition & 0 deletions lib/os/configurator/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ defmodule FarmbotOS.Configurator.Router do
require FarmbotTelemetry

import Phoenix.HTML
use PhoenixHTMLHelpers
use Plug.Router
use Plug.Debugger, otp_app: :farmbot
alias FarmbotOS.Configurator.ConfigDataLayer
Expand Down
4 changes: 3 additions & 1 deletion lib/os/lua.ex
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ defmodule FarmbotOS.Lua do
soil_height: &DataManipulation.soil_height/2,
sort: &DataManipulation.sort/2,
take_photo_raw: &DataManipulation.take_photo_raw/2,
take_photo: execute_script("take-photo"),
take_photo: &DataManipulation.take_photo/2,
toggle_pin: &Firmware.toggle_pin/2,
uart: [
{:open, &FarmbotOS.Firmware.LuaUART.open/2},
Expand All @@ -178,6 +178,8 @@ defmodule FarmbotOS.Lua do
update_device: &DataManipulation.update_device/2,
update_fbos_config: &DataManipulation.update_fbos_config/2,
update_firmware_config: &DataManipulation.update_firmware_config/2,
utc: &Info.utc/2,
local_time: &Info.local_time/2,
verify_tool: &DataManipulation.verify_tool/2,
wait_ms: &Wait.wait/2,
wait: &DataManipulation.wait/2,
Expand Down
82 changes: 70 additions & 12 deletions lib/os/lua/data_manipulation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -219,21 +219,79 @@ defmodule FarmbotOS.Lua.DataManipulation do
{[Util.map_to_table(result)], lua}
end

def take_photo([], lua), do: take_photo_p(lua, %{})

def take_photo([args], lua) do
{:ok, json_args_string} = JSON.encode(Util.lua_to_elixir(args))

env = %{
take_photo_args: json_args_string
}

take_photo_p(lua, env)
end

def take_photo([width, height], lua) do
env = %{
take_photo_width: width,
take_photo_height: height
}

take_photo_p(lua, env)
end

def take_photo([width, height, args], lua) do
{:ok, json_args_string} = JSON.encode(Util.lua_to_elixir(args))

env = %{
take_photo_width: width,
take_photo_height: height,
take_photo_args: json_args_string
}

take_photo_p(lua, env)
end

defp take_photo_p(lua, env) do
env = Map.new(env, fn {k, v} -> {to_string(k), to_string(v)} end)

case FarmbotOS.SysCalls.Farmware.execute_script("take-photo", env) do
{:error, reason} -> {[reason], lua}
:ok -> {[], lua}
other -> {[inspect(other)], lua}
end
end

def take_photo_raw([], lua), do: take_photo_raw_p(lua, 800, 800, [])

def take_photo_raw([args], lua),
do: take_photo_raw_p(lua, 800, 800, Util.lua_to_elixir(args))

def take_photo_raw([width, height], lua),
do: take_photo_raw_p(lua, width, height, [])

def take_photo_raw([width, height, args], lua),
do: take_photo_raw_p(lua, width, height, Util.lua_to_elixir(args))

# Output is jpg encoded string.
# Optionally emits an error.
def take_photo_raw(_, lua) do
defp take_photo_raw_p(lua, width, height, args) do
{data, resp} =
System.cmd("fswebcam", [
"-r",
"800x800",
"-S",
"10",
"--no-banner",
"--log",
"/dev/null",
"--save",
"-"
])
System.cmd(
"fswebcam",
args ++
[
"-r",
"#{width}x#{height}",
"-S",
"10",
"--no-banner",
"--log",
"/dev/null",
"--save",
"-"
]
)

case resp do
0 ->
Expand Down
26 changes: 26 additions & 0 deletions lib/os/lua/info.ex
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,32 @@ defmodule FarmbotOS.Lua.Info do
{[v, nil], lua}
end

def utc(["year"], lua), do: {[utc_p().year], lua}
def utc(["month"], lua), do: {[utc_p().month], lua}
def utc(["day"], lua), do: {[utc_p().day], lua}
def utc(["hour"], lua), do: {[utc_p().hour], lua}
def utc(["minute"], lua), do: {[utc_p().minute], lua}
def utc(["second"], lua), do: {[utc_p().second], lua}
def utc(_, lua), do: {[DateTime.to_iso8601(utc_p())], lua}

def local_time(["year"], lua), do: {[local_time_p().year], lua}
def local_time(["month"], lua), do: {[local_time_p().month], lua}
def local_time(["day"], lua), do: {[local_time_p().day], lua}
def local_time(["hour"], lua), do: {[local_time_p().hour], lua}
def local_time(["minute"], lua), do: {[local_time_p().minute], lua}
def local_time(["second"], lua), do: {[local_time_p().second], lua}
def local_time(_, lua), do: {[DateTime.to_iso8601(local_time_p())], lua}

defp utc_p() do
DateTime.utc_now()
end

defp local_time_p() do
tz = FarmbotOS.Asset.device().timezone
datetime = utc_p()
Timex.Timezone.convert(datetime, tz)
end

@doc "Returns the current month"
def current_month(_args, lua) do
{[DateTime.utc_now().month], lua}
Expand Down
19 changes: 10 additions & 9 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ defmodule FarmbotOS.MixProject do
{:busybox, "~> 0.1", targets: @all_targets},
{:certifi, "~> 2.12"},
{:circuits_gpio, "~> 1.1", targets: @all_targets},
{:circuits_i2c, "~> 1.2", targets: @all_targets},
{:circuits_i2c, "~> 2.0", targets: @all_targets},
{:circuits_uart, "~> 1.5"},
{:cors_plug, "~> 3.0", targets: @all_targets},
{:dns, "~> 2.4"},
{:ecto_sqlite3, "~> 0.12"},
{:ecto_sqlite3, "~> 0.15"},
{:ecto, "~> 3.11"},
{:ex_doc, "~> 0.30", only: [:dev], targets: [:host], runtime: false},
{:ex_doc, "~> 0.32", only: [:dev], targets: [:host], runtime: false},
{:excoveralls, "~> 0.18", only: [:test], targets: [:host]},
{:farmbot_system_rpi,
github: "FarmBot/farmbot_system_rpi",
Expand All @@ -124,27 +124,28 @@ defmodule FarmbotOS.MixProject do
{:extty, "~> 0.3"},
{:hackney, "~> 1.20"},
{:jason, "~> 1.4"},
{:luerl, "~> 1.0"},
{:luerl, "~> 1.2"},
{:mdns_lite, "~> 0.8", targets: @all_targets},
{:mimic, "~> 1.7", only: :test},
{:mix_unused, "~> 0.4", only: :dev},
{:muontrap, "~> 1.3"},
{:muontrap, "~> 1.5"},
{:nerves_runtime, "~> 0.13", targets: @all_targets},
{:nerves_time, "~> 0.4", targets: @all_targets},
{:nerves, "~> 1.10", runtime: false},
{:phoenix_html, "~> 3.3"},
{:plug_cowboy, "~> 2.6"},
{:phoenix_html, "~> 4.1"},
{:phoenix_html_helpers, "~> 1.0"},
{:plug_cowboy, "~> 2.7"},
{:ring_logger, "~> 0.11"},
{:rollbax, "~> 0.11"},
{:shoehorn, "~> 0.8"},
{:telemetry, "~> 1.2"},
{:tesla, "~> 1.8"},
{:tesla, "~> 1.9"},
{:timex, "~> 3.7"},
{:toolshed, "~> 0.3", targets: @all_targets},
{:tortoise311, "~> 0.11"},
{:uuid, "~> 1.1"},
{:vintage_net_ethernet, "~> 0.11", targets: @all_targets},
{:vintage_net_wifi, "~> 0.11", targets: @all_targets},
{:vintage_net_wifi, "~> 0.12", targets: @all_targets},
{:vintage_net, "~> 0.13", targets: @all_targets}
]
end
Expand Down
Loading

0 comments on commit eade856

Please sign in to comment.