Skip to content

Commit

Permalink
Merge pull request #2 from lf-lang/v0.6.0
Browse files Browse the repository at this point in the history
Compatibility with Lingua Franca 0.6.0
  • Loading branch information
lhstrh authored Feb 5, 2024
2 parents e444525 + ce7caee commit 97fb6c1
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 55 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: 'CI'
on:
pull_request:
push:
branches:
- main

jobs:
find-latest-release:
uses: lf-lang/lingua-franca/.github/workflows/latest-release.yml@master

check-compile:
runs-on: ubuntu-latest
needs: find-latest-release
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up Java 17
run: |
echo "$JAVA_HOME_17_X64/bin" >> $GITHUB_PATH
echo "JAVA_HOME=$JAVA_HOME_17_X64" >> $GITHUB_ENV
shell: bash
- name: Install dev dependencies
run: |
sudo apt update
sudo apt install cmake make gcc gcc-arm-none-eabi libnewlib-arm-none-eabi
- uses: lf-lang/action-check-lf-files@main
with:
check_mode: "compile"
no_compile_flag: false
exclude_dirs: '["failing", "experimental"]'
checkout_dir: '../lingua-franca'
compiler_ref: ${{ needs.find-latest-release.outputs.ref }}

check-format:
runs-on: ubuntu-latest
needs: find-latest-release
steps:
- uses: actions/checkout@v4
- name: Set up Java 17
run: |
echo "$JAVA_HOME_17_X64/bin" >> $GITHUB_PATH
echo "JAVA_HOME=$JAVA_HOME_17_X64" >> $GITHUB_ENV
shell: bash
- uses: lf-lang/action-check-lf-files@main
with:
check_mode: "format"
exclude_dirs: '["failing", "experimental"]'
checkout_dir: '../lingua-franca'
compiler_ref: ${{ needs.find-latest-release.outputs.ref }}
17 changes: 9 additions & 8 deletions src/Blink.lf
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
target C {
platform: "Rp2040",
threading: false
platform: "Rp2040",
single-threaded: true
}

import Led from "./lib/Led.lf";
import Led from "./lib/Led.lf"

main reactor {
timer t1(0, 100 msec);
led = new Led();
reaction(t1) -> led.tog {=
lf_set(led.tog, true);
=}
timer t1(0, 100 msec)
led = new Led()

reaction(t1) -> led.tog {=
lf_set(led.tog, true);
=}
}
17 changes: 9 additions & 8 deletions src/HelloPico.lf
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
target C {
platform: "Rp2040",
threading: false,
timeout: 5 sec,
platform: "Rp2040",
single-threaded: true,
timeout: 5 sec
}

preamble {=
#include <stdio.h>
#include <stdio.h>
=}

main reactor {
timer t1(0, 1 sec);
reaction(t1) {=
printf("Hello World!\n");
=}
timer t1(0, 1 sec)

reaction(t1) {=
printf("Hello World!\n");
=}
}
29 changes: 15 additions & 14 deletions src/Timer.lf
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
target C {
platform: "Rp2040",
threading: false,
timeout: 10 sec,
platform: "Rp2040",
single-threaded: true,
timeout: 10 sec
}

preamble {=
#include <stdio.h>
#include "pico/stdlib.h"
#include <stdio.h>
#include "pico/stdlib.h"
=}

main reactor {
timer t1(0, 1 sec);
reaction(t1) {=
interval_t t = lf_time_logical_elapsed();
interval_t T = lf_time_physical_elapsed();
printf(
"Elapsed logical time %lld, physical time %lld, lag: %lld\n",
t, T, T-t
);
=}
timer t1(0, 1 sec)

reaction(t1) {=
interval_t t = lf_time_logical_elapsed();
interval_t T = lf_time_physical_elapsed();
printf(
"Elapsed logical time %lld, physical time %lld, lag: %lld\n",
t, T, T-t
);
=}
}
1 change: 0 additions & 1 deletion src/HelloThread.lf → src/experimental/HelloThread.lf
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
target C {
platform: "Rp2040",
threading: true,
workers: 2,
tracing: false,
}
Expand Down
47 changes: 23 additions & 24 deletions src/lib/Led.lf
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
target C {
platform: "RP2040",
threading: false,
platform: "RP2040",
single-threaded: true
}

preamble {=
#include <pico/stdlib.h>
#include <hardware/gpio.h>
#include <pico/stdlib.h>
#include <hardware/gpio.h>
=}

/**
* Led reactor that keeps track of led state.
* Can either be toggled or set using different signals
**/
* Led reactor that keeps track of led state. Can either be toggled or set using different signals
*/
reactor Led {
input tog:bool; // when is_present, will toggle the led
input set:bool; // when is_present, set the led state to the input value
state led:bool;

reaction(startup) {=
gpio_init(25);
gpio_set_dir(25, GPIO_OUT);
=}

reaction(tog) {=
self->led = !self->led;
gpio_put(25, self->led);
=}
input tog: bool // when is_present, will toggle the led
input set: bool // when is_present, set the led state to the input value
state led: bool

reaction(set) {=
self->led = set->value;
gpio_put(25, self->led);
=}
reaction(startup) {=
gpio_init(25);
gpio_set_dir(25, GPIO_OUT);
=}

reaction(tog) {=
self->led = !self->led;
gpio_put(25, self->led);
=}

reaction(set) {=
self->led = set->value;
gpio_put(25, self->led);
=}
}

0 comments on commit 97fb6c1

Please sign in to comment.