1. F Malpartida
  2. New LiquidCrystal

Commits

f...@hp-work  committed a1a2d29

Shift1 cascading support

  • Participants
  • Parent commits 1edad34
  • Branches fastIO

Comments (0)

Files changed (2)

File FastIO.cpp

View file
  • Ignore whitespace
 	fio_digitalWrite(shift1Register,shift1Bit,HIGH);
 	delayMicroseconds(300);
 }
-void fio_shiftOut1(fio_register shift1Register, fio_bit shift1Bit, uint8_t value){
+void fio_shiftOut1(fio_register shift1Register, fio_bit shift1Bit, uint8_t value, boolean noLatch){
 	/*
 	 * this function are based on Shif1 protocol developed by Roman Black (http://www.romanblack.com/shift1.htm)
 	 *
 	 * test sketches:
 	 * 	http://pastebin.com/raw.php?i=2hnC9v2Z
 	 * 	http://pastebin.com/raw.php?i=bGg4DhXQ
-	 * 	http://pastebin.com/raw.php?i=tg1ZFiM5 - flickering neighbor
+	 * 	http://pastebin.com/raw.php?i=tg1ZFiM5
 	 * tested with:
 	 * 	TPIC6595N - seems to work fine (circuit: http://www.3guys1laser.com/arduino-one-wire-shift-register-prototype)
-	 * 	7HC595N - flickering neighbor
+	 * 	7HC595N
 	 */
-
 	// disable interrupts since timing is going to be critical
 	uint8_t oldSREG;
 	oldSREG = SREG;
 	cli();
 
 	// iterate but ignore last bit (is it correct now?)
-	for(int8_t i = 7; i>=1; --i){
+	for(int8_t i = 7; i>=0; --i){
 
 		// assume that pin is HIGH (smokin' pot all day... :) - requires initialization
 		if(LOW==!!(value & (1 << i))){
 			//hold pin HIGH for 15us
 			delayMicroseconds(15);
 		}
+		if(!noLatch && i==1) break;
 	}
-	// send last bit (=LOW) and Latch command
-	fio_digitalWrite_SWITCHTO(shift1Register,shift1Bit,LOW);
-	// Hold pin low for 200us
-	delayMicroseconds(199);
-	fio_digitalWrite_HIGH(shift1Register,shift1Bit);
-	// Hold pin high for 300us and leave it that way - using explicit HIGH here, just in case.
-	delayMicroseconds(299);
+	if(!noLatch){
+		// send last bit (=LOW) and Latch command
+		fio_digitalWrite_SWITCHTO(shift1Register,shift1Bit,LOW);
+		// Hold pin low for 200us
+		delayMicroseconds(199);
+		fio_digitalWrite_HIGH(shift1Register,shift1Bit);
+		// Hold pin high for 300us and leave it that way - using explicit HIGH here, just in case.
+		delayMicroseconds(299);
+	}
 
 	// enable interrupts
 	SREG = oldSREG;
 
 }
-void fio_shiftOut1(uint8_t pin, uint8_t value){
-	fio_shiftOut1(fio_pinToOutputRegister(pin, SKIP),fio_pinToBit(pin),value);
+void fio_shiftOut1(uint8_t pin, uint8_t value, boolean noLatch){
+	fio_shiftOut1(fio_pinToOutputRegister(pin, SKIP),fio_pinToBit(pin),value, noLatch);
 }

File FastIO.h

View file
  • Ignore whitespace
  * @param shift1Bit[in] pins bit
  * @param value[in] value to shift out, last byte is ignored and always shifted out LOW
  */
-void fio_shiftOut1(fio_register shift1Register, fio_bit shift1Bit, uint8_t value);
+void fio_shiftOut1(fio_register shift1Register, fio_bit shift1Bit, uint8_t value, boolean noLatch = false);
 /*!
  * @method
  * @abstract one wire shift out
  * @param pin[in] digital pin
  * @param value[in] value to shift out, last byte is ignored and always shifted out LOW
  */
-void fio_shiftOut1(uint8_t pin, uint8_t value);
+void fio_shiftOut1(uint8_t pin, uint8_t value, boolean noLatch = false);
 /*!
  * @method
  * @abstract initializes one wire shift out protocol