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