parent
c2ff889d0c
commit
827c714daf
@ -1,35 +0,0 @@ |
|||||||
#!/bin/env python3 |
|
||||||
import gex |
|
||||||
|
|
||||||
with gex.Client(gex.TrxRawUSB()) as client: |
|
||||||
# Neopixel strip |
|
||||||
strip = gex.Neopixel(client, 'npx') |
|
||||||
# Load RGB to the strip |
|
||||||
strip.load([0xFF0000, 0x00FF00, 0x0000FF, 0xFF00FF]) |
|
||||||
# |
|
||||||
# # I2C bus |
|
||||||
# i2c = gex.I2C(client, 'i2c') |
|
||||||
# # Read device register |
|
||||||
# print(i2c.read_reg(address=0x76, reg=0xD0)) |
|
||||||
# # Write value to a register |
|
||||||
# i2c.write_reg(address=0x76, reg=0xF4, value=0xFA) |
|
||||||
# |
|
||||||
# # SPI |
|
||||||
# spi = gex.SPI(client, 'spi') |
|
||||||
# # Query slave 0 |
|
||||||
# print(spi.query(0, [0xAA, 0xBB, 0xCC, 0xDD], rlen=2, rskip=4)) |
|
||||||
# # Write slaves 0 and 2 |
|
||||||
# spi.multicast(0b101, [0xDE, 0xAD, 0xBE, 0xEF]) |
|
||||||
# |
|
||||||
# # USART |
|
||||||
# usart = gex.USART(client, 'serial') |
|
||||||
# # Handle received data |
|
||||||
# usart.listen(lambda x: print(x, end='', flush=True)) |
|
||||||
# # Write a string |
|
||||||
# usart.write("AHOJ\r\n") |
|
||||||
# |
|
||||||
# # Digital output (8 pins) |
|
||||||
# display = gex.DOut(client, 'display') |
|
||||||
# display.write(0b10110011) |
|
||||||
# display.toggle(0b00010010) |
|
||||||
|
|
@ -0,0 +1,35 @@ |
|||||||
|
#!/bin/env python3 |
||||||
|
import gex |
||||||
|
import numpy as np |
||||||
|
from matplotlib import pyplot as plt |
||||||
|
|
||||||
|
# frequency response measurement |
||||||
|
|
||||||
|
with gex.Client(gex.TrxRawUSB()) as client: |
||||||
|
dac = gex.DAC(client, 'dac') |
||||||
|
adc = gex.ADC(client, 'adc') |
||||||
|
|
||||||
|
dac.waveform(1, 'SINE') |
||||||
|
adc.set_sample_rate(50000) |
||||||
|
|
||||||
|
table = [] |
||||||
|
|
||||||
|
for i in range(100, 10000, 100): |
||||||
|
dac.set_frequency(1, i) |
||||||
|
data = adc.capture(10000) |
||||||
|
# convert to floats |
||||||
|
samples = data.astype(float) |
||||||
|
amplitude = np.max(samples) - np.min(samples) |
||||||
|
print("%d Hz ... rms %d" % (i, amplitude)) |
||||||
|
table.append(i) |
||||||
|
table.append(amplitude) |
||||||
|
|
||||||
|
dac.dc(1, 0) |
||||||
|
|
||||||
|
t = np.reshape(np.array(table), [int(len(table)/2),2]) |
||||||
|
hz = t[:,0] |
||||||
|
am = t[:,1] |
||||||
|
|
||||||
|
plt.plot(hz, am, 'r-', lw=1) |
||||||
|
plt.grid() |
||||||
|
plt.show() |
@ -0,0 +1,23 @@ |
|||||||
|
#!/bin/env python3 |
||||||
|
import gex |
||||||
|
|
||||||
|
# experiment with the dot matrix driver |
||||||
|
|
||||||
|
with gex.Client(gex.TrxRawUSB()) as client: |
||||||
|
bus = gex.I2C(client, 'i2c') |
||||||
|
addr = 0x61 |
||||||
|
bus.write_reg(addr, 0x00, 0b00011000) # dual matrix |
||||||
|
bus.write_reg(addr, 0x0D, 0b00001110) # 34 mA |
||||||
|
bus.write_reg(addr, 0x19, 64) # set brightness |
||||||
|
# matrix 1 |
||||||
|
bus.write_reg(addr, 0x01, [ |
||||||
|
0xAA, 0x55, 0xAA, 0x55, |
||||||
|
0xAA, 0x55, 0xAA, 0x55 |
||||||
|
]) |
||||||
|
# matrix 2 |
||||||
|
bus.write_reg(addr, 0x0E, [ |
||||||
|
0xFF, 0x00, 0xFF, 0x00, |
||||||
|
0xFF, 0x00, 0xFF, 0x00 |
||||||
|
]) |
||||||
|
# update display |
||||||
|
bus.write_reg(addr, 0x0C, 0x01) |
@ -0,0 +1,11 @@ |
|||||||
|
#!/bin/env python3 |
||||||
|
import gex |
||||||
|
|
||||||
|
# the most basic neopixel demo |
||||||
|
|
||||||
|
with gex.Client(gex.TrxRawUSB()) as client: |
||||||
|
# Neopixel strip |
||||||
|
strip = gex.Neopixel(client, 'npx') |
||||||
|
# Load RGB to the strip |
||||||
|
strip.load([0xFF0000, 0x00FF00, 0x0000FF, 0xFF00FF]) |
||||||
|
|
@ -1,6 +1,14 @@ |
|||||||
import time |
import time |
||||||
import gex |
import gex |
||||||
|
|
||||||
|
# GEX pomodoro timer |
||||||
|
|
||||||
|
# button btn |
||||||
|
# neopixel neo |
||||||
|
|
||||||
|
# this is an example of using GEX as a user interface. |
||||||
|
# for practical use it would be better to make this into a standalone device with a custom firmware. |
||||||
|
|
||||||
WK_TIME = 25 |
WK_TIME = 25 |
||||||
BK_TIME = 5 |
BK_TIME = 5 |
||||||
LIGHT_CNT = 30 |
LIGHT_CNT = 30 |
@ -0,0 +1,37 @@ |
|||||||
|
#!/bin/env python3 |
||||||
|
import time |
||||||
|
|
||||||
|
import gex |
||||||
|
import numpy as np |
||||||
|
from matplotlib import pyplot as plt |
||||||
|
|
||||||
|
from scipy.io import wavfile |
||||||
|
|
||||||
|
# catching a transient |
||||||
|
|
||||||
|
with gex.Client(gex.TrxRawUSB()) as client: |
||||||
|
adc = gex.ADC(client, 'adc') |
||||||
|
|
||||||
|
rate=50000 |
||||||
|
fs = adc.set_sample_rate(rate) |
||||||
|
|
||||||
|
d = None |
||||||
|
|
||||||
|
def x(report): |
||||||
|
global d |
||||||
|
print("capt") |
||||||
|
d = report |
||||||
|
|
||||||
|
adc.on_trigger(x) |
||||||
|
adc.setup_trigger(0, 50, 600, edge='rising', pretrigger=100) |
||||||
|
adc.arm() |
||||||
|
|
||||||
|
time.sleep(2) |
||||||
|
|
||||||
|
if d is not None: |
||||||
|
plt.plot(d.data, 'r-', lw=1) |
||||||
|
plt.grid() |
||||||
|
plt.show() |
||||||
|
else: |
||||||
|
print("Nothing rx") |
||||||
|
|
Loading…
Reference in new issue