diff --git a/arduino/sample_with_makefile/Arduino.mk b/arduino/sample_with_makefile/Arduino.mk new file mode 100644 index 0000000000000000000000000000000000000000..f5c32eb60515a0ece4289cfca1b278a2692ba407 --- /dev/null +++ b/arduino/sample_with_makefile/Arduino.mk @@ -0,0 +1,171 @@ + +#------------------------------------------------- +# +# Basic Makefile to get rid of arduino's GUI (and .ino files) +# +# How it works: +# - the user gives a list of .c/.cc /.cpp +# CALLED USR_SRCS +# - generate (once) a "core.a" lib containong all the necessary +# code from arduino (comprizing the generic "main") +# - compile our own code +# - link all together to get a "elf" +# - objcopy the "elf" to a "hex" file +# - upload the hex + + +what: + @echo "Make what ???? (compile,upload,clean)" + +#------------------------------------------------- +# compilation +#------------------------------------------------- +# avr-xxx bin tools are installed in standard places (/usr/bin) +CC=avr-gcc +CPP=avr-g++ +AR=avr-ar +OBJ_COPY=avr-objcopy +LOADER=avrdude + + +# dev files are installed in /usr/share, and must be explicitely refered +ARDUINO_TOP=/usr/share/arduino +INCLS=\ + -I$(ARDUINO_TOP)/hardware/arduino/cores/arduino \ + -I$(ARDUINO_TOP)/hardware/arduino/variants/mega + +MCU=atmega2560 +F_CPU=16000000 + +# C flags are used both to compile arduino and user code +GENERAL_FLAGS=\ + -c -g -Os -Wall -ffunction-sections -fdata-sections \ + -mmcu=$(MCU) -DF_CPU=$(F_CPU)L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 +CPP_FLAGS = $(GENERAL_FLAGS) -fno-exceptions +CC_FLAGS = $(GENERAL_FLAGS) + +# Everything generated goes there +OBJDIR=./objs + +# User code, must be defined: +# USR_TARGET = name for the bin +# USR_SRCS = list of .c,.cc,.cpp ONLY + +define compile_c_rule +USR_OBJS+=$(addprefix $(OBJDIR)/, $(notdir $(basename $(1)))).o +$(addprefix $(OBJDIR)/, $(notdir $(basename $(1)))).o: $(1) + $(CC) $(CC_FLAGS) $(USR_CFLAGS) $(INCLS) $(USR_INCLS) $$< -o $$@ +endef + +define compile_cpp_rule +USR_OBJS+=$(addprefix $(OBJDIR)/, $(notdir $(basename $(1)))).o +$(addprefix $(OBJDIR)/, $(notdir $(basename $(1)))).o: $(1) + $(CPP) $(CPP_FLAGS) $(USR_CPP_FLAGS) $(INCLS) $(USR_INCLS) $$< -o $$@ +endef + +USR_C=$(filter %.c, $(USR_SRCS)) +USR_CPP=$(filter %.cc, $(USR_SRCS)) +USR_CPP+=$(filter %.cpp, $(USR_SRCS)) + +$(foreach src,$(USR_C),$(eval $(call compile_c_rule, $(src)))) + +$(foreach src,$(USR_CPP),$(eval $(call compile_cpp_rule, $(src)))) + +#all: $(OBJDIR) $(OBJS) +compile: $(OBJDIR) $(OBJDIR)/$(TARGET).hex + +# link my code and the core.a +$(OBJDIR)/$(TARGET).elf: $(OBJDIR)/core.a $(USR_OBJS) + $(CC) -Os -Wl,--gc-sections,--relax -mmcu=$(MCU) -o $@ \ + $(USR_OBJS) $(OBJDIR)/core.a -L$(OBJDIR) -lm + +# elf -> eep + hex +$(OBJDIR)/$(TARGET).hex: $(OBJDIR)/$(TARGET).elf + $(OBJ_COPY) -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load \ + --no-change-warnings --change-section-lma .eeprom=0 $< $(OBJDIR)/$(TARGET).eep + $(OBJ_COPY) -O ihex -R .eeprom $< $@ + +# upload +upload: $(OBJDIR)/$(TARGET).hex + $(LOADER) -C$(ARDUINO_TOP)/hardware/tools/avrdude.conf -v -patmega2560 \ + -cwiring -P/dev/ttyACM0 -b115200 -D -Uflash:w:$(OBJDIR)/$(TARGET).hex:i + +#/usr/share/arduino/hardware/tools/avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf -v -v -v -v -patmega2560 -cwiring -P/dev/ttyACM0 -b115200 -D -Uflash:w:/tmp/build1928257561581363585.tmp/led_arduino_puzzle_loop.cpp.hex:i + +$(OBJDIR): + mkdir -p $@ + +$(OBJDIR)/%.o: %.cpp + $(CPP) $(CPP_FLAGS) $(INCLS) $*.cpp -o $@ + +# +# These are all the .o files for core.a +# + +CORE_OBJS=\ + $(OBJDIR)/malloc.o \ + $(OBJDIR)/realloc.o \ + $(OBJDIR)/WInterrupts.o \ + $(OBJDIR)/wiring.o \ + $(OBJDIR)/wiring_digital.o \ + $(OBJDIR)/wiring_analog.o \ + $(OBJDIR)/wiring_pulse.o \ + $(OBJDIR)/wiring_shift.o \ + $(OBJDIR)/CDC.o \ + $(OBJDIR)/HardwareSerial.o \ + $(OBJDIR)/HID.o \ + $(OBJDIR)/IPAddress.o \ + $(OBJDIR)/main.o \ + $(OBJDIR)/new.o \ + $(OBJDIR)/Print.o \ + $(OBJDIR)/Stream.o \ + $(OBJDIR)/Tone.o \ + $(OBJDIR)/USBCore.o \ + $(OBJDIR)/WMath.o \ + $(OBJDIR)/WString.o \ + +COREDIR=$(ARDUINO_TOP)/hardware/arduino/cores/arduino + +# Sources are either .c or .cpp, in COREDIR or COREDIR/avr-libc, +# let gmake find the right one, according to these 2 generic rules: + +$(OBJDIR)/%.o: $(COREDIR)/avr-libc/%.c + $(CC) $(CC_FLAGS) $(INCLS) $< -o $@ + +$(OBJDIR)/%.o: $(COREDIR)/%.c + $(CC) $(CC_FLAGS) $(INCLS) $< -o $@ + +$(OBJDIR)/%.o: $(COREDIR)/%.cpp + $(CPP) $(CPP_FLAGS) $(INCLS) $< -o $@ + +# build the library + +$(OBJDIR)/core.a: $(CORE_OBJS) + $(AR) rcs $@ $(CORE_OBJS) + +# minimal arduino code to link +# +#cores/arduino/avr-libc/malloc.c +#cores/arduino/avr-libc/realloc.c +#cores/arduino/WInterrupts.c +#cores/arduino/wiring.c +#cores/arduino/wiring_digital.c +#cores/arduino/wiring_analog.c +#cores/arduino/wiring_pulse.c +#cores/arduino/wiring_shift.c +#cores/arduino/CDC.cpp +#cores/arduino/HardwareSerial.cpp +#cores/arduino/HID.cpp +#cores/arduino/IPAddress.cpp +#cores/arduino/main.cpp +#cores/arduino/new.cpp +#cores/arduino/Print.cpp +#cores/arduino/Stream.cpp +#cores/arduino/Tone.cpp +#cores/arduino/USBCore.cpp +#cores/arduino/WMath.cpp +#cores/arduino/WString.cpp + + +clean: + /bin/rm -rf $(OBJDIR)/* diff --git a/arduino/sample_with_makefile/Makefile b/arduino/sample_with_makefile/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..b62da57be1e0d8ddeabdd36921185182042260a9 --- /dev/null +++ b/arduino/sample_with_makefile/Makefile @@ -0,0 +1,29 @@ + +#---------------------------------------------- +# user makefile to use with Arduino.mk +# +#---------------------------------------------- + +# Name of the final binary +TARGET=led + +# usr sources: +# - bundle of c/cpp files +# can be anywhere +# - warning: extensions must be .c or .cc/.cpp (c++) +USR_SRCS=my_code/led_function.cpp led_loop.cpp + +# Thinks that can be customized +USR_CPP_FLAGS= +USR_CC_FLAGS= +USR_INCLS=-I./my_code + +# target can be: +# compile +# upload +# clean +all: compile + +# Generic makfile +include Arduino.mk + diff --git a/arduino/sample_with_makefile/README b/arduino/sample_with_makefile/README new file mode 100644 index 0000000000000000000000000000000000000000..a2c8009ffbacf310a25f52cd38fb474f5fcc0665 --- /dev/null +++ b/arduino/sample_with_makefile/README @@ -0,0 +1,4 @@ +Compile a bundle of user c code, lonk and upload on arduino, +WHITOUT the GUI (gmake command-line based) +See Makefile/Arduino.mk + diff --git a/arduino/sample_with_makefile/led_loop.cpp b/arduino/sample_with_makefile/led_loop.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0c9682c353182cc1f67562b120893a36c46e18b3 --- /dev/null +++ b/arduino/sample_with_makefile/led_loop.cpp @@ -0,0 +1,56 @@ + +#include <Arduino.h> +#include "led_function.h" + +led_arduino_puzzle_ctx_type* ctx = led_arduino_puzzle_ctx_new_ctx(); + +byte PIN_led1 = 13; +byte PIN_led2 = 12; +byte PIN_led3 = 11; +byte PIN_led4 = 10; +byte PIN_led5 = 9; + +byte PIN_red = 4; +byte PIN_blue = 3; + +void setup() { + pinMode(PIN_led1, OUTPUT); + pinMode(PIN_led2, OUTPUT); + pinMode(PIN_led3, OUTPUT); + pinMode(PIN_led4, OUTPUT); + pinMode(PIN_led5, OUTPUT); + + pinMode(PIN_red, INPUT); + pinMode(PIN_blue, INPUT); + + led_arduino_puzzle_ctx_reset(ctx); + + Serial.begin(9600); +} + +void loop() { + _boolean led1; + _boolean led2; + _boolean led3; + _boolean led4; + _boolean led5; + _boolean red; + _boolean blue; + +// read the pushbutton input pin: + red = digitalRead(PIN_red); + blue = digitalRead(PIN_blue); + + // Do a step + led_arduino_puzzle_step(red,blue,&led1,&led2,&led3,&led4,&led5,ctx); + + digitalWrite(PIN_led1, led1); + digitalWrite(PIN_led2, led2); + digitalWrite(PIN_led3, led3); + digitalWrite(PIN_led4, led4); + digitalWrite(PIN_led5, led5); + + delay(50); // wait a little +} + + diff --git a/arduino/sample_with_makefile/my_code/led_function.cpp b/arduino/sample_with_makefile/my_code/led_function.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cb781ddf85dfc38f45f58627fd4a6a68a0bfac6b --- /dev/null +++ b/arduino/sample_with_makefile/my_code/led_function.cpp @@ -0,0 +1,211 @@ +/* This file was generated by lv6 version master.737 (2727a7744111c84f7984634d2bd3ad6f7c6c7ff9). */ +/* lv6 -2c led.lus -n arduino_puzzle */ +/* on estrop the 02/05/2018 at 11:14:43 */ +#include "led_function.h" +//// Defining step functions +// Memory initialisation for Lustre_arrow_ctx +void Lustre_arrow_ctx_reset(Lustre_arrow_ctx_type* ctx){ + //int _i; + ctx->_memory = _true; +} +// Memory allocation for Lustre_arrow_ctx +Lustre_arrow_ctx_type* Lustre_arrow_ctx_new_ctx(){ + + Lustre_arrow_ctx_type* ctx = (Lustre_arrow_ctx_type*)calloc(1, sizeof(Lustre_arrow_ctx_type)); + // ctx->client_data = cdata; + Lustre_arrow_ctx_reset(ctx); + return ctx; +} +// Step function(s) for Lustre_arrow_ctx +void Lustre_arrow_step(_boolean i1,_boolean i2,_boolean *out,Lustre_arrow_ctx_type* ctx){ *out = ((ctx->_memory)? i1 : i2); + ctx->_memory = _false; + +} // End of Lustre_arrow_step + +// Memory initialisation for Lustre_pre_ctx +void Lustre_pre_ctx_reset(Lustre_pre_ctx_type* ctx){ + //int _i; + +} +// Memory allocation for Lustre_pre_ctx +Lustre_pre_ctx_type* Lustre_pre_ctx_new_ctx(){ + + Lustre_pre_ctx_type* ctx = (Lustre_pre_ctx_type*)calloc(1, sizeof(Lustre_pre_ctx_type)); + // ctx->client_data = cdata; + Lustre_pre_ctx_reset(ctx); + return ctx; +} +// Step function(s) for Lustre_pre_ctx +void Lustre_pre_get(_boolean *out,Lustre_pre_ctx_type* ctx){ + *out = ctx->_memory; + +} // End of Lustre_pre_get + +void Lustre_pre_set(_boolean i1,Lustre_pre_ctx_type* ctx){ + ctx->_memory = i1; + +} // End of Lustre_pre_set + +// Memory initialisation for led_arduino_puzzle_ctx +void led_arduino_puzzle_ctx_reset(led_arduino_puzzle_ctx_type* ctx){ + //int _i; + + led_puzzle1_ctx_reset(&ctx->led_puzzle1_ctx_tab[0]); + led_fedge_ctx_reset(&ctx->led_fedge_ctx_tab[0]); + led_fedge_ctx_reset(&ctx->led_fedge_ctx_tab[1]); +} +// Memory allocation for led_arduino_puzzle_ctx +led_arduino_puzzle_ctx_type* led_arduino_puzzle_ctx_new_ctx(){ + + led_arduino_puzzle_ctx_type* ctx = (led_arduino_puzzle_ctx_type*)calloc(1, sizeof(led_arduino_puzzle_ctx_type)); + // ctx->client_data = cdata; + led_arduino_puzzle_ctx_reset(ctx); + return ctx; +} +// Step function(s) for led_arduino_puzzle_ctx +void led_arduino_puzzle_step(_boolean red,_boolean blue,_boolean *led1,_boolean *led2,_boolean *led3,_boolean *led4,_boolean *led5,led_arduino_puzzle_ctx_type* ctx){ _boolean _split_2; + _boolean _split_1; + + led_fedge_step(blue,&_split_2,&ctx->led_fedge_ctx_tab[0]); + led_fedge_step(red,&_split_1,&ctx->led_fedge_ctx_tab[1]); + led_puzzle1_step(_split_1,_split_2,led1,led2,led3,led4,led5,&ctx->led_puzzle1_ctx_tab[0]); + +} // End of led_arduino_puzzle_step + +// Memory initialisation for led_fedge_ctx +void led_fedge_ctx_reset(led_fedge_ctx_type* ctx){ + //int _i; + + Lustre_pre_ctx_reset(&ctx->Lustre_pre_ctx_tab[0]); + Lustre_arrow_ctx_reset(&ctx->Lustre_arrow_ctx_tab[0]); +} +// Memory allocation for led_fedge_ctx +led_fedge_ctx_type* led_fedge_ctx_new_ctx(){ + + led_fedge_ctx_type* ctx = (led_fedge_ctx_type*)calloc(1, sizeof(led_fedge_ctx_type)); + // ctx->client_data = cdata; + led_fedge_ctx_reset(ctx); + return ctx; +} +// Step function(s) for led_fedge_ctx +void led_fedge_step(_boolean s,_boolean *res,led_fedge_ctx_type* ctx){ _boolean _split_5; + _boolean _split_4; + _boolean _split_3; + + Lustre_pre_get(&_split_3,&ctx->Lustre_pre_ctx_tab[0]); + _split_4 = ! s; + _split_5 = _split_3 & _split_4; + Lustre_pre_set(s,&ctx->Lustre_pre_ctx_tab[0]); + Lustre_arrow_step(_false,_split_5,res,&ctx->Lustre_arrow_ctx_tab[0]); + +} // End of led_fedge_step + +// Memory initialisation for led_puzzle1_ctx +void led_puzzle1_ctx_reset(led_puzzle1_ctx_type* ctx){ + int _i; + for (_i=0 ; _i<12 ; _i+=1){ + Lustre_pre_ctx_reset(&ctx->Lustre_pre_ctx_tab[_i]); + } for (_i=0 ; _i<5 ; _i+=1){ + Lustre_arrow_ctx_reset(&ctx->Lustre_arrow_ctx_tab[_i]); + } +} +// Memory allocation for led_puzzle1_ctx +led_puzzle1_ctx_type* led_puzzle1_ctx_new_ctx(){ + + led_puzzle1_ctx_type* ctx = (led_puzzle1_ctx_type*)calloc(1, sizeof(led_puzzle1_ctx_type)); + // ctx->client_data = cdata; + led_puzzle1_ctx_reset(ctx); + return ctx; +} +// Step function(s) for led_puzzle1_ctx +void led_puzzle1_step(_boolean red,_boolean blue,_boolean *led1,_boolean *led2,_boolean *led3,_boolean *led4,_boolean *led5,led_puzzle1_ctx_type* ctx){ _boolean _split_26; + _boolean _split_25; + _boolean _split_24; + _boolean _split_23; + _boolean _split_22; + _boolean _split_21; + _boolean _split_20; + _boolean _split_19; + _boolean _split_18; + _boolean _split_17; + _boolean _split_16; + _boolean _split_15; + _boolean _split_14; + _boolean _split_13; + _boolean _split_12; + _boolean _split_11; + _boolean _split_10; + _boolean _split_9; + _boolean _split_8; + _boolean _split_7; + _boolean _split_6; + + Lustre_pre_get(&_split_6,&ctx->Lustre_pre_ctx_tab[1]); + Lustre_pre_get(&_split_7,&ctx->Lustre_pre_ctx_tab[0]); + if (blue == _true) { + _split_8 = _split_6; + } else { + _split_8 = _split_7; + } + Lustre_arrow_step(_false,_split_8,led1,&ctx->Lustre_arrow_ctx_tab[0]); + Lustre_pre_set(*led1,&ctx->Lustre_pre_ctx_tab[0]); + Lustre_pre_get(&_split_24,&ctx->Lustre_pre_ctx_tab[11]); + Lustre_pre_get(&_split_25,&ctx->Lustre_pre_ctx_tab[10]); + if (blue == _true) { + _split_26 = _split_24; + } else { + _split_26 = _split_25; + } + Lustre_arrow_step(_false,_split_26,led5,&ctx->Lustre_arrow_ctx_tab[4]); + Lustre_pre_set(*led5,&ctx->Lustre_pre_ctx_tab[1]); + Lustre_pre_get(&_split_9,&ctx->Lustre_pre_ctx_tab[4]); + Lustre_pre_get(&_split_12,&ctx->Lustre_pre_ctx_tab[2]); + Lustre_pre_get(&_split_10,&ctx->Lustre_pre_ctx_tab[3]); + _split_11 = ! _split_10; + if (red == _true) { + _split_13 = _split_11; + } else { + _split_13 = _split_12; + } + if (blue == _true) { + _split_14 = _split_9; + } else { + _split_14 = _split_13; + } + Lustre_arrow_step(_true,_split_14,led2,&ctx->Lustre_arrow_ctx_tab[1]); + Lustre_pre_set(*led2,&ctx->Lustre_pre_ctx_tab[2]); + Lustre_pre_set(*led2,&ctx->Lustre_pre_ctx_tab[3]); + Lustre_pre_set(*led1,&ctx->Lustre_pre_ctx_tab[4]); + Lustre_pre_get(&_split_15,&ctx->Lustre_pre_ctx_tab[6]); + Lustre_pre_get(&_split_16,&ctx->Lustre_pre_ctx_tab[5]); + if (blue == _true) { + _split_17 = _split_15; + } else { + _split_17 = _split_16; + } + Lustre_arrow_step(_false,_split_17,led3,&ctx->Lustre_arrow_ctx_tab[2]); + Lustre_pre_set(*led3,&ctx->Lustre_pre_ctx_tab[5]); + Lustre_pre_set(*led2,&ctx->Lustre_pre_ctx_tab[6]); + Lustre_pre_get(&_split_18,&ctx->Lustre_pre_ctx_tab[9]); + Lustre_pre_get(&_split_21,&ctx->Lustre_pre_ctx_tab[7]); + Lustre_pre_get(&_split_19,&ctx->Lustre_pre_ctx_tab[8]); + _split_20 = ! _split_19; + if (red == _true) { + _split_22 = _split_20; + } else { + _split_22 = _split_21; + } + if (blue == _true) { + _split_23 = _split_18; + } else { + _split_23 = _split_22; + } + Lustre_arrow_step(_false,_split_23,led4,&ctx->Lustre_arrow_ctx_tab[3]); + Lustre_pre_set(*led4,&ctx->Lustre_pre_ctx_tab[7]); + Lustre_pre_set(*led4,&ctx->Lustre_pre_ctx_tab[8]); + Lustre_pre_set(*led3,&ctx->Lustre_pre_ctx_tab[9]); + Lustre_pre_set(*led5,&ctx->Lustre_pre_ctx_tab[10]); + Lustre_pre_set(*led4,&ctx->Lustre_pre_ctx_tab[11]); + +} // End of led_puzzle1_step + diff --git a/arduino/sample_with_makefile/my_code/led_function.h b/arduino/sample_with_makefile/my_code/led_function.h new file mode 100644 index 0000000000000000000000000000000000000000..6202f019eb7d008f33c1e3aec7696c7deddba32b --- /dev/null +++ b/arduino/sample_with_makefile/my_code/led_function.h @@ -0,0 +1,36 @@ +/* This file was generated by lv6 version master.737 (2727a7744111c84f7984634d2bd3ad6f7c6c7ff9). */ +/* lv6 -2c led.lus -n arduino_puzzle */ +/* on estrop the 02/05/2018 at 11:14:43 */ + +#include <stdlib.h> +#include <string.h> + +#include "lustre_types.h" +#include "lustre_consts.h" + +#ifndef _led_arduino_puzzle_H_FILE +#define _led_arduino_puzzle_H_FILE +void Lustre_arrow_ctx_reset(Lustre_arrow_ctx_type* ctx); +Lustre_arrow_ctx_type* Lustre_arrow_ctx_new_ctx(); +void Lustre_arrow_step(_boolean ,_boolean ,_boolean *,Lustre_arrow_ctx_type*); + +void Lustre_pre_ctx_reset(Lustre_pre_ctx_type* ctx); +Lustre_pre_ctx_type* Lustre_pre_ctx_new_ctx(); +void Lustre_pre_get(_boolean *,Lustre_pre_ctx_type*); + +void Lustre_pre_set(_boolean ,Lustre_pre_ctx_type*); + +void led_arduino_puzzle_ctx_reset(led_arduino_puzzle_ctx_type* ctx); +led_arduino_puzzle_ctx_type* led_arduino_puzzle_ctx_new_ctx(); +void led_arduino_puzzle_step(_boolean ,_boolean ,_boolean *,_boolean *,_boolean *,_boolean *,_boolean *,led_arduino_puzzle_ctx_type*); + +void led_fedge_ctx_reset(led_fedge_ctx_type* ctx); +led_fedge_ctx_type* led_fedge_ctx_new_ctx(); +void led_fedge_step(_boolean ,_boolean *,led_fedge_ctx_type*); + +void led_puzzle1_ctx_reset(led_puzzle1_ctx_type* ctx); +led_puzzle1_ctx_type* led_puzzle1_ctx_new_ctx(); +void led_puzzle1_step(_boolean ,_boolean ,_boolean *,_boolean *,_boolean *,_boolean *,_boolean *,led_puzzle1_ctx_type*); + +///////////////////////////////////////////////// +#endif diff --git a/arduino/sample_with_makefile/my_code/led_loop.cpp b/arduino/sample_with_makefile/my_code/led_loop.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0c9682c353182cc1f67562b120893a36c46e18b3 --- /dev/null +++ b/arduino/sample_with_makefile/my_code/led_loop.cpp @@ -0,0 +1,56 @@ + +#include <Arduino.h> +#include "led_function.h" + +led_arduino_puzzle_ctx_type* ctx = led_arduino_puzzle_ctx_new_ctx(); + +byte PIN_led1 = 13; +byte PIN_led2 = 12; +byte PIN_led3 = 11; +byte PIN_led4 = 10; +byte PIN_led5 = 9; + +byte PIN_red = 4; +byte PIN_blue = 3; + +void setup() { + pinMode(PIN_led1, OUTPUT); + pinMode(PIN_led2, OUTPUT); + pinMode(PIN_led3, OUTPUT); + pinMode(PIN_led4, OUTPUT); + pinMode(PIN_led5, OUTPUT); + + pinMode(PIN_red, INPUT); + pinMode(PIN_blue, INPUT); + + led_arduino_puzzle_ctx_reset(ctx); + + Serial.begin(9600); +} + +void loop() { + _boolean led1; + _boolean led2; + _boolean led3; + _boolean led4; + _boolean led5; + _boolean red; + _boolean blue; + +// read the pushbutton input pin: + red = digitalRead(PIN_red); + blue = digitalRead(PIN_blue); + + // Do a step + led_arduino_puzzle_step(red,blue,&led1,&led2,&led3,&led4,&led5,ctx); + + digitalWrite(PIN_led1, led1); + digitalWrite(PIN_led2, led2); + digitalWrite(PIN_led3, led3); + digitalWrite(PIN_led4, led4); + digitalWrite(PIN_led5, led5); + + delay(50); // wait a little +} + + diff --git a/arduino/sample_with_makefile/my_code/lustre_consts.h b/arduino/sample_with_makefile/my_code/lustre_consts.h new file mode 100644 index 0000000000000000000000000000000000000000..7ff691feb69948128517203f4cb987aa56544a0c --- /dev/null +++ b/arduino/sample_with_makefile/my_code/lustre_consts.h @@ -0,0 +1,12 @@ +/* This file was generated by lv6 version master.737 (2727a7744111c84f7984634d2bd3ad6f7c6c7ff9). */ +/* lv6 -2c led.lus -n arduino_puzzle */ +/* on estrop the 02/05/2018 at 11:14:43 */ + +// Constant definitions +#define led_Allume 1 +#define led_Eteint 0 +#define led_led1_00 0 +#define led_led2_00 1 +#define led_led3_00 0 +#define led_led4_00 0 +#define led_led5_00 0 diff --git a/arduino/sample_with_makefile/my_code/lustre_types.h b/arduino/sample_with_makefile/my_code/lustre_types.h new file mode 100644 index 0000000000000000000000000000000000000000..f71dc2524c62e2a58fd5cfb81d93a0e81919a36c --- /dev/null +++ b/arduino/sample_with_makefile/my_code/lustre_types.h @@ -0,0 +1,55 @@ +/* This file was generated by lv6 version master.737 (2727a7744111c84f7984634d2bd3ad6f7c6c7ff9). */ +/* lv6 -2c led.lus -n arduino_puzzle */ +/* on estrop the 02/05/2018 at 11:14:43 */ + +#ifndef _SOC2C_PREDEF_TYPES +#define _SOC2C_PREDEF_TYPES +typedef int _boolean; +typedef int _integer; +typedef char* _string; +typedef double _real; +typedef double _double; +typedef float _float; +#define _false 0 +#define _true 1 +#endif +// end of _SOC2C_PREDEF_TYPES +// User typedef +#ifndef _led_arduino_puzzle_TYPES +#define _led_arduino_puzzle_TYPES +#endif // enf of _led_arduino_puzzle_TYPES +// Memoryless soc ctx typedef +// Memoryfull soc ctx typedef +/* Lustre_pre_ctx */ +typedef struct { + /*Memory cell*/ + _boolean _memory ; +} Lustre_pre_ctx_type; + +/* Lustre_arrow_ctx */ +typedef struct { + /*Memory cell*/ + _boolean _memory ; +} Lustre_arrow_ctx_type; + +/* led_fedge_ctx */ +typedef struct { + /*INSTANCES*/ + Lustre_pre_ctx_type Lustre_pre_ctx_tab[1]; + Lustre_arrow_ctx_type Lustre_arrow_ctx_tab[1]; +} led_fedge_ctx_type; + +/* led_puzzle1_ctx */ +typedef struct { + /*INSTANCES*/ + Lustre_pre_ctx_type Lustre_pre_ctx_tab[12]; + Lustre_arrow_ctx_type Lustre_arrow_ctx_tab[5]; +} led_puzzle1_ctx_type; + +/* led_arduino_puzzle_ctx */ +typedef struct { + /*INSTANCES*/ + led_puzzle1_ctx_type led_puzzle1_ctx_tab[1]; + led_fedge_ctx_type led_fedge_ctx_tab[2]; +} led_arduino_puzzle_ctx_type; +