def cart(): print('Cartesian data test.') def populate_1(func): x = -1 while x < 1.01: yield x, func(x) # x, y x += 0.1 def populate_2(): x = -1 while x < 1.01: yield x, x**2 # x, y x += 0.1 refresh(ssd, True) # Clear any prior image g = CartesianGraph(wri, 2, 2, yorigin=2, fgcolor=WHITE, gridcolor=LIGHTGREEN) # Asymmetric y axis curve1 = Curve(g, YELLOW, populate_1(lambda x: x**3 + x**2 - x, )) # args demo curve2 = Curve(g, RED, populate_2()) refresh(ssd)
def liss(): print('Lissajous figure.') def populate(): t = -math.pi while t <= math.pi: yield math.sin(t), math.cos(3 * t) # x, y t += 0.1 refresh(ssd, True) # Clear any prior image g = CartesianGraph(wri, 2, 2, fgcolor=WHITE, gridcolor=LIGHTGREEN) curve = Curve(g, YELLOW, populate()) refresh(ssd)
def graph(): row, col, ht, wd = 5, 140, 75, 150 def populate(): x = -0.998 while x < 1.01: z = 6 * pi * x y = sin(z) / z yield x, y x += 0.05 g = CartesianGraph(wri, row, col, height=ht, width=wd, bdcolor=False) curve2 = Curve(g, None, populate()) Label(wri, row + ht + 5, col - 10, '-2.0 t: secs') Label(wri, row + ht + 5, col - 8 + int(wd // 2), '0.0') Label(wri, row + ht + 5, col - 10 + wd, '2.0')
def rt_rect(): print('Simulate realtime data acquisition of discontinuous data.') refresh(ssd, True) # Clear any prior image g = CartesianGraph(wri, 2, 2, fgcolor=WHITE, gridcolor=LIGHTGREEN) curve = Curve(g, RED) x = -1 for _ in range(40): y = 0.1 / x if abs(x) > 0.05 else None # Discontinuity curve.point(x, y) utime.sleep_ms(100) refresh(ssd) x += 0.05 g.clear() curve = Curve(g, YELLOW) x = -1 for _ in range(40): y = -0.1 / x if abs(x) > 0.05 else None # Discontinuity curve.point(x, y) utime.sleep_ms(100) refresh(ssd) x += 0.05
def lem(): print('Lemniscate of Bernoulli.') def populate(): t = -math.pi while t <= math.pi + 0.1: x = 0.5 * math.sqrt(2) * math.cos(t) / (math.sin(t)**2 + 1) y = math.sqrt(2) * math.cos(t) * math.sin(t) / (math.sin(t)**2 + 1) yield x, y t += 0.1 refresh(ssd, True) # Clear any prior image Label(wri, 82, 2, 'To infinity and beyond...') g = CartesianGraph(wri, 2, 2, height=75, fgcolor=WHITE, gridcolor=LIGHTGREEN) curve = Curve(g, YELLOW, populate()) refresh(ssd)