parent
634093507f
commit
f3920743aa
@ -1,36 +1,35 @@ |
|||||||
#!/bin/env python3 |
#!/bin/env python3 |
||||||
import gex |
import gex |
||||||
|
|
||||||
client = gex.Client(port='/dev/ttyACM0') |
with gex.Client(gex.TrxRawUSB()) as client: |
||||||
|
# Neopixel strip |
||||||
# Neopixel strip |
strip = gex.Neopixel(client, 'npx') |
||||||
strip = gex.Neopixel(client, 'npx') |
# Load RGB to the strip |
||||||
# Load RGB to the strip |
strip.load([0xFF0000, 0x00FF00, 0x0000FF, 0xFF00FF]) |
||||||
strip.load([0xFF0000, 0x00FF00, 0x0000FF, 0xFF00FF]) |
# |
||||||
|
# # I2C bus |
||||||
# I2C bus |
# i2c = gex.I2C(client, 'i2c') |
||||||
i2c = gex.I2C(client, 'i2c') |
# # Read device register |
||||||
# Read device register |
# print(i2c.read_reg(address=0x76, reg=0xD0)) |
||||||
print(i2c.read_reg(address=0x76, reg=0xD0)) |
# # Write value to a register |
||||||
# Write value to a register |
# i2c.write_reg(address=0x76, reg=0xF4, value=0xFA) |
||||||
i2c.write_reg(address=0x76, reg=0xF4, value=0xFA) |
# |
||||||
|
# # SPI |
||||||
# SPI |
# spi = gex.SPI(client, 'spi') |
||||||
spi = gex.SPI(client, 'spi') |
# # Query slave 0 |
||||||
# Query slave 0 |
# print(spi.query(0, [0xAA, 0xBB, 0xCC, 0xDD], rlen=2, rskip=4)) |
||||||
print(spi.query(0, [0xAA, 0xBB, 0xCC, 0xDD], rlen=2, rskip=4)) |
# # Write slaves 0 and 2 |
||||||
# Write slaves 0 and 2 |
# spi.multicast(0b101, [0xDE, 0xAD, 0xBE, 0xEF]) |
||||||
spi.multicast(0b101, [0xDE, 0xAD, 0xBE, 0xEF]) |
# |
||||||
|
# # USART |
||||||
# USART |
# usart = gex.USART(client, 'serial') |
||||||
usart = gex.USART(client, 'serial') |
# # Handle received data |
||||||
# Handle received data |
# usart.listen(lambda x: print(x, end='', flush=True)) |
||||||
usart.listen(lambda x: print(x, end='', flush=True)) |
# # Write a string |
||||||
# Write a string |
# usart.write("AHOJ\r\n") |
||||||
usart.write("AHOJ\r\n") |
# |
||||||
|
# # Digital output (8 pins) |
||||||
# Digital output (8 pins) |
# display = gex.DOut(client, 'display') |
||||||
display = gex.DOut(client, 'display') |
# display.write(0b10110011) |
||||||
display.write(0b10110011) |
# display.toggle(0b00010010) |
||||||
display.toggle(0b00010010) |
|
||||||
|
|
||||||
|
@ -0,0 +1,28 @@ |
|||||||
|
#!/bin/env python3 |
||||||
|
import time |
||||||
|
|
||||||
|
import gex |
||||||
|
import numpy as np |
||||||
|
from matplotlib import pyplot as plt |
||||||
|
|
||||||
|
from scipy.io import wavfile |
||||||
|
|
||||||
|
with gex.Client(gex.TrxRawUSB()) as client: |
||||||
|
adc = gex.ADC(client, 'a') |
||||||
|
|
||||||
|
adc.set_active_channels([3]) |
||||||
|
rate=44000 |
||||||
|
fs = adc.set_sample_rate(rate) |
||||||
|
|
||||||
|
count = 44000*2 |
||||||
|
data = np.add(adc.capture(count) / 4096, -0.5) |
||||||
|
|
||||||
|
if data is not None: |
||||||
|
# wavfile.write('file.wav', rate, data) |
||||||
|
# print("Ok") |
||||||
|
|
||||||
|
plt.plot(data, 'r-', lw=1) |
||||||
|
plt.show() |
||||||
|
else: |
||||||
|
print("Nothing rx") |
||||||
|
|
Loading…
Reference in new issue