def main(): pad = lp.get_me_a_pad() # frames = [hertz_1, hertz_2, hertz_3, hertz_4] # frames = [smiley] for _ in range(20): for frame in frames: for y, row in enumerate(frame, 1): for x, col in enumerate(row): color = int(col) b = (color & 0xF00) >> 8 g = (color & 0x0F0) >> 4 r = color & 0x00F # Scale up the colour range to the Launchpad 6 bits format b = arduino_map(b, 0, 15, 0, 63) g = arduino_map(g, 0, 15, 0, 63) r = arduino_map(r, 0, 15, 0, 63) pad.set_led_xy(x, y, r, g, b) time.sleep(.02)
def tree(pad): """ Draw a christmas tree :param pad: :return: """ pad.draw_colour = pad.colours['green'] pad.draw_char(bmp.tree) def snow_tree(pad): snow_flakes = [0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x00, 0x40, 0x00, 0x80, 0x00] snow_rows = [] for _ in range(10): snow_rows.insert(0, choice(snow_flakes)) for y in range(len(snow_rows)): draw_single_snow_row(pad, snow_rows, y) if len(snow_rows) == 9: snow_rows.pop(8) time.sleep(.8) if __name__ == "__main__": launchpad = lp.get_me_a_pad() launchpad.reset() tree(launchpad) snow_tree(launchpad)
bits.append(bin_val[bit]) bin_bitmap.append(bits) # Rotate the bitmap bin_rot = np.rot90(bin_bitmap, amount, axes=(1, 0)) rotated_bmp = [] # convert the bitmap back to a list of decimal numbers for row in bin_rot: dec_val = sum(int(b) << i for i, b in enumerate(row[::-1])) rotated_bmp.append(dec_val) return rotated_bmp def spin_ghost(pad): """ Rotate the ghost bitmap 360' :return: """ ghost = bmp.ghost_one colours = ['red', 'green', 'blue', 'yellow', 'red'] for spin in range(5): pad.draw_colour = pad.colours[colours[spin]] pad.draw_char(ghost) time.sleep(0.5) ghost = rotate_bitmap(ghost) if __name__ == "__main__": pad = pylp.get_me_a_pad() spin_ghost(pad)
import pylaunchpad as lp if __name__ == "__main__": pad = lp.get_me_a_pad() pad.set_all_on_slow pad.reset()
:return: """ # set the top row to a set of colours pad.reset() pad.setup_painter_colours() pad.in_ports.set_callback(pad.paint_app) while True: if pad.last_x >= 8 and pad.last_y == 8: break time.sleep(.4) pad.in_ports.cancel_callback() pylp.save_frame(pad.painter_frame) pad.reset() launchpad = pylp.get_me_a_pad() demos(launchpad) # pylp.load_frame(launchpad,"my_picture - Copy.csv") # input("wait") #painter(launchpad) # launchpad.scroll_frames_right([source_bmp.pac_one, source_bmp.pac_two]) #painter_with_colour(launchpad) #demos(launchpad) print("Press any of the Launchpad Keys or the bottom right pad to exit") #painter(launchpad) print("Choose a colour to paint with or the bottom right pad to exit") #painter_with_colour(launchpad) patterns.show_file(launchpad, "fireworks.csv")
def main(): pad = lp.get_me_a_pad() count_up(pad) while True: decimal = get_a_number() draw_binary(pad, decimal)