Anonymous avatar Anonymous committed afbc872

Better integration of (currently not working) compatibility to Roman's circuit

Comments (0)

Files changed (2)

LiquidCrystal_SR1.cpp

 #define SR_RS_BIT		B00000100	/* = Qc */
 #define SR_EN_BIT		B10000000	/* = Qh */
 #define SR_UNUSED_BITS	B00000011	/* = Qa + Qb */
+#define SR_SREN_BIT		B00001000	/* = Qd */
 
 // send
 void LiquidCrystal_SR1::send(uint8_t value, uint8_t mode)
 {
-	uint8_t val1, val2;
-
+	uint8_t val;
 
 	// Divide byte in two nibbles (val1 and val2), include the RS signal
 	// and format it for shiftregister output wiring to the LCD
 	mode = mode ? SR_RS_BIT : 0; // RS bit; LOW: command.  HIGH: character.
 
-	//not working - trying to be compatible to romans circuit
-	//val1 = mode | SR_EN_BIT | (value & 0xF0); // upper nibble
-	//val2 = mode | SR_EN_BIT | ((value << 4) & 0xF0); // lower nibble
+#if 0 /* 1 = Roman's circuit
+	//trying to be compatible to Roman Black's circuit - not working, but why?
+	val = mode | (value /* & 0xF0 */); // upper nibble
+	val |= SR_UNUSED_BITS; // unused outputs to high (faster)
+	shiftIt(val,SR_SREN_BIT);
 
-	// upper nibble
-	val1 = mode | ((value >> 1) /* & 0x78 */);
-	val1 |= SR_UNUSED_BITS; // unused outputs to high (faster)
-	val1 |= SR_EN_BIT; // Enable high
-	fio_shiftOut1(_srSignalRegister,_srSignalBit,val1);
+	val = mode | SR_SREN_BIT | ((value << 4) /* & 0xF0 */); // lower nibble
+	val |= SR_UNUSED_BITS; // unused outputs to high (faster)
+	shiftIt(val,SR_SREN_BIT);
+#else
+	//using different outputs on the shift register seems to make it work...
+	val = mode | ((value >> 1) /* & 0x78 */); // upper nibble
+	val |= SR_UNUSED_BITS; // unused outputs to high (faster)
+	shiftIt(val,SR_EN_BIT);
+
+	val = mode | ((value << 3) /* & 0x78 */); // lower nibble
+	val |= SR_UNUSED_BITS; // unused outputs to high (faster)
+	shiftIt(val,SR_EN_BIT);
+#endif
+
+}
+void LiquidCrystal_SR1::shiftIt(uint8_t val,uint8_t enableBit)
+{
+	val |= enableBit; // Enable Bit HIGH
+	fio_shiftOut1(_srSignalRegister,_srSignalBit,val);
 	waitUsec(1);
-	val1 &= ~SR_EN_BIT; // Enable low
-	fio_shiftOut1(_srSignalRegister,_srSignalBit,val1);
-	waitUsec(40);
-
-	// lower nibble
-	val2 = mode | ((value << 3) /* & 0x78 */);
-	val2 |= SR_UNUSED_BITS; // unused outputs to high (faster)
-	val2 |= SR_EN_BIT; // Enable high
-	fio_shiftOut1(_srSignalRegister,_srSignalBit,val2);
-	waitUsec(1);
-	val2 &= ~SR_EN_BIT; // Enable low
-	fio_shiftOut1(_srSignalRegister,_srSignalBit,val2);
+	val &= ~enableBit; // Enable Bit LOW
+	fio_shiftOut1(_srSignalRegister,_srSignalBit,val);
 	waitUsec(40);
 }

LiquidCrystal_SR1.h

 public:
    /*!
     @method     
-    @abstract   LCD SHIFT REGISTER constructors.
+    @abstract   LCD SHIFT REGISTER constructor.
     @discussion Defines the pin assignment that the LCD will have.
     The constructor does not initialize the LCD. Assuming 1 line 8 pixel high 
     font.
    
    
 private:
+   /*!
+    * @method
+    * @abstract takes care of the 1 wire shift out process
+    */
+   void shiftIt(uint8_t val,uint8_t enableBit);
 
    // signal pin
    fio_register _srSignalRegister;
    fio_bit  _srSignalBit;
-
 };
 
 #endif
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.