Use xor drawing to animate game of life over arbitrary display content

This commit is contained in:
bernd 2011-07-24 08:59:56 +02:00
parent c7e867815d
commit 9a77b01cef
1 changed files with 11 additions and 5 deletions

View File

@ -2,9 +2,9 @@
#include "basic/basic.h" #include "basic/basic.h"
//#include "lcd/render.h" #include "lcd/render.h"
#include "lcd/display.h" #include "lcd/display.h"
//#include "lcd/allfonts.h" #include "lcd/allfonts.h"
#define BITSET_X (RESX+2) #define BITSET_X (RESX+2)
#define BITSET_Y (RESY+2) #define BITSET_Y (RESY+2)
@ -79,7 +79,7 @@ uint32_t sum_area(struct bitset *area, uchar x0, uchar y0, uchar x1, uchar y1) {
void draw_area() { void draw_area() {
for(uchar x=0; x<RESX; ++x) { for(uchar x=0; x<RESX; ++x) {
for(uchar y=0; y<RESY; ++y) { for(uchar y=0; y<RESY; ++y) {
lcdSetPixel(x,y,bitset_get2(life,x+1,y+1)); lcdSetPixel(x,y,lcdGetPixel(x,y)^bitset_get2(life,x+1,y+1));
} }
} }
} }
@ -162,13 +162,18 @@ uchar randdensity=0;
void main_life(void) { void main_life(void) {
backlightInit(); backlightInit();
reset_area(); reset_area();
lcdFill(0);
font = &Font_Orbitron14pt;
int dx;
dx=DoString(20,20,"NICK");
gpioSetValue (RB_LED0, CFG_LED_ON); gpioSetValue (RB_LED0, CFG_LED_ON);
gpioSetValue (RB_LED1, CFG_LED_ON); gpioSetValue (RB_LED1, CFG_LED_ON);
gpioSetValue (RB_LED2, CFG_LED_ON); gpioSetValue (RB_LED2, CFG_LED_ON);
gpioSetValue (RB_LED3, CFG_LED_ON); gpioSetValue (RB_LED3, CFG_LED_ON);
while (1) { while (1) {
// checkISP(); // checkISP();
lcdFill(0);
uint32_t button=(stepmode?getInputWait():getInput()); uint32_t button=(stepmode?getInputWait():getInput());
if(button!=BTN_ENTER) randdensity=0; if(button!=BTN_ENTER) randdensity=0;
switch(button) { switch(button) {
@ -193,8 +198,9 @@ void main_life(void) {
stepmode=1; stepmode=1;
break; break;
} }
draw_area(); draw_area(); // xor life pattern over display content
lcdDisplay(); lcdDisplay();
draw_area(); // xor life pattern again to restore original display content
delayms(10); delayms(10);
calc_area(); calc_area();
} }