Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add shortcut keys F5-8 to reconfigure video in brightness and contras…

…t while rendering
  • Loading branch information...
commit 1d81dfa88fd0ea90c27ab27793586ca339b6420c 1 parent 2178ee9
Sébastien Bourdeauducq sbourdeauducq authored
2  src/Makefile
View
@@ -29,7 +29,7 @@ ifeq ($(WITH_PDF),1)
endif
# renderer
-OBJS+=framedescriptor.o analyzer.o sampler.o compiler.o eval.o line.o wave.o font.o osd.o raster.o renderer.o
+OBJS+=framedescriptor.o analyzer.o sampler.o compiler.o eval.o line.o wave.o font.o osd.o raster.o renderer.o videoinreconf.o
#
50 src/guirender.c
View
@@ -23,12 +23,16 @@
#include <rtems.h>
#include <mtklib.h>
#include <mtkeycodes.h>
+#include <bsp/milkymist_video.h>
#include "compiler.h"
#include "renderer.h"
#include "resmgr.h"
#include "fb.h"
#include "input.h"
+#include "config.h"
+#include "cp.h"
+#include "videoinreconf.h"
#include "guirender.h"
@@ -72,6 +76,36 @@ void guirender_stop()
callback();
}
+static void adjust_brightness(int amount)
+{
+ int brightness;
+
+ brightness = config_read_int("vin_brightness", 0);
+ brightness += amount;
+ if(brightness < -128)
+ brightness = -128;
+ else if(brightness > 127)
+ brightness = 127;
+ config_write_int("vin_brightness", brightness);
+ videoinreconf_request(VIDEO_SET_BRIGHTNESS, brightness);
+ cp_notify_changed();
+}
+
+static void adjust_contrast(int amount)
+{
+ int contrast;
+
+ contrast = config_read_int("vin_contrast", 0);
+ contrast += amount;
+ if(contrast < 0)
+ contrast = 0;
+ else if(contrast > 255)
+ contrast = 255;
+ config_write_int("vin_contrast", contrast);
+ videoinreconf_request(VIDEO_SET_CONTRAST, contrast);
+ cp_notify_changed();
+}
+
static int wait_release;
static void input_cb(mtk_event *e, int count)
@@ -94,6 +128,22 @@ static void input_cb(mtk_event *e, int count)
wait_release = e[i].press.code;
}
}
+ if(e[i].type == EVENT_TYPE_PRESS) {
+ switch(e[i].press.code) {
+ case MTK_KEY_F5:
+ adjust_brightness(5);
+ break;
+ case MTK_KEY_F6:
+ adjust_brightness(-5);
+ break;
+ case MTK_KEY_F7:
+ adjust_contrast(5);
+ break;
+ case MTK_KEY_F8:
+ adjust_contrast(-5);
+ break;
+ }
+ }
}
}
2  src/main.c
View
@@ -47,6 +47,7 @@
#include <curl/curl.h>
#include "version.h"
+#include "videoinreconf.h"
#include "shellext.h"
#include "sysconfig.h"
#include "fb.h"
@@ -172,6 +173,7 @@ rtems_task Init(rtems_task_argument argument)
mount("/dev/flash5", "/ssd", "yaffs", RTEMS_FILESYSTEM_READ_WRITE, "");
init_version();
+ init_videoinreconf();
sysconfig_load();
rtems_bsdnet_initialize_network();
2  src/raster.c
View
@@ -560,6 +560,8 @@ static rtems_task raster_task(rtems_task_argument argument)
if(frd == NULL)
break;
assert(frd->status == FRD_STATUS_EVALUATED);
+
+ videoinreconf_do(video_fd);
/* Update brightness */
brightness_error += frd->decay;
68 src/videoinreconf.c
View
@@ -0,0 +1,68 @@
+/*
+ * Flickernoise
+ * Copyright (C) 2010, 2011 Sebastien Bourdeauducq
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <assert.h>
+#include <rtems.h>
+#include <sys/ioctl.h>
+
+#include "videoinreconf.h"
+
+struct reconf_request {
+ int cmd;
+ int value;
+};
+
+static rtems_id request_q;
+
+void init_videoinreconf()
+{
+ rtems_status_code sc;
+
+ sc = rtems_message_queue_create(
+ rtems_build_name('V', 'I', 'N', 'R'),
+ 2,
+ sizeof(struct reconf_request),
+ 0,
+ &request_q);
+ assert(sc == RTEMS_SUCCESSFUL);
+}
+
+void videoinreconf_request(int cmd, int value)
+{
+ struct reconf_request req;
+
+ req.cmd = cmd;
+ req.value = value;
+ rtems_message_queue_send(request_q, &req, sizeof(struct reconf_request));
+}
+
+void videoinreconf_do(int fd)
+{
+ rtems_status_code sc;
+ struct reconf_request req;
+ size_t s;
+
+ sc = rtems_message_queue_receive(
+ request_q,
+ &req,
+ &s,
+ RTEMS_NO_WAIT,
+ RTEMS_NO_TIMEOUT
+ );
+ if(sc == RTEMS_SUCCESSFUL)
+ ioctl(fd, req.cmd, req.value);
+}
25 src/videoinreconf.h
View
@@ -0,0 +1,25 @@
+/*
+ * Flickernoise
+ * Copyright (C) 2010, 2011 Sebastien Bourdeauducq
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __VIDEOINRECONF_H
+#define __VIDEOINRECONF_H
+
+void init_videoinreconf();
+void videoinreconf_request(int cmd, int value);
+void videoinreconf_do(int fd);
+
+#endif /* __VIDEOINRECONF_H */
Please sign in to comment.
Something went wrong with that request. Please try again.