Skip to content

Commit

Permalink
Simplify implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
ckormanyos committed Jan 11, 2024
1 parent 8ec39ae commit 9e1ef60
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 67 deletions.
5 changes: 3 additions & 2 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ version:

##############################################################################80
# file lists/paths
# VPATH is required for GNUmake to find the C and assembly source files
# VPATH is used by GNUmake to find the C and assembly source files.
##############################################################################80

SUFFIX_OBJ := rel
Expand All @@ -147,7 +147,7 @@ VPATH := $(sort $(dir $(FILES_PRJ)) $(PATH_OBJ))


##############################################################################80
# compile/link/hex-manip rules
# compile/link
##############################################################################80

$(PATH_BIN)/refapp.ihx : $(FILES_OBJ)
Expand Down Expand Up @@ -188,6 +188,7 @@ clean:

##############################################################################80
# pattern rules
# Delete default suffixes with .SUFFIXES. We do not use implicit rules.
##############################################################################80

.SUFFIXES:
Expand Down
31 changes: 5 additions & 26 deletions src/app/app_hello.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,20 @@

#include <app/app_lcd_util.h>

static void app_hello_hello(void);
static void app_hello_world(void);
static void app_hello_clear(void);

static bool app_hello_is_hello;


void app_hello_init(void)
{
}

void app_hello_task(void)
{
app_hello_clear();
app_lcd_util_row((uint8_t) UINT8_C(3));
app_lcd_util_col((uint8_t) UINT8_C(6));
app_lcd_util_puts(" ");
app_lcd_util_col((uint8_t) UINT8_C(6));

(!app_hello_is_hello) ? app_hello_hello() : app_hello_world();
(!app_hello_is_hello) ? app_lcd_util_puts("hello") : app_lcd_util_puts("world");

app_hello_is_hello = (bool) (!app_hello_is_hello);
}

static void app_hello_hello(void)
{
app_lcd_util_home2();
app_lcd_util_puts("hello");
}

static void app_hello_world(void)
{
app_lcd_util_home2();
app_lcd_util_puts("world");
}

static void app_hello_clear(void)
{
app_lcd_util_home2();
app_lcd_util_puts(" ");
}

18 changes: 6 additions & 12 deletions src/app/app_lcd_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,18 @@ void app_lcd_util_puts(const char* p_str)
}
}

void app_lcd_util_home1(void) ATTRIBUTE_NAKED
void app_lcd_util_row(const char row) ATTRIBUTE_NAKED
{
__asm__("ld b,#0x02\n");
__asm__("ld a,b\n");
(void) row;

__asm__("ld (#0x844B), a\n");
__asm__("ld b,#0x06\n");
__asm__("ld a,b\n");
__asm__("ld (#0x844C), a\n");
__asm__("ret\n");
}

void app_lcd_util_home2(void) ATTRIBUTE_NAKED
void app_lcd_util_col(const char col) ATTRIBUTE_NAKED
{
__asm__("ld b,#0x03\n");
__asm__("ld a,b\n");
__asm__("ld (#0x844B), a\n");
__asm__("ld b,#0x06\n");
__asm__("ld a,b\n");
(void) col;

__asm__("ld (#0x844C), a\n");
__asm__("ret\n");
}
Expand Down
7 changes: 4 additions & 3 deletions src/app/app_lcd_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@

void app_lcd_util_puts(const char* p_str);

void app_lcd_util_home1(void) ATTRIBUTE_NAKED;
void app_lcd_util_home2(void) ATTRIBUTE_NAKED;
void app_lcd_util_init (void) ATTRIBUTE_NAKED;
void app_lcd_util_row(const char row) ATTRIBUTE_NAKED;
void app_lcd_util_col(const char col) ATTRIBUTE_NAKED;

void app_lcd_util_init(void) ATTRIBUTE_NAKED;

#endif // APP_LED_UTIL_2024_01_07_H
29 changes: 5 additions & 24 deletions src/app/app_led.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@

#include <app/app_lcd_util.h>

static void app_led_on (void);
static void app_led_off(void);
static void app_led_clr(void);

static bool app_led_is_on;

void app_led_init(void)
Expand All @@ -18,27 +14,12 @@ void app_led_init(void)

void app_led_task(void)
{
app_led_clr();
app_lcd_util_row((uint8_t) UINT8_C(2));
app_lcd_util_col((uint8_t) UINT8_C(6));
app_lcd_util_puts(" ");
app_lcd_util_col((uint8_t) UINT8_C(6));

(!app_led_is_on) ? app_led_on() : app_led_off();
(!app_led_is_on) ? app_lcd_util_puts("ON ") : app_lcd_util_puts("OFF");

app_led_is_on = (bool) (!app_led_is_on);
}

static void app_led_on(void)
{
app_lcd_util_home1();
app_lcd_util_puts("ON ");
}

static void app_led_off(void)
{
app_lcd_util_home1();
app_lcd_util_puts("OFF");
}

static void app_led_clr(void)
{
app_lcd_util_home1();
app_lcd_util_puts(" ");
}

0 comments on commit 9e1ef60

Please sign in to comment.