From a63b81a66b0fb194e2ce2e11b6b7b5f159192533 Mon Sep 17 00:00:00 2001 From: Sebastian Steuer Date: Mon, 13 Jun 2011 19:55:51 +0200 Subject: [PATCH] lcdSetPixel implemented --- lcd/display.c | 11 ++++ lcd/display.h | 1 + modules/iggy.c | 154 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 166 insertions(+) create mode 100644 modules/iggy.c diff --git a/lcd/display.c b/lcd/display.c index 659f242..80cdde3 100644 --- a/lcd/display.c +++ b/lcd/display.c @@ -154,6 +154,17 @@ void lcdFill(char 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)%RESX]; + if (f) { + byte |= (1 << y_off); + } else { + byte &= ~(1 << y_off); + } + lcdBuffer[y_byte*RESX+(RESX-x)%RESX] = byte; +} void lcdDisplay(uint32_t shift) { lcdWrite(0,0xB0); diff --git a/lcd/display.h b/lcd/display.h index 9d98e15..b68ab55 100644 --- a/lcd/display.h +++ b/lcd/display.h @@ -23,5 +23,6 @@ void lcdInit(void); void lcdFill(char f); void lcdDisplay(uint32_t shift); void lcdInvert(void); +void lcdSetPixel(char x, char y, bool f); #endif diff --git a/modules/iggy.c b/modules/iggy.c new file mode 100644 index 0000000..652b8a7 --- /dev/null +++ b/modules/iggy.c @@ -0,0 +1,154 @@ +#include + +#include "basic/basic.h" + +#include "lcd/render.h" +#include "lcd/display.h" +#include "lcd/allfonts.h" + +void ReinvokeISP(void); +void EnableWatchdog(uint32_t ms); +void delayms(uint32_t ms); + +/**************************************************************************/ + +void module_iggy(void) { + //Make PIO1_11 an analog input + gpioSetDir(RB_LED3, gpioDirection_Input); + IOCON_PIO1_11 = 0x41; + + backlightInit(); + + uint32_t j=0; + + //disable the JTAG on PIO3_3 + IOCON_PIO3_3 = 0x10; + + int yctr=8; + int dx=0; + + font_direction = FONT_DIR_LTR; // LeftToRight is the default + font = &Font_8x8; + + static FONT fonts[] = { + &Font_7x8, + &Font_Ubuntu18pt, // 3 byte-font + &Font_8x8, + }; + + int fontctr=0; + yctr=18; + + uint8_t trigger; + +#define SEND +#ifdef SEND + trigger=200; + gpioSetDir(RB_LED0, gpioDirection_Output); + IOCON_JTAG_TDI_PIO0_11 = 0x11; +#else + trigger=380; + gpioSetDir(RB_LED0, gpioDirection_Input); + IOCON_JTAG_TDI_PIO0_11 = 0x42; +#endif + + bool on = true; + uint32_t ctr=0; + while (1) { + ctr++; + uint32_t results; + lcdDisplay(j); + delayms(10); + + font=fonts[fontctr]; + + if(gpioGetValue(RB_BTN3)==0){ + while(gpioGetValue(RB_BTN3)==0); + trigger +=10; + }; + if(gpioGetValue(RB_BTN2)==0){ + while(gpioGetValue(RB_BTN2)==0); + trigger -=10; + }; + + for(char x=0; xtrigger/10){ + ctr=0; + if (gpioGetValue(RB_LED0) == CFG_LED_OFF){ + gpioSetValue (RB_LED0, CFG_LED_ON); +// DoString(dx,14,"ON!"); + on = true; + } else { + gpioSetValue (RB_LED0, CFG_LED_OFF); +// DoString(dx,14,"off"); + on = false; + }; + }; +#else + results = adcRead(0); + DoInt(dx,20,results); + + if(results>trigger){ + DoString(dx,30,"YES!"); + }else{ + DoString(dx,30," no "); + }; + +#endif + font = &Font_7x8; + + results = adcRead(1); + dx=DoString(0,yctr+28,"Voltage:"); + results *= 10560; + results /= 1024; + DoInt(dx,yctr+28,results); + + if( results < 3500 ){ + DoString(0,yctr+30,"Shutdown"); + gpioSetValue (RB_PWR_GOOD, 0); + gpioSetValue (RB_LCD_BL, 0); + SCB_SCR |= SCB_SCR_SLEEPDEEP; + PMU_PMUCTRL = PMU_PMUCTRL_DPDEN_DEEPPOWERDOWN; + __asm volatile ("WFI"); + }else{ + //DoString(0,yctr+30,"OK "); + ; + } + + } + + return; +}