Closed munizart closed 11 months ago
I'm having a hard time writing a program that fades in and out a led, this is what i'm trying:
module Blink open(Prelude, Io, Time) let boardLed = 11 let tState = Time:state() let ledState = ref (0u16, high()) fun loop() = ( fadeLed(boardLed, tState, ledState) ) fun folder(_ : uint32, lastState: (uint16 * pinState)) = ( case (lastState) of | (0, low()) => (1, high()) | (x, low()) => (x - 1, low()) | (100, high()) => (99, low()) | (x, high()) => (x + 1, high()) end ) fun fadeLed(boardLed, tState, ledState) = ( let timeSignal = Time:every(10, tState); let fader = Signal:foldP(folder, ledState, timeSignal); let pinSignal = Signal:map(fst, fader); Io:anaOut(boardLed, pinSignal) ) fun setup() = Io:setPinMode(boardLed, Io:output())
However, i'm getting this message when i try to uptade the cpp to a arduino uno using platformIO:
> Executing task in folder Juniper: pio run --target upload < Processing uno (platform: atmelavr; board: uno; framework: arduino) ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Verbose mode can be enabled via `-v, --verbose` option CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/uno.html PLATFORM: Atmel AVR (3.0.0) > Arduino Uno HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 31.50KB Flash DEBUG: Current (avr-stub) On-board (avr-stub, simavr) PACKAGES: - framework-arduino-avr 5.1.0 - tool-avrdude 1.60300.200527 (6.3.0) - toolchain-atmelavr 1.50400.190710 (5.4.0) LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf LDF Modes: Finder ~ chain, Compatibility ~ soft Found 5 compatible libraries Scanning dependencies... No dependencies Building in release mode Compiling .pio/build/uno/src/main.cpp.o src/main.cpp: In instantiation of 'Result juniper::concrete_function<Func, Result, Args>::operator()(Args ...) [with Func = Prelude::tuple2<long int, Io::pinState> (*)(long unsigned int, Prelude::tuple2<unsigned int, Io::pinState>); Result = Prelude::tuple2<unsigned int, Io::pinState>; Args = {long unsigned int, Prelude::tuple2<unsigned int, Io::pinState>}]': src/main.cpp:4504:1: required from here src/main.cpp:130:29: error: could not convert '((juniper::concrete_function<Prelude::tuple2<long int, Io::pinState> (*)(long unsigned int, Prelude::tuple2<unsigned int, Io::pinState>), Prelude::tuple2<unsigned int, Io::pinState>, long unsigned int, Prelude::tuple2<unsigned int, Io::pinState> >*)this)->juniper::concrete_function<Prelude::tuple2<long int, Io::pinState> (*)(long unsigned int, Prelude::tuple2<unsigned int, Io::pinState>), Prelude::tuple2<unsigned int, Io::pinState>, long unsigned int, Prelude::tuple2<unsigned int, Io::pinState> >::f(args#0, args#1)' from 'Prelude::tuple2<long int, Io::pinState>' to 'Prelude::tuple2<unsigned int, Io::pinState>' return f(args...); ^ *** [.pio/build/uno/src/main.cpp.o] Error 1 ================================================================================================= [FAILED] Took 0.56 seconds ================================================================================================= The terminal process "pio 'run', '--target', 'upload'" terminated with exit code: 1.
It there something i'm doing wrong?
I somehow missed this issue. Could you try again with the latest version of Juniper? The implementation of lambdas and functions have been dramatically been reworked in the latest version.
I'm having a hard time writing a program that fades in and out a led, this is what i'm trying:
However, i'm getting this message when i try to uptade the cpp to a arduino uno using platformIO:
It there something i'm doing wrong?