-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisplay.cpp
More file actions
87 lines (70 loc) · 2.12 KB
/
display.cpp
File metadata and controls
87 lines (70 loc) · 2.12 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <Arduino.h> ////
#include "sensor.h" ////
#include "display.h"
#include <string.h>
#include <cocoos.h>
#include <stdio.h>
//// #include <termios.h>
//// #include <unistd.h>
// Message buffer for display task
DisplayMsg_t displayMessages[10];
static const char *tempdata;
static uint8_t _x = 1;
static uint8_t _y = 2;
static uint8_t _z = 3;
/////
#include <stdarg.h>
static char buf[256]; // resulting string limited to 256 chars
static void serial_printf(const char fmt[], long a1 = 0, long a2 = 0, long a3 = 0, long a4 = 0, long a5 = 0) {
sprintf(buf, fmt, a1, a2, a3, a4, a5);
debug(buf);
}
#define printf serial_printf
////
static void update() {
// clear current line and move to start of line
////printf("%c" "%s" "%c", ESC, CLEAR_LINE, CR);
////printf("-----------------Sensor readings--------------------");
// move to next line and print temp data
////printf("%c" "%s" "%c" , ESC, MOVE_DOWN, CR);
////printf("%c%s%s",ESC, CLEAR_LINE, tempdata);
debug(tempdata); ////
// move to next line and print gyro data
////printf("%c" "%s" "%c" , ESC, MOVE_DOWN, CR);
////printf("%c%sGyro:\t\tx:%d\ty:%d\tz:%d",ESC, CLEAR_LINE, _x, _y, _z);
printf("Gyro:\t\tx:%ld\ty:%ld\tz:%ld", _x, _y, _z); ////
// go home
////printf("%c" "%s" "%c" , ESC, MOVE_UP(2), CR);
////fflush(stdout);
}
static void updateData(uint8_t id, const char *data) {
if (id == TEMP_DATA) {
tempdata = data;
}
else if (id == GYRO_DATA) {
_x = data[0];
_y = data[1];
_z = data[2];
}
}
static Display_t display = {
.update = &update,
.updateData = &updateData
};
Display_t *display_get(void) {
return &display;
}
void display_init(void) {
/* ////
struct termios old, new;
tcgetattr(STDIN_FILENO, &old); // get current settings
new = old; // create a backup
new.c_lflag &= ~(ICANON | ECHO); // disable line buffering and feedback
tcsetattr(STDIN_FILENO, TCSANOW, &new); // set our new config
*/ ////
////printf("\n\n\n");
////printf("\n\n\n");
////printf("\n\n\n");
////printf("%c" "%s" , ESC, MOVE_UP(7));
////printf("%c" "%s" , ESC, MOVE_DOWN);
}