Commits

Anonymous committed 9ad575d

Mpide 0023 Compatibility, shiftOut1 ATOMIC_BLOCK

Comments (0)

Files changed (3)

                    boolean noLatch)
 {
 
-   //TODO: Adapt changes from _rb
-
 	// iterate but ignore last bit (is it correct now?)
 	for(int8_t i = 7; i>=0; --i)
    {
 
 		// assume that pin is HIGH (smokin' pot all day... :) - requires initialization
-		if(LOW==!!(value & (1 << i)))
+      if(value & _BV(i))
       {
-			// LOW = 0 Bit
-			fio_digitalWrite_SWITCHTO(shift1Register,shift1Bit,LOW);
-			// hold pin LOW for ... (was 15us)
+         ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
+         {
+   			// HIGH = 1 Bit
+   			fio_digitalWrite_SWITCHTO(shift1Register,shift1Bit,LOW);
+   			//hold pin LOW for 1us - done! :)
+   			fio_digitalWrite_SWITCHTO(shift1Register,shift1Bit,HIGH);
+   			//hold pin HIGH for ... (was 15us)
+         }
 			delayMicroseconds(6);
-			fio_digitalWrite_SWITCHTO(shift1Register,shift1Bit,HIGH);
-			// hold pin HIGH for ... (was 30us)
-			delayMicroseconds(10);
 		}
       else
       {
-			// HIGH = 1 Bit
-			fio_digitalWrite_SWITCHTO(shift1Register,shift1Bit,LOW);
-			//hold pin LOW for 1us - done! :)
-			fio_digitalWrite_SWITCHTO(shift1Register,shift1Bit,HIGH);
-			//hold pin HIGH for ... (was 15us)
-			delayMicroseconds(6);
+         ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
+         {
+   			// LOW = 0 Bit
+   			fio_digitalWrite_SWITCHTO(shift1Register,shift1Bit,LOW);
+   			// hold pin LOW for ... (was 15us)
+   			delayMicroseconds(6);
+   			fio_digitalWrite_SWITCHTO(shift1Register,shift1Bit,HIGH);
+   			// hold pin HIGH for ... (was 30us)
+         }
+			delayMicroseconds(10);
 		}
 		if(!noLatch && i==1)
       {
 	if(!noLatch)
    {
 		// send last bit (=LOW) and Latch command
-		fio_digitalWrite_SWITCHTO(shift1Register,shift1Bit,LOW);
+	   fio_digitalWrite(shift1Register,shift1Bit,LOW);
 		// Hold pin low for ... (was 200us)
 		delayMicroseconds(96);
-		fio_digitalWrite_HIGH(shift1Register,shift1Bit);
+		fio_digitalWrite(shift1Register,shift1Bit,HIGH);
 		// Hold pin high for ... (was 300us) and leave it that way - using explicit HIGH here, just in case.
 		delayMicroseconds(110);
 	}

examples/HelloWorld_SR1/HelloWorld_SR1.ino

-#include <LiquidCrystal_SR1.h>
-
-LiquidCrystal_SR1 lcd(2);
-//                    |
-//                    \---- Signal Pin
-
-// Creat a set of new characters
-byte armsUp[8] = {0b00100,0b01010,0b00100,0b10101,0b01110,0b00100,0b00100,0b01010};
-byte armsDown[8] = {0b00100,0b01010,0b00100,0b00100,0b01110,0b10101,0b00100,0b01010};
-
-void setup(){
-  lcd.begin(16,2);               // initialize the lcd
-
-  lcd.createChar (0, armsUp);    // load character to the LCD
-  lcd.createChar (1, armsDown);    // load character to the LCD
-
-  lcd.home ();                   // go home
-  lcd.println(F("newLiquidCrystal"));
-
-}
-
-void loop(){
-  // Do a little animation
-  for(int i = 0; i <= 15; i++) showHappyGuy(i);
-  for(int i = 15; i >= 0; i--) showHappyGuy(i);
-}
-
-void showHappyGuy(int pos){
-  lcd.setCursor ( pos, 1 ); // go to position
-  lcd.print(char(random(0,2))); // show one of the two custom characters
-  delay(150); // wait so it can be seen
-  lcd.setCursor ( pos, 1 ); // go to position again
-  lcd.print(F(" ")); // delete character
-}

examples/HelloWorld_SR1/HelloWorld_SR1.pde

+#include <Wire.h>
+#include <LiquidCrystal_SR1.h>
+
+LiquidCrystal_SR1 lcd(2);
+//                    |
+//                    \---- Signal Pin
+
+// Creat a set of new characters
+byte armsUp[8] = {0b00100,0b01010,0b00100,0b10101,0b01110,0b00100,0b00100,0b01010};
+byte armsDown[8] = {0b00100,0b01010,0b00100,0b00100,0b01110,0b10101,0b00100,0b01010};
+
+void setup(){
+  lcd.begin(16,2);               // initialize the lcd
+
+  lcd.createChar (0, armsUp);    // load character to the LCD
+  lcd.createChar (1, armsDown);    // load character to the LCD
+
+  lcd.home ();                   // go home
+  lcd.println("newLiquidCrystal");
+
+}
+
+void loop(){
+  // Do a little animation
+  for(int i = 0; i <= 15; i++) showHappyGuy(i);
+  for(int i = 15; i >= 0; i--) showHappyGuy(i);
+}
+
+void showHappyGuy(int pos){
+  lcd.setCursor ( pos, 1 ); // go to position
+  lcd.print(char(random(0,2))); // show one of the two custom characters
+  delay(150); // wait so it can be seen
+  lcd.setCursor ( pos, 1 ); // go to position again
+  lcd.print(" "); // delete character
+}