#include #define F_CPU 8000000UL #include #include #include #include #include #include "font.h" //#include "tex.h" #include #define PIN_SCK PORTB7 #define PIN_MOSI PORTB5 #define PIN_SS PORTB4 #define PIN_MISO PORTB6 #define DIGIT0 0x01 #define DIGIT1 0x02 #define DIGIT2 0x03 #define DIGIT3 0x04 #define DIGIT4 0x05 #define DIGIT5 0x06 #define DIGIT6 0x07 #define DIGIT7 0x08 #define MAX71219_DATAIN1 PORTB |= (1<0;i--) spiSendByte(spidata[i-1]); //latch the data onto the display MAX7219_LOAD1; } //********************************************************* void clearDisplay1(int addr) { int offset; if(addr<0 || addr>=2) return; offset=addr*8; for(int i=7;i<8;i++) { status[offset + i]=0; spiTransfer(addr, i+1,status[offset + i]); } } //******************************************************************************** void setLed(int addr, int row, int column, bool state) { int offset; uint8_t val=0x00; if(addr<0 || addr>=2) return; if(row<0 || row>7 || column<0 || column>7) return; offset=addr*8; val= 0b10000000 >> column; if(state) status[offset+row]=status[offset+row]|val; else { val=~val; status[offset+row]=status[offset+row]&val; } spiTransfer(addr, row+1,status[offset+row]); } //***************************************************************************** void setRow(int addr, uint8_t row, uint8_t value) { int offset; if(addr<0 || addr>=2) return; if(row<0 || row>7) return; offset=addr*8; status[offset+row]=value; spiTransfer(addr, row+1,status[offset+row]); } //************************************************************************************ void setColumn(int addr, int col, uint8_t value) { uint8_t val; if(addr<0 || addr>=2) return; if(col<0 || col>7) return; for(int row=0;row<8;row++) { val=value >> (7-row); val=val & 0x01; setLed(addr,row,col,val); } } //************************************************************************************** void setChar(int addr, uint8_t value) { offset=addr*8; for(k = 0; k < 8; k++){ v = pgm_read_byte (&font [value] [k]);//v=charTable[index]; status[offset+k]=v; spiTransfer(addr, k+1,v); } } //****************************************************************************************** void clearDisplay() { char zeile[8]; for(i=0;i<8;i++) { zeile[i] = 0x00; sendByte(i+1,zeile[i], i+1,zeile[i]); //_delay_ms(200); } } //****************** function to write byte to LCD controller ***************************************** /*Input: data byte to write to LCD rs 1: write data 0: write instruction */ uint16_t address_counter = 0; uint16_t ac; void lcd_write(uint8_t data,uint8_t rs) { if(rs == 0) //write to instruction register { //DDRB = 0xff; PORTB &= ~(1<