Exemple #1
0
static int
am335x_lcd_sysctl_backlight(SYSCTL_HANDLER_ARGS)
{
    struct am335x_lcd_softc *sc = (struct am335x_lcd_softc*)arg1;
    int error;
    int backlight;

    backlight = sc->sc_backlight;;
    error = sysctl_handle_int(oidp, &backlight, 0, req);

    if (error != 0 || req->newptr == NULL)
        return (error);

    if (backlight < 0)
        backlight = 0;
    if (backlight > 100)
        backlight = 100;

    LCD_LOCK(sc);
    error = am335x_pwm_config_ecas(PWM_UNIT, PWM_PERIOD,
                                   backlight*PWM_PERIOD/100);
    if (error == 0)
        sc->sc_backlight = backlight;
    LCD_UNLOCK(sc);

    return (error);
}
Exemple #2
0
void lcdSetRefVolt(uint8_t val)
{
  LCD_LOCK();
  lcdSendCtl(0x81);
  lcdSendCtl(val);
  LCD_UNLOCK();
}
Exemple #3
0
void lcdSetRefVolt(uint8_t val)
{
#if !defined(LCD_ST7920) // No contrast setting for ST7920
  LCD_LOCK();
  lcdSendCtl(0x81);
  lcdSendCtl(val);
  LCD_UNLOCK();
#endif
}
Exemple #4
0
inline void lcdInit()
{
  // /home/thus/txt/datasheets/lcd/KS0713.pdf
  // ~/txt/flieger/ST7565RV17.pdf  from http://www.glyn.de/content.asp?wdid=132&sid=

  LCD_LOCK();
  PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_RES);  //LCD_RES
  delay_2us();
  PORTC_LCD_CTRL |= (1<<OUT_C_LCD_RES); //  f524  sbi 0x15, 2 IOADR-PORTC_LCD_CTRL; 21           1
  delay_1_5us(1500);
  for (uint8_t i=0; i<12; i++) {
    lcdSendCtl(pgm_read_byte(&lcdInitSequence[i])) ;
  }
  g_eeGeneral.contrast = 0x22;
  LCD_UNLOCK();
}
Exemple #5
0
inline void lcdInit()
{
  LCD_LOCK();
  PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_RES);  //LCD reset
  _delay_us(2);
  PORTC_LCD_CTRL |= (1<<OUT_C_LCD_RES);  //LCD normal operation
#if defined(LCD_ST7920)
  _delay_ms(40);
#else
  _delay_us(1500);
#endif
  for (uint8_t i=0; i<DIM(lcdInitSequence); i++) {
    lcdSendCtl(pgm_read_byte(&lcdInitSequence[i])) ;
#if defined(LCD_ST7920)
    _delay_us(80);
#endif
  }
#if defined(LCD_ERC12864FSF)
  g_eeGeneral.contrast = 0x2D;
#else
  g_eeGeneral.contrast = 0x22;
#endif
  LCD_UNLOCK();
}
Exemple #6
0
void lcdRefresh()
{
  LCD_LOCK();
  uint8_t *p=displayBuf;
  for(uint8_t y=0; y < 8; y++) {
    lcdSendCtl(0x04);
    lcdSendCtl(0x10); //column addr 0
    lcdSendCtl( y | 0xB0); //page addr y
    PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_CS1);
#ifdef LCD_MULTIPLEX
    DDRA = 0xFF; // set LCD_DAT pins to output
#endif
    PORTC_LCD_CTRL |=  (1<<OUT_C_LCD_A0);
    PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_RnW);
    for (xcoord_t x=LCD_W; x>0; --x) {
      PORTA_LCD_DAT = *p++;
      PORTC_LCD_CTRL |= (1<<OUT_C_LCD_E);
      PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_E);
    }
    PORTC_LCD_CTRL |=  (1<<OUT_C_LCD_A0);
    PORTC_LCD_CTRL |=  (1<<OUT_C_LCD_CS1);
  }
  LCD_UNLOCK();
}
Exemple #7
0
uint8_t lcdRefresh_ST7920(uint8_t full)
{
#else
void lcdRefresh()
{
#endif
  LCD_LOCK();
#if defined(LCD_ST7920)
  static uint8_t state;
  uint8_t yst,yend;
  uint8_t x_addr = 0;
  uint8_t y_addr = 0;
  uint16_t line_offset = 0;
  uint8_t col_offset = 0;
  uint8_t bit_count = 0;
  uint8_t result;
  uint8_t *p;
  if(full!=0){
    yst=0;
    yend=64;
    state=0;
  } 
  else{
    switch (state){//Since writing to ST7920 is too slow we need to split it to five bands.
     default:
     case 0:
       yst=0;
       yend=13;
       state=1;
       break;
     case 1:
       yst=13;
       yend=26;
       state=2;
       break;
     case 2:
       yst=26;
       yend=39;
       state=3;
       break;
     case 3:
       yst=39;
       yend=52;
       state=4;
       break;
     case 4:
       yst=52;
       yend=64;
       state=0;
       break;
    }
  }
  
  for (uint8_t y=yst; y<yend; y++) {
    x_addr = 0;
    //Convert coordinates to weirdly-arranged 128x64 screen (the ST7920 is mapped for 256x32 displays)
    if (y > 31) {
      y_addr = y - 32;    //Because there are only 31 addressable lines in the ST7920
      x_addr += 8;        //so we overflow x (7 visible bytes per line) to reach the bottom half
    }
    else {
      y_addr = y;
    }
    lcdSendCtl( 0x80 | y_addr );  //Set Vertical Address
    _delay_us(49);
    lcdSendCtl( 0x80 | x_addr );  //Set Horizontal Address
    _delay_us(49);
    PORTC_LCD_CTRL |= (1<<OUT_C_LCD_A0);    //HIGH RS and LOW RW will put the LCD to
    PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_RnW);  //Write data register mode
    bit_count = y & 0x07; //Count from 0 bis 7 -> 0=0, 1=1..7=7, 8=0, 9=1...
    col_offset = 1 << bit_count; //Build a value for a AND operation with the vorrect bitposition
    line_offset = ( y / 8 ) * 128; //On the ST7565 there are 8 lines with each 128 bytes width
    for (coord_t x=0; x<16; x++) { //Walk through 16 bytes form left to right (128 Pixel)
      p=displayBuf + line_offset + ( x * 8 ); //Calculate the position of the first byte im array
      // adressing the bytes sequential and set the bits at the correct position merging them with an OR operation to get all bits in one byte
      // the position of the LSB is the right-most position of the byte to the ST7920
    result = ((*p++ & col_offset)!=0?0x80:0); 
    result|= ((*p++ & col_offset)!=0?0x40:0);
    result|= ((*p++  & col_offset)!=0?0x20:0);
    result|= ((*p++  & col_offset)!=0?0x10:0);
    result|= ((*p++  & col_offset)!=0?0x08:0);
    result|= ((*p++  & col_offset)!=0?0x04:0);
    result|= ((*p++  & col_offset) !=0?0x02:0);
    result|= ((*p++  & col_offset)!=0?0x01:0);
    PORTA_LCD_DAT = result;
      PORTC_LCD_CTRL |= (1<<OUT_C_LCD_E);
      _delay_us(8);
      PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_E);
      _delay_us(49);
    }
  }
#else  //All other LCD
  uint8_t * p = displayBuf;
  for (uint8_t y=0; y < 8; y++) {
#if defined(LCD_ST7565R)
    lcdSendCtl(0x01);
#else
    lcdSendCtl(0x04);
#endif
    lcdSendCtl(0x10); // Column addr 0
    lcdSendCtl( y | 0xB0); //Page addr y
    PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_CS1);
#if defined(LCD_MULTIPLEX)
    DDRA = 0xFF; // Set LCD_DAT pins to output
#endif
    PORTC_LCD_CTRL |=  (1<<OUT_C_LCD_A0);
    PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_RnW);
    for (coord_t x=LCD_W; x>0; --x) {
      PORTA_LCD_DAT = *p++;
      PORTC_LCD_CTRL |= (1<<OUT_C_LCD_E);
      PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_E);
    }
    PORTC_LCD_CTRL |=  (1<<OUT_C_LCD_A0);
    PORTC_LCD_CTRL |=  (1<<OUT_C_LCD_CS1);
  }
#endif  
  LCD_UNLOCK();
#if defined(LCD_ST7920)
  return state;
#endif  

}