summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2014-05-29 14:07:58 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-05-31 03:57:28 +0000
commit200246949abb240788d89645c572d14f0a0a8b96 (patch)
treeb7f7490c7b87b5ba345150bd3e2a36008674930e
parentfe4f1275b2f596dd5ebc8e5594176d6128b46b04 (diff)
downloadchrome-ec-200246949abb240788d89645c572d14f0a0a8b96.tar.gz
Keyborg: provide options on data encoding/printing style
For easier developement/experiment, this adds two options: - CONFIG_ENCODE_SEGMENT/CONFIG_ENCODE_RAW SEGMENT style encoding uses less RAM, so it can store the entire frame. However, it sometimes losses data. RAW style encoding is always lossless, but it can only save a bit more than a half frame. - CONFIG_ENCODE_DUMP_PYTHON If this flag is defined, the output style is a 2-D Python list. This is used so that the data can be easily fed into another script. BUG=None TEST=Tries all four combinations. BRANCH=None Change-Id: Ic6a916f1cae20edccee5d05783ef98a1c48dff2e Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202140 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--board/keyborg/board.h5
-rw-r--r--board/keyborg/build.mk3
-rw-r--r--board/keyborg/encode_raw.c58
-rw-r--r--board/keyborg/encode_segment.c (renamed from board/keyborg/encode.c)30
4 files changed, 95 insertions, 1 deletions
diff --git a/board/keyborg/board.h b/board/keyborg/board.h
index 0acf810514..d0dadffc2d 100644
--- a/board/keyborg/board.h
+++ b/board/keyborg/board.h
@@ -27,6 +27,11 @@
#undef CONFIG_TASK_PROFILING
#undef CONFIG_WATCHDOG_HELP
+/* How the touch data is stored and printed */
+#define CONFIG_ENCODE_SEGMENT
+#undef CONFIG_ENCODE_RAW
+#undef CONFIG_ENCODE_DUMP_PYTHON
+
#ifndef __ASSEMBLER__
enum gpio_signal;
diff --git a/board/keyborg/build.mk b/board/keyborg/build.mk
index cdd1a7ff84..be53116402 100644
--- a/board/keyborg/build.mk
+++ b/board/keyborg/build.mk
@@ -10,5 +10,6 @@ CHIP_FAMILY:=stm32f
CHIP_VARIANT:=stm32ts60
board-y=board.o hardware.o runtime.o master_slave.o spi_comm.o touch_scan.o
-board-y+=encode.o
+board-$(CONFIG_ENCODE_SEGMENT)+=encode_segment.o
+board-$(CONFIG_ENCODE_RAW)+=encode_raw.o
board-$(CONFIG_DEBUG_PRINTF)+=debug.o
diff --git a/board/keyborg/encode_raw.c b/board/keyborg/encode_raw.c
new file mode 100644
index 0000000000..cf358edc96
--- /dev/null
+++ b/board/keyborg/encode_raw.c
@@ -0,0 +1,58 @@
+/* Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Raw touch data recording */
+
+#include "common.h"
+#include "debug.h"
+#include "touch_scan.h"
+#include "util.h"
+
+#define ENC_COL_COUNT 70
+static uint8_t encoded[ENC_COL_COUNT][ROW_COUNT * 2];
+static int encoded_col;
+
+void encode_reset(void)
+{
+ encoded_col = 0;
+}
+
+void encode_add_column(const uint8_t *dptr)
+{
+ if (encoded_col >= ENC_COL_COUNT)
+ return;
+ memcpy(encoded[encoded_col], dptr, ROW_COUNT * 2);
+ encoded_col++;
+}
+
+void encode_dump_matrix(void)
+{
+ int row, col;
+
+#ifdef CONFIG_ENCODE_DUMP_PYTHON
+ debug_printf("heat_map = [");
+ for (row = 0; row < ROW_COUNT * 2; ++row) {
+ debug_printf("[");
+ for (col = 0; col < encoded_col; ++col) {
+ if (encoded[col][row] < THRESHOLD)
+ debug_printf("0,");
+ else
+ debug_printf("%d,", encoded[col][row]);
+ }
+ debug_printf("],\n");
+ }
+ debug_printf("]\n");
+#else
+ for (row = 0; row < ROW_COUNT * 2; ++row) {
+ for (col = 0; col < encoded_col; ++col) {
+ if (encoded[col][row] < THRESHOLD)
+ debug_printf(" - ");
+ else
+ debug_printf("%3d ", encoded[col][row]);
+ }
+ debug_printf("\n");
+ }
+#endif
+}
diff --git a/board/keyborg/encode.c b/board/keyborg/encode_segment.c
index 266f67d3b3..49eaec64c9 100644
--- a/board/keyborg/encode.c
+++ b/board/keyborg/encode_segment.c
@@ -84,6 +84,35 @@ void encode_dump_matrix(void)
debug_printf("Encoded size = %d\n", encoded_size);
+#ifdef CONFIG_ENCODE_DUMP_PYTHON
+ debug_printf("heat_map = [");
+ dptr = encoded;
+ for (col = 0; col < COL_COUNT * 2; ++col) {
+ debug_printf("[");
+ if (dptr >= encoded + encoded_size) {
+ debug_printf("0] * %d,\n", ROW_COUNT * 2);
+ continue;
+ }
+ seg_count = *(dptr++);
+ row = 0;
+ for (seg = 0; seg < seg_count; ++seg) {
+ if (row < *dptr) {
+ debug_printf("] + [0] * %d + [", *dptr - row);
+ row = *dptr;
+ }
+ dptr++;
+ seg_end = *dptr + row;
+ dptr++;
+ for (; row < seg_end; ++row, ++dptr)
+ debug_printf("%d,", *dptr);
+ }
+ if (row < ROW_COUNT * 2)
+ debug_printf("] + [0] * %d,\n", ROW_COUNT * 2 - row);
+ else
+ debug_printf("],\n");
+ }
+ debug_printf("]\n");
+#else
dptr = encoded;
for (col = 0; col < COL_COUNT * 2; ++col) {
if (dptr >= encoded + encoded_size) {
@@ -111,4 +140,5 @@ void encode_dump_matrix(void)
}
debug_printf("\n");
}
+#endif
}