commit 85d353287c190642eeb42a23c07f59792fe55a34 Author: Peter Tillemans Date: Sun Oct 8 12:14:38 2023 +0200 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e35d885 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +_build diff --git a/bin/dune b/bin/dune new file mode 100644 index 0000000..5356984 --- /dev/null +++ b/bin/dune @@ -0,0 +1,4 @@ +(executable + (public_name oblub) + (name main) + (libraries base oblub)) diff --git a/bin/main.ml b/bin/main.ml new file mode 100644 index 0000000..7bf6048 --- /dev/null +++ b/bin/main.ml @@ -0,0 +1 @@ +let () = print_endline "Hello, World!" diff --git a/dune-project b/dune-project new file mode 100644 index 0000000..b3b5658 --- /dev/null +++ b/dune-project @@ -0,0 +1,26 @@ +(lang dune 3.11) + +(name oblub) + +(generate_opam_files true) + +(source + (github username/reponame)) + +(authors "Author Name") + +(maintainers "Maintainer Name") + +(license LICENSE) + +(documentation https://url/to/documentation) + +(package + (name oblub) + (synopsis "A short synopsis") + (description "A longer description") + (depends ocaml dune) + (tags + (topics "to describe" your project))) + +; See the complete stanza docs at https://dune.readthedocs.io/en/stable/dune-files.html#dune-project diff --git a/lib/Ds1820.ml b/lib/Ds1820.ml new file mode 100644 index 0000000..8ef432b --- /dev/null +++ b/lib/Ds1820.ml @@ -0,0 +1,19 @@ +open! Base + +let parse s = + Stdlib.Scanf.sscanf s "%s@ t=%f" (fun _ t -> t /. 1000.) + +let%test_unit "parse temperature" = + [%test_eq: float ] (parse "brol\nmore junk text t=18241") 18.241 + + +let read_temperature file_name = + let open Lwt.Infix in + let rec aux () = + Lwt_io.with_file ~mode:Lwt_io.Input file_name (fun ic -> + Lwt_io.read_all ic >>= function + | None -> aux () + | Some s -> Lwt.return (parse s) + ) + in + aux diff --git a/lib/dune b/lib/dune new file mode 100644 index 0000000..2ab082f --- /dev/null +++ b/lib/dune @@ -0,0 +1,5 @@ +(library + (name oblub) + (inline_tests) + (libraries lwt lwt.unix) + (preprocess (pps ppx_inline_test ppx_assert ppx_expect))) diff --git a/oblub.opam b/oblub.opam new file mode 100644 index 0000000..7b13bb9 --- /dev/null +++ b/oblub.opam @@ -0,0 +1,31 @@ +# This file is generated by dune, edit dune-project instead +opam-version: "2.0" +synopsis: "A short synopsis" +description: "A longer description" +maintainer: ["Maintainer Name"] +authors: ["Author Name"] +license: "LICENSE" +tags: ["topics" "to describe" "your" "project"] +homepage: "https://github.com/username/reponame" +doc: "https://url/to/documentation" +bug-reports: "https://github.com/username/reponame/issues" +depends: [ + "ocaml" + "dune" {>= "3.11"} + "odoc" {with-doc} +] +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] +dev-repo: "git+https://github.com/username/reponame.git" diff --git a/test/dune b/test/dune new file mode 100644 index 0000000..e5dffc4 --- /dev/null +++ b/test/dune @@ -0,0 +1,2 @@ +(test + (name oblub)) diff --git a/test/oblub.ml b/test/oblub.ml new file mode 100644 index 0000000..e69de29