Orbital - build and flash Gleam projects to devices running

Hello! I’ve started playing around with Gleam and AtomVM and I’m having so much fun! I made a little tool called orbital to help build and flash Gleam projects to embedded devices, though I might share it here for folks who want to give that a try :slight_smile:

A video showcasing the 'orbital' workflow: The command 'gleam run -m orbital flash esp32 --port /dev/tty.usbserial001' is ran in a terminal window. After a short while the message 'Done' is displayed and the command 'screen' is ran to show that the code was flashed and is running on an esp device

Thank you for the awesome project! May I ask you what library did you use for the GPIO access in the video? Or is it just a set of wrappers over external Erlang functions?

Yeah it is a little set of wrappers I defined in my Gleam project:

pub type Value {
  High
  Low
}

pub type Mode {
  Output
  Input
}

@external(erlang, "pin_ffi", "set")
pub fn set(pin: Int, to value: Value) -> Result(Nil, Nil)

@external(erlang, "pin_ffi", "mode")
pub fn mode(pin: Int, mode: Mode) -> Result(Nil, Nil)
% inside src/pin_ffi.gleam
-module(pin_ffi).
-export([ set/2, mode/2]).

set(Pin, Value) ->
    % This is using the functions from atomvm's
    % gpio module
    case gpio:digital_write(Pin, Value) of
        ok -> {ok, nil};
        _ -> {error, nil}
    end.

mode(Pin, Mode) ->
    case gpio:set_pin_mode(Pin, Mode) of
        ok -> {ok, nil};
        _ -> {error, nil}
    end.

Thanks, that helped a lot!