Merge branch 'master' of github.com:r0ket/r0ket

This commit is contained in:
kiu 2011-07-21 23:32:50 +02:00
commit dae166e99e
31 changed files with 588 additions and 667 deletions

View File

@ -0,0 +1,53 @@
#ifndef CBITFIELD_H
#define CBITFIELD_H
#define BITSETCHUNKSIZE 32
#define one ((uint32_t)1)
struct bitset {
uint16_t size;
uint32_t bits[BITSET_SIZE/BITSETCHUNKSIZE+1];
};
static inline void bitset_set(struct bitset *bs,uint16_t index, uint8_t value) {
uint16_t base=index/BITSETCHUNKSIZE;
uint16_t offset=index%BITSETCHUNKSIZE;
if(value) {
bs->bits[base]|=(one<<offset);
} else {
bs->bits[base]&=~(one<<offset);
}
}
static inline void bitset_xor(struct bitset *bs,uint16_t index, uint8_t value) {
uint16_t base=index/BITSETCHUNKSIZE;
uint16_t offset=index%BITSETCHUNKSIZE;
if(value) {
bs->bits[base]^=(one<<offset);
}
}
static inline uint8_t bitset_get(struct bitset *bs,uint16_t index) {
uint16_t base=index/BITSETCHUNKSIZE;
uint16_t offset=index%BITSETCHUNKSIZE;
return (bs->bits[base]&(one<<offset))==(one<<offset);;
}
static inline uint16_t bitset_offset2(uint8_t x, uint8_t y) {
return ((uint16_t)x)+((uint16_t)y)*BITSET_X;
}
static inline void bitset_set2(struct bitset *bs, uint8_t x, uint8_t y, uint8_t value) {
bitset_set(bs,bitset_offset2(x,y),value);
}
static inline void bitset_xor2(struct bitset *bs, uint8_t x, uint8_t y, uint8_t value) {
bitset_xor(bs,bitset_offset2(x,y),value);
}
static inline uint8_t bitset_get2(struct bitset *bs,uint8_t x,uint8_t y) {
return bitset_get(bs,bitset_offset2(x,y));
}
#endif

View File

@ -113,15 +113,19 @@ void f_nick(void){
delayms(40); delayms(40);
key= getInputRaw(); key= getInputRaw();
if(key==BTN_UP){ if(key & BTN_UP){
--y;//if(--y<0) y=0; --y;//if(--y<0) y=0;
}else if (key ==BTN_DOWN){ };
if (key & BTN_DOWN){
++y;//if(++y>=RESY) y=RESY-1; ++y;//if(++y>=RESY) y=RESY-1;
}else if (key ==BTN_LEFT){ };
if (key & BTN_LEFT){
--x;//if(--x<0) x=0; --x;//if(--x<0) x=0;
}else if (key ==BTN_RIGHT){ };
if (key & BTN_RIGHT){
++x;//if(++x>=RESX) x=RESX-1; ++x;//if(++x>=RESX) x=RESX-1;
}else if (key ==BTN_ENTER){ };
if (key == BTN_ENTER){
lcdClear(); lcdClear();
lcdPrintln("Done."); lcdPrintln("Done.");
lcdDisplay(); lcdDisplay();

View File

@ -0,0 +1,202 @@
#include <sysinit.h>
#include "basic/basic.h"
//#include "lcd/render.h"
#include "lcd/display.h"
//#include "lcd/allfonts.h"
#define BITSET_X (RESX+2)
#define BITSET_Y (RESY+2)
#define BITSET_SIZE (BITSET_X*BITSET_Y)
#include "cbitset.h"
typedef uint8_t uchar;
unsigned char rnd1();
void draw_rect(char x0, char y0, char x1, char y1) {
for(char x=x0; x<=x1; ++x) {
lcdSetPixel(x,y0,true);
lcdSetPixel(x,y1,true);
}
for(char y=y0+1; y<y1; ++y) {
lcdSetPixel(x0,y,true);
lcdSetPixel(x1,y,true);
}
}
void fill_rect(char x0, char y0, char x1, char y1) {
for(char x=x0; x<=x1; ++x) {
for(char y=y0; y<=y1; ++y) {
lcdSetPixel(x,y,true);
}
}
}
#define STARTVALUE 10
struct bitset _buf1,*buf1=&_buf1;
struct bitset _buf2,*buf2=&_buf2;
struct bitset *life =&_buf1;
struct bitset *new =&_buf2;
void swap_areas() {
struct bitset *tmp=life;
life=new;
new=tmp;
}
void fill_area(struct bitset *area, uchar x0, uchar y0, uchar x1, uchar y1,uchar value) {
for(uchar x=x0; x<=x1; ++x) {
for(uchar y=y0; y<=y1; ++y) {
bitset_set2(area,x,y,value);
}
}
}
bool find_area(struct bitset *area, uchar x0, uchar y0, uchar x1, uchar y1,uchar value) {
for(uchar x=x0; x<=x1; ++x) {
for(uchar y=y0; y<=y1; ++y) {
if(bitset_get2(area,x,y)==value) return true;
}
}
return false;
}
uint32_t sum_area(struct bitset *area, uchar x0, uchar y0, uchar x1, uchar y1) {
uint32_t sum=0;
for(uchar x=x0; x<=x1; ++x) {
for(uchar y=y0; y<=y1; ++y) {
sum+=bitset_get2(area,x,y);
}
}
return sum;
}
void draw_area() {
for(uchar x=0; x<RESX; ++x) {
for(uchar y=0; y<RESY; ++y) {
lcdSetPixel(x,y,bitset_get2(life,x+1,y+1));
}
}
}
void calc_area() {
#ifdef SIMULATOR
static unsigned long iter=0;
fprintf(stderr,"Iteration %d \n",++iter);
#endif
for(uchar x=1; x<=RESX; ++x) {
for(uchar y=1; y<=RESY; ++y) {
uchar sum=sum_area(life,x-1,y-1,x+1,y+1)-bitset_get2(life,x,y);
bitset_set2(new,x,y,sum==3||(sum==2&&bitset_get2(life,x,y)));
}
}
swap_areas();
}
int pattern=0;
#define PATTERNCOUNT 3
void reset_area() {
fill_area(life,0,0,RESX+1,RESY+1,0);
fill_area(new,0,0,RESX+1,RESY+1,0);
switch(pattern) {
case 0:
bitset_set2(life,41,40,1);
bitset_set2(life,42,40,1);
bitset_set2(life,41,41,1);
bitset_set2(life,40,41,1);
bitset_set2(life,41,42,1);
break;
case 1:
for(int i=0; i<RESX/2; ++i) bitset_set2(life,i,0,1);
bitset_set2(life,40,40,1);
bitset_set2(life,41,40,1);
bitset_set2(life,41,41,1);
break;
case 2:
bitset_set2(life,40,40,1);
bitset_set2(life,41,40,1);
bitset_set2(life,42,40,1);
bitset_set2(life,42,41,1);
bitset_set2(life,42,42,1);
bitset_set2(life,40,41,1);
bitset_set2(life,40,42,1);
break;
}
}
void random_area(struct bitset *area, uchar x0, uchar y0, uchar x1, uchar y1,uchar value) {
for(uchar x=x0; x<=x1; ++x) {
for(uchar y=y0; y<=y1; ++y) {
bitset_set2(area,x,y,rnd1()<value);
}
}
}
#define LEDINTERVAL 1
uint8_t ledcycle=3;
void nextledcycle() {
ledcycle=(ledcycle+1)%(8*LEDINTERVAL);
uint8_t a=ledcycle/LEDINTERVAL;
switch(a) {
case 0: gpioSetValue (RB_LED0, CFG_LED_ON); break;
case 4: gpioSetValue (RB_LED0, CFG_LED_OFF); break;
case 1: gpioSetValue (RB_LED1, CFG_LED_ON); break;
case 5: gpioSetValue (RB_LED1, CFG_LED_OFF); break;
case 2: gpioSetValue (RB_LED2, CFG_LED_ON); break;
case 6: gpioSetValue (RB_LED2, CFG_LED_OFF); break;
case 3: gpioSetValue (RB_LED3, CFG_LED_ON); break;
case 7: gpioSetValue (RB_LED3, CFG_LED_OFF); break;
}
}
uchar stepmode=0;
uchar randdensity=0;
void main_life(void) {
backlightInit();
reset_area();
gpioSetValue (RB_LED0, CFG_LED_ON);
gpioSetValue (RB_LED1, CFG_LED_ON);
gpioSetValue (RB_LED2, CFG_LED_ON);
gpioSetValue (RB_LED3, CFG_LED_ON);
while (1) {
// checkISP();
lcdFill(0);
uint32_t button=(stepmode?getInputWait():getInput());
if(button!=BTN_ENTER) randdensity=0;
switch(button) {
case BTN_DOWN:
stepmode=1;
nextledcycle();
break;
case BTN_RIGHT:
stepmode=0;
break;
case BTN_LEFT:
reset_area();
break;
case BTN_ENTER:
randdensity+=8;
random_area(life,1,1,RESX,RESY,randdensity);
stepmode=1;
break;
case BTN_UP:
pattern=(pattern+1)%PATTERNCOUNT;
reset_area();
stepmode=1;
break;
}
draw_area();
lcdDisplay();
delayms(10);
calc_area();
}
return;
}

View File

@ -24,7 +24,7 @@ void blink(){
struct mb { struct mb {
long rmin, rmax, imin, imax; long rmin, rmax, imin, imax;
bool dirty; bool dirty, dup, ddown, dleft, dright;
} mandel; } mandel;
void mandelInit() { void mandelInit() {
@ -38,51 +38,64 @@ void mandelInit() {
mandel.imax = fixpt(2); mandel.imax = fixpt(2);
mandel.dirty = true; mandel.dirty = true;
mandel.dup = false;
mandel.ddown = false;
mandel.dleft = false;
mandel.dright = false;
} }
void mandelMove() { void mandelMove() {
long delta_r = (mandel.rmax - mandel.rmin)/10; //long delta_r = (mandel.rmax - mandel.rmin)/10;
long delta_i = (mandel.imax - mandel.imin)/10; //long delta_i = (mandel.imax - mandel.imin)/10;
long rs =(mandel.rmax-mandel.rmin)/RESY;
long is =(mandel.imax-mandel.imin)/RESX;
char key = getInputRaw(); char key = getInputRaw();
if(key == BTN_LEFT) { if (key == BTN_LEFT) {
mandel.imax -= delta_i; mandel.imax -=is;
mandel.imin -= delta_i; mandel.imin -=is;
mandel.dirty = true; mandel.dleft = true;
} else if (key == BTN_RIGHT) { } else if (key == BTN_RIGHT) {
mandel.imax += delta_i; mandel.imax += is;
mandel.imin += delta_i; mandel.imin += is;
mandel.dirty = true; mandel.dright = true;
} else if (key == BTN_DOWN) { } else if (key == BTN_DOWN) {
mandel.rmax += delta_r; mandel.rmax += rs;
mandel.rmin += delta_r; mandel.rmin += rs;
mandel.dirty = true; mandel.ddown = true;
} else if (key == BTN_UP) { } else if (key == BTN_UP) {
mandel.rmax -= delta_r; mandel.rmax -= rs;
mandel.rmin -= delta_r; mandel.rmin -= rs;
mandel.dirty = true; mandel.dup = true;
} else if (key == BTN_ENTER) { } else if (key == (BTN_ENTER + BTN_UP)) {
mandel.imin = mandel.imin + (mandel.imax-mandel.imin)/10; mandel.imin = mandel.imin + (mandel.imax-mandel.imin)/10;
mandel.imax = mandel.imax - (mandel.imax-mandel.imin)/10; mandel.imax = mandel.imax - (mandel.imax-mandel.imin)/10;
mandel.rmin = mandel.rmin +(mandel.rmax-mandel.rmin)/10; mandel.rmin = mandel.rmin +(mandel.rmax-mandel.rmin)/10;
mandel.rmax = mandel.rmax -(mandel.rmax-mandel.rmin)/10; mandel.rmax = mandel.rmax -(mandel.rmax-mandel.rmin)/10;
mandel.dirty = true; mandel.dirty = true;
} else if (key == (BTN_ENTER + BTN_DOWN)) {
mandel.imin = mandel.imin - (mandel.imax-mandel.imin)/10;
mandel.imax = mandel.imax + (mandel.imax-mandel.imin)/10;
mandel.rmin = mandel.rmin -(mandel.rmax-mandel.rmin)/10;
mandel.rmax = mandel.rmax +(mandel.rmax-mandel.rmin)/10;
mandel.dirty = true;
} }
} }
void mandelCalc() { void mandelPixel(int x, int y) {
long r0,i0,rn, p,q; long r0,i0,rn, p,q;
long rs,is; long rs,is;
int iteration; int iteration;
char x, y;
rs=(mandel.rmax-mandel.rmin)/RESY; rs=(mandel.rmax-mandel.rmin)/RESY;
is=(mandel.imax-mandel.imin)/RESX; is=(mandel.imax-mandel.imin)/RESX;
//p=fixpt(mandel.rmin+y*rs);
for (x=0; x<RESX; x++){ //q=fixpt(mandel.imin+x*is);
for (y=0; y<RESY; y++) {
p=mandel.rmin+y*rs; p=mandel.rmin+y*rs;
q=mandel.imin+x*is; q=mandel.imin+x*is;
rn=0; rn=0;
r0=0; r0=0;
i0=0; i0=0;
@ -95,11 +108,56 @@ void mandelCalc() {
if (iteration==ITERATION_MAX) iteration=1; if (iteration==ITERATION_MAX) iteration=1;
bool pixel = ( iteration>1); bool pixel = ( iteration>1);
lcdSetPixel(x, y, pixel); lcdSetPixel(x, y, pixel);
}
}
mandel.dirty = false;
} }
void mandelUpdate() {
int xmin,xmax,ymin,ymax;
if (mandel.dirty) {
xmin = 0;
xmax = RESX;
ymin = 0;
ymax = RESY;
mandel.dirty = false;
} else if (mandel.dleft) {
lcdShift(1,0,false);
xmin = 0;
xmax = 1;
ymin = 0;
ymax = RESY;
mandel.dleft = false;
} else if (mandel.dright) {
lcdShift(-1,0,false);
xmin = RESX-1;
xmax = RESX;
ymin = 0;
ymax = RESY;
mandel.dright = false;
} else if (mandel.dup) {
lcdShift(0,-1,true);
xmin=0;
xmax=RESX;
ymin=0;
ymax=1;
mandel.dup = false;
} else if (mandel.ddown) {
lcdShift(0,1,true);
xmin=0;
xmax=RESX;
ymin=RESY-1;
ymax=RESY;
mandel.ddown = false;
} else {
return;
}
for (int x = xmin; x<xmax; x++) {
for (int y = ymin; y<ymax; y++) {
mandelPixel(x,y);
}
}
}
void main_mandelbrot2(void) { void main_mandelbrot2(void) {
backlightInit(); backlightInit();
IOCON_PIO3_3 = 0x10; IOCON_PIO3_3 = 0x10;
@ -108,9 +166,8 @@ void main_mandelbrot2(void) {
while (1) { while (1) {
lcdDisplay(); lcdDisplay();
mandelMove(); mandelMove();
if (mandel.dirty) { mandelUpdate();
mandelCalc();
}
if(gpioGetValue(RB_BTN0)==0 && gpioGetValue(RB_BTN4)==0){ if(gpioGetValue(RB_BTN0)==0 && gpioGetValue(RB_BTN4)==0){
DoString(0,0,"Enter ISP!"); DoString(0,0,"Enter ISP!");

View File

@ -5,6 +5,7 @@
#include "lcd/render.h" #include "lcd/render.h"
#include "lcd/display.h" #include "lcd/display.h"
#include "lcd/allfonts.h" #include "lcd/allfonts.h"
#include "lcd/print.h"
void backlightInit(void); void backlightInit(void);
@ -14,7 +15,8 @@ void main_scroll(void) {
int dx=0; int dx=0;
char key; char key;
backlightInit(); backlightInit();
font_direction = FONT_DIR_LTR; // LeftToRight is the default bool wrap=true;
int ctr=0;
font=&Font_7x8; font=&Font_7x8;
dx=DoString(0,0,"Hello World"); dx=DoString(0,0,"Hello World");
@ -23,25 +25,30 @@ void main_scroll(void) {
lcdDisplay(); lcdDisplay();
//// delayms(10); //// delayms(10);
key= getInput(); key= getInputRaw();
// Easy flashing // Easy flashing
if(key==BTN_ENTER){ if((key&(BTN_ENTER|BTN_LEFT))==(BTN_ENTER|BTN_LEFT)){
DoString(0,8,"Enter ISP!"); DoString(0,8,"Enter ISP!");
lcdDisplay(); lcdDisplay();
ISPandReset(); ISPandReset();
} }
if(key==BTN_RIGHT){ if(key&BTN_ENTER){
lcdShift(1,0,true); lcdPrintInt(ctr++);
lcdPrintln(".");
while(getInputRaw())delayms(10);
};
if(key&BTN_RIGHT){
lcdShift(1,0,wrap);
} }
if(key==BTN_LEFT){ if(key&BTN_LEFT){
lcdShift(-1,0,true); lcdShift(-1,0,wrap);
} }
if(key==BTN_UP){ if(key&BTN_UP){
lcdShift(0,1,true); lcdShift(0,1,wrap);
} }
if(key==BTN_DOWN){ if(key&BTN_DOWN){
lcdShift(0,-1,true); lcdShift(0,-1,wrap);
} }
//font = &Font_Ubuntu36pt; //font = &Font_Ubuntu36pt;

View File

@ -1,63 +1,42 @@
#include <sysinit.h> #include <sysinit.h>
#include "basic/basic.h" #include "basic/basic.h"
uint8_t getInput(void) {
uint8_t result = BTN_NONE;
if (gpioGetValue(RB_BTN3)==0) {
while(gpioGetValue(RB_BTN3)==0);
result += BTN_UP;
}
if (gpioGetValue(RB_BTN2)==0) {
while(gpioGetValue(RB_BTN2)==0);
result += BTN_DOWN;
}
if (gpioGetValue(RB_BTN4)==0) {
while(gpioGetValue(RB_BTN4)==0);
result += BTN_ENTER;
}
if (gpioGetValue(RB_BTN0)==0) {
while(gpioGetValue(RB_BTN0)==0);
result += BTN_LEFT;
}
if (gpioGetValue(RB_BTN1)==0) {
while(gpioGetValue(RB_BTN1)==0);
result += BTN_RIGHT;
}
return result;
}
uint8_t getInputRaw(void) { uint8_t getInputRaw(void) {
uint8_t result = BTN_NONE; uint8_t result = BTN_NONE;
if (gpioGetValue(RB_BTN3)==0) { if (gpioGetValue(RB_BTN3)==0) {
result += BTN_UP; result |= BTN_UP;
} }
if (gpioGetValue(RB_BTN2)==0) { if (gpioGetValue(RB_BTN2)==0) {
result += BTN_DOWN; result |= BTN_DOWN;
} }
if (gpioGetValue(RB_BTN4)==0) { if (gpioGetValue(RB_BTN4)==0) {
result += BTN_ENTER; result |= BTN_ENTER;
} }
if (gpioGetValue(RB_BTN0)==0) { if (gpioGetValue(RB_BTN0)==0) {
result += BTN_LEFT; result |= BTN_LEFT;
} }
if (gpioGetValue(RB_BTN1)==0) { if (gpioGetValue(RB_BTN1)==0) {
result += BTN_RIGHT; result |= BTN_RIGHT;
} }
return result; return result;
} }
uint8_t getInput(void) {
uint8_t key = BTN_NONE;
key=getInputRaw();
if(key != BTN_NONE)
while(key==getInputRaw()); // Wait for any release
return key;
}
uint8_t getInputWait(void) { uint8_t getInputWait(void) {
uint8_t key; uint8_t key;
while ((key=getInput())==BTN_NONE) while ((key=getInput())==BTN_NONE)

View File

@ -1,3 +1,5 @@
#include <string.h>
#include <display.h> #include <display.h>
#include <sysdefs.h> #include <sysdefs.h>
#include "lpc134x.h" #include "lpc134x.h"
@ -167,88 +169,86 @@ void lcdShiftH(bool right, bool wrap) {
if (right) { if (right) {
tmp = lcdBuffer[yb*RESX]; tmp = lcdBuffer[yb*RESX];
memmove(lcdBuffer + yb*RESX,lcdBuffer + yb*RESX+1 ,RESX-1); memmove(lcdBuffer + yb*RESX,lcdBuffer + yb*RESX+1 ,RESX-1);
if (wrap) lcdBuffer[yb*RESX+(RESX-1)] = tmp; lcdBuffer[yb*RESX+(RESX-1)] = wrap?tmp:0;
} else { } else {
tmp = lcdBuffer[yb*RESX+(RESX-1)]; tmp = lcdBuffer[yb*RESX+(RESX-1)];
memmove(lcdBuffer + yb*RESX+1,lcdBuffer + yb*RESX ,RESX-1); memmove(lcdBuffer + yb*RESX+1,lcdBuffer + yb*RESX ,RESX-1);
if (wrap) lcdBuffer[yb*RESX] = tmp; lcdBuffer[yb*RESX] = wrap?tmp:0;
} }
} }
} }
void lcdShiftV8(bool up, bool wrap) { void lcdShiftV8(bool up, bool wrap) {
uint8_t tmp[RESX]; uint8_t tmp[RESX];
if (up) { if (!up) {
if (wrap) memmove(tmp, lcdBuffer, RESX); if (wrap)
memmove(tmp, lcdBuffer, RESX);
else
memset(tmp,0,RESX);
memmove(lcdBuffer,lcdBuffer+RESX ,RESX*(RESY_B-1)); memmove(lcdBuffer,lcdBuffer+RESX ,RESX*(RESY_B-1));
if (wrap) memmove(lcdBuffer+RESX*(RESY_B-1),tmp,RESX); memmove(lcdBuffer+RESX*(RESY_B-1),tmp,RESX);
} else { } else {
if (wrap) memmove(tmp, lcdBuffer+RESX*(RESY_B-1), RESX); if (wrap)
memmove(tmp, lcdBuffer+RESX*(RESY_B-1), RESX);
else
memset(tmp,0,RESX);
memmove(lcdBuffer+RESX,lcdBuffer ,RESX*(RESY_B-1)); memmove(lcdBuffer+RESX,lcdBuffer ,RESX*(RESY_B-1));
if (wrap) memmove(lcdBuffer,tmp,RESX); memmove(lcdBuffer,tmp,RESX);
} }
} }
void lcdShiftV(bool up, bool wrap) { void lcdShiftV(bool up, bool wrap) {
uint8_t tmp[RESX]; uint8_t tmp[RESX];
if (up) { if (up) {
if (wrap) memmove(tmp,lcdBuffer+((RESY_B-1)*RESX),RESX); if (wrap)
memmove(tmp,lcdBuffer+((RESY_B-1)*RESX),RESX);
else
memset(tmp,0,RESX);
for (int x = 0; x<RESX; x++){ for (int x = 0; x<RESX; x++){
for (int y = RESY_B-1; y > 0; y--){ for (int y = RESY_B-1; y > 0; y--){
lcdBuffer[x+(y*RESX)] = (lcdBuffer[x+(y*RESX)] << 1) |( lcdBuffer[x+((y-1)*RESX)] >> 7); lcdBuffer[x+(y*RESX)] = (lcdBuffer[x+(y*RESX)] << 1) |( lcdBuffer[x+((y-1)*RESX)] >> 7);
} }
if (wrap) lcdBuffer[x] = ( lcdBuffer[x] << 1) | ((tmp[x]>>3)&1); lcdBuffer[x] = ( lcdBuffer[x] << 1) | ((tmp[x]>>3)&1);
} }
} else { } else {
if (wrap) memmove(tmp,lcdBuffer,RESX); if (wrap)
memmove(tmp,lcdBuffer,RESX);
else
memset(tmp,0,RESX);
for (int x = 0; x<RESX; x++){ for (int x = 0; x<RESX; x++){
for (int y = 0; y < (RESY_B-1); y++){ for (int y = 0; y < (RESY_B-1); y++){
lcdBuffer[x+(y*RESX)] = (lcdBuffer[x+(y*RESX)] >> 1) |( lcdBuffer[x+((y+1)*RESX)] << 7); lcdBuffer[x+(y*RESX)] = (lcdBuffer[x+(y*RESX)] >> 1) |( lcdBuffer[x+((y+1)*RESX)] << 7);
} }
if (wrap) lcdBuffer[x+((RESY_B-1)*RESX)] = ( lcdBuffer[x+((RESY_B-1)*RESX)] >> 1) | ((tmp[x]<<3)&8); lcdBuffer[x+((RESY_B-1)*RESX)] = ( lcdBuffer[x+((RESY_B-1)*RESX)] >> 1) | ((tmp[x]<<3)&8);
} }
} }
} }
void lcdShift(int x, int y, bool wrap) { void lcdShift(int x, int y, bool wrap) {
int yb, yr, ya; bool dir=true;
bool dir;
if (x>0) { if(x<0){
for (int cx = 0; cx < x; cx++) { dir=false;
lcdShiftH(true, wrap); x=-x;
} };
} else if (x<0) {
for (int cx = x; cx < 0; cx++) {
lcdShiftH(false, wrap);
}
}
while(x-->0)
lcdShiftH(dir, wrap);
if (y != 0) { if(y<0){
if (y>0) { dir=false;
ya = y; y=-y;
yb = y/8; }else{
yr = y%8; dir=true;
dir = true; };
} else if (y<0) { while(y>=8){
ya = -y; y-=8;
yb = (-y)/8; lcdShiftV8(dir, wrap);
yr = (-y)%8; };
dir = false;
}
//for (int cyb = 0; cyb < yb; cyb++) { while(y-->0)
// lcdShiftV8(dir, wrap);
//}
//for (int cyr = 0; cyr < yr; cyr++) {
// lcdShiftV(dir, wrap);
//}
for (int cya = 0; cya < ya; cya++) {
lcdShiftV(dir, wrap); lcdShiftV(dir, wrap);
}
}
} }

View File

@ -6,7 +6,15 @@
int x=0; int x=0;
int y=0; int y=0;
void checkScroll(void){
if(y+font->u8Height>RESY){
lcdShift(0,y+font->u8Height-RESY,false);
y=RESY-font->u8Height;
};
};
void lcdPrint(const char *string){ void lcdPrint(const char *string){
checkScroll();
x=DoString(x,y,string); x=DoString(x,y,string);
}; };
@ -20,18 +28,22 @@ void lcdPrintln(const char *string){
}; };
void lcdPrintInt(const int num){ void lcdPrintInt(const int num){
checkScroll();
x=DoInt(x,y,num); x=DoInt(x,y,num);
}; };
void lcdPrintIntHex(const int num){ void lcdPrintIntHex(const int num){
checkScroll();
x=DoIntX(x,y,num); x=DoIntX(x,y,num);
}; };
void lcdPrintCharHex(const uint8_t num){ void lcdPrintCharHex(const uint8_t num){
checkScroll();
x=DoCharX(x,y,num); x=DoCharX(x,y,num);
}; };
void lcdPrintShortHex(const uint16_t num){ void lcdPrintShortHex(const uint16_t num){
checkScroll();
x=DoShortX(x,y,num); x=DoShortX(x,y,num);
}; };

View File

@ -5,6 +5,13 @@ true
# echo $1 # echo $1
} }
if test ! -d simulat0r/firmware -o ! -d firmware
then
echo ERROR:
echo This script must be run from toplevel r0ket directory
exit
fi
echo "Updating directories" echo "Updating directories"
for i in `find firmware/ -type d ` for i in `find firmware/ -type d `
do do
@ -14,7 +21,7 @@ else mkdir -v simulat0r/$i
fi fi
done done
echo "Updating bridge files" echo "Updating bridge files for C source"
for i in `find firmware/ \! -path firmware/lcd/allfonts.h -type f -iname \*.[ch]` for i in `find firmware/ \! -path firmware/lcd/allfonts.h -type f -iname \*.[ch]`
do do
if test -f simulat0r/$i; if test -f simulat0r/$i;
@ -25,3 +32,15 @@ do
(printf "/* AUTOGENERATED SOURCE FILE */\n"; echo \#include \"`dirname $i | sed "s#[^/]*#..#g" `/../$i\") >simulat0r/$i (printf "/* AUTOGENERATED SOURCE FILE */\n"; echo \#include \"`dirname $i | sed "s#[^/]*#..#g" `/../$i\") >simulat0r/$i
fi fi
done done
echo "Updating bridge files for Makefiles"
for i in `find firmware/ -type f -iname Makefile`
do
if test -f simulat0r/$i;
then
verbmsg "OK File already exists: $i"
else
echo Writing bridge file simulat0r/$i
(printf "# GENERATED INCLUDE BRIDGE/\n"; echo include `dirname $i | sed "s#[^/]*#..#g" `/../$i) >simulat0r/$i
fi
done

View File

@ -1,108 +1,4 @@
VPATH = # GENERATED INCLUDE BRIDGE/
OBJS = main.o include ../../firmware/Makefile
##########################################################################
# Project-specific files
##########################################################################
VPATH +=
OBJS +=
OBJS += basic/basic.o basic/reinvoke_isp.o basic/delayms.o basic/voltage.o
OBJS += basic/keyin.o basic/uuid.o
LIBS += core/libcore.a lcd/liblcd.a applications/libapp.a filesystem/libfat.a usb/libusb.a
##########################################################################
# GNU GCC compiler flags
##########################################################################
ROOT_PATH = .
INCLUDE_PATHS = -I$(ROOT_PATH) -I$(ROOT_PATH)/core
include $(ROOT_PATH)/Makefile.inc
LDFLAGS+= -Wl,--gc-sections
VPATH += lpc1xxx
OBJS += $(TARGET)_handlers.o LPC1xxx_startup.o
##########################################################################
# Startup files
##########################################################################
LDLIBS = -lm
LDLIBS += -Lapplications -lapp
LDLIBS += -Lfunk -lfunk
LDLIBS += -Lusbcdc -lusbcdc
LDLIBS += -Lfilesystem -lfat
LDLIBS += -Lbasic -lbasic
LDLIBS += -Llcd -llcd
LDLIBS += -Lcore -lcore
LDLIBS += -Lusb -lusb
LD_PATH = lpc1xxx
LD_SCRIPT = $(LD_PATH)/linkscript.ld
LD_TEMP = $(LD_PATH)/memory.ld
### User targets:
all: $(OUTFILE).bin
protect: $(OUTFILE).bin
$(LPCFIX) -p 2 $(OUTFILE).bin
loadables: $(OUTFILE).bin
@cd loadable && $(MAKE)
clean:
rm -f $(OBJS) $(LD_TEMP) $(OUTFILE).elf $(OUTFILE).bin $(OUTFILE).hex
@cd core && $(MAKE) clean
# @cd ../tools/bootloader && $(MAKE) clean
@cd lcd && $(MAKE) clean
@cd applications && $(MAKE) clean
@cd filesystem && $(MAKE) clean
@cd usb && $(MAKE) clean
@cd loadable && $(MAKE) clean
### Internal targets
%.o : %.c
$(CC) $(CFLAGS) -o $@ $<
core/libcore.a: core/projectconfig.h
cd core && $(MAKE) ROOT_PATH=../$(ROOT_PATH)
lcd/liblcd.a lcd/render.o lcd/display.o:
cd lcd && $(MAKE) ROOT_PATH=../$(ROOT_PATH)
applications/libapp.a:
cd applications && $(MAKE) ROOT_PATH=../$(ROOT_PATH)
filesystem/libfat.a:
cd filesystem && $(MAKE) ROOT_PATH=../$(ROOT_PATH)
usb/libusb.a:
cd usb && $(MAKE) ROOT_PATH=../$(ROOT_PATH)
../tools/bootloader/lpcfix:
# cd ../tools/bootloader && $(MAKE)
$(LD_TEMP):
-@echo "MEMORY" > $(LD_TEMP)
-@echo "{" >> $(LD_TEMP)
-@echo " flash(rx): ORIGIN = 0x00000000, LENGTH = $(FLASH)" >> $(LD_TEMP)
-@echo " sram(rwx): ORIGIN = 0x10000000+$(SRAM_USB), LENGTH = $(SRAM)-$(SRAM_USB)-$(RAMCODE)" >> $(LD_TEMP)
-@echo "}" >> $(LD_TEMP)
-@echo "INCLUDE $(LD_SCRIPT)" >> $(LD_TEMP)
.IGNORE: $(OUTFILE).elf
$(OUTFILE).elf: $(OBJS) $(SYS_OBJS) $(LIBS) $(LPCFIX) $(LD_TEMP)
$(CC) $(LDFLAGS) -T $(LD_TEMP) -o $(OUTFILE).elf $(OBJS) $(LDLIBS)
-@echo ""
# $(SIZE) $(OUTFILE).elf
# -@echo ""
%.bin: %.elf
# $(OBJCOPY) $(OCFLAGS) -O binary $< $@
-@echo ""
# $(LPCFIX) -c $@
.PHONY: $(LD_TEMP) lcd/liblcd.a applications/libapp.a filesystem/libfat.a usb/libusb.a
.IGNORE: $(OUTFILE).elf $(OUTFILE).bin

View File

@ -1,66 +1,2 @@
########################################################################## # GENERATED INCLUDE BRIDGE/
# User configuration and firmware specific object files include ../../../firmware/applications/Makefile
##########################################################################
OBJS = default.o
OBJS += $(foreach mod,$(APP),$(mod).o)
SRCS = $(foreach mod,$(APP),$(mod).c)
ifndef APP
ME_OBJ=$(USERNAME)
ifeq "$(ME_OBJ)" ""
ME_OBJ=$(USER)
endif
ifeq "$(ME_OBJ)" ""
ME_OBJ=nouser
endif
OBJS += $(ME_OBJ).o
endif
WRAP=wrapper
LIBNAME=app
##########################################################################
# GNU GCC compiler flags
##########################################################################
ROOT_PATH?= ..
INCLUDE_PATHS = -I$(ROOT_PATH) -I../core -I.
include $(ROOT_PATH)/Makefile.inc
WRAPOBJ=$(WRAP).o
WRAPSRC=$(WRAP).c
LIBFILE=lib$(LIBNAME).a
##########################################################################
# Compiler settings, parameters and flags
##########################################################################
all: $(LIBFILE)
$(LIBFILE): $(OBJS) $(WRAPOBJ)
$(AR) rcs $@ $(OBJS) $(WRAPOBJ)
%.o : %.c
$(CC) $(CFLAGS) -o $@ $<
clean:
rm -f $(OBJS) $(WRAPOBJ) $(WRAPSRC) $(LIBFILE) *.o
%.c:
@echo
@echo "You need to create $@ first"
@echo "It should contain a single function void main_filename(void)"
@echo
@exit 1
$(WRAPSRC):
./mkwrapper $(OBJS) > $@
.PHONY: $(LIBFILE) $(WRAPSRC) $(SRCS)
.SUFFIXES:

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/cbitset.h"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/flame.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/loadable.c"

View File

@ -0,0 +1,2 @@
# GENERATED INCLUDE BRIDGE/
include ../../../firmware/basic/Makefile

View File

@ -1,2 +1,4 @@
/* AUTOGENERATED SOURCE FILE */ /* use SAFE version instead of ARM asm */
#define SAFE
#include "../../../firmware/basic/xxtea.c" #include "../../../firmware/basic/xxtea.c"

View File

@ -1,56 +1,2 @@
########################################################################## # GENERATED INCLUDE BRIDGE/
# User configuration and firmware specific object files include ../../../firmware/core/Makefile
##########################################################################
# The target, flash and ram of the LPC1xxx microprocessor.
# Use for the target the value: LPC11xx, LPC13xx or LPC17xx
TARGET = LPC13xx
OBJS = sysinit.o
OBJS += adc/adc.o
#OBJS += cmd/cmd.o
OBJS += cpu/cpu.o
OBJS += gpio/gpio.o
OBJS += i2c/i2c.o
OBJS += iap/iap.o
OBJS += libc/ctype.o
OBJS += libc/stdio.o
OBJS += libc/string.o
OBJS += pmu/pmu.o
#OBJS += pwm/pwm.o
OBJS += ssp/ssp.o
OBJS += systick/systick.o
OBJS += timer16/timer16.o
OBJS += timer32/timer32.o
#OBJS += uart/uart.o
#OBJS += uart/uart_buf.o
#OBJS += usbcdc/cdcuser.o
#OBJS += usbcdc/cdc_buf.o
#OBJS += usbcdc/usbcore.o
#OBJS += usbcdc/usbdesc.o
#OBJS += usbcdc/usbhw.o
#OBJS += usbcdc/usbuser.o
OBJS += wdt/wdt.o
##########################################################################
# GNU GCC compiler flags
##########################################################################
ROOT_PATH?= ..
INCLUDE_PATHS = -I$(ROOT_PATH) -I.
include $(ROOT_PATH)/Makefile.inc
##########################################################################
# Compiler settings, parameters and flags
##########################################################################
all: libcore.a
libcore.a: $(OBJS)
$(AR) rcs libcore.a $(OBJS)
%.o : %.c projectconfig.h
$(CC) $(CFLAGS) -o $@ $<
clean:
rm -f $(OBJS) libcore.a

View File

@ -1,2 +1,34 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/i2c/i2c.c" // dummy implementation instead of #include "../../../../firmware/core/i2c/i2c.c"
#include "i2c.h"
volatile uint32_t I2CMasterState = I2CSTATE_IDLE;
volatile uint32_t I2CSlaveState = I2CSTATE_IDLE;
volatile uint8_t I2CMasterBuffer[I2C_BUFSIZE];
volatile uint8_t I2CSlaveBuffer[I2C_BUFSIZE];
volatile uint32_t I2CReadLength;
volatile uint32_t I2CWriteLength;
volatile uint32_t RdIndex = 0;
volatile uint32_t WrIndex = 0;
void I2C_IRQHandler(void) {
}
uint32_t i2cInit( uint32_t I2cMode ) {
return( TRUE );
}
uint32_t i2cEngine( void ) {
return I2CSTATE_IDLE;
}
/******************************************************************************
** End Of File
******************************************************************************/

View File

@ -1,30 +1,2 @@
########################################################################## # GENERATED INCLUDE BRIDGE/
# User configuration and firmware specific object files include ../../../firmware/filesystem/Makefile
##########################################################################
OBJS =
OBJS += ff.o
OBJS += diskio.o
OBJS += iobase.o
OBJS += mmc.o
OBJS += at45db041d.o
OBJS += util.o
OBJS += select.o
OBJS += execute.o
LIBNAME=fat
##########################################################################
# GNU GCC compiler flags
##########################################################################
ROOT_PATH?= ..
INCLUDE_PATHS = -I$(ROOT_PATH) -I../core -I.
include $(ROOT_PATH)/Makefile.inc
##########################################################################
# Actual work
##########################################################################
include $(ROOT_PATH)/Makefile.util

View File

@ -1,25 +1,2 @@
########################################################################## # GENERATED INCLUDE BRIDGE/
# User configuration and firmware specific object files include ../../../firmware/funk/Makefile
##########################################################################
OBJS =
OBJS += nrf24l01p.o
OBJS += rftransfer.o
OBJS += filetransfer.o
LIBNAME=funk
##########################################################################
# GNU GCC compiler flags
##########################################################################
ROOT_PATH?= ..
INCLUDE_PATHS = -I$(ROOT_PATH) -I../core -I.
include $(ROOT_PATH)/Makefile.inc
##########################################################################
# Actual work
##########################################################################
include $(ROOT_PATH)/Makefile.util

View File

@ -1,45 +1,2 @@
########################################################################## # GENERATED INCLUDE BRIDGE/
# User configuration and firmware specific object files include ../../../firmware/lcd/Makefile
##########################################################################
OBJS =
OBJS += display.o
OBJS += render.o
OBJS += decoder.o
OBJS += backlight.o
OBJS += print.o
FONTS = $(basename $(wildcard fonts/*.c))
LIBNAME=lcd
##########################################################################
# GNU GCC compiler flags
##########################################################################
ROOT_PATH?= ..
INCLUDE_PATHS = -I$(ROOT_PATH) -I../core -I.
include $(ROOT_PATH)/Makefile.inc
FOBJS= $(foreach ft,$(FONTS),$(ft).o)
OBJS+= $(FOBJS)
##########################################################################
# Actual work
##########################################################################
include $(ROOT_PATH)/Makefile.util
all: allfonts.h
$(FOBJS): $(foreach ft,$(FONTS),$(ft).h) fonts.h
clean::
rm -f fonts/*.o allfonts.h
touch allfonts.h
.PHONY: allfonts.h
allfonts.h:
(echo "#include <lcd/fonts.h>";for a in $(FONTS) ; do echo "#include <lcd/$$a.h>"; done) > $@

View File

@ -1,56 +1,14 @@
#if 0 #define lcdDisplay _hideaway_lcdDisplay
#include "../firmware/lcd/display.c" #define lcdInit _hideaway_lcdInit
#else #include "../../../firmware/lcd/display.c"
#undef lcdDisplay
#undef lcdInit
#include "../firmware/lcd/display.h"
#include "simulator.h" #include "simulator.h"
uint8_t lcdBuffer[RESX*RESY_B];
int lcd_layout = 0;
const int TYPE_DATA=0;
void lcdInit(void) {
fprintf(stderr,"lcdInit(void)\n");
}
void lcdFill(char f){
int x;
for(x=0;x<RESX*RESY_B;x++) {
lcdBuffer[x]=f;
}
};
void lcdSetPixel(char x, char y, bool f){
char y_byte = (RESY-(y+1)) / 8;
char y_off = (RESY-(y+1)) % 8;
char byte = lcdBuffer[y_byte*RESX+(RESX-(x+1))];
if (f) {
byte |= (1 << y_off);
} else {
byte &= ~(1 << y_off);
}
lcdBuffer[y_byte*RESX+(RESX-(x+1))] = byte;
}
bool lcdGetPixel(char x, char y){
char y_byte = (RESY-(y+1)) / 8;
char y_off = (RESY-(y+1)) % 8;
char byte = lcdBuffer[y_byte*RESX+(RESX-(x+1))];
return byte & (1 << y_off);
}
void lcdDisplay() { void lcdDisplay() {
simlcdDisplayUpdate(); simlcdDisplayUpdate();
} }
inline void lcdInvert(void) { void lcdInit() {
lcdToggleFlag(LCD_INVERTED);
} }
void lcdToggleFlag(int flag) {
lcd_layout=lcd_layout ^ flag;
}
#endif

View File

@ -1,5 +1,13 @@
/* /*
This header is "gcc -include"d for all compilations of firmware files when building as simulat0r. This header is "gcc -include"d for all compilations of firmware files when building as simulat0r.
*/
/*
The following symbols are expected from r0ket firmware to come from libc
*/
#define siprintf sprintf
/*
The following symbols were found to be defined within glibc. The following symbols were found to be defined within glibc.
Use different names within simulat0r to keep the firmware and simulat0r-host universes collision-free. Use different names within simulat0r to keep the firmware and simulat0r-host universes collision-free.
*/ */

View File

@ -1,12 +1,2 @@
# Make doesn't allow dependencies on parent directory, so we need to # GENERATED INCLUDE BRIDGE/
# run make from one level up: include ../../../firmware/loadable/Makefile
MAKEFILE=loadable/Makefile.sub
MAKE+=--no-print-directory
all:
@cd .. && $(MAKE) -f $(MAKEFILE)
clean:
@cd .. && $(MAKE) -f $(MAKEFILE) clean

View File

@ -1,57 +0,0 @@
DIR?= loadable
##########################################################################
# User configuration and firmware specific object files
##########################################################################
SRCS = $(wildcard $(DIR)/*.c)
OBJS = $(foreach mod,$(SRCS),$(subst .c,.o,$(mod)))
ELFS = $(foreach mod,$(SRCS),$(subst .c,.elf,$(mod)))
BINS = $(foreach mod,$(SRCS),$(subst .c,.bin,$(mod)))
HDRS = $(foreach mod,$(SRCS),$(subst .c,.h,$(mod)))
##########################################################################
# GNU GCC compiler flags
##########################################################################
ROOT_PATH?= .
INCLUDE_PATHS = -I$(ROOT_PATH) -I$(ROOT_PATH)/core
include $(ROOT_PATH)/Makefile.inc
##########################################################################
# Compiler settings, parameters and flags
##########################################################################
FIRMWARE=$(ROOT_PATH)/$(OUTFILE).elf
LDSRCFILE=$(DIR)/ram.ld
LDFILE=$(DIR)/loadable.ld
CFLAGS+=-mlong-calls -fno-toplevel-reorder
LDFLAGS+= -R $(FIRMWARE)
all: $(OBJS) $(ELFS) $(BINS) $(HDRS)
$(LDFILE):
-@echo "MEMORY" > $(LDFILE)
-@echo "{" >> $(LDFILE)
-@echo " sram(rwx): ORIGIN = 0x10002000 - $(RAMCODE), LENGTH = $(RAMCODE)" >> $(LDFILE)
-@echo "}" >> $(LDFILE)
-@echo "INCLUDE $(LDSRCFILE)" >> $(LDFILE)
%.o : %.c
$(CC) $(CFLAGS) -o $@ $<
%.elf: %.o $(FIRMWARE) $(LDFILE)
$(LD) $(LDFLAGS) -T $(LDFILE) -o $@ $<
$(SIZE) $@
%.bin: %.elf
$(OBJCOPY) $(OCFLAGS) -O binary $< $@
%.h: %.bin $(DIR)/bin2h.pl
$(DIR)/bin2h.pl $<
clean:
cd $(DIR) && rm -f *.o *.elf *.bin
.SUFFIXES:
.PHONY: $(LDFILE)

View File

@ -1,36 +1,2 @@
########################################################################## # GENERATED INCLUDE BRIDGE/
# User configuration and firmware specific object files include ../../../firmware/usb/Makefile
##########################################################################
OBJS =
OBJS += usbconfig.o
OBJS += usbhid.o
OBJS += usbmsc.o
LIBNAME=usb
##########################################################################
# GNU GCC compiler flags
##########################################################################
ROOT_PATH?= ..
INCLUDE_PATHS = -I$(ROOT_PATH) -I../core -I.
include $(ROOT_PATH)/Makefile.inc
LIBFILE=lib$(LIBNAME).a
##########################################################################
# Compiler settings, parameters and flags
##########################################################################
all: $(LIBFILE)
$(LIBFILE): $(OBJS)
$(AR) rcs $@ $(OBJS)
%.o : %.c
$(CC) $(CFLAGS) -o $@ $<
clean:
rm -f $(OBJS) $(LIBFILE)

View File

@ -0,0 +1,2 @@
# GENERATED INCLUDE BRIDGE/
include ../../../firmware/usbcdc/Makefile

View File

@ -7,6 +7,10 @@ link_directories(${CMAKE_CURRENT_BINARY_DIR}
../../firmware/applications ../../firmware/applications
../../firmware/filesystem ../../firmware/filesystem
../../firmware/lcd ../../firmware/lcd
../../firmware/funk
../../firmware/basic
../../firmware/core
../../firmware/usbcdc
../../firmware/usb) ../../firmware/usb)
include(${QT_USE_FILE}) include(${QT_USE_FILE})
@ -27,28 +31,6 @@ QT_WRAP_CPP(qsimulat0r MocSources ${qsimulat0r_SRCS})
set(FIRMWARE_OBJS set(FIRMWARE_OBJS
../simcore/simcore.o ../simcore/simcore.o
../simcore/misc.o ../simcore/misc.o
../firmware/basic/basic.o
../firmware/basic/reinvoke_isp.o
../firmware/basic/delayms.o
../firmware/basic/uuid.o
../firmware/basic/keyin.o
../firmware/basic/voltage.o
../firmware/core/sysinit.o
../firmware/core/adc/adc.o
../firmware/core/cpu/cpu.o
../firmware/core/gpio/gpio.o
../firmware/core/i2c/i2c.o
../firmware/core/iap/iap.o
../firmware/core/libc/ctype.o
../firmware/core/libc/stdio.o
../firmware/core/libc/string.o
../firmware/core/pmu/pmu.o
../firmware/core/ssp/ssp.o
../firmware/core/systick/systick.o
../firmware/core/timer16/timer16.o
../firmware/core/timer32/timer32.o
../firmware/core/wdt/wdt.o
) )
@ -62,7 +44,17 @@ add_executable(qsimulat0r ${qsimulat0r_SRCS} ${MocSources}
${FIRMWARE_OBJS} ${FIRMWARE_OBJS}
) )
target_link_libraries(qsimulat0r ${QT_LIBRARIES} libapp.a liblcd.a libusb.a libfat.a) target_link_libraries(qsimulat0r
${QT_LIBRARIES}
libapp.a
liblcd.a
libusb.a
libfat.a
libfunk.a
libusbcdc.a
libbasic.a
libcore.a
)

View File

@ -27,6 +27,15 @@ extern int lcd_layout;
time_t starttime; time_t starttime;
long framecount=0; long framecount=0;
const int colorGreenLED=QColor(0,255,0).rgb();
const int colorRedLED=QColor(255,0,0).rgb();
const int colorOffLED=QColor(64,64,64).rgb();
const int colorPixelOn=QColor(255,192,0).rgb();
const int colorPixelOff=QColor(64,64,64).rgb();
const int colorInvertedPixelOn=QColor(128,128,128).rgb(); // inverted and on => dark
const int colorInvertedPixelOff=QColor(128,255,128).rgb(); // inverted and off => bright
class LCD : public QWidget { class LCD : public QWidget {
public: public:
static const int ledsize=10; static const int ledsize=10;
@ -41,8 +50,8 @@ public:
static const int dimx=RESX; //96; static const int dimx=RESX; //96;
static const int dimy=RESY; static const int dimy=RESY;
void drawLED(QImage& pixmap,int led, int x, int y) { void drawLED(QImage& pixmap,int led, int x, int y,int colorOn) {
int color=simGetLED(led)?QColor(255,0,0).rgb():QColor(64,64,64).rgb(); int color=simGetLED(led)?colorOn:colorOffLED;
for(int minix=0; minix<ledsize; ++minix) { for(int minix=0; minix<ledsize; ++minix) {
for(int miniy=0; miniy<ledsize; ++miniy) { for(int miniy=0; miniy<ledsize; ++miniy) {
pixmap.setPixel(x+minix,y+miniy,color); pixmap.setPixel(x+minix,y+miniy,color);
@ -63,9 +72,9 @@ public:
for(int y=0; y<dimy; ++y) { for(int y=0; y<dimy; ++y) {
int color; int color;
if(lcd_layout & LCD_INVERTED) { if(lcd_layout & LCD_INVERTED) {
color=lcdGetPixel((lcd_layout & LCD_MIRRORX)?(RESX-x-1):x,(lcd_layout & LCD_MIRRORY)?(RESY-y-1):y)?QColor(128,128,128).rgb():QColor(128,255,128).rgb(); color=lcdGetPixel((lcd_layout & LCD_MIRRORX)?(RESX-x-1):x,(lcd_layout & LCD_MIRRORY)?(RESY-y-1):y)?colorInvertedPixelOn:colorInvertedPixelOff;
} else { } else {
color=lcdGetPixel((lcd_layout & LCD_MIRRORX)?(RESX-x-1):x,(lcd_layout & LCD_MIRRORY)?(RESY-y-1):y)?QColor(255,192,0).rgb():QColor(64,64,64).rgb(); color=lcdGetPixel((lcd_layout & LCD_MIRRORX)?(RESX-x-1):x,(lcd_layout & LCD_MIRRORY)?(RESY-y-1):y)?colorPixelOn:colorPixelOff;
} }
for(int minix=0; minix<pixw; ++minix) { for(int minix=0; minix<pixw; ++minix) {
for(int miniy=0; miniy<pixh; ++miniy) { for(int miniy=0; miniy<pixh; ++miniy) {
@ -77,10 +86,10 @@ public:
const int x1=dimx*rasterx-1-ledsize; const int x1=dimx*rasterx-1-ledsize;
const int y1=dimy*rastery-1+2*ledsep+ledsize; const int y1=dimy*rastery-1+2*ledsep+ledsize;
drawLED(pixmap,0,0,0); drawLED(pixmap,0,x1,y1,colorGreenLED);
drawLED(pixmap,1,x1,0); drawLED(pixmap,1,0,0,colorGreenLED);
drawLED(pixmap,2,0,y1); drawLED(pixmap,2,0,y1,colorGreenLED);
drawLED(pixmap,3,x1,y1); drawLED(pixmap,3,x1,0,colorRedLED);
painter.drawImage(0,0,pixmap); painter.drawImage(0,0,pixmap);
} }

View File

@ -1,6 +1,3 @@
int crc16(int x) {
}
void __disable_irq() { void __disable_irq() {
} }

View File

@ -3,10 +3,7 @@
#include <stdint.h> #include <stdint.h>
void simlcdPrepareUpdate(); void simlcdDisplayUpdate();
void simlcdWrite(int ignored, int bit);
void simlcdLineFeed();
void simlcdCompleteUpdate();
int simButtonPressed(int button); int simButtonPressed(int button);