fixed parallel_led/ trying to make work the lcd_hept
parent
c6bd6f1a1a
commit
35e74807da
@ -1,10 +1,26 @@
|
|||||||
open Arduinolib
|
open Arduinolib
|
||||||
|
|
||||||
node main() returns ()
|
node update_lcd<<period, ledMax : int; msg : string; line: int >>() returns ()
|
||||||
var i : int;
|
var i : int;
|
||||||
|
ledTime : int;
|
||||||
|
upt : bool;
|
||||||
|
downt : bool;
|
||||||
|
|
||||||
|
let
|
||||||
|
i = 0 fby (i+1);
|
||||||
|
ledTime = i % period;
|
||||||
|
upt = ledTime < ledMax;
|
||||||
|
downt = not upt;
|
||||||
|
|
||||||
|
() = lcd_string((msg, line) when upt);
|
||||||
|
() = lcd_string((".", line) when downt);
|
||||||
|
tel
|
||||||
|
|
||||||
|
node main() returns ()
|
||||||
let
|
let
|
||||||
i = 0 fby (i+1);
|
() = dinit();
|
||||||
() = dinit();
|
|
||||||
() = lcd_init();
|
() = lcd_init();
|
||||||
|
() = update_lcd<<6, 4, "Hello", 0>>();
|
||||||
|
() = update_lcd<<10, 5, "Hi", 1>>();
|
||||||
tel
|
tel
|
||||||
|
|
||||||
|
@ -1,32 +1,25 @@
|
|||||||
//#include <math.h>
|
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
#include "arduinolib.h"
|
#include "arduinolib.h"
|
||||||
//#include "HardwareSerial.h"
|
|
||||||
|
|
||||||
void Arduinolib__dwrite_step(int p, int v, Arduinolib__dwrite_out *out){
|
void Arduinolib__dwrite_step(int p, int v, Arduinolib__dwrite_out *out){
|
||||||
/* set pin 5 of PORTB for output. i.e port 13 */
|
|
||||||
if (p == 13){
|
if (8 <= p && p <= 13){
|
||||||
DDRC |= _BV(DDD7);
|
int pin = p - 8;
|
||||||
if (v == 0)
|
DDRB |= (1 << pin);
|
||||||
{
|
PORTB |= (1 << pin);
|
||||||
PORTD &= ~(1<<PORTD7);
|
if (v == 0) PORTB &= ~(1 << pin);
|
||||||
//PORTB &= ~_BV(PORTB5); //put it to low
|
}
|
||||||
return;
|
else if ( 0 <= p && p <= 7){
|
||||||
}
|
DDRD |= (1 << p);
|
||||||
PORTD |= (1<<PORTD7);
|
PORTD |= (1 << p);
|
||||||
//PORTB |= _BV(PORTB5);
|
if (v == 0) PORTD &= ~(1 << p);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
DDRD |= _BV(DDD5);
|
else { //by default
|
||||||
if (v == 0)
|
DDRB |= (1 << 5);
|
||||||
{
|
PORTB |= (1 << 5);
|
||||||
PORTD &= ~(1<<PORTD5);
|
if (v == 0) PORTB &= ~(1 << 5);
|
||||||
//PORTB &= ~_BV(PORTB4); //put it to low
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
PORTD |= (1<<PORTD5);
|
|
||||||
//PORTB |= _BV(PORTB4);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue