[Armadeus-commitlog] armadeus branch, master, updated. latestrelease-161-g131f99b
Brought to you by:
sszy
|
From: Julien B a. A. <ar...@us...> - 2009-11-23 14:46:10
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "armadeus".
The branch, master has been updated
via 131f99b3279c9235a7ca7a6892c3390007946404 (commit)
from b6f655f9991fe3b1582d4b7dd04dafcf4e74ec62 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 131f99b3279c9235a7ca7a6892c3390007946404
Author: Julien Boibessot <jul...@ar...>
Date: Mon Nov 23 15:45:41 2009 +0100
[DEMOS] Add preliminary work for a graphical (kind of) oscilloscope using AsDevices library
-----------------------------------------------------------------------
Summary of changes:
.../demos/{real_time/fractal => oscillo}/Makefile | 13 ++-
target/demos/oscillo/README | 5 +
target/demos/oscillo/lcd.c | 128 ++++++++++++++++++++
target/demos/oscillo/lcd.h | 15 +++
target/demos/oscillo/main.c | 78 ++++++++++++
5 files changed, 234 insertions(+), 5 deletions(-)
copy target/demos/{real_time/fractal => oscillo}/Makefile (69%)
create mode 100644 target/demos/oscillo/README
create mode 100644 target/demos/oscillo/lcd.c
create mode 100644 target/demos/oscillo/lcd.h
create mode 100644 target/demos/oscillo/main.c
diff --git a/target/demos/real_time/fractal/Makefile b/target/demos/oscillo/Makefile
similarity index 69%
copy from target/demos/real_time/fractal/Makefile
copy to target/demos/oscillo/Makefile
index e6c30d6..266fa0d 100644
--- a/target/demos/real_time/fractal/Makefile
+++ b/target/demos/oscillo/Makefile
@@ -1,13 +1,16 @@
CC=arm-linux-gcc
CFLAGS=-g -W -Wall
-LDFLAGS=
-EXEC=newton
+LDFLAGS=-lm
+INSTALL_DIR=/tftpboot
+
+
SRC= $(wildcard *.c)
OBJ= $(SRC:.c=.o)
+EXEC=oscillo
all: $(EXEC)
-newton: $(OBJ)
+$(EXEC): $(OBJ)
$(CC) -o $@ $^ $(LDFLAGS)
%.o: %.c
@@ -18,7 +21,7 @@ newton: $(OBJ)
clean:
rm -rf *.o
rm -f $(EXEC)
- rm -f *.c~ *.h~ Makefile~
+
install: all
- cp -f $(EXEC) /tftpboot/local/bin
+ cp -f $(EXEC) $(INSTALL_DIR)
diff --git a/target/demos/oscillo/README b/target/demos/oscillo/README
new file mode 100644
index 0000000..effc687
--- /dev/null
+++ b/target/demos/oscillo/README
@@ -0,0 +1,5 @@
+Under development !
+
+Will graphically show (raw framebuffer) APF's ADC (MAX1027) inputs by using
+AsDevices library.
+
diff --git a/target/demos/oscillo/lcd.c b/target/demos/oscillo/lcd.c
new file mode 100644
index 0000000..db1e0c7
--- /dev/null
+++ b/target/demos/oscillo/lcd.c
@@ -0,0 +1,128 @@
+/*
+ * Abstracts framebuffer access
+ *
+ * Copyright (C) 2009 <gwe...@ar...>
+ * Armadeus Project / Armadeus Systems
+ *
+ *
+ * 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; either version 2, or (at your option)
+ * any later version.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+
+#include <errno.h>
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <ctype.h>
+
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <linux/fb.h>
+#include <sys/mman.h>
+
+#include "lcd.h"
+
+
+char *fbp = 0;
+struct fb_var_screeninfo vinfo;
+struct fb_fix_screeninfo finfo;
+long int screensize = 0;
+
+int init_lcd()
+{
+ int fbfd = 0;
+
+ /* Open the file for reading and writing */
+ fbfd = open("/dev/fb0", O_RDWR);
+ if (fbfd < 0) {
+ printf("Error: cannot open framebuffer device.\n");
+ return -1;
+ }
+ printf("The framebuffer device was opened successfully.\n");
+
+ /* Get fixed screen information */
+ if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)) {
+ printf("Error reading fixed information.\n");
+ return -1;
+ }
+
+ /* Get variable screen information */
+ if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) {
+ printf("Error reading variable information.\n");
+ return -1;
+ }
+
+ printf("%dx%d, %dbpp\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel );
+
+ /* Figure out the size of the screen in bytes */
+ screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;
+
+ /* Map the device to memory */
+ fbp = (char *)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED,
+ fbfd, 0);
+ if ((int)fbp == -1) {
+ printf("Error: failed to map framebuffer device to memory.\n");
+ return -1;
+ }
+ printf("The framebuffer device was mapped to memory successfully.\n");
+
+ return fbfd;
+}
+
+void close_lcd(int fbfd)
+{
+ munmap(fbp, screensize);
+ close(fbfd);
+}
+
+
+void draw_pixel(unsigned int x, unsigned int y, struct color rgb)
+{
+ long int location = 0;
+
+ if ((x >= vinfo.xres) || (y >= vinfo.yres)) {
+ printf("%s: position (%d,%d) outside boundaries !\n", __func__, x, y);
+ if (x >= vinfo.xres)
+ x = vinfo.xres-1;
+ if (y >= vinfo.yres)
+ x = vinfo.yres-1;
+ }
+ location = (x+vinfo.xoffset) * (vinfo.bits_per_pixel/8) +
+ (y+vinfo.yoffset) * finfo.line_length;
+
+ unsigned short int t = ((rgb.r&0xf8)>>3)<<11 | ((rgb.g&0xfc)>>2) << 5 | ((rgb.b&0xf8)>>3);
+ *((unsigned short int*)(fbp + location)) = t;
+}
+
+void clear_vline(unsigned int x)
+{
+ unsigned int y = 0;
+ struct color black = {0,0,0};
+
+ for (y=0; y<vinfo.yres; y++) {
+ draw_pixel(x, y, black);
+ }
+}
+
diff --git a/target/demos/oscillo/lcd.h b/target/demos/oscillo/lcd.h
new file mode 100644
index 0000000..d2d2fbc
--- /dev/null
+++ b/target/demos/oscillo/lcd.h
@@ -0,0 +1,15 @@
+#ifndef LCD_H
+#define LCD_H
+
+struct color {
+ int r;
+ int g;
+ int b;
+};
+
+int init_lcd ();
+void close_lcd(int fbfd);
+void draw_pixel(unsigned int x, unsigned int y, struct color rgb);
+void clear_vline(unsigned int x);
+
+#endif /* LCD_H */
diff --git a/target/demos/oscillo/main.c b/target/demos/oscillo/main.c
new file mode 100644
index 0000000..452452d
--- /dev/null
+++ b/target/demos/oscillo/main.c
@@ -0,0 +1,78 @@
+/*
+ * (Kind of) Oscilloscope for the APF
+ *
+ * Copyright (C) 2009 <jul...@ar...>
+ * Armadeus Project / Armadeus Systems
+ *
+ * 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; either version 2, or (at your option)
+ * any later version.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <math.h> /* sin() */
+
+#include "lcd.h"
+
+
+int fbfd;
+
+static void cleanup(void)
+{
+ close_lcd(fbfd);
+}
+
+#define MAX_CHANNELS 8
+
+int main(void /*int argc, char **argv*/)
+{
+ /*int x[MAX_CHANNELS] = {0, 10, 20, 30, 40, 50, 60, 70};*/
+ int y[MAX_CHANNELS];
+ int time = 0, i;
+ int nb_channels;
+ double rad;
+ struct color colours[MAX_CHANNELS] = {{120,120,120},{0,150,150},{160,0,160},{170,170,0}};
+
+ atexit(cleanup);
+
+ fbfd = init_lcd();
+ if (fbfd < 0)
+ return EXIT_FAILURE;
+
+ nb_channels = 3;
+ while(1) {
+ time += 1;
+ if (time >= 479) {
+ time = 0;
+ }
+ for (i=0; i<nb_channels; i++) {
+ rad += 0.01745f;
+ y[i] = (unsigned int)(sin(rad)*100 + 136 + 5*i);
+ //printf("%d: %d %d\n", i, time, y[i]);
+ draw_pixel(time, y[i], colours[i]);
+ }
+ clear_vline(time+1);
+ usleep(50000);
+ }
+
+ return EXIT_SUCCESS;
+}
+
hooks/post-receive
--
armadeus
|