From: hackbard Date: Tue, 11 Sep 2007 22:19:15 +0000 (+0200) Subject: some display testing (doesn't work by now!) X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=2c6f5744c29fb65d904aa5fe40b5ce541247f900;p=my-code%2Farm.git some display testing (doesn't work by now!) --- diff --git a/betty/betty.c b/betty/betty.c index 859860a..200bd6f 100644 --- a/betty/betty.c +++ b/betty/betty.c @@ -47,15 +47,20 @@ int main() { /* pause - seems to not work if running from flash! (?) */ pause(0xffffff); + /* display init */ + display_init(); + + /* pasue again */ + /* announce */ uart0_send_string(announce); - /* toggle backlight */ - display_bl_toggle(); - //addr=0x82000000; - flash_sector_erase(BANK2,0); - addr=FLASH_BANK2; + //flash_sector_erase(BANK2,0); + //addr=FLASH_BANK2; + + DISPLAY_SET_C_ADDR(0); + DISPLAY_SET_PAGE_ADDR(0); while(1) { pause(0x0fffff); @@ -64,9 +69,8 @@ int main() { if(button_get_event(&button)) { uart0_send_string(announce); if(button.key[0]==BUTTON_POWER) { - display_bl_toggle(); - flash_write_buf(addr,(u16 *)announce,42); - addr+=64; + DISPLAY_DATA=0xff; + DISPLAY_DATA=0xff; } } } diff --git a/betty/display.c b/betty/display.c index 210cd17..fad0804 100644 --- a/betty/display.c +++ b/betty/display.c @@ -11,9 +11,44 @@ * functions */ +void display_clear_screen(void) { + + u32 cnt; + + DISPLAY_SET_PAGE_ADDR(0); + DISPLAY_SET_C_ADDR(0); + + for(cnt=0;cnt>4)) +#define DISPLAY_SET_MASTER DISPLAY_CMD=0x18 +#define DISPLAY_SET_SLAVE DISPLAY_CMD=0x19 +#define DISPLAY_SET_REGULATOR(r) DISPLAY_CMD=(0x20|((r)&0x07)) +#define DISPLAY_SET_POWER(p) DISPLAY_CMD=(0x28|((p)&0x07)) +#define DISPLAY_V_BOOST 0x01 +#define DISPLAY_REGULATOR 0x02 +#define DISPLAY_OPAMP 0x04 +#define DISPLAY_SET_START_LINE(s) DISPLAY_CMD=0x40; \ + DISPLAY_CMD=(s) +#define DISPLAY_SET_OFFSET(o) DISPLAY_CMD=0x44; \ + DISPLAY_CMD=(o) +#define DISPLAY_SET_MPLEX_RATIO(m) DISPLAY_CMD=0x48; \ + DISPLAY_CMD=(m) +#define DISPLAY_SET_NINV(n) DISPLAY_CMD=0x4c; \ + DISPLAY_CMD=(n) +#define DISPLAY_SET_BIAS(b) DISPLAY_CMD=(0x50|((b)&0x07)) +#define DISPLAY_SET_UW_CORNER_X(x) DISPLAY_CMD=0x60; \ + DISPLAY_CMD=((x)&0x7f) +#define DISPLAY_SET_UW_CORNER_Y(y) DISPLAY_CMD=0x61; \ + DISPLAY_CMD=(y) +#define DISPLAY_SET_LW_CORNER_X(x) DISPLAY_CMD=0x62; \ + DISPLAY_CMD=((x)&0x7f) +#define DISPLAY_SET_LW_CORNER_Y(y) DISPLAY_CMD=0x63; \ + DISPLAY_CMD=(y) +#define DISPLAY_SET_CONV_FACTOR(c) DISPLAY_CMD=(0x64|((c)&0x03)) +#define DISPLAY_SET_CONTRAST(c) DISPLAY_CMD=0x81; \ + DISPLAY_CMD=((c)&0x3f) +#define DISPLAY_SET_WHITE(a,b,c,d) DISPLAY_CMD=0x88; \ + DISPLAY_CMD=(((b)&0x0f)<<4|((a)&0x0f)); \ + DISPLAY_CMD=0x89; \ + DISPLAY_CMD=(((d)&0x0f)<<4|((c)&0x0f)) +#define DISPLAY_SET_LGRAY(a,b,c,d) DISPLAY_CMD=0x8a; \ + DISPLAY_CMD=(((b)&0x0f)<<4|((a)&0x0f)); \ + DISPLAY_CMD=0x8b; \ + DISPLAY_CMD=(((d)&0x0f)<<4|((c)&0x0f)) +#define DISPLAY_SET_DGRAY(a,b,c,d) DISPLAY_CMD=0x8c; \ + DISPLAY_CMD=(((b)&0x0f)<<4|((a)&0x0f)); \ + DISPLAY_CMD=0x8d; \ + DISPLAY_CMD=(((d)&0x0f)<<4|((c)&0x0f)) +#define DISPLAY_SET_BLACK(a,b,c,d) DISPLAY_CMD=0x88; \ + DISPLAY_CMD=(((b)&0x0f)<<4|((a)&0x0f)); \ + DISPLAY_CMD=0x89; \ + DISPLAY_CMD=(((d)&0x0f)<<4|((c)&0x0f)) +#define DISPLAY_SET_PWM_FRC(p,f) DISPLAY_CMD=(0x90|(((f&0x01)<<2)|p&0x03)) +#define DISPLAY_SET_SEGMENT_REMAP_00H DISPLAY_CMD=0xa0 +#define DISPLAY_SET_SEGMENT_REMAP_7fH DISPLAY_CMD=0xa1 +#define DISPLAY_RAM_CONTENTS_ON DISPLAY_CMD=0xa4 +#define DISPLAY_ENTIRE_ON DISPLAY_CMD=0xa5 +#define DISPLAY_NORMAL DISPLAY_CMD=0xa6 +#define DISPLAY_REVERSE DISPLAY_CMD=0xa7 +#define DISPLAY_SET_POWER_SAVE DISPLAY_CMD=0xa9 +#define DISPLAY_START_OSCILLATOR DISPLAY_CMD=0xab +#define DISPLAY_SET_OFF DISPLAY_CMD=0xae +#define DISPLAY_SET_ON DISPLAY_CMD=0xaf +#define DISPLAY_SET_PAGE_ADDR(p) DISPLAY_CMD=0xb0; \ + DISPLAY_CMD=((p)&0x1f) +#define DISPLAY_SET_COM_ODIR_NORMAL DISPLAY_CMD=0xc0 +#define DISPLAY_SET_COM_ODIR_REMAPPED DISPLAY_CMD=0xc8 +#define DISPLAY_EXIT_POWER_SAVE DISPLAY_CMD=0xe1 +#define DISPLAY_SOFT_RESET DISPLAY_CMD=0xe2 +#define DISPLAY_EXIT_NLINE_INVERSION DISPLAY_CMD=0xe4 +#define DISPLAY_SCROLL_BUF_ENABLE DISPLAY_CMD=0xe6 +#define DISPLAY_SCROLL_BUF_DISABLE DISPLAY_CMD=0xe7 +#define DISPLAY_SET_TC(c) DISPLAY_CMD=0xe9; \ + DISPLAY_CMD=(c) +#define DISPLAY_EXTENDED_FEATURES DISPLAY_CMD=0xf0 + /* function prototypes */ void display_bl_init(void); void display_bl_toggle(void);