summaryrefslogtreecommitdiff
path: root/board/keyborg/encode_raw.c
blob: cf358edc961d3c1be09cdb94efb12b21b12beb8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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
}