diff --git a/lcd_c/Makefile b/lcd_c/Makefile index f20a956..73e8c4e 100644 --- a/lcd_c/Makefile +++ b/lcd_c/Makefile @@ -2,7 +2,7 @@ CC = avr-gcc OBJCOPY = avr-objcopy AVRDUDE = avrdude CFLAGS = -Os -DF_CPU=16000000UL -mmcu=atmega328p -SERIAL = /dev/cu.usbmodem141401 +SERIAL = /dev/cu.usbmodem143401 ADDR = $(shell heptc -where)/c TARGET = lcd diff --git a/lcd_hept/Makefile b/lcd_hept/Makefile index b5b61fd..7d5678e 100644 --- a/lcd_hept/Makefile +++ b/lcd_hept/Makefile @@ -2,7 +2,7 @@ CC = avr-gcc OBJCOPY = avr-objcopy AVRDUDE = avrdude CFLAGS = -Os -DF_CPU=16000000UL -mmcu=atmega328p -SERIAL = /dev/cu.usbmodem141401 +SERIAL = /dev/cu.usbmodem143401 ADDR = $(shell heptc -where)/c TARGET = prog LIB = arduinolib diff --git a/lcd_hept/arduinolib.c b/lcd_hept/arduinolib.c index 586433e..cd23d10 100644 --- a/lcd_hept/arduinolib.c +++ b/lcd_hept/arduinolib.c @@ -1,4 +1,3 @@ -//#include #include #include #include "arduinolib.h" @@ -125,29 +124,22 @@ void Arduinolib__lcd_char_step(uint8_t char_data, Arduinolib__lcd_char_out *out) } /* give a string to display to the LCD */ -void Arduinolib__lcd_string_step(uint8_t lstring[], Arduinolib__lcd_string_out *out){ - - //uint8_t lstring = atoi(message); +void Arduinolib__lcd_string_step(uint8_t lstring[], int line, Arduinolib__lcd_string_out *out){ + + Arduinolib__lcd_cmd_out *o1; + Arduinolib__lcd_cmd_out *o2; + if (line == 1) { + Arduinolib__lcd_cmd_step(LCD_CURSOR_SET | LCD_START_LINE2, o1); + _delay_us(80); //more than + } else { + Arduinolib__lcd_cmd_step(LCD_CURSOR_SET | LCD_START_LINE1, o2); + _delay_us(80); + } volatile int i = 0; for (i = 0; lstring[i] != 0 ; i++) { - Arduinolib__lcd_char_out *o1; - Arduinolib__lcd_char_step(lstring[i], o1); + Arduinolib__lcd_char_out *o3; + Arduinolib__lcd_char_step(lstring[i], o3); _delay_us(80); //more than 39us } } -/*uint8_t msg[] = "Arduino"; -uint8_t msg2[] = "Hello world"; - -int main(void) { - Arduinolib__dinit_step(); - Arduinolib__lcd_init_step(); - Arduinolib__lcd_string_step(msg); - Arduinolib__lcd_cmd_step(LCD_CURSOR_SET | LCD_START_LINE2); - _delay_us(80); // more than 39us - Arduinolib__lcd_string_step(msg2); - - while(1); - return 0; -}*/ - diff --git a/lcd_hept/arduinolib.epi b/lcd_hept/arduinolib.epi index 0c0a718..bdc6b49 100644 --- a/lcd_hept/arduinolib.epi +++ b/lcd_hept/arduinolib.epi @@ -5,4 +5,4 @@ fun lcd_init() returns () fun lcd_write(info:uint8_t) returns () fun lcd_cmd(cmd:uint8_t) returns () fun lcd_char(char_data:uint8_t) returns () -fun lcd_string (lstring:uint8_t) returns () +fun lcd_string (lstring:string; line: int) returns () diff --git a/lcd_hept/arduinolib.h b/lcd_hept/arduinolib.h index 0674500..776f589 100644 --- a/lcd_hept/arduinolib.h +++ b/lcd_hept/arduinolib.h @@ -57,11 +57,3 @@ #define LCD_CURSOR_SET 0b10000000 #define LCD_FUNCTION_SET_8bit 0b00110000 #define LCD_FUNCTION_SET_4bit 0b00101000 - -// Functions -/*void dinit(void); -void lcd_init(void); -void lcd_write(uint8_t); -void lcd_cmd(uint8_t); -void lcd_char(uint8_t); -void lcd_string(uint8_t *);*/ \ No newline at end of file diff --git a/lcd_hept/arduinolib_types.h b/lcd_hept/arduinolib_types.h index ff409a4..d8013e1 100644 --- a/lcd_hept/arduinolib_types.h +++ b/lcd_hept/arduinolib_types.h @@ -39,6 +39,6 @@ void Arduinolib__lcd_cmd_step(uint8_t cmd, Arduinolib__lcd_cmd_out *o); void Arduinolib__lcd_char_step(uint8_t char_data, Arduinolib__lcd_char_out *o); -void Arduinolib__lcd_string_step(uint8_t lstring[], Arduinolib__lcd_string_out *o); +void Arduinolib__lcd_string_step(uint8_t lstring[], int line, Arduinolib__lcd_string_out *o); #endif \ No newline at end of file diff --git a/lcd_hept/main.c b/lcd_hept/main.c index 6b0d724..fbe9577 100644 --- a/lcd_hept/main.c +++ b/lcd_hept/main.c @@ -2,7 +2,6 @@ #include #include "main.h" -//#define BLINK_DELAY_MS 4000 int main (void) { diff --git a/lcd_hept/prog.ept b/lcd_hept/prog.ept index 19088e4..bea0445 100644 --- a/lcd_hept/prog.ept +++ b/lcd_hept/prog.ept @@ -1,10 +1,26 @@ open Arduinolib -node main() returns () +node update_lcd<>() 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 diff --git a/parallel_led/arduinolib.c b/parallel_led/arduinolib.c index 2ab4aa3..97ad4ba 100644 --- a/parallel_led/arduinolib.c +++ b/parallel_led/arduinolib.c @@ -1,32 +1,25 @@ -//#include #include #include #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< #include "main.h" -//#define BLINK_DELAY_MS 4000 - int main (void) { Prog__main_mem mem; diff --git a/parallel_led/prog.ept b/parallel_led/prog.ept index 47175e7..8a5201a 100644 --- a/parallel_led/prog.ept +++ b/parallel_led/prog.ept @@ -20,5 +20,6 @@ node main() returns () let () = led<<3, 1, 13>>(); () = led<<4, 2, 9>>(); + () = led<<3, 1, 5>>(); tel