コード例 #1
0
ファイル: main.c プロジェクト: sphincs/LCD
void main()
{
  lcdInit();
  spiOn();
  spiOff();
  sendByte(out);
  sendArray(array);
  lcdOn();
  lcdOff();
  sendBuffer();
  sendPart(3, 7, LCD_Buffer);
  clear();
  clearPart(5, 76);
  clearPartColor(5, 76, clBLACK);
  setPenColor(clBLACK);
  setBackColor(clWHITE);
  delay_nsek(40);
  scsOn();
  scsOff();
  i =  getValue(LCD_Buffer, 23, 266);
  setValue(LCD_Buffer, 23, 266, 0x3F);
  setCharge();
  resetCharge();
  drawPixel(5, 5, LCD_Buffer);
  drawVLine(5, 5, 5, LCD_Buffer);
  drawHLine(5, 5, 5, LCD_Buffer);
  drawLine(5, 5, 55, 55, LCD_Buffer);
  drawRect(5, 5, 55, 55, LCD_Buffer);
  drawFillRect(5, 5, 55, 55, clWHITE, LCD_Buffer);
  drawCircle(10, 10, 5, LCD_Buffer);
}
コード例 #2
0
ファイル: display.c プロジェクト: bgomberg/TapeBot
//Initializes the LCD as described in the HD44780 datasheet.
//Normally called only by the initialize() function in utility.c.
void lcdInit()
{
	//configure LCD E (Enable) control pin as an output
	sbi(DDRD, 6);
	//configure LCD RS (Register Select) control pin as an output
	sbi(DDRD, 7);
	//set LCD E (Enable) line low inititally, so it can rise later
	cbi(PORTD, 6);

	//wait 15ms after power on
	delayMs(15);

	//Issue 'Function Set' commands to initialize LCD for 8-bit interface mode
	writeControl(0x38);
	delayUs(4900); //+100us in writeControl = 5000us or 5ms total
	writeControl(0x38);
	delayUs(50); //+100us in writeControl = 150us total
	writeControl(0x38);

	//Function Set command to specify 2 display lines and character font
	writeControl(0x38);

	//Display off
	lcdOff();

	//Clear display
	clearScreen();

	//Set entry mode
	writeControl(0x06);

	//Display on
	lcdOn();
}
コード例 #3
0
void lcdOnEnable(void) {
    Soft_I2C_Init();
    Delay_ms(40);
    lcdCmd(0x38);
    lcdCmd(0x39);///function IS=1
    lcdCmd(0x14);
    lcdCmd(0x70);///contrast
    lcdCmd(0x56);
    lcdCmd(0x6C);
    Delay_ms(300);
    lcdCmd(0x38);///function IS=0
    lcdOn();
    lcdClear();
}
コード例 #4
0
void main() {
    OSCCON.IRCF2=1;//8Hz
    OSCCON.IRCF1=1;//...
    OSCCON.IRCF0=1;//...
    ANSEL = 0b00000000;///GP0~5をデジタル利用に設定
    GPIO = 0b00000000;///GPIOの中身を空に
    TRISIO = 0b00001111;///GP0~3を入力、4,5を出力
    CMCON0 = 0b00000111;///コンパレータを使わない
    /*OPTION_REG = 0b00000111;///プリスケーラ1:256
    INTCON = 0b10100100;///割り込み設定*/
    OPTION_REG.NOT_GPPU= 0;///ピンのプルアップ使用(スイッチ入力用)
    WPU = 0b00000011;///GP0,1をプルアップ
    lcdOnEnable();///lcd起動
    lcdClear();
    clockReload();
    while(1) {///1tick = 10ms(100回で1秒)
        if(count==100&&mode==0) {
            countUp(0,1);
            clockReload();
            count=0;
        } else if(mode==2) {
            if(count==100) {
                countUp(0,1);
                count=0;
            }
            stopWatchReload();
            ///stopwatch
        } else if(mode==1) {
            count=0;
        }
        //////////////////////////button
        if(Button(&GPIO,0,0,0)) {
            button1++;
        } else {
            if(300>button1&&button1>5) {
                if(mode==0) {
                    mode=2;
                    swMode=0;
                    sw_down=0;
                    sw_sec=0;
                    sw_min=0;
                    stopWatchReload();
                    ///stopwatch
                } else if(mode==1) {
                    countUp(mode1At,0);
                    clockReload();
                } else if(mode==2) {
                    mode=0;
                    swMode=0;
                    clockReload();
                }
                button1 = 0;
                button2 = 0;
                if(lcdIsOn==0) {
                    lcdOn();
                }
            } else if(button1>=300) {
                if(mode==0) {
                    mode=1;
                    singleHeight();
                    button1 = 0;
                    button2 = 0;
                    if(lcdIsOn==0) {
                        lcdOn();
                    }
                    mode1At=0;
                    clockReload();
                }
            }
            button1 = 0;
        }
        if(Button(&GPIO,1,0,0)) {
            button2++;
        } else {
            if(button2>5) {
                if(mode==0) {
                    last = 0;
                } else if(mode==1) {
                    mode1At++;
                    if(mode1At==3) {
                        mode1At=0;
                        mode=0;
                        doubleHeight();
                    }
                    clockReload();
                } else if(mode==2) {
                    swMode++;
                    if(swMode==2) {
                        swMode=0;
                    } else {
                        sw_down=0;
                        sw_sec=0;
                        sw_min=0;
                    }
                    ///stopwatch
                }
                button1 = 0;
                button2 = 0;
                if(lcdIsOn==0) {
                    lcdOn();
                }
            }
            button2 = 0;
        }
        //////////////////////////////
        if(last==1000) {
            lcdOff();
            last = 0;
        }
        Delay_ms(10);
        count++;
        if(lcdIsOn==1&&mode==0) {
            last++;
        } else {
            last=0;
        }
    }
}
コード例 #5
0
ファイル: main.c プロジェクト: roziqbahtiar/ElinfoUGM
void main(void)
{

PORTA=0x00;
DDRA=0x00;

PORTB=0xFF;
DDRB=0xFF;
 
PORTC=0x00;
DDRC=0x00;

PORTD=0x00;
DDRD=0xFC;

// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: 2000.000 kHz
// Mode: Fast PWM top=0xFF
// OC0 output: Disconnected
TCCR0=0x4A;
TCNT0=0x00;
OCR0=0x0F;

// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: 250.000 kHz
// Mode: Fast PWM top=0x00FF
// OC1A output: Non-Inv.
// OC1B output: Non-Inv.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0xA1;
TCCR1B=0x0B;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;

// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer2 Stopped
// Mode: Normal top=0xFF
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;

// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// INT2: Off
MCUCR=0x00;
MCUCSR=0x00;

// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;

// USART initialization
// USART disabled
UCSRB=0x00;

// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;

// ADC initialization
// ADC Clock frequency: 125.000 kHz
// ADC Voltage Reference: AVCC pin
// Only the 8 most significant bits of
// the AD conversion result are used
ADMUX=ADC_VREF_TYPE & 0xff;
ADCSRA=0x87;

// SPI initialization
// SPI disabled
SPCR=0x00;

// TWI initialization
// TWI disabled
TWCR=0x00;


// Alphanumeric LCD initialization
// Connections are specified in the
// Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu:
// RS - PORTB Bit 0
// RD - PORTB Bit 1
// EN - PORTB Bit 2
// D4 - PORTB Bit 4
// D5 - PORTB Bit 5
// D6 - PORTB Bit 6
// D7 - PORTB Bit 7
// Characters/line: 16
lcd_init(16);   
lcd_clear();
define_char(fullBlock,FULL_BLOCK);
define_char(emptyBlock,EMPTY_BLOCK);
lcdOn(1);

    while (1) {  
          
    }
}