src/main.cpp

Tue, 27 Oct 2020 21:48:28 +0100

author
David Douard <david.douard@sdf3.org>
date
Tue, 27 Oct 2020 21:48:28 +0100
changeset 39
63c6a720cb97
parent 38
ffef9bbb345d
child 44
b3c3d54d2c7c
permissions
-rw-r--r--

hp34comm: add support for boot keycode

1
3021fc79cc3b kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff changeset
1 #include "stdio.h"
4
219766126afb another attempt using a more complete support of the protocol and async serial stuff
David Douard <david.douard@logilab.fr>
parents: 3
diff changeset
2
21
David Douard <david.douard@logilab.fr>
parents: 19
diff changeset
3 #include <mbed.h>
David Douard <david.douard@logilab.fr>
parents: 19
diff changeset
4 #include <rtos.h>
David Douard <david.douard@logilab.fr>
parents: 19
diff changeset
5 #include <string>
4
219766126afb another attempt using a more complete support of the protocol and async serial stuff
David Douard <david.douard@logilab.fr>
parents: 3
diff changeset
6
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents: 4
diff changeset
7 #include "hp34comm.h"
37
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents: 36
diff changeset
8 #include "display.h"
1
3021fc79cc3b kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff changeset
9
19
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
10 #include "QEI.h"
18
4fd621551d55 [full replacement] implement a state machine for Rx
David Douard <david.douard@logilab.fr>
parents: 17
diff changeset
11 #include "Keypad.h"
4fd621551d55 [full replacement] implement a state machine for Rx
David Douard <david.douard@logilab.fr>
parents: 17
diff changeset
12
32
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
13 // Pins and device declarations
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
14 #if defined TARGET_NUCLEO_F446RE
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
15 #include "def_f446re.h"
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
16 #elif defined TARGET_HP34970_FP_F303RD
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
17 #include "def_hp34970_fp.h"
8
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 7
diff changeset
18 #endif
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 7
diff changeset
19
32
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
20 #include "platform/CircularBuffer.h"
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 23
diff changeset
21
1
3021fc79cc3b kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff changeset
22
37
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents: 36
diff changeset
23 Display *dsp;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents: 36
diff changeset
24 volatile bool splashscreen;
19
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
25 HPSerial *hp;
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
26 Thread tdsp;
19
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
27 Ticker blinker;
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
28 Timeout rst_delay;
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
29 Timeout splashscreen_timer;
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
30 InterruptIn rst(HP_RST);
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
31
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
32 QEI qenc(KP_ENC1, KP_ENC2, NC, 16);
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
33 volatile uint8_t knob;
35
b2dca6b935bb Indent src/main.cpp with 2-ws
David Douard <david.douard@sdf3.org>
parents: 34
diff changeset
34 bool shift; // true when kp is shifted, cleared by command 0x01 from Unit
19
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
35
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
36 typedef enum {
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
37 KEY_NONE=0,
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
38 KEY_PRESSED,
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
39 KEY_RELEASED
19
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
40 } key_event_t;
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
41
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
42 typedef struct keycode {
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
43 uint8_t row;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
44 uint8_t col;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
45 key_event_t keyevent;
19
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
46 } keycode_t;
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
47
32
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
48 //volatile keycode_t cur_keycode;
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
49
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
50 #define KEY_BUF_SIZE 10
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
51 CircularBuffer<keycode_t, KEY_BUF_SIZE> key_buf;
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents: 4
diff changeset
52
34
94ab7ff42a1b Add a key mapping table (protocol value vs. raw keycode) and send it
David Douard <david.douard@sdf3.org>
parents: 32
diff changeset
53 #define KP_NROWS 4
94ab7ff42a1b Add a key mapping table (protocol value vs. raw keycode) and send it
David Douard <david.douard@sdf3.org>
parents: 32
diff changeset
54 #define KP_NCOLS 5
94ab7ff42a1b Add a key mapping table (protocol value vs. raw keycode) and send it
David Douard <david.douard@sdf3.org>
parents: 32
diff changeset
55 DigitalIn kp_rows[KP_NROWS] = {
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
56 KP_R0,
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
57 KP_R1,
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
58 KP_R2,
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
59 KP_R3
19
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
60 };
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
61
34
94ab7ff42a1b Add a key mapping table (protocol value vs. raw keycode) and send it
David Douard <david.douard@sdf3.org>
parents: 32
diff changeset
62 DigitalOut kp_columns[KP_NCOLS] = {
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
63 KP_C0, KP_C1,
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
64 KP_C2, KP_C3,
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
65 KP_C4
19
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
66 };
18
4fd621551d55 [full replacement] implement a state machine for Rx
David Douard <david.douard@logilab.fr>
parents: 17
diff changeset
67
36
a6c7292742a0 Add support for the shift flag
David Douard <david.douard@sdf3.org>
parents: 35
diff changeset
68 /* key mapping
a6c7292742a0 Add support for the shift flag
David Douard <david.douard@sdf3.org>
parents: 35
diff changeset
69 RxC code name
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
70 0x2 0x00 View
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
71 0x1 0x01 Mon
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
72 3x3 0x02 Sto/Rcl
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
73 0x0 0x03 Scan
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
74 1x2 0x04 Alarm
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
75 1x1 0x05 Mx+B
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
76 1x0 0x06 Measure
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
77 2x0 0x07 Interval
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
78 3x2 0x08 Card Reset
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
79 3x1 0x09 Close
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
80 3x0 0x0A Open
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
81 0x3 0x0B Read
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
82 2x3 0x0C Shift
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
83 1x3 0x0D Write
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
84 0x4 0x0E Left
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
85 1x4 0x0F Right
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
86 2x2 0x10 Advanced
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
87 2x1 0x11 Step
34
94ab7ff42a1b Add a key mapping table (protocol value vs. raw keycode) and send it
David Douard <david.douard@sdf3.org>
parents: 32
diff changeset
88 */
94ab7ff42a1b Add a key mapping table (protocol value vs. raw keycode) and send it
David Douard <david.douard@sdf3.org>
parents: 32
diff changeset
89
36
a6c7292742a0 Add support for the shift flag
David Douard <david.douard@sdf3.org>
parents: 35
diff changeset
90 uint8_t kp_mapping[KP_NROWS][KP_NCOLS] = {
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
91 {0x03, 0x01, 0x00, 0x0B, 0x0E},
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
92 {0x06, 0x05, 0x04, 0x0D, 0x0F},
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
93 {0x07, 0x11, 0x10, 0x0C, 0xFF},
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
94 {0x0A, 0x09, 0x08, 0x02, 0xFF}
19
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
95 };
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
96
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
97 void kp_cb(uint8_t row, uint8_t col);
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
98 void kr_cb(uint8_t row, uint8_t col);
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
99
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
100 Keypad *kpad;
1
3021fc79cc3b kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff changeset
101 uint8_t curchar;
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 23
diff changeset
102 //uint8_t curcmd;
1
3021fc79cc3b kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff changeset
103 uint8_t nchars;
3021fc79cc3b kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff changeset
104 char buffer[MAX_BUFF+1];
3021fc79cc3b kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff changeset
105
37
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents: 36
diff changeset
106 void refresh_display(void);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents: 36
diff changeset
107
8
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 7
diff changeset
108 void timeout_h() {
32
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
109 #if defined(HAS_LED)
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
110 led = !led;
32
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
111 #endif
8
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 7
diff changeset
112 }
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 7
diff changeset
113
1
3021fc79cc3b kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff changeset
114 #ifdef DEBUG
3021fc79cc3b kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff changeset
115
3021fc79cc3b kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff changeset
116 DigitalOut dbgpin(DBGPIN);
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents: 4
diff changeset
117 inline void pulse(uint8_t count=1, bool stayup=false)
1
3021fc79cc3b kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff changeset
118 {
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
119 dbgpin = 0;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
120 wait_us(2);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
121 while (count--)
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
122 {
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
123 dbgpin = 1;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
124 wait_us(2);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
125 dbgpin = 0;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
126 wait_us(2);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
127 }
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
128 if (stayup)
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
129 dbgpin = 1;
1
3021fc79cc3b kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff changeset
130 }
3021fc79cc3b kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff changeset
131 #else
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents: 4
diff changeset
132 inline void pulse(uint8_t count=1, bool stayup=false)
1
3021fc79cc3b kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff changeset
133 {}
3021fc79cc3b kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff changeset
134 #endif
3021fc79cc3b kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff changeset
135
19
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
136 // callbacks & thread functions
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
137 void reset(void);
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
138 void reset_irq(void);
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
139 void qei_cb(int dir);
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
140 void end_splashscreen(void);
4
219766126afb another attempt using a more complete support of the protocol and async serial stuff
David Douard <david.douard@logilab.fr>
parents: 3
diff changeset
141
32
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
142 /*
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
143 #if defined(HAVE_PC)
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
144 FileHandle *mbed::mbed_override_console(int fd)
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
145 {
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
146 return static_cast<FileHandle*> (&pc);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
147 }
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
148 #endif
32
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
149 */
3
a3233abe730e beginning of a working display using the 3.2 OLED module
David Douard <david.douard@logilab.fr>
parents: 2
diff changeset
150
1
3021fc79cc3b kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff changeset
151 void setup() {
32
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
152 #if defined(HAVE_PC)
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
153 #if defined(TARGET_NUCLEO_F446RE)
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
154 pc.set_baud(115200);
32
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
155 #endif
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
156
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
157 /*
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
158 #if defined(TARGET_HP34970_FP_F303RD)
32
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
159 pc.init();
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
160 pc.connect();
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
161 #endif
32
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
162 */
8
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 7
diff changeset
163 #endif
21
David Douard <david.douard@logilab.fr>
parents: 19
diff changeset
164
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
165 printf("\n\nSETUP\n");
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
166 printf(" System Core Clock = %.3f MHZ\r\n",
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
167 (float)SystemCoreClock/1000000);
21
David Douard <david.douard@logilab.fr>
parents: 19
diff changeset
168
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
169 /*
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
170 #if defined(HAS_LED)
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
171 printf("Attaching Led 1: %d\n", LED1);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
172 blinker.attach(callback(timeout_h), 0.5f);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
173 #endif
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
174 */
21
David Douard <david.douard@logilab.fr>
parents: 19
diff changeset
175
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
176 hp = NULL;
32
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
177 #if defined(TARGET_NUCLEO_F446RE)
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
178 printf("Serial communication pins\r\n");
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
179 printf(" USBRX=%d\r\n", USBRX);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
180 printf(" USBTX=%d\r\n", USBTX);
32
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
181 #endif
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
182 #if defined(TARGET_HP34970_FP_F303RD)
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
183 printf("Serial communication via USB\r\n");
32
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
184 #endif
22
2f51221af82d more stuff
David Douard <david.douard@logilab.fr>
parents: 21
diff changeset
185
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
186 printf("Setup HP communication pins\r\n");
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
187 printf(" HP_RX=%d\r\n", HP_RX);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
188 DigitalIn(HP_RX).mode(PullDown);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
189 printf(" HP_TX=%d\r\n", HP_TX);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
190 DigitalOut(HP_TX).write(1);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
191 printf(" HP_RST=%d\r\n", HP_RST);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
192 DigitalIn(HP_RST).mode(PullDown);
21
David Douard <david.douard@logilab.fr>
parents: 19
diff changeset
193
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
194 printf(" setup QEI pins\r\n");
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
195 printf(" ENC1=%d\r\n", KP_ENC1);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
196 DigitalIn(KP_ENC1).mode(PullDown);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
197 printf(" ENC2=%d\r\n", KP_ENC2);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
198 DigitalIn(KP_ENC2).mode(PullDown);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
199 qenc.attach(&qei_cb);
19
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
200
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
201 printf(" setup Keypad\r\n");
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
202 //cur_keycode.keyevent = KEY_NONE;
19
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
203
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
204 shift = false;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
205 kpad = new Keypad(KP_NROWS, kp_rows, KP_NCOLS, kp_columns);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
206 printf(" attach Keypad callbacks\r\n");
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
207 kpad->attach(&kp_cb, &kr_cb);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
208 printf(" start Keypad\r\n");
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
209 kpad->start();
21
David Douard <david.douard@logilab.fr>
parents: 19
diff changeset
210
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
211 printf("Setup OLED display\r\n");
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
212 // init the LCD
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
213 printf(" DSP_MOSI=%d\r\n", DSP_MOSI);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
214 printf(" DSP_MISO=%d\r\n", DSP_MISO);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
215 printf(" DSP_SCLK=%d\r\n", DSP_SCLK);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
216 printf(" DSP_CS=%d\r\n", DSP_CS);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
217 printf(" DSP_RST=%d\r\n", DSP_RST);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
218 printf(" DSP_DC=%d\r\n", DSP_DC);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
219 dsp = new Display(20000000, DSP_MOSI, DSP_MISO, DSP_SCLK, DSP_CS,
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
220 DSP_RST, DSP_DC, "SSD1322");
19
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
221
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
222 //curcmd = 0xFF;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
223 curchar = 0;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
224 nchars = 0;
7
5cf4034ba4e0 attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents: 5
diff changeset
225
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
226 for (uint8_t i=0; i<sizeof(table)/sizeof(table[0]); ++i)
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
227 memset(table[i].buffer, 0, MAX_BUFF+1);
19
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
228
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
229 printf(" display splash screen\r\n");
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
230 dsp->show_splashscreen();
19
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
231
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
232 printf("Starting LCD thread\r\n");
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
233 tdsp.start(&refresh_display);
22
2f51221af82d more stuff
David Douard <david.douard@logilab.fr>
parents: 21
diff changeset
234
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
235 /*
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
236 dsp->clrbuff();
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
237 show(0x00, "HH:MM:\tSS\t:mmmm", 15); // main dsp
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
238 show(0x0C, "888", 3); // channel dsp
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
239 show(0x0A, "\xFF\xFF\xFF\xFF", 4); // all flags
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
240 */
21
David Douard <david.douard@logilab.fr>
parents: 19
diff changeset
241
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
242 printf("Attaching timers\r\n");
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
243 splashscreen = true;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
244 splashscreen_timer.attach(callback(&end_splashscreen), 2ms);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
245 rst.fall(&reset_irq);
21
David Douard <david.douard@logilab.fr>
parents: 19
diff changeset
246
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
247 printf("SETUP DONE\r\n");
19
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
248 }
8
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 7
diff changeset
249
19
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
250 void end_splashscreen(void)
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
251 {
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
252 // print is forbidden here because we are in an ISR context here
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
253 //printf("End of splash screen CB\r\n");
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
254 splashscreen = false;
19
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
255 }
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
256
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
257 void reset_irq(void)
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
258 {
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
259 rst_delay.attach(callback(&reset), 1ms);
19
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
260 }
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
261
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
262 void reset(void)
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
263 {
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
264 if (DigitalIn(HP_RST).read() == 0) {
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
265 if (hp == NULL) {
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
266 printf("setup HP communication handler\r\n");
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
267 hp = new HPSerial(HP_TX, HP_RX);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
268 }
21
David Douard <david.douard@logilab.fr>
parents: 19
diff changeset
269
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
270 printf("!! RST !! (gstate=%d, state=%d)\r\n",
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
271 hp->gstate(), hp->state());
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
272 //printf("Value is ... %X\n", hp->search());
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
273 hp->startup();
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
274 }
1
3021fc79cc3b kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff changeset
275 }
3021fc79cc3b kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff changeset
276
37
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents: 36
diff changeset
277 void refresh_display(void) {
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
278 //uint8_t mask=1;
7
5cf4034ba4e0 attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents: 5
diff changeset
279
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
280 while(1) {
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
281 pulse(0, true);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
282 if (splashscreen == false) {
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
283 //Thread::wait(20); // give a bit of time for some more cmds
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
284 dsp->copy_to_lcd();
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
285 }
8
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 7
diff changeset
286
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
287 /*
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
288 if (must_refresh & mask) {
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
289 for(uint8_t i=0; i<sizeof(zones)/sizeof(zones[0]); i++)
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
290 if (zones[i].flag == mask) {
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
291 dsp->copy_to_lcd(zones[i].x0/4, (zones[i].x1+3)/4,
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
292 zones[i].y0, zones[i].y1);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
293 must_refresh &= ~mask;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
294 break;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
295 }
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
296 }
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
297 mask = mask << 1;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
298 if (mask == 0) {
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
299 mask = 1;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
300 }
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
301 */
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
302 pulse(0, false);
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 23
diff changeset
303
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
304 ThisThread::sleep_for(30ms);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
305 }
1
3021fc79cc3b kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff changeset
306 }
3021fc79cc3b kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff changeset
307
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
308 void mainloop()
19
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
309 { // run over and over
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
310 keycode_t key = {0, 0, KEY_NONE};
32
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
311
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
312 unsigned int err[8];
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
313 for (uint8_t i=0; i<8; i++)
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
314 err[i] = 0;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
315 int p, pp; // rot encoder pulse counters
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
316 p = 0;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
317 pp = 0;
32
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
318
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
319 while(1) {
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
320 p = qenc.getPulses();
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
321 if (p != pp)
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
322 {
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
323 dsp->locate(0, 0);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
324 dsp->printf("Pulses = %d ", p);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
325 dsp->copy_to_lcd();
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
326 pp = p;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
327 }
32
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
328
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
329 if (knob != 0)
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
330 {
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
331 if (hp != NULL)
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
332 {
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
333 printf("Sending keycode %X\r\n", knob);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
334 hp->sendkey(knob);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
335 printf(" DONE\r\n");
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
336 }
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
337 else
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
338 {
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
339 dsp->locate(70, 0);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
340 dsp->printf("Knob = %X ", knob);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
341 dsp->copy_to_lcd();
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
342 }
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
343 knob = 0;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
344 }
34
94ab7ff42a1b Add a key mapping table (protocol value vs. raw keycode) and send it
David Douard <david.douard@sdf3.org>
parents: 32
diff changeset
345
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
346 if (!key_buf.empty()) //cur_keycode.keyevent != KEY_NONE)
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
347 {
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
348 key_buf.pop(key);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
349 printf("Keycode %dx%d: %s\r\n",
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
350 key.row, key.col, key.keyevent==KEY_PRESSED?"pressed":"released");
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
351 if (hp != NULL) {
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
352 uint8_t keycode = kp_mapping[key.row][key.col];
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
353 if (key.keyevent == KEY_RELEASED)
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
354 keycode |= 0x40; // bit 6: key relased
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
355 if (shift)
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
356 keycode |= 0x20; // bit 5: key shifted
35
b2dca6b935bb Indent src/main.cpp with 2-ws
David Douard <david.douard@sdf3.org>
parents: 34
diff changeset
357
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
358 hp->sendkey(kp_mapping[key.row][key.col]);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
359 }
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
360 else
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
361 {
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
362 dsp->locate(140, 0);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
363 dsp->printf("KC: %dx%d[0x%s%X] %s",
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
364 key.row, key.col,
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
365 kp_mapping[key.row][key.col] <= 0x0F ? "0" : "",
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
366 kp_mapping[key.row][key.col],
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
367 key.keyevent==KEY_PRESSED ? "PRE" : "REL");
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
368 dsp->copy_to_lcd();
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
369 }
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
370 // cur_keycode.keyevent = KEY_NONE;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
371 }
19
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
372
21
David Douard <david.douard@logilab.fr>
parents: 19
diff changeset
373
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
374 if ((hp != NULL) && (hp->cmd_available()))
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
375 {
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
376 HPSerial::CMD cmd;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
377 if (hp->pop(cmd))
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
378 {
32
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
379 #if defined(HAS_LED)
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
380 led = 1;
32
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
381 #endif
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
382 for (uint8_t i=0; i<7; i++)
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
383 if (hp->nerrors(i) > err[i]) {
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
384 printf("ERR: %d/%d/%d/%d/%d/%d/%d\r\n",
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
385 hp->nerrors(0),
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
386 hp->nerrors(1),
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
387 hp->nerrors(2),
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
388 hp->nerrors(3),
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
389 hp->nerrors(4),
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
390 hp->nerrors(5),
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
391 hp->nerrors(6)
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
392 );
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
393 break;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
394 }
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
395 for (uint8_t i=0; i<7; i++)
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
396 err[i] = hp->nerrors(i);
19
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
397
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
398 printf("CMD[%d] %02X", (int)cmd.id, cmd.cmd);
19
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
399
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
400 // 0x00: main display
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
401 // 0x0C: channel display
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
402 if ((cmd.cmd == 0x00) || (cmd.cmd == 0x0C))
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
403 printf(": '%s'\r\n", cmd.value);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
404 else {
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
405 printf(":");
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
406 for (uint8_t i=0; i<cmd.size; i++)
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
407 printf("%02x ", cmd.value[i]);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
408 printf("\r\n");
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
409 }
36
a6c7292742a0 Add support for the shift flag
David Douard <david.douard@sdf3.org>
parents: 35
diff changeset
410
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
411 if (cmd.cmd == 0x01) {
36
a6c7292742a0 Add support for the shift flag
David Douard <david.douard@sdf3.org>
parents: 35
diff changeset
412 // clear a flag
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
413 if (cmd.value[0] == 0x0E) {
36
a6c7292742a0 Add support for the shift flag
David Douard <david.douard@sdf3.org>
parents: 35
diff changeset
414 // clear the Shift flag
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
415 shift = false;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
416 }
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
417 } else if (cmd.cmd == 0x86) {
36
a6c7292742a0 Add support for the shift flag
David Douard <david.douard@sdf3.org>
parents: 35
diff changeset
418 // shutdown
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
419 // TODO
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
420 } else {
36
a6c7292742a0 Add support for the shift flag
David Douard <david.douard@sdf3.org>
parents: 35
diff changeset
421 // display related commands
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
422 dsp->show(cmd.cmd, cmd.value, cmd.size);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
423 }
32
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
424 #if defined(HAS_LED)
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
425 led = 0;
32
bc1d6ecbb0cc Update the main code: extract headers and use a CircularBuffer for key events
David Douard <david.douard@sdf3.org>
parents: 28
diff changeset
426 #endif
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
427 }
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
428 }
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
429 //else
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
430 ThisThread::sleep_for(1ms);
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
431 }
1
3021fc79cc3b kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff changeset
432 }
3021fc79cc3b kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff changeset
433
19
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
434 void qei_cb(int dir)
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
435 {
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
436 if(dir == 1) // turn right
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
437 knob = 0x80;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
438 else // turn left
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
439 knob = 0x81; // 83?
19
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
440 }
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
441
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
442 void kp_cb(uint8_t row, uint8_t col)
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
443 {
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
444 keycode_t key;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
445 key.row = row;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
446 key.col = col;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
447 key.keyevent = KEY_PRESSED;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
448 if(!key_buf.full())
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
449 key_buf.push(key);
19
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
450 }
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
451
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
452 void kr_cb(uint8_t row, uint8_t col)
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
453 {
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
454 keycode_t key;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
455 key.row = row;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
456 key.col = col;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
457 key.keyevent = KEY_RELEASED;
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
458 if(!key_buf.full())
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
459 key_buf.push(key);
19
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
460 }
a52d60613cf7 Stuff...
David Douard <david.douard@logilab.fr>
parents: 18
diff changeset
461
1
3021fc79cc3b kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff changeset
462 int main()
3021fc79cc3b kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff changeset
463 {
38
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
464 setup();
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
465 printf("Main loop (noop)\r\n");
ffef9bbb345d kill tabs (again) in src/main.cpp
David Douard <david.douard@sdf3.org>
parents: 37
diff changeset
466 mainloop();
1
3021fc79cc3b kinf of working prototype using a ILI9341 based TFT
David Douard <david.douard@logilab.fr>
parents:
diff changeset
467 }

mercurial