summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2015-05-31 20:46:40 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2015-05-31 20:46:40 +0200
commit570bdb95dbfb7ee3af36396569d43575ed761650 (patch)
tree30a0bce8a7041ed38d2e2a9175446e2573562390
parent8f45739d02f02c226452f7f62c4dc195e6e13b38 (diff)
downloadphone_remote_nrf51-570bdb95dbfb7ee3af36396569d43575ed761650.tar.gz
phone_remote_nrf51-570bdb95dbfb7ee3af36396569d43575ed761650.tar.bz2
phone_remote_nrf51-570bdb95dbfb7ee3af36396569d43575ed761650.tar.xz
phone_remote_nrf51-570bdb95dbfb7ee3af36396569d43575ed761650.zip
o Better LCD code, increased per command delay.
-rw-r--r--LiquidCrystal.c10
-rw-r--r--LiquidCrystal.h3
-rw-r--r--main.c56
-rw-r--r--nrf51.md4
4 files changed, 60 insertions, 13 deletions
diff --git a/LiquidCrystal.c b/LiquidCrystal.c
index eed30c8..3411ea8 100644
--- a/LiquidCrystal.c
+++ b/LiquidCrystal.c
@@ -53,7 +53,9 @@ static void write_value(uint8_t value, bool is_data, uint32_t delay) {
write_4(value >> 4);
write_4(value);
- nrf_delay_us(delay);
+ // something is going too fast. have to investigate.
+// nrf_delay_us(delay);
+ nrf_delay_ms(delay);
}
void liquid_crystal_write_char(char chr) {
@@ -66,6 +68,12 @@ void liquid_crystal_write_string(char *chr) {
}
}
+void liquid_crystal_write_string_len(char *chr, size_t max_len) {
+ for (; *chr != '\0' && max_len > 0; chr++, max_len--) {
+ liquid_crystal_write_char(*chr);
+ }
+}
+
void liquid_crystal_clear() {
// The documentation doesn't specify a value, but everything else is 37us
write_value(LIQUID_CRYSTAL_CMD_CLEAR, false, 50);
diff --git a/LiquidCrystal.h b/LiquidCrystal.h
index dd28fc9..d995504 100644
--- a/LiquidCrystal.h
+++ b/LiquidCrystal.h
@@ -7,6 +7,7 @@
#include <stdint.h>
#include <stdbool.h>
+#include <unistd.h>
void liquid_crystal_init(bool data_length, bool two_line, bool many_dots);
@@ -26,4 +27,6 @@ void liquid_crystal_write_char(char chr);
void liquid_crystal_write_string(char *chr);
+void liquid_crystal_write_string_len(char *chr, size_t max_len);
+
#endif
diff --git a/main.c b/main.c
index d79c12b..e3a8506 100644
--- a/main.c
+++ b/main.c
@@ -40,14 +40,12 @@
#include "boards.h"
#include "ble_sensorsim.h"
#include "softdevice_handler.h"
-#include "app_timer.h"
#include "device_manager.h"
#include "pstorage.h"
#include "app_error.h"
#include "app_trace.h"
#include "app_timer.h"
#include "app_gpiote.h"
-#include "app_timer.h"
#include "bsp.h"
#include "phone_remote.h"
@@ -121,6 +119,22 @@ static void hello_timer_handler(void* data)
seconds++;
printf("hello world, seconds=%" PRIu32 ", ticks=%" PRIu32 ", ms=%" PRIu32 "\r\n", seconds, ticks, ms);
+
+// liquid_crystal_clear();
+
+// char buf0[8];
+//
+ liquid_crystal_set_cursor(0, 1);
+ uint32_t value = 1337;
+ app_timer_cnt_get(&value);
+ char buf1[9];
+// snprintf(buf1, sizeof(buf1), "%" PRIu32, value);
+ int size = snprintf(buf1, sizeof(buf1), "%" PRIu32, seconds);
+// liquid_crystal_write_string("hello!");
+ liquid_crystal_write_string_len(buf1, size);
+// liquid_crystal_write_string(buf1);
+ buf1[8] = '\0';
+ printf("buf: %s\r\n", buf1);
}
static void timers_init(void)
@@ -410,18 +424,13 @@ int main(void)
uint32_t err_code = bsp_init(BSP_INIT_LED | BSP_INIT_BUTTONS, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL);
APP_ERROR_CHECK(err_code);
- device_manager_init();
- gap_params_init();
- advertising_init();
- services_init();
- conn_params_init();
-
- timers_start();
-
liquid_crystal_init(false, true, false);
liquid_crystal_reset();
+
+ /*
liquid_crystal_display(true, false, false);
liquid_crystal_write_string("01234567890123456");
+ */
/*
char chars[] = "abcdefghijklmopqrstuvwxyz";
@@ -431,14 +440,39 @@ int main(void)
}
nrf_delay_ms(1000);
-*/
liquid_crystal_clear();
+*/
+
+ liquid_crystal_display(true, false, false);
+ nrf_delay_ms(500);
+
+ liquid_crystal_display(false, false, false);
+ nrf_delay_ms(500);
+
+ liquid_crystal_display(true, false, false);
+ nrf_delay_ms(500);
+
+ liquid_crystal_display(false, false, false);
+ nrf_delay_ms(500);
+
+ liquid_crystal_display(true, true, true);
+ nrf_delay_ms(500);
// liquid_crystal_return_home();
liquid_crystal_set_cursor(1, 1);
liquid_crystal_write_string("hello!");
+ /*
+ device_manager_init();
+ gap_params_init();
+ advertising_init();
+ services_init();
+ conn_params_init();
+
advertising_start();
+ */
+
+ timers_start();
for (;; )
{
diff --git a/nrf51.md b/nrf51.md
index 0737ca0..90f19e4 100644
--- a/nrf51.md
+++ b/nrf51.md
@@ -43,7 +43,9 @@ Device | Size | Start | End | Size | Start | End
# Debugging
- screen /dev/ttyACM0 115200,-ixon,-ixoff
+When using the nRF51-DK or the dongle you'll talk to the nRF chip through the Segger chip. It will only listen for traffic when a terminal is connected to /dev/ttyACM0. The terminal must use the DTR (data terminal ready) signal for the Segger to disable the tristating of the uart pins and start listening.
+
+ screen /dev/ttyACM0 115200,ixon,ixoff
## GDB