From b21f9c85c9c613468274e3d80a03afe7e9675681 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Sat, 2 Feb 2019 16:54:24 +0100 Subject: [PATCH] pattern stuff --- Makefile | 2 +- led.c | 6 +++--- led.h | 1 + main.c | 4 ++++ pattern.c | 28 ++++++++++++++++++++++++++++ pattern.h | 8 ++++++++ 6 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 pattern.c create mode 100644 pattern.h diff --git a/Makefile b/Makefile index 22de3a2..22a804b 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ CC=msp430-gcc CFLAGS=-O3 -g0 -Wall -mmcu=msp430g2553 -std=gnu99 -I hottislib LDFLAGS=-mmcu=msp430g2553 -blinky1.elf: main.o led.o time.o PontCoopScheduler.o +blinky1.elf: main.o led.o time.o pattern.o PontCoopScheduler.o $(CC) -o $@ $(LDFLAGS) $^ PontCoopScheduler.o: hottislib/PontCoopScheduler.c hottislib/PontCoopScheduler.h diff --git a/led.c b/led.c index a31f465..eee34cb 100644 --- a/led.c +++ b/led.c @@ -179,7 +179,7 @@ void selectCol(uint8_t column, tColor color) { } } -/* + void testledExec() { static uint8_t rowNum = 0; @@ -203,7 +203,7 @@ void testledExec() { } } } -*/ + void ledExec() { @@ -223,5 +223,5 @@ void ledExec() { } void ledInit() { - schAdd(ledExec, NULL, 0, 10); + // schAdd(testledExec, NULL, 0, 500); } diff --git a/led.h b/led.h index f84b3c6..72c9a98 100644 --- a/led.h +++ b/led.h @@ -16,6 +16,7 @@ typedef enum { BLUE = 0, RED = 1, OFF = 2 } tColor; void ledInit(); +void ledExec(); void ledSetMatrix(uint8_t col, uint8_t row, tColor color); diff --git a/main.c b/main.c index e526bba..7c168ac 100644 --- a/main.c +++ b/main.c @@ -8,6 +8,7 @@ #include "PontCoopScheduler.h" #include "led.h" +#include "pattern.h" int main() { @@ -26,10 +27,13 @@ int main() { schInit(); ledInit(); + // patternInit(); + ledSetMatrix(3, 1, BLUE); __enable_interrupt(); while (1) { schExec(); + ledExec(); } } diff --git a/pattern.c b/pattern.c new file mode 100644 index 0000000..fd25349 --- /dev/null +++ b/pattern.c @@ -0,0 +1,28 @@ +#include "pattern.h" +#include "led.h" +#include "PontCoopScheduler.h" +#include + + + +void patternExec() { + static uint8_t i = 0; + static uint8_t j = 0; + + ledSetMatrix(i, j, BLUE); + + i++; + if (i > 3) { + i = 0; + j++; + if (j > 3) { + j = 0; + } + } + ledSetMatrix(i, j, RED); +} + + +void patternInit() { + schAdd(patternExec, NULL, 0, 1000); +} \ No newline at end of file diff --git a/pattern.h b/pattern.h new file mode 100644 index 0000000..1d2bff0 --- /dev/null +++ b/pattern.h @@ -0,0 +1,8 @@ +#ifndef PATTERN_H_ +#define PATTERN_H_ + +void patternExec(); +void patternInit(); + + +#endif /* PATTERN_H_ */