From 0a26d9983b6d1deab272ff6dde98f7c77ff2a56c Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Thu, 2 May 2013 01:50:09 +0200 Subject: updated license headers --- 3rdparty/boing/gfxconf.h | 40 +++++++++++++++++ 3rdparty/boing/main.c | 111 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 3rdparty/boing/gfxconf.h create mode 100644 3rdparty/boing/main.c (limited to '3rdparty/boing') diff --git a/3rdparty/boing/gfxconf.h b/3rdparty/boing/gfxconf.h new file mode 100644 index 00000000..45b6d7ab --- /dev/null +++ b/3rdparty/boing/gfxconf.h @@ -0,0 +1,40 @@ +/** + * This file has a different license to the rest of the GFX system. + * You can copy, modify and distribute this file as you see fit. + * You do not need to publish your source modifications to this file. + * The only thing you are not permitted to do is to relicense it + * under a different license. + */ + +#ifndef _GFXCONF_H +#define _GFXCONF_H + +/* GFX sub-systems to turn on */ +#define GFX_USE_GDISP TRUE +#define GFX_USE_GWIN FALSE +#define GFX_USE_GEVENT FALSE +#define GFX_USE_GTIMER FALSE +#define GFX_USE_GINPUT FALSE + +/* Features for the GDISP sub-system. */ +#define GDISP_NEED_VALIDATION FALSE +#define GDISP_NEED_CLIP FALSE +#define GDISP_NEED_TEXT FALSE +#define GDISP_NEED_CIRCLE FALSE +#define GDISP_NEED_ELLIPSE FALSE +#define GDISP_NEED_ARC FALSE +#define GDISP_NEED_SCROLL FALSE +#define GDISP_NEED_PIXELREAD FALSE +#define GDISP_NEED_CONTROL FALSE +#define GDISP_NEED_MULTITHREAD FALSE +#define GDISP_NEED_ASYNC FALSE +#define GDISP_NEED_MSGAPI FALSE + +/* Builtin Fonts */ +#define GDISP_INCLUDE_FONT_SMALL FALSE +#define GDISP_INCLUDE_FONT_LARGER FALSE +#define GDISP_INCLUDE_FONT_UI1 FALSE +#define GDISP_INCLUDE_FONT_UI2 FALSE +#define GDISP_INCLUDE_FONT_LARGENUMBERS FALSE + +#endif /* _GFXCONF_H */ diff --git a/3rdparty/boing/main.c b/3rdparty/boing/main.c new file mode 100644 index 00000000..a34cd2a9 --- /dev/null +++ b/3rdparty/boing/main.c @@ -0,0 +1,111 @@ +/* Derived from the 2011 IOCCC submission by peter.eastman@gmail.com + * http://www.ioccc.org/2011/eastman/eastman.c + * -- + * Public Domain -- but you're looking at this for ideas of techniques + * and methods, not trying to cut&paste an entire application, anyway. + * -- + * When you need to blit an entire screenfull of data to an LCD + * display, the basic idea is to exploit the auto-increment feature of + * the display controller when it writes to screen memory. You start + * by resetting the 'cursor' to the 0,0 position, and then stream + * width*height pixels out. + * -- + * Chris Baird,, April 2013 + */ + +#include +#include "ch.h" +#include "hal.h" +#include "gfx.h" +#include "ssd2119.h" + +#define Lightgrey (HTML2COLOR(0xC0C0C0)) +#define Midgrey (HTML2COLOR(0x606060)) +#define Darkgrey (HTML2COLOR(0x303030)) + + +/* ---------------------------------------------------------------------- */ +/* As of early April 2013, the /gfx extension tries to keep the low-level + * stuff away from our filthy paws. So Code Duplication. + * (Possibly to be replaced with gdispStartStream(), gdispWriteStream() + * and gdispStopStream() in the future.) + */ + +#define GDISP_REG (*((volatile uint16_t *) 0x60000000)) /* DC = 0 */ +#define GDISP_RAM (*((volatile uint16_t *) 0x60100000)) /* DC = 1 */ + +inline void write_index (uint16_t index) { GDISP_REG = index; } +inline void write_data (uint16_t data) { GDISP_RAM = data; } + +#define write_reg(reg, data) { write_index(reg); write_data(data); } + +void reset_cursor (void) +{ + write_reg (SSD2119_REG_X_RAM_ADDR, 0); + write_reg (SSD2119_REG_Y_RAM_ADDR, 0); +} + +#define StartStream() { write_index (SSD2119_REG_RAM_DATA); } +#define WriteStream(x) { write_data (x); } +#define StopStream() /* NOP */ + + +/* ---------------------------------------------------------------------- */ + +void main (void) +{ + uint16_t xx, yy, colour; + + halInit(); + chSysInit(); + gdispInit(); + + uint16_t width = (uint16_t)gdispGetWidth(); + uint16_t height = (uint16_t)gdispGetHeight(); + + float i=height/5+height%2+1, floorstart=height/5-1, spherespin=0.0, + l=width/2, m=height/4, n=.01*width, o=0.0, rotspeed=0.1, h, f, g; + + while (TRUE) + { + reset_cursor (); + StartStream (); + + for (xx=yy=0; + h = (m-yy)/i, f=-.3*(g=(l-xx)/i)+.954*h, yywidth-floorstart) + colour = Darkgrey; /* side wall */ + else + colour = Lightgrey; /* back wall */ + + if (yy > height-floorstart) + if (xx < height-yy || height-yy > width-xx) /* floor */ + colour = Darkgrey; + else + colour = Midgrey; + + if (g*(g+.6)+.09+h*h < 1) + colour >>= 1; /* ball shadow; make it darker */ + } + + WriteStream (colour); /* pixel to the LCD */ + } + + StopStream(); + spherespin += rotspeed; + m += o; + o = m > height-1.75*floorstart ? -.04*height : o+.002*height; + n = (l+=n)width-i ? rotspeed=-rotspeed,-n : n; + } +} + +/* ---------------------------------------------------------------------- */ -- cgit v1.2.3