This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| IFILE=$1 | |
| ./printlicense.sh $IFILE > "$IFILE.new" | |
| echo "" >> "$IFILE.new" | |
| cat $IFILE >> "$IFILE.new" | |
| mv "$IFILE.new" $IFILE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| + <head> | |
| + <link rel="stylesheet" href="/milligram.min.css"> | |
| + </head> | |
| <body> | |
| + def handle_req('GET', ['milligram.min.css'], conn) do | |
| + :http_server.reply(200, :atomvm.read_priv(:morse_encoder, 'milligram.min.css'), conn) | |
| + end | |
| + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defp blink_led(nil, _l) do | |
| :ok | |
| end | |
| defp blink_led(gpio_num, l) do | |
| gpio = get_gpio() | |
| GPIO.set_direction(gpio, gpio_num, :output) | |
| Enum.each(l, fn e -> | |
| case e do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule EncoderTest do | |
| use ExUnit.Case | |
| alias MorseEncoder.Encoder | |
| test "encode hello world" do | |
| assert Encoder.morse_encode('HELLO') == '.... . .-.. .-.. --- ' | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule MorseEncoder.Encoder do | |
| def morse_encode(s) do | |
| :string.to_upper(s) | |
| |> Enum.map(&to_morse/1) | |
| |> List.flatten() | |
| end | |
| defp to_morse(c) do | |
| case c do | |
| ?\s -> ' ' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def handle_req('GET', [], conn) do | |
| body = """ | |
| <html> | |
| <body> | |
| <h1>Morse Encoder</h1> | |
| <form method=\"post\"> | |
| <p>Text: <input type=\"text\" name=\"text\"></p> | |
| <p>GPIO: <input type=\"text\" name=\"gpio\"></p> | |
| <input type=\"submit\" value=\"Submit\"> | |
| </form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def start() do | |
| connect() | |
| end | |
| def connect() do | |
| this_process = self() | |
| config = [ | |
| {:sta, | |
| [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Run "mix help deps" to learn about dependencies. | |
| defp deps do | |
| [ | |
| + {:exatomvm, github: "bettio/exatomvm", runtime: false} | |
| # {:dep_from_hexpm, "~> 0.3.0"}, | |
| # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"} | |
| ] | |
| - deps: deps() | |
| + deps: deps(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule UDPHelloWorld do | |
| @remote_ip {192, 168, 0, 2} | |
| @port 8981 | |
| # @ssid 'YourSSID' | |
| # @psk 'YourPassword' | |
| def start() do | |
| # You should connect to a network and sleep some seconds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule Blink do | |
| @led_gpio 2 | |
| def start() do | |
| gpio_driver = GPIO.open() | |
| GPIO.set_direction(gpio_driver, @led_gpio, :output) | |
| loop(gpio_driver, 0) | |
| end |