10 hc595::
hc595(uint8_t latch,uint8_t clock,uint8_t data,uint8_t num)
15 Buffer=(uint8_t*)malloc(num);
16 for(uint8_t i=0;i<num;i++) Buffer[i]=0;
17 pinMode(latchPin, OUTPUT);
18 pinMode(dataPin, OUTPUT);
19 pinMode(clockPin, OUTPUT);
22 b_Latch = digitalPinToBitMask(latchPin);;
27 p_Latch=(uint8_t *)portOutputRegister(digitalPinToPort(latchPin));
44 bitWrite(Buffer[num],3,LOW);
48 bitWrite(Buffer[num],3,HIGH);
52 bitWrite(Buffer[num],3,LOW);
54 delayMicroseconds(38);
66 for( uint8_t i=num_595;i;i--)
72 register uint8_t tmp=128;
76 send=((uint8_t)Buffer[i-1] &tmp);s
77 if(send) PORTD |= B10000000;
78 else PORTD &= ~ B10000000;
93 *p_Latch &= ~(uint8_t)b_Latch;
94 for(
register uint8_t i=num_595;i;i--)
FastshiftOut(dataPin, clockPin, Buffer[i-1]);
95 *p_Latch |=(uint8_t) b_Latch;
105 Set595Pin(val,display);
113 void hc595::
Set595Pin(
bool D7,
bool D6,
bool D5,
bool D4,
bool D3,
bool D2,
bool D1,
bool D0,uint8_t num)
115 Buffer[num]=(D7<<7)+(D6<<6)+(D5<<5)+(D4<<4)+(D3<<3)+(D2<<2)+(D1<<1)+D0;
121 void hc595::Set595Pin(uint8_t val,uint8_t num)
132 bitWrite(Buffer[sr],pin,status);
147 delayMicroseconds(4100);
149 SetLcdPin(0,0,1,1,num);
151 delayMicroseconds(4200);
153 SetLcdPin(0,0,1,1,num);
155 delayMicroseconds(110);
157 SetLcdPin(0,0,1,1,num);
160 SetLcdPin(0,0,1,0,num);
164 SendLcdCommand(options,num);
176 for(
int i=0;i<ln;i++) {DisplayChar(buff[i],display);}
186 SetLcdRS(HIGH,display);
187 SetHLcd(buff,display);
189 SetLLcd(buff,display);
191 delayMicroseconds(37);
197 bitWrite(Buffer[num],7,D7);
198 bitWrite(Buffer[num],6,D6);
199 bitWrite(Buffer[num],5,D5);
200 bitWrite(Buffer[num],4,D4);
213 int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };
214 if(type==2) {row_offsets[2]=0x10; row_offsets[3]=0x50;}
218 val=(0x80 | (X + row_offsets[Y]));
219 SendLcdCommand(val,display);
225 uint8_t val=(0x80 | address);
226 SendLcdCommand(val,display);
247 SendLcdCommand(0x40 | (address << 3),display);
248 for (
int i=0; i<8; i++) DisplayChar(map[i],display);
278 SetLcdRS(LOW,display);
279 SetHLcd(val,display);
281 SetLLcd(val,display);
283 delayMicroseconds(37);
290 bitWrite(Buffer[display],1,Val);
296 SetLcdPin(bitRead(val,7),bitRead(val,6),bitRead(val,5),bitRead(val,4),display);
301 SetLcdPin(bitRead(val,3),bitRead(val,2),bitRead(val,1),bitRead(val,0),display);
void SetLcdRS(bool, uint8_t)
#define LCD595_DISPLAY_ON
void SendLcdCommand(uint8_t, uint8_t)
This function is useful to send directly some commands to the display. val This is the option parame...
void DisplayWrite(const char *, uint8_t)
Write a string on the specificated display starting from actual position.
void DisplayReset(uint8_t, uint8_t)
Reset of the display.
void SetDDRAM_Address(uint8_t, uint8_t)
hc595(uint8_t, uint8_t, uint8_t, uint8_t)
costructor
#define LCD595_BASIC_DISPLAY_INIT
#define LCD595_DISPLAY_CLEAR
void Set595Pin(bool, bool, bool, bool, bool, bool, bool, bool, uint8_t)
Using this function you can set every bit of the buffer of a single 74HC595 internal buffer using sin...
void Set595Pin(uint8_t, uint8_t)
set internal buffer of single 74hc595 (without update the real chip status but only internal buffer ...
void SetLcdPin(bool, bool, bool, bool, uint8_t)
#define FastshiftOut(a, b, d)
void SetHLcd(uint8_t, uint8_t)
#define LCD595_USEFONT_5X10
void SetCursor(uint8_t, uint8_t, uint8_t, uint8_t)
move virtual cursor to x,y position
void CreateChar(uint8_t, uint8_t[], uint8_t)
Used to redefine some custom characters. The char is the number of the character to redefine (0-7)...
void Send595Pin(uint8_t, uint8_t)
It works as the sum of Set595Pin and the Send595, in the sense that sets the 8-bit and sends them dir...
void SetLLcd(uint8_t, uint8_t)
void Send595(void)
It sends the internal buffer to the shift register chain. This produce a update of all outputs of all...
void Lcd_SetFreePin(uint8_t, bool, uint8_t)
Sets the free pins (2 and 0) of 74HC595 connected to a display. ,.
void PulseE(uint8_t)
internal function, don't use direcly
void DisplayChar(uint8_t, uint8_t)
Write a single char on the specificated display starting from actual position.