-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_hw.py
65 lines (55 loc) · 2.01 KB
/
test_hw.py
1
import hardware def next_color(color_number, intensity): if color_number == 0: current_color = (intensity, 0, 0) elif color_number == 1: current_color = (0, intensity, 0) elif color_number == 2: current_color = (0, 0, intensity) elif color_number == 3: current_color = (intensity, intensity, intensity) return current_colordef main(): count = 0 color_number = 0 intensity = 64 current_color = (intensity, intensity, intensity) light_on = False hw = hardware.Hardware() while True: if hw.button1_pressed(): hw.pixel_color(current_color[0],current_color[1],current_color[2]) light_on = True hw.oled_clear() hw.oled_graphic('/graphics/yingyang.txt', 48, 16) hw.oled_show() if hw.button2_pressed(): hw.pixel_color(0,0,0) light_on = False hw.oled_clear() if hw.button3_pressed(): current_color = next_color(color_number, intensity) if color_number >= 3: color_number = 0 else: color_number += 1 if light_on: hw.pixel_color(current_color[0],current_color[1],current_color[2]) hw.oled_clear() hw.oled_circle(64, 32, 10) hw.oled_circle(64, 32, 12) hw.oled_box(0, 0, 127, 63) hw.oled_line(0, 0, 127, 63) hw.oled_line(0, 63, 127, 0) hw.oled_show() if ((count % 100000) == 0 and light_on): hw.oled_text(str(count), 0, 0) hw.oled_text(str(count), 8, 8) hw.oled_text(str(count), 16, 16) hw.oled_text(str(count), 24, 24) hw.oled_text(str(count), 32, 32) hw.oled_text(str(count), 40, 40) hw.oled_text(str(count), 48, 48) hw.oled_text(str(count), 56, 56) hw.oled_show() count+=1