예제 #1
0
파일: Exp05_7.c 프로젝트: neoelec/ok128c_2
static void LCD_3d(uint16_t number)
{                                               /* display 3-digit decimal number */
    uint8_t i, flag;

    flag = 0;
    i = number / 100;                           // 10^2
    if (i == 0)
        LCD_data(' ');
    else {
        LCD_data(i + '0');
        flag = 1;
    }

    number = number % 100;                      // 10^1
    i = number / 10;
    if ((i == 0) && (flag == 0))
        LCD_data(' ');
    else {
        LCD_data(i + '0');
        flag = 1;
    }

    i = number % 10;                            // 10^0
    LCD_data(i + '0');
}
예제 #2
0
파일: Exp10_7.c 프로젝트: neoelec/ok128c_2
int main(void)
{
    MCU_initialize();                           // initialize MCU and kit
    Delay_ms(50);                               // wait for system stabilization
    LCD_initialize();                           // initialize text LCD module
    Beep();

    LCD_string(0x80, "  Analog Comp.  ");       // display title
    LCD_string(0xC0, "  VR1 < 1.23V   ");

    ACSR = _BV(ACBG) | _BV(ACIS1) | _BV(ACIS0); // +input = 1.23V
    SFIOR |= _BV(ACME);                         // use ADC input pin
    ADCSRA &= ~_BV(ADEN);                       // ADEN = 0
    ADMUX = _BV(MUX1) | _BV(MUX0);              // -input = ADC3

    while (1) {
        if ((ACSR & 0x20) == 0x20) {            // if ACO=1, ADC3 < 1.23V
            PORTB = _BV(PB4);                   //   LED1 on
            LCD_command(0xC6);                  //   display "<"
            LCD_data('<');
        } else {                                // if ACO=0, ADC3 > 1.23V
            PORTB = _BV(PB7);                   //   LED4 on
            LCD_command(0xC6);                  //   display ">"
            LCD_data('>');
        }

        Delay_ms(100);                          // delay 100 ms
    }

    return 0;
}
예제 #3
0
파일: Exp18_6.c 프로젝트: neoelec/ok89s52
void main(void)
{
    uint16_t i, j, k;

    Kit_initialize();                           // initialize OK-89S52 kit
    Delay_ms(50);                               // wait for system stabilization
    LCD_initialize();                           // initialize text LCD module
    Beep();

    LCD_string(0x80, " Multiplication ");       // display title
    LCD_string(0xC0, "   0 * 0 = 00   ");

    while (1) {
        for (i = 2; i <= 9; i++) {
            for (j = 1; j <= 9; j++) {
                LCD_command(0xC3);              // display multiplicand
                LCD_data(i + '0');
                LCD_command(0xC7);              // display multiplier
                LCD_data(j + '0');
                k = Mul_8bit(i, j);             // call assembly routine(1)
                LCD_command(0xCB);              // display multiplication
                LCD_2d(k);
                Delay_1sec();                   // call assembly routine(2)
            }
            Beep();
        }
    }
}
예제 #4
0
파일: Exp07_1.c 프로젝트: neoelec/ok89s52
static void Ucompare(uint8_t a, uint8_t b)
{                                               /* uint8_t compare */
    LCD_command(0xC7);
    if (a == b)
        LCD_data('=');
    else if (a > b)
        LCD_data('>');
    else
        LCD_data('<');
    Delay_ms(2000);
}
예제 #5
0
파일: Exp03_4.c 프로젝트: neoelec/ok128c
static void LCD_1d1(float number)
{                                               /* floating-point number x.x */
    uint16_t i, j;

    j = (uint16_t) (number * 10. + 0.5);
    i = j / 10;                                 // 10^0
    LCD_data(i + '0');
    LCD_data('.');
    i = j % 10;                                 // 10^-1
    LCD_data(i + '0');
}
예제 #6
0
void dis_data(unsigned char data)
{
	char data1;
	
	data1=data&0xF0; //takes higher nibble to send to LCD for 4 bit mode
	LCD_data(data1);
	
	data1=(data<<4)&0xF0; //takes lower nibble to send to LCd
	LCD_data(data1);


}
예제 #7
0
파일: Exp18_6.c 프로젝트: neoelec/ok89s52
static void LCD_2d(uint8_t number)
{                                               /* display 2-digit decimal number */
    uint8_t i;

    i = number / 10;                            // 10^1
    if (i == 0)
        LCD_data(' ');
    else
        LCD_data(i + '0');

    i = number % 10;                            // 10^0
    LCD_data(i + '0');
}
예제 #8
0
파일: Exp03_2.c 프로젝트: neoelec/ok128c
int main(void)
{
    MCU_initialize();                           // initialize MCU
    Delay_ms(50);                               // wait for system stabilization
    LCD_initialize();                           // initialize text LCD module

    Set_font();                                 // set user character font

    LCD_command(0x80);                          // display logo
    LCD_data(0x00);
    LCD_string(0x81, " OK-128  V2.2 ");
    LCD_data(0x07);

    while (1) {
        LCD_string(0xC0, "ATmega128 ");         // display message 1
        LCD_data(0x01);
        LCD_data(0x02);
        LCD_data(0x03);
        LCD_data(0x04);
        LCD_data(0x05);
        LCD_data(0x06);
        Beep();
        Delay_ms(2000);
        LCD_string(0xC0, "   2005/03/01   ");   // display message 2
        Delay_ms(2000);
        LCD_string(0xC0, " DUCK-YONG YOON ");   // display message 3
        Delay_ms(2000);
    }

    return 0;
}
예제 #9
0
파일: Exp16_2.c 프로젝트: neoelec/ok89s52
static void LCD_2hex(uint8_t number)
{                                               /* display HEX number xxH */
    uint8_t i;

    i = number >> 4;                            // 16^1
    if (i <= 9)
        LCD_data(i + '0');
    else
        LCD_data(i - 10 + 'A');

    i = number & 0x0F;                          // 16^0
    if (i <= 9)
        LCD_data(i + '0');
    else
        LCD_data(i - 10 + 'A');
}
예제 #10
0
파일: OK128.c 프로젝트: neoelec/ok128c
void LCD_string(uint8_t command, char *string)
{                                               /* display a string on LCD */
    LCD_command(command);                       // start position of string
    while (*string != '\0') {                   // display string
        LCD_data(*string);
        string++;
    }
}
예제 #11
0
파일: OK89S52.c 프로젝트: neoelec/ok89s52
void LCD_string(uint8_t command, char *string)
{                                               /* display a string on text LCD */
    LCD_command(command);
    while (*string != '\0') {
        LCD_data(*string);
        string++;
    }
}
예제 #12
0
파일: Exp18_7.c 프로젝트: neoelec/ok89s52
static void LCD_s3d(int number)
{                                               /* display signed decimal number +xxx */
    signed int i;
    uint8_t flag;

    flag = 0;

    if (number >= 0)
        LCD_data('+');                          // sign
    else
        LCD_data('-');

    number = abs(number);

    i = number / 100;                           // 10^2
    if (i == 0)
        LCD_data(' ');
    else {
        LCD_data(i + '0');
        flag = 1;
    }

    number = number % 100;                      // 10^1
    i = number / 10;
    if ((i == 0) && (flag == 0))
        LCD_data(' ');
    else
        LCD_data(i + '0');

    i = number % 10;                            // 10^0
    LCD_data(i + '0');
}
예제 #13
0
파일: Exp18_7.c 프로젝트: neoelec/ok89s52
static void LCD_s1d3(float number)
{                                               /* display signed real number +x.xxx */
    uint16_t i, j;

    if (number >= 0.0)
        LCD_data('+');                          // sign
    else
        LCD_data('-');

    number = fabsf(number);
    j = (int)(number * 1000. + 0.5);

    i = j / 1000;                               // 10^0
    LCD_data(i + '0');
    LCD_data('.');

    j = j % 1000;                               // 10^-1
    i = j / 100;
    LCD_data(i + '0');

    j = j % 100;                                // 10^-2
    i = j / 10;
    LCD_data(i + '0');

    i = j % 10;                                 // 10^-3
    LCD_data(i + '0');
}
예제 #14
0
void Write_LCD(unsigned char *str, unsigned char n)
{
while(*str && n)
    {
        LCD_data(*str);                                 /* Passing address of a string to LCD data display function */
        str++;                                          /* Increments the address of a string variable              */
        n--;
}
}
예제 #15
0
void LCD_string(const rom char *buffer)
{
    while(*buffer)              // Write data to LCD up to null
    {
        LCD_isbusy();           // Wait while LCD is busy
        LCD_data(*buffer);      // Write character to LCD
        buffer++;               // Increment buffer
    }
}
예제 #16
0
파일: lcd.c 프로젝트: Roboin/SmartCar2015
void LCD_string(unsigned char x, unsigned char y, char *string)
{
  LCD_XY(x, y);
  while (*string != '\0')
  {
    LCD_data(*string);
    string++;
  }
}
예제 #17
0
void Write_TIME_LCD(char *str)
{ unsigned char i=0;
LCD_cmd(0x80);                                          /* LCD command - Force cursor to the bigining of first line */
    while(i!=16)
    {
    LCD_data(*str);                                     /* Passing address of a string to LCD data display function */
    str++;                                              /* String variable address increment                        */
    i++;
    }
str++;                                                  /* String variable address increment                        */
i=17;
LCD_cmd(0xC0);                                          /* Force cursor to the bigining of the 2nd line             */
while(i!=32)
        {
        LCD_data(*str);                                 /* Passing address of a string to LCD data display function */
        str++;                                          /* String variable address increment                        */
        i++;                                            
        }
    }
예제 #18
0
파일: newfile.c 프로젝트: reebot/wins
void LCDProcessEvents() {
    unsigned char p, c;
    for (p = 0; p < 8; p++) {
        LCD_comm(CMD_SET_PAGE | p);
        LCD_comm(CMD_SET_COLUMN_LOWER | 0x00);
        LCD_comm(CMD_SET_COLUMN_UPPER | 0x00);
        for (c = 0; c < 128; c++) {
            LCD_comm(CMD_RMW);
            LCD_data(rpiData.lcd[(128 * p) + c]);
        }
    }
}
예제 #19
0
파일: Exp15_1.c 프로젝트: neoelec/ok89s52
static void RXD_char(void)
{                                               /* receive a character */
    if (RI) {                                   // receive ready ?
        LCD_data(SBUF);                         // if yes, receive and RI=0
        RI = 0;                                 //      and display a character
        cursor += 1;                            // 16 characters OK ?
        if (cursor == 17) {
            LCD_command(0xC0);                  // if yes, go first column
            cursor = 1;
            Beep();
        }
    }
}
예제 #20
0
// 86 screen offset
static void port0(CPU_t *cpu, device_t *dev) {
	if (cpu->input) {
		cpu->bus = 0;
		cpu->input = FALSE;
	} else if (cpu->output) {
		dev->aux = (LPVOID) (0x100 * ((cpu->bus % 0x40) + 0xC0));
		port10(cpu, dev);
		cpu->pio.devices[0x10].aux = dev->aux;
		cpu->output = FALSE;
		device_t lcd_dev;
		lcd_dev.aux = cpu->pio.lcd;
		LCD_data(cpu, &lcd_dev);
	}
	return;
}
예제 #21
0
파일: Exp03_2.c 프로젝트: neoelec/ok128c
static void Set_font(void)
{                                               /* set user character font */
    uint8_t i;
    uint8_t font[] = {
        0x10, 0x18, 0x1C, 0x1E, 0x1C, 0x18, 0x10, 0x00, // character 0
        0x0F, 0x09, 0x09, 0x09, 0x09, 0x09, 0x0F, 0x00, // character 1
        0x08, 0x08, 0x08, 0x0E, 0x08, 0x08, 0x08, 0x00, // character 2
        0x01, 0x02, 0x04, 0x08, 0x00, 0x00, 0x0F, 0x00, // character 3
        0x10, 0x08, 0x04, 0x02, 0x00, 0x00, 0x1E, 0x00, // character 4
        0x0F, 0x08, 0x08, 0x0F, 0x08, 0x08, 0x0F, 0x00, // character 5
        0x04, 0x04, 0x04, 0x1C, 0x04, 0x04, 0x04, 0x00, // character 6
        0x01, 0x03, 0x07, 0x0F, 0x07, 0x03, 0x01, 0x00  // character 7
    };

    LCD_command(0x40);                          // set CGRAM address
    for (i = 0; i < 64; i++)                    // download font data
        LCD_data(font[i]);
}
예제 #22
0
파일: Exp08_5.c 프로젝트: neoelec/ok128c
static void LCD_s1d2(float number)
{                                               /* floating-point number x.xx */
    uint16_t i, j;

    if (number >= 0.)
        LCD_data('+');                          // sign +/-
    else
        LCD_data('-');

    j = (int)(fabs(number) * 100. + 0.5);
    i = j / 100;                                // 10^0
    LCD_data(i + '0');
    LCD_data('.');

    j = j % 100;                                // 10^-1
    i = j / 10;
    LCD_data(i + '0');

    i = j % 10;                                 // 10^-2
    LCD_data(i + '0');
}
예제 #23
0
파일: Exp03_4.c 프로젝트: neoelec/ok128c
static void LCD_2d2(float number)
{                                               /* floating-point number xx.xx */
    uint8_t i, j;

    j = (int32_t) (number * 100. + 0.5);
    i = j / 1000;                               // 10^1
    if (i == 0)
        LCD_data(' ');
    else
        LCD_data(i + '0');

    j = j % 1000;                               // 10^0
    i = j / 100;
    LCD_data(i + '0');
    LCD_data('.');

    j = j % 100;                                // 10^-1
    i = j / 10;
    LCD_data(i + '0');

    i = j % 10;                                 // 10^-2
    LCD_data(i + '0');
}
예제 #24
0
파일: Exp06_4.c 프로젝트: neoelec/ok128c_2
static void LCD_2digit(uint8_t number)
{                                               /* display 2-digit decimal number */
    LCD_data(number / 10 + '0');                // 10^1
    LCD_data(number % 10 + '0');                // 10^0
}
예제 #25
0
void LCD_init() {
    int time = 0;
    LCD_command(CMD_SWRESET);//software reset
    time = _CP0_GET_COUNT();
    while (_CP0_GET_COUNT() < time + 48000000/2/2) {} //delay(500);

	LCD_command(CMD_SLPOUT);//exit sleep
    time = _CP0_GET_COUNT();
	while (_CP0_GET_COUNT() < time + 48000000/2/200) {} //delay(5);

	LCD_command(CMD_PIXFMT);//Set Color Format 16bit
	LCD_data(0x05);
	time = _CP0_GET_COUNT();
	while (_CP0_GET_COUNT() < time + 48000000/2/200) {} //delay(5);

	LCD_command(CMD_GAMMASET);//default gamma curve 3
	LCD_data(0x04);//0x04
	time = _CP0_GET_COUNT();
	while (_CP0_GET_COUNT() < time + 48000000/2/1000) {} //delay(1);

	LCD_command(CMD_GAMRSEL);//Enable Gamma adj
	LCD_data(0x01);
	time = _CP0_GET_COUNT();
	while (_CP0_GET_COUNT() < time + 48000000/2/1000) {} //delay(1);

	LCD_command(CMD_NORML);

	LCD_command(CMD_DFUNCTR);
	LCD_data(0b11111111);
	LCD_data(0b00000110);

    int i = 0;
	LCD_command(CMD_PGAMMAC);//Positive Gamma Correction Setting
	for (i=0;i<15;i++){
		LCD_data(pGammaSet[i]);
	}

	LCD_command(CMD_NGAMMAC);//Negative Gamma Correction Setting
	for (i=0;i<15;i++){
		LCD_data(nGammaSet[i]);
	}

	LCD_command(CMD_FRMCTR1);//Frame Rate Control (In normal mode/Full colors)
	LCD_data(0x08);//0x0C//0x08
	LCD_data(0x02);//0x14//0x08
	time = _CP0_GET_COUNT();
	while (_CP0_GET_COUNT() < time + 48000000/2/1000) {} //delay(1);

	LCD_command(CMD_DINVCTR);//display inversion
	LCD_data(0x07);
	time = _CP0_GET_COUNT();
	while (_CP0_GET_COUNT() < time + 48000000/2/1000) {} //delay(1);

	LCD_command(CMD_PWCTR1);//Set VRH1[4:0] & VC[2:0] for VCI1 & GVDD
	LCD_data(0x0A);//4.30 - 0x0A
	LCD_data(0x02);//0x05
	time = _CP0_GET_COUNT();
	while (_CP0_GET_COUNT() < time + 48000000/2/1000) {} //delay(1);

	LCD_command(CMD_PWCTR2);//Set BT[2:0] for AVDD & VCL & VGH & VGL
	LCD_data(0x02);
	time = _CP0_GET_COUNT();
	while (_CP0_GET_COUNT() < time + 48000000/2/1000) {} //delay(1);

	LCD_command(CMD_VCOMCTR1);//Set VMH[6:0] & VML[6:0] for VOMH & VCOML
	LCD_data(0x50);//0x50
	LCD_data(99);//0x5b
	time = _CP0_GET_COUNT();
	while (_CP0_GET_COUNT() < time + 48000000/2/1000) {} //delay(1);

	LCD_command(CMD_VCOMOFFS);
	LCD_data(0);//0x40
	time = _CP0_GET_COUNT();
	while (_CP0_GET_COUNT() < time + 48000000/2/1000) {} //delay(1);

	LCD_command(CMD_CLMADRS);//Set Column Address
	LCD_data16(0x00);
    LCD_data16(_GRAMWIDTH);

	LCD_command(CMD_PGEADRS);//Set Page Address
	LCD_data16(0x00);
    LCD_data16(_GRAMHEIGH);

	LCD_command(CMD_VSCLLDEF);
	LCD_data16(0); // __OFFSET
	LCD_data16(_GRAMHEIGH); // _GRAMHEIGH - __OFFSET
	LCD_data16(0);

	LCD_command(CMD_MADCTL); // rotation
    LCD_data(0b00001000); // bit 3 0 for RGB, 1 for GBR, rotation: 0b00001000, 0b01101000, 0b11001000, 0b10101000

	LCD_command(CMD_DISPON);//display ON
	time = _CP0_GET_COUNT();
	while (_CP0_GET_COUNT() < time + 48000000/2/1000) {} //delay(1);

	LCD_command(CMD_RAMWR);//Memory Write
}
예제 #26
0
void LCD_command_1D(short command, short data) {
  LCD_data(data);
  LCD_command(command);
}
예제 #27
0
void LCD_command_2D(short command, int data) {
  LCD_data(data & 0xFF);
  LCD_data((data >> 8) & 0xFF);
  LCD_command(command);
}