In [103]:
def calc_pos_off(wrap_mode=True, bits_per_pixel=2, g_RAM_FRAME_SIZE=256, image_base_x_offset=4, wrap_begin=3, wrap_end=200, loop=100):
if bits_per_pixel == 1:
pixel_per_byte = 8
elif bits_per_pixel == 2:
pixel_per_byte = 4
elif bits_per_pixel == 4:
pixel_per_byte = 2
image_offset_x = image_base_x_offset * pixel_per_byte
x_position = 0
wrap_counter = 0
print("---------------------------------")
print(" i | x_pos | img_off | wrp_cnt - Wrapmode {} - {}Bits/Pixel - {}Pixel/Byte".format(wrap_mode, bits_per_pixel, pixel_per_byte))
print("-----|--------|---------|--------")
for i in range(loop): # Calculate me the next x position
# Print stuff
print("{:4} | {:6} | {:7} | {:7}".format(i, x_position, image_offset_x, wrap_counter))
# Do calculations each loop
if (bits_per_pixel == 1): # 8 Pixel/Byte
if wrap_mode and (x_position + (g_RAM_FRAME_SIZE/1) > (wrap_end)):
image_offset_x = (image_base_x_offset*pixel_per_byte) + x_position + (g_RAM_FRAME_SIZE/1) - wrap_end + wrap_begin
x_position = x_position + (g_RAM_FRAME_SIZE/1) - wrap_end + wrap_begin
wrap_counter = wrap_counter + 1
else:
x_position = x_position + (g_RAM_FRAME_SIZE/1)
image_offset_x = (image_base_x_offset*pixel_per_byte) + x_position + (g_RAM_FRAME_SIZE/1)
elif (bits_per_pixel == 2): # 4 Pixel/Byte
if wrap_mode and (x_position + (g_RAM_FRAME_SIZE/2) > (wrap_end)):
image_offset_x = (image_base_x_offset*pixel_per_byte) + x_position + (g_RAM_FRAME_SIZE/2) - wrap_end + wrap_begin
x_position = x_position + (g_RAM_FRAME_SIZE/2) - wrap_end + wrap_begin
wrap_counter = wrap_counter + 1
else:
x_position = x_position + (g_RAM_FRAME_SIZE/2)
image_offset_x = (image_base_x_offset*pixel_per_byte) + x_position + (g_RAM_FRAME_SIZE/2)
else: # 2 Pixel/Byte
if wrap_mode and (x_position + (g_RAM_FRAME_SIZE/4) > (wrap_end)):
image_offset_x = (image_base_x_offset*pixel_per_byte) + x_position + (g_RAM_FRAME_SIZE/4) - wrap_end + wrap_begin
x_position = x_position + (g_RAM_FRAME_SIZE/4) - wrap_end + wrap_begin
wrap_counter = wrap_counter + 1
else:
x_position = x_position + (g_RAM_FRAME_SIZE/4)
image_offset_x = (image_base_x_offset*pixel_per_byte) + x_position + (g_RAM_FRAME_SIZE/4)
In [104]:
g_RAM_FRAME_SIZE = 256
image_base_x_offset = 4
loop = 10
wrap_begin = 10
wrap_end = 200
calc_pos_off(False, 4, g_RAM_FRAME_SIZE, image_base_x_offset, wrap_begin, wrap_end, loop)
calc_pos_off(True, 4, g_RAM_FRAME_SIZE, image_base_x_offset, wrap_begin, wrap_end, loop)
calc_pos_off(False, 2, g_RAM_FRAME_SIZE, image_base_x_offset, wrap_begin, wrap_end, loop)
calc_pos_off(True, 2, g_RAM_FRAME_SIZE, image_base_x_offset, wrap_begin, wrap_end, loop)
calc_pos_off(False, 1, g_RAM_FRAME_SIZE, image_base_x_offset, wrap_begin, wrap_end, loop)
calc_pos_off(True, 1, g_RAM_FRAME_SIZE, image_base_x_offset, wrap_begin, wrap_end, loop)
In [102]:
def calc_off(bits_per_pixel=2, g_RAM_FRAME_SIZE=256, image_base_x_offset=4, loop=100):
if bits_per_pixel == 1:
pixel_per_byte = 8
elif bits_per_pixel == 2:
pixel_per_byte = 4
elif bits_per_pixel == 4:
pixel_per_byte = 2
image_offset_x = image_base_x_offset * pixel_per_byte
x_position = 0
print("--------------")
print(" i | img_off - {}Bits/Pixel - {}Pixel/Byte".format(bits_per_pixel, pixel_per_byte))
print("-----|--------")
for i in range(loop): # Calculate me the next x position
# Print stuff
print("{:4} | {:6}".format(i, image_offset_x))
# Do calculations each loop
if (bits_per_pixel == 1): # 8 Pixel/Byte
image_offset_x <= image_offset_x - g_RAM_FRAME_SIZE/1
elif (bits_per_pixel == 2): # 4 Pixel/Byte
image_offset_x <= image_offset_x - g_RAM_FRAME_SIZE/2
else: # 2 Pixel/Byte
image_offset_x <= image_offset_x - g_RAM_FRAME_SIZE/4
In [ ]:
g_RAM_FRAME_SIZE = 256
image_base_x_offset = 4
loop = 10
wrap_begin = 10
wrap_end = 200
calc_pos_off(False, 2, g_RAM_FRAME_SIZE, image_base_x_offset, wrap_begin, wrap_end, loop)
calc_pos_off(True, 2, g_RAM_FRAME_SIZE, image_base_x_offset, wrap_begin, wrap_end, loop)
calc_pos_off(False, 4, g_RAM_FRAME_SIZE, image_base_x_offset, wrap_begin, wrap_end, loop)
calc_pos_off(True, 4, g_RAM_FRAME_SIZE, image_base_x_offset, wrap_begin, wrap_end, loop)
calc_pos_off(False, 8, g_RAM_FRAME_SIZE, image_base_x_offset, wrap_begin, wrap_end, loop)
calc_pos_off(True, 8, g_RAM_FRAME_SIZE, image_base_x_offset, wrap_begin, wrap_end, loop)