implement the increase of a counter when pushing a button
This commit is contained in:
parent
999e627c53
commit
a83de8df52
4 changed files with 10 additions and 10 deletions
|
@ -134,7 +134,7 @@ void Arduinolib__lcd_string_step(uint8_t lstring[], int line, Arduinolib__lcd_st
|
|||
}
|
||||
|
||||
/* gice a number to display to the LCD */
|
||||
void Arduinolib__lcd_int_step(uint8_t numb, int line, Arduinolib__lcd_int_out *out){
|
||||
void Arduinolib__lcd_int_step(int numb, int line, Arduinolib__lcd_int_out *out){
|
||||
char lstring[80]; //buffer
|
||||
itoa(numb, lstring, 10);
|
||||
Arduinolib__lcd_string_out *o;
|
||||
|
|
|
@ -5,6 +5,6 @@ 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:string; line:int) returns ()
|
||||
fun lcd_int (numb:uint8_t; line:int) returns ()
|
||||
fun lcd_int (numb:int; line:int) returns ()
|
||||
fun dread(buttonpin: int) returns (v : int)
|
||||
fun dwrite(p:int; v:int) returns ()
|
|
@ -36,7 +36,7 @@ void Arduinolib__lcd_char_step(uint8_t char_data, Arduinolib__lcd_char_out *o);
|
|||
|
||||
void Arduinolib__lcd_string_step(uint8_t lstring[], int line, Arduinolib__lcd_string_out *o);
|
||||
|
||||
void Arduinolib__lcd_int_step(uint8_t numb, int line, Arduinolib__lcd_int_out *o);
|
||||
void Arduinolib__lcd_int_step(int numb, int line, Arduinolib__lcd_int_out *o);
|
||||
|
||||
void Arduinolib__dread_step(int p, Arduinolib__dread_out *out);
|
||||
|
||||
|
|
|
@ -24,16 +24,17 @@ let
|
|||
() = lcd_int(count/period, line);
|
||||
tel
|
||||
|
||||
node button (bpin, ledpin : int) returns ()
|
||||
node lcd_button_counter (bpin, period, line : int) returns ()
|
||||
var value : int;
|
||||
count : int;
|
||||
i : int;
|
||||
let
|
||||
i = 0 fby (i+1);
|
||||
value = dread(bpin);
|
||||
() = dwrite((ledpin, value));
|
||||
i = 0 fby (i+1);
|
||||
value = dread(bpin);
|
||||
count = 0 fby (count + value);
|
||||
() = lcd_int(count/period, line);
|
||||
tel
|
||||
|
||||
|
||||
node main() returns ()
|
||||
var start : bool;
|
||||
let
|
||||
|
@ -41,7 +42,6 @@ let
|
|||
() = lcd_init() when start;
|
||||
|
||||
() = lcd_blink_msg ((750, 375, "hello world!", 0) when not start);
|
||||
() = lcd_counter ((375, 1) when not start);
|
||||
() = button((8, 13) when not start);
|
||||
() = lcd_button_counter((8, 50, 1) when not start);
|
||||
tel
|
||||
|
||||
|
|
Loading…
Reference in a new issue