Add sensor.flush()

This commit is contained in:
iabdalkader 2017-06-25 16:47:47 +02:00
parent 99ec972ad0
commit 7d29104ed6
3 changed files with 14 additions and 3 deletions

View File

@ -27,6 +27,11 @@ static mp_obj_t py_sensor_reset() {
return mp_const_none;
}
static mp_obj_t py_sensor_flush() {
fb_update_jpeg_buffer();
return mp_const_none;
}
/*
* Filter functions bypass the default line processing in sensor.c, and pre-process lines before anything else.
* Processing is done on the fly, i.e. line filters are called from sensor_snapshot after each line is readout.
@ -361,6 +366,7 @@ static mp_obj_t py_sensor_read_reg(mp_obj_t addr) {
//}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(py_sensor_reset_obj, py_sensor_reset);
STATIC MP_DEFINE_CONST_FUN_OBJ_0(py_sensor_flush_obj, py_sensor_flush);
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_sensor_snapshot_obj, 0, py_sensor_snapshot);
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_sensor_skip_frames_obj, 0, py_sensor_skip_frames);
STATIC MP_DEFINE_CONST_FUN_OBJ_0(py_sensor_width_obj, py_sensor_width);
@ -438,6 +444,7 @@ STATIC const mp_map_elem_t globals_dict_table[] = {
// Sensor functions
{ MP_OBJ_NEW_QSTR(MP_QSTR_reset), (mp_obj_t)&py_sensor_reset_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_flush), (mp_obj_t)&py_sensor_flush_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_snapshot), (mp_obj_t)&py_sensor_snapshot_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_skip_frames), (mp_obj_t)&py_sensor_skip_frames_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_width), (mp_obj_t)&py_sensor_width_obj },

View File

@ -208,6 +208,7 @@ Q(NORMAL)
Q(NEGATIVE)
Q(reset)
Q(flush)
Q(snapshot)
Q(skip_frames)
Q(get_fb)

View File

@ -2,7 +2,7 @@
#
# This example shows how to load and copy an image to framebuffer for testing.
import sensor, image
import sensor, image, time
# Still need to init sensor
sensor.reset()
@ -15,10 +15,13 @@ sensor.set_framesize(sensor.QQVGA)
sensor.set_pixformat(sensor.GRAYSCALE)
# Load image
img = image.Image("/image.pgm", copy_to_fb=True)
img = image.Image("/example.bmp", copy_to_fb=True)
# Add drawing code here.
# img.draw_line(...)
# Flush FB
sensor.snapshot()
sensor.flush()
# Add a small delay to allow the IDE to read the flushed image.
time.sleep(100)