static void ST7735_writeCmd( uint8_t c ) { LcdWrite(LCD_C, &c, 1); }
// Set contrast can set the LCD Vop to a value between 0 and 127. // 40-60 is usually a pretty good range. void PCD8544::setContrast(byte contrast) { LcdWrite(LCD_CMD, 0x21); //Tell LCD that extended commands follow LcdWrite(LCD_CMD, 0x80 | contrast); //Set LCD Vop (Contrast): Try 0xB1(good @ 3.3V) or 0xBF if your display is too dark LcdWrite(LCD_CMD, 0x20); //Set display mode }
void gotoXY(int x, int y) { LcdWrite( 0, 0x80 | x); // Column. LcdWrite( 0, 0x40 | y); // Row. }
void LcdClear(void) { LcdWrite(LCD_RS_CNTL, 0x01); }
///---------------------------------------------------------------------------- /// Function Break ///---------------------------------------------------------------------------- void WriteMapToLcd(uint8 (*g_mmap_ptr)[128]) { uint8 segment; uint8* pixel_byte_ptr; uint8 col_index; uint8 row_index; // Check if the LCD has power. If not, can't get status, so return if (GetPowerControlState(LCD_POWER_ENABLE) == OFF) { return; } row_index = 0; while (row_index < 8) { col_index = 0; pixel_byte_ptr = (uint8*)g_mmap_ptr[row_index]; segment = LCD_SEGMENT1; SetLcdOrigin(row_index, DEFAULT_Y_LOC, segment); while (col_index <= SEGMENT_ONE_BLOCK_BORDER) { // Normal command replaced by code below //WriteLcdData(*(pixel_byte_ptr + col_index),segment); // Optimized WriteLcdData operation for speed //ClockDataToLcd(lcdCmdSeg1, *(pixel_byte_ptr + col_index)); //while (ClockDataFromLcd(lcdStatusSeg1) & LCD_BUSY_FLAG) {}; // End of optimized WriteLcdData operation LcdWrite(LCD_DATA, *(pixel_byte_ptr + col_index), segment); WaitForLcdReady(segment); col_index++; } segment = LCD_SEGMENT2; SetLcdOrigin(row_index, DEFAULT_Y_LOC, segment); while (col_index <= SEGMENT_TWO_BLOCK_BORDER) { // Normal command replaced by code below //WriteLcdData(*(pixel_byte_ptr + col_index),segment); // Optimized WriteLcdData operation for speed //ClockDataToLcd(lcdCmdSeg2, *(pixel_byte_ptr + col_index)); //while (ClockDataFromLcd(lcdStatusSeg2) & LCD_BUSY_FLAG) {}; // End of optimized WriteLcdData operation LcdWrite(LCD_DATA, *(pixel_byte_ptr + col_index), segment); WaitForLcdReady(segment); col_index++; } row_index++; } }
///---------------------------------------------------------------------------- /// Function Break ///---------------------------------------------------------------------------- void ClearControlLinesLcdDisplay(void) { LcdWrite(LCD_INSTRUCTION, 0x00, LCD_SEGMENT1); LcdWrite(LCD_DATA, 0x00, LCD_SEGMENT1); }
static void f3d_lcd_writeCmd(uint8_t c) { LcdWrite(LCD_C,&c,1); }
///---------------------------------------------------------------------------- /// Function Break ///---------------------------------------------------------------------------- inline void WriteLcdData(uint8 lcdData, uint8 segment) { LcdWrite(LCD_DATA, lcdData, segment); WaitForLcdReady(segment); }
// clear the entire LCD void LcdClear(void) { int index; for (index = 0; index < LCD_X * LCD_Y / 8; index++) { LcdWrite(LCD_D, 0x00); } }
//==============================================================// // Initialize single LCD and flush memory //==============================================================// void LcdSingleInit(void) { uint16_t i; // Software reset LcdWrite(CMD_RESET,CMD); //---- Ignored by china LCDs ----// // Charge pump LcdWrite(CMD_CHARGE_PUMP_MUL,CMD); LcdWrite(0x01,CMD); // A bit lower VLCD for 3.3V // Set VOP (contrast) LcdWrite(CMD_SET_VOP,CMD); LcdWrite(0x00,CMD); // default // V0 - voltage range LcdWrite(CMD_SET_VO_RANGE | V0R_8V12,CMD); // default // Electronic volume LcdWrite(CMD_SET_EV | 0x10,CMD); // default // X-axis reverse #ifdef HORIZONTAL_REVERSE LcdWrite(CMD_SELECT_SEGMENT_DIR | SEGMENT_REVERSE, CMD); #else LcdWrite(CMD_SELECT_SEGMENT_DIR | SEGMENT_NORMAL, CMD); #endif //------------------------------// // Y-axis reverse #ifdef VERTICAL_REVERSE LcdWrite(CMD_SELECT_COMMON_DIR | COMMON_REVERSE, CMD); #else LcdWrite(CMD_SELECT_COMMON_DIR | COMMON_NORMAL, CMD); #endif // Display inversion #ifdef LCD_INVERSE LcdWrite(CMD_NORM_INVERSE | DISPLAY_INVERSE,CMD); #else LcdWrite(CMD_NORM_INVERSE | DISPLAY_NORMAL,CMD); #endif // Power saver OFF LcdWrite(CMD_ALL_POINTS_ON_OFF | POINTS_NORMAL,CMD); // Internal voltage enable LcdWrite(CMD_SET_POWER | ALL_ENABLE,CMD); // Start line 0 LcdWrite(CMD_SET_START_LINE | 0x00, CMD); // Others deafults LcdWrite(CMD_SET_ICON_MODE | ICON_MODE_DISABLE,CMD); LcdWrite(CMD_LINES_NUMBER | 0x00,CMD); LcdWrite(CMD_SET_BIAS | 0x00,CMD); // Add memory init code here // clear LCD LcdSetRow(0); LcdSetCol(0); for(i=0; i<LCD_BUFFER_SIZE-1; i++) LcdWrite(0,DATA); // Display ON LcdWrite(CMD_ON_OFF | DISPLAY_ON,CMD); }
/* * LcdWriteStr * Description: This function writes a string of characters to the LCD * This function doesnt return until the LCD's BF is cleared. * * Arguments: str: string to write to LCD * Return: None * * Input: None * Output: LCD * * Operation: Choose the data register of the LCD then write each char of the * string to the LCD. * * Revision History: * Dec. 16, 2012 Nnoduka Eruchalu Initial Revision */ void LcdWriteStr(const char *str) { while (*str != '\0') { LcdWrite(*str++); } }
void LcdTinyString(const char *characters, uint8_t inverse, uint8_t maxWidth) { uint8_t width = 0; while (*characters && width < maxWidth) { if (*characters == 'm') { // special case 'm' characters++; if (width < maxWidth) { LcdWrite(LCD_DATA, inverse ? 0x3c ^ 0x7F : 0x3c); width++; } if (width < maxWidth) { LcdWrite(LCD_DATA, inverse ? 0x04 ^ 0x7F : 0x04); width++; } if (width < maxWidth) { LcdWrite(LCD_DATA, inverse ? 0x18 ^ 0x7F : 0x18); width++; } if (width < maxWidth) { LcdWrite(LCD_DATA, inverse ? 0x04 ^ 0x7F : 0x04); width++; } if (width < maxWidth) { LcdWrite(LCD_DATA, inverse ? 0x38 ^ 0x7F : 0x38); width++; } if (width < maxWidth) { LcdWrite(LCD_DATA, inverse ? 0x7F : 0x00); width++; } } else { unsigned short charbase = (*characters++ - 0x20) * 3; for (uint8_t index = 0; index < 3 && width < maxWidth; index++) { uint8_t pixels = pgm_read_byte((unsigned char*)tiny_font + charbase + index); pixels = pixels << 1; LcdWrite(LCD_DATA, inverse ? pixels ^ 0x7F : pixels); width++; } if (width < maxWidth) { LcdWrite(LCD_DATA, inverse ? 0x7F : 0x00); width++; } } } }
void LcdGoto(uint8_t x, uint8_t y) { LcdWrite(LCD_CMD, 0x80 | x); LcdWrite(LCD_CMD, 0x40 | y); }