I'm not fully understanding, if you right shift 32 bits from a size of 4 bytes, you have nothing left, all bits are shifted out.
Just clear the array.
Post the code you have.
EDIT: are you saying that code like this isn't working how you expect
long l_Data = 0x00FF0000;
l_Data = l_Data >> 8;
Yep exactly, I'm getting some stupidity when the top bits are manipulated.
I started out with something simple like this
#include <Flash.h>
#include <LiquidCrystal.h>
#include <ctype.h>
#include <limits.h>
// select the pins used on the LCD panel
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
byte workingstorage[] = {
0xFF, 0xFF, 0xFF, 0xFF };
void setup()
{
Serial.begin(115200);
lcd.begin(16, 2); // Start the LCD library
lcd.clear(); // Clear LCD
}
void loop(){
shifter(workingstorage,false,1);
lcd.setCursor(0,1); //set the LCD to the second line pos 0
mask_to_str(workingstorage);
delay(1000);
}
void shifter(uint8_t* mask, boolean right, int count){
unsigned long ulong;
ulong = ( (mask[0] << 24)
+ (mask[1] << 16)
+ (mask[2] << 8)
+ (mask[3] ) );
if (right)
{
ulong = ulong >>count;
}
else{
ulong = ulong <<count;
}
mask[0] = (int)((ulong >> 24) & 0xff) ;
mask[1] = (int)((ulong >> 16) & 0xff) ;
mask[2] = (int)((ulong >> 8) & 0xff);
mask[3] = (int)((ulong & 0xff));
}
void mask_to_str(const uint8_t* mask)
{
static char buf[16];
// This chews up code size!! adding 1.5k
sprintf(buf,"%03d-%03d-%03d-%03d",mask[0],mask[1],mask[2],mask[3]);
lcd.print(buf);
}
But as the mask travels left or right , and I print out the 'store' array the values are jumping or sometimes appearing in the wrong place
I thought it was something stupid like sign extension