//inicjalizacja sterownika void LcdInit(void) { int i; HAL_GPIO_WritePin(PORT_DISP_NOKIA,LCD_PWR,GPIO_PIN_RESET); HAL_GPIO_WritePin(PORT_DISP_NOKIA,LCD_BKLT,GPIO_PIN_RESET); delay_ms(500); HAL_GPIO_WritePin(PORT_DISP_NOKIA,LCD_BKLT,GPIO_PIN_SET); HAL_GPIO_WritePin(PORT_DISP_NOKIA,LCD_PWR,GPIO_PIN_SET); HAL_GPIO_WritePin(PORT_DISP_NOKIA,RES,GPIO_PIN_RESET); delay_ms(2); HAL_GPIO_WritePin(PORT_DISP_NOKIA,RES,GPIO_PIN_SET); WriteCmd(0x21);//komendy rozszerzone WriteCmd(0x05);//komenda „przelaczajaca” sterownik w tryb pracy zgodny PCD8544 WriteCmd(0xd5);//ustawienie Vop Delay(2); //WriteCmd(0x13);//bias WriteCmd(0x06);//korekcja temperatury dla PCD8544 WriteCmd(0x14);//wspólczynnik multipleksowania WriteCmd(0x20);//komendy standardowe - adresowanie poziome Delay(2); WriteCmd(0x0c);//tryb wyœwietlania Standard Mode WriteCmd(0x40);//zerowanie licznika wierszy WriteCmd(0x80);//zerowanie licznika kolumn Delay(2); // for(i=0;i<(48*84);i++)//612 // WriteData(0x00);//zerowanie pamieci RAM wyswietlacza LoWaterMark = LCD_CACHE_SIZE; HiWaterMark = 0; LcdClear(); LcdUpdate(); }
void LcdClear (void) //Clears the display { int i; for (i = 0; i < LCD_CACHE_SIZE; i++) LcdCache[i] = 0; //забиваем всю память 0 LcdUpdate (); }
int main() { LcdInit(); //initialize LCD LcdContrast(0x7F); //display image _delay_ms(1000); LcdClear(); LcdContrast(0x3F); //adjust contrast _delay_ms(1000); LcdClear(); LcdImage(waitImage); //wait image LcdUpdate(); _delay_ms(4000); ADCSRA |= (1<<ADEN)|(1<<ADPS0)|(1<<ADPS1)|(1<<ADPS2); //enable ADC and select clk/128 ADMUX |= (1<<REFS0)|(1<<ADLAR); //Vref, ADC0 as input DDRC = 0x00; uint16_t temp, temp1, temp2, temp3; while (1) { ADCSRA |= (1<<ADSC); //begin conversion while(!(ADCSRA &(1<<ADSC))==0); //wait for end of conversion temp=(ADCH<<8)|ADCL; //calculation for temperature temp1 = temp%10; temp2 = temp%100/10; temp3 = temp%1000/100; char digit[4]; sprintf(digit, "%d%d.%d ", temp1, temp2, temp3); //display temperature LcdClear(); LcdGotoXYFont(1,1); LcdFStr(FONT_1X,(unsigned char*)digit); LcdGotoXYFont(1,2); LcdFStr(FONT_1X,(unsigned char*)PSTR ("Fahrenheit")); LcdUpdate(); _delay_ms(1000); } return 0; }
/*-------------------------------------------------------------------------------------------------- Name : LcdClear Description : Clears the display. LcdUpdate must be called next. Argument(s) : None. Return value : None. --------------------------------------------------------------------------------------------------*/ void LcdClear ( void ) { unsigned int i; for ( i = 0; i <= LCD_CACHE_SIZE; i++ ) LcdCache[i] = 0x00; LoWaterMark = 0; HiWaterMark = LCD_CACHE_SIZE - 1; WriteCmd(0x80); WriteCmd(0x40); LcdUpdate(); }
void LcdDisplaySet(u8 xStart, u8 yStart, u8 xEnd, u8 yEnd, eat_bool update) { u8 x, y; for(y=yStart; y<=yEnd; y++) { for(x=xStart; x<=xEnd; x++) { M_SetLcdDisplayData(x, y); } } if(update == EAT_TRUE) { LcdUpdate(xStart, yStart, xEnd, yEnd); } }
/* * Name : LcdInit * Description : Performs MCU SPI & LCD controller initialization. * Argument(s) : None. * Return value : None. */ void LcdInit ( void ) { /* Pull-up on reset pin. */ LCD_PORT |= _BV ( LCD_RST_PIN ); /* Set output bits on LCD Port. */ LCD_DDR |= _BV( LCD_RST_PIN ) | _BV( LCD_DC_PIN ) | _BV( LCD_CE_PIN ) | _BV( SPI_MOSI_PIN ) | _BV( SPI_CLK_PIN ); Delay(); /* Toggle display reset pin. */ LCD_PORT &= ~( _BV( LCD_RST_PIN ) ); Delay(); LCD_PORT |= _BV ( LCD_RST_PIN ); /* Enable SPI port: * No interrupt, MSBit first, Master mode, CPOL->0, CPHA->0, Clk/4 */ SPCR = 0x50; /* Disable LCD controller */ LCD_PORT |= _BV( LCD_CE_PIN ); LcdSend( 0x21, LCD_CMD ); /* LCD Extended Commands. */ LcdSend( 0xC8, LCD_CMD ); /* Set LCD Vop (Contrast).*/ LcdSend( 0x06, LCD_CMD ); /* Set Temp coefficent. */ LcdSend( 0x13, LCD_CMD ); /* LCD bias mode 1:48. */ LcdSend( 0x20, LCD_CMD ); /* LCD Standard Commands,Horizontal addressing mode */ LcdSend( 0x0C, LCD_CMD ); /* LCD in normal mode. */ /* Reset watermark pointers to empty */ LoWaterMark = LCD_CACHE_SIZE; HiWaterMark = 0; /* Clear display on first time use */ LcdClear(); LcdUpdate(); }
int main(void) { MainInit(); I2C1init(); RtcInit(); LcdInit(); DataLogInit(); StringInit(); Mct485Init(); FieldInit(); Ads1115Init(); Ads1244Init(); USBInit(); RtuInit(); AdcInit(); TC74Init(); // enable multi-vector interrupts INTEnableSystemMultiVectoredInt(); MainDelay(50); DataLogDateTime(DLOG_SFC_POWERUP); // init param after interrupts are enabled ParamInit(); // wait to init desiccant until after ParamInit DesiccantInit(); string[0].mct[0].chan[4] = 0x7FFF; // // Begin Main Loop // for (;;) { if (test == 1) { test = 0; FieldNewState((FIELD_STATE_m)t1); } USBUpdate(); // called as often as possible //sysTickEvent every ms if (sysTickEvent) { sysTickEvent = 0; sysTicks++; UsbTimeoutUpdate(); LcdUpdate(); // fill time before dropping LCD_E if (sysTicks >= 1000) { sysSec++; sysTicks = 0; mPORTDToggleBits(PD_LED_HEARTBEAT); // These Updates are // called once a second //TODO if any of these are long, we could split them on separate milliseconds. DesiccantUpdate(); AdcUpdate(); TC74Update(); }// end 1 Hz else if (sysTicks == 250) { mPORTDToggleBits(PD_LED_HEARTBEAT); } else if (sysTicks == 500) { mPORTDToggleBits(PD_LED_HEARTBEAT); } else if (sysTicks == 750) { mPORTDToggleBits(PD_LED_HEARTBEAT); } // Complete LcdUpdate() by dropping LCD_E) PORTClearBits(IOPORT_G, PG_LCD_E); // These Updates called once each millisecond RtcUpdate(); I2C1update(); StringUpdate(); Mct485Update(); FieldUpdate(); RtuUpdate(); DessicantFanPWMupdate(); } // if (sysTickEvent) } // for (;;) } // main()
void mainPcd8544() { //STM_EVAL_LEDInit(LED3); //STM_EVAL_LEDToggle(LED3); //QuadEncInit(); LcdInit(); LcdClear(); LcdGotoXYFont ( 2, 2 ); LcdStr( FONT_1X, "1234" ); LcdUpdate(); /* HwLcdInit(); while (1) { HwLcdPinRst(1); HwLcdPinDC(1); HwLcdPinCE(1); HwLcdSend(0xEEEE); Delay(2); HwLcdPinRst(0); HwLcdPinDC(0); HwLcdPinCE(0); Delay(2); } */ for(int i=0; 1; i++) { LcdClear(); LcdGotoXYFont ( 1, 1 ); printInt(i, FONT_1X); LcdUpdate(); Delay(100); } while (1) { STM_EVAL_LEDToggle(LED3); LcdClear(); if(QuadEncButton()) { LcdGotoXYFont ( 1, 1 ); LcdStr(FONT_1X, "PRESSED!"); } LcdGotoXYFont ( 1, 3 ); LcdStr(FONT_1X, "Q="); printInt(QuadEncValue(), FONT_2X); LcdUpdate(); Delay(20); } /* while (1) { //uint16_t temp_lo = PressureRead(0x20); //uint16_t temp_hi = PressureRead(0x0F); STM_EVAL_LEDToggle(LED3); LcdClear(); LcdGotoXYFont ( 1, 3 ); LcdStr(FONT_1X, "P="); printInt(PressureReadPressure(), FONT_1X); LcdGotoXYFont ( 1, 5 ); LcdStr(FONT_1X, "T="); printIntFixed(PressureReadTemp(), FONT_1X, 3, 1); LcdUpdate(); Delay(200); } */ }
void LcdDisplayStrCn(u8 xStart, u8 yStart, u8 xEnd, u8 yEnd, u8 align, const unsigned short *str, eat_bool update) { u8 x, y, ix, iy, cur_x, cur_x2, cur_y; EatCharFontInfo_st fontInfo; unsigned char height, width; unsigned char c_h, c_w; const unsigned short *p; unsigned int pos; /* 获取高度&宽度 */ p = str; width = 0; height = 0; while(*p != 0) { /* 取字库信息 */ if(EatGetCharFontWidthAndHeight(EAT_FONT_TYPE_CHINESE, *p, &c_h, &c_w)) { width += c_w; #if defined(CHAR_SPACE_PIXEL) width += CHAR_SPACE_PIXEL; #endif if(c_h > height) height = c_h; } p++; } switch(align&LCD_ALIGN_V) { case LCD_ALIGN_V_UP: y = yStart; break; case LCD_ALIGN_V_DOWN: if((yStart+height) > yEnd) y = yStart; else y = yEnd-height-1; break; default: if((yStart+height) > yEnd) y = yStart; else y = yStart + ((yEnd - yStart - height) / 2); break; } switch(align&LCD_ALIGN_H) { case LCD_ALIGN_H_LEFT: x = xStart; break; case LCD_ALIGN_H_RIGHT: if((xStart+width) > xEnd) x = xStart; else x = xEnd-width-1; break; default: if((xStart+width) > xEnd) x = xStart; else x = xStart + ((xEnd - xStart - width) / 2); break; } LcdDisplayClear(xStart, yStart, xEnd, yEnd, EAT_FALSE); p = str; cur_x = x; while(*p != 0) { /* 取字库信息 */ if(EatGetCharFontInfo(EAT_FONT_TYPE_CHINESE, *p, &fontInfo)) { /* 字库转换为显示数据 */ cur_y = y; pos = 0; for(iy=0; iy<fontInfo.height; iy++) { cur_x2 = cur_x; for(ix=0; ix<fontInfo.width; ix++) { if(fontInfo.data[pos]) { M_SetLcdDisplayData(cur_x2, cur_y); } else { M_ClearLcdDisplayData(cur_x2, cur_y); } pos++; cur_x2++; if(cur_x2 > xEnd) break; } cur_y++; if(cur_y > yEnd) break; } cur_x += fontInfo.width; #if defined(CHAR_SPACE_PIXEL) cur_x += CHAR_SPACE_PIXEL; #endif if(cur_x > xEnd) break; } p++; } if(update == EAT_TRUE) { LcdUpdate(xStart, yStart, xEnd, yEnd); } }
void LcdUpdateAll(void) { LcdUpdate(0, 0, X_PIXELS-1, Y_PIXELS-1); }
void LcdDisplayStr(u8 xStart, u8 yStart, u8 xEnd, u8 yEnd, FontType_Enum font, u8 align, const char *str, eat_bool update) { u8 x, y, ix, iy, cur_x, cur_x2, cur_y; u8 width, height; FontInfo_Struct fontInfo; const u8 *fontData; const char *p; if(font >= FONT_TYPE_NUM) return; if(str == NULL) return; if(xEnd < xStart) return; if(yEnd < yStart) return; /* 获取高度&宽度 */ p = str; width = 0; height = 0; while(*p != 0) { /* 取字库信息 */ fontData = FontFind(*p, font, &fontInfo); if(fontData != NULL) { width += fontInfo.width; #if defined(CHAR_SPACE_PIXEL) width += CHAR_SPACE_PIXEL; #endif if(fontInfo.height > height) height = fontInfo.height; } p++; } switch(align&LCD_ALIGN_V) { case LCD_ALIGN_V_UP: y = yStart; break; case LCD_ALIGN_V_DOWN: if((yStart+height) > yEnd) y = yStart; else y = yEnd-height-1; break; default: if((yStart+height) > yEnd) y = yStart; else y = yStart + ((yEnd - yStart - height) / 2); break; } switch(align&LCD_ALIGN_H) { case LCD_ALIGN_H_LEFT: x = xStart; break; case LCD_ALIGN_H_RIGHT: if((xStart+width) > xEnd) x = xStart; else x = xEnd-width-1; break; default: if((xStart+width) > xEnd) x = xStart; else x = xStart + ((xEnd - xStart - width) / 2); break; } LcdDisplayClear(xStart, yStart, xEnd, yEnd, EAT_FALSE); p = str; cur_x = x; while(*p != 0) { /* 取字库信息 */ fontData = FontFind(*p, font, &fontInfo); if(fontData != NULL) { /* 字库转换为显示数据 */ cur_y = y; for(iy=0; iy<fontInfo.height; iy++) { cur_x2 = cur_x; for(ix=0; ix<fontInfo.width; ix++) { if((fontData[iy*((fontInfo.width+7)/8) + ix/8] & (1<<(ix%8)))) { M_SetLcdDisplayData(cur_x2, cur_y); } else { M_ClearLcdDisplayData(cur_x2, cur_y); } cur_x2++; if(cur_x2 > xEnd) break; } cur_y++; if(cur_y > yEnd) break; } cur_x += fontInfo.width; #if defined(CHAR_SPACE_PIXEL) cur_x += CHAR_SPACE_PIXEL; #endif if(cur_x > xEnd) break; } p++; } if(update == EAT_TRUE) { LcdUpdate(xStart, yStart, xEnd, yEnd); } }