From c12c8baba35fd2d39067ee6639ef2c80b04553d2 Mon Sep 17 00:00:00 2001 From: "Schoenberger, Philipp" Date: Tue, 9 Apr 2019 10:24:26 +0200 Subject: [PATCH] add configurable centered owner at startup --- remote/include/config.h | 1 + remote/src/state_init.cpp | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/remote/include/config.h b/remote/include/config.h index 310b467..2843941 100644 --- a/remote/include/config.h +++ b/remote/include/config.h @@ -16,6 +16,7 @@ #define _CONFIG_H_ #include +#define REMOE_OWNER "Sina" #define DEFAULT_BIND_TIME 13 /*seconds*/ diff --git a/remote/src/state_init.cpp b/remote/src/state_init.cpp index 2530d30..7a6a380 100644 --- a/remote/src/state_init.cpp +++ b/remote/src/state_init.cpp @@ -6,7 +6,17 @@ #include "input.h" #include "eeprom.h" #include "debug.h" +#include "config.h" +#include "pins.h" #include "tx_def.h" +void centerText(char *text, int fieldWidth) +{ + int padlen = 0; + padlen = (fieldWidth - strlen(text)) / 2 ; + char line[17]; + sprintf(line, "%*s%s%*s\n", padlen, "", text, padlen, ""); + lcd.print(line); +} LCD_state_init::LCD_state_init(void) { } @@ -14,9 +24,11 @@ void LCD_state_init::enter(void) { lcd.setCursor(0,0); lcd.print(" wellcome "); lcd.setCursor(0,1); - lcd.print(" phschoen "); + centerText(REMOE_OWNER,16); + this->time_enter = millis(); } + void LCD_state_init::update(void) { uint32_t diff; @@ -48,10 +60,9 @@ void LCD_state_init::update(void) uint32_t master_id = 0; eeprom_config.get_master_id(&master_id); set_rx_tx_addr(master_id); - - } } + void LCD_state_init::leave(void) { lcd.clear();