def normal(): # Display a stationary message a = 1 b = 0 ##happy=[[0,0,1,1,1,1,0,0],[0,1,0,1,0,0,1,0],[1,0,1,0,0,1,0,1],[1,0,1,0,0,0,0,1],[1,0,1,0,0,0,0,1],[1,0,1,0,0,1,0,1],[0,1,0,1,0,0,1,0],[0,0,1,1,1,1,0,0]] happy = [[b, b, b, b, b, b, b, b], [b, b, a, b, b, b, b, b], [b, a, b, b, b, a, b, b], [b, a, b, b, b, b, b, b], [b, a, b, b, b, b, b, b], [b, a, b, b, b, a, b, b], [b, b, a, b, b, b, b, b], [b, b, b, b, b, b, b, b]] LEDMatrix.gfx_sprite_array(happy, start_x=0, start_y=0, state=GFX_INVERT) LEDMatrix.gfx_scroll_towards(new_graphic=GFX_OFF, repeats=3, speed=5, direction=DIR_L, finish=True) LEDMatrix.gfx_render() time.sleep(1) LEDMatrix.clear_all() while True: for row in cur.fetchall(): mq2 = str(row[0]) mq7 = str(row[1]) mq131 = str(row[2]) mq135 = str(row[3]) mq136 = str(row[4]) pm1 = str(row[5]) pm25 = str(row[6]) pm10 = str(row[7]) print(mq2) print(mq7) print(mq131) print(mq135) print(mq136) LEDMatrix.scroll_message_horiz(["LPG: " + mq2], 1, 5) LEDMatrix.scroll_message_horiz(["CO: " + mq7], 1, 5) LEDMatrix.scroll_message_horiz(["NOx: " + mq131], 1, 5) LEDMatrix.scroll_message_horiz(["HAZ: " + mq135], 1, 5) LEDMatrix.scroll_message_horiz(["H2S: " + mq136], 1, 5) LEDMatrix.scroll_message_horiz(["PM1.0: " + pm1], 1, 5) LEDMatrix.scroll_message_horiz(["PM2.5: " + pm25], 1, 5) LEDMatrix.scroll_message_horiz(["PM10: " + pm10], 1, 5) time.sleep(1) LEDMatrix.clear_all()
def warn(): a = 0 b = 1 sad = [[b, b, b, b, b, b, b, b], [b, a, b, b, b, b, b, b], [b, b, a, b, b, a, b, b], [b, b, a, b, b, b, b, b], [b, b, a, b, b, b, b, b], [b, b, a, b, b, a, b, b], [b, a, b, b, b, b, b, b], [b, b, b, b, b, b, b, b]] LEDMatrix.gfx_sprite_array(sad, start_x=0, start_y=0, state=GFX_INVERT) LEDMatrix.gfx_scroll_towards(new_graphic=GFX_OFF, repeats=3, speed=5, direction=DIR_L, finish=True) LEDMatrix.gfx_render() LEDMatrix.gfx_render() LEDMatrix.gfx_render() time.sleep(1) LEDMatrix.clear_all() LEDMatrix.scroll_message_horiz(["warning"], 1, 5) while True: for row in cur.fetchall(): mq2 = str(row[0]) mq7 = str(row[1]) mq131 = str(row[2]) mq135 = str(row[3]) mq136 = str(row[4]) pm1 = str(row[5]) pm25 = str(row[6]) pm10 = str(row[7]) print(mq2) print(mq7) print(mq131) print(mq135) print(mq136) LEDMatrix.scroll_message_horiz(["LPG: 2100"], 1, 5) time.sleep(1) LEDMatrix.clear_all()
# Rain Effect imgx = [[0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0],[0,1,1,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0],[1,0,0,0,0,1,1,0,1,0,0,0,0,1,1,0,1,0,0,1,0,0,0,0],[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,0,1,0,0,0],[0,1,1,1,1,1,1,0,0,1,0,0,1,1,0,0,1,0,0,0,0,1,0,0],[0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,0,0,1,0,0],[0,0,0,0,0,1,1,0,1,0,0,0,0,1,1,0,1,0,0,0,1,0,0,0],[0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0],[0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,1,1,1,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0],[0,1,1,1,1,1,0,0,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,0],[0,1,0,0,0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R_D, DIR_LD]): LEDMatrix.gfx_effect_wipe(PiLogo[index%2], 3, scroll) time.sleep(0.5) # Scroll another Graphic to screen LEDMatrix.gfx_scroll_towards(PiLogo[0], 1, 3, DIR_L) LEDMatrix.gfx_scroll_towards(PiLogo[1], 2, 4, DIR_U) LEDMatrix.gfx_scroll_towards(PiLogo[1], 3, 5, DIR_R) LEDMatrix.gfx_scroll_towards(PiLogo[0], 1, 6, DIR_D) time.sleep(1) # Display a clock LEDMatrix.gfx_set_all(GFX_OFF) clock = [[0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,1,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]] centerX = 11 # position for the clockhand centerY = 11 clockHandSec = 8 # length of the clockhand clockHandMin = 6 clockHandHour = 5 for s in range(30): sec = int(time.strftime('%S'))*6