mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2025-12-06 03:31:59 +01:00
optimize protocol of capture function
This commit is contained in:
parent
1c4718ae4a
commit
7ce755d666
8
main.c
8
main.c
|
|
@ -403,17 +403,17 @@ static void cmd_capture(BaseSequentialStream *chp, int argc, char *argv[])
|
||||||
int i;
|
int i;
|
||||||
ili9341_read_memory(0, 0, 320, 240, PART, buf);
|
ili9341_read_memory(0, 0, 320, 240, PART, buf);
|
||||||
for (i = 0; i < PART; i++) {
|
for (i = 0; i < PART; i++) {
|
||||||
chprintf(chp, "%04x ", buf[i]);
|
streamPut(chp, buf[i] >> 8);
|
||||||
|
streamPut(chp, buf[i] & 0xff);
|
||||||
}
|
}
|
||||||
chprintf(chp, "\r\n");
|
|
||||||
|
|
||||||
len -= PART;
|
len -= PART;
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
ili9341_read_memory_continue(PART, buf);
|
ili9341_read_memory_continue(PART, buf);
|
||||||
for (i = 0; i < PART; i++) {
|
for (i = 0; i < PART; i++) {
|
||||||
chprintf(chp, "%04x ", buf[i]);
|
streamPut(chp, buf[i] >> 8);
|
||||||
|
streamPut(chp, buf[i] & 0xff);
|
||||||
}
|
}
|
||||||
chprintf(chp, "\r\n");
|
|
||||||
len -= PART;
|
len -= PART;
|
||||||
}
|
}
|
||||||
//*/
|
//*/
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import numpy as np
|
||||||
import pylab as pl
|
import pylab as pl
|
||||||
import scipy.signal as signal
|
import scipy.signal as signal
|
||||||
import time
|
import time
|
||||||
|
import struct
|
||||||
|
|
||||||
REF_LEVEL = (1<<9)
|
REF_LEVEL = (1<<9)
|
||||||
|
|
||||||
|
|
@ -191,11 +192,8 @@ class NanoVNA():
|
||||||
def capture(self):
|
def capture(self):
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
self.send_command("capture\r")
|
self.send_command("capture\r")
|
||||||
data = self.fetch_data()
|
b = self.serial.read(320 * 240 * 2)
|
||||||
x = []
|
x = struct.unpack(">76800H", b)
|
||||||
for line in data.split('\n'):
|
|
||||||
if line:
|
|
||||||
x.extend([int(d, 16) for d in line.strip().split(' ')])
|
|
||||||
# convert pixel format from 565(RGB) to 8888(RGBA)
|
# convert pixel format from 565(RGB) to 8888(RGBA)
|
||||||
arr = np.array(x, dtype=np.uint32)
|
arr = np.array(x, dtype=np.uint32)
|
||||||
arr = 0xFF000000 + ((arr & 0xF800) >> 8) + ((arr & 0x07E0) << 5) + ((arr & 0x001F) << 19)
|
arr = 0xFF000000 + ((arr & 0xF800) >> 8) + ((arr & 0x07E0) << 5) + ((arr & 0x001F) << 19)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue