/********************************************************************* * Function: SHORT TouchGetY() * * PreCondition: none * * Input: none * * Output: y coordinate * * Side Effects: none * * Overview: returns y coordinate if touch screen is pressed * and -1 if not * * Note: none * ********************************************************************/ SHORT TouchGetY(){ long result; #ifdef SWAP_X_AND_Y result = ADCGetX(); #else result = ADCGetY(); #endif if(result>=0){ #ifdef SWAP_X_AND_Y result = (GetMaxY()*(result- _calXMin))/(_calXMax - _calXMin); #else result = (GetMaxY()*(result - _calYMin))/(_calYMax - _calYMin); #endif #ifdef FLIP_Y result = GetMaxY()- result; #endif } return result; }
/********************************************************************* * Function: WORD Bar(SHORT left, SHORT top, SHORT right, SHORT bottom) * * PreCondition: none * * Input: left,top - top left corner coordinates, * right,bottom - bottom right corner coordinates * * Output: For NON-Blocking configuration: * - Returns 0 when device is busy and the shape is not yet completely drawn. * - Returns 1 when the shape is completely drawn. * For Blocking configuration: * - Always return 1. * * Side Effects: none * * Overview: draws rectangle filled with current color * * Note: none * ********************************************************************/ WORD Bar(SHORT left, SHORT top, SHORT right, SHORT bottom){ DWORD address; register SHORT x,y; #ifndef USE_NONBLOCKING_CONFIG while(IsDeviceBusy() != 0); /* Ready */ #else if(IsDeviceBusy() != 0) return 0; #endif if(_clipRgn){ if(left<_clipLeft) left = _clipLeft; if(right>_clipRight) right= _clipRight; if(top<_clipTop) top = _clipTop; if(bottom>_clipBottom) bottom = _clipBottom; } #if (DISP_ORIENTATION == 0) address = (DWORD)LINE_MEM_PITCH*top + left; CS_LAT_BIT = 0; for(y=top; y<bottom+1; y++){ SetAddress(address); for(x=left; x<right+1; x++){ WriteData(_color); } address += LINE_MEM_PITCH; } CS_LAT_BIT = 1; #else top = GetMaxY() - top; bottom = GetMaxY() - bottom; address = (DWORD)LINE_MEM_PITCH*left + top; CS_LAT_BIT = 0; for(y=bottom; y<top+1; y++){ SetAddress(address); for(x=left; x<right+1; x++){ WriteData(_color); } address -= 1; } CS_LAT_BIT = 1; #endif return 1; }
TPolyLine3D* BasicHorizontalRectangularDetectorElement::GeneratePolyLine3D() { TPolyLine3D* pPolyLine = new TPolyLine3D(5); // printf("---------MinX: %f, Maxx:%f, Miny: %f, MaxY:%f, Z: %f\n", GetMinX(), GetMaxX(), GetMinY(), GetMaxY(), GetZOffset()); pPolyLine->SetPoint(0, GetMinX(), GetMinY(), GetZOffset()); pPolyLine->SetPoint(1, GetMaxX(), GetMinY(), GetZOffset()); pPolyLine->SetPoint(2, GetMaxX(), GetMaxY(), GetZOffset()); pPolyLine->SetPoint(3, GetMinX(), GetMaxY(), GetZOffset()); pPolyLine->SetPoint(4, GetMinX(), GetMinY(), GetZOffset()); return pPolyLine; }
/********************************************************************* * Function: void ClearDevice(void) * * PreCondition: none * * Input: none * * Output: none * * Side Effects: none * * Overview: clears screen with current color * * Note: none * ********************************************************************/ void ClearDevice(void){ DWORD counter; CS_LAT_BIT = 0; SetPointer(0,0,GetMaxX(),GetMaxY()); WriteCommand(CMD_WRITE); for(counter=0; counter<(DWORD)(GetMaxX()+1)*(GetMaxY()+1); counter++){ WriteData(_color.v[1]); WriteData(_color.v[0]); } CS_LAT_BIT = 1; }
void Camera::SetY(double y) { if ( !HasBounds() ) { this->y = y; } else { if ( y < GetMinY() ) this->y = GetMinY(); else if ( y > GetMaxY() ) this->y = GetMaxY(); else this->y = y; } }
/********************************************************************* * Function: void Bar(SHORT left, SHORT top, SHORT right, SHORT bottom) * * PreCondition: none * * Input: left,top - top left corner coordinates, * right,bottom - bottom right corner coordinates * * Output: none * * Side Effects: none * * Overview: draws rectangle filled with current color * * Note: none * ********************************************************************/ void Bar(SHORT left, SHORT top, SHORT right, SHORT bottom){ DWORD_VAL address; register SHORT x,y; if(_clipRgn){ if(left<_clipLeft) left = _clipLeft; if(right>_clipRight) right= _clipRight; if(top<_clipTop) top = _clipTop; if(bottom>_clipBottom) bottom = _clipBottom; } #ifdef USE_PORTRAIT address.Val = (DWORD)LINE_MEM_PITCH*top + left; CS_LAT_BIT = 0; for(y=top; y<bottom+1; y++){ SetAddress(address.v[2],address.v[1],address.v[0]); for(x=left; x<right+1; x++){ WriteData(_color.v[1],_color.v[0]); } address.Val += LINE_MEM_PITCH; } CS_LAT_BIT = 1; #else top = GetMaxY() - top; bottom = GetMaxY() - bottom; address.Val = (DWORD)LINE_MEM_PITCH*left + top; CS_LAT_BIT = 0; for(y=bottom; y<top+1; y++){ SetAddress(address.v[2],address.v[1],address.v[0]); for(x=left; x<right+1; x++){ WriteData(_color.v[1],_color.v[0]); } address.Val -= 1; } CS_LAT_BIT = 1; #endif }
/********************************************************************* * Function: void PutPixel(SHORT x, SHORT y) * * PreCondition: none * * Input: x,y - pixel coordinates * * Output: none * * Side Effects: none * * Overview: puts pixel * * Note: none * ********************************************************************/ void PutPixel(SHORT x, SHORT y){ DWORD_VAL address; if(_clipRgn){ if(x<_clipLeft) return; if(x>_clipRight) return; if(y<_clipTop) return; if(y>_clipBottom) return; } #ifdef USE_PORTRAIT address.Val = (long)LINE_MEM_PITCH*y + x; #else y = GetMaxY() - y; address.Val = (long)LINE_MEM_PITCH*x + y; #endif CS_LAT_BIT = 0; SetAddress(address.v[2],address.v[1],address.v[0]); WriteData(_color.v[1],_color.v[0]); CS_LAT_BIT = 1; }
/********************************************************************* * Function: void ClearDevice(void) * * PreCondition: none * * Input: none * * Output: none * * Side Effects: none * * Overview: clears screen with current color * * Note: none * ********************************************************************/ void ClearDevice(void) { int x, y; DisplayEnable(); SetRegion(0, GetMaxX(), 0, GetMaxY()); DisplaySetCommand(); DeviceWrite(MemoryWrite); DisplaySetData(); for (x = 0; x < GetMaxY() + 1; x++) { for (y = 0; y < GetMaxX() + 1; y++) { DeviceWrite(_color); } } DisplayDisable(); }
/********************************************************************* * Function: void PutPixel(SHORT x, SHORT y) * * PreCondition: none * * Input: x,y - pixel coordinates * * Output: none * * Side Effects: none * * Overview: puts pixel * * Note: none * ********************************************************************/ void PutPixel(SHORT x, SHORT y){ DWORD address; if(_clipRgn){ if(x<_clipLeft) return; if(x>_clipRight) return; if(y<_clipTop) return; if(y>_clipBottom) return; } #if (DISP_ORIENTATION == 0) // x=GetMaxX() - x; address = (long)LINE_MEM_PITCH*y + x; #else y = GetMaxY() - y; address = (long)LINE_MEM_PITCH*x + y; #endif CS_LAT_BIT = 0; SetAddress(address); WriteData(_color); CS_LAT_BIT = 1; }
/********************************************************************* * Function: WORD GetPixel(SHORT x, SHORT y) * * PreCondition: none * * Input: x,y - pixel coordinates * * Output: pixel color * * Side Effects: none * * Overview: return pixel color at x,y position * * Note: none * ********************************************************************/ WORD GetPixel(SHORT x, SHORT y){ WORD_VAL result; CS_LAT_BIT = 0; SetPointer(x,y,GetMaxX(),GetMaxY()); WriteCommand(CMD_READ); // Start read cycle for LSB result.v[0] = PMDIN1; // Wait for reading is done Nop(); Nop(); // Get LSB and start read cycle for MSB result.v[0] = PMDIN1; // Wait for reading is done Nop(); Nop(); // Disable LCD (it will not accept extra /RD pulse) CS_LAT_BIT = 1; // Read MSB result.v[1] = PMDIN1; // Wait for dummy reading is done Nop(); Nop(); return result.Val; }
bool FGAFRect::IntersectsRect(const FGAFRect& rect) const { return !( GetMaxX() < rect.GetMinX() || rect.GetMaxX() < GetMinX() || GetMaxY() < rect.GetMinY() || rect.GetMaxY() < GetMinY()); }
/********************************************************************* * Function: void PutPixel(SHORT x, SHORT y) * * PreCondition: none * * Input: x,y - pixel coordinates * * Output: none * * Side Effects: none * * Overview: puts pixel * * Note: none * ********************************************************************/ void PutPixel(SHORT x, SHORT y) { DWORD address; if(_clipRgn) { if(x < _clipLeft) return; if(x > _clipRight) return; if(y < _clipTop) return; if(y > _clipBottom) return; } #if (DISP_ORIENTATION == 0) address = (long)LINE_MEM_PITCH * y + x; #else y = GetMaxY() - y; address = (long)LINE_MEM_PITCH * x + y; #endif DisplayEnable(); SetAddress(address); WritePixel(_color); DisplayDisable(); }
void FunctionSimple::SetMinY(float f) { // Offset is avg of min and max. m_offsetY = (f + GetMaxY()) / 2.0f; // Multiplier is max - offset, or offset - min m_multiplierY = fabs(f - m_offsetY); }
void CRoiDlg::UpdateRange() { m_SpinX.SetRange(0,GetMaxX()); m_SpinY.SetRange(0,GetMaxY()); m_SpinWidth.SetRange(1,GetMaxWidth()); m_SpinHeight.SetRange(1,GetMaxHeight()); }
/********************************************************************* * Function: LCD_SetArea(start_x,start_y,end_x,end_y) * * PreCondition: SetActivePage(page) * * Input: start_x, end_x - start column and end column * start_y,end_y - start row and end row position (i.e. page address) * * Output: none * * Side Effects: none * * Overview: defines start/end columns and start/end rows for memory access * from host to SSD1963 * Note: none ********************************************************************/ void LCD_SetArea(u16 start_x, u16 start_y, u16 end_x, u16 end_y) { long offset; offset = (u16)_activePage*(GetMaxY()+1); start_y = offset + start_y; end_y = offset + end_y; LCD_WriteCommand(CMD_SET_COLUMN); Clr_Cs; LCD_WriteData(start_x>>8); LCD_WriteData(start_x); LCD_WriteData(end_x>>8); LCD_WriteData(end_x); Set_Cs; LCD_WriteCommand(CMD_SET_PAGE); Clr_Cs; LCD_WriteData(start_y>>8); LCD_WriteData(start_y); LCD_WriteData(end_y>>8); LCD_WriteData(end_y); Set_Cs; }
/********************************************************************* * Function: void ClearDevice(void) * * PreCondition: none * * Input: none * * Output: none * * Side Effects: none * * Overview: clears screen with current color * * Note: none * ********************************************************************/ void ClearDevice(void) { WORD counter; DisplayEnable(); // Whole screen DisplaySetCommand(); DeviceWrite(LASET); //Line Address Set(lines from 16 to 144 are used) DisplaySetData(); DeviceWrite(0x10); //Start Line=16 DeviceWrite(0x8f); //End Line =144-1 DisplaySetCommand(); DeviceWrite(CASET); //Column Address Set DisplaySetData(); DeviceWrite(0x00); //Start Column=0 DeviceWrite(0x54); //End Column =84 ((84+1)*3 == 255) DisplaySetCommand(); DeviceWrite(RAMWR); DisplaySetData(); for(counter = 0; counter < (WORD) (GetMaxX() + 1) * (GetMaxY() + 1); counter++) { DeviceWrite(_color); } DisplayDisable(); }
void CreateDemo(void) { GOLFree(); SetColor(GFX_SCHEMEDEFAULT.CommonBkColor); ClearDevice(); BtnCreate(ID_BUTTON, GetMaxX() * 1 / 4, GetMaxY() * 1 / 3, GetMaxX() * 3 / 4, GetMaxY() * 2 / 3, 0, BTN_DRAW, NULL, "Button", NULL); showDecoration = FALSE; showDecorationPrev = TRUE; // force redraw }
/********************************************************************* * Function: void TouchGetCalPoints(WORD* ax, WORD* ay) * * PreCondition: InitGraph() must be called before * * Input: ax - pointer to array receiving 3 X touch positions * ay - pointer to array receiving 3 Y touch positions * * Output: none * * Side Effects: none * * Overview: gets values for 3 touches * * Note: none * ********************************************************************/ void TouchGetCalPoints(WORD* ax, WORD* ay){ static const XCHAR calStr[] = {'C','A','L','I','B','R','A','T','I','O','N',0}; XCHAR calTouchLeft[] = {'3',' ','t','o','u','c','h','e','s',' ','l','e','f','t',0}; SHORT counter; SHORT x,y; SetFont((void*)&GOLFontDefault); SetColor(BRIGHTRED); OutTextXY((GetMaxX()-GetTextWidth((XCHAR*)calStr,(void*)&GOLFontDefault))>>1, (GetMaxY()-GetTextHeight((void*)&GOLFontDefault))>>1, (XCHAR*)calStr); for(counter=0; counter<3; counter++){ SetColor(BRIGHTRED); calTouchLeft[0] = '3' - counter; OutTextXY((GetMaxX()-GetTextWidth(calTouchLeft,(void*)&GOLFontDefault))>>1, (GetMaxY()+GetTextHeight((void*)&GOLFontDefault))>>1, calTouchLeft); // Wait for press do{ x=ADCGetX(); y=ADCGetY(); }while((y==-1)||(x==-1)); Beep(); *(ax+counter) = x; *(ay+counter) = y; // Wait for release do{ x=ADCGetX(); y=ADCGetY(); }while((y!=-1)&&(x!=-1)); SetColor(WHITE); OutTextXY((GetMaxX()-GetTextWidth(calTouchLeft,(void*)&GOLFontDefault))>>1, (GetMaxY()+GetTextHeight((void*)&GOLFontDefault))>>1, calTouchLeft); DelayMs(500); } }
/********************************************************************* * Function: void PutImage1BPP(SHORT left, SHORT top, FLASH_BYTE* bitmap, BYTE stretch) * * PreCondition: none * * Input: left,top - left top image corner, bitmap - image pointer, * stretch - image stretch factor * * Output: none * * Side Effects: none * * Overview: outputs monochrome image starting from left,top coordinates * * Note: image must be located in flash * ********************************************************************/ void PutImage1BPP(SHORT left, SHORT top, FLASH_BYTE* bitmap, BYTE stretch){ register FLASH_BYTE* flashAddress; register FLASH_BYTE* tempFlashAddress; BYTE temp; WORD sizeX, sizeY; WORD x,y; BYTE stretchX,stretchY; WORD pallete[2]; BYTE mask; // Move pointer to size information flashAddress = bitmap + 2; // Read image size sizeY = *((FLASH_WORD*)flashAddress); flashAddress += 2; sizeX = *((FLASH_WORD*)flashAddress); flashAddress += 2; pallete[0] = *((FLASH_WORD*)flashAddress); flashAddress += 2; pallete[1] = *((FLASH_WORD*)flashAddress); flashAddress += 2; CS_LAT_BIT = 0; for(y=0; y<sizeY; y++){ tempFlashAddress = flashAddress; for(stretchY = 0; stretchY<stretch; stretchY++){ flashAddress = tempFlashAddress; SetPointer(left, top+y, GetMaxX(), GetMaxY()); WriteCommand(CMD_WRITE); mask = 0; for(x=0; x<sizeX; x++){ // Read 8 pixels from flash if(mask == 0){ temp = *flashAddress; flashAddress++; mask = 0x80; } // Set color if(mask&temp){ SetColor(pallete[1]); }else{ SetColor(pallete[0]); } // Write pixel to screen for(stretchX=0; stretchX<stretch; stretchX++){ WriteData(_color.v[1]); WriteData(_color.v[0]); } // Shift to the next pixel mask >>= 1; } } } CS_LAT_BIT = 1; }
/***************************************************************************** * void CreateLightingScreen(void) * * NOTE: The lighting demo is not available when using the PIC24FJ256GB210. * The demo requires loading an image from the external memory, the Epson * S1D13517 () has some routing conflicts which make loading the image * difficult and not robust. For these reasons, the lighting demo has * been take out for a better out of box experience. *****************************************************************************/ void CreateLightingScreen(void) { GOL_SCHEME *currentScheme; currentScheme = GFX_SchemeGetCurrentScheme(); SetColor(currentScheme->Color0); while(!FillBevel((GetMaxX() >> 2) + 20,90 ,GetMaxX() - 10, GetMaxY()-10,5)); while(!AlphaBlendWindow(GetDrawBufferAddress(), (GetMaxX() >> 2) + 15, 85, GFX_PAGE1, (GetMaxX() >> 2) + 15, 85, GetDrawBufferAddress(), (GetMaxX() >> 2) + 15, 85, (GetMaxX())-((GetMaxX() >> 2) + 15), GetMaxY() - 90, GFX_SchemeGetDefaultScheme()->AlphaValue)); SetState(GOLFindObject(PANEL_SCREEN_ID_LIGHTING_BUT), BTN_DISABLED); if(GetState(GOLFindObject(PANEL_SCREEN_ID_COMFORT_BUT),BTN_DISABLED)) { ClrState(GOLFindObject(PANEL_SCREEN_ID_COMFORT_BUT), BTN_DISABLED); SetState(GOLFindObject(PANEL_SCREEN_ID_COMFORT_BUT),BTN_DRAW); } if(GetState(GOLFindObject(PANEL_SCREEN_ID_SECURITY_BUT),BTN_DISABLED)) { ClrState(GOLFindObject(PANEL_SCREEN_ID_SECURITY_BUT), BTN_DISABLED); SetState(GOLFindObject(PANEL_SCREEN_ID_SECURITY_BUT),BTN_DRAW); } if(GetState(GOLFindObject(PANEL_SCREEN_ID_ENERGY_USAGE_BUT),BTN_DISABLED)) { ClrState(GOLFindObject(PANEL_SCREEN_ID_ENERGY_USAGE_BUT), BTN_DISABLED); SetState(GOLFindObject(PANEL_SCREEN_ID_ENERGY_USAGE_BUT),BTN_DRAW); } /*** * See above note in the function comment for more information **/ #ifndef __PIC24FJ256GB210__ GFX_BlockUntilFinished(PutImage((GetMaxX() >> 2)+40, 90+10, (void *) &House, IMAGE_NORMAL)); #endif }
void CRoiDlg::OnKillfocusRoiY() { m_Roi.height = GetInt(&m_HeightEdit); m_Roi.y = GetInt(&m_YEdit); UpdateValue(m_Roi.y, 0, GetMaxY()); UpdateValue(m_Roi.height, 1, GetMaxHeight(), &m_SpinHeight); UpdateData(FALSE); }
unsigned char N11_ReadPixel(unsigned char x, unsigned char y) { #if LCDlight == 0 if((x > GetMaxX()) || (y > GetMaxY())) return(0x00); //exit if coordinates are not legal return(bit_is_set(N11_Cache[x][y/8], (1 << (y%8))) ? 0x01 : 0x00); #endif//LCDlight } //*N11_ReadPixel
double XYDataset::GetMaxValue(bool verticalAxis) { if (verticalAxis) { return GetMaxY(); } else { return GetMaxX(); } }
/************************************************************************ Function: void CreateAnimation(void) Overview: Creates the animation screen. Input: none Output: none ************************************************************************/ void CreateAnimation(void) { SHORT j, height, endPoint; // free memory for the objects in the previous linked list and start new list GOLFree(); SetColor(SCREEN_BACKGROUND_COLOR); ClearDevice(); // draw the band of lines with increasing thickness background of the demo height = 13; endPoint = GetMaxY() - 35; SetColor(RGB565CONVERT(0x4C, 0x8E, 0xFF)); for(j = 2; j <= endPoint; j += (height + 6)) { WAIT_UNTIL_FINISH(Bar(0, j, GetMaxX(), j + height)); if(height <= 0) height = 0; else height -= 1; } pPicture = PictCreate ( ID_PICTURE1, // ID PICTURE_XINDENT, PICTURE_YINDENT, PICTURE_XINDENT + PICTURE_WIDTH - 1, PICTURE_YINDENT + PICTURE_HEIGHT - 1, PICT_DRAW, // will be dislayed, has frame 2, // scale factor is x1 (void *) &Engine1, // bitmap altScheme ); // default GOL scheme pMeter = MtrCreate ( ID_METER2, (2 * PICTURE_XINDENT + PICTURE_WIDTH), PICTURE_YINDENT - 20, (2 * (PICTURE_XINDENT + PICTURE_WIDTH)), PICTURE_YINDENT + PICTURE_HEIGHT + 20, MTR_DRAW | MTR_RING | MTR_ACCURACY, // draw normal meter object MAX_METER_VALUE, // set initial value 0, MAX_METER_VALUE, // set range (void *) &GOLFontDefault, // Title font to be used (void *) &GOLMediumFont, // Value font to be used MeterStr, // meterScheme ); // alternative GOL scheme //pMeter->pTitleFont = (void*)&GOLFontDefault; //pMeter->pValueFont = (void*)&GOLMediumFont; // create the demo navigation/control buttons CreateCtrlButtons(ExitStr, ScaleStr, LeftArrowStr, RightArrowStr); }
/***************************************** * void CreateMainPage(void) *****************************************/ void CreateMainDemoPage(void) { WndCreate ( ID_WINDOW1, // ID 0, 0, GetMaxX(), GetMaxY(), // dimension WND_DRAW, // will be dislayed after creation NULL, // icon NULL, // set text NULL // default GOL scheme ); BtnCreate ( ID_BUTTON_BACK, // button ID 0, 40, // left, top corner NAV_BTN_WIDTH, GetMaxY(), 0, // right, bottom corner (with radius = 0) BTN_DRAW, // will be dislayed after creation NULL, // no bitmap (XCHAR *)"<", // LEFT arrow as text NULL // default GOL scheme ); BtnCreate ( ID_BUTTON_NEXT, // button ID GetMaxX() - NAV_BTN_WIDTH, 40, GetMaxX(), GetMaxY(), 0, // dimension (with radius = 0) BTN_DRAW, // will be dislayed and disabled after creation NULL, // no bitmap (XCHAR *)">", // RIGHT arrow as text NULL // default GOL scheme ); }
WORD GetPixel(SHORT x, SHORT y) { DWORD address; WORD result; #if (DISP_ORIENTATION == 0) address = (long)LINE_MEM_PITCH * y + x; #else y = GetMaxY() - y; address = (long)LINE_MEM_PITCH * x + y; #endif CS_LAT_BIT = 0; SetAddress(address); // Temporary change wait cycles for reading (250ns = 4 cycles) #if defined(__C30__) PMMODEbits.WAITM = 4; #elif defined(__PIC32MX__) PMMODEbits.WAITM = 8; #else #error Need wait states for the device #endif RS_LAT_BIT = 1; // First RD cycle to move data from GRAM to Read Data Latch result = PMDIN1; while(PMMODEbits.BUSY); // Second RD cycle to get data from Read Data Latch result = PMDIN1; while(PMMODEbits.BUSY); // Disable LCD CS_LAT_BIT = 1; // Disable PMP PMCONbits.PMPEN = 1; // Read result result = PMDIN1; // Restore wait cycles for writing (60ns) #if defined(__dsPIC33F__) || defined(__PIC24H__) PMMODEbits.WAITM = 2; #else PMMODEbits.WAITM = 1; #endif // Enable PMP PMCONbits.PMPEN = 1; return (result); }
/********************************************************************* * Function: WORD GetPixel(SHORT x, SHORT y) * * PreCondition: none * * Input: x,y - pixel coordinates * * Output: pixel color * * Side Effects: none * * Overview: returns pixel color at x,y position * * Note: none * ********************************************************************/ WORD GetPixel(SHORT x, SHORT y){ DWORD_VAL address; WORD_VAL result; #ifdef USE_PORTRAIT address.Val = (long)LINE_MEM_PITCH*y + x; #else y = GetMaxY() - y; address.Val = (long)LINE_MEM_PITCH*x + y; #endif CS_LAT_BIT = 0; SetAddress(address.v[2],address.v[1],address.v[0]); // Temporary change wait cycles for reading (250ns = 4 cycles) PMMODEbits.WAITM = 4; RS_LAT_BIT = 1; // First RD cycle to move data from GRAM to Read Data Latch result.v[1] = PMDIN1; while(PMMODEbits.BUSY); // Second RD cycle to move data from GRAM to Read Data Latch result.v[1] = PMDIN1; while(PMMODEbits.BUSY); // First RD cycle to get data from Read Data Latch // Read previous dummy value result.v[1] = PMDIN1; while(PMMODEbits.BUSY); // Second RD cycle to get data from Read Data Latch // Read MSB result.v[1] = PMDIN1; while(PMMODEbits.BUSY); // Disable LCD CS_LAT_BIT = 1; // Disable PMP PMCONbits.PMPEN = 1; // Read LSB result.v[0] = PMDIN1; // Restore wait cycles for writing (60ns = 1 cycle) PMMODEbits.WAITM = 1; // Enable PMP PMCONbits.PMPEN = 1; return result.Val; }
/********************************************************************* * Function: void ClearDevice(void) * * PreCondition: none * * Input: none * * Output: none * * Side Effects: none * * Overview: clears screen with current color * * Note: none * ********************************************************************/ void ClearDevice(void){ DWORD counter; CS_LAT_BIT = 0; SetAddress(0); for(counter=0; counter<(DWORD)(GetMaxX()+1)*(GetMaxY()+1); counter++){ WriteData(_color); } CS_LAT_BIT = 1; }
/********************************************************************* * Function: void ClearDevice(void) * * PreCondition: none * * Input: none * * Output: none * * Side Effects: none * * Overview: clears screen with current color * * Note: none * ********************************************************************/ void LCD_Clear(u16 color) { u32 xcounter, ycounter; LCD_SetArea(0,0,GetMaxX(),GetMaxY()); LCD_WriteCommand(CMD_WR_MEMSTART); Clr_Cs; for(ycounter=0; ycounter<GetMaxY()+1; ycounter++) { for(xcounter=0; xcounter<GetMaxX()+1; xcounter++) { LCD_WriteData(color); } } Set_Cs; }
/********************************************************************* * Function: void PutImage4BPP(SHORT left, SHORT top, FLASH_BYTE* bitmap, BYTE stretch) * * PreCondition: none * * Input: left,top - left top image corner, bitmap - image pointer, * stretch - image stretch factor * * Output: none * * Side Effects: none * * Overview: outputs 16 color image starting from left,top coordinates * * Note: image must be located in flash * ********************************************************************/ void PutImage4BPP(SHORT left, SHORT top, FLASH_BYTE* bitmap, BYTE stretch){ register FLASH_BYTE* flashAddress; register FLASH_BYTE* tempFlashAddress; WORD sizeX, sizeY; register WORD x,y; BYTE temp; register BYTE stretchX,stretchY; WORD pallete[16]; WORD counter; // Move pointer to size information flashAddress = bitmap + 2; // Read image size sizeY = *((FLASH_WORD*)flashAddress); flashAddress += 2; sizeX = *((FLASH_WORD*)flashAddress); flashAddress += 2; // Read pallete for(counter=0;counter<16;counter++){ pallete[counter] = *((FLASH_WORD*)flashAddress); flashAddress += 2; } CS_LAT_BIT = 0; for(y=0; y<sizeY; y++){ tempFlashAddress = flashAddress; for(stretchY = 0; stretchY<stretch; stretchY++){ flashAddress = tempFlashAddress; SetPointer(left, top+y, GetMaxX(), GetMaxY()); WriteCommand(CMD_WRITE); for(x=0; x<sizeX; x++){ // Read 2 pixels from flash if((x&0x0001) == 0){ // Set color SetColor(pallete[temp>>4]); }else{ temp = *flashAddress; flashAddress++; // Set color SetColor(pallete[temp&0x0f]); } // Write pixel to screen for(stretchX=0; stretchX<stretch; stretchX++){ WriteData(_color.v[1]); WriteData(_color.v[0]); } // Shift to the next pixel temp >>= 4; } }